@opensumi/cli-engine 3.6.5-next-1735781723.0 → 3.6.5-next-1735790538.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/browser/browser.js +2 -2
- package/package.json +10 -10
package/lib/browser/browser.js
CHANGED
|
@@ -28180,7 +28180,7 @@ and limitations under the License.
|
|
|
28180
28180
|
`)[0];let a,b=f.match(QUERY_WORD_REGEX)[0];switch(d){case 2:a=new RangeError(`Bad node name '${b}'`);break;case 3:a=new RangeError(`Bad field name '${b}'`);break;case 4:a=new RangeError(`Bad capture name @${b}`);break;case 5:a=new TypeError(`Bad pattern structure at offset ${_}: '${f}'...`),b="";break;default:a=new SyntaxError(`Bad syntax at offset ${_}: '${f}'...`),b=""}throw a.index=_,a.length=b.length,C._free(n),a}const o=C._ts_query_string_count(r),l=C._ts_query_capture_count(r),m=C._ts_query_pattern_count(r),E=new Array(l),p=new Array(o);for(let d=0;d<l;d++){const u=C._ts_query_capture_name_for_id(r,d,TRANSFER_BUFFER),_=getValue(TRANSFER_BUFFER,"i32");E[d]=UTF8ToString(u,_)}for(let d=0;d<o;d++){const u=C._ts_query_string_value_for_id(r,d,TRANSFER_BUFFER),_=getValue(TRANSFER_BUFFER,"i32");p[d]=UTF8ToString(u,_)}const v=new Array(m),s=new Array(m),g=new Array(m),c=new Array(m),h=new Array(m);for(let d=0;d<m;d++){const u=C._ts_query_predicates_for_pattern(r,d,TRANSFER_BUFFER),_=getValue(TRANSFER_BUFFER,"i32");c[d]=[],h[d]=[];const f=[];let a=u;for(let b=0;b<_;b++){const y=getValue(a,"i32");a+=SIZE_OF_INT;const S=getValue(a,"i32");if(a+=SIZE_OF_INT,y===PREDICATE_STEP_TYPE_CAPTURE)f.push({type:"capture",name:E[S]});else if(y===PREDICATE_STEP_TYPE_STRING)f.push({type:"string",value:p[S]});else if(f.length>0){if(f[0].type!=="string")throw new Error("Predicates must begin with a literal value");const A=f[0].value;let w,T=!0,D=!0;switch(A){case"any-not-eq?":case"not-eq?":T=!1;case"any-eq?":case"eq?":if(f.length!==3)throw new Error(`Wrong number of arguments to \`#${A}\` predicate. Expected 2, got ${f.length-1}`);if(f[1].type!=="capture")throw new Error(`First argument of \`#${A}\` predicate must be a capture. Got "${f[1].value}"`);if(D=!A.startsWith("any-"),f[2].type==="capture"){const R=f[1].name,M=f[2].name;h[d].push(k=>{const B=[],x=[];for(const j of k)j.name===R&&B.push(j.node),j.name===M&&x.push(j.node);const N=(j,K,U)=>U?j.text===K.text:j.text!==K.text;return D?B.every(j=>x.some(K=>N(j,K,T))):B.some(j=>x.some(K=>N(j,K,T)))})}else{w=f[1].name;const R=f[2].value,M=B=>B.text===R,k=B=>B.text!==R;h[d].push(B=>{const x=[];for(const j of B)j.name===w&&x.push(j.node);const N=T?M:k;return D?x.every(N):x.some(N)})}break;case"any-not-match?":case"not-match?":T=!1;case"any-match?":case"match?":if(f.length!==3)throw new Error(`Wrong number of arguments to \`#${A}\` predicate. Expected 2, got ${f.length-1}.`);if(f[1].type!=="capture")throw new Error(`First argument of \`#${A}\` predicate must be a capture. Got "${f[1].value}".`);if(f[2].type!=="string")throw new Error(`Second argument of \`#${A}\` predicate must be a string. Got @${f[2].value}.`);w=f[1].name;const I=new RegExp(f[2].value);D=!A.startsWith("any-"),h[d].push(R=>{const M=[];for(const B of R)B.name===w&&M.push(B.node.text);const k=(B,x)=>x?I.test(B):!I.test(B);return M.length===0?!T:D?M.every(B=>k(B,T)):M.some(B=>k(B,T))});break;case"set!":if(f.length<2||f.length>3)throw new Error(`Wrong number of arguments to \`#set!\` predicate. Expected 1 or 2. Got ${f.length-1}.`);if(f.some(R=>R.type!=="string"))throw new Error('Arguments to `#set!` predicate must be a strings.".');v[d]||(v[d]={}),v[d][f[1].value]=f[2]?f[2].value:null;break;case"is?":case"is-not?":if(f.length<2||f.length>3)throw new Error(`Wrong number of arguments to \`#${A}\` predicate. Expected 1 or 2. Got ${f.length-1}.`);if(f.some(R=>R.type!=="string"))throw new Error(`Arguments to \`#${A}\` predicate must be a strings.".`);const O=A==="is?"?s:g;O[d]||(O[d]={}),O[d][f[1].value]=f[2]?f[2].value:null;break;case"not-any-of?":T=!1;case"any-of?":if(f.length<2)throw new Error(`Wrong number of arguments to \`#${A}\` predicate. Expected at least 1. Got ${f.length-1}.`);if(f[1].type!=="capture")throw new Error(`First argument of \`#${A}\` predicate must be a capture. Got "${f[1].value}".`);for(let R=2;R<f.length;R++)if(f[R].type!=="string")throw new Error(`Arguments to \`#${A}\` predicate must be a strings.".`);w=f[1].name;const P=f.slice(2).map(R=>R.value);h[d].push(R=>{const M=[];for(const k of R)k.name===w&&M.push(k.node.text);return M.length===0?!T:M.every(k=>P.includes(k))===T});break;default:c[d].push({operator:A,operands:f.slice(1)})}f.length=0}}Object.freeze(v[d]),Object.freeze(s[d]),Object.freeze(g[d])}return C._free(n),new Query(INTERNAL,r,E,h,c,Object.freeze(v),Object.freeze(s),Object.freeze(g))}static load(t){let e;if(t instanceof Uint8Array)e=Promise.resolve(t);else{const n=t;if(typeof process<"u"&&process.versions&&process.versions.node){const r=__webpack_require__(83078);e=Promise.resolve(r.readFileSync(n))}else e=fetch(n).then(r=>r.arrayBuffer().then(o=>{if(r.ok)return new Uint8Array(o);{const l=new TextDecoder("utf-8").decode(o);throw new Error(`Language.load failed with status ${r.status}.
|
|
28181
28181
|
|
|
28182
28182
|
${l}`)}}))}return e.then(n=>loadWebAssemblyModule(n,{loadAsync:!0})).then(n=>{const r=Object.keys(n),o=r.find(m=>LANGUAGE_FUNCTION_REGEX.test(m)&&!m.includes("external_scanner_"));o||console.log(`Couldn't find language function in WASM file. Symbols:
|
|
28183
|
-
${JSON.stringify(r,null,2)}`);const l=n[o]();return new Language(INTERNAL,l)})}}class LookaheadIterable{constructor(t,e,n){assertInternal(t),this[0]=e,this.language=n}get currentTypeId(){return C._ts_lookahead_iterator_current_symbol(this[0])}get currentType(){return this.language.types[this.currentTypeId]||"ERROR"}delete(){C._ts_lookahead_iterator_delete(this[0]),this[0]=0}resetState(t){return C._ts_lookahead_iterator_reset_state(this[0],t)}reset(t,e){return!!C._ts_lookahead_iterator_reset(this[0],t[0],e)&&(this.language=t,!0)}[Symbol.iterator](){const t=this;return{next:()=>C._ts_lookahead_iterator_next(t[0])?{done:!1,value:t.currentType}:{done:!0,value:""}}}}class Query{constructor(t,e,n,r,o,l,m,E){assertInternal(t),this[0]=e,this.captureNames=n,this.textPredicates=r,this.predicates=o,this.setProperties=l,this.assertedProperties=m,this.refutedProperties=E,this.exceededMatchLimit=!1}delete(){C._ts_query_delete(this[0]),this[0]=0}matches(t,{startPosition:e=ZERO_POINT,endPosition:n=ZERO_POINT,startIndex:r=0,endIndex:o=0,matchLimit:l=4294967295,maxStartDepth:m=4294967295}={}){if(typeof l!="number")throw new Error("Arguments must be numbers");marshalNode(t),C._ts_query_matches_wasm(this[0],t.tree[0],e.row,e.column,n.row,n.column,r,o,l,m);const E=getValue(TRANSFER_BUFFER,"i32"),p=getValue(TRANSFER_BUFFER+SIZE_OF_INT,"i32"),v=getValue(TRANSFER_BUFFER+2*SIZE_OF_INT,"i32"),s=new Array(E);this.exceededMatchLimit=!!v;let g=0,c=p;for(let h=0;h<E;h++){const d=getValue(c,"i32");c+=SIZE_OF_INT;const u=getValue(c,"i32");c+=SIZE_OF_INT;const _=new Array(u);if(c=unmarshalCaptures(this,t.tree,c,_),this.textPredicates[d].every(f=>f(_))){s[g]={pattern:d,captures:_};const f=this.setProperties[d];f&&(s[g].setProperties=f);const a=this.assertedProperties[d];a&&(s[g].assertedProperties=a);const b=this.refutedProperties[d];b&&(s[g].refutedProperties=b),g++}}return s.length=g,C._free(p),s}captures(t,{startPosition:e=ZERO_POINT,endPosition:n=ZERO_POINT,startIndex:r=0,endIndex:o=0,matchLimit:l=4294967295,maxStartDepth:m=4294967295}={}){if(typeof l!="number")throw new Error("Arguments must be numbers");marshalNode(t),C._ts_query_captures_wasm(this[0],t.tree[0],e.row,e.column,n.row,n.column,r,o,l,m);const E=getValue(TRANSFER_BUFFER,"i32"),p=getValue(TRANSFER_BUFFER+SIZE_OF_INT,"i32"),v=getValue(TRANSFER_BUFFER+2*SIZE_OF_INT,"i32"),s=[];this.exceededMatchLimit=!!v;const g=[];let c=p;for(let h=0;h<E;h++){const d=getValue(c,"i32");c+=SIZE_OF_INT;const u=getValue(c,"i32");c+=SIZE_OF_INT;const _=getValue(c,"i32");if(c+=SIZE_OF_INT,g.length=u,c=unmarshalCaptures(this,t.tree,c,g),this.textPredicates[d].every(f=>f(g))){const f=g[_],a=this.setProperties[d];a&&(f.setProperties=a);const b=this.assertedProperties[d];b&&(f.assertedProperties=b);const y=this.refutedProperties[d];y&&(f.refutedProperties=y),s.push(f)}}return C._free(p),s}predicatesForPattern(t){return this.predicates[t]}disableCapture(t){const e=lengthBytesUTF8(t),n=C._malloc(e+1);stringToUTF8(t,n,e+1),C._ts_query_disable_capture(this[0],n,e),C._free(n)}didExceedMatchLimit(){return this.exceededMatchLimit}}function getText(L,t,e){const n=e-t;let r=L.textCallback(t,null,e);for(t+=r.length;t<e;){const o=L.textCallback(t,null,e);if(!(o&&o.length>0))break;t+=o.length,r+=o}return t>e&&(r=r.slice(0,n)),r}function unmarshalCaptures(L,t,e,n){for(let r=0,o=n.length;r<o;r++){const l=getValue(e,"i32"),m=unmarshalNode(t,e+=SIZE_OF_INT);e+=SIZE_OF_NODE,n[r]={name:L.captureNames[l],node:m}}return e}function assertInternal(L){if(L!==INTERNAL)throw new Error("Illegal constructor")}function isPoint(L){return L&&typeof L.row=="number"&&typeof L.column=="number"}function marshalNode(L){let t=TRANSFER_BUFFER;setValue(t,L.id,"i32"),t+=SIZE_OF_INT,setValue(t,L.startIndex,"i32"),t+=SIZE_OF_INT,setValue(t,L.startPosition.row,"i32"),t+=SIZE_OF_INT,setValue(t,L.startPosition.column,"i32"),t+=SIZE_OF_INT,setValue(t,L[0],"i32")}function unmarshalNode(L,t=TRANSFER_BUFFER){const e=getValue(t,"i32");if(e===0)return null;const n=getValue(t+=SIZE_OF_INT,"i32"),r=getValue(t+=SIZE_OF_INT,"i32"),o=getValue(t+=SIZE_OF_INT,"i32"),l=getValue(t+=SIZE_OF_INT,"i32"),m=new Node(INTERNAL,L);return m.id=e,m.startIndex=n,m.startPosition={row:r,column:o},m[0]=l,m}function marshalTreeCursor(L,t=TRANSFER_BUFFER){setValue(t+0*SIZE_OF_INT,L[0],"i32"),setValue(t+1*SIZE_OF_INT,L[1],"i32"),setValue(t+2*SIZE_OF_INT,L[2],"i32"),setValue(t+3*SIZE_OF_INT,L[3],"i32")}function unmarshalTreeCursor(L){L[0]=getValue(TRANSFER_BUFFER+0*SIZE_OF_INT,"i32"),L[1]=getValue(TRANSFER_BUFFER+1*SIZE_OF_INT,"i32"),L[2]=getValue(TRANSFER_BUFFER+2*SIZE_OF_INT,"i32"),L[3]=getValue(TRANSFER_BUFFER+3*SIZE_OF_INT,"i32")}function marshalPoint(L,t){setValue(L,t.row,"i32"),setValue(L+SIZE_OF_INT,t.column,"i32")}function unmarshalPoint(L){return{row:getValue(L,"i32")>>>0,column:getValue(L+SIZE_OF_INT,"i32")>>>0}}function marshalRange(L,t){marshalPoint(L,t.startPosition),marshalPoint(L+=SIZE_OF_POINT,t.endPosition),setValue(L+=SIZE_OF_POINT,t.startIndex,"i32"),setValue(L+=SIZE_OF_INT,t.endIndex,"i32"),L+=SIZE_OF_INT}function unmarshalRange(L){const t={};return t.startPosition=unmarshalPoint(L),L+=SIZE_OF_POINT,t.endPosition=unmarshalPoint(L),L+=SIZE_OF_POINT,t.startIndex=getValue(L,"i32")>>>0,L+=SIZE_OF_INT,t.endIndex=getValue(L,"i32")>>>0,t}function marshalEdit(L){let t=TRANSFER_BUFFER;marshalPoint(t,L.startPosition),t+=SIZE_OF_POINT,marshalPoint(t,L.oldEndPosition),t+=SIZE_OF_POINT,marshalPoint(t,L.newEndPosition),t+=SIZE_OF_POINT,setValue(t,L.startIndex,"i32"),t+=SIZE_OF_INT,setValue(t,L.oldEndIndex,"i32"),t+=SIZE_OF_INT,setValue(t,L.newEndIndex,"i32"),t+=SIZE_OF_INT}for(const L of Object.getOwnPropertyNames(ParserImpl.prototype))Object.defineProperty(Parser.prototype,L,{value:ParserImpl.prototype[L],enumerable:!1,writable:!1});Parser.Language=Language,Module.onRuntimeInitialized=()=>{ParserImpl.init(),resolveInitPromise()}}))}}return Parser}();module.exports=TreeSitter},52730:(L,t,e)=>{"use strict";var n=e(80705),r=e(14834),o=e(28498),l=e(79818),m=e(69336),E=l("Object.prototype.toString"),p=e(51913)(),v=typeof globalThis>"u"?e.g:globalThis,s=r(),g=l("String.prototype.slice"),c=Object.getPrototypeOf,h=l("Array.prototype.indexOf",!0)||function(a,b){for(var y=0;y<a.length;y+=1)if(a[y]===b)return y;return-1},d={__proto__:null};p&&m&&c?n(s,function(f){var a=new v[f];if(Symbol.toStringTag in a){var b=c(a),y=m(b,Symbol.toStringTag);if(!y){var S=c(b);y=m(S,Symbol.toStringTag)}d["$"+f]=o(y.get)}}):n(s,function(f){var a=new v[f],b=a.slice||a.set;b&&(d["$"+f]=o(b))});var u=function(a){var b=!1;return n(d,function(y,S){if(!b)try{"$"+y(a)===S&&(b=g(S,1))}catch{}}),b},_=function(a){var b=!1;return n(d,function(y,S){if(!b)try{y(a),b=g(S,1)}catch{}}),b};L.exports=function(a){if(!a||typeof a!="object")return!1;if(!p){var b=g(E(a),8,-1);return h(s,b)>-1?b:b!=="Object"?!1:_(a)}return m?u(a):null}},79682:(L,t,e)=>{"use strict";var n;Object.defineProperty(t,"__esModule",{value:!0}),t.ChromeDevtoolsContribution=void 0;const r=e(85608),o=e(76003),l=e(41869),m=e(65265),E=e(98295),p=e(27654);let v=n=class extends l.Disposable{constructor(){super(...arguments),this.lantencyHandler=g=>{const{command:c}=g.detail;c===m.DevtoolsLantencyCommand.Start?this.interval||this.startRTTInterval():c===m.DevtoolsLantencyCommand.Stop&&this.interval&&(clearInterval(this.interval),this.interval=void 0)}}initialize(){var g;this.appConfig.devtools&&(window.addEventListener(m.EDevtoolsEvent.Latency,this.lantencyHandler),this.addDispose(l.Disposable.create(()=>{window.removeEventListener(m.EDevtoolsEvent.Latency,this.lantencyHandler),this.interval&&(clearInterval(this.interval),this.interval=void 0)})),!((g=window.__OPENSUMI_DEVTOOLS_GLOBAL_HOOK__)===null||g===void 0)&&g.captureRPC&&(this.interval||this.startRTTInterval()))}startRTTInterval(){this.interval=setInterval(async()=>{const g=Date.now();await this.rttService.measure();const c=Date.now()-g;window.__OPENSUMI_DEVTOOLS_GLOBAL_HOOK__.captureRPC&&(window.__OPENSUMI_DEVTOOLS_GLOBAL_HOOK__.latency=c)},n.INTERVAL)}};t.ChromeDevtoolsContribution=v,v.INTERVAL=1e3,r.__decorate([(0,o.Autowired)(l.AppConfig),r.__metadata("design:type",Object)],v.prototype,"appConfig",void 0),r.__decorate([(0,o.Autowired)(p.ConnectionRTTBrowserServiceToken),r.__metadata("design:type",p.ConnectionRTTBrowserService)],v.prototype,"rttService",void 0),t.ChromeDevtoolsContribution=v=n=r.__decorate([(0,E.Domain)(l.ClientAppContribution)],v)},72915:(L,t,e)=>{"use strict";var n;Object.defineProperty(t,"__esModule",{value:!0}),t.ConnectionRTTContribution=void 0;const r=e(85608),o=e(76003),l=e(26542),m=e(92323),E=e(98295),p=e(27654),v={id:"connection.start.rtt",label:"%connection.start.rtt%",category:"%command.category.developerTools%"},s={id:"connection.stop.rtt",label:"%connection.stop.rtt%",category:"%command.category.developerTools%"},g={alignment:l.StatusBarAlignment.LEFT,priority:1/0-1};let c=n=class{registerCommands(d){d.registerCommand(v,{execute:()=>{this.interval||this.startRTTInterval()}}),d.registerCommand(s,{execute:()=>{this.interval&&(clearInterval(this.interval),this.statusBar&&(this.statusBar.dispose(),this.statusBar=void 0))}})}startRTTInterval(){this.interval=setInterval(async()=>{const d=Date.now();await this.rttService.measure();const _={text:`${Date.now()-d}ms`};if(this.statusBar)this.statusBar.update({..._,...g});else{const f=this.statusBarService.addElement("connection-rtt",{..._,...g});this.statusBar=f}},n.INTERVAL)}};t.ConnectionRTTContribution=c,c.INTERVAL=1e3,r.__decorate([(0,o.Autowired)(l.IStatusBarService),r.__metadata("design:type",Object)],c.prototype,"statusBarService",void 0),r.__decorate([(0,o.Autowired)(p.ConnectionRTTBrowserServiceToken),r.__metadata("design:type",p.ConnectionRTTBrowserService)],c.prototype,"rttService",void 0),t.ConnectionRTTContribution=c=n=r.__decorate([(0,E.Domain)(m.CommandContribution)],c)},27654:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ConnectionRTTBrowserService=t.ConnectionRTTBrowserServiceToken=void 0;const n=e(85608),r=e(76003),o=e(69452);t.ConnectionRTTBrowserServiceToken=Symbol("ConnectionRTTBrowserService");let l=class{async measure(){await this.connectionBackService.$measure()}};t.ConnectionRTTBrowserService=l,n.__decorate([(0,r.Autowired)(o.ConnectionBackServicePath),n.__metadata("design:type",Object)],l.prototype,"connectionBackService",void 0),t.ConnectionRTTBrowserService=l=n.__decorate([(0,r.Injectable)()],l)},17631:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.FileDropContribution=void 0;const n=e(85608),r=e(76003),o=e(41869),l=e(43718),m=e(69452);let E=class extends l.WithEventBus{onDidDropFile(v){this.dropService.onDidDropFile(v)}};t.FileDropContribution=E,n.__decorate([(0,r.Autowired)(m.IFileDropFrontendServiceToken),n.__metadata("design:type",Object)],E.prototype,"dropService",void 0),n.__decorate([(0,l.OnEvent)(l.FileTreeDropEvent),n.__metadata("design:type",Function),n.__metadata("design:paramtypes",[l.FileTreeDropEvent]),n.__metadata("design:returntype",void 0)],E.prototype,"onDidDropFile",null),t.FileDropContribution=E=n.__decorate([(0,r.Injectable)(),(0,o.Domain)(o.ClientAppContribution)],E)},22874:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.FileDropService=void 0;const n=e(85608),r=e(76003),o=e(41869),l=e(26542),m=e(43718),E=e(42933),{Path:p}=m.path,v=e(69452);let s=class extends m.WithEventBus{constructor(){super(...arguments),this.pending=new Set}onDidUploadFileStart(c){this.pending.add(c),this.createOrUpdateStatusBar()}onDidUploadFileEnd(c){this.pending.delete(c),this.createOrUpdateStatusBar()}createOrUpdateStatusBar(c){if(this.pending.size===0){this.uploadStatus&&(this.uploadStatus.dispose(),this.uploadStatus=void 0);return}const h="sumi-upload-file-status",d=(0,o.formatLocalize)("workbench.uploadingFiles",this.pending.size,c||"0 MB"),u={text:d,alignment:l.StatusBarAlignment.RIGHT,tooltip:d,iconClass:"kaitian-icon kticon-cloud-server"};this.uploadStatus?this.uploadStatus.update({id:h,...u}):this.uploadStatus=this.statusBarService.addElement(h,u)}onDidDropFile(c){var h;const{payload:{event:d,targetDir:u}}=c;if(!u||!(!((h=d.dataTransfer)===null||h===void 0)&&h.files)||d.dataTransfer.files.length===0)return;const _=d.dataTransfer.items;let f=0;const a=Date.now(),b=y=>{f+=y;const S=Date.now(),w=`${(f/((S-a)/1e3)/1024/1024).toFixed(2)} MB`;this.createOrUpdateStatusBar(w)};for(const y of _){const S=y.webkitGetAsEntry();this.processFilesEntry(u,S,b)}}async processFilesEntry(c,h,d){if(h.isFile)this.processFileEntry(h,c,d);else{const u=m.Uri.file(new p(c).join(h.fullPath).toString()).toString();await this.fs.createFolder(u),this.processDirEntry(h,c,d)}}toBinaryString(c){let h;const d=c.length;let u="";for(h=0;h<d;h+=1)u+=String.fromCharCode(c[h]);return u}async doUploadFile(c,h,d){var u;const _=new p(h).join(c.name).toString();this.onDidUploadFileStart(_.toString()),await this.fs.createFile(m.Uri.file(_.toString()).toString()),await this.dropService.$ensureFileExist(c.name,h);const f=c.stream().getReader();let a=await f.read();for(;!a.done;)await this.dropService.$writeStream(this.toBinaryString(a.value),c.name,h,a.done),d((u=a.value)===null||u===void 0?void 0:u.byteLength),a=await f.read();a.done&&this.onDidUploadFileEnd(_.toString())}processFileEntry(c,h,d){c.file(u=>{const _=new File([u],c.fullPath,{type:c.type});this.doUploadFile(_,h,d)},()=>{})}processDirEntry(c,h,d){c.createReader().readEntries(_=>{_.forEach(async f=>{this.processFilesEntry(h,f,d)})},()=>{})}};t.FileDropService=s,n.__decorate([(0,r.Autowired)(E.IFileServiceClient),n.__metadata("design:type",Object)],s.prototype,"fs",void 0),n.__decorate([(0,r.Autowired)(v.FileDropServicePath),n.__metadata("design:type",Object)],s.prototype,"dropService",void 0),n.__decorate([(0,r.Autowired)(l.IStatusBarService),n.__metadata("design:type",Object)],s.prototype,"statusBarService",void 0),t.FileDropService=s=n.__decorate([(0,r.Injectable)()],s)},79240:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.FileSearchContribution=t.FileSearchQuickCommandHandler=t.matchLineReg=t.quickGoToSymbol=t.quickFileOpen=void 0,t.getValidateInput=b;const n=e(85608),r=n.__importDefault(e(39050)),o=e(76003),l=e(41869),m=e(26542),E=e(43718),p=e(98295),v=e(54414),s=e(17459),g=e(84660),c=n.__importStar(e(20868)),h=e(97821),d=e(80490),u=e(51500),_=e(30981),f=200;t.quickFileOpen={id:"workbench.action.quickOpen",category:"File",label:"Open File..."},t.quickGoToSymbol={id:"workbench.action.gotoSymbol",category:"File",label:"Open File Symbol..."},t.matchLineReg=/^([^:#(]*)[:#(]?L?(\d+)?[:,]?(\d+)?\)?/;function a(T=""){const D=T.match(t.matchLineReg)||[];if(D.length<2)return;const I={line:Number(D[2]||0),start:Number(D[3]||0)};return new c.Range(I.line,I.start,I.line,I.start)}function b(T){return T.replace(t.matchLineReg,"$1")}let y=class extends h.QuickOpenBaseAction{constructor(){super({id:"file-search:splitToRight",tooltip:(0,l.localize)("quickOpen.openOnTheRightSide"),class:(0,l.getIcon)("embed")})}async run(D){await this.commandService.executeCommand(l.EDITOR_COMMANDS.OPEN_RESOURCE.id,D.getUri(),{preview:!1,split:v.EditorGroupSplitAction.Right,range:a(this.injector.get(A).currentLookFor),focus:!0})}};n.__decorate([(0,o.Autowired)(l.CommandService),n.__metadata("design:type",Object)],y.prototype,"commandService",void 0),n.__decorate([(0,o.Autowired)(o.INJECTOR_TOKEN),n.__metadata("design:type",o.Injector)],y.prototype,"injector",void 0),y=n.__decorate([(0,o.Injectable)(),n.__metadata("design:paramtypes",[])],y);let S=class{hasActions(){return!0}getActions(){return[this.fileSearchActionLeftRight]}getValidateInput(D){return b(D)}};n.__decorate([(0,o.Autowired)(),n.__metadata("design:type",y)],S.prototype,"fileSearchActionLeftRight",void 0),S=n.__decorate([(0,o.Injectable)()],S);let A=class{constructor(){this.cancelIndicator=new E.CancellationTokenSource,this.default=!0,this.prefix="...",this.description=(0,l.localize)("file-search.command.fileOpen.description"),this.prevEditorState={},this.currentLookFor=""}getModel(){return{onType:async(D,I)=>{this.cancelIndicator.cancel(),this.cancelIndicator=new E.CancellationTokenSource;const O=this.cancelIndicator.token,P=new Set;let R=[];D=D.trim().replace(/\s/g,""),this.currentLookFor=D;const M=b(D),k=this.reporterService.time(E.REPORT_NAME.QUICK_OPEN_MEASURE),B=await this.getRecentlyItems(P,M,O);if(D&&(this.logger.debug("lookFor",D,M),R=await this.getFindOutItems(P,M,O)),O.isCancellationRequested)return;const x=B.concat(R);I(x,x.length?this.fileSearchActionProvider:void 0),k.timeEnd(D.indexOf("@")>-1?"file-symbol":"file",{lookFor:D,stat:{recently:B.length,find:R.length}})}}}getOptions(){return{placeholder:(0,l.localize)("file-search.command.fileOpen.placeholder"),fuzzyMatchLabel:{enableSeparateSubstringMatching:!0},showItemsWithoutHighlight:!0,fuzzyMatchDescription:{enableSeparateSubstringMatching:!0},getPlaceholderItem:D=>new l.QuickOpenItem({label:(0,l.localize)(D.indexOf("@")>-1?"search.fileSymbolResults.notfound":"search.fileResults.notfound"),run:()=>!1})}}onClose(D){D&&this.prevEditorState.uri&&(this.workbenchEditorService.open(this.prevEditorState.uri,{range:this.prevEditorState.range}),this.prevEditorState={}),this.prevSelected=void 0,this.commandService.executeCommand(l.EDITOR_COMMANDS.FOCUS.id),this.cancelIndicator.cancel()}onToggle(){this.cancelIndicator.cancel()}trySaveEditorState(){var D;if(this.workbenchEditorService.currentResource){let I={startColumn:1,startLineNumber:1,endColumn:1,endLineNumber:1};const O=(D=this.workbenchEditorService.currentEditor)===null||D===void 0?void 0:D.getSelections();if(O){const{selectionStartLineNumber:P,selectionStartColumn:R,positionLineNumber:M,positionColumn:k}=O[0];I=new c.Range(P,R,M,k)}this.prevEditorState={uri:this.workbenchEditorService.currentResource.uri,range:I}}}async getFindOutItems(D,I,O){var P;let R;if(I.indexOf("@")>-1){this.trySaveEditorState(),R=[];const[M,k]=I.split("@");let B;if(this.prevSelected)B=this.prevSelected.withoutFragment();else if(M){const x=await this.getQueryFiles(M,D,O);x.length&&(B=x[0].getUri())}else B=(P=this.workbenchEditorService.currentResource)===null||P===void 0?void 0:P.uri;if(B){const x=await this.documentSymbolStore.getDocumentSymbolAsync(B)||[],N=[];this.flattenSymbols({children:x},N),R=N.filter(K=>{const U=(0,_.matchesFuzzy)(k,K.name,!0)||[];return U&&(K.labelHighlights=U),U&&U.length}).map((K,U)=>{var X;return new l.QuickOpenItem({uri:B,label:K.name,iconClass:(0,l.getSymbolIcon)(K.kind),description:(X=K.parent)===null||X===void 0?void 0:X.name,labelHighlights:K.labelHighlights,groupLabel:U===0?(0,l.formatLocalize)("search.fileSymbolResults",N.length):"",showBorder:!1,run:z=>z===l.Mode.PREVIEW?(this.locateSymbol(B,K),!0):z===l.Mode.OPEN?(this.locateSymbol(B,K),!0):!1})})}else return[]}else if(R=await this.getQueryFiles(I,D,O),R[0]){const M=await this.getItems([R[0].getUri().codeUri.fsPath],{groupLabel:(0,l.localize)("search.fileResults"),showBorder:!0});R[0]=M[0]}return R}async getQueryFiles(D,I,O){const R=(await this.workspaceService.roots).map(B=>new l.URI(B.uri).codeUri.fsPath),M=await this.fileSearchService.find(D,{rootUris:R,fuzzyMatch:!0,limit:f,useGitIgnore:!0,noIgnoreParent:!0,excludePatterns:this.getPreferenceSearchExcludes()},O),k=await this.getItems(M.filter(B=>I.has(B)||O.isCancellationRequested?!1:(I.add(B),!0)),{});return k.sort(this.compareItems.bind(this)),k}async flattenSymbols(D,I){D.children.forEach(O=>{I.push(O),O.children&&this.flattenSymbols(O,I)})}async getRecentlyItems(D,I,O){const P=await this.recentFilesManager.getMostRecentlyOpenedFiles(!0)||[];return await this.getItems(P.filter(R=>{const M=new l.URI(R);return D.has(R)||!r.default.test(I,M.displayName)||O.isCancellationRequested?!1:(D.add(R),!0)}),{groupLabel:(0,l.localize)("search.historyMatches")})}async getItems(D,I){const O=[];for(const[P,R]of D.entries()){const M=l.URI.isUriString(R)?new l.URI(R):l.URI.file(R),k=`file-icon ${this.labelService.getIcon(M.withoutFragment())}`;let B="";const x=await this.workspaceService.asRelativePath(M.parent);x&&(this.workspaceService.isMultiRootWorkspaceOpened?B=`${new l.URI(x.root).displayName}${x.path?` \u30FB ${x.path}`:""}`:B=x.path||"");const N=new l.QuickOpenItem({uri:M,label:M.displayName,tooltip:R,iconClass:k,description:B,groupLabel:P===0?I.groupLabel:"",showBorder:D.length>0&&P===0?I.showBorder:!1,run:j=>(j===l.Mode.PREVIEW&&(this.prevSelected=M),j===l.Mode.OPEN?(this.openFile(M),!0):!1)});O.push(N)}return O}openFile(D){const I=D.codeUri.fsPath;let O=a(this.currentLookFor);(!O||!O.startLineNumber&&!O.startColumn)&&(O=a(D.fragment?"#"+D.fragment:I)),this.currentLookFor="",this.commandService.executeCommand(l.EDITOR_COMMANDS.OPEN_RESOURCE.id,D.withoutFragment(),{preview:!1,range:O,focus:!0})}locateSymbol(D,I){this.workbenchEditorService.open(D,{range:I.range,preview:!0})}compareItems(D,I,O="getLabel"){function P(j){return j.trim().toLowerCase()}const R=P(b(this.currentLookFor));function M(j){const K=r.default.match(R,j);return K===null?0:K.score}let k=D[O](),B=I[O]();typeof k!="string"&&(k=k.path.toString()),typeof B!="string"&&(B=B.path.toString()),k=P(k),B=P(B);const x=M(k),N=M(B);if(x===N){const j=k.indexOf(R),K=B.indexOf(R);return j===K?k.length!==B.length?k.length<B.length?-1:1:B.localeCompare(k)===0?O==="getUri"?0:this.compareItems(D,I,"getUri"):B.localeCompare(k):j-K}return N-x}getPreferenceSearchExcludes(){const D=[],I=this.preferenceService.get("files.exclude"),O=this.preferenceService.get("search.exclude"),P=Object.assign({},I,O);for(const R of Object.keys(P))P[R]&&D.push(R);return D}};t.FileSearchQuickCommandHandler=A,n.__decorate([(0,o.Autowired)(l.CommandService),n.__metadata("design:type",Object)],A.prototype,"commandService",void 0),n.__decorate([(0,o.Autowired)(g.FileSearchServicePath),n.__metadata("design:type",Object)],A.prototype,"fileSearchService",void 0),n.__decorate([(0,o.Autowired)(v.WorkbenchEditorService),n.__metadata("design:type",v.WorkbenchEditorService)],A.prototype,"workbenchEditorService",void 0),n.__decorate([(0,o.Autowired)(s.DocumentSymbolStore),n.__metadata("design:type",s.DocumentSymbolStore)],A.prototype,"documentSymbolStore",void 0),n.__decorate([(0,o.Autowired)(),n.__metadata("design:type",m.LabelService)],A.prototype,"labelService",void 0),n.__decorate([(0,o.Autowired)(u.IWorkspaceService),n.__metadata("design:type",Object)],A.prototype,"workspaceService",void 0),n.__decorate([(0,o.Autowired)(l.RecentFilesManager),n.__metadata("design:type",l.RecentFilesManager)],A.prototype,"recentFilesManager",void 0),n.__decorate([(0,o.Autowired)(l.ILogger),n.__metadata("design:type",Object)],A.prototype,"logger",void 0),n.__decorate([(0,o.Autowired)(),n.__metadata("design:type",S)],A.prototype,"fileSearchActionProvider",void 0),n.__decorate([(0,o.Autowired)(l.PreferenceService),n.__metadata("design:type",Object)],A.prototype,"preferenceService",void 0),n.__decorate([(0,o.Autowired)(E.IReporterService),n.__metadata("design:type",Object)],A.prototype,"reporterService",void 0),t.FileSearchQuickCommandHandler=A=n.__decorate([(0,o.Injectable)()],A);let w=class{registerQuickOpenHandlers(D){D.registerHandler(this.fileSearchQuickCommandHandler,{title:(0,l.localize)("quickopen.tab.file"),commandId:t.quickFileOpen.id,order:1})}registerCommands(D){D.registerCommand(t.quickFileOpen,{execute:()=>this.quickOpenService.open("...")}),D.registerCommand(t.quickGoToSymbol,{execute:()=>this.quickOpenService.open("...@")})}registerKeybindings(D){D.registerKeybinding({command:t.quickFileOpen.id,keybinding:"ctrlcmd+p"})}};t.FileSearchContribution=w,n.__decorate([(0,o.Autowired)(A),n.__metadata("design:type",A)],w.prototype,"fileSearchQuickCommandHandler",void 0),n.__decorate([(0,o.Autowired)(h.PrefixQuickOpenService),n.__metadata("design:type",Object)],w.prototype,"quickOpenService",void 0),t.FileSearchContribution=w=n.__decorate([(0,p.Domain)(E.CommandContribution,l.KeybindingContribution,d.QuickOpenContribution)],w)},73827:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ClientAddonModule=void 0;const n=e(85608),r=e(76003),o=e(41869),l=e(69452),m=e(79682),E=e(72915),p=e(27654),v=e(17631),s=e(22874),g=e(79240),c=e(18256),h=e(7756),d=e(16426);let u=class extends o.BrowserModule{constructor(){super(...arguments),this.providers=[m.ChromeDevtoolsContribution,c.LanguageChangeHintContribution,g.FileSearchContribution,h.StatusBarContribution,d.ToolbarCustomizeContribution,v.FileDropContribution,E.ConnectionRTTContribution,{token:l.IFileDropFrontendServiceToken,useClass:s.FileDropService},{token:p.ConnectionRTTBrowserServiceToken,useClass:p.ConnectionRTTBrowserService}],this.backServices=[{servicePath:l.FileDropServicePath},{servicePath:l.ConnectionBackServicePath}]}};t.ClientAddonModule=u,t.ClientAddonModule=u=n.__decorate([(0,r.Injectable)()],u)},18256:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.LanguageChangeHintContribution=void 0;const n=e(85608),r=e(76003),o=e(41869),l=e(72665);let m=class{onStart(){this.preferenceService.onSpecificPreferenceChange(o.GeneralSettingsId.Language,async p=>{(0,o.setLanguageId)(p.newValue),this.preferenceService.get("general.askReloadOnLanguageChange")&&await this.dialogService.info((0,o.localize)("preference.general.language.change.refresh.info","After changing the language, it should be restarted to take effect. Will it be refreshed immediately?"),[(0,o.localize)("preference.general.language.change.refresh.later","Later"),(0,o.localize)("preference.general.language.change.refresh.now","Now")])===(0,o.localize)("preference.general.language.change.refresh.now","Now")&&this.clientApp.fireOnReload()})}};t.LanguageChangeHintContribution=m,n.__decorate([(0,r.Autowired)(o.PreferenceService),n.__metadata("design:type",Object)],m.prototype,"preferenceService",void 0),n.__decorate([(0,r.Autowired)(o.IClientApp),n.__metadata("design:type",Object)],m.prototype,"clientApp",void 0),n.__decorate([(0,r.Autowired)(l.IDialogService),n.__metadata("design:type",Object)],m.prototype,"dialogService",void 0),t.LanguageChangeHintContribution=m=n.__decorate([(0,o.Domain)(o.ClientAppContribution)],m)},7756:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.StatusBarContribution=void 0;const n=e(85608),r=e(76003),o=e(41869),l=e(43718);let m=class extends l.WithEventBus{onStart(){}handleBrowserConnectionOpen(){this.commandService.executeCommand("statusbar.changeBackgroundColor","var(--statusBar-background)"),this.logger.log("Browser connection open, change status bar background color")}handleBrowserConnectionClose(){this.commandService.executeCommand("statusbar.changeBackgroundColor","var(--kt-statusbar-offline-background)"),this.logger.log("Browser connection close, change status bar background color")}};t.StatusBarContribution=m,n.__decorate([(0,r.Autowired)(l.CommandService),n.__metadata("design:type",Object)],m.prototype,"commandService",void 0),n.__decorate([(0,r.Autowired)(l.ILogger),n.__metadata("design:type",Object)],m.prototype,"logger",void 0),n.__decorate([(0,l.OnEvent)(l.BrowserConnectionOpenEvent),n.__metadata("design:type",Function),n.__metadata("design:paramtypes",[]),n.__metadata("design:returntype",void 0)],m.prototype,"handleBrowserConnectionOpen",null),n.__decorate([(0,l.OnEvent)(l.BrowserConnectionCloseEvent),n.__metadata("design:type",Function),n.__metadata("design:paramtypes",[]),n.__metadata("design:returntype",void 0)],m.prototype,"handleBrowserConnectionClose",null),t.StatusBarContribution=m=n.__decorate([(0,l.Domain)(o.ClientAppContribution)],m)},16426:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ToolbarCustomizeContribution=void 0;const n=e(85608),r=e(76003),o=e(41869),l=e(93899),m=e(62132);let E=class{registerCommands(v){v.registerCommand({id:"toolbar.showCustomizePanel",label:"Show Toolbar Customization"},{execute:()=>{this.viewService.setVisible(!0)}})}registerComponent(v){v.register("addon/toolbar-customize",{id:"addon/toolbar-customize",component:m.ToolbarCustomizeComponent}),this.config.layoutConfig[o.SlotLocation.extra]||(this.config.layoutConfig[o.SlotLocation.extra]={modules:[]}),this.config.layoutConfig[o.SlotLocation.extra].modules.push("addon/toolbar-customize")}registerMenus(v){v.registerMenuItem(l.MenuId.KTToolbarLocationContext,{command:{id:"toolbar.showCustomizePanel",label:(0,o.localize)("toolbar.customize.menu")}})}};t.ToolbarCustomizeContribution=E,n.__decorate([(0,r.Autowired)(o.AppConfig),n.__metadata("design:type",Object)],E.prototype,"config",void 0),n.__decorate([(0,r.Autowired)(m.ToolbarCustomizeViewService),n.__metadata("design:type",m.ToolbarCustomizeViewService)],E.prototype,"viewService",void 0),t.ToolbarCustomizeContribution=E=n.__decorate([(0,o.Domain)(o.CommandContribution,o.ComponentContribution,l.MenuContribution)],E)},62132:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ToolbarCustomizeComponent=t.ToolbarCustomizeViewService=void 0;const n=e(85608),r=n.__importDefault(e(14041)),o=e(76003),l=e(97267),m=e(41869),E=n.__importDefault(e(18541));let p=class{bindSetVisibleHandle(g){this._setVisible=g}setVisible(g){this._setVisible(g)}async toggleActionVisibility(g,c,h){const d=this.preferenceService.getValid("toolbar.ignoreActions",{});if(d[g]||(d[g]=[]),!h)d[g].indexOf(c)===-1&&d[g].push(c);else{const _=d[g].indexOf(c);_!==-1&&d[g].splice(_,1)}const u=this.preferenceService.inspect("toolbar.ignoreActions").workspaceValue?m.PreferenceScope.Workspace:m.PreferenceScope.User;await this.preferenceService.set("toolbar.ignoreActions",d,u)}};t.ToolbarCustomizeViewService=p,n.__decorate([(0,o.Autowired)(m.PreferenceService),n.__metadata("design:type",Object)],p.prototype,"preferenceService",void 0),t.ToolbarCustomizeViewService=p=n.__decorate([(0,o.Injectable)()],p);const v=()=>{const[s,g]=r.default.useState(!1),c=(0,m.useInjectable)(p),h=(0,m.useInjectable)(m.IToolbarRegistry),d=(0,m.useInjectable)(m.PreferenceService);if(c.bindSetVisibleHandle(g),!s)return null;const u=h.getAllLocations(),_=d.get("toolbar.ignoreActions")||{};let f=d.get("toolbar.buttonDisplay","iconAndText");function a(b){const y=[{id:"_head"},...h.getActionGroups(b)||[],{id:"_tail"}],S=[],A=_[b]||[];return y.forEach((w,T)=>{const D=h.getToolbarActions({location:b,group:w.id});D&&D.actions.length>0&&(S.length>0&&S.push(r.default.createElement("div",{className:E.default["group-split"],key:"split-"+T})),D.actions.forEach((I,O)=>{var P;let R=A.indexOf(I.id)===-1;const M="action-toggle-"+I.id;S.push(r.default.createElement("div",{className:E.default["action-item"],key:O+"_"+I.id},r.default.createElement(l.CheckBox,{onChange:()=>{c.toggleActionVisibility(b,I.id,!R),R=!R},defaultChecked:R,id:M,label:(P=I.description)!==null&&P!==void 0?P:I.id})))}))}),S.length===0?null:r.default.createElement("div",{key:b,className:E.default["toolbar-customize-location"]},S)}return r.default.createElement("div",{className:E.default["toolbar-customize-overlay"]},r.default.createElement("div",{className:E.default["toolbar-customize"]},u.map(b=>a(b)),r.default.createElement("div",{className:E.default["button-display"]},r.default.createElement("div",null,(0,m.localize)("toolbar-customize.buttonDisplay.description")),r.default.createElement(l.Select,{options:[{label:(0,m.localize)("toolbar-customize.buttonDisplay.icon"),value:"icon"},{label:(0,m.localize)("toolbar-customize.buttonDisplay.iconAndText"),value:"iconAndText"}],value:f,onChange:b=>{const y=d.inspect("toolbar.buttonDisplay").workspaceValue?m.PreferenceScope.Workspace:m.PreferenceScope.User;d.set("toolbar.buttonDisplay",b,y),f=b},className:E.default["button-display-select"]})),r.default.createElement("div",{className:E.default["customize-complete"]},r.default.createElement(l.Button,{type:"primary",onClick:()=>g(!1)},(0,m.localize)("toolbar-customize.complete")))))};t.ToolbarCustomizeComponent=v},69452:(L,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.IConnectionBackService=t.ConnectionBackServicePath=t.IFileDropFrontendServiceToken=t.IFileDropServiceToken=t.FileDropServicePath=void 0,t.FileDropServicePath="FileDropServicePath",t.IFileDropServiceToken=Symbol("IFileDropService"),t.IFileDropFrontendServiceToken=Symbol("IFileDropFrontendService"),t.ConnectionBackServicePath="ConnectionBackServicePath",t.IConnectionBackService=Symbol("IConnectionBackService")},77659:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AINativeContextKey=void 0;const n=e(85608),r=e(76003),o=e(41869),l=e(50394);let m=class{get contextKeyService(){return this._contextKeyService}constructor(p){this._contextKeyService=this.globalContextKeyService.createScoped(p),this.inlineChatIsVisible=l.InlineChatIsVisible.bind(this._contextKeyService),this.inlineCompletionIsTrigger=l.InlineCompletionIsTrigger.bind(this._contextKeyService),this.inlineHintWidgetIsVisible=l.InlineHintWidgetIsVisible.bind(this._contextKeyService),this.inlineInputWidgetIsVisible=l.InlineInputWidgetIsVisible.bind(this._contextKeyService),this.inlineDiffPartialEditsIsVisible=l.InlineDiffPartialEditsIsVisible.bind(this._contextKeyService),this.multiLineEditsIsVisible=l.MultiLineEditsIsVisible.bind(this._contextKeyService)}};t.AINativeContextKey=m,n.__decorate([(0,r.Autowired)(o.IContextKeyService),n.__metadata("design:type",Object)],m.prototype,"globalContextKeyService",void 0),t.AINativeContextKey=m=n.__decorate([(0,r.Injectable)(),n.__param(0,(0,r.Optional)()),n.__metadata("design:paramtypes",[Object])],m)},32016:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AINativeBrowserContribution=void 0;const n=e(85608),r=e(76003),o=e(41869),l=e(57925),m=e(50394),E=e(1149),p=e(97222),v=e(43718),s=e(82353),g=e(57517),c=e(63067),h=e(46507),d=e(97682),u=e(68415),_=e(96640),f=e(19413),a=e(51081),b=e(76154),y=e(79559),S=e(57232),A=e(72991),w=e(71863),T=e(7511),D=e(42911),I=e(72801),O=e(87817),P=e(4972),R=e(82983),M=e(77633),k=e(51221),B=e(2281),x=e(31031),N=e(38890),j=e(77886),K=e(89060),U=e(74353),X=e(22169),z=e(90058);let Q=class{constructor(){this.registerFeature()}initialize(){const{supportsChatAssistant:Z}=this.aiNativeConfigService.capabilities;Z&&(o.ComponentRegistryImpl.addLayoutModule(this.appConfig.layoutConfig,f.AI_CHAT_VIEW_ID,f.AI_CHAT_CONTAINER_ID),o.ComponentRegistryImpl.addLayoutModule(this.appConfig.layoutConfig,s.DESIGN_MENU_BAR_RIGHT,f.AI_CHAT_LOGO_AVATAR_ID),this.chatProxyService.registerDefaultAgent())}registerEditorExtensionContribution(Z){const{supportsInlineChat:G,supportsInlineCompletion:H,supportsProblemFix:$}=this.aiNativeConfigService.capabilities;Z(N.InlineDiffController.ID,new _.SyncDescriptor(N.InlineDiffController,[this.injector]),d.EditorContributionInstantiation.Lazy),G&&(Z(z.SumiLightBulbWidget.ID,z.SumiLightBulbWidget,d.EditorContributionInstantiation.Lazy),Z(k.InlineChatEditorController.ID,new _.SyncDescriptor(k.InlineChatEditorController,[this.injector]),d.EditorContributionInstantiation.BeforeFirstInteraction),this.inlineChatFeatureRegistry.getInteractiveInputHandler()&&(Z(j.InlineHintController.ID,new _.SyncDescriptor(j.InlineHintController,[this.injector]),d.EditorContributionInstantiation.AfterFirstRender),Z(K.InlineInputController.ID,new _.SyncDescriptor(K.InlineInputController,[this.injector]),d.EditorContributionInstantiation.AfterFirstRender))),H&&(Z(T.IntelligentCompletionsController.ID,new _.SyncDescriptor(T.IntelligentCompletionsController,[this.injector]),d.EditorContributionInstantiation.AfterFirstRender),Z(A.InlineCompletionsController.ID,new _.SyncDescriptor(A.InlineCompletionsController,[this.injector]),d.EditorContributionInstantiation.AfterFirstRender)),$&&Z(D.ProblemFixController.ID,new _.SyncDescriptor(D.ProblemFixController,[this.injector]),d.EditorContributionInstantiation.AfterFirstRender)}onDidStart(){(0,v.runWhenIdle)(()=>{const{supportsRenameSuggestions:Z,supportsInlineChat:G}=this.aiNativeConfigService.capabilities,H=this.preferenceService.getValid(o.AINativeSettingSectionsId.ChatVisibleType);H==="always"?this.commandService.executeCommand(l.AI_CHAT_VISIBLE.id,!0):H==="never"&&this.commandService.executeCommand(l.AI_CHAT_VISIBLE.id,!1),Z&&this.renameSingleHandler.load(),G&&this.codeActionSingleHandler.load()})}registerFeature(){this.contributions.getContributions().forEach(Z=>{var G,H,$,J,re,ce,he,Ae;(G=Z.registerInlineChatFeature)===null||G===void 0||G.call(Z,this.inlineChatFeatureRegistry),(H=Z.registerChatFeature)===null||H===void 0||H.call(Z,this.chatFeatureRegistry),($=Z.registerResolveConflictFeature)===null||$===void 0||$.call(Z,this.resolveConflictRegistry),(J=Z.registerRenameProvider)===null||J===void 0||J.call(Z,this.renameCandidatesProviderRegistry),(re=Z.registerChatRender)===null||re===void 0||re.call(Z,this.chatRenderRegistry),(ce=Z.registerTerminalProvider)===null||ce===void 0||ce.call(Z,this.terminalProviderRegistry),(he=Z.registerIntelligentCompletionFeature)===null||he===void 0||he.call(Z,this.intelligentCompletionsRegistry),(Ae=Z.registerProblemFixFeature)===null||Ae===void 0||Ae.call(Z,this.problemFixProviderRegistry)})}registerSetting(Z){Z.registerSettingGroup({id:o.AI_NATIVE_SETTING_GROUP_ID,title:v.AI_NATIVE_SETTING_GROUP_TITLE,iconClass:(0,o.getIcon)("magic-wand")}),Z.registerSettingSection(o.AI_NATIVE_SETTING_GROUP_ID,{title:(0,o.localize)("preference.ai.native.chat.title"),preferences:[{id:o.AINativeSettingSectionsId.ChatVisibleType,localized:"preference.ai.native.chat.visible.type"}]}),Z.registerSettingSection(o.AI_NATIVE_SETTING_GROUP_ID,{title:(0,o.localize)("preference.ai.native.interface.quick.title"),preferences:[{id:o.AINativeSettingSectionsId.InterfaceQuickNavigationEnabled,localized:"preference.ai.native.interface.quick.navigation"}]}),this.aiNativeConfigService.capabilities.supportsInlineCompletion&&(Z.registerSettingSection(o.AI_NATIVE_SETTING_GROUP_ID,{title:(0,o.localize)("preference.ai.native.intelligentCompletions.title"),preferences:[{id:o.AINativeSettingSectionsId.IntelligentCompletionsCacheEnabled,localized:"preference.ai.native.intelligentCompletions.cache.enabled"},{id:o.AINativeSettingSectionsId.IntelligentCompletionsDebounceTime,localized:"preference.ai.native.intelligentCompletions.debounceTime"},{id:o.AINativeSettingSectionsId.IntelligentCompletionsPromptEngineeringEnabled,localized:"preference.ai.native.intelligentCompletions.promptEngineering.enabled"},{id:o.AINativeSettingSectionsId.IntelligentCompletionsAlwaysVisible,localized:"preference.ai.native.intelligentCompletions.alwaysVisible"}]}),Z.registerSettingSection(o.AI_NATIVE_SETTING_GROUP_ID,{title:(0,o.localize)("preference.ai.native.codeEdits.title"),preferences:[{id:o.AINativeSettingSectionsId.CodeEditsLintErrors,localized:"preference.ai.native.codeEdits.lintErrors"},{id:o.AINativeSettingSectionsId.CodeEditsLineChange,localized:"preference.ai.native.codeEdits.lineChange"}]})),this.aiNativeConfigService.capabilities.supportsInlineChat&&Z.registerSettingSection(o.AI_NATIVE_SETTING_GROUP_ID,{title:(0,o.localize)("preference.ai.native.inlineChat.title"),preferences:[{id:o.AINativeSettingSectionsId.InlineChatAutoVisible,localized:"preference.ai.native.inlineChat.auto.visible"},{id:o.AINativeSettingSectionsId.InlineChatCodeActionEnabled,localized:"preference.ai.native.inlineChat.codeAction.enabled"},{id:o.AINativeSettingSectionsId.InlineDiffPreviewMode,localized:"preference.ai.native.inlineDiff.preview.mode"}]})}registerEditorFeature(Z){Z.registerEditorFeatureContribution({contribute:G=>{const{monacoEditor:H}=G;return this.codeActionSingleHandler.mountEditor(G.monacoEditor),H.onDidScrollChange(()=>{this.ctxMenuRenderer.visible&&this.ctxMenuRenderer.hide(!0)})}})}registerCommands(Z){Z.registerCommand(l.AI_INLINE_CHAT_VISIBLE,{execute:G=>{this.aiInlineChatService._onInlineChatVisible.fire(G)}}),Z.registerCommand(l.AI_INLINE_CHAT_INTERACTIVE_INPUT_VISIBLE,{execute:G=>{G?this.inlineInputChatService.visible():this.inlineInputChatService.hide(),this.aiInlineChatService._onInteractiveInputVisible.fire(G)}}),Z.registerCommand(l.AI_INLINE_COMPLETION_REPORTER,{execute:(G,H,$,J)=>{this.aiCompletionsService.report({sessionId:H,accept:$,relationId:G,code:J})}}),Z.registerCommand(l.AI_CHAT_VISIBLE,{execute:G=>{this.layoutService.toggleSlot(f.AI_CHAT_VIEW_ID,(0,v.isUndefined)(G)?!0:G)}}),Z.registerCommand(l.AI_INLINE_COMPLETION_VISIBLE,{execute:async G=>{G||(this.aiCompletionsService.hideStatusBarItem(),this.aiInlineCompletionsProvider.setVisibleCompletion(!1),this.aiInlineCompletionsProvider.cancelRequest())}}),Z.registerCommand(l.AI_INLINE_DIFF_PARTIAL_EDIT,{execute:G=>{this.inlineStreamDiffService.launchAcceptDiscardPartialEdit(G)}}),Z.afterExecuteCommand(u.HideInlineCompletion.ID,()=>{this.commandService.executeCommand(l.AI_INLINE_COMPLETION_VISIBLE.id,!1)})}registerRenderer(Z){this.designLayoutConfig.supportExternalChatPanel?Z.registerSlotRenderer(f.AI_CHAT_VIEW_ID,P.AIChatTabRendererWithTab):Z.registerSlotRenderer(f.AI_CHAT_VIEW_ID,P.AIChatTabRenderer),this.designLayoutConfig.useMergeRightWithLeftPanel&&(Z.registerSlotRenderer(o.SlotLocation.left,P.AILeftTabRenderer),Z.registerSlotRenderer(o.SlotLocation.right,P.AIRightTabRenderer))}registerComponent(Z){Z.register(f.AI_CHAT_CONTAINER_ID,[],{component:b.AIChatView,title:(0,o.localize)("aiNative.chat.ai.assistant.name"),iconClass:(0,o.getIcon)("magic-wand"),containerId:f.AI_CHAT_CONTAINER_ID}),Z.register(f.AI_MENU_BAR_DEBUG_TOOLBAR,{id:f.AI_MENU_BAR_DEBUG_TOOLBAR,component:O.AIRunToolbar}),Z.register(f.AI_CHAT_LOGO_AVATAR_ID,{id:f.AI_CHAT_LOGO_AVATAR_ID,component:R.AIChatLogoAvatar})}registerKeybindings(Z){this.aiNativeConfigService.capabilities.supportsInlineChat&&(Z.registerKeybinding({command:l.AI_INLINE_CHAT_VISIBLE.id,keybinding:"ctrlcmd+i",when:"editorTextFocus",args:!0,priority:0},o.KeybindingScope.USER),Z.registerKeybinding({command:l.AI_INLINE_CHAT_VISIBLE.id,keybinding:"esc",args:!1,when:`editorFocus && ${m.InlineChatIsVisible.raw}`}),this.inlineChatFeatureRegistry.getInteractiveInputHandler()&&(Z.registerKeybinding({command:l.AI_INLINE_CHAT_INTERACTIVE_INPUT_VISIBLE.id,keybinding:"ctrlcmd+k",args:!0,priority:0,when:`editorFocus && ${m.InlineChatIsVisible.raw}`},o.KeybindingScope.USER),Z.registerKeybinding({command:l.AI_INLINE_CHAT_INTERACTIVE_INPUT_VISIBLE.id,keybinding:"esc",args:!1,priority:0,when:`editorFocus && ${m.InlineInputWidgetIsVisible.raw}`}),Z.registerKeybinding({command:l.AI_INLINE_CHAT_INTERACTIVE_INPUT_VISIBLE.id,keybinding:"ctrlcmd+k",args:!0,priority:0,when:`editorFocus && ${m.InlineHintWidgetIsVisible.raw} && ${m.InlineChatIsVisible.not}`},o.KeybindingScope.USER))),Z.registerKeybinding({command:l.AI_INLINE_DIFF_PARTIAL_EDIT.id,keybinding:"ctrl+y",args:!0,priority:100,when:`editorTextFocus && ${m.InlineDiffPartialEditsIsVisible.raw}`}),Z.registerKeybinding({command:l.AI_INLINE_DIFF_PARTIAL_EDIT.id,keybinding:"ctrl+n",args:!1,priority:100,when:`editorTextFocus && ${m.InlineDiffPartialEditsIsVisible.raw}`})}};t.AINativeBrowserContribution=Q,n.__decorate([(0,r.Autowired)(o.AppConfig),n.__metadata("design:type",Object)],Q.prototype,"appConfig",void 0),n.__decorate([(0,r.Autowired)(r.INJECTOR_TOKEN),n.__metadata("design:type",r.Injector)],Q.prototype,"injector",void 0),n.__decorate([(0,r.Autowired)(p.IBrowserCtxMenu),n.__metadata("design:type",p.IBrowserCtxMenu)],Q.prototype,"ctxMenuRenderer",void 0),n.__decorate([(0,r.Autowired)(M.AINativeCoreContribution),n.__metadata("design:type",Object)],Q.prototype,"contributions",void 0),n.__decorate([(0,r.Autowired)(v.InlineChatFeatureRegistryToken),n.__metadata("design:type",B.InlineChatFeatureRegistry)],Q.prototype,"inlineChatFeatureRegistry",void 0),n.__decorate([(0,r.Autowired)(v.ChatFeatureRegistryToken),n.__metadata("design:type",Object)],Q.prototype,"chatFeatureRegistry",void 0),n.__decorate([(0,r.Autowired)(v.ChatRenderRegistryToken),n.__metadata("design:type",Object)],Q.prototype,"chatRenderRegistry",void 0),n.__decorate([(0,r.Autowired)(v.ResolveConflictRegistryToken),n.__metadata("design:type",Object)],Q.prototype,"resolveConflictRegistry",void 0),n.__decorate([(0,r.Autowired)(v.RenameCandidatesProviderRegistryToken),n.__metadata("design:type",Object)],Q.prototype,"renameCandidatesProviderRegistry",void 0),n.__decorate([(0,r.Autowired)(v.TerminalRegistryToken),n.__metadata("design:type",Object)],Q.prototype,"terminalProviderRegistry",void 0),n.__decorate([(0,r.Autowired)(v.IntelligentCompletionsRegistryToken),n.__metadata("design:type",Object)],Q.prototype,"intelligentCompletionsRegistry",void 0),n.__decorate([(0,r.Autowired)(v.ProblemFixRegistryToken),n.__metadata("design:type",Object)],Q.prototype,"problemFixProviderRegistry",void 0),n.__decorate([(0,r.Autowired)(o.AINativeConfigService),n.__metadata("design:type",o.AINativeConfigService)],Q.prototype,"aiNativeConfigService",void 0),n.__decorate([(0,r.Autowired)(E.DesignLayoutConfig),n.__metadata("design:type",E.DesignLayoutConfig)],Q.prototype,"designLayoutConfig",void 0),n.__decorate([(0,r.Autowired)(w.AICompletionsService),n.__metadata("design:type",w.AICompletionsService)],Q.prototype,"aiCompletionsService",void 0),n.__decorate([(0,r.Autowired)(S.AIInlineCompletionsProvider),n.__metadata("design:type",S.AIInlineCompletionsProvider)],Q.prototype,"aiInlineCompletionsProvider",void 0),n.__decorate([(0,r.Autowired)(v.CommandService),n.__metadata("design:type",Object)],Q.prototype,"commandService",void 0),n.__decorate([(0,r.Autowired)(o.PreferenceService),n.__metadata("design:type",Object)],Q.prototype,"preferenceService",void 0),n.__decorate([(0,r.Autowired)(c.IMainLayoutService),n.__metadata("design:type",Object)],Q.prototype,"layoutService",void 0),n.__decorate([(0,r.Autowired)(f.ChatProxyServiceToken),n.__metadata("design:type",a.ChatProxyService)],Q.prototype,"chatProxyService",void 0),n.__decorate([(0,r.Autowired)(o.IAIInlineChatService),n.__metadata("design:type",x.AIInlineChatService)],Q.prototype,"aiInlineChatService",void 0),n.__decorate([(0,r.Autowired)(U.InlineInputChatService),n.__metadata("design:type",U.InlineInputChatService)],Q.prototype,"inlineInputChatService",void 0),n.__decorate([(0,r.Autowired)(X.InlineStreamDiffService),n.__metadata("design:type",X.InlineStreamDiffService)],Q.prototype,"inlineStreamDiffService",void 0),n.__decorate([(0,r.Autowired)(I.RenameSingleHandler),n.__metadata("design:type",I.RenameSingleHandler)],Q.prototype,"renameSingleHandler",void 0),n.__decorate([(0,r.Autowired)(y.CodeActionSingleHandler),n.__metadata("design:type",y.CodeActionSingleHandler)],Q.prototype,"codeActionSingleHandler",void 0),t.AINativeBrowserContribution=Q=n.__decorate([(0,o.Domain)(o.ClientAppContribution,g.BrowserEditorContribution,o.CommandContribution,h.SettingContribution,o.KeybindingContribution,o.ComponentContribution,o.SlotRendererContribution,o.MonacoContribution),n.__metadata("design:paramtypes",[])],Q)},74055:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ChatAgentService=void 0;const n=e(85608),r=n.__importDefault(e(66652)),o=e(76003),l=e(43718),m=e(29770);let E=class extends l.Disposable{constructor(){super(),this.agents=new Map,this._onDidChangeAgents=new l.Emitter,this.onDidChangeAgents=this._onDidChangeAgents.event,this._onDidSendMessage=new l.Emitter,this.onDidSendMessage=this._onDidSendMessage.event,this.addDispose(this._onDidChangeAgents)}registerAgent(v){if(this.agents.has(v.id))throw new Error(`Already registered an agent with id ${v.id}`);return this.agents.set(v.id,{agent:v,commands:[]}),this._onDidChangeAgents.fire(),(0,l.toDisposable)(()=>{this.agents.delete(v.id)&&this._onDidChangeAgents.fire()})}async updateAgent(v,s){const g=this.agents.get(v);if(!g)throw new Error(`No agent with id ${v} registered`);g.agent.metadata={...g.agent.metadata,...s},g.commands=await g.agent.provideSlashCommands(l.CancellationToken.None),s.isDefault&&(this.defaultAgentId=v);const c=await g.agent.provideChatWelcomeMessage(l.CancellationToken.None);if(c){const{content:h,sampleQuestions:d}=c;this.chatFeatureRegistry.registerWelcome(h,d)}this._onDidChangeAgents.fire()}getAgents(){return Array.from(this.agents.values(),v=>v.agent)}hasAgent(v){return this.agents.has(v)}getDefaultAgentId(){return this.defaultAgentId}getAgent(v){const s=this.agents.get(v);return s?.agent}async invokeAgent(v,s,g,c,h){const d=this.agents.get(v);if(!d)throw new Error(`No agent with id ${v}`);return await d.agent.invoke(s,g,c,h)}populateChatInput(v,s){this.aiChatService.sendMessage({...s,agentId:v,immediate:!1})}getCommands(){return(0,r.default)(Array.from(this.agents.values(),({agent:v,commands:s})=>s.map(g=>({...g,agentId:v.id}))))}async getFollowups(v,s,g){const c=this.agents.get(v);if(!c)throw new Error(`No agent with id ${v}`);return c.agent.provideFollowups?c.agent.provideFollowups(s,g):[]}async getSampleQuestions(v,s){const g=this.agents.get(v);if(!g)throw new Error(`No agent with id ${v}`);return g.agent.provideSampleQuestions?g.agent.provideSampleQuestions(s):[]}async getAllSampleQuestions(){const v=await Promise.all(Array.from(this.agents.values()).map(async({agent:s})=>{try{return await this.getSampleQuestions(s.id,l.CancellationToken.None)}catch(g){return this.logger.error(g),[]}}));return(0,r.default)(v)}sendMessage(v){this._onDidSendMessage.fire(v)}parseMessage(v,s){var g;const c={agentId:"",command:"",message:v};let h=s;const d=this.getAgents(),u=new RegExp(`^@(${d.map(f=>f.id).join("|")})(?:\\s+|$)`,"i"),_=c.message.match(u);if(_){const f=d.find(a=>a.id.toLowerCase()===_[1].toLowerCase());if(!f)return c;h=f.id,c.agentId=h,c.message=c.message.replace(_[0],"")}if(h){const f=(g=this.agents.get(h))===null||g===void 0?void 0:g.commands;if(f?.length){const a=new RegExp(`^/\\s?(${f.map(y=>y.name).join("|")})(?:\\s+|$)`,"i"),b=c.message.match(a);if(b){const y=f.find(S=>S.name.toLowerCase()===b[1].toLowerCase());if(!y)return c;c.command=y.name,c.message=c.message.replace(b[0],"")}}}return c}};t.ChatAgentService=E,n.__decorate([(0,o.Autowired)(l.ILogger),n.__metadata("design:type",Object)],E.prototype,"logger",void 0),n.__decorate([(0,o.Autowired)(l.ChatServiceToken),n.__metadata("design:type",m.ChatService)],E.prototype,"aiChatService",void 0),n.__decorate([(0,o.Autowired)(l.ChatFeatureRegistryToken),n.__metadata("design:type",Object)],E.prototype,"chatFeatureRegistry",void 0),t.ChatAgentService=E=n.__decorate([(0,o.Injectable)(),n.__metadata("design:paramtypes",[])],E)},84543:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ChatAgentViewService=void 0;const n=e(85608),r=e(76003),o=e(43718),l=e(19413),m=e(51081);let E=class{constructor(){this.componentsMap=new Map,this.componentsDeferredMap=new Map}registerChatComponent(v){return this.componentsMap.set(v.id,v),this.componentsDeferredMap.has(v.id)&&(this.componentsDeferredMap.get(v.id).resolve(v),this.componentsDeferredMap.delete(v.id)),{dispose:()=>{this.componentsMap.get(v.id)===v&&(this.componentsMap.delete(v.id),this.componentsDeferredMap.delete(v.id))}}}getChatComponent(v){return this.componentsMap.has(v)?this.componentsMap.get(v):(this.componentsDeferredMap.has(v)||this.componentsDeferredMap.set(v,new o.Deferred),null)}getChatComponentDeferred(v){return this.componentsDeferredMap.get(v)||null}getRenderAgents(){return this.chatAgentService.getAgents().filter(v=>v.id!==m.ChatProxyService.AGENT_ID)}};t.ChatAgentViewService=E,n.__decorate([(0,r.Autowired)(l.IChatAgentService),n.__metadata("design:type",Object)],E.prototype,"chatAgentService",void 0),t.ChatAgentViewService=E=n.__decorate([(0,r.Injectable)()],E)},61282:(L,t,e)=>{"use strict";var n,r;Object.defineProperty(t,"__esModule",{value:!0}),t.ChatManagerService=void 0;const o=e(85608),l=e(76003),m=e(43718),E=e(19413),p=e(42033);let v=class extends m.Disposable{constructor(){super(),n.set(this,this.registerDispose(new m.DisposableMap)),r.set(this,this.registerDispose(new m.DisposableMap))}startSession(){const g=this.injector.get(p.ChatModel);return o.__classPrivateFieldGet(this,n,"f").set(g.sessionId,g),g}getSession(g){return o.__classPrivateFieldGet(this,n,"f").get(g)}clearSession(g){var c;if(!o.__classPrivateFieldGet(this,n,"f").get(g))throw new Error(`Unknown session: ${g}`);o.__classPrivateFieldGet(this,n,"f").disposeKey(g),(c=o.__classPrivateFieldGet(this,r,"f").get(g))===null||c===void 0||c.cancel(),o.__classPrivateFieldGet(this,r,"f").disposeKey(g)}createRequest(g,c,h,d){const u=this.getSession(g);if(!u)throw new Error(`Unknown session: ${g}`);if(!o.__classPrivateFieldGet(this,r,"f").has(g))return u.addRequest({prompt:c,agentId:h,command:d})}async sendRequest(g,c,h){const d=this.getSession(g);if(!d)throw new Error(`Unknown session: ${g}`);const u=new m.CancellationTokenSource,_=u.token;o.__classPrivateFieldGet(this,r,"f").set(d.sessionId,u);const f=_.onCancellationRequested(()=>{c.response.cancel()}),a=[];for(const b of d.requests)b.response.isComplete&&(a.push({role:1,content:b.message.prompt}),a.push({role:2,content:b.response.responseText}));try{const b=A=>{_.isCancellationRequested||d.acceptResponseProgress(c,A)},y={sessionId:g,requestId:c.requestId,message:c.message.prompt,command:c.message.command,regenerate:h},S=await this.chatAgentService.invokeAgent(c.message.agentId,y,b,a,_);_.isCancellationRequested||(S.errorDetails&&c.response.setErrorDetails(S.errorDetails),this.chatAgentService.getFollowups(c.message.agentId,g,m.CancellationToken.None).then(w=>{c.response.setFollowups(w),c.response.complete()}))}finally{f.dispose(),o.__classPrivateFieldGet(this,r,"f").disposeKey(d.sessionId)}}cancelRequest(g){var c;(c=o.__classPrivateFieldGet(this,r,"f").get(g))===null||c===void 0||c.cancel(),o.__classPrivateFieldGet(this,r,"f").disposeKey(g)}};t.ChatManagerService=v,n=new WeakMap,r=new WeakMap,o.__decorate([(0,l.Autowired)(l.INJECTOR_TOKEN),o.__metadata("design:type",l.Injector)],v.prototype,"injector",void 0),o.__decorate([(0,l.Autowired)(E.IChatAgentService),o.__metadata("design:type",Object)],v.prototype,"chatAgentService",void 0),t.ChatManagerService=v=o.__decorate([(0,l.Injectable)(),o.__metadata("design:paramtypes",[])],v)},42033:(L,t,e)=>{"use strict";var n,r,o,l,m,E,p,v,s,g,c,h,d,u,_,f;Object.defineProperty(t,"__esModule",{value:!0}),t.ChatSlashCommandItemModel=t.ChatWelcomeMessageModel=t.ChatModel=t.ChatRequestModel=t.ChatResponseModel=void 0;const a=e(85608),b=e(76003),y=e(43718),S=e(90684),A=e(19413),w=e(44260);let T=class extends y.Disposable{get responseParts(){return a.__classPrivateFieldGet(this,r,"f")}get responseContents(){return a.__classPrivateFieldGet(this,o,"f")}get isComplete(){return a.__classPrivateFieldGet(this,l,"f")}get isCanceled(){return a.__classPrivateFieldGet(this,m,"f")}get requestId(){return a.__classPrivateFieldGet(this,E,"f")}get responseText(){return a.__classPrivateFieldGet(this,p,"f")}get errorDetails(){return a.__classPrivateFieldGet(this,v,"f")}get followups(){return a.__classPrivateFieldGet(this,s,"f")}get onDidChange(){return a.__classPrivateFieldGet(this,g,"f").event}constructor(M,k,B){super(),n.add(this),this.session=k,this.agentId=B,r.set(this,[]),o.set(this,[]),l.set(this,!1),m.set(this,!1),E.set(this,void 0),p.set(this,""),v.set(this,void 0),s.set(this,void 0),g.set(this,this.registerDispose(new y.Emitter)),a.__classPrivateFieldSet(this,E,M,"f")}updateContent(M,k){var B;if(M.kind==="content"||M.kind==="markdownContent"){const x=a.__classPrivateFieldGet(this,r,"f").length-1,N=a.__classPrivateFieldGet(this,r,"f")[x];!N||N.kind!=="markdownContent"?M.kind==="content"?a.__classPrivateFieldGet(this,r,"f").push({content:new S.MarkdownString(M.content),kind:"markdownContent"}):a.__classPrivateFieldGet(this,r,"f").push(M):M.kind==="markdownContent"?a.__classPrivateFieldGet(this,r,"f")[x]={content:new S.MarkdownString(N.content.value+M.content.value),kind:"markdownContent"}:a.__classPrivateFieldGet(this,r,"f")[x]={content:new S.MarkdownString(N.content.value+M.content,N.content),kind:"markdownContent"},a.__classPrivateFieldGet(this,n,"m",c).call(this)}else if(M.kind==="asyncContent"){const x=a.__classPrivateFieldGet(this,r,"f").push(M)-1;a.__classPrivateFieldGet(this,n,"m",c).call(this),(B=M.resolvedContent)===null||B===void 0||B.then(N=>{typeof N=="string"?a.__classPrivateFieldGet(this,r,"f")[x]={content:new S.MarkdownString(N),kind:"markdownContent"}:(0,S.isMarkdownString)(N)?a.__classPrivateFieldGet(this,r,"f")[x]={content:N,kind:"markdownContent"}:a.__classPrivateFieldGet(this,r,"f")[x]=N,a.__classPrivateFieldGet(this,n,"m",c).call(this,k)})}else M.kind==="treeData"?(a.__classPrivateFieldGet(this,r,"f").push(M),a.__classPrivateFieldGet(this,n,"m",c).call(this,k)):M.kind==="component"&&(a.__classPrivateFieldGet(this,r,"f").push(M),a.__classPrivateFieldGet(this,n,"m",c).call(this,k))}complete(){a.__classPrivateFieldSet(this,l,!0,"f"),a.__classPrivateFieldGet(this,g,"f").fire()}cancel(){a.__classPrivateFieldSet(this,l,!0,"f"),a.__classPrivateFieldSet(this,m,!0,"f"),a.__classPrivateFieldGet(this,g,"f").fire()}reset(){a.__classPrivateFieldSet(this,o,[],"f"),a.__classPrivateFieldSet(this,r,[],"f"),a.__classPrivateFieldSet(this,p,"","f"),a.__classPrivateFieldSet(this,m,!1,"f"),a.__classPrivateFieldSet(this,l,!1,"f"),a.__classPrivateFieldSet(this,v,void 0,"f"),a.__classPrivateFieldSet(this,s,void 0,"f"),a.__classPrivateFieldGet(this,g,"f").fire()}setErrorDetails(M){a.__classPrivateFieldSet(this,v,M,"f"),a.__classPrivateFieldGet(this,g,"f").fire()}setFollowups(M){a.__classPrivateFieldSet(this,s,M,"f"),a.__classPrivateFieldGet(this,g,"f").fire()}};t.ChatResponseModel=T,r=new WeakMap,o=new WeakMap,l=new WeakMap,m=new WeakMap,E=new WeakMap,p=new WeakMap,v=new WeakMap,s=new WeakMap,g=new WeakMap,n=new WeakSet,c=function(M){a.__classPrivateFieldSet(this,p,a.__classPrivateFieldGet(this,r,"f").map(B=>B.kind==="asyncContent"?B.content:B.kind==="treeData"||B.kind==="component"?"":B.content.value).join(`
|
|
28183
|
+
${JSON.stringify(r,null,2)}`);const l=n[o]();return new Language(INTERNAL,l)})}}class LookaheadIterable{constructor(t,e,n){assertInternal(t),this[0]=e,this.language=n}get currentTypeId(){return C._ts_lookahead_iterator_current_symbol(this[0])}get currentType(){return this.language.types[this.currentTypeId]||"ERROR"}delete(){C._ts_lookahead_iterator_delete(this[0]),this[0]=0}resetState(t){return C._ts_lookahead_iterator_reset_state(this[0],t)}reset(t,e){return!!C._ts_lookahead_iterator_reset(this[0],t[0],e)&&(this.language=t,!0)}[Symbol.iterator](){const t=this;return{next:()=>C._ts_lookahead_iterator_next(t[0])?{done:!1,value:t.currentType}:{done:!0,value:""}}}}class Query{constructor(t,e,n,r,o,l,m,E){assertInternal(t),this[0]=e,this.captureNames=n,this.textPredicates=r,this.predicates=o,this.setProperties=l,this.assertedProperties=m,this.refutedProperties=E,this.exceededMatchLimit=!1}delete(){C._ts_query_delete(this[0]),this[0]=0}matches(t,{startPosition:e=ZERO_POINT,endPosition:n=ZERO_POINT,startIndex:r=0,endIndex:o=0,matchLimit:l=4294967295,maxStartDepth:m=4294967295}={}){if(typeof l!="number")throw new Error("Arguments must be numbers");marshalNode(t),C._ts_query_matches_wasm(this[0],t.tree[0],e.row,e.column,n.row,n.column,r,o,l,m);const E=getValue(TRANSFER_BUFFER,"i32"),p=getValue(TRANSFER_BUFFER+SIZE_OF_INT,"i32"),v=getValue(TRANSFER_BUFFER+2*SIZE_OF_INT,"i32"),s=new Array(E);this.exceededMatchLimit=!!v;let g=0,c=p;for(let h=0;h<E;h++){const d=getValue(c,"i32");c+=SIZE_OF_INT;const u=getValue(c,"i32");c+=SIZE_OF_INT;const _=new Array(u);if(c=unmarshalCaptures(this,t.tree,c,_),this.textPredicates[d].every(f=>f(_))){s[g]={pattern:d,captures:_};const f=this.setProperties[d];f&&(s[g].setProperties=f);const a=this.assertedProperties[d];a&&(s[g].assertedProperties=a);const b=this.refutedProperties[d];b&&(s[g].refutedProperties=b),g++}}return s.length=g,C._free(p),s}captures(t,{startPosition:e=ZERO_POINT,endPosition:n=ZERO_POINT,startIndex:r=0,endIndex:o=0,matchLimit:l=4294967295,maxStartDepth:m=4294967295}={}){if(typeof l!="number")throw new Error("Arguments must be numbers");marshalNode(t),C._ts_query_captures_wasm(this[0],t.tree[0],e.row,e.column,n.row,n.column,r,o,l,m);const E=getValue(TRANSFER_BUFFER,"i32"),p=getValue(TRANSFER_BUFFER+SIZE_OF_INT,"i32"),v=getValue(TRANSFER_BUFFER+2*SIZE_OF_INT,"i32"),s=[];this.exceededMatchLimit=!!v;const g=[];let c=p;for(let h=0;h<E;h++){const d=getValue(c,"i32");c+=SIZE_OF_INT;const u=getValue(c,"i32");c+=SIZE_OF_INT;const _=getValue(c,"i32");if(c+=SIZE_OF_INT,g.length=u,c=unmarshalCaptures(this,t.tree,c,g),this.textPredicates[d].every(f=>f(g))){const f=g[_],a=this.setProperties[d];a&&(f.setProperties=a);const b=this.assertedProperties[d];b&&(f.assertedProperties=b);const y=this.refutedProperties[d];y&&(f.refutedProperties=y),s.push(f)}}return C._free(p),s}predicatesForPattern(t){return this.predicates[t]}disableCapture(t){const e=lengthBytesUTF8(t),n=C._malloc(e+1);stringToUTF8(t,n,e+1),C._ts_query_disable_capture(this[0],n,e),C._free(n)}didExceedMatchLimit(){return this.exceededMatchLimit}}function getText(L,t,e){const n=e-t;let r=L.textCallback(t,null,e);for(t+=r.length;t<e;){const o=L.textCallback(t,null,e);if(!(o&&o.length>0))break;t+=o.length,r+=o}return t>e&&(r=r.slice(0,n)),r}function unmarshalCaptures(L,t,e,n){for(let r=0,o=n.length;r<o;r++){const l=getValue(e,"i32"),m=unmarshalNode(t,e+=SIZE_OF_INT);e+=SIZE_OF_NODE,n[r]={name:L.captureNames[l],node:m}}return e}function assertInternal(L){if(L!==INTERNAL)throw new Error("Illegal constructor")}function isPoint(L){return L&&typeof L.row=="number"&&typeof L.column=="number"}function marshalNode(L){let t=TRANSFER_BUFFER;setValue(t,L.id,"i32"),t+=SIZE_OF_INT,setValue(t,L.startIndex,"i32"),t+=SIZE_OF_INT,setValue(t,L.startPosition.row,"i32"),t+=SIZE_OF_INT,setValue(t,L.startPosition.column,"i32"),t+=SIZE_OF_INT,setValue(t,L[0],"i32")}function unmarshalNode(L,t=TRANSFER_BUFFER){const e=getValue(t,"i32");if(e===0)return null;const n=getValue(t+=SIZE_OF_INT,"i32"),r=getValue(t+=SIZE_OF_INT,"i32"),o=getValue(t+=SIZE_OF_INT,"i32"),l=getValue(t+=SIZE_OF_INT,"i32"),m=new Node(INTERNAL,L);return m.id=e,m.startIndex=n,m.startPosition={row:r,column:o},m[0]=l,m}function marshalTreeCursor(L,t=TRANSFER_BUFFER){setValue(t+0*SIZE_OF_INT,L[0],"i32"),setValue(t+1*SIZE_OF_INT,L[1],"i32"),setValue(t+2*SIZE_OF_INT,L[2],"i32"),setValue(t+3*SIZE_OF_INT,L[3],"i32")}function unmarshalTreeCursor(L){L[0]=getValue(TRANSFER_BUFFER+0*SIZE_OF_INT,"i32"),L[1]=getValue(TRANSFER_BUFFER+1*SIZE_OF_INT,"i32"),L[2]=getValue(TRANSFER_BUFFER+2*SIZE_OF_INT,"i32"),L[3]=getValue(TRANSFER_BUFFER+3*SIZE_OF_INT,"i32")}function marshalPoint(L,t){setValue(L,t.row,"i32"),setValue(L+SIZE_OF_INT,t.column,"i32")}function unmarshalPoint(L){return{row:getValue(L,"i32")>>>0,column:getValue(L+SIZE_OF_INT,"i32")>>>0}}function marshalRange(L,t){marshalPoint(L,t.startPosition),marshalPoint(L+=SIZE_OF_POINT,t.endPosition),setValue(L+=SIZE_OF_POINT,t.startIndex,"i32"),setValue(L+=SIZE_OF_INT,t.endIndex,"i32"),L+=SIZE_OF_INT}function unmarshalRange(L){const t={};return t.startPosition=unmarshalPoint(L),L+=SIZE_OF_POINT,t.endPosition=unmarshalPoint(L),L+=SIZE_OF_POINT,t.startIndex=getValue(L,"i32")>>>0,L+=SIZE_OF_INT,t.endIndex=getValue(L,"i32")>>>0,t}function marshalEdit(L){let t=TRANSFER_BUFFER;marshalPoint(t,L.startPosition),t+=SIZE_OF_POINT,marshalPoint(t,L.oldEndPosition),t+=SIZE_OF_POINT,marshalPoint(t,L.newEndPosition),t+=SIZE_OF_POINT,setValue(t,L.startIndex,"i32"),t+=SIZE_OF_INT,setValue(t,L.oldEndIndex,"i32"),t+=SIZE_OF_INT,setValue(t,L.newEndIndex,"i32"),t+=SIZE_OF_INT}for(const L of Object.getOwnPropertyNames(ParserImpl.prototype))Object.defineProperty(Parser.prototype,L,{value:ParserImpl.prototype[L],enumerable:!1,writable:!1});Parser.Language=Language,Module.onRuntimeInitialized=()=>{ParserImpl.init(),resolveInitPromise()}}))}}return Parser}();module.exports=TreeSitter},52730:(L,t,e)=>{"use strict";var n=e(80705),r=e(14834),o=e(28498),l=e(79818),m=e(69336),E=l("Object.prototype.toString"),p=e(51913)(),v=typeof globalThis>"u"?e.g:globalThis,s=r(),g=l("String.prototype.slice"),c=Object.getPrototypeOf,h=l("Array.prototype.indexOf",!0)||function(a,b){for(var y=0;y<a.length;y+=1)if(a[y]===b)return y;return-1},d={__proto__:null};p&&m&&c?n(s,function(f){var a=new v[f];if(Symbol.toStringTag in a){var b=c(a),y=m(b,Symbol.toStringTag);if(!y){var S=c(b);y=m(S,Symbol.toStringTag)}d["$"+f]=o(y.get)}}):n(s,function(f){var a=new v[f],b=a.slice||a.set;b&&(d["$"+f]=o(b))});var u=function(a){var b=!1;return n(d,function(y,S){if(!b)try{"$"+y(a)===S&&(b=g(S,1))}catch{}}),b},_=function(a){var b=!1;return n(d,function(y,S){if(!b)try{y(a),b=g(S,1)}catch{}}),b};L.exports=function(a){if(!a||typeof a!="object")return!1;if(!p){var b=g(E(a),8,-1);return h(s,b)>-1?b:b!=="Object"?!1:_(a)}return m?u(a):null}},79682:(L,t,e)=>{"use strict";var n;Object.defineProperty(t,"__esModule",{value:!0}),t.ChromeDevtoolsContribution=void 0;const r=e(85608),o=e(76003),l=e(41869),m=e(65265),E=e(98295),p=e(27654);let v=n=class extends l.Disposable{constructor(){super(...arguments),this.lantencyHandler=g=>{const{command:c}=g.detail;c===m.DevtoolsLantencyCommand.Start?this.interval||this.startRTTInterval():c===m.DevtoolsLantencyCommand.Stop&&this.interval&&(clearInterval(this.interval),this.interval=void 0)}}initialize(){var g;this.appConfig.devtools&&(window.addEventListener(m.EDevtoolsEvent.Latency,this.lantencyHandler),this.addDispose(l.Disposable.create(()=>{window.removeEventListener(m.EDevtoolsEvent.Latency,this.lantencyHandler),this.interval&&(clearInterval(this.interval),this.interval=void 0)})),!((g=window.__OPENSUMI_DEVTOOLS_GLOBAL_HOOK__)===null||g===void 0)&&g.captureRPC&&(this.interval||this.startRTTInterval()))}startRTTInterval(){this.interval=setInterval(async()=>{const g=Date.now();await this.rttService.measure();const c=Date.now()-g;window.__OPENSUMI_DEVTOOLS_GLOBAL_HOOK__.captureRPC&&(window.__OPENSUMI_DEVTOOLS_GLOBAL_HOOK__.latency=c)},n.INTERVAL)}};t.ChromeDevtoolsContribution=v,v.INTERVAL=1e3,r.__decorate([(0,o.Autowired)(l.AppConfig),r.__metadata("design:type",Object)],v.prototype,"appConfig",void 0),r.__decorate([(0,o.Autowired)(p.ConnectionRTTBrowserServiceToken),r.__metadata("design:type",p.ConnectionRTTBrowserService)],v.prototype,"rttService",void 0),t.ChromeDevtoolsContribution=v=n=r.__decorate([(0,E.Domain)(l.ClientAppContribution)],v)},72915:(L,t,e)=>{"use strict";var n;Object.defineProperty(t,"__esModule",{value:!0}),t.ConnectionRTTContribution=void 0;const r=e(85608),o=e(76003),l=e(26542),m=e(92323),E=e(98295),p=e(27654),v={id:"connection.start.rtt",label:"%connection.start.rtt%",category:"%command.category.developerTools%"},s={id:"connection.stop.rtt",label:"%connection.stop.rtt%",category:"%command.category.developerTools%"},g={alignment:l.StatusBarAlignment.LEFT,priority:1/0-1};let c=n=class{registerCommands(d){d.registerCommand(v,{execute:()=>{this.interval||this.startRTTInterval()}}),d.registerCommand(s,{execute:()=>{this.interval&&(clearInterval(this.interval),this.statusBar&&(this.statusBar.dispose(),this.statusBar=void 0))}})}startRTTInterval(){this.interval=setInterval(async()=>{const d=Date.now();await this.rttService.measure();const _={text:`${Date.now()-d}ms`};if(this.statusBar)this.statusBar.update({..._,...g});else{const f=this.statusBarService.addElement("connection-rtt",{..._,...g});this.statusBar=f}},n.INTERVAL)}};t.ConnectionRTTContribution=c,c.INTERVAL=1e3,r.__decorate([(0,o.Autowired)(l.IStatusBarService),r.__metadata("design:type",Object)],c.prototype,"statusBarService",void 0),r.__decorate([(0,o.Autowired)(p.ConnectionRTTBrowserServiceToken),r.__metadata("design:type",p.ConnectionRTTBrowserService)],c.prototype,"rttService",void 0),t.ConnectionRTTContribution=c=n=r.__decorate([(0,E.Domain)(m.CommandContribution)],c)},27654:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ConnectionRTTBrowserService=t.ConnectionRTTBrowserServiceToken=void 0;const n=e(85608),r=e(76003),o=e(69452);t.ConnectionRTTBrowserServiceToken=Symbol("ConnectionRTTBrowserService");let l=class{async measure(){await this.connectionBackService.$measure()}};t.ConnectionRTTBrowserService=l,n.__decorate([(0,r.Autowired)(o.ConnectionBackServicePath),n.__metadata("design:type",Object)],l.prototype,"connectionBackService",void 0),t.ConnectionRTTBrowserService=l=n.__decorate([(0,r.Injectable)()],l)},17631:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.FileDropContribution=void 0;const n=e(85608),r=e(76003),o=e(41869),l=e(43718),m=e(69452);let E=class extends l.WithEventBus{onDidDropFile(v){this.dropService.onDidDropFile(v)}};t.FileDropContribution=E,n.__decorate([(0,r.Autowired)(m.IFileDropFrontendServiceToken),n.__metadata("design:type",Object)],E.prototype,"dropService",void 0),n.__decorate([(0,l.OnEvent)(l.FileTreeDropEvent),n.__metadata("design:type",Function),n.__metadata("design:paramtypes",[l.FileTreeDropEvent]),n.__metadata("design:returntype",void 0)],E.prototype,"onDidDropFile",null),t.FileDropContribution=E=n.__decorate([(0,r.Injectable)(),(0,o.Domain)(o.ClientAppContribution)],E)},22874:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.FileDropService=void 0;const n=e(85608),r=e(76003),o=e(41869),l=e(26542),m=e(43718),E=e(42933),{Path:p}=m.path,v=e(69452);let s=class extends m.WithEventBus{constructor(){super(...arguments),this.pending=new Set}onDidUploadFileStart(c){this.pending.add(c),this.createOrUpdateStatusBar()}onDidUploadFileEnd(c){this.pending.delete(c),this.createOrUpdateStatusBar()}createOrUpdateStatusBar(c){if(this.pending.size===0){this.uploadStatus&&(this.uploadStatus.dispose(),this.uploadStatus=void 0);return}const h="sumi-upload-file-status",d=(0,o.formatLocalize)("workbench.uploadingFiles",this.pending.size,c||"0 MB"),u={text:d,alignment:l.StatusBarAlignment.RIGHT,tooltip:d,iconClass:"kaitian-icon kticon-cloud-server"};this.uploadStatus?this.uploadStatus.update({id:h,...u}):this.uploadStatus=this.statusBarService.addElement(h,u)}onDidDropFile(c){var h;const{payload:{event:d,targetDir:u}}=c;if(!u||!(!((h=d.dataTransfer)===null||h===void 0)&&h.files)||d.dataTransfer.files.length===0)return;const _=d.dataTransfer.items;let f=0;const a=Date.now(),b=y=>{f+=y;const S=Date.now(),w=`${(f/((S-a)/1e3)/1024/1024).toFixed(2)} MB`;this.createOrUpdateStatusBar(w)};for(const y of _){const S=y.webkitGetAsEntry();this.processFilesEntry(u,S,b)}}async processFilesEntry(c,h,d){if(h.isFile)this.processFileEntry(h,c,d);else{const u=m.Uri.file(new p(c).join(h.fullPath).toString()).toString();await this.fs.createFolder(u),this.processDirEntry(h,c,d)}}toBinaryString(c){let h;const d=c.length;let u="";for(h=0;h<d;h+=1)u+=String.fromCharCode(c[h]);return u}async doUploadFile(c,h,d){var u;const _=new p(h).join(c.name).toString();this.onDidUploadFileStart(_.toString()),await this.fs.createFile(m.Uri.file(_.toString()).toString()),await this.dropService.$ensureFileExist(c.name,h);const f=c.stream().getReader();let a=await f.read();for(;!a.done;)await this.dropService.$writeStream(this.toBinaryString(a.value),c.name,h,a.done),d((u=a.value)===null||u===void 0?void 0:u.byteLength),a=await f.read();a.done&&this.onDidUploadFileEnd(_.toString())}processFileEntry(c,h,d){c.file(u=>{const _=new File([u],c.fullPath,{type:c.type});this.doUploadFile(_,h,d)},()=>{})}processDirEntry(c,h,d){c.createReader().readEntries(_=>{_.forEach(async f=>{this.processFilesEntry(h,f,d)})},()=>{})}};t.FileDropService=s,n.__decorate([(0,r.Autowired)(E.IFileServiceClient),n.__metadata("design:type",Object)],s.prototype,"fs",void 0),n.__decorate([(0,r.Autowired)(v.FileDropServicePath),n.__metadata("design:type",Object)],s.prototype,"dropService",void 0),n.__decorate([(0,r.Autowired)(l.IStatusBarService),n.__metadata("design:type",Object)],s.prototype,"statusBarService",void 0),t.FileDropService=s=n.__decorate([(0,r.Injectable)()],s)},79240:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.FileSearchContribution=t.FileSearchQuickCommandHandler=t.matchLineReg=t.quickGoToSymbol=t.quickFileOpen=void 0,t.getValidateInput=b;const n=e(85608),r=n.__importDefault(e(39050)),o=e(76003),l=e(41869),m=e(26542),E=e(43718),p=e(98295),v=e(54414),s=e(17459),g=e(84660),c=n.__importStar(e(20868)),h=e(97821),d=e(80490),u=e(51500),_=e(30981),f=200;t.quickFileOpen={id:"workbench.action.quickOpen",category:"File",label:"Open File..."},t.quickGoToSymbol={id:"workbench.action.gotoSymbol",category:"File",label:"Open File Symbol..."},t.matchLineReg=/^([^:#(]*)[:#(]?L?(\d+)?[:,]?(\d+)?\)?/;function a(T=""){const D=T.match(t.matchLineReg)||[];if(D.length<2)return;const I={line:Number(D[2]||0),start:Number(D[3]||0)};return new c.Range(I.line,I.start,I.line,I.start)}function b(T){return T.replace(t.matchLineReg,"$1")}let y=class extends h.QuickOpenBaseAction{constructor(){super({id:"file-search:splitToRight",tooltip:(0,l.localize)("quickOpen.openOnTheRightSide"),class:(0,l.getIcon)("embed")})}async run(D){await this.commandService.executeCommand(l.EDITOR_COMMANDS.OPEN_RESOURCE.id,D.getUri(),{preview:!1,split:v.EditorGroupSplitAction.Right,range:a(this.injector.get(A).currentLookFor),focus:!0})}};n.__decorate([(0,o.Autowired)(l.CommandService),n.__metadata("design:type",Object)],y.prototype,"commandService",void 0),n.__decorate([(0,o.Autowired)(o.INJECTOR_TOKEN),n.__metadata("design:type",o.Injector)],y.prototype,"injector",void 0),y=n.__decorate([(0,o.Injectable)(),n.__metadata("design:paramtypes",[])],y);let S=class{hasActions(){return!0}getActions(){return[this.fileSearchActionLeftRight]}getValidateInput(D){return b(D)}};n.__decorate([(0,o.Autowired)(),n.__metadata("design:type",y)],S.prototype,"fileSearchActionLeftRight",void 0),S=n.__decorate([(0,o.Injectable)()],S);let A=class{constructor(){this.cancelIndicator=new E.CancellationTokenSource,this.default=!0,this.prefix="...",this.description=(0,l.localize)("file-search.command.fileOpen.description"),this.prevEditorState={},this.currentLookFor=""}getModel(){return{onType:async(D,I)=>{this.cancelIndicator.cancel(),this.cancelIndicator=new E.CancellationTokenSource;const O=this.cancelIndicator.token,P=new Set;let R=[];D=D.trim().replace(/\s/g,""),this.currentLookFor=D;const M=b(D),k=this.reporterService.time(E.REPORT_NAME.QUICK_OPEN_MEASURE),B=await this.getRecentlyItems(P,M,O);if(D&&(this.logger.debug("lookFor",D,M),R=await this.getFindOutItems(P,M,O)),O.isCancellationRequested)return;const x=B.concat(R);I(x,x.length?this.fileSearchActionProvider:void 0),k.timeEnd(D.indexOf("@")>-1?"file-symbol":"file",{lookFor:D,stat:{recently:B.length,find:R.length}})}}}getOptions(){return{placeholder:(0,l.localize)("file-search.command.fileOpen.placeholder"),fuzzyMatchLabel:{enableSeparateSubstringMatching:!0},showItemsWithoutHighlight:!0,fuzzyMatchDescription:{enableSeparateSubstringMatching:!0},getPlaceholderItem:D=>new l.QuickOpenItem({label:(0,l.localize)(D.indexOf("@")>-1?"search.fileSymbolResults.notfound":"search.fileResults.notfound"),run:()=>!1})}}onClose(D){D&&this.prevEditorState.uri&&(this.workbenchEditorService.open(this.prevEditorState.uri,{range:this.prevEditorState.range}),this.prevEditorState={}),this.prevSelected=void 0,this.commandService.executeCommand(l.EDITOR_COMMANDS.FOCUS.id),this.cancelIndicator.cancel()}onToggle(){this.cancelIndicator.cancel()}trySaveEditorState(){var D;if(this.workbenchEditorService.currentResource){let I={startColumn:1,startLineNumber:1,endColumn:1,endLineNumber:1};const O=(D=this.workbenchEditorService.currentEditor)===null||D===void 0?void 0:D.getSelections();if(O){const{selectionStartLineNumber:P,selectionStartColumn:R,positionLineNumber:M,positionColumn:k}=O[0];I=new c.Range(P,R,M,k)}this.prevEditorState={uri:this.workbenchEditorService.currentResource.uri,range:I}}}async getFindOutItems(D,I,O){var P;let R;if(I.indexOf("@")>-1){this.trySaveEditorState(),R=[];const[M,k]=I.split("@");let B;if(this.prevSelected)B=this.prevSelected.withoutFragment();else if(M){const x=await this.getQueryFiles(M,D,O);x.length&&(B=x[0].getUri())}else B=(P=this.workbenchEditorService.currentResource)===null||P===void 0?void 0:P.uri;if(B){const x=await this.documentSymbolStore.getDocumentSymbolAsync(B)||[],N=[];this.flattenSymbols({children:x},N),R=N.filter(K=>{const U=(0,_.matchesFuzzy)(k,K.name,!0)||[];return U&&(K.labelHighlights=U),U&&U.length}).map((K,U)=>{var X;return new l.QuickOpenItem({uri:B,label:K.name,iconClass:(0,l.getSymbolIcon)(K.kind),description:(X=K.parent)===null||X===void 0?void 0:X.name,labelHighlights:K.labelHighlights,groupLabel:U===0?(0,l.formatLocalize)("search.fileSymbolResults",N.length):"",showBorder:!1,run:z=>z===l.Mode.PREVIEW?(this.locateSymbol(B,K),!0):z===l.Mode.OPEN?(this.locateSymbol(B,K),!0):!1})})}else return[]}else if(R=await this.getQueryFiles(I,D,O),R[0]){const M=await this.getItems([R[0].getUri().codeUri.fsPath],{groupLabel:(0,l.localize)("search.fileResults"),showBorder:!0});R[0]=M[0]}return R}async getQueryFiles(D,I,O){const R=(await this.workspaceService.roots).map(B=>new l.URI(B.uri).codeUri.fsPath),M=await this.fileSearchService.find(D,{rootUris:R,fuzzyMatch:!0,limit:f,useGitIgnore:!0,noIgnoreParent:!0,excludePatterns:this.getPreferenceSearchExcludes()},O),k=await this.getItems(M.filter(B=>I.has(B)||O.isCancellationRequested?!1:(I.add(B),!0)),{});return k.sort(this.compareItems.bind(this)),k}async flattenSymbols(D,I){D.children.forEach(O=>{I.push(O),O.children&&this.flattenSymbols(O,I)})}async getRecentlyItems(D,I,O){const P=await this.recentFilesManager.getMostRecentlyOpenedFiles(!0)||[];return await this.getItems(P.filter(R=>{const M=new l.URI(R);return D.has(R)||!r.default.test(I,M.displayName)||O.isCancellationRequested?!1:(D.add(R),!0)}),{groupLabel:(0,l.localize)("search.historyMatches")})}async getItems(D,I){const O=[];for(const[P,R]of D.entries()){const M=l.URI.isUriString(R)?new l.URI(R):l.URI.file(R),k=`file-icon ${this.labelService.getIcon(M.withoutFragment())}`;let B="";const x=await this.workspaceService.asRelativePath(M.parent);x&&(this.workspaceService.isMultiRootWorkspaceOpened?B=`${new l.URI(x.root).displayName}${x.path?` \u30FB ${x.path}`:""}`:B=x.path||"");const N=new l.QuickOpenItem({uri:M,label:M.displayName,tooltip:R,iconClass:k,description:B,groupLabel:P===0?I.groupLabel:"",showBorder:D.length>0&&P===0?I.showBorder:!1,run:j=>(j===l.Mode.PREVIEW&&(this.prevSelected=M),j===l.Mode.OPEN?(this.openFile(M),!0):!1)});O.push(N)}return O}openFile(D){const I=D.codeUri.fsPath;let O=a(this.currentLookFor);(!O||!O.startLineNumber&&!O.startColumn)&&(O=a(D.fragment?"#"+D.fragment:I)),this.currentLookFor="",this.commandService.executeCommand(l.EDITOR_COMMANDS.OPEN_RESOURCE.id,D.withoutFragment(),{preview:!1,range:O,focus:!0})}locateSymbol(D,I){this.workbenchEditorService.open(D,{range:I.range,preview:!0})}compareItems(D,I,O="getLabel"){function P(j){return j.trim().toLowerCase()}const R=P(b(this.currentLookFor));function M(j){const K=r.default.match(R,j);return K===null?0:K.score}let k=D[O](),B=I[O]();typeof k!="string"&&(k=k.path.toString()),typeof B!="string"&&(B=B.path.toString()),k=P(k),B=P(B);const x=M(k),N=M(B);if(x===N){const j=k.indexOf(R),K=B.indexOf(R);return j===K?k.length!==B.length?k.length<B.length?-1:1:B.localeCompare(k)===0?O==="getUri"?0:this.compareItems(D,I,"getUri"):B.localeCompare(k):j-K}return N-x}getPreferenceSearchExcludes(){const D=[],I=this.preferenceService.get("files.exclude"),O=this.preferenceService.get("search.exclude"),P=Object.assign({},I,O);for(const R of Object.keys(P))P[R]&&D.push(R);return D}};t.FileSearchQuickCommandHandler=A,n.__decorate([(0,o.Autowired)(l.CommandService),n.__metadata("design:type",Object)],A.prototype,"commandService",void 0),n.__decorate([(0,o.Autowired)(g.FileSearchServicePath),n.__metadata("design:type",Object)],A.prototype,"fileSearchService",void 0),n.__decorate([(0,o.Autowired)(v.WorkbenchEditorService),n.__metadata("design:type",v.WorkbenchEditorService)],A.prototype,"workbenchEditorService",void 0),n.__decorate([(0,o.Autowired)(s.DocumentSymbolStore),n.__metadata("design:type",s.DocumentSymbolStore)],A.prototype,"documentSymbolStore",void 0),n.__decorate([(0,o.Autowired)(),n.__metadata("design:type",m.LabelService)],A.prototype,"labelService",void 0),n.__decorate([(0,o.Autowired)(u.IWorkspaceService),n.__metadata("design:type",Object)],A.prototype,"workspaceService",void 0),n.__decorate([(0,o.Autowired)(l.RecentFilesManager),n.__metadata("design:type",l.RecentFilesManager)],A.prototype,"recentFilesManager",void 0),n.__decorate([(0,o.Autowired)(l.ILogger),n.__metadata("design:type",Object)],A.prototype,"logger",void 0),n.__decorate([(0,o.Autowired)(),n.__metadata("design:type",S)],A.prototype,"fileSearchActionProvider",void 0),n.__decorate([(0,o.Autowired)(l.PreferenceService),n.__metadata("design:type",Object)],A.prototype,"preferenceService",void 0),n.__decorate([(0,o.Autowired)(E.IReporterService),n.__metadata("design:type",Object)],A.prototype,"reporterService",void 0),t.FileSearchQuickCommandHandler=A=n.__decorate([(0,o.Injectable)()],A);let w=class{registerQuickOpenHandlers(D){D.registerHandler(this.fileSearchQuickCommandHandler,{title:(0,l.localize)("quickopen.tab.file"),commandId:t.quickFileOpen.id,order:1})}registerCommands(D){D.registerCommand(t.quickFileOpen,{execute:()=>this.quickOpenService.open("...")}),D.registerCommand(t.quickGoToSymbol,{execute:()=>this.quickOpenService.open("...@")})}registerKeybindings(D){D.registerKeybinding({command:t.quickFileOpen.id,keybinding:"ctrlcmd+p"})}};t.FileSearchContribution=w,n.__decorate([(0,o.Autowired)(A),n.__metadata("design:type",A)],w.prototype,"fileSearchQuickCommandHandler",void 0),n.__decorate([(0,o.Autowired)(h.PrefixQuickOpenService),n.__metadata("design:type",Object)],w.prototype,"quickOpenService",void 0),t.FileSearchContribution=w=n.__decorate([(0,p.Domain)(E.CommandContribution,l.KeybindingContribution,d.QuickOpenContribution)],w)},73827:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ClientAddonModule=void 0;const n=e(85608),r=e(76003),o=e(41869),l=e(69452),m=e(79682),E=e(72915),p=e(27654),v=e(17631),s=e(22874),g=e(79240),c=e(18256),h=e(7756),d=e(16426);let u=class extends o.BrowserModule{constructor(){super(...arguments),this.providers=[m.ChromeDevtoolsContribution,c.LanguageChangeHintContribution,g.FileSearchContribution,h.StatusBarContribution,d.ToolbarCustomizeContribution,v.FileDropContribution,E.ConnectionRTTContribution,{token:l.IFileDropFrontendServiceToken,useClass:s.FileDropService},{token:p.ConnectionRTTBrowserServiceToken,useClass:p.ConnectionRTTBrowserService}],this.backServices=[{servicePath:l.FileDropServicePath},{servicePath:l.ConnectionBackServicePath}]}};t.ClientAddonModule=u,t.ClientAddonModule=u=n.__decorate([(0,r.Injectable)()],u)},18256:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.LanguageChangeHintContribution=void 0;const n=e(85608),r=e(76003),o=e(41869),l=e(72665);let m=class{onStart(){this.preferenceService.onSpecificPreferenceChange(o.GeneralSettingsId.Language,async p=>{(0,o.setLanguageId)(p.newValue),this.preferenceService.get("general.askReloadOnLanguageChange")&&await this.dialogService.info((0,o.localize)("preference.general.language.change.refresh.info","After changing the language, it should be restarted to take effect. Will it be refreshed immediately?"),[(0,o.localize)("preference.general.language.change.refresh.later","Later"),(0,o.localize)("preference.general.language.change.refresh.now","Now")])===(0,o.localize)("preference.general.language.change.refresh.now","Now")&&this.clientApp.fireOnReload()})}};t.LanguageChangeHintContribution=m,n.__decorate([(0,r.Autowired)(o.PreferenceService),n.__metadata("design:type",Object)],m.prototype,"preferenceService",void 0),n.__decorate([(0,r.Autowired)(o.IClientApp),n.__metadata("design:type",Object)],m.prototype,"clientApp",void 0),n.__decorate([(0,r.Autowired)(l.IDialogService),n.__metadata("design:type",Object)],m.prototype,"dialogService",void 0),t.LanguageChangeHintContribution=m=n.__decorate([(0,o.Domain)(o.ClientAppContribution)],m)},7756:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.StatusBarContribution=void 0;const n=e(85608),r=e(76003),o=e(41869),l=e(43718);let m=class extends l.WithEventBus{onStart(){}handleBrowserConnectionOpen(){this.commandService.executeCommand("statusbar.changeBackgroundColor","var(--statusBar-background)"),this.logger.log("Browser connection open, change status bar background color")}handleBrowserConnectionClose(){this.commandService.executeCommand("statusbar.changeBackgroundColor","var(--kt-statusbar-offline-background)"),this.logger.log("Browser connection close, change status bar background color")}};t.StatusBarContribution=m,n.__decorate([(0,r.Autowired)(l.CommandService),n.__metadata("design:type",Object)],m.prototype,"commandService",void 0),n.__decorate([(0,r.Autowired)(l.ILogger),n.__metadata("design:type",Object)],m.prototype,"logger",void 0),n.__decorate([(0,l.OnEvent)(l.BrowserConnectionOpenEvent),n.__metadata("design:type",Function),n.__metadata("design:paramtypes",[]),n.__metadata("design:returntype",void 0)],m.prototype,"handleBrowserConnectionOpen",null),n.__decorate([(0,l.OnEvent)(l.BrowserConnectionCloseEvent),n.__metadata("design:type",Function),n.__metadata("design:paramtypes",[]),n.__metadata("design:returntype",void 0)],m.prototype,"handleBrowserConnectionClose",null),t.StatusBarContribution=m=n.__decorate([(0,l.Domain)(o.ClientAppContribution)],m)},16426:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ToolbarCustomizeContribution=void 0;const n=e(85608),r=e(76003),o=e(41869),l=e(93899),m=e(62132);let E=class{registerCommands(v){v.registerCommand({id:"toolbar.showCustomizePanel",label:"Show Toolbar Customization"},{execute:()=>{this.viewService.setVisible(!0)}})}registerComponent(v){v.register("addon/toolbar-customize",{id:"addon/toolbar-customize",component:m.ToolbarCustomizeComponent}),this.config.layoutConfig[o.SlotLocation.extra]||(this.config.layoutConfig[o.SlotLocation.extra]={modules:[]}),this.config.layoutConfig[o.SlotLocation.extra].modules.push("addon/toolbar-customize")}registerMenus(v){v.registerMenuItem(l.MenuId.KTToolbarLocationContext,{command:{id:"toolbar.showCustomizePanel",label:(0,o.localize)("toolbar.customize.menu")}})}};t.ToolbarCustomizeContribution=E,n.__decorate([(0,r.Autowired)(o.AppConfig),n.__metadata("design:type",Object)],E.prototype,"config",void 0),n.__decorate([(0,r.Autowired)(m.ToolbarCustomizeViewService),n.__metadata("design:type",m.ToolbarCustomizeViewService)],E.prototype,"viewService",void 0),t.ToolbarCustomizeContribution=E=n.__decorate([(0,o.Domain)(o.CommandContribution,o.ComponentContribution,l.MenuContribution)],E)},62132:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ToolbarCustomizeComponent=t.ToolbarCustomizeViewService=void 0;const n=e(85608),r=n.__importDefault(e(14041)),o=e(76003),l=e(97267),m=e(41869),E=n.__importDefault(e(18541));let p=class{bindSetVisibleHandle(g){this._setVisible=g}setVisible(g){this._setVisible(g)}async toggleActionVisibility(g,c,h){const d=this.preferenceService.getValid("toolbar.ignoreActions",{});if(d[g]||(d[g]=[]),!h)d[g].indexOf(c)===-1&&d[g].push(c);else{const _=d[g].indexOf(c);_!==-1&&d[g].splice(_,1)}const u=this.preferenceService.inspect("toolbar.ignoreActions").workspaceValue?m.PreferenceScope.Workspace:m.PreferenceScope.User;await this.preferenceService.set("toolbar.ignoreActions",d,u)}};t.ToolbarCustomizeViewService=p,n.__decorate([(0,o.Autowired)(m.PreferenceService),n.__metadata("design:type",Object)],p.prototype,"preferenceService",void 0),t.ToolbarCustomizeViewService=p=n.__decorate([(0,o.Injectable)()],p);const v=()=>{const[s,g]=r.default.useState(!1),c=(0,m.useInjectable)(p),h=(0,m.useInjectable)(m.IToolbarRegistry),d=(0,m.useInjectable)(m.PreferenceService);if(c.bindSetVisibleHandle(g),!s)return null;const u=h.getAllLocations(),_=d.get("toolbar.ignoreActions")||{};let f=d.get("toolbar.buttonDisplay","iconAndText");function a(b){const y=[{id:"_head"},...h.getActionGroups(b)||[],{id:"_tail"}],S=[],A=_[b]||[];return y.forEach((w,T)=>{const D=h.getToolbarActions({location:b,group:w.id});D&&D.actions.length>0&&(S.length>0&&S.push(r.default.createElement("div",{className:E.default["group-split"],key:"split-"+T})),D.actions.forEach((I,O)=>{var P;let R=A.indexOf(I.id)===-1;const M="action-toggle-"+I.id;S.push(r.default.createElement("div",{className:E.default["action-item"],key:O+"_"+I.id},r.default.createElement(l.CheckBox,{onChange:()=>{c.toggleActionVisibility(b,I.id,!R),R=!R},defaultChecked:R,id:M,label:(P=I.description)!==null&&P!==void 0?P:I.id})))}))}),S.length===0?null:r.default.createElement("div",{key:b,className:E.default["toolbar-customize-location"]},S)}return r.default.createElement("div",{className:E.default["toolbar-customize-overlay"]},r.default.createElement("div",{className:E.default["toolbar-customize"]},u.map(b=>a(b)),r.default.createElement("div",{className:E.default["button-display"]},r.default.createElement("div",null,(0,m.localize)("toolbar-customize.buttonDisplay.description")),r.default.createElement(l.Select,{options:[{label:(0,m.localize)("toolbar-customize.buttonDisplay.icon"),value:"icon"},{label:(0,m.localize)("toolbar-customize.buttonDisplay.iconAndText"),value:"iconAndText"}],value:f,onChange:b=>{const y=d.inspect("toolbar.buttonDisplay").workspaceValue?m.PreferenceScope.Workspace:m.PreferenceScope.User;d.set("toolbar.buttonDisplay",b,y),f=b},className:E.default["button-display-select"]})),r.default.createElement("div",{className:E.default["customize-complete"]},r.default.createElement(l.Button,{type:"primary",onClick:()=>g(!1)},(0,m.localize)("toolbar-customize.complete")))))};t.ToolbarCustomizeComponent=v},69452:(L,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.IConnectionBackService=t.ConnectionBackServicePath=t.IFileDropFrontendServiceToken=t.IFileDropServiceToken=t.FileDropServicePath=void 0,t.FileDropServicePath="FileDropServicePath",t.IFileDropServiceToken=Symbol("IFileDropService"),t.IFileDropFrontendServiceToken=Symbol("IFileDropFrontendService"),t.ConnectionBackServicePath="ConnectionBackServicePath",t.IConnectionBackService=Symbol("IConnectionBackService")},77659:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AINativeContextKey=void 0;const n=e(85608),r=e(76003),o=e(41869),l=e(50394);let m=class{get contextKeyService(){return this._contextKeyService}constructor(p){this._contextKeyService=this.globalContextKeyService.createScoped(p),this.inlineChatIsVisible=l.InlineChatIsVisible.bind(this._contextKeyService),this.inlineCompletionIsTrigger=l.InlineCompletionIsTrigger.bind(this._contextKeyService),this.inlineHintWidgetIsVisible=l.InlineHintWidgetIsVisible.bind(this._contextKeyService),this.inlineInputWidgetIsVisible=l.InlineInputWidgetIsVisible.bind(this._contextKeyService),this.inlineDiffPartialEditsIsVisible=l.InlineDiffPartialEditsIsVisible.bind(this._contextKeyService),this.multiLineEditsIsVisible=l.MultiLineEditsIsVisible.bind(this._contextKeyService)}};t.AINativeContextKey=m,n.__decorate([(0,r.Autowired)(o.IContextKeyService),n.__metadata("design:type",Object)],m.prototype,"globalContextKeyService",void 0),t.AINativeContextKey=m=n.__decorate([(0,r.Injectable)(),n.__param(0,(0,r.Optional)()),n.__metadata("design:paramtypes",[Object])],m)},32016:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AINativeBrowserContribution=void 0;const n=e(85608),r=e(76003),o=e(41869),l=e(57925),m=e(50394),E=e(1149),p=e(97222),v=e(43718),s=e(82353),g=e(57517),c=e(63067),h=e(46507),d=e(97682),u=e(68415),_=e(96640),f=e(19413),a=e(51081),b=e(76154),y=e(79559),S=e(57232),A=e(72991),w=e(71863),T=e(7511),D=e(42911),I=e(72801),O=e(87817),P=e(4972),R=e(82983),M=e(77633),k=e(51221),B=e(2281),x=e(31031),N=e(38890),j=e(77886),K=e(89060),U=e(74353),X=e(22169),z=e(90058);let Q=class{constructor(){this.registerFeature()}initialize(){const{supportsChatAssistant:Z}=this.aiNativeConfigService.capabilities;Z&&(o.ComponentRegistryImpl.addLayoutModule(this.appConfig.layoutConfig,f.AI_CHAT_VIEW_ID,f.AI_CHAT_CONTAINER_ID),o.ComponentRegistryImpl.addLayoutModule(this.appConfig.layoutConfig,s.DESIGN_MENU_BAR_RIGHT,f.AI_CHAT_LOGO_AVATAR_ID),this.chatProxyService.registerDefaultAgent())}registerEditorExtensionContribution(Z){const{supportsInlineChat:G,supportsInlineCompletion:H,supportsProblemFix:$}=this.aiNativeConfigService.capabilities;Z(N.InlineDiffController.ID,new _.SyncDescriptor(N.InlineDiffController,[this.injector]),d.EditorContributionInstantiation.Lazy),G&&(Z(z.SumiLightBulbWidget.ID,z.SumiLightBulbWidget,d.EditorContributionInstantiation.Lazy),Z(k.InlineChatEditorController.ID,new _.SyncDescriptor(k.InlineChatEditorController,[this.injector]),d.EditorContributionInstantiation.BeforeFirstInteraction),this.inlineChatFeatureRegistry.getInteractiveInputHandler()&&(Z(j.InlineHintController.ID,new _.SyncDescriptor(j.InlineHintController,[this.injector]),d.EditorContributionInstantiation.AfterFirstRender),Z(K.InlineInputController.ID,new _.SyncDescriptor(K.InlineInputController,[this.injector]),d.EditorContributionInstantiation.AfterFirstRender))),H&&(Z(T.IntelligentCompletionsController.ID,new _.SyncDescriptor(T.IntelligentCompletionsController,[this.injector]),d.EditorContributionInstantiation.AfterFirstRender),Z(A.InlineCompletionsController.ID,new _.SyncDescriptor(A.InlineCompletionsController,[this.injector]),d.EditorContributionInstantiation.AfterFirstRender)),$&&Z(D.ProblemFixController.ID,new _.SyncDescriptor(D.ProblemFixController,[this.injector]),d.EditorContributionInstantiation.AfterFirstRender)}onDidStart(){(0,v.runWhenIdle)(()=>{const{supportsRenameSuggestions:Z,supportsInlineChat:G}=this.aiNativeConfigService.capabilities,H=this.preferenceService.getValid(o.AINativeSettingSectionsId.ChatVisibleType);H==="always"?this.commandService.executeCommand(l.AI_CHAT_VISIBLE.id,!0):H==="never"&&this.commandService.executeCommand(l.AI_CHAT_VISIBLE.id,!1),Z&&this.renameSingleHandler.load(),G&&this.codeActionSingleHandler.load()})}registerFeature(){this.contributions.getContributions().forEach(Z=>{var G,H,$,J,re,ce,he,Ae;(G=Z.registerInlineChatFeature)===null||G===void 0||G.call(Z,this.inlineChatFeatureRegistry),(H=Z.registerChatFeature)===null||H===void 0||H.call(Z,this.chatFeatureRegistry),($=Z.registerResolveConflictFeature)===null||$===void 0||$.call(Z,this.resolveConflictRegistry),(J=Z.registerRenameProvider)===null||J===void 0||J.call(Z,this.renameCandidatesProviderRegistry),(re=Z.registerChatRender)===null||re===void 0||re.call(Z,this.chatRenderRegistry),(ce=Z.registerTerminalProvider)===null||ce===void 0||ce.call(Z,this.terminalProviderRegistry),(he=Z.registerIntelligentCompletionFeature)===null||he===void 0||he.call(Z,this.intelligentCompletionsRegistry),(Ae=Z.registerProblemFixFeature)===null||Ae===void 0||Ae.call(Z,this.problemFixProviderRegistry)})}registerSetting(Z){Z.registerSettingGroup({id:o.AI_NATIVE_SETTING_GROUP_ID,title:v.AI_NATIVE_SETTING_GROUP_TITLE,iconClass:(0,o.getIcon)("magic-wand")}),Z.registerSettingSection(o.AI_NATIVE_SETTING_GROUP_ID,{title:(0,o.localize)("preference.ai.native.chat.title"),preferences:[{id:o.AINativeSettingSectionsId.ChatVisibleType,localized:"preference.ai.native.chat.visible.type"}]}),Z.registerSettingSection(o.AI_NATIVE_SETTING_GROUP_ID,{title:(0,o.localize)("preference.ai.native.interface.quick.title"),preferences:[{id:o.AINativeSettingSectionsId.InterfaceQuickNavigationEnabled,localized:"preference.ai.native.interface.quick.navigation"}]}),this.aiNativeConfigService.capabilities.supportsInlineCompletion&&(Z.registerSettingSection(o.AI_NATIVE_SETTING_GROUP_ID,{title:(0,o.localize)("preference.ai.native.intelligentCompletions.title"),preferences:[{id:o.AINativeSettingSectionsId.IntelligentCompletionsCacheEnabled,localized:"preference.ai.native.intelligentCompletions.cache.enabled"},{id:o.AINativeSettingSectionsId.IntelligentCompletionsDebounceTime,localized:"preference.ai.native.intelligentCompletions.debounceTime"},{id:o.AINativeSettingSectionsId.IntelligentCompletionsPromptEngineeringEnabled,localized:"preference.ai.native.intelligentCompletions.promptEngineering.enabled"},{id:o.AINativeSettingSectionsId.IntelligentCompletionsAlwaysVisible,localized:"preference.ai.native.intelligentCompletions.alwaysVisible"}]}),Z.registerSettingSection(o.AI_NATIVE_SETTING_GROUP_ID,{title:(0,o.localize)("preference.ai.native.codeEdits.title"),preferences:[{id:o.AINativeSettingSectionsId.CodeEditsLintErrors,localized:"preference.ai.native.codeEdits.lintErrors"},{id:o.AINativeSettingSectionsId.CodeEditsLineChange,localized:"preference.ai.native.codeEdits.lineChange"}]})),this.aiNativeConfigService.capabilities.supportsInlineChat&&Z.registerSettingSection(o.AI_NATIVE_SETTING_GROUP_ID,{title:(0,o.localize)("preference.ai.native.inlineChat.title"),preferences:[{id:o.AINativeSettingSectionsId.InlineChatAutoVisible,localized:"preference.ai.native.inlineChat.auto.visible"},{id:o.AINativeSettingSectionsId.InlineChatCodeActionEnabled,localized:"preference.ai.native.inlineChat.codeAction.enabled"},{id:o.AINativeSettingSectionsId.InlineDiffPreviewMode,localized:"preference.ai.native.inlineDiff.preview.mode"}]})}registerEditorFeature(Z){Z.registerEditorFeatureContribution({contribute:G=>{const{monacoEditor:H}=G;return this.codeActionSingleHandler.mountEditor(G.monacoEditor),H.onDidScrollChange(()=>{this.ctxMenuRenderer.visible&&this.ctxMenuRenderer.hide(!0)})}})}registerCommands(Z){Z.registerCommand(l.AI_INLINE_CHAT_VISIBLE,{execute:G=>{this.aiInlineChatService._onInlineChatVisible.fire(G)}}),Z.registerCommand(l.AI_INLINE_CHAT_INTERACTIVE_INPUT_VISIBLE,{execute:G=>{G?this.inlineInputChatService.visible():this.inlineInputChatService.hide(),this.aiInlineChatService._onInteractiveInputVisible.fire(G)}}),Z.registerCommand(l.AI_INLINE_COMPLETION_REPORTER,{execute:(G,H,$,J)=>{this.aiCompletionsService.report({sessionId:H,accept:$,relationId:G,code:J})}}),Z.registerCommand(l.AI_CHAT_VISIBLE,{execute:G=>{this.layoutService.toggleSlot(f.AI_CHAT_VIEW_ID,(0,v.isUndefined)(G)?!0:G)}}),Z.registerCommand(l.AI_INLINE_COMPLETION_VISIBLE,{execute:async G=>{G||(this.aiCompletionsService.hideStatusBarItem(),this.aiInlineCompletionsProvider.setVisibleCompletion(!1),this.aiInlineCompletionsProvider.cancelRequest())}}),Z.registerCommand(l.AI_INLINE_DIFF_PARTIAL_EDIT,{execute:G=>{this.inlineStreamDiffService.launchAcceptDiscardPartialEdit(G)}}),Z.afterExecuteCommand(u.HideInlineCompletion.ID,()=>{this.commandService.executeCommand(l.AI_INLINE_COMPLETION_VISIBLE.id,!1)})}registerRenderer(Z){this.designLayoutConfig.supportExternalChatPanel?Z.registerSlotRenderer(f.AI_CHAT_VIEW_ID,P.AIChatTabRendererWithTab):Z.registerSlotRenderer(f.AI_CHAT_VIEW_ID,P.AIChatTabRenderer),this.designLayoutConfig.useMergeRightWithLeftPanel&&(Z.registerSlotRenderer(o.SlotLocation.left,P.AILeftTabRenderer),Z.registerSlotRenderer(o.SlotLocation.right,P.AIRightTabRenderer))}registerComponent(Z){Z.register(f.AI_CHAT_CONTAINER_ID,[],{component:b.AIChatView,title:(0,o.localize)("aiNative.chat.ai.assistant.name"),iconClass:(0,o.getIcon)("magic-wand"),containerId:f.AI_CHAT_CONTAINER_ID}),Z.register(f.AI_MENU_BAR_DEBUG_TOOLBAR,{id:f.AI_MENU_BAR_DEBUG_TOOLBAR,component:O.AIRunToolbar}),Z.register(f.AI_CHAT_LOGO_AVATAR_ID,{id:f.AI_CHAT_LOGO_AVATAR_ID,component:R.AIChatLogoAvatar})}registerKeybindings(Z){this.aiNativeConfigService.capabilities.supportsInlineChat&&(Z.registerKeybinding({command:l.AI_INLINE_CHAT_VISIBLE.id,keybinding:"ctrlcmd+i",when:"editorTextFocus",args:!0,priority:0},o.KeybindingScope.USER),Z.registerKeybinding({command:l.AI_INLINE_CHAT_VISIBLE.id,keybinding:"esc",args:!1,when:`editorFocus && ${m.InlineChatIsVisible.raw}`}),this.inlineChatFeatureRegistry.getInteractiveInputHandler()&&(Z.registerKeybinding({command:l.AI_INLINE_CHAT_INTERACTIVE_INPUT_VISIBLE.id,keybinding:"ctrlcmd+k",args:!0,priority:0,when:`editorFocus && (${m.InlineChatIsVisible.raw} || inlineSuggestionVisible)`},o.KeybindingScope.USER),Z.registerKeybinding({command:l.AI_INLINE_CHAT_INTERACTIVE_INPUT_VISIBLE.id,keybinding:"esc",args:!1,priority:0,when:`editorFocus && ${m.InlineInputWidgetIsVisible.raw}`}),Z.registerKeybinding({command:l.AI_INLINE_CHAT_INTERACTIVE_INPUT_VISIBLE.id,keybinding:"ctrlcmd+k",args:!0,priority:0,when:`editorFocus && ${m.InlineHintWidgetIsVisible.raw} && ${m.InlineChatIsVisible.not}`},o.KeybindingScope.USER))),Z.registerKeybinding({command:l.AI_INLINE_DIFF_PARTIAL_EDIT.id,keybinding:"ctrl+y",args:!0,priority:100,when:`editorTextFocus && ${m.InlineDiffPartialEditsIsVisible.raw}`}),Z.registerKeybinding({command:l.AI_INLINE_DIFF_PARTIAL_EDIT.id,keybinding:"ctrl+n",args:!1,priority:100,when:`editorTextFocus && ${m.InlineDiffPartialEditsIsVisible.raw}`})}};t.AINativeBrowserContribution=Q,n.__decorate([(0,r.Autowired)(o.AppConfig),n.__metadata("design:type",Object)],Q.prototype,"appConfig",void 0),n.__decorate([(0,r.Autowired)(r.INJECTOR_TOKEN),n.__metadata("design:type",r.Injector)],Q.prototype,"injector",void 0),n.__decorate([(0,r.Autowired)(p.IBrowserCtxMenu),n.__metadata("design:type",p.IBrowserCtxMenu)],Q.prototype,"ctxMenuRenderer",void 0),n.__decorate([(0,r.Autowired)(M.AINativeCoreContribution),n.__metadata("design:type",Object)],Q.prototype,"contributions",void 0),n.__decorate([(0,r.Autowired)(v.InlineChatFeatureRegistryToken),n.__metadata("design:type",B.InlineChatFeatureRegistry)],Q.prototype,"inlineChatFeatureRegistry",void 0),n.__decorate([(0,r.Autowired)(v.ChatFeatureRegistryToken),n.__metadata("design:type",Object)],Q.prototype,"chatFeatureRegistry",void 0),n.__decorate([(0,r.Autowired)(v.ChatRenderRegistryToken),n.__metadata("design:type",Object)],Q.prototype,"chatRenderRegistry",void 0),n.__decorate([(0,r.Autowired)(v.ResolveConflictRegistryToken),n.__metadata("design:type",Object)],Q.prototype,"resolveConflictRegistry",void 0),n.__decorate([(0,r.Autowired)(v.RenameCandidatesProviderRegistryToken),n.__metadata("design:type",Object)],Q.prototype,"renameCandidatesProviderRegistry",void 0),n.__decorate([(0,r.Autowired)(v.TerminalRegistryToken),n.__metadata("design:type",Object)],Q.prototype,"terminalProviderRegistry",void 0),n.__decorate([(0,r.Autowired)(v.IntelligentCompletionsRegistryToken),n.__metadata("design:type",Object)],Q.prototype,"intelligentCompletionsRegistry",void 0),n.__decorate([(0,r.Autowired)(v.ProblemFixRegistryToken),n.__metadata("design:type",Object)],Q.prototype,"problemFixProviderRegistry",void 0),n.__decorate([(0,r.Autowired)(o.AINativeConfigService),n.__metadata("design:type",o.AINativeConfigService)],Q.prototype,"aiNativeConfigService",void 0),n.__decorate([(0,r.Autowired)(E.DesignLayoutConfig),n.__metadata("design:type",E.DesignLayoutConfig)],Q.prototype,"designLayoutConfig",void 0),n.__decorate([(0,r.Autowired)(w.AICompletionsService),n.__metadata("design:type",w.AICompletionsService)],Q.prototype,"aiCompletionsService",void 0),n.__decorate([(0,r.Autowired)(S.AIInlineCompletionsProvider),n.__metadata("design:type",S.AIInlineCompletionsProvider)],Q.prototype,"aiInlineCompletionsProvider",void 0),n.__decorate([(0,r.Autowired)(v.CommandService),n.__metadata("design:type",Object)],Q.prototype,"commandService",void 0),n.__decorate([(0,r.Autowired)(o.PreferenceService),n.__metadata("design:type",Object)],Q.prototype,"preferenceService",void 0),n.__decorate([(0,r.Autowired)(c.IMainLayoutService),n.__metadata("design:type",Object)],Q.prototype,"layoutService",void 0),n.__decorate([(0,r.Autowired)(f.ChatProxyServiceToken),n.__metadata("design:type",a.ChatProxyService)],Q.prototype,"chatProxyService",void 0),n.__decorate([(0,r.Autowired)(o.IAIInlineChatService),n.__metadata("design:type",x.AIInlineChatService)],Q.prototype,"aiInlineChatService",void 0),n.__decorate([(0,r.Autowired)(U.InlineInputChatService),n.__metadata("design:type",U.InlineInputChatService)],Q.prototype,"inlineInputChatService",void 0),n.__decorate([(0,r.Autowired)(X.InlineStreamDiffService),n.__metadata("design:type",X.InlineStreamDiffService)],Q.prototype,"inlineStreamDiffService",void 0),n.__decorate([(0,r.Autowired)(I.RenameSingleHandler),n.__metadata("design:type",I.RenameSingleHandler)],Q.prototype,"renameSingleHandler",void 0),n.__decorate([(0,r.Autowired)(y.CodeActionSingleHandler),n.__metadata("design:type",y.CodeActionSingleHandler)],Q.prototype,"codeActionSingleHandler",void 0),t.AINativeBrowserContribution=Q=n.__decorate([(0,o.Domain)(o.ClientAppContribution,g.BrowserEditorContribution,o.CommandContribution,h.SettingContribution,o.KeybindingContribution,o.ComponentContribution,o.SlotRendererContribution,o.MonacoContribution),n.__metadata("design:paramtypes",[])],Q)},74055:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ChatAgentService=void 0;const n=e(85608),r=n.__importDefault(e(66652)),o=e(76003),l=e(43718),m=e(29770);let E=class extends l.Disposable{constructor(){super(),this.agents=new Map,this._onDidChangeAgents=new l.Emitter,this.onDidChangeAgents=this._onDidChangeAgents.event,this._onDidSendMessage=new l.Emitter,this.onDidSendMessage=this._onDidSendMessage.event,this.addDispose(this._onDidChangeAgents)}registerAgent(v){if(this.agents.has(v.id))throw new Error(`Already registered an agent with id ${v.id}`);return this.agents.set(v.id,{agent:v,commands:[]}),this._onDidChangeAgents.fire(),(0,l.toDisposable)(()=>{this.agents.delete(v.id)&&this._onDidChangeAgents.fire()})}async updateAgent(v,s){const g=this.agents.get(v);if(!g)throw new Error(`No agent with id ${v} registered`);g.agent.metadata={...g.agent.metadata,...s},g.commands=await g.agent.provideSlashCommands(l.CancellationToken.None),s.isDefault&&(this.defaultAgentId=v);const c=await g.agent.provideChatWelcomeMessage(l.CancellationToken.None);if(c){const{content:h,sampleQuestions:d}=c;this.chatFeatureRegistry.registerWelcome(h,d)}this._onDidChangeAgents.fire()}getAgents(){return Array.from(this.agents.values(),v=>v.agent)}hasAgent(v){return this.agents.has(v)}getDefaultAgentId(){return this.defaultAgentId}getAgent(v){const s=this.agents.get(v);return s?.agent}async invokeAgent(v,s,g,c,h){const d=this.agents.get(v);if(!d)throw new Error(`No agent with id ${v}`);return await d.agent.invoke(s,g,c,h)}populateChatInput(v,s){this.aiChatService.sendMessage({...s,agentId:v,immediate:!1})}getCommands(){return(0,r.default)(Array.from(this.agents.values(),({agent:v,commands:s})=>s.map(g=>({...g,agentId:v.id}))))}async getFollowups(v,s,g){const c=this.agents.get(v);if(!c)throw new Error(`No agent with id ${v}`);return c.agent.provideFollowups?c.agent.provideFollowups(s,g):[]}async getSampleQuestions(v,s){const g=this.agents.get(v);if(!g)throw new Error(`No agent with id ${v}`);return g.agent.provideSampleQuestions?g.agent.provideSampleQuestions(s):[]}async getAllSampleQuestions(){const v=await Promise.all(Array.from(this.agents.values()).map(async({agent:s})=>{try{return await this.getSampleQuestions(s.id,l.CancellationToken.None)}catch(g){return this.logger.error(g),[]}}));return(0,r.default)(v)}sendMessage(v){this._onDidSendMessage.fire(v)}parseMessage(v,s){var g;const c={agentId:"",command:"",message:v};let h=s;const d=this.getAgents(),u=new RegExp(`^@(${d.map(f=>f.id).join("|")})(?:\\s+|$)`,"i"),_=c.message.match(u);if(_){const f=d.find(a=>a.id.toLowerCase()===_[1].toLowerCase());if(!f)return c;h=f.id,c.agentId=h,c.message=c.message.replace(_[0],"")}if(h){const f=(g=this.agents.get(h))===null||g===void 0?void 0:g.commands;if(f?.length){const a=new RegExp(`^/\\s?(${f.map(y=>y.name).join("|")})(?:\\s+|$)`,"i"),b=c.message.match(a);if(b){const y=f.find(S=>S.name.toLowerCase()===b[1].toLowerCase());if(!y)return c;c.command=y.name,c.message=c.message.replace(b[0],"")}}}return c}};t.ChatAgentService=E,n.__decorate([(0,o.Autowired)(l.ILogger),n.__metadata("design:type",Object)],E.prototype,"logger",void 0),n.__decorate([(0,o.Autowired)(l.ChatServiceToken),n.__metadata("design:type",m.ChatService)],E.prototype,"aiChatService",void 0),n.__decorate([(0,o.Autowired)(l.ChatFeatureRegistryToken),n.__metadata("design:type",Object)],E.prototype,"chatFeatureRegistry",void 0),t.ChatAgentService=E=n.__decorate([(0,o.Injectable)(),n.__metadata("design:paramtypes",[])],E)},84543:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ChatAgentViewService=void 0;const n=e(85608),r=e(76003),o=e(43718),l=e(19413),m=e(51081);let E=class{constructor(){this.componentsMap=new Map,this.componentsDeferredMap=new Map}registerChatComponent(v){return this.componentsMap.set(v.id,v),this.componentsDeferredMap.has(v.id)&&(this.componentsDeferredMap.get(v.id).resolve(v),this.componentsDeferredMap.delete(v.id)),{dispose:()=>{this.componentsMap.get(v.id)===v&&(this.componentsMap.delete(v.id),this.componentsDeferredMap.delete(v.id))}}}getChatComponent(v){return this.componentsMap.has(v)?this.componentsMap.get(v):(this.componentsDeferredMap.has(v)||this.componentsDeferredMap.set(v,new o.Deferred),null)}getChatComponentDeferred(v){return this.componentsDeferredMap.get(v)||null}getRenderAgents(){return this.chatAgentService.getAgents().filter(v=>v.id!==m.ChatProxyService.AGENT_ID)}};t.ChatAgentViewService=E,n.__decorate([(0,r.Autowired)(l.IChatAgentService),n.__metadata("design:type",Object)],E.prototype,"chatAgentService",void 0),t.ChatAgentViewService=E=n.__decorate([(0,r.Injectable)()],E)},61282:(L,t,e)=>{"use strict";var n,r;Object.defineProperty(t,"__esModule",{value:!0}),t.ChatManagerService=void 0;const o=e(85608),l=e(76003),m=e(43718),E=e(19413),p=e(42033);let v=class extends m.Disposable{constructor(){super(),n.set(this,this.registerDispose(new m.DisposableMap)),r.set(this,this.registerDispose(new m.DisposableMap))}startSession(){const g=this.injector.get(p.ChatModel);return o.__classPrivateFieldGet(this,n,"f").set(g.sessionId,g),g}getSession(g){return o.__classPrivateFieldGet(this,n,"f").get(g)}clearSession(g){var c;if(!o.__classPrivateFieldGet(this,n,"f").get(g))throw new Error(`Unknown session: ${g}`);o.__classPrivateFieldGet(this,n,"f").disposeKey(g),(c=o.__classPrivateFieldGet(this,r,"f").get(g))===null||c===void 0||c.cancel(),o.__classPrivateFieldGet(this,r,"f").disposeKey(g)}createRequest(g,c,h,d){const u=this.getSession(g);if(!u)throw new Error(`Unknown session: ${g}`);if(!o.__classPrivateFieldGet(this,r,"f").has(g))return u.addRequest({prompt:c,agentId:h,command:d})}async sendRequest(g,c,h){const d=this.getSession(g);if(!d)throw new Error(`Unknown session: ${g}`);const u=new m.CancellationTokenSource,_=u.token;o.__classPrivateFieldGet(this,r,"f").set(d.sessionId,u);const f=_.onCancellationRequested(()=>{c.response.cancel()}),a=[];for(const b of d.requests)b.response.isComplete&&(a.push({role:1,content:b.message.prompt}),a.push({role:2,content:b.response.responseText}));try{const b=A=>{_.isCancellationRequested||d.acceptResponseProgress(c,A)},y={sessionId:g,requestId:c.requestId,message:c.message.prompt,command:c.message.command,regenerate:h},S=await this.chatAgentService.invokeAgent(c.message.agentId,y,b,a,_);_.isCancellationRequested||(S.errorDetails&&c.response.setErrorDetails(S.errorDetails),this.chatAgentService.getFollowups(c.message.agentId,g,m.CancellationToken.None).then(w=>{c.response.setFollowups(w),c.response.complete()}))}finally{f.dispose(),o.__classPrivateFieldGet(this,r,"f").disposeKey(d.sessionId)}}cancelRequest(g){var c;(c=o.__classPrivateFieldGet(this,r,"f").get(g))===null||c===void 0||c.cancel(),o.__classPrivateFieldGet(this,r,"f").disposeKey(g)}};t.ChatManagerService=v,n=new WeakMap,r=new WeakMap,o.__decorate([(0,l.Autowired)(l.INJECTOR_TOKEN),o.__metadata("design:type",l.Injector)],v.prototype,"injector",void 0),o.__decorate([(0,l.Autowired)(E.IChatAgentService),o.__metadata("design:type",Object)],v.prototype,"chatAgentService",void 0),t.ChatManagerService=v=o.__decorate([(0,l.Injectable)(),o.__metadata("design:paramtypes",[])],v)},42033:(L,t,e)=>{"use strict";var n,r,o,l,m,E,p,v,s,g,c,h,d,u,_,f;Object.defineProperty(t,"__esModule",{value:!0}),t.ChatSlashCommandItemModel=t.ChatWelcomeMessageModel=t.ChatModel=t.ChatRequestModel=t.ChatResponseModel=void 0;const a=e(85608),b=e(76003),y=e(43718),S=e(90684),A=e(19413),w=e(44260);let T=class extends y.Disposable{get responseParts(){return a.__classPrivateFieldGet(this,r,"f")}get responseContents(){return a.__classPrivateFieldGet(this,o,"f")}get isComplete(){return a.__classPrivateFieldGet(this,l,"f")}get isCanceled(){return a.__classPrivateFieldGet(this,m,"f")}get requestId(){return a.__classPrivateFieldGet(this,E,"f")}get responseText(){return a.__classPrivateFieldGet(this,p,"f")}get errorDetails(){return a.__classPrivateFieldGet(this,v,"f")}get followups(){return a.__classPrivateFieldGet(this,s,"f")}get onDidChange(){return a.__classPrivateFieldGet(this,g,"f").event}constructor(M,k,B){super(),n.add(this),this.session=k,this.agentId=B,r.set(this,[]),o.set(this,[]),l.set(this,!1),m.set(this,!1),E.set(this,void 0),p.set(this,""),v.set(this,void 0),s.set(this,void 0),g.set(this,this.registerDispose(new y.Emitter)),a.__classPrivateFieldSet(this,E,M,"f")}updateContent(M,k){var B;if(M.kind==="content"||M.kind==="markdownContent"){const x=a.__classPrivateFieldGet(this,r,"f").length-1,N=a.__classPrivateFieldGet(this,r,"f")[x];!N||N.kind!=="markdownContent"?M.kind==="content"?a.__classPrivateFieldGet(this,r,"f").push({content:new S.MarkdownString(M.content),kind:"markdownContent"}):a.__classPrivateFieldGet(this,r,"f").push(M):M.kind==="markdownContent"?a.__classPrivateFieldGet(this,r,"f")[x]={content:new S.MarkdownString(N.content.value+M.content.value),kind:"markdownContent"}:a.__classPrivateFieldGet(this,r,"f")[x]={content:new S.MarkdownString(N.content.value+M.content,N.content),kind:"markdownContent"},a.__classPrivateFieldGet(this,n,"m",c).call(this)}else if(M.kind==="asyncContent"){const x=a.__classPrivateFieldGet(this,r,"f").push(M)-1;a.__classPrivateFieldGet(this,n,"m",c).call(this),(B=M.resolvedContent)===null||B===void 0||B.then(N=>{typeof N=="string"?a.__classPrivateFieldGet(this,r,"f")[x]={content:new S.MarkdownString(N),kind:"markdownContent"}:(0,S.isMarkdownString)(N)?a.__classPrivateFieldGet(this,r,"f")[x]={content:N,kind:"markdownContent"}:a.__classPrivateFieldGet(this,r,"f")[x]=N,a.__classPrivateFieldGet(this,n,"m",c).call(this,k)})}else M.kind==="treeData"?(a.__classPrivateFieldGet(this,r,"f").push(M),a.__classPrivateFieldGet(this,n,"m",c).call(this,k)):M.kind==="component"&&(a.__classPrivateFieldGet(this,r,"f").push(M),a.__classPrivateFieldGet(this,n,"m",c).call(this,k))}complete(){a.__classPrivateFieldSet(this,l,!0,"f"),a.__classPrivateFieldGet(this,g,"f").fire()}cancel(){a.__classPrivateFieldSet(this,l,!0,"f"),a.__classPrivateFieldSet(this,m,!0,"f"),a.__classPrivateFieldGet(this,g,"f").fire()}reset(){a.__classPrivateFieldSet(this,o,[],"f"),a.__classPrivateFieldSet(this,r,[],"f"),a.__classPrivateFieldSet(this,p,"","f"),a.__classPrivateFieldSet(this,m,!1,"f"),a.__classPrivateFieldSet(this,l,!1,"f"),a.__classPrivateFieldSet(this,v,void 0,"f"),a.__classPrivateFieldSet(this,s,void 0,"f"),a.__classPrivateFieldGet(this,g,"f").fire()}setErrorDetails(M){a.__classPrivateFieldSet(this,v,M,"f"),a.__classPrivateFieldGet(this,g,"f").fire()}setFollowups(M){a.__classPrivateFieldSet(this,s,M,"f"),a.__classPrivateFieldGet(this,g,"f").fire()}};t.ChatResponseModel=T,r=new WeakMap,o=new WeakMap,l=new WeakMap,m=new WeakMap,E=new WeakMap,p=new WeakMap,v=new WeakMap,s=new WeakMap,g=new WeakMap,n=new WeakSet,c=function(M){a.__classPrivateFieldSet(this,p,a.__classPrivateFieldGet(this,r,"f").map(B=>B.kind==="asyncContent"?B.content:B.kind==="treeData"||B.kind==="component"?"":B.content.value).join(`
|
|
28184
28184
|
|
|
28185
28185
|
`),"f");const k=[];for(const B of a.__classPrivateFieldGet(this,r,"f")){const x=k[k.length-1];B.kind==="markdownContent"&&x?.kind==="markdownContent"?k[k.length-1]={content:new S.MarkdownString(x.content.value+B.content.value,{isTrusted:x.content.isTrusted}),kind:"markdownContent"}:k.push(B)}a.__classPrivateFieldSet(this,o,k,"f"),M||a.__classPrivateFieldGet(this,g,"f").fire()},t.ChatResponseModel=T=a.__decorate([(0,b.Injectable)({multiple:!0}),a.__metadata("design:paramtypes",[String,Object,String])],T);let D=class{get requestId(){return a.__classPrivateFieldGet(this,h,"f")}constructor(M,k,B,x){this.session=k,this.message=B,this.response=x,h.set(this,void 0),a.__classPrivateFieldSet(this,h,M,"f")}};t.ChatRequestModel=D,h=new WeakMap,t.ChatRequestModel=D=a.__decorate([(0,b.Injectable)({multiple:!0}),a.__metadata("design:paramtypes",[String,Object,Object,T])],D);let I=_=class extends y.Disposable{constructor(){super(...arguments),d.set(this,(0,y.uuid)()),u.set(this,new Map)}get sessionId(){return a.__classPrivateFieldGet(this,d,"f")}get requests(){return Array.from(a.__classPrivateFieldGet(this,u,"f").values())}get history(){return this.injector.get(w.MsgHistoryManager,[])}addRequest(M){const k=`${this.sessionId}_request_${_.requestIdPool++}`,B=new T(k,this,M.agentId),x=new D(k,this,M,B);return a.__classPrivateFieldGet(this,u,"f").set(k,x),x}acceptResponseProgress(M,k,B){if(M.response.isComplete)throw new Error("acceptResponseProgress: Adding progress to a completed response");const{kind:x}=k;["content","markdownContent","asyncContent","treeData","component"].includes(x)?M.response.updateContent(k,B):this.logger.error(`Couldn't handle progress: ${JSON.stringify(k)}`)}getRequest(M){return a.__classPrivateFieldGet(this,u,"f").get(M)}dispose(){super.dispose(),a.__classPrivateFieldGet(this,u,"f").forEach(M=>M.response.dispose())}};t.ChatModel=I,d=new WeakMap,u=new WeakMap,I.requestIdPool=0,a.__decorate([(0,b.Autowired)(y.ILogger),a.__metadata("design:type",Object)],I.prototype,"logger",void 0),a.__decorate([(0,b.Autowired)(b.INJECTOR_TOKEN),a.__metadata("design:type",b.Injector)],I.prototype,"injector",void 0),a.__decorate([y.memoize,a.__metadata("design:type",w.MsgHistoryManager),a.__metadata("design:paramtypes",[])],I.prototype,"history",null),t.ChatModel=I=_=a.__decorate([(0,b.Injectable)({multiple:!0})],I);let O=f=class extends y.Disposable{get id(){return this._id}constructor(M,k){super(),this.content=M,this.sampleQuestions=k,this._id="welcome_"+f.nextId++}};t.ChatWelcomeMessageModel=O,O.nextId=0,t.ChatWelcomeMessageModel=O=f=a.__decorate([(0,b.Injectable)({multiple:!0}),a.__metadata("design:paramtypes",[Object,Array])],O);let P=class extends y.Disposable{constructor(M,k,B){super(),this.chatCommand=M,this.command=k,this.agentId=B}get name(){return this.chatCommand.name}get isShortcut(){return!!this.chatCommand.isShortcut}get icon(){return this.chatCommand.icon}get description(){return this.chatCommand.description}get tooltip(){return this.chatCommand.tooltip}get nameWithSlash(){return this.name.startsWith(A.SLASH_SYMBOL)?this.name:`${A.SLASH_SYMBOL} ${this.name}`}};t.ChatSlashCommandItemModel=P,t.ChatSlashCommandItemModel=P=a.__decorate([(0,b.Injectable)({multiple:!0}),a.__metadata("design:paramtypes",[Object,String,String])],P)},51081:(L,t,e)=>{"use strict";var n;Object.defineProperty(t,"__esModule",{value:!0}),t.ChatProxyService=void 0;const r=e(85608),o=e(76003),l=e(43718),m=e(9447),E=e(93062),p=e(19413),v=e(29770),s=e(11735);let g=n=class extends l.Disposable{constructor(){super(...arguments),this.chatDeferred=new l.Deferred}registerDefaultAgent(){this.addDispose(this.chatAgentService.registerAgent({id:n.AGENT_ID,metadata:{},invoke:async(h,d,u,_)=>{this.chatDeferred=new l.Deferred;const{message:f,command:a}=h;let b=f;if(a){const S=this.chatFeatureRegistry.getSlashCommandHandler(a);if(S&&S.providerPrompt){const A=this.monacoCommandRegistry.getActiveCodeEditor();b=await S.providerPrompt(f,A)}}const y=await this.aiBackService.requestStream(b,{requestId:h.requestId,sessionId:h.sessionId,history:this.aiChatService.getHistoryMessages()},_);return(0,E.listenReadable)(y,{onData:S=>{d(S)},onEnd:()=>{this.chatDeferred.resolve()},onError:S=>{this.aiReporter.end(h.sessionId+"_"+h.requestId,{message:S.message,success:!1,command:a})}}),await this.chatDeferred.promise,{}},provideSlashCommands:async h=>this.chatFeatureRegistry.getAllSlashCommand().map(d=>({...d,name:d.name,description:d.description||""})),provideChatWelcomeMessage:async h=>{}})),queueMicrotask(()=>{this.chatAgentService.updateAgent(n.AGENT_ID,{})})}};t.ChatProxyService=g,g.AGENT_ID="Default_Chat_Agent_"+(0,l.uuid)(6),r.__decorate([(0,o.Autowired)(p.IChatAgentService),r.__metadata("design:type",Object)],g.prototype,"chatAgentService",void 0),r.__decorate([(0,o.Autowired)(l.AIBackSerivcePath),r.__metadata("design:type",Object)],g.prototype,"aiBackService",void 0),r.__decorate([(0,o.Autowired)(l.ChatFeatureRegistryToken),r.__metadata("design:type",s.ChatFeatureRegistry)],g.prototype,"chatFeatureRegistry",void 0),r.__decorate([(0,o.Autowired)(m.MonacoCommandRegistry),r.__metadata("design:type",m.MonacoCommandRegistry)],g.prototype,"monacoCommandRegistry",void 0),r.__decorate([(0,o.Autowired)(l.ChatServiceToken),r.__metadata("design:type",v.ChatService)],g.prototype,"aiChatService",void 0),r.__decorate([(0,o.Autowired)(l.IAIReporter),r.__metadata("design:type",Object)],g.prototype,"aiReporter",void 0),t.ChatProxyService=g=n=r.__decorate([(0,o.Injectable)()],g)},29770:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ChatService=void 0;const n=e(85608),r=e(76003),o=e(43718),l=e(63067),m=e(19413),E=e(59347);let p=class extends o.Disposable{constructor(){super(),this._onChatMessageLaunch=new o.Emitter,this.onChatMessageLaunch=this._onChatMessageLaunch.event,this._onChatReplyMessageLaunch=new o.Emitter,this.onChatReplyMessageLaunch=this._onChatReplyMessageLaunch.event,this._onChatMessageListLaunch=new o.Emitter,this.onChatMessageListLaunch=this._onChatMessageListLaunch.event,this._onScrollToBottom=new o.Emitter,this.onScrollToBottom=this._onScrollToBottom.event}showChatView(){this.mainLayoutService.toggleSlot(m.AI_CHAT_VIEW_ID,!0)}sendMessage(s){this.showChatView(),this._onChatMessageLaunch.fire(s)}clearHistoryMessages(){var s;(s=this.chatInternalService.sessionModel)===null||s===void 0||s.history.clearMessages()}sendReplyMessage(s){typeof s=="string"?this._onChatReplyMessageLaunch.fire({kind:"content",content:s}):this._onChatReplyMessageLaunch.fire(s)}sendMessageList(s){this._onChatMessageListLaunch.fire(s)}getHistoryMessages(){var s;return((s=this.chatInternalService.sessionModel)===null||s===void 0?void 0:s.history.getMessages())||[]}scrollToBottom(){this._onScrollToBottom.fire()}};t.ChatService=p,n.__decorate([(0,r.Autowired)(m.IChatInternalService),n.__metadata("design:type",E.ChatInternalService)],p.prototype,"chatInternalService",void 0),n.__decorate([(0,r.Autowired)(l.IMainLayoutService),n.__metadata("design:type",Object)],p.prototype,"mainLayoutService",void 0),t.ChatService=p=n.__decorate([(0,r.Injectable)(),n.__metadata("design:paramtypes",[])],p)},11735:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ChatFeatureRegistry=void 0;const n=e(85608),r=e(76003),o=e(43718),l=e(19413),m=e(42033),E=e(51081);let p=class extends o.Disposable{constructor(){super(...arguments),this.logger=(0,o.getDebugLogger)(),this.slashCommandsMap=new Map,this.slashCommandsHandlerMap=new Map,this._onDidWelcomeMessageChange=new o.Emitter,this.onDidWelcomeMessageChange=this._onDidWelcomeMessageChange.event}dispose(){super.dispose(),this.slashCommandsMap.clear(),this.slashCommandsHandlerMap.clear()}registerWelcome(s,g){this.chatWelcomeMessageModel=new m.ChatWelcomeMessageModel(s,g),this._onDidWelcomeMessageChange.fire()}registerSlashCommand(s,g){const{name:c}=s;if(this.slashCommandsMap.has(c)){this.logger.warn(`ChatFeatureRegistry: commands name ${c} already exists`);return}this.slashCommandsMap.set(c,new m.ChatSlashCommandItemModel(s,c,E.ChatProxyService.AGENT_ID)),this.slashCommandsHandlerMap.set(c,g)}getSlashCommandHandler(s){return this.slashCommandsHandlerMap.get(s)}getSlashCommand(s){return this.slashCommandsMap.get(s)}getSlashCommandHandlerBySlashName(s){const g=this.getAllSlashCommand().find(c=>c.nameWithSlash===s);if(g)return this.getSlashCommandHandler(g.name)}getSlashCommandBySlashName(s){const g=this.getAllSlashCommand().find(c=>c.nameWithSlash===s);if(g)return this.getSlashCommand(g.name)}getAllSlashCommand(){return Array.from(this.slashCommandsMap.values())}getAllShortcutSlashCommand(){return this.getAllSlashCommand().filter(s=>s.isShortcut===!0)}parseSlashCommand(s){if(s.startsWith(l.SLASH_SYMBOL)){const g=this.getAllSlashCommand();for(const c of g){const{nameWithSlash:h}=c;if(s.startsWith(h))return{value:s.slice(h.length),nameWithSlash:h}}}return{value:s,nameWithSlash:""}}};t.ChatFeatureRegistry=p,t.ChatFeatureRegistry=p=n.__decorate([(0,r.Injectable)()],p)},59347:(L,t,e)=>{"use strict";var n;Object.defineProperty(t,"__esModule",{value:!0}),t.ChatInternalService=void 0;const r=e(85608),o=e(76003),l=e(41869),m=e(43718),E=e(19413),p=e(61282);let v=class extends m.Disposable{get latestRequestId(){return this._latestRequestId}get sessionModel(){return r.__classPrivateFieldGet(this,n,"f")}constructor(){super(),this._onChangeRequestId=new m.Emitter,this.onChangeRequestId=this._onChangeRequestId.event,this._onChangeSession=new m.Emitter,this.onChangeSession=this._onChangeSession.event,n.set(this,void 0),r.__classPrivateFieldSet(this,n,this.chatManagerService.startSession(),"f")}setLatestRequestId(g){this._latestRequestId=g,this._onChangeRequestId.fire(g)}createRequest(g,c,h){return this.chatManagerService.createRequest(r.__classPrivateFieldGet(this,n,"f").sessionId,g,c,h)}sendRequest(g,c=!1){return this.chatManagerService.sendRequest(r.__classPrivateFieldGet(this,n,"f").sessionId,g,c)}cancelRequest(){this.chatManagerService.cancelRequest(r.__classPrivateFieldGet(this,n,"f").sessionId)}clearSessionModel(){this.chatManagerService.clearSession(r.__classPrivateFieldGet(this,n,"f").sessionId),r.__classPrivateFieldSet(this,n,this.chatManagerService.startSession(),"f"),this._onChangeSession.fire(r.__classPrivateFieldGet(this,n,"f").sessionId)}activateSession(g){const c=this.chatManagerService.getSession(g);if(!c)throw new Error(`There is no session with session id ${g}`);r.__classPrivateFieldSet(this,n,c,"f"),this._onChangeSession.fire(r.__classPrivateFieldGet(this,n,"f").sessionId)}dispose(){var g;(g=r.__classPrivateFieldGet(this,n,"f"))===null||g===void 0||g.dispose(),super.dispose()}};t.ChatInternalService=v,n=new WeakMap,r.__decorate([(0,o.Autowired)(m.AIBackSerivcePath),r.__metadata("design:type",Object)],v.prototype,"aiBackService",void 0),r.__decorate([(0,o.Autowired)(l.PreferenceService),r.__metadata("design:type",Object)],v.prototype,"preferenceService",void 0),r.__decorate([(0,o.Autowired)(E.IChatManagerService),r.__metadata("design:type",p.ChatManagerService)],v.prototype,"chatManagerService",void 0),t.ChatInternalService=v=r.__decorate([(0,o.Injectable)(),r.__metadata("design:paramtypes",[])],v)},70394:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ChatRenderRegistry=void 0;const n=e(85608),r=e(76003),o=e(43718);let l=class extends o.Disposable{registerWelcomeRender(E){this.chatWelcomeRender=E}registerAIRoleRender(E){this.chatAIRoleRender=E}registerUserRoleRender(E){this.chatUserRoleRender=E}registerThinkingRender(E){this.chatThinkingRender=E}registerInputRender(E){this.chatInputRender=E}registerThinkingResultRender(E){this.chatThinkingResultRender=E}registerChatViewHeaderRender(E){this.chatViewHeaderRender=E}};t.ChatRenderRegistry=l,t.ChatRenderRegistry=l=n.__decorate([(0,r.Injectable)()],l)},76154:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AIChatView=void 0,t.DefaultChatViewHeader=w;const n=e(85608),r=n.__importStar(e(14041)),o=e(68392),l=e(41869),m=e(81878),E=e(89195),p=e(43718),v=e(63067);e(41937);const s=e(19413),g=e(25834),c=e(57987),h=e(56474),d=e(92635),u=e(29039),_=e(78048),f=e(86556),a=e(42033),b=e(51081),y=n.__importDefault(e(77256)),S="chat_scroll",A=()=>{const T=(0,l.useInjectable)(s.IChatInternalService),D=(0,l.useInjectable)(p.ChatServiceToken),I=(0,l.useInjectable)(p.IAIReporter),O=(0,l.useInjectable)(s.IChatAgentService),P=(0,l.useInjectable)(p.ChatFeatureRegistryToken),R=(0,l.useInjectable)(p.ChatRenderRegistryToken),M=(0,l.useInjectable)(v.IMainLayoutService),k=T.sessionModel.history,B=r.useRef(null),x=r.useRef(null),[N,j]=r.useState([]),[K,U]=r.useReducer((we,le)=>{switch(le.type){case"add":return[...we,...le.payload||[]];case"clear":return[];case"init":return Array.isArray(le.payload)?le.payload:[];default:return we}},[]),[X,z]=r.useState(!1),[Q,Y]=r.useState(""),[Z,G]=r.useState(""),[H,$]=r.useState(""),[J,re]=r.useState(null);r.useEffect(()=>{const we=P.getAllShortcutSlashCommand(),le=O.onDidChangeAgents(()=>{const Se=O.getCommands().filter(Oe=>Oe.isShortcut).map(Oe=>new a.ChatSlashCommandItemModel({icon:"",name:`${Oe.name} `,description:Oe.description,isShortcut:Oe.isShortcut},Oe.name,Oe.agentId));j(we.concat(Se))});return j(we),()=>le.dispose()},[P,O]),(0,l.useUpdateOnEvent)(T.onChangeSession);const ce=r.useMemo(()=>R.chatInputRender?R.chatInputRender:c.ChatInput,[R.chatInputRender]),he=r.useMemo(()=>(0,_.createMessageByAI)({id:(0,p.uuid)(6),relationId:"",text:r.createElement(f.WelcomeMessage,null)}),[]),Ae=r.useCallback(()=>{if(B&&B.current){const we=B.current.lastElementChild;we&&we.scrollIntoView({behavior:"smooth",block:"end"}),B.current.scrollHeight>B.current.clientHeight&&B.current.classList.add(S)}},[B]),te=r.useCallback(we=>{U(we),requestAnimationFrame(()=>{Ae()})},[U,Ae]);r.useEffect(()=>{te({type:"init",payload:[he]})},[]),r.useEffect(()=>{const we=new p.Disposable;return we.addDispose(D.onScrollToBottom(()=>{requestAnimationFrame(()=>{Ae()})})),we.addDispose(D.onChatMessageLaunch(async le=>{var Se;if(le.immediate!==!1){if(X)return;await _e(le)}else le.agentId&&Y(le.agentId),le.command&&$(le.command),(Se=x?.current)===null||Se===void 0||Se.setInputValue(le.message)})),we.addDispose(D.onChatReplyMessageLaunch(le=>{if(le.kind==="content"){const Se=I.start(p.AIServiceType.CustomReplay,{message:le.content});k.addAssistantMessage({content:le.content,relationId:Se}),se({chunk:le.content,relationId:Se})}else{const Se=I.start(p.AIServiceType.CustomReplay,{message:"component#"+le.component});k.addAssistantMessage({componentId:le.component,componentValue:le.value,content:"",relationId:Se}),me({chunk:le,relationId:Se})}})),we.addDispose(D.onChatMessageListLaunch(le=>{const Se=[];le.forEach(Oe=>{const{role:Fe}=Oe,We=I.start(p.AIServiceType.Chat,{message:""});if(Fe==="assistant"){const Ve=Oe;Se.push((0,_.createMessageByAI)({id:(0,p.uuid)(6),relationId:We,text:r.createElement(d.ChatNotify,{requestId:We,chunk:Ve})},y.default.chat_notify))}if(Fe==="user"){const{message:Ve}=Oe,Ke=b.ChatProxyService.AGENT_ID,dt=R.chatUserRoleRender,ot=Ke===b.ChatProxyService.AGENT_ID?"":Ke;Se.push((0,_.createMessageByUser)({id:(0,p.uuid)(6),relationId:We,text:dt?r.createElement(dt,{content:Ve,agentId:ot}):r.createElement(g.CodeBlockWrapperInput,{relationId:We,text:Ve,agentId:ot,command:H})},y.default.chat_message_code))}}),te({type:"add",payload:Se}),setTimeout(Ae,0)})),()=>we.dispose()},[D,R.chatAIRoleRender,k]),r.useEffect(()=>{const we=new p.Disposable;return we.addDispose(O.onDidSendMessage(le=>{const Se=le,Oe=I.start(p.AIServiceType.Agent,{message:""}),Fe=(0,_.createMessageByAI)({id:(0,p.uuid)(6),relationId:Oe,text:r.createElement(d.ChatNotify,{requestId:T.latestRequestId,chunk:Se})},y.default.chat_notify);te({type:"add",payload:[Fe]})})),we.addDispose(O.onDidChangeAgents(async()=>{const le=O.getDefaultAgentId();G(le??"")})),()=>we.dispose()},[O,k,T]);const Pe=r.useCallback(async we=>{const{userMessage:le,relationId:Se,requestId:Oe,render:Fe,startTime:We,command:Ve,agentId:Ke}=we;k.addAssistantMessage({type:"component",content:""});const dt=(0,_.createMessageByAI)({id:(0,p.uuid)(6),relationId:Se,className:y.default.chat_with_more_actions,text:r.createElement(u.SlashCustomRender,{userMessage:le,startTime:We,relationId:Se,requestId:Oe,renderContent:Fe,command:Ve,agentId:Ke})});te({type:"add",payload:[dt]})},[B,k]),Te=r.useCallback(async we=>{const le=R.chatUserRoleRender,{message:Se,agentId:Oe,relationId:Fe,command:We}=we,Ve=Oe===b.ChatProxyService.AGENT_ID?"":Oe,Ke=(0,_.createMessageByUser)({id:(0,p.uuid)(6),relationId:Fe,text:le?r.createElement(le,{content:Se,agentId:Ve,command:We}):r.createElement(g.CodeBlockWrapperInput,{relationId:Fe,text:Se,agentId:Ve,command:We})},y.default.chat_message_code);te({type:"add",payload:[Ke]})},[R,R.chatUserRoleRender,k,Ae]),ie=r.useCallback(async we=>{const{message:le,agentId:Se,request:Oe,relationId:Fe,command:We,startTime:Ve,msgId:Ke}=we,dt=Se===b.ChatProxyService.AGENT_ID?"":Se;if(Se===b.ChatProxyService.AGENT_ID&&We){const vt=P.getSlashCommandHandler(We);if(vt&&vt.providerRender)return z(!1),Pe({userMessage:le,render:vt.providerRender,relationId:Fe,requestId:Oe.requestId,startTime:Ve,agentId:Se,command:We})}const ot=(0,_.createMessageByAI)({id:(0,p.uuid)(6),relationId:Fe,className:y.default.chat_with_more_actions,text:r.createElement(d.ChatReply,{relationId:Fe,request:Oe,startTime:Ve,agentId:dt,command:We,onDidChange:()=>{Ae()},history:k,onDone:()=>{z(!1)},onRegenerate:()=>{T.sendRequest(Oe,!0)},msgId:Ke})});te({type:"add",payload:[ot]})},[R,k,Ae]),se=r.useCallback(we=>{const{chunk:le,relationId:Se}=we;let Oe=r.createElement(h.ChatMarkdown,{markdown:le,fillInIncompleteTokens:!0,agentId:Q,command:H});if(R.chatAIRoleRender){const We=R.chatAIRoleRender;Oe=r.createElement(We,{content:le})}const Fe=(0,_.createMessageByAI)({id:(0,p.uuid)(6),relationId:Se,text:Oe,className:y.default.chat_with_more_actions});te({type:"add",payload:[Fe]})},[R,k,Ae]),me=r.useCallback(we=>{const{chunk:le,relationId:Se}=we,Oe=(0,_.createMessageByAI)({id:(0,p.uuid)(6),relationId:Se,text:r.createElement(d.ChatNotify,{requestId:Se,chunk:le})},y.default.chat_notify);te({type:"add",payload:[Oe]})},[R,k,Ae]),ye=r.useCallback(async we=>{const{message:le,agentId:Se,command:Oe,reportExtra:Fe}=we,{actionType:We,actionSource:Ve}=Fe||{},Ke=T.createRequest(le,Se,Oe);if(!Ke)return;z(!0),T.setLatestRequestId(Ke.requestId);const dt=Date.now(),ot=b.ChatProxyService.AGENT_ID===Se?p.AIServiceType.Chat:p.AIServiceType.Agent,vt=I.start(Oe||ot,{message:le,agentId:Se,userMessage:le,actionType:We,actionSource:Ve});k.addUserMessage({content:le,agentId:Se,agentCommand:Oe,relationId:vt}),await Te({relationId:vt,message:le,command:Oe,agentId:Se}),T.sendRequest(Ke);const ut=k.addAssistantMessage({content:"",relationId:vt,requestId:Ke.requestId,replyStartTime:dt});await ie({startTime:dt,relationId:vt,message:le,agentId:Se,command:Oe,request:Ke,msgId:ut})},[R,R.chatUserRoleRender,k,Ae]),_e=r.useCallback(async we=>{const{message:le,command:Se,reportExtra:Oe}=we,Fe=we.agentId?we.agentId:b.ChatProxyService.AGENT_ID;return ye({message:le,agentId:Fe,command:Se,reportExtra:Oe})},[ye]),Ce=r.useCallback(()=>{T.clearSessionModel(),D.clearHistoryMessages(),Ee()},[K]),Ee=r.useCallback(()=>{var we;(we=B?.current)===null||we===void 0||we.classList.remove(S),te({type:"init",payload:[he]})},[K]),xe=we=>{X||(re(we.nameWithSlash),Y(we.agentId),$(we.command))},Ye=r.useCallback(()=>{M.toggleSlot(s.AI_CHAT_VIEW_ID)},[M]),Ue=R.chatViewHeaderRender||w,Qe=r.useCallback(async we=>{for(const le of k.getMessages()){if(we.isCancellationRequested)return;le.role===1?await Te({relationId:le.relationId,message:le.content,agentId:le.agentId,command:le.agentCommand}):le.role===2&&le.requestId?(T.sessionModel.getRequest(le.requestId).response.isComplete||z(!0),await ie({msgId:le.id,relationId:le.relationId,message:le.content,agentId:le.agentId,command:le.agentCommand,startTime:le.replyStartTime,request:T.sessionModel.getRequest(le.requestId)})):le.role===2&&le.content?await se({relationId:le.relationId,chunk:le.content}):le.role===2&&le.componentId&&await me({relationId:le.relationId,chunk:{kind:"component",component:le.componentId,value:le.componentValue}})}},[ie]);return r.useEffect(()=>{Ee();const we=new p.CancellationTokenSource;return z(!1),Qe(we.token),()=>{we.cancel()}},[T.sessionModel]),r.createElement("div",{id:y.default.ai_chat_view},r.createElement("div",{className:y.default.header_container},r.createElement(Ue,{handleClear:Ce,handleCloseChatView:Ye})),r.createElement("div",{className:y.default.body_container},r.createElement("div",{className:y.default.left_bar,id:"ai_chat_left_container"},r.createElement("div",{className:y.default.chat_container,ref:B},r.createElement(o.MessageList,{className:y.default.message_list,lockable:!0,toBottomHeight:"100%",dataSource:K})),r.createElement("div",{className:y.default.chat_input_wrap},r.createElement("div",{className:y.default.header_operate},r.createElement("div",{className:y.default.header_operate_left},N.map(we=>r.createElement(m.Popover,{id:`ai-chat-shortcut-${we.name}`,key:`ai-chat-shortcut-${we.name}`,title:we.tooltip||we.name},r.createElement("div",{className:y.default.tag,onClick:()=>xe(we)},we.name)))),r.createElement("div",{className:y.default.header_operate_right})),r.createElement(ce,{onSend:(we,le,Se)=>_e({message:we,agentId:le,command:Se,reportExtra:{actionSource:p.ActionSourceEnum.Chat,actionType:p.ActionTypeEnum.Send}}),disabled:X,enableOptions:!0,theme:J,setTheme:re,agentId:Q,setAgentId:Y,defaultAgentId:Z,command:H,setCommand:$,ref:x})))))};t.AIChatView=A;function w({handleClear:T,handleCloseChatView:D}){const I=r.useMemo(()=>(0,p.localize)("aiNative.chat.ai.assistant.name"),[]);return r.createElement(r.Fragment,null,r.createElement("div",{className:y.default.left},r.createElement("span",{className:y.default.title},I)),r.createElement("div",{className:y.default.right},r.createElement(m.Popover,{overlayClassName:y.default.popover_icon,id:"ai-chat-header-clear",title:(0,p.localize)("aiNative.operate.clear.title")},r.createElement(E.EnhanceIcon,{wrapperClassName:y.default.action_btn,className:(0,l.getIcon)("clear"),onClick:T,tabIndex:0,role:"button",ariaLabel:(0,p.localize)("aiNative.operate.clear.title")})),r.createElement(m.Popover,{overlayClassName:y.default.popover_icon,id:"ai-chat-header-close",position:m.PopoverPosition.left,title:(0,p.localize)("aiNative.operate.close.title")},r.createElement(E.EnhanceIcon,{wrapperClassName:y.default.action_btn,className:(0,l.getIcon)("window-close"),onClick:D,tabIndex:0,role:"button",ariaLabel:(0,p.localize)("aiNative.operate.close.title")}))))}},25834:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CodeBlockWrapperInput=t.CodeBlockWrapper=t.CodeEditorWithHighlight=void 0;const n=e(85608),r=n.__importDefault(e(56005)),o=n.__importStar(e(14041)),l=n.__importDefault(e(10580)),m=e(41869),E=e(81878),p=e(89195),v=e(43718),s=e(71624),g=e(9447),c=e(52416),h=n.__importDefault(e(6960)),d=e(83933);e(38191);const u=b=>{const{input:y,language:S,relationId:A,agentId:w,command:T}=b,D=o.default.useRef(null),I=(0,m.useInjectable)(g.MonacoCommandRegistry),O=(0,m.useInjectable)(m.IClipboardService),P=(0,m.useInjectable)(c.IThemeService),R=(0,m.useInjectable)(v.IAIReporter),[M,k]=(0,o.useState)(!1),B=(0,o.useMemo)(()=>(0,m.uuid)(12),[D,D.current]);(0,o.useEffect)(()=>{const j=X=>{X.type==="dark"||X.type==="hcDark"?e.e(622).then(e.bind(e,51622)):(X.type==="light"||X.type==="hcLight")&&e.e(412).then(e.bind(e,50412))},K=P.onThemeChange(X=>{j(X)}),U=P.getCurrentThemeSync();return j(U),()=>K.dispose()},[]);const x=(0,o.useCallback)(async()=>{k(!0),await O.writeText(y),R.end(A,{copy:!0,code:y,language:S,agentId:w,command:T,actionSource:v.ActionSourceEnum.Chat,actionType:v.ActionTypeEnum.ChatCopyCode}),(0,v.runWhenIdle)(()=>{k(!1)},1e3)},[O,y,A]),N=(0,o.useCallback)(()=>{const j=I.getActiveCodeEditor();if(j){const K=j.getSelection();K&&((0,s.insertSnippetWithMonacoEditor)(j,y,[K],{undoStopBefore:!1,undoStopAfter:!1}),R.end(A,{insert:!0,code:y,language:S,agentId:w,command:T,actionSource:v.ActionSourceEnum.Chat,actionType:v.ActionTypeEnum.ChatInsertCode}))}},[I]);return o.default.createElement("div",{className:h.default.monaco_wrapper},o.default.createElement("div",{className:h.default.action_toolbar},o.default.createElement(E.Popover,{id:`ai-chat-inser-${B}`,title:(0,v.localize)("aiNative.chat.code.insert")},o.default.createElement(p.EnhanceIcon,{className:(0,m.getIcon)("insert"),onClick:()=>N(),tabIndex:0,role:"button",ariaLabel:(0,v.localize)("aiNative.chat.code.insert")})),o.default.createElement(E.Popover,{id:`ai-chat-copy-${B}`,title:(0,v.localize)(M?"aiNative.chat.code.copy.success":"aiNative.chat.code.copy")},o.default.createElement(p.EnhanceIcon,{className:(0,m.getIcon)("copy"),onClick:()=>x(),tabIndex:0,role:"button",ariaLabel:(0,v.localize)("aiNative.chat.code.copy")}))),o.default.createElement(l.default,{language:S,ref:D,className:h.default.editor},y))};t.CodeEditorWithHighlight=u;const _=({content:b="",relationId:y,renderText:S,agentId:A="",command:w=""})=>{const T=/`([^`]+)`/g,D=/```([^]+?)```/g,I=/```([^]+)?/g,O=R=>{const M=R.split(`
|
|
28186
28186
|
`)[0].trim().toLowerCase(),k=d.highLightLanguageSupport.find(B=>B===M)||"plaintext";return R=R.replace(/.*?\n/,""),R=R.trim(),o.default.createElement("div",{className:h.default.code_block},o.default.createElement("div",{className:h.default.code_language},(0,r.default)(k)),o.default.createElement(t.CodeEditorWithHighlight,{input:R,language:M,relationId:y,agentId:A,command:w}))},P=(0,o.useMemo)(()=>{const R=b.split(D),M=[];return R.map((k,B)=>{B%2===0?k.split(T).map((x,N)=>{if(N%2===0){if(x.includes("```")){const j=x.split(I).filter(Boolean);if(j.length===2){M.push(j[0]),M.push(O(j[1]));return}}S?M.push(S(x)):M.push(x)}else M.push(o.default.createElement("span",{className:h.default.code_inline,key:N},x))}):M.push(O(k))}),M},[b,S]);return o.default.createElement(o.default.Fragment,null,P)},f=({text:b,renderText:y,relationId:S,agentId:A})=>o.default.createElement("div",{className:h.default.ai_chat_code_wrapper},o.default.createElement("div",{className:h.default.render_text},o.default.createElement(_,{content:b,renderText:y,relationId:S,agentId:A})));t.CodeBlockWrapper=f;const a=({text:b,relationId:y,agentId:S,command:A})=>{const w=(0,m.useInjectable)(v.ChatFeatureRegistryToken),[T,D]=(0,o.useState)(""),[I,O]=(0,o.useState)(b);return o.default.useEffect(()=>{const{value:P,nameWithSlash:R}=w.parseSlashCommand(b);if(R){D(R),O(P);return}else O(b)},[b,w]),o.default.createElement("div",{className:h.default.ai_chat_code_wrapper},o.default.createElement("div",{className:h.default.render_text},T&&o.default.createElement("div",{className:h.default.tag_wrapper},o.default.createElement("span",{className:h.default.tag},T)),S&&o.default.createElement("div",{className:h.default.tag,style:{marginRight:4}},"@",S),A&&o.default.createElement("div",{className:h.default.tag},"/ ",A),o.default.createElement(_,{content:I,relationId:y,agentId:S,command:A})))};t.CodeBlockWrapperInput=a},57987:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ChatInput=void 0;const n=e(85608),r=n.__importDefault(e(53373)),o=n.__importStar(e(14041)),l=e(41869),m=e(81878),E=e(89195),p=e(83913),v=e(43718),s=e(9447),g=e(19413),c=e(42033),h=e(51081),d=n.__importDefault(e(6960)),u=8,_=68,f=({icon:S,name:A,description:w,agentId:T,command:D,selectedAgentId:I})=>{const O=(0,o.useMemo)(()=>!I&&T&&T!==h.ChatProxyService.AGENT_ID&&D?o.default.createElement("span",{className:d.default.agent_label},"@",T):null,[]);return o.default.createElement("div",{className:d.default.block},S&&o.default.createElement(E.EnhanceIcon,{className:S}),A&&o.default.createElement("span",{className:d.default.name},A),w&&o.default.createElement("span",{className:d.default.text},w),O)},a=({onClick:S,bottom:A,trigger:w,agentId:T})=>{const D=(0,l.useInjectable)(g.IChatAgentService),I=(0,l.useInjectable)(v.ChatAgentViewServiceToken),O=(0,o.useMemo)(()=>w===g.AT_SIGN_SYMBOL?I.getRenderAgents().map(R=>new c.ChatSlashCommandItemModel({icon:"",name:`${g.AT_SIGN_SYMBOL}${R.id} `,description:R.metadata.description},"",R.id)):D.getCommands().map(R=>new c.ChatSlashCommandItemModel({icon:"",name:`${g.SLASH_SYMBOL} ${R.name} `,description:R.description},R.name,R.agentId)).filter(R=>!T||R.agentId===T),[w,D]),P=(0,o.useCallback)((R,M,k)=>{S&&S(R||"",M,k)},[S]);return O.length===0?null:o.default.createElement("div",{className:d.default.instruction_options_container,style:{bottom:A+"px"}},o.default.createElement("div",{className:d.default.options},o.default.createElement("ul",null,O.map(({icon:R,name:M,nameWithSlash:k,description:B,agentId:x,command:N})=>o.default.createElement("li",{key:`${x||""}-${M}`,onMouseDown:()=>P(k,x,N)},o.default.createElement(f,{icon:R,name:M,description:B,agentId:x,command:N,selectedAgentId:T}))))))},b=({themeBlock:S})=>o.default.createElement("div",{className:d.default.theme_container},o.default.createElement("div",{className:d.default.theme_block},S)),y=({agentId:S,command:A})=>o.default.createElement("div",{className:d.default.theme_container},S!==h.ChatProxyService.AGENT_ID&&o.default.createElement("div",{className:d.default.theme_block,style:{marginRight:4}},"@",S),A&&o.default.createElement("div",{className:d.default.theme_block},g.SLASH_SYMBOL," ",A));t.ChatInput=o.default.forwardRef((S,A)=>{const{onSend:w,onValueChange:T,enableOptions:D=!1,disabled:I=!1,defaultHeight:O=32,autoFocus:P,setTheme:R,theme:M,setAgentId:k,agentId:B,defaultAgentId:x,setCommand:N,command:j,sendBtnClassName:K}=S,U=B||x,X=(0,o.useRef)(null),z=(0,o.useRef)(null),[Q,Y]=(0,o.useState)(S.value||""),[Z,G]=(0,o.useState)(!1),[H,$]=(0,o.useState)(O),[J,re]=(0,o.useState)(!1),[ce,he]=(0,o.useState)(!1),[Ae,te]=(0,o.useState)(!1),[Pe,Te]=(0,o.useState)((0,v.localize)("aiNative.chat.input.placeholder.default")),ie=(0,l.useInjectable)(s.MonacoCommandRegistry),se=(0,l.useInjectable)(g.IChatAgentService),me=(0,l.useInjectable)(v.ChatFeatureRegistryToken),ye=(0,l.useLatest)(U);(0,o.useImperativeHandle)(A,()=>({setInputValue:Se=>{Y(Se),(0,v.runWhenIdle)(()=>{var Oe;(Oe=X.current)===null||Oe===void 0||Oe.focus()},120)}})),(0,o.useEffect)(()=>{S.value!==Q&&Y(S.value||"")},[S.value]),(0,o.useEffect)(()=>{var Se;(Se=X.current)===null||Se===void 0||Se.focus();const Oe=(0,v.localize)("aiNative.chat.input.placeholder.default"),Fe=me.getSlashCommandHandler(j);if(Fe&&Fe.providerInputPlaceholder){const We=ie.getActiveCodeEditor(),Ve=Fe.providerInputPlaceholder(Q,We);Te(Ve||Oe)}else Te(Oe)},[me,j]),(0,o.useEffect)(()=>{Ee(M||"",U,j)},[M,U,j]),(0,o.useEffect)(()=>{var Se;X&&P&&((Se=X.current)===null||Se===void 0||Se.focus())},[X,P,S.value]),(0,o.useEffect)(()=>{if(D&&((Q===g.SLASH_SYMBOL||Q===g.AT_SIGN_SYMBOL&&se.getAgents().length>0)&&!Ae?G(!0):G(!1)),Q.startsWith(g.SLASH_SYMBOL)){const{value:Se,nameWithSlash:Oe}=me.parseSlashCommand(Q);if(Oe){const Fe=me.getSlashCommandBySlashName(Oe);Y(Se),R(Oe),Fe&&(k(Fe.agentId),N(Fe.command));return}}if(se.getAgents().length){const Se=se.parseMessage(Q,ye.current);(Se.agentId||Se.command)&&(R(""),Y(Se.message),Se.agentId&&k(Se.agentId),Se.command&&N(Se.command))}},[X,Q,D,me]),(0,o.useEffect)(()=>{Q||($(O),he(!1),te(!1))},[Q]);const _e=(0,o.useCallback)(Se=>{Y(Se),T&&T(Se)},[]),Ce=(0,o.useCallback)(async()=>{if(I)return;const Se=(Oe=Q)=>{w(Oe,U,j),Y(""),R(""),k(""),N("")};if(j){const Oe=me.getSlashCommandHandler(j);if(Oe&&Oe.execute){const Fe=ie.getActiveCodeEditor();await Oe.execute(Q,We=>Se(We),Fe);return}}Se()},[w,Q,U,j,me]),Ee=(0,o.useCallback)((Se,Oe,Fe)=>{if(Oe){if(G(!1),R(""),k(Oe),N(Fe||""),X?.current){const We=X.current.value;(We===g.AT_SIGN_SYMBOL||Fe&&We===g.SLASH_SYMBOL)&&Y(""),(0,v.runWhenIdle)(()=>X.current.focus())}}else if(Se){G(!1),k(""),N("");const We=me.getSlashCommandBySlashName(Se);if(R(We?We.nameWithSlash:""),X&&X.current){const Ve=X.current.value;Ve.length===1&&Ve.startsWith(g.SLASH_SYMBOL)&&Y(""),(0,v.runWhenIdle)(()=>X.current.focus())}}},[X,me]),xe=(0,o.useMemo)(()=>{const Se=u+H;return Ae&&G(!1),Se},[H]),Ye=Se=>{var Oe,Fe;if(Se.key==="Backspace"&&((Oe=X.current)===null||Oe===void 0?void 0:Oe.selectionEnd)===0&&((Fe=X.current)===null||Fe===void 0?void 0:Fe.selectionStart)===0){if(R(""),U===h.ChatProxyService.AGENT_ID){N(""),k("");return}U&&(j?N(""):k(""))}},Ue=(0,o.useCallback)(Se=>{$(Se),Se>_?he(!0):he(!1)},[]),Qe=(0,o.useCallback)(()=>{re(!1),G(!1)},[X]),we=(0,o.useCallback)(()=>{re(!0)},[X]),le=(0,o.useCallback)(()=>{const Se=Ae;if(te(!Se),Se)$(O),he(!1);else{const Fe=document.querySelector("#ai_chat_left_container").clientHeight-68-(M?32:0)-16;$(Fe)}},[Ae]);return o.default.createElement("div",{className:(0,r.default)(d.default.chat_input_container,J?d.default.active:null)},Z&&o.default.createElement("div",{ref:z},o.default.createElement(a,{onClick:Ee,bottom:xe,trigger:Q,agentId:U})),M&&o.default.createElement(b,{themeBlock:M}),U&&o.default.createElement(y,{agentId:U,command:j}),ce&&o.default.createElement("div",{className:d.default.expand_icon,onClick:()=>le()},o.default.createElement(m.Popover,{id:"ai_chat_input_expand",title:(0,v.localize)(Ae?"aiNative.chat.expand.unfullscreen":"aiNative.chat.expand.fullescreen")},o.default.createElement(m.Icon,{className:(0,r.default)(Ae?(0,m.getIcon)("unfullscreen"):(0,m.getIcon)("fullescreen"))}))),o.default.createElement(p.InteractiveInput,{ref:X,placeholder:Pe,value:Q,onKeyDown:Ye,onBlur:Qe,onFocus:we,onValueChange:_e,disabled:I,className:d.default.input_wrapper,onSend:Ce,sendBtnClassName:K,onHeightChange:Ue,height:H,popoverPosition:m.PopoverPosition.left}))})},56474:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ChatMarkdown=void 0,t.postProcessCodeBlockLanguageId=c,t.fillInIncompleteTokens=h;const n=e(85608),r=n.__importDefault(e(53373)),o=n.__importStar(e(14041)),l=e(13719),m=e(84605),E=e(41869),p=e(90684),v=e(25834),s=n.__importDefault(e(6960)),g=I=>{const O=(0,o.useRef)(null),P=(0,E.useInjectable)(E.AppConfig),[R,M]=(0,o.useState)(),[k,B]=(0,o.useState)();return(0,o.useEffect)(()=>{var x,N;if(!O.current)return;const K=typeof I.markdown=="string"?new p.MarkdownString(I.markdown):I.markdown,U=new l.MarkdownReactRenderer;U.code=(G,H)=>{const $=c(H);return o.default.createElement("div",{className:s.default.code},o.default.createElement(E.ConfigProvider,{value:P},o.default.createElement("div",{className:s.default.code_block},o.default.createElement("div",{className:s.default.code_language},$),o.default.createElement(v.CodeEditorWithHighlight,{input:G,language:$,relationId:I.relationId||"",agentId:I.agentId,command:I.command}))))},U.codespan=G=>o.default.createElement("code",{className:s.default.code_inline},G);const X=new l.MarkdownReactParser({renderer:U}),z=(x=I.markedOptions)!==null&&x!==void 0?x:{};z.renderer=X;let Q=(N=K.value)!==null&&N!==void 0?N:"";Q.length>1e5&&(Q=`${Q.slice(0,1e5)}\u2026`);let Y,Z;if(I.fillInIncompleteTokens){const G={...m.marked.defaults,...z},H=m.marked.lexer(Q,G),$=h(H);Y=m.marked.parser($,G),Z=$}else{const G=m.marked.lexer(Q,m.marked.defaults);Y=m.marked.parser(G,z),Z=G}B(Z),M(X)},[I.markdown]),o.default.createElement("div",{className:(0,r.default)(s.default.markdown_container,I.className),ref:O,tabIndex:0},k&&R&&R.parse(k))};t.ChatMarkdown=g;function c(I){if(!I)return"";const O=I.split(/[\s+|:|,|\{|\?]/,1);return O.length?O[0]:I}function h(I){let O,P;for(O=0;O<I.length;O++){const R=I[O];if(R.type==="paragraph"&&R.raw.match(/(\n|^)```/)){P=d(I.slice(O));break}if(R.type==="paragraph"&&R.raw.match(/(\n|^)\|/)){P=w(I.slice(O));break}if(R.type==="paragraph"&&O===I.length-1){const M=D(R);if(M){P=[M];break}}}if(P){const R=[...I.slice(0,O),...P];return R.links=I.links,R}return I}function d(I){const O=T(I);return m.marked.lexer(O+"\n```")}function u(I){return A(I,"`")}function _(I){return A(I,"*")}function f(I){return A(I,"_")}function a(I){return A(I,")")}function b(I){return A(I,"](about:blank)")}function y(I){return A(I,"**")}function S(I){return A(I,"__")}function A(I,O){const P=T(Array.isArray(I)?I:[I]);return m.marked.lexer(P+O)[0]}function w(I){const O=T(I),P=O.split(`
|
|
@@ -28266,7 +28266,7 @@ ${S.slice(1).join(`
|
|
|
28266
28266
|
${f.slice(1).join(`
|
|
28267
28267
|
`)}`:""}`}}return c.text}findTypeIdentifier(c){let h=c;for(;h;){if(h.type==="type_identifier")return h.text;const d=h.child(1);if(!d)break;h=d}return""}async extractImportPaths(c){var h;const d=[],u=await this.parser.parse(c),_=u?.rootNode,f=[],a=[];if(_)for(let b=0;b<_?.childCount;b++){const y=_.child(b);if(y?.type==="import_statement")f.push(y);else if(y?.type==="type_annotation"){const S=y.child(1);S&&a.push(S.text)}else if(y?.type==="lexical_declaration"){const S=this.findTypeIdentifier(y);S&&a.push(S)}}for(const b of f)if(a.some(y=>b.text.includes(y))){let y=(h=b.child(3))===null||h===void 0?void 0:h.text;(y?.includes("'")||y?.includes('"'))&&(y=y.slice(1,-1)),y&&d.push(y)}return d}async extractInterfaceOrTypeCode(c){var h;const d=[];if(this.language==="typescript"){await this.parserLoaded.promise;const u=(h=this.parser)===null||h===void 0?void 0:h.parse(c),_=u?.rootNode;if(_)for(let f=0;f<_?.childCount;f++){const a=_.child(f);if(a?.type==="export_statement"){const b=a.child(1);(b?.type==="interface_declaration"||b?.type==="type_alias_declaration")&&d.push(b.text)}else(a?.type==="interface_declaration"||a?.type==="type_alias_declaration")&&d.push(a.text)}}return d}async findSyntaxErrorCount(c){var h;await this.parserLoaded.promise;const d=(h=this.parser)===null||h===void 0?void 0:h.parse(c),u=d?.rootNode;if(!u)return 0;let _=0;const f=a=>{(a.type==="function_declaration"||a.type==="class_declaration"||a.type==="variable_declarator"||a.type==="statement_block"||a.type==="expression_statement")&&(a.hasError||a.isMissing||a.type==="ERROR")&&_++;for(let y=0;y<a.childCount;y++){const S=a.child(y);S&&f(S)}};return f(u),_}async findNearestCodeBlockWithPosition(c,h){const d=await this.parser.parse(c);if(d){const{rootNode:u}=d,_=u.namedDescendantForIndex(h),f=this.findContainingCodeBlockWithPosition(_,h);if(!f)return null;let b=c.split(`
|
|
28268
28268
|
`).slice(0,f.startPosition.row).reduce((y,S)=>y+S.length,0);return b+=f.startPosition.row,b+=f.startPosition.column,{codeBlock:f.text,range:{start:{line:f.startPosition.row,character:0},end:{line:f.endPosition.row,character:1/0}},offset:b,type:f.startPosition.row===f.endPosition.row?m.NearestCodeBlockType.Line:m.NearestCodeBlockType.Block}}return null}dispose(){this.parser.delete(),this.lruCache.clear()}};t.LanguageParser=s,n.__decorate([(0,o.Autowired)(v.WasmModuleManager),n.__metadata("design:type",v.WasmModuleManager)],s.prototype,"wasmModuleManager",void 0),n.__decorate([(0,o.Autowired)(p.TreeSitterLanguageFacts),n.__metadata("design:type",p.TreeSitterLanguageFacts)],s.prototype,"languageFacts",void 0),t.LanguageParser=s=n.__decorate([(0,o.Injectable)({multiple:!0}),n.__metadata("design:paramtypes",[String])],s)},85679:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.LanguageParserService=void 0;const n=e(85608),r=e(76003),o=e(3073),l=e(22486);let m=class{constructor(){this.pool=new Map}createParser(p){const v=l.parserNameMap[p];if(v)return this.pool.has(v)||this.pool.set(v,this.injector.get(o.LanguageParser,[v])),this.pool.get(v)}dispose(){this.pool.forEach(p=>p.dispose()),this.pool.clear()}};t.LanguageParserService=m,n.__decorate([(0,r.Autowired)(r.INJECTOR_TOKEN),n.__metadata("design:type",r.Injector)],m.prototype,"injector",void 0),t.LanguageParserService=m=n.__decorate([(0,r.Injectable)()],m)},53374:(L,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.toMonacoRange=e;function e(n){return{startLineNumber:n.startPosition.row+1,startColumn:n.startPosition.column+1,endLineNumber:n.endPosition.row+1,endColumn:n.endPosition.column+1}}},19584:(L,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.GolangLanguageFacts=void 0;const e=["function_declaration","method_declaration","block","if_statement","else_statement","switch_statement","case_clause","for_statement","range_clause","type_switch_statement","type_case_clause","comm_clause","select_statement","go_statement","defer_statement"],n=new Set(e);class r{constructor(){this.name="go",this.listCommentStyle="// ",this.blockCommentStyle={start:"/**",end:" */",linePrefix:" * "}}provideCodeBlocks(){return n}isCodeBlock(l){return n.has(l)}}t.GolangLanguageFacts=r},22486:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TreeSitterLanguageFacts=t.knownLanguageFacts=void 0;const n=e(85608);n.__exportStar(e(17973),t);const r=e(76003),o=e(19584),l=e(44606),m=e(82381),E=e(41486),p=e(98588),v=e(96436),s=e(2349),g=e(78542),c=new Set;t.knownLanguageFacts=[o.GolangLanguageFacts,l.JavaLanguageFacts,m.JavaScriptLanguageFacts,E.JavaScriptReactLanguageFacts,p.PythonLanguageFacts,v.RustLanguageFacts,s.TypeScriptLanguageFacts,g.TypeScriptReactLanguageFacts];let h=class{constructor(){this.langs=new Map,t.knownLanguageFacts.forEach(u=>{const _=new u;this.langs.set(_.name,_)})}isCodeBlock(u,_){const f=this.langs.get(u);return f&&f.isCodeBlock?f.isCodeBlock(_):!1}isFunctionCodeBlock(u,_){const f=this.langs.get(u);return f&&f.isFunctionCodeBlocks?f.isFunctionCodeBlocks(_):!1}provideFunctionInfo(u,_){const f=this.langs.get(u);return f&&f.provideFunctionInfo?f.provideFunctionInfo(_):null}getCodeBlockTypes(u){const _=this.langs.get(u);return _?_.provideCodeBlocks():c}};t.TreeSitterLanguageFacts=h,t.TreeSitterLanguageFacts=h=n.__decorate([(0,r.Injectable)(),n.__metadata("design:paramtypes",[])],h)},44606:(L,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.JavaLanguageFacts=void 0;const e=["compilation_unit","class_declaration","interface_declaration","enum_declaration","method_declaration","constructor_declaration","block","static_initializer","instance_initializer","if_statement","switch_statement","while_statement","do_statement","for_statement","enhanced_for_statement","try_statement","catch_clause","finally_clause"],n=new Set(["method_declaration","constructor_declaration"]),r=new Set(e);class o{constructor(){this.name="java",this.listCommentStyle="// ",this.blockCommentStyle={start:"/**",end:" */",linePrefix:" * "}}provideCodeBlocks(){return r}isCodeBlock(m){return r.has(m)}isFunctionCodeBlocks(m){return n.has(m)}}t.JavaLanguageFacts=o},82381:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.JavaScriptLanguageFacts=t.functionBlockCodeTypes=t.javascriptBlockCodeTypes=void 0;const n=e(53374);t.javascriptBlockCodeTypes=["function","function_declaration","function_expression","arrow_function","class_declaration","method_definition","if_statement","switch_case","while_statement","do_statement","for_statement","for_in_statement","try_statement","catch_clause","block","export_statement","lexical_declaration"],t.functionBlockCodeTypes=["function","function_declaration","function_expression","arrow_function","method_definition"];const r=new Set(t.functionBlockCodeTypes),o=new Set(t.javascriptBlockCodeTypes);class l{constructor(){this.name="javascript",this.listCommentStyle="// ",this.blockCommentStyle={start:"/**",end:" */",linePrefix:" * "}}provideCodeBlocks(){return o}isCodeBlock(E){return o.has(E)}isFunctionCodeBlocks(E){return r.has(E)}provideFunctionInfo(E){var p,v,s;switch(E.type){case"function_declaration":case"function_expression":return{infoCategory:"function",type:E.type,name:((p=E.firstNamedChild)===null||p===void 0?void 0:p.text)||"",signatures:E.children.filter(g=>g.type==="parameter").map(g=>{var c;return((c=g.firstChild)===null||c===void 0?void 0:c.text)||""}),range:(0,n.toMonacoRange)(E)};case"arrow_function":{const g=E.parent;return g&&g.type==="variable_declarator"&&g.parent&&(g.parent.type==="lexical_declaration"||g.parent.type==="export_statement"||g.parent.type==="variable_declaration")?{infoCategory:"function",type:E.type,name:((v=g.firstChild)===null||v===void 0?void 0:v.text)||"",signatures:E.children.filter(c=>c.type==="parameter").map(c=>{var h;return((h=c.firstChild)===null||h===void 0?void 0:h.text)||""}),range:(0,n.toMonacoRange)(g.parent)}:null}case"method_definition":return{infoCategory:"function",type:E.type,name:((s=E.firstNamedChild)===null||s===void 0?void 0:s.text)||"",signatures:E.children.filter(g=>g.type==="parameter").map(g=>{var c;return((c=g.firstChild)===null||c===void 0?void 0:c.text)||""}),range:(0,n.toMonacoRange)(E)}}return null}}t.JavaScriptLanguageFacts=l},41486:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.JavaScriptReactLanguageFacts=t.javascriptreactBlockCodeTypes=void 0;const n=e(82381);t.javascriptreactBlockCodeTypes=[...n.javascriptBlockCodeTypes,"jsx_element","jsx_self_closing_element","jsx_expression","jsx_fragment"];const r=new Set(t.javascriptreactBlockCodeTypes);class o{constructor(){this.name="jsx",this.listCommentStyle="// ",this.blockCommentStyle={start:"/**",end:" */",linePrefix:" * "}}provideCodeBlocks(){return r}isCodeBlock(m){return r.has(m)}}t.JavaScriptReactLanguageFacts=o},98588:(L,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.PythonLanguageFacts=t.pythonBlockCodeTypes=void 0,t.pythonBlockCodeTypes=["function_definition","class_definition","compound_statement","if_statement","elif_clause","else_clause","for_statement","while_statement","try_statement","except_clause","with_statement","decorated_definition"];const e=new Set(t.pythonBlockCodeTypes);class n{constructor(){this.name="python",this.listCommentStyle="# ",this.blockCommentStyle={start:"'''",end:"'''",linePrefix:""}}provideCodeBlocks(){return e}isCodeBlock(o){return e.has(o)}}t.PythonLanguageFacts=n},96436:(L,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.RustLanguageFacts=t.rustBlockCodeTypes=void 0,t.rustBlockCodeTypes=["function_item","impl_item","trait_item","block","if_expression","match_expression","while_expression","loop_expression","for_expression","closure_expression","struct_item","enum_item","union_item","mod_item"];const e=new Set(t.rustBlockCodeTypes);class n{constructor(){this.name="rust",this.listCommentStyle="// ",this.blockCommentStyle={start:"/**",end:" */",linePrefix:" * "}}provideCodeBlocks(){return e}isCodeBlock(o){return e.has(o)}}t.RustLanguageFacts=n},17973:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parserIdentifierMap=t.parserNameMap=void 0;const r=e(85608).__importDefault(e(19891)),o={typescript:"typescript",typescriptreact:"tsx",javascript:"javascript",javascriptreact:"jsx",rust:"rust",python:"python",java:"java",go:"go"};t.parserNameMap=o,t.parserIdentifierMap=(0,r.default)(t.parserNameMap)},2349:(L,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TypeScriptLanguageFacts=t.typescriptBlockTypes=void 0,t.typescriptBlockTypes=["function","function_declaration","function_expression","arrow_function","class_declaration","interface_declaration","method_definition","method_signature","enum_declaration","type_alias_declaration","lexical_declaration","if_statement","switch_case","while_statement","do_statement","for_statement","for_in_statement","for_of_statement","try_statement","catch_clause","block","module","public_field_definition","private_field_definition","export_statement"];const e=new Set(t.typescriptBlockTypes);class n{constructor(){this.name="typescript",this.listCommentStyle="// ",this.blockCommentStyle={start:"/**",end:" */",linePrefix:" * "}}provideCodeBlocks(){return e}isCodeBlock(o){return e.has(o)}}t.TypeScriptLanguageFacts=n},78542:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TypeScriptReactLanguageFacts=t.typescriptreactBlockTypes=void 0;const n=e(2349);t.typescriptreactBlockTypes=[...n.typescriptBlockTypes,"jsx_element","jsx_self_closing_element","jsx_expression","jsx_fragment"];const r=new Set(t.typescriptreactBlockTypes);class o{constructor(){this.name="tsx",this.listCommentStyle="// ",this.blockCommentStyle={start:"/**",end:" */",linePrefix:" * "}}provideCodeBlocks(){return r}isCodeBlock(m){return r.has(m)}}t.TypeScriptReactLanguageFacts=o},67045:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WasmModuleManager=void 0;const n=e(85608),r=n.__importDefault(e(13833)),o=e(76003),l=e(6858),m=e(70392);let E=class{async resolveResourceUri(){const v=await this.rendererRuntime.provideResourceUri(l.EKnownResources.TreeSitterWasmDirectory);this.resolvedResourceUriDeferred.resolve(v)}constructor(){this.resolvedResourceUriDeferred=new m.Deferred,this.cachedRuntime=new Map,this.parserInitialized=!1,this.resolveResourceUri()}async initParser(){const s=`${await this.resolvedResourceUriDeferred.promise}/tree-sitter.wasm`;return this.parserInitialized||(await r.default.init({locateFile:()=>s}),this.parserInitialized=!0),new r.default}async loadLanguage(v){if(!this.cachedRuntime.has(v)){const s=new m.Deferred;this.cachedRuntime.set(v,s);const c=`${await this.resolvedResourceUriDeferred.promise}/tree-sitter-${v}.wasm`;fetch(c).then(h=>h.arrayBuffer()).then(h=>{s.resolve(h)})}return this.cachedRuntime.get(v).promise}};t.WasmModuleManager=E,n.__decorate([(0,o.Autowired)(l.RendererRuntime),n.__metadata("design:type",l.RendererRuntime)],E.prototype,"rendererRuntime",void 0),t.WasmModuleManager=E=n.__decorate([(0,o.Injectable)(),n.__metadata("design:paramtypes",[])],E)},4972:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AIRightTabRenderer=t.AILeftTabRenderer=t.AIChatTabRendererWithTab=t.AIChatTabRenderer=void 0;const n=e(85608),r=n.__importDefault(e(53373)),o=n.__importStar(e(14041)),l=e(41869),m=e(89195),E=e(1149),p=e(43718),v=e(11090),s=e(63067),g=e(46245),c=e(66368),h=e(19951),d=e(752),u=e(19413),_=n.__importDefault(e(87708)),f=()=>{const{side:w}=o.default.useContext(h.TabbarConfig),T=(0,l.useInjectable)(d.TabbarServiceFactory)(w);return(0,o.useEffect)(()=>{T.setIsLatter(!0)},[T]),o.default.createElement("div",{style:{width:0}},o.default.createElement(g.TabbarViewBase,{tabSize:0,MoreTabView:g.IconElipses,TabView:g.IconTabView,barSize:0,panelBorderSize:1}))},a=({className:w,components:T})=>o.default.createElement(h.TabRendererBase,{side:u.AI_CHAT_VIEW_ID,direction:"left-to-right",id:_.default.ai_chat_panel,className:(0,r.default)(w,`${u.AI_CHAT_VIEW_ID}-slot`),components:T,TabbarView:()=>o.default.createElement(f,null),TabpanelView:()=>o.default.createElement(c.BaseTabPanelView,{PanelView:c.ContainerView,PanelViewProps:{className:_.default.ai_chat_view_container}})});t.AIChatTabRenderer=a;const b=({className:w,components:T})=>o.default.createElement(h.TabRendererBase,{side:u.AI_CHAT_VIEW_ID,direction:"right-to-left",id:_.default.ai_chat_panel,className:(0,r.default)(w,`${u.AI_CHAT_VIEW_ID}-slot`,"design_right_slot"),components:T,TabbarView:()=>o.default.createElement(g.ChatTabbarRenderer2,null),TabpanelView:()=>o.default.createElement(c.BaseTabPanelView,{PanelView:c.ContainerView,PanelViewProps:{className:_.default.ai_chat_view_container}})});t.AIChatTabRendererWithTab=b;const y=({className:w,components:T})=>o.default.createElement(v.DesignLeftTabRenderer,{className:w,components:T,tabbarView:S});t.AILeftTabRenderer=y;const S=()=>{const w=(0,l.useInjectable)(s.IMainLayoutService),T=(0,l.useInjectable)(d.TabbarServiceFactory)(l.SlotLocation.right),D=(0,l.useAutorun)(T.currentContainerId),I=o.default.useMemo(()=>w.getExtraMenu(),[w]),[O]=(0,l.useContextMenus)(I),P=(0,o.useCallback)(({renderContainers:R})=>{const M=T.visibleContainers.filter(k=>{var B;return!(!((B=k.options)===null||B===void 0)&&B.hideTab)});return o.default.createElement(o.default.Fragment,null,M.length>0&&o.default.createElement(m.HorizontalVertical,{margin:"8px auto 0px",width:"60%"}),M.map(k=>R(k,T,D)))},[D,T]);return o.default.createElement(g.LeftTabbarRenderer,{renderOtherVisibleContainers:P,isRenderExtraTopMenus:!1,renderExtraMenus:o.default.createElement("div",{className:_.default.extra_bottom_icon_container},O.length>=0?O.map(R=>o.default.createElement(m.EnhanceIconWithCtxMenu,{key:R.id,id:R.id,wrapperClassName:_.default.extra_bottom_icon,iconClass:R.icon,menuNodes:R.children,skew:{x:-8,y:-4}})):null)})},A=({className:w,components:T})=>{const D=(0,l.useInjectable)(d.TabbarServiceFactory)(l.SlotLocation.right),I=(0,l.useInjectable)(E.DesignLayoutConfig),O=(0,o.useCallback)(()=>{D.updateCurrentContainerId("")},[]),P=(0,o.useCallback)(M=>{const{component:k}=M,{options:B}=k;return o.default.createElement(c.ContainerView,{...M,renderContainerWrap:({children:x})=>o.default.createElement("div",{className:_.default.right_slot_container_wrap},o.default.createElement("div",{className:_.default.header},o.default.createElement("span",{className:_.default.title},B&&B.title),o.default.createElement("div",{className:_.default.side},o.default.createElement(m.EnhancePopover,{id:"ai_right_panel_header_close",title:(0,p.localize)("editor.title.context.close")},o.default.createElement(m.EnhanceIcon,{icon:"close",onClick:O})))),o.default.createElement("div",{className:_.default.container},x))})},[]),R=(0,o.useMemo)(()=>I.useMergeRightWithLeftPanel?_.default.right_tab_renderer:"",[I]);return o.default.createElement(v.DesignRightTabRenderer,{components:T,className:R,tabbarView:()=>o.default.createElement(g.RightTabbarRenderer,{barSize:0,style:{width:0}}),tabpanelView:()=>o.default.createElement(c.BaseTabPanelView,{PanelView:P})})};t.AIRightTabRenderer=A},82983:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AIChatLogoAvatar=void 0;const n=e(85608),r=n.__importDefault(e(14041)),o=e(41869),l=e(89195),m=e(63067),E=e(19413),p=n.__importDefault(e(88473)),v=()=>{const s=(0,o.useInjectable)(m.IMainLayoutService),g=r.default.useCallback(()=>{s.toggleSlot(E.AI_CHAT_VIEW_ID)},[s]);return r.default.createElement("div",{className:p.default.ai_switch,onClick:g},r.default.createElement(l.AILogoAvatar,{iconClassName:p.default.avatar_icon_large}))};t.AIChatLogoAvatar=v},53617:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.EnhanceDecorationsCollection=void 0;const n=e(85608),r=e(43718),o=e(20868),l=e(77714),m=n.__importDefault(e(4619));class E{get isHidden(){return this._hidden}get codeEditor(){return this.metadata.codeEditor}get deltaData(){return this.metadata.deltaData}get id(){return this.metadata.id}get editorDecoration(){return this.metadata.editorDecoration}get group(){return this._group}constructor(s){this.metadata=s,this._hidden=!1;const{editorDecoration:g,deltaData:c,isHidden:h,group:d}=s;(0,r.isUndefined)(c.length)?this.length=g.range.endLineNumber-g.range.startLineNumber:this.length=c.length,this.range=g.range,this.options=g.options,this.resumeRange=this.range,this._hidden=!!h,this._hidden&&this.hide(),(0,r.isDefined)(d)&&this.setGroup(d)}setGroup(s){this._group=s}changeVisibility(s,g){if(!this.options.className)return;const c=this.options.className.split(l.space).filter(h=>h!==m.default.hidden&&h!==m.default.visible).filter(Boolean);c.push(s),this.options.className=c.join(l.space),this.codeEditor.changeDecorations(h=>{h.changeDecorationOptions(this.id,this.options),h.changeDecoration(this.id,g)})}setRange(s){this.range=s}getRange(){return this.range}dispose(){var s,g;(g=(s=this.deltaData).dispose)===null||g===void 0||g.call(s)}hide(){this.resumeRange=this.range,this._hidden=!0;const s={lineNumber:this.range.startLineNumber,column:1},g=o.Range.fromPositions(s);this.changeVisibility(m.default.hidden,g)}resume(){this._hidden=!1,this.changeVisibility(m.default.visible,o.Range.lift(this.resumeRange))}}class p extends r.Disposable{get model(){return this.codeEditor.getModel()}constructor(s){super(),this.codeEditor=s,this.deltaDecorations=[],this._onDidDecorationsChange=this.registerDispose(new r.Emitter),this.onDidDecorationsChange=this._onDidDecorationsChange.event,this.addDispose(this.codeEditor.onDidContentSizeChange(g=>{const{contentHeightChanged:c}=g;c&&this.flush()}))}flush(){this.deltaDecorations=this.deltaDecorations.map(s=>{const{id:g,editorDecoration:{range:c}}=s,h=this.model.getDecorationRange(g);return s.setRange(h??c),s}),this._onDidDecorationsChange.fire(this.deltaDecorations)}delete(s){this.codeEditor.changeDecorations(g=>{g.removeDecoration(s),this.deltaDecorations=this.deltaDecorations.filter(c=>c.id!==s)})}createDecorations(s){return new E(s)}set(s){this.clear(),this.codeEditor.changeDecorations(g=>{const c=[];for(const h of s){const d=g.addDecoration(h.range,h.options);c.push(this.createDecorations({id:d,editorDecoration:h,codeEditor:this.codeEditor,isHidden:h.isHidden,group:h.group,deltaData:{dispose:()=>this.delete(d),length:h.length}}))}this.deltaDecorations=c})}getDecorations(){return this.deltaDecorations}getDecorationByGroup(s){return this.deltaDecorations.find(g=>g.group===s)}getDecorationByLineNumber(s){return this.deltaDecorations.find(g=>g.getRange().startLineNumber===s)}clear(){this.codeEditor.changeDecorations(s=>{for(const g of this.deltaDecorations)s.removeDecoration(g.id);this.deltaDecorations=[]})}}t.EnhanceDecorationsCollection=p},44260:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MsgHistoryManager=void 0;const n=e(85608),r=e(76003),o=e(43718);let l=class extends o.Disposable{constructor(){super(...arguments),this.messageMap=new Map,this._onMessageChange=new o.Emitter,this.onMessageChange=this._onMessageChange.event}dispose(){this.clearMessages(),super.dispose()}clearMessages(){this.messageMap.clear()}doAddMessage(E){const p=(0,o.uuid)(6),v=this.messageMap.size,s={...E,id:p,order:v,type:E.type||"string"};return this.messageMap.set(p,s),this._onMessageChange.fire(this.getMessages()),p}getMessages(){return Array.from(this.messageMap.values()).sort((E,p)=>E.order-p.order)}addUserMessage(E){return this.doAddMessage({...E,role:1})}addAssistantMessage(E){return this.doAddMessage({...E,role:2})}updateAssistantMessage(E,p){if(!this.messageMap.has(E))return;const v=this.messageMap.get(E);this.messageMap.set(E,{...v,content:p.content})}};t.MsgHistoryManager=l,t.MsgHistoryManager=l=n.__decorate([(0,r.Injectable)({multiple:!1})],l)},3841:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AINativePreferencesContribution=void 0;const n=e(85608),r=e(41869),o=e(83854);let l=class{constructor(){this.schema=o.aiNativePreferenceSchema}};t.AINativePreferencesContribution=l,t.AINativePreferencesContribution=l=n.__decorate([(0,r.Domain)(r.PreferenceContribution)],l)},83854:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.aiNativePreferenceSchema=t.EInlineDiffPreviewMode=void 0;const n=e(41869),r=e(43718);var o;(function(l){l.inlineLive="inlineLive",l.sideBySide="sideBySide"})(o||(t.EInlineDiffPreviewMode=o={})),t.aiNativePreferenceSchema={properties:{[n.AINativeSettingSectionsId.InlineDiffPreviewMode]:{type:"string",enum:[o.inlineLive,o.sideBySide],enumDescriptions:[(0,r.localize)("preference.ai.native.inlineDiff.preview.mode.inlineLive"),(0,r.localize)("preference.ai.native.inlineDiff.preview.mode.sideBySide")],default:o.inlineLive},[n.AINativeSettingSectionsId.InlineChatAutoVisible]:{type:"boolean",default:!0},[n.AINativeSettingSectionsId.InlineChatCodeActionEnabled]:{type:"boolean",default:!0},[n.AINativeSettingSectionsId.InterfaceQuickNavigationEnabled]:{type:"boolean",default:!0},[n.AINativeSettingSectionsId.ChatVisibleType]:{type:"string",enum:["never","always","default"],default:"default"},[n.AINativeSettingSectionsId.IntelligentCompletionsPromptEngineeringEnabled]:{type:"boolean",default:!0},[n.AINativeSettingSectionsId.IntelligentCompletionsDebounceTime]:{type:"number",default:150},[n.AINativeSettingSectionsId.IntelligentCompletionsCacheEnabled]:{type:"boolean",default:!0},[n.AINativeSettingSectionsId.IntelligentCompletionsAlwaysVisible]:{type:"boolean",default:!1},[n.AINativeSettingSectionsId.CodeEditsLintErrors]:{type:"boolean",default:!1},[n.AINativeSettingSectionsId.CodeEditsLineChange]:{type:"boolean",default:!1}}}},77633:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AINativeCoreContribution=t.TerminalSuggestionReadableStream=t.ERunStrategy=void 0;const n=e(93062);var r;(function(l){l.EXECUTE="EXECUTE",l.PREVIEW="PREVIEW"})(r||(t.ERunStrategy=r={}));class o extends n.SumiReadableStream{static create(){return new o}}t.TerminalSuggestionReadableStream=o,t.AINativeCoreContribution=Symbol("AINativeCoreContribution")},24522:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ttPolicy=t.renderLines=void 0;const n=e(85608),r=e(55405),o=n.__importStar(e(98236)),l=e(27357),m=e(31324),E=e(33892),p=e(24315),v=(s,g,c,h)=>{const d=h.get(m.EditorOption.disableMonospaceOptimizations),u=h.get(m.EditorOption.stopRenderingLineAfter),_="none",f=h.get(m.EditorOption.renderControlCharacters),a=h.get(m.EditorOption.fontLigatures),b=h.get(m.EditorOption.fontInfo),y=h.get(m.EditorOption.lineHeight),S=new E.StringBuilder(1e4);S.appendString('<div class="suggest-preview-text">');for(let T=0,D=c.length;T<D;T++){const I=c[T],O=I.content;S.appendString('<div class="view-line'),S.appendString('" style="top:'),S.appendString(String(T*y)),S.appendString('px;width:1000000px;">');const P=o.isBasicASCII(O),R=o.containsRTL(O);(0,p.renderViewLine)(new p.RenderLineInput(b.isMonospace&&!d,b.canUseHalfwidthRightwardsArrow,O,!1,P,R,0,I.lineTokens,I.decorations,g,0,b.spaceWidth,b.middotWidth,b.wsmiddotWidth,u,_,f,a!==m.EditorFontLigatures.OFF,null),S),S.appendString("</div>")}S.appendString("</div>"),(0,l.applyFontInfo)(s,b);const A=S.build(),w=t.ttPolicy?t.ttPolicy.createHTML(A):A;s.innerHTML=w};t.renderLines=v,t.ttPolicy=(0,r.createTrustedTypesPolicy)("editorGhostText",{createHTML:s=>s})},90614:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.InlineResultAction=void 0;const r=e(85608).__importStar(e(14041)),o=e(66205),l=e(89195),m=e(43718),E=e(31031),p=({onResultClick:v})=>{const s=(0,r.useMemo)(()=>[{icon:"check",text:(0,m.localize)("aiNative.inline.chat.operate.check.title"),btnType:"default",onClick:()=>v(E.EResultKind.ACCEPT)},{icon:"discard",text:(0,m.localize)("aiNative.operate.discard.title"),onClick:()=>v(E.EResultKind.DISCARD)},{icon:"afresh",text:(0,m.localize)("aiNative.operate.afresh.title"),onClick:()=>v(E.EResultKind.REGENERATE)}],[v]);return r.default.createElement(o.ContentWidgetContainerPanel,{style:{transform:"translateY(4px)"}},r.default.createElement(l.AIInlineResult,{iconItems:s}))};t.InlineResultAction=p},40111:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.InlineChatController=void 0;const n=e(43718),r=e(93062),o=e(98864);class l{static is(E){return E instanceof l&&typeof E.mountReadable=="function"}constructor(E){this.options=E,this._onData=new n.Emitter,this.onData=this._onData.event,this._onEnd=new n.Emitter,this.onEnd=this._onEnd.event,this._onAbort=new n.Emitter,this.onAbort=this._onAbort.event,this._onError=new n.Emitter,this.onError=this._onError.event,this._stream=null,this._listened=!1}calculateCodeBlocks(E){var p;return!((p=this.options)===null||p===void 0)&&p.enableCodeblockRender?(0,o.extractCodeBlocks)(E):E}mountReadable(E){this._stream=E}get isListened(){return this._listened}listen(){if(this._listened)return;if(!this._stream)throw new Error("No Stream mounted");this._listened=!0;const E=new n.ReplyResponse("");let p="";(0,r.listenReadable)(this._stream,{onData:v=>{p+=v.content;const s=this.calculateCodeBlocks(p);E.updateMessage(s),this._onData.fire(E)},onEnd:()=>{this._onEnd.fire()},onError:v=>{n.AbortError.is(v)?this._onAbort.fire():this._onError.fire(new n.ErrorResponse(v))}})}}t.InlineChatController=l},51221:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.InlineChatEditorController=void 0;const n=e(41869),r=e(43718),o=e(66482),l=e(54414),m=e(52902),E=e(99906),p=e(89132),v=e(77633),s=e(38890),g=e(40111),c=e(31031),h=e(26664);class d extends E.BaseAIMonacoEditorController{constructor(){super(...arguments),this.aiInlineChatDisposable=new r.Disposable,this.aiInlineChatOperationDisposable=new r.Disposable,this.inlineChatInUsing=!1}static get(_){return _.getContribution(d.ID)}get aiNativeConfigService(){return this.injector.get(n.AINativeConfigService)}get aiInlineChatService(){return this.injector.get(n.IAIInlineChatService)}get inlineChatFeatureRegistry(){return this.injector.get(r.InlineChatFeatureRegistryToken)}get preferenceService(){return this.injector.get(n.PreferenceService)}get aiReporter(){return this.injector.get(r.IAIReporter)}get workbenchEditorService(){return this.injector.get(l.WorkbenchEditorService)}get codeActionService(){return this.injector.get(p.CodeActionService)}get logger(){return this.injector.get(r.ILogger)}get contextKeyService(){return this.injector.get(n.IContextKeyService)}mount(){if(this.inlineDiffController=s.InlineDiffController.get(this.monacoEditor),!this.monacoEditor)return this.featureDisposable;this.featureDisposable.addDispose(this.aiInlineChatService.onInlineChatVisible(a=>{a?this.showInlineChat(this.monacoEditor):(this.cancelToken(),this.disposeAllWidget())})),this.featureDisposable.addDispose(this.codeActionService.onCodeActionRun(({id:a,range:b})=>{const y=this.workbenchEditorService.currentEditor;y?.getId()===this.monacoEditor.getId()&&(this.monacoEditor.setSelection(b),this.showInlineChat(this.monacoEditor),this.aiInlineContentWidget&&this.aiInlineContentWidget.clickActionId(a,"codeAction"))})),this.featureDisposable.addDispose(this.monacoEditor.onWillChangeModel(()=>{this.disposeAllWidget()}));let _=!1;this.featureDisposable.addDispose(this.monacoEditor.onMouseDown(a=>{const y=a.target.detail;_=!1,!(y&&typeof y=="string"&&y===r.AIInlineChatContentWidgetId)&&this.aiInlineContentWidget&&!this.aiInlineContentWidget.isPersisted&&this.disposeAllWidget()})),this.featureDisposable.addDispose(this.monacoEditor.onMouseUp(a=>{const y=a.target.detail;y&&typeof y=="string"&&y===r.AIInlineChatContentWidgetId?_=!1:_=!0}));let f=this.preferenceService.getValid(r.AINativeSettingSectionsId.InlineChatAutoVisible,!0);return this.featureDisposable.addDispose(this.preferenceService.onSpecificPreferenceChange(r.AINativeSettingSectionsId.InlineChatAutoVisible,({newValue:a})=>{f=a})),this.featureDisposable.addDispose(r.Event.debounce(r.Event.any(this.monacoEditor.onDidChangeCursorSelection,this.monacoEditor.onMouseUp),(a,b)=>b,100)(()=>{!f||!_||this.aiInlineContentWidget&&this.aiInlineContentWidget.isPersisted||this.showInlineChat(this.monacoEditor)})),this.featureDisposable}disposeAllWidget(){[this.aiInlineContentWidget,this.aiInlineChatDisposable,this.aiInlineChatOperationDisposable].forEach(_=>{_?.dispose()}),this.inlineChatInUsing=!1,this.cancelToken()}showInlineContentWidget(_,f){this.aiInlineContentWidget&&this.aiInlineContentWidget.dispose(),this.aiInlineContentWidget=this.injector.get(h.AIInlineContentWidget,[_]),this.aiInlineContentWidget.show({selection:f})}async showInlineChat(_){if(this.contextKeyService.getContextValue(o.CONTEXT_IN_DEBUG_MODE_KEY)||!this.aiNativeConfigService.capabilities.supportsInlineChat||this.inlineChatInUsing)return;this.inlineChatInUsing=!0,this.disposeAllWidget();const a=_.getSelection();!a||a.isEmpty()||(this.showInlineContentWidget(_,a),this.aiInlineChatDisposable.addDispose(this.inlineChatFeatureRegistry.onChatClick(()=>{this.aiInlineChatService.launchInputVisible(!0)})),this.aiInlineChatDisposable.addDispose(this.aiInlineContentWidget.onActionClick(({actionId:b,source:y})=>{const S=this.inlineChatFeatureRegistry.getEditorHandler(b),A=this.inlineChatFeatureRegistry.getAction(b);if(!S||!A)return;const w=this.getCrossSelection(_);if(!w)return;const T=()=>{const D=S.providerDiffPreviewStrategy?S.providerDiffPreviewStrategy:S.providePreviewStrategy;if(D)return D.bind(this,_,this.token)};this.runAction({monacoEditor:_,crossSelection:w,reporterFn:()=>this.aiReporter.start(A.name,{message:A.name,type:r.AIServiceType.InlineChat,source:y,runByCodeAction:y==="codeAction",actionSource:y==="codeAction"?r.ActionSourceEnum.CodeAction:r.ActionSourceEnum.InlineChat,actionType:A.name}),execute:S.execute?S.execute.bind(this,_,this.token):void 0,providerPreview:T(),extraData:{actionSource:y==="codeAction"?r.ActionSourceEnum.CodeAction:r.ActionSourceEnum.InlineChat,actionType:A.name}})})),this.aiInlineChatDisposable.addDispose(this.aiInlineContentWidget.onInteractiveInputValue(async b=>{const y=this.inlineChatFeatureRegistry.getInteractiveInputHandler();if(!y)return;const S=await this.inlineChatFeatureRegistry.getInteractiveInputStrategyHandler()(_,b),A=this.getCrossSelection(_);A&&this.runAction({monacoEditor:_,crossSelection:A,reporterFn:()=>this.aiReporter.start(r.AIServiceType.InlineChatInput,{message:b,type:r.AIServiceType.InlineChatInput,source:"input",actionSource:r.ActionSourceEnum.InlineChatInput}),execute:y.execute&&S===v.ERunStrategy.EXECUTE?y.execute.bind(this,_,b,this.token):void 0,providerPreview:y.providePreviewStrategy&&S===v.ERunStrategy.PREVIEW?y.providePreviewStrategy.bind(this,_,b,this.token):void 0,extraData:{actionSource:r.ActionSourceEnum.InlineChatInput,actionType:S}})})))}getCrossSelection(_){const f=_.getSelection();if(!f){this.logger.error("No selection found, aborting inline chat action.");return}return f.setStartPosition(f.startLineNumber,1).setEndPosition(f.endLineNumber,_.getModel().getLineMaxColumn(f.endLineNumber))}convertInlineChatStatus(_,f){if(!this.aiInlineContentWidget)return;const{relationId:a,message:b,startTime:y,isRetry:S,isStop:A}=f;let w;_===c.EInlineChatStatus.DONE&&(w=this.inlineDiffController.getModifyContent()),this.aiInlineChatDisposable.addDispose(this.aiInlineContentWidget.launchChatStatus(_)),this.aiReporter.end(a,{message:b,success:_!==c.EInlineChatStatus.ERROR,replytime:Date.now()-y,isStop:A,isRetry:S,code:w,actionType:f?.actionType,actionSource:f?.actionSource})}visibleDiffWidget(_){const{monacoEditor:f,options:a,reportInfo:b}=_,{chatResponse:y}=a,{relationId:S,startTime:A,isRetry:w,actionType:T,actionSource:D}=b;if(g.InlineChatController.is(y))this.aiInlineChatOperationDisposable.addDispose([y.onError(O=>{this.convertInlineChatStatus(c.EInlineChatStatus.ERROR,{relationId:S,message:O.message||"",startTime:A,isRetry:w,actionSource:D,actionType:T})}),y.onAbort(()=>{this.convertInlineChatStatus(c.EInlineChatStatus.READY,{relationId:S,message:"abort",startTime:A,isRetry:w,isStop:!0,actionSource:D,actionType:T})}),y.onEnd(()=>{this.convertInlineChatStatus(c.EInlineChatStatus.DONE,{relationId:S,message:"",startTime:A,isRetry:w,actionSource:D,actionType:T})})]);else{if(this.aiInlineContentWidget&&this.aiInlineChatDisposable.disposed||r.CancelResponse.is(y)){this.convertInlineChatStatus(c.EInlineChatStatus.READY,{relationId:S,message:y.message||"",startTime:A,isRetry:w,isStop:!0,actionSource:D,actionType:T});return}if(r.ErrorResponse.is(y)){this.convertInlineChatStatus(c.EInlineChatStatus.ERROR,{relationId:S,message:y.message||"",startTime:A,isRetry:w,actionSource:D,actionType:T});return}this.convertInlineChatStatus(c.EInlineChatStatus.DONE,{relationId:S,message:"",startTime:A,isRetry:w,actionSource:D,actionType:T})}this.inlineDiffController.showPreviewerByStream(f,a).mount(this.aiInlineContentWidget)}ensureInlineChatVisible(_,f){this.aiInlineContentWidget.disposed?this.showInlineContentWidget(_,f):this.aiInlineContentWidget.isHidden&&this.aiInlineContentWidget.resume()}async handleDiffPreviewStrategy(_){if(!this.aiInlineContentWidget)return;const{monacoEditor:f,strategy:a,crossSelection:b,relationId:y,isRetry:S,actionType:A,actionSource:w}=_,T=f.getModel();this.inlineDiffController.destroyPreviewer(T.uri.toString()),this.aiInlineChatOperationDisposable.dispose(),this.ensureInlineChatVisible(f,b),this.aiInlineChatDisposable.addDispose(this.aiInlineContentWidget.launchChatStatus(c.EInlineChatStatus.THINKING));const D=Date.now();if(this.token.isCancellationRequested){this.convertInlineChatStatus(c.EInlineChatStatus.READY,{relationId:y,message:"abort",startTime:D,isRetry:S,isStop:!0,actionSource:w,actionType:A});return}const I=await a();if(r.CancelResponse.is(I)){this.convertInlineChatStatus(c.EInlineChatStatus.READY,{relationId:y,message:"abort",startTime:D,isRetry:S,isStop:!0,actionSource:w,actionType:A}),this.disposeAllWidget();return}this.visibleDiffWidget({monacoEditor:f,options:{crossSelection:b,chatResponse:I},reportInfo:{relationId:y,startTime:D,isRetry:S,actionType:A,actionSource:w}}),this.aiInlineChatOperationDisposable.addDispose([this.aiInlineContentWidget.onResultClick(O=>{const P=this.inlineDiffController.getModifyContent(),R=this.inlineDiffController.getOriginContent();this.inlineDiffController.handleAction(O),O===c.EResultKind.ACCEPT?(this.aiReporter.end(y,{message:"accept",success:!0,isReceive:!0,isDrop:!1,code:P,originCode:R,actionType:r.ActionTypeEnum.Accept}),(0,r.runWhenIdle)(()=>{this.disposeAllWidget()})):O===c.EResultKind.DISCARD?(this.aiReporter.end(y,{message:"discard",success:!0,isDrop:!0,isReceive:!1,code:P,originCode:R,actionType:r.ActionTypeEnum.Discard}),(0,r.runWhenIdle)(()=>{this.disposeAllWidget()})):O===c.EResultKind.REGENERATE&&(this.aiReporter.end(y,{message:"regenerate",success:!0,isDrop:!0,isReceive:!1,code:P,originCode:R,actionType:r.ActionTypeEnum.Regenerate}),this.handleDiffPreviewStrategy({monacoEditor:f,strategy:a,crossSelection:b,relationId:y,isRetry:!0,actionSource:w,actionType:A}))}),this.aiInlineChatService.onThumbs(O=>{this.aiReporter.end(y,{isLike:O})}),this.inlineDiffController.onMaxLineCount(O=>{requestAnimationFrame(()=>{if(b.endLineNumber===T.getLineCount()){const P=f.getOption(m.monacoApi.editor.EditorOption.lineHeight);this.aiInlineContentWidget.setOffsetTop(P*O+12)}})})])}async runAction(_){const{monacoEditor:f,crossSelection:a,reporterFn:b,execute:y,providerPreview:S,extraData:A}=_;if(y&&(await y(),this.disposeAllWidget()),S){const w=b();await this.handleDiffPreviewStrategy({monacoEditor:f,strategy:S,crossSelection:a,relationId:w,isRetry:!1,actionSource:A?.actionSource,actionType:A?.actionType})}}}t.InlineChatEditorController=d,d.ID="editor.contrib.ai.inline.chat"},2281:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.InlineChatFeatureRegistry=void 0;const n=e(85608),r=e(76003),o=e(41869),l=e(57925),m=e(83913),E=e(43718),p=e(89132),v=e(77633);class s{setHandler(h){this._handler=h}handler(){return this._handler}setStrategyHandler(h){this._strategyHandler=h}strategyHandler(){return this._strategyHandler}dispose(){this._handler=void 0}}s.ID=`${m.InteractiveInput.displayName}:${(0,E.uuid)(4)}`;let g=class extends E.Disposable{constructor(){super(...arguments),this.actionsMap=new Map,this.editorHandlerMap=new Map,this.terminalHandlerMap=new Map,this.interactiveInputModel=new s,this._onChatClick=new E.Emitter,this.onChatClick=this._onChatClick.event}dispose(){super.dispose(),this.actionsMap.clear(),this.editorHandlerMap.clear(),this.terminalHandlerMap.clear()}updateActions(h,d){this.actionsMap.set(h,d)}collectActions(h){const{id:d}=h;return this.actionsMap.has(d)?(this.logger.warn(`InlineChatFeatureRegistry: id ${d} already exists`),!1):((0,E.isUndefined)(h.renderType)&&(h.renderType="button"),(0,E.isUndefined)(h.order)&&(h.order=0),this.actionsMap.set(d,h),!0)}removeCollectedActions(h){this.actionsMap.delete(h.id),this.codeActionService.deleteCodeActionById(h.id)}getInteractiveInputId(){return s.ID}registerEditorInlineChat(h,d){return this.collectActions(h)&&(this.editorHandlerMap.set(h.id,d),this.codeActionService.registerCodeAction(h)),{dispose:()=>{this.removeCollectedActions(h)}}}unregisterEditorInlineChat(h){return this.removeCollectedActions(h)}registerTerminalInlineChat(h,d){return this.collectActions(h)&&((0,E.isUndefined)(d.triggerRules)&&(d.triggerRules="selection"),this.terminalHandlerMap.set(h.id,d)),{dispose:()=>{this.removeCollectedActions(h)}}}unregisterTerminalInlineChat(h){return this.removeCollectedActions(h)}registerInteractiveInput(h,d){this.interactiveInputModel.setHandler(d),h.handleStrategy?this.interactiveInputModel.setStrategyHandler(h.handleStrategy):this.interactiveInputModel.setStrategyHandler(()=>h.strategy||v.ERunStrategy.EXECUTE);const u=()=>{const _=String(this.getSequenceKeyString());if(_){const f={id:s.ID,name:`Chat(${_.toLocaleUpperCase()})`,renderType:"button",order:Number.MAX_SAFE_INTEGER};this.actionsMap.has(f.id)?this.updateActions(f.id,f):this.collectActions(f)}};return this.addDispose(E.Event.filter(this.keybindingRegistry.onKeybindingsChanged,({affectsCommands:_})=>_.includes(l.AI_INLINE_CHAT_INTERACTIVE_INPUT_VISIBLE.id))(()=>u())),u(),{dispose:()=>{this.interactiveInputModel.dispose()}}}getSequenceKeyString(){var h;const u=(h=this.keybindingRegistry.getKeybindingsForCommand(l.AI_INLINE_CHAT_INTERACTIVE_INPUT_VISIBLE.id)[0])===null||h===void 0?void 0:h.resolved;return u?this.keybindingRegistry.acceleratorForSequence(u,"+"):""}getInteractiveInputHandler(){return this.interactiveInputModel.handler()}getInteractiveInputStrategyHandler(){return this.interactiveInputModel.strategyHandler()}getEditorActionButtons(){const h=Array.from(this.editorHandlerMap.keys()).filter(d=>{const u=this.actionsMap.get(d);return u&&u.renderType==="button"}).map(d=>this.actionsMap.get(d)).sort((d,u)=>d.order-u.order);return this.actionsMap.has(s.ID)&&h.push(this.actionsMap.get(s.ID)),h}getEditorActionMenus(){return Array.from(this.editorHandlerMap.keys()).filter(h=>{const d=this.actionsMap.get(h);return d&&d.renderType==="dropdown"}).map(h=>this.actionsMap.get(h))}getEditorHandler(h){return this.editorHandlerMap.get(h)}getTerminalHandler(h){return this.terminalHandlerMap.get(h)}getTerminalActions(){return Array.from(this.terminalHandlerMap.keys()).map(h=>this.actionsMap.get(h))}getAction(h){return this.actionsMap.get(h)}};t.InlineChatFeatureRegistry=g,n.__decorate([(0,r.Autowired)(o.Logger),n.__metadata("design:type",o.Logger)],g.prototype,"logger",void 0),n.__decorate([(0,r.Autowired)(p.CodeActionService),n.__metadata("design:type",p.CodeActionService)],g.prototype,"codeActionService",void 0),n.__decorate([(0,r.Autowired)(o.KeybindingRegistry),n.__metadata("design:type",Object)],g.prototype,"keybindingRegistry",void 0),t.InlineChatFeatureRegistry=g=n.__decorate([(0,r.Injectable)()],g)},31031:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AIInlineChatService=t.EResultKind=t.EInlineChatStatus=void 0;const n=e(85608),r=e(76003),o=e(43718);var l=e(19413);Object.defineProperty(t,"EInlineChatStatus",{enumerable:!0,get:function(){return l.EInlineChatStatus}}),Object.defineProperty(t,"EResultKind",{enumerable:!0,get:function(){return l.EResultKind}});let m=class{constructor(){this._interactiveInputVisible=!1,this._onInteractiveInputVisible=new o.Emitter,this.onInteractiveInputVisible=this._onInteractiveInputVisible.event,this._onInlineChatVisible=new o.Emitter,this.onInlineChatVisible=this._onInlineChatVisible.event,this._onThumbs=new o.Emitter,this.onThumbs=this._onThumbs.event}get interactiveInputVisible(){return this._interactiveInputVisible}fireThumbsEvent(p){this._onThumbs.fire(p)}launchInputVisible(p){return(0,o.runWhenIdle)(()=>{this._interactiveInputVisible=p,this._onInteractiveInputVisible.fire(p)})}};t.AIInlineChatService=m,t.AIInlineChatService=m=n.__decorate([(0,r.Injectable)({multiple:!1})],m)},26664:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AIInlineContentWidget=void 0;const n=e(85608),r=n.__importStar(e(14041)),o=e(76003),l=e(41869),m=e(89195),E=e(83913),p=e(64102),v=e(43718),s=n.__importStar(e(20868)),g=e(62663),c=e(52659),h=e(77659),d=e(90614),u=e(2281),_=n.__importDefault(e(26899)),f=e(31031),a=y=>{const{onClickActions:S,onClose:A,onInteractiveInputSend:w,onLayoutChange:T,onChatStatus:D,onResultClick:I}=y,O=(0,l.useInjectable)(l.IAIInlineChatService),P=(0,l.useInjectable)(v.InlineChatFeatureRegistryToken),[R,M]=(0,r.useState)(f.EInlineChatStatus.READY),[k,B]=(0,r.useState)(!1);(0,r.useEffect)(()=>{const G=new v.Disposable;return G.addDispose(D(H=>M(H))),G.addDispose(O.onInteractiveInputVisible(H=>{B(H)})),()=>{G.dispose()}},[D,O]),(0,r.useEffect)(()=>{R===f.EInlineChatStatus.ERROR&&A?.()},[A]);const x=(0,r.useMemo)(()=>R===f.EInlineChatStatus.THINKING,[R]),N=(0,r.useMemo)(()=>R===f.EInlineChatStatus.DONE,[R]),j=(0,r.useMemo)(()=>R===f.EInlineChatStatus.ERROR,[R]),K=(0,r.useMemo)(()=>P.getEditorActionButtons(),[P]),U=(0,r.useCallback)(G=>{S?.(G)},[S]),X=(0,r.useCallback)(()=>{A?.()},[A]),z=(0,r.useCallback)(G=>{w?.(G)},[w]),Q=(0,r.useMemo)(()=>P.getEditorActionMenus().map(G=>new p.MenuNode({id:`ai.menu.operation.${G.id}`,label:G.name,className:_.default.more_operation_menu_item,execute:()=>{U(G.id)}})),[P]),Y=(0,r.useMemo)(()=>k?r.default.createElement(E.InteractiveInput,{autoFocus:!0,onHeightChange:G=>T(G),size:"small",placeholder:(0,v.localize)("aiNative.inline.chat.input.placeholder.default"),width:320,disabled:x,onSend:z}):null,[x,k]),Z=(0,r.useCallback)(()=>K.length===0&&Q.length===0||j?null:N?r.default.createElement(d.InlineResultAction,{onResultClick:I}):r.default.createElement(m.AIAction,{operationList:K,moreOperation:Q,onClickItem:U,onClose:X,loading:x,loadingShowOperation:k,customOperationRender:Y}),[K,Q,Y,I,R,k]);return r.default.createElement("div",{className:_.default.inline_chat_controller_box},Z())};let b=class extends c.ReactInlineContentWidget{get interactiveInputValue(){return this._interactiveInputValue}get status(){return this._status}get isPersisted(){return!this.isHidden&&this.status!==f.EInlineChatStatus.READY&&this.status!==f.EInlineChatStatus.ERROR}constructor(S){super(S),this.editor=S,this.allowEditorOverflow=!0,this._onActionClickEmitter=new v.Emitter,this.onActionClick=this._onActionClickEmitter.event,this._onInteractiveInputValue=new v.Emitter,this.onInteractiveInputValue=this._onInteractiveInputValue.event,this._onStatusChange=new v.Emitter,this.onStatusChange=this._onStatusChange.event,this._onResultClick=new v.Emitter,this.onResultClick=this._onResultClick.event,this._status=f.EInlineChatStatus.READY,this.aiNativeContextKey=this.injector.get(h.AINativeContextKey,[this.editor.contextKeyService]),this.addDispose(this.editor.onDidLayoutChange(()=>{this.isOutOfArea()&&this.dispose()}))}launchChatStatus(S){return(0,v.runWhenIdle)(()=>{this._status=S,this._onStatusChange.fire(S)})}dispose(){this.launchChatStatus(f.EInlineChatStatus.READY),super.dispose()}clickActionId(S,A){if(S===this.inlineChatFeatureRegistry.getInteractiveInputId()){this.inlineChatFeatureRegistry._onChatClick.fire();return}this._onActionClickEmitter.fire({actionId:S,source:A})}renderView(){return r.default.createElement(a,{onClickActions:S=>this.clickActionId(S,"widget"),onClose:()=>this.dispose(),onChatStatus:this.onStatusChange.bind(this),onLayoutChange:()=>{this.editor.layoutContentWidget(this)},onInteractiveInputSend:S=>{this.launchChatStatus(f.EInlineChatStatus.THINKING),this._interactiveInputValue=S,this._onInteractiveInputValue.fire(S)},onResultClick:S=>{this._onResultClick.fire(S)}})}async show(S){super.show(S),this.aiNativeContextKey.inlineChatIsVisible.set(!0)}getDomNode(){const S=super.getDomNode();return requestAnimationFrame(()=>{S.style.zIndex=(l.StackingLevel.FindWidget-1).toString()}),S}async hide(){this.aiNativeContextKey.inlineChatIsVisible.set(!1),super.hide()}setOptions(S){this.options=S}setOffsetTop(S){this.domNode.style.transform=`translateY(${S}px)`}id(){return v.AIInlineChatContentWidgetId}getPosition(){const S=super.getPosition();if(S)return S;if(!this.options)return null;const{selection:A}=this.options;if(!A)return null;const w=this.computePosition(A);return w||null}safeGetLineLastNonWhitespaceColumn(S){const A=this.editor.getModel();S<1&&(S=1);const w=A.getLineCount();return S>w&&(S=w),A.getLineLastNonWhitespaceColumn(S)}toAbovePosition(S,A){return{position:new s.Position(S,A),preference:[g.monacoBrowser.editor.ContentWidgetPositionPreference.ABOVE,g.monacoBrowser.editor.ContentWidgetPositionPreference.BELOW]}}toBelowPosition(S,A){return{position:new s.Position(S,A),preference:[g.monacoBrowser.editor.ContentWidgetPositionPreference.BELOW,g.monacoBrowser.editor.ContentWidgetPositionPreference.ABOVE]}}recheckSelection(S){const A=S.getStartPosition(),w=S.getEndPosition(),D=this.editor.getModel().getLineCount(),I=Math.max(1,w.lineNumber-1),O=Math.min(D,w.lineNumber+1),P=A.with(I,1),R=w.with(O,this.safeGetLineLastNonWhitespaceColumn(O));if(D===1)return this.toBelowPosition(O,this.safeGetLineLastNonWhitespaceColumn(O));if(R.lineNumber===1&&w.lineNumber!==A.lineNumber)return this.computePosition(s.Selection.fromPositions(P,R));const M=this.safeGetLineLastNonWhitespaceColumn(I),k=this.safeGetLineLastNonWhitespaceColumn(O),B=this.safeGetLineLastNonWhitespaceColumn(w.lineNumber);return k>B&&k>M?this.computePosition(s.Selection.fromPositions(R,P)):this.computePosition(s.Selection.fromPositions(P,R))}isProtrudeAbove(S){const A=this.safeGetLineLastNonWhitespaceColumn(S);return A>=this.safeGetLineLastNonWhitespaceColumn(S-1)&&A>=this.safeGetLineLastNonWhitespaceColumn(S-2)}isProtrudeBelow(S){const A=this.safeGetLineLastNonWhitespaceColumn(S);return A>=this.safeGetLineLastNonWhitespaceColumn(S+1)&&A>=this.safeGetLineLastNonWhitespaceColumn(S+2)}computePosition(S){const A=S.getStartPosition(),w=S.getEndPosition();let T=S.getPosition();const I=this.editor.getModel().getLineCount();if(A.lineNumber===w.lineNumber)return this.recheckSelection(S);w.lineNumber-A.lineNumber===1&&(T=w);const O=this.safeGetLineLastNonWhitespaceColumn(T.lineNumber);let P=T.lineNumber,R="below";if(T.equals(A)){if(Math.max(this.safeGetLineLastNonWhitespaceColumn(T.lineNumber-1),this.safeGetLineLastNonWhitespaceColumn(T.lineNumber-2))<=O)return this.toAbovePosition(T.lineNumber,O);for(let B=A.lineNumber;B<=w.lineNumber;B++){if(this.isProtrudeAbove(B)){P=B,R="above";break}if(this.isProtrudeBelow(B)){P=B,R="below";break}}}else if(T.equals(w)){if(Math.max(this.safeGetLineLastNonWhitespaceColumn(T.lineNumber+1),this.safeGetLineLastNonWhitespaceColumn(T.lineNumber+2))<=O)return this.toBelowPosition(T.lineNumber,O);for(let B=Math.min(I,w.lineNumber+1);B>=A.lineNumber;B--){if(this.isProtrudeBelow(B)){P=B,R="below";break}if(this.isProtrudeAbove(B)){P=B,R="above";break}}}const M=this.safeGetLineLastNonWhitespaceColumn(P)+1;return R==="below"?this.toBelowPosition(P,M):this.toAbovePosition(P,M)}};t.AIInlineContentWidget=b,n.__decorate([(0,o.Autowired)(o.INJECTOR_TOKEN),n.__metadata("design:type",o.Injector)],b.prototype,"injector",void 0),n.__decorate([(0,o.Autowired)(v.InlineChatFeatureRegistryToken),n.__metadata("design:type",u.InlineChatFeatureRegistry)],b.prototype,"inlineChatFeatureRegistry",void 0),t.AIInlineContentWidget=b=n.__decorate([(0,o.Injectable)({multiple:!0}),n.__metadata("design:paramtypes",[Object])],b)},15989:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=e(85608);n.__exportStar(e(38890),t),n.__exportStar(e(49444),t),n.__exportStar(e(37679),t),n.__exportStar(e(51347),t)},49444:(L,t,e)=>{"use strict";var n;Object.defineProperty(t,"__esModule",{value:!0}),t.LiveInlineDiffPreviewer=t.SideBySideInlineDiffWidget=t.BaseInlineDiffPreviewer=void 0;const r=e(85608),o=e(76003),l=e(43718),m=e(20868),E=e(90052),p=e(77714),v=e(43255),s=e(74547),g=e(11827),c=e(9491),h=e(31031),d=e(33062),u=e(37679);let _=class extends l.Disposable{constructor(y){super(),this.monacoEditor=y,this.inlineContentWidget=null,this.model=this.monacoEditor.getModel(),this.addDispose(l.Disposable.create(()=>{this.inlineContentWidget&&this.inlineContentWidget.dispose(),this.attachNode(void 0)}))}formatIndentation(y){const S=this.selection.startLineNumber,A=(0,p.getLeadingWhitespace)(this.model.getLineContent(S));if(y===p.empty||A===p.empty)return y;const{tabSize:w,insertSpaces:T}=this.model.getOptions(),D=this.model.getEOL(),I=(0,c.getSpaceCnt)(A,w);let O=(0,c.generateIndent)(I,w,T);const P=y.split(D),R=P[0];let M=!1;if(R){const B=(0,p.getLeadingWhitespace)(R);O===B?O="":O.length>B.length?O=O.slice(B.length):(O=B.slice(O.length),M=!0)}return P.map(B=>{if(M){const x=(0,p.getLeadingWhitespace)(B);return B=O+B.substring(x.length),B}return O+B}).join(D)}getNode(){return this.node}createNodeSnapshot(){return this.node}mount(y){this.inlineContentWidget=y}layout(){var y,S;(y=this.inlineContentWidget)===null||y===void 0||y.setOptions({position:this.getPosition()}),(S=this.inlineContentWidget)===null||S===void 0||S.layoutContentWidget()}onReady(y){return y(),l.Disposable.NULL}create(y,S={disposeWhenEditorClosed:!0}){this.selection=y,this.node=this.createNode(),this.node.setPreviewerOptions(S)}attachNode(y){this.node=y}show(y,S){}onLineCount(y){return this}setValue(y){}getValue(){return""}getOriginValue(){return""}onError(y){}onAbort(){}onEnd(){}revealFirstDiff(){}isModel(y){return this.model.uri.toString()===y}};t.BaseInlineDiffPreviewer=_,r.__decorate([(0,o.Autowired)(o.INJECTOR_TOKEN),r.__metadata("design:type",o.Injector)],_.prototype,"injector",void 0),t.BaseInlineDiffPreviewer=_=r.__decorate([(0,o.Injectable)({multiple:!0}),r.__metadata("design:paramtypes",[Object])],_);let f=n=class extends _{createNode(){const y=this.injector.get(u.InlineDiffWidget,[n.AI_DIFF_WIDGET_ID,{editor:this.monacoEditor,selection:this.selection}]);return y.create(),this.addDispose(y),y}mount(y){super.mount(y),y.addDispose(this)}getPosition(){return m.Position.lift({lineNumber:this.selection.endLineNumber+1,column:1})}layout(){var y;(y=this.inlineContentWidget)===null||y===void 0||y.setPositionPreference([E.ContentWidgetPositionPreference.BELOW]),super.layout()}onReady(y){return this.node?this.node.onReady(y.bind(this)):l.Disposable.NULL}show(y,S){var A;(A=this.node)===null||A===void 0||A.showByLine(y,S)}setValue(y){var S;const A=(S=this.node)===null||S===void 0?void 0:S.getModifiedModel();A?.setValue(this.formatIndentation(y))}getValue(){var y;return((y=this.node)===null||y===void 0?void 0:y.getModifiedModel()).getValue()}getOriginValue(){var y;return((y=this.node)===null||y===void 0?void 0:y.getOriginModel()).getValue()||""}handleAction(y){if(y===h.EResultKind.ACCEPT){const S=this.getValue();this.model.pushEditOperations(null,[{range:this.selection,text:S}],()=>null),this.model.pushStackElement()}}onLineCount(y){var S;return(S=this.node)===null||S===void 0||S.onMaxLineCount(y.bind(this)),this}onData(y){var S,A;const{message:w}=y,T=this.formatIndentation(w),D=(S=this.node)===null||S===void 0?void 0:S.getModifiedModel(),I=D.getEOL()===`\r
|
|
28269
|
-
`?v.DefaultEndOfLine.CRLF:v.DefaultEndOfLine.LF,{textBuffer:O,disposable:P}=(0,s.createTextBuffer)(T,I),R=g.ModelService._computeEdits(D,O);D.pushEditOperations([],R,()=>[]),P.dispose(),(A=this.node)===null||A===void 0||A.layout()}onError(y){var S;(S=this.node)===null||S===void 0||S.layout()}onAbort(){var y;(y=this.node)===null||y===void 0||y.layout()}onEnd(){var y;(y=this.node)===null||y===void 0||y.layout()}};t.SideBySideInlineDiffWidget=f,f.AI_DIFF_WIDGET_ID="AI-DIFF-WIDGET",t.SideBySideInlineDiffWidget=f=n=r.__decorate([(0,o.Injectable)({multiple:!0})],f);let a=class extends _{listenNode(y){y.addDispose(y.onDidEditChange(()=>this.layout())),y.addDispose(y.onPartialEditWidgetListChange(A=>{var w;A.every(T=>T.isHidden)&&(this.dispose(),(w=this.inlineContentWidget)===null||w===void 0||w.dispose())}));const S=y.onDispose(()=>{this.dispose(),S.dispose()});this.addDispose(y)}createNode(){const y=this.injector.get(d.InlineStreamDiffHandler,[this.monacoEditor]);return y.initialize(this.selection),this.listenNode(y),y}attachNode(y){var S;if((S=this.node)===null||S===void 0||S.dispose(),this.node=y,y){const A=y.currentSnapshotStore;A&&(this.node.restoreDecorationSnapshot(A.decorationSnapshotData),this.listenNode(y))}}createNodeSnapshot(){if(!this.node)return this.createNode();const y=this.node.createSnapshot(),S=this.injector.get(d.InlineStreamDiffHandler,[this.monacoEditor]);return S.restoreSnapshot(y),S}getPosition(){var y;const S=(y=this.node)===null||y===void 0?void 0:y.getZone();return S?m.Position.lift({lineNumber:S.startLineNumber,column:1}):m.Position.lift({lineNumber:1,column:1})}handleAction(y){var S,A;switch(y){case h.EResultKind.ACCEPT:(S=this.node)===null||S===void 0||S.acceptAll();break;case h.EResultKind.DISCARD:case h.EResultKind.REGENERATE:(A=this.node)===null||A===void 0||A.rejectAll();break;default:break}}onLineCount(){return l.Disposable.NULL}layout(){var y,S,A;(y=this.inlineContentWidget)===null||y===void 0||y.setPositionPreference([E.ContentWidgetPositionPreference.ABOVE,E.ContentWidgetPositionPreference.BELOW]),super.layout();const w=this.getPosition();if(w&&this.inlineContentWidget){const T=(S=this.node)===null||S===void 0?void 0:S.livePreviewDiffDecorationModel.getRemovedWidgets();if(T?.length){const D=w.lineNumber,I=T[0];if(I&&((A=I.getLastPosition())===null||A===void 0?void 0:A.lineNumber)<=D){const P=this.inlineContentWidget.getLineHeight(),R=I.height;this.inlineContentWidget.setOffsetTop(-P*R-4)}}}}onData(y){var S;const{message:A}=y;(S=this.node)===null||S===void 0||S.addLinesToDiff(this.formatIndentation(A))}onEnd(){var y,S;const A=(y=this.node)===null||y===void 0?void 0:y.recompute(d.EComputerMode.legacy);A&&((S=this.node)===null||S===void 0||S.pushRateFinallyDiffStack(A))}getValue(){var y;return((y=this.node)===null||y===void 0?void 0:y.getVirtualModelValue())||""}getOriginValue(){var y;return((y=this.node)===null||y===void 0?void 0:y.getOriginModelValue())||""}setValue(y){var S,A;const w=(S=this.node)===null||S===void 0?void 0:S.recompute(d.EComputerMode.legacy,this.formatIndentation(y));w&&((A=this.node)===null||A===void 0||A.finallyRender(w))}revealFirstDiff(){var y;(y=this.node)===null||y===void 0||y.revealFirstDiff()}};t.LiveInlineDiffPreviewer=a,t.LiveInlineDiffPreviewer=a=r.__decorate([(0,o.Injectable)({multiple:!0})],a)},37679:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.InlineDiffWidget=void 0;const n=e(85608),r=n.__importStar(e(14041)),o=e(43144),l=n.__importDefault(e(25873)),m=e(76003),E=e(41869),p=n.__importStar(e(20868)),v=e(87822),s=e(34819),g=e(90626),c=n.__importDefault(e(69790)),h={fixedOverflowWidgets:!0,readOnly:!1,enableSplitViewResizing:!0,ignoreTrimWhitespace:!0,renderSideBySide:!0,lineNumbers:"on",glyphMargin:!0,scrollbar:{useShadows:!1,alwaysConsumeMouseWheel:!1,vertical:"hidden"},scrollBeyondLastLine:!1,renderMarginRevertIcon:!1,renderOverviewRuler:!1,rulers:void 0,overviewRulerBorder:void 0,overviewRulerLanes:0,padding:{top:0,bottom:0},folding:!1,diffCodeLens:!1,stickyScroll:{enabled:!1},minimap:{enabled:!1},automaticLayout:!0,renderIndicators:!1,inDiffEditor:!0},d=r.default.memo(_=>{const{range:f,onMaxLineCount:a,editor:b,onReady:y}=_,S=(0,E.useInjectable)(E.MonacoService),A=(0,r.useRef)(null);return(0,r.useEffect)(()=>{if(!f)return;const w=b.getModel();if(!w)return;const T=w.getValueInRange(f),D=S.createDiffEditor(A.current,{...h,lineDecorationsWidth:b.getLayoutInfo().decorationsWidth,lineNumbersMinChars:b.getOption(p.editor.EditorOption.lineNumbersMinChars)}),I=g.StandaloneServices.get(v.IModelService),O={languageId:w.getLanguageId(),onDidChange:E.Event.None},P=I.createModel(T,O,p.Uri.from({scheme:E.Schemes.inMemory,path:"inline-diff-widget/"+(0,E.randomString)(8)}),!0),R=I.createModel("",O,p.Uri.from({scheme:E.Schemes.inMemory,path:"inline-diff-widget/"+(0,E.randomString)(8)}),!0);D.setModel({original:P,modified:R}),D.revealLine(f.startLineNumber,p.editor.ScrollType.Immediate);const M=()=>{if(a){const k=P.getLineCount(),B=R.getLineCount();a(Math.max(k,B)+1)}};return y&&y({getModifiedModel:()=>R,getOriginModel:()=>P,layout:M}),M(),()=>{D&&D.dispose()}},[f,b]),r.default.createElement("div",{ref:A,className:c.default.diff_editor_widget})});let u=class extends s.ZoneWidget{setPreviewerOptions(f){this.previewerOptions=f}_fillContainer(f){this.setCssClass("inline-diff-widget"),this.root=l.default.createRoot(f);let a=null;if(this._resolveResultWidget)if(f.parentNode){const b=document.createElement("div");requestAnimationFrame(()=>{b.className=c.default.ai_diff_editor_resolve_result_widget;const y=this.editor.getLayoutInfo();b.style.width=`${y.contentWidth}px`,b.style.left=`${y.contentLeft}px`}),f.parentNode.appendChild(b),a=(0,o.createPortal)(this._resolveResultWidget,b),this.resultContainer=b}else throw new Error("[impossible path] container.parentNode is null");this.root.render(r.default.createElement(E.ConfigProvider,{value:this.configContext},r.default.createElement("div",{className:c.default.ai_diff_editor_container},r.default.createElement(d,{range:this.range,editor:this.editor,onMaxLineCount:b=>{b&&(this._relayout(b),this._onMaxLineCount.fire(b))},onReady:b=>{this.diffWidgetHandler=b,this._onReady.fire()}})),a))}computeResultWidgetWidth(){const f=this.editor.getLayoutInfo();return f.contentWidth+f.contentLeft}_onWidth(f){super._onWidth(f),requestAnimationFrame(()=>{this.resultContainer&&(this.resultContainer.style.width=`${this.computeResultWidgetWidth()}px`)})}getModifiedModel(){var f;return(f=this.diffWidgetHandler)===null||f===void 0?void 0:f.getModifiedModel()}getOriginModel(){var f;return(f=this.diffWidgetHandler)===null||f===void 0?void 0:f.getOriginModel()}layout(){var f;return(f=this.diffWidgetHandler)===null||f===void 0?void 0:f.layout()}constructor(f,a){super(a.editor,{showArrow:!1,showFrame:!1,arrowColor:void 0,frameColor:void 0,keepEditorSelection:!0,showInHiddenAreas:!0}),this.id=f,this._onMaxLineCount=new E.Emitter,this.onMaxLineCount=this._onMaxLineCount.event,this._onReady=new E.Emitter,this.onReady=this._onReady.event,this.diffWidgetHandler=null,this.resultContainer=null,this._resolveResultWidget=null;const{selection:b,hiddenArea:y,editor:S}=a;this.range=b,this.hiddenArea=y||b,S.setHiddenAreas([this.hiddenArea],this.id)}revealRange(f,a){}setContainerStyle(f){var a;const b=Object.keys(f);for(const y of b)Object.prototype.hasOwnProperty.call((a=this.container)===null||a===void 0?void 0:a.style,y)&&(this.container.style[y]=f[y])}addClassName(f){return this.setCssClass(f),this}dispose(){this.hide(),super.dispose()}hide(){this.editor.setHiddenAreas([],this.id),super.hide(),this.root&&this.root.unmount()}showByLine(f,a=20){this.editor._modelData.viewModel.coordinatesConverter.modelPositionIsVisible=()=>!0,super.show({startLineNumber:f,startColumn:1,endLineNumber:f,endColumn:Number.MAX_SAFE_INTEGER},a)}setResolveResultWidget(f){this._resolveResultWidget=f}};t.InlineDiffWidget=u,n.__decorate([(0,m.Autowired)(E.AppConfig),n.__metadata("design:type",Object)],u.prototype,"configContext",void 0),t.InlineDiffWidget=u=n.__decorate([(0,m.Injectable)({multiple:!0}),n.__metadata("design:paramtypes",[String,Object])],u)},38890:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.InlineDiffController=void 0;const n=e(41869),r=e(43718),o=e(57517),l=e(99906),m=e(83854),E=e(40111),p=e(49444);class v extends l.BaseAIMonacoEditorController{constructor(){super(...arguments),this._onMaxLineCount=new r.Emitter,this.onMaxLineCount=this._onMaxLineCount.event,this._previewerNodeStore=new Map}static get(g){return g.getContribution(v.ID)}get preferenceService(){return this.injector.get(n.PreferenceService)}get eventBus(){return this.injector.get(r.IEventBus)}mount(){return this.featureDisposable.addDispose(this.eventBus.on(o.EditorGroupCloseEvent,g=>{const c=g.payload.resource.uri.toString(),h=this.getStoredState(c);h&&h.previewerOptions.disposeWhenEditorClosed&&this.destroyPreviewer(c)})),this.registerInlineDiffFeature(this.monacoEditor),this.featureDisposable}storeState(g){if(!this.previewer)return;const c=this.previewer.createNodeSnapshot();c&&this._previewerNodeStore.set(g,c)}tryRestoreState(g,c){const h=this.getStoredState(c);if(h){if(h.disposed){this.destroyPreviewer(c);return}return this.restoreState(g,h)}}restoreState(g,c){var h;if((h=g.getModel())===null||h===void 0?void 0:h.uri){this.previewer=this.injector.get(p.LiveInlineDiffPreviewer,[g]),this.previewer.attachNode(c),this.listenPreviewer(this.previewer);const u=this.previewer.onDispose(()=>{this.destroyPreviewer(),u.dispose()})}}registerInlineDiffFeature(g){const c=g.getModel();this.featureDisposable.addDispose(g.onWillChangeModel(h=>{if(!h.oldModelUrl)return;const d=h.oldModelUrl.toString();this.storeState(d),this.destroyPreviewer()})),this.featureDisposable.addDispose(g.onDidChangeModel(h=>{h.newModelUrl&&this.tryRestoreState(g,h.newModelUrl.toString())})),c&&this.featureDisposable.addDispose(c.onWillDispose(()=>{const h=c.uri.toString();this.destroyPreviewer(h)}))}showPreviewerByStream(g,c){const{crossSelection:h,chatResponse:d}=c,u=new r.Disposable,_=this.createDiffPreviewer(g,h,c.previewerOptions),f=()=>{_.layout(),u.dispose()};return u.addDispose(_.onReady(()=>{if(E.InlineChatController.is(d)){const a=d;u.addDispose([a.onData(b=>{r.ReplyResponse.is(b)&&_.onData(b)}),a.onError(b=>{_.onError(b),f()}),a.onAbort(()=>{_.onAbort(),f()}),a.onEnd(()=>{_.onEnd(),f()})]),a.listen()}else _.setValue(d.message),f()})),_.layout(),_}createDiffPreviewer(g,c,h){const d=this.preferenceService.getValid(r.AINativeSettingSectionsId.InlineDiffPreviewMode,m.EInlineDiffPreviewMode.inlineLive);return this.destroyPreviewer(),d===m.EInlineDiffPreviewMode.sideBySide?this.previewer=this.injector.get(p.SideBySideInlineDiffWidget,[g]):this.previewer=this.injector.get(p.LiveInlineDiffPreviewer,[g]),this.previewer.create(c,h),this.previewer.show(c.startLineNumber-1,c.endLineNumber-c.startLineNumber+2),this.listenPreviewer(this.previewer),this.previewer}listenPreviewer(g){g&&g.addDispose(g.onLineCount(c=>this._onMaxLineCount.fire(c)))}getPreviewer(){return this.previewer}getStoredState(g){return this._previewerNodeStore.get(g)}handleAction(g){var c;(c=this.previewer)===null||c===void 0||c.handleAction(g)}getModifyContent(){var g;return(g=this.previewer)===null||g===void 0?void 0:g.getValue()}getOriginContent(){var g;return(g=this.previewer)===null||g===void 0?void 0:g.getOriginValue()}destroyPreviewer(g){var c;(c=this.previewer)===null||c===void 0||c.dispose(),this.previewer=void 0,g&&this._previewerNodeStore.delete(g)}revealFirstDiff(){var g;(g=this.previewer)===null||g===void 0||g.revealFirstDiff()}}t.InlineDiffController=v,v.ID="editor.contrib.ai.inline.diff"},51347:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.InlineDiffService=void 0;const n=e(85608),r=e(76003),o=e(70392);let l=class{constructor(){this._partialEventEmitter=new o.Emitter,this.onPartialEdit=this._partialEventEmitter.event}firePartialEdit(E){this._partialEventEmitter.fire(E)}};t.InlineDiffService=l,t.InlineDiffService=l=n.__decorate([(0,r.Injectable)()],l)},53182:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.InlineHintLineDecoration=void 0;const n=e(85608),r=e(76003),o=e(41869),l=e(57925),m=e(43718),E=e(20868),p=e(60304),v=e(52416),s=e(75189),g="inline_hint_description",c="inline_hint_description_key";let h=class extends m.Disposable{constructor(u){super(),this.monacoEditor=u,this.colorRegister=(0,v.getColorRegistry)(),p.StandaloneServices.get(s.ICodeEditorService).registerDecorationType(g,c,{isWholeLine:!0}),this.addDispose(m.Disposable.create(()=>{this.monacoEditor.setDecorationsByType(g,c,[])}))}getSequenceKeyString(u="+"){var _;const a=(_=this.keybindingRegistry.getKeybindingsForCommand(l.AI_INLINE_CHAT_INTERACTIVE_INPUT_VISIBLE.id)[0])===null||_===void 0?void 0:_.resolved;return a?this.keybindingRegistry.acceleratorForSequence(a,u):""}async show(u){var _;const f=(0,m.formatLocalize)("aiNative.inline.hint.widget.placeholder",this.getSequenceKeyString("")),a=await this.themeService.getCurrentTheme(),b=this.colorRegister.resolveDefaultColor(v.inputPlaceholderForeground,a);this.monacoEditor.setDecorationsByType(g,c,[{range:E.Range.fromPositions(u),renderOptions:{after:{contentText:f,opacity:"0.5",color:(_=b?.toString())!==null&&_!==void 0?_:"",padding:"0 0 0 12px",width:"max-content",fontFamily:"-apple-system,BlinkMacSystemFont,PingFang SC,Hiragino Sans GB,sans-serif"}}}])}};t.InlineHintLineDecoration=h,n.__decorate([(0,r.Autowired)(o.KeybindingRegistry),n.__metadata("design:type",Object)],h.prototype,"keybindingRegistry",void 0),n.__decorate([(0,r.Autowired)(v.IThemeService),n.__metadata("design:type",Object)],h.prototype,"themeService",void 0),t.InlineHintLineDecoration=h=n.__decorate([(0,r.Injectable)({multiple:!0}),n.__metadata("design:paramtypes",[Object])],h)},77886:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.InlineHintController=void 0;const n=e(43718),r=e(77659),o=e(99906),l=e(71863),m=e(74353),E=e(19520),p=e(53182);class v extends o.BaseAIMonacoEditorController{static get(g){return g.getContribution(v.ID)}get inlineCompletionsService(){return this.injector.get(l.AICompletionsService)}get inlineInputChatService(){return this.injector.get(m.InlineInputChatService)}mount(){return this.registerHintLineFeature(this.monacoEditor)}registerHintLineFeature(g){const c=new n.Disposable,h=this.injector.get(r.AINativeContextKey,[g.contextKeyService]),d=()=>{c.dispose()},u=_=>{var f;const a=g.getModel();if(!a||this.inlineCompletionsService.isVisibleCompletion)return;if(!a.getLineDecorations(_.lineNumber).some(S=>S.options.description===E.InlineInputPreviewDecorationID)){const S=this.injector.get(p.InlineHintLineDecoration,[g]),A=(f=g.getModel())===null||f===void 0?void 0:f.getLineContent(_.lineNumber);A?.trim()||S.show(_),this.inlineInputChatService.setCurrentVisiblePosition(_),h.inlineHintWidgetIsVisible.set(!0),c.addDispose(S.onDispose(()=>{this.inlineInputChatService.setCurrentVisiblePosition(void 0),h.inlineHintWidgetIsVisible.set(!1)})),c.addDispose(S)}};return this.featureDisposable.addDispose(g.onDidChangeCursorPosition(_=>{d(),u(_.position)})),this.featureDisposable.addDispose(g.onDidFocusEditorWidget(()=>{const _=g.getPosition();_&&(d(),u(_))})),this.featureDisposable.addDispose(g.onDidBlurEditorWidget(()=>{d()})),this.featureDisposable.addDispose(this.inlineCompletionsService.onVisibleCompletion(_=>{_&&d()})),this.featureDisposable.addDispose(c),this.featureDisposable}}t.InlineHintController=v,v.ID="editor.contrib.ai.inline.hint"},32213:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.InlineInputChatWidget=void 0;const n=e(85608),r=n.__importStar(e(14041)),o=e(76003),l=e(89195),m=e(43718),E=e(90052),p=e(90614),v=e(31031),s=e(26664),g=n.__importDefault(e(13185)),c=e(74353),h=u=>{const{onClose:_,onInteractiveInputSend:f,onLayoutChange:a,onChatStatus:b,onResultClick:y}=u,[S,A]=(0,r.useState)(v.EInlineChatStatus.READY);(0,r.useEffect)(()=>{const P=new m.Disposable;return P.addDispose(b(R=>A(R))),()=>{P.dispose()}},[b]);const w=(0,r.useMemo)(()=>S===v.EInlineChatStatus.THINKING,[S]),T=(0,r.useMemo)(()=>S===v.EInlineChatStatus.DONE,[S]),D=(0,r.useMemo)(()=>S===v.EInlineChatStatus.ERROR,[S]),I=(0,r.useCallback)(()=>{_?.()},[_]),O=(0,r.useCallback)(P=>{f?.(P)},[f]);return D?null:T?r.default.createElement(p.InlineResultAction,{onResultClick:y}):r.default.createElement(l.AIAction,{loadingShowOperation:!0,onClose:I,loading:w,customOperationRender:r.default.createElement(l.InteractiveInput,{autoFocus:!0,onHeightChange:P=>a(P),size:"small",placeholder:(0,m.localize)("aiNative.inline.chat.input.placeholder.default"),width:320,disabled:w,onSend:O})})};let d=class extends s.AIInlineContentWidget{constructor(){super(...arguments),this.allowEditorOverflow=!0,this.positionPreference=[E.ContentWidgetPositionPreference.ABOVE]}dispose(){super.dispose(),this.inlineInputChatService.hide()}id(){return m.AIInlineInputChatContentWidgetId}renderView(){return r.default.createElement("div",{className:g.default.input_wrapper},r.default.createElement(h,{onClose:()=>this.dispose(),onChatStatus:this.onStatusChange.bind(this),onLayoutChange:()=>{this.editor.layoutContentWidget(this)},onInteractiveInputSend:_=>{this.launchChatStatus(v.EInlineChatStatus.THINKING),this._onInteractiveInputValue.fire(_)},onResultClick:_=>{this._onResultClick.fire(_)}}))}};t.InlineInputChatWidget=d,n.__decorate([(0,o.Autowired)(c.InlineInputChatService),n.__metadata("design:type",c.InlineInputChatService)],d.prototype,"inlineInputChatService",void 0),t.InlineInputChatWidget=d=n.__decorate([(0,o.Injectable)({multiple:!0})],d)},89060:(L,t,e)=>{"use strict";var n;Object.defineProperty(t,"__esModule",{value:!0}),t.InlineInputController=void 0;const r=e(85608),o=e(76003),l=e(43718),m=r.__importStar(e(20868)),E=e(2261),p=e(52451),v=e(74547),s=e(77659),g=e(99906),c=e(85679),h=e(77633),d=e(40111),u=e(31031),_=e(19520),f=e(32213),a=r.__importDefault(e(13185)),b=e(74353);let y=n=class extends g.BaseAIMonacoEditorController{static get(A){return A.getContribution(n.ID)}get inlineInputChatService(){return this.injector.get(b.InlineInputChatService)}get inlineChatFeatureRegistry(){return this.injector.get(l.InlineChatFeatureRegistryToken)}get languageParserService(){return this.injector.get(c.LanguageParserService)}mount(){return this.registerInlineInputFeature(this.monacoEditor)}async doRequestReadable(A,w,T,D,I,O){const P=this.inlineChatFeatureRegistry.getInteractiveInputHandler(),R=T.getModel();if(!P||!R)return;w.launchChatStatus(u.EInlineChatStatus.THINKING);const M=await this.inlineChatFeatureRegistry.getInteractiveInputStrategyHandler()(T,A);if(M===h.ERunStrategy.EXECUTE&&P.execute){P.execute(T,A,this.token),w.launchChatStatus(u.EInlineChatStatus.DONE),O();return}if(M===h.ERunStrategy.PREVIEW&&P.providePreviewStrategy){const k=await P.providePreviewStrategy(T,A,this.token);if(l.CancelResponse.is(k)){w.launchChatStatus(u.EInlineChatStatus.READY),O();return}if(d.InlineChatController.is(k)){const B=k;let x;const N=this.registerDispose(new l.RunOnceScheduler(()=>{const j=I.getRange(0);j&&x&&R.pushEditOperations(null,[E.EditOperation.replace(j,x)],()=>null)},16*12.5));D.addDispose([B.onData(async j=>{l.ReplyResponse.is(j)&&(x=j.message,N.isScheduled()||N.schedule())}),B.onError(j=>{w.launchChatStatus(u.EInlineChatStatus.ERROR)}),B.onAbort(()=>{w.launchChatStatus(u.EInlineChatStatus.READY)}),B.onEnd(()=>{R.pushStackElement(),w.launchChatStatus(u.EInlineChatStatus.DONE)})]),B.listen()}}}registerInlineInputFeature(A){const w=new l.Disposable,T=this.injector.get(s.AINativeContextKey,[A.contextKeyService]),D=()=>{w.dispose()};this.featureDisposable.addDispose(this.inlineInputChatService.onInteractiveInputVisibleInPosition(O=>{D(),O?I(O,A):setTimeout(()=>{A.focus()},0)}));const I=async(O,P)=>{var R;this.featureDisposable.addDispose(P.onWillChangeModel(()=>{D()}));const M=P.getModel();if(!M||!P.hasTextFocus())return;const B=P.getSelection();if(B&&B.startLineNumber!==B.endLineNumber)return;const x=this.injector.get(f.InlineInputChatWidget,[P]),N=P.createDecorationsCollection(),j=!(!((R=P.getModel())===null||R===void 0)&&R.getLineContent(O.lineNumber)),K=P.getPosition(),U=P.getModel(),X=U?.getOffsetAt(K),z=U?.getLanguageId(),Q=this.languageParserService.createParser(z),Y=await Q?.findNearestCodeBlockWithPosition(U?.getValue()||"",X);if(Y){const H=new m.Selection(Y.range.start.line+1,Y.range.start.character,Y.range.end.line+1,Y.range.end.character);P.setSelection(H)}else P.setSelection(new m.Selection(O.lineNumber,1,O.lineNumber,1/0));if(!j)return;N.append([{range:m.Range.fromPositions(O),options:v.ModelDecorationOptions.register({description:_.InlineInputPreviewDecorationID,isWholeLine:!0,className:a.default.input_decoration_readable_container,inlineClassName:a.default.inline_chat_inserted_range})}]);const Z=N.getRange(0);let G;Z&&(G=p.LineRange.fromRange(Z),x.show({position:Z.getStartPosition()})),T.inlineInputWidgetIsVisible.set(!0),w.addDispose(x.onDispose(()=>{this.cancelToken(),N.clear(),T.inlineInputWidgetIsVisible.set(!1)})),w.addDispose(x.onResultClick(async H=>{const $=()=>{const J=N.getRange(0);M.pushStackElement(),M.pushEditOperations(null,[E.EditOperation.delete(J)],()=>null),M.pushStackElement()};switch(H){case u.EResultKind.ACCEPT:D();break;case u.EResultKind.DISCARD:$(),D();break;case u.EResultKind.REGENERATE:$(),await this.doRequestReadable(x.interactiveInputValue,x,P,w,N,D);break;default:break}})),w.addDispose(l.Event.debounce(N.onDidChange.bind(N),()=>{},l.FRAME_THREE)(()=>{if(!N.getRange(0))return;const H=N.getRange(0),$=p.LineRange.fromRange(H);G.equals($)||(x.setOptions({position:H.getStartPosition()}),x.layoutContentWidget()),G=$})),w.addDispose(x.onInteractiveInputValue(async H=>{await this.doRequestReadable(H,x,P,w,N,D)})),w.addDispose(x)};return this.featureDisposable.addDispose(w),this.featureDisposable}};t.InlineInputController=y,y.ID="editor.contrib.ai.inline.input",t.InlineInputController=y=n=r.__decorate([(0,o.Injectable)()],y)},74353:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.InlineInputChatService=void 0;const n=e(85608),r=e(76003),o=e(43718);let l=class{constructor(){this._onInteractiveInputVisibleInPosition=new o.Emitter,this.onInteractiveInputVisibleInPosition=this._onInteractiveInputVisibleInPosition.event}get currentVisiblePosition(){return this._currentVisiblePosition}setCurrentVisiblePosition(E){this._currentVisiblePosition=E}visible(){this._onInteractiveInputVisibleInPosition.fire(this._currentVisiblePosition)}hide(){this._onInteractiveInputVisibleInPosition.fire(void 0)}};t.InlineInputChatService=l,t.InlineInputChatService=l=n.__decorate([(0,r.Injectable)()],l)},76755:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.InlineStreamDiffComputer=void 0;const n=e(9514),r=e(52451),o=e(37348),l=e(44781),m=e(68450),E=e(56702),p=e(89216),v=e(10438),s=e(30861),g=e(46739),c=(d,u,_=m.InfiniteTimeout.instance)=>{if(!d.length||!u.length)return m.DiffAlgorithmResult.trivial(d,u);const f=new v.Array2D(2*d.length+1,u.length+1),a=new v.Array2D(2*d.length+1,u.length+1);for(let D=0;D<=u.length;D++)f.set(0,D,D),a.set(0,D,D>0);for(let D=0;D<=2*d.length;D++)f.set(D,0,Math.floor((D+1)/2)),a.set(D,0,!1);for(let D=1;D<=u.length;D++)for(let I=1;I<=2*d.length;I++){if(!_.isValid())return m.DiffAlgorithmResult.trivialTimedOut(d,u);if(I%2===0){const O=f.get(I,D-1)+1,P=f.get(I-1,D),R=O<P;f.set(I,D,R?O:P),a.set(I,D,R)}else{const O=f.get(I-1,D)+.4,P=d.getElement(Math.floor(I/2))===u.getElement(D-1)?f.get(I-1,D-1):Number.MAX_VALUE,R=P<O;f.set(I,D,R?P:O),a.set(I,D,R)}}let b=Number.MAX_VALUE,y=-1;for(let D=0;D<=2*d.length;D++){const I=f.get(D,u.length);I<b&&(b=I,y=D)}const S=[];let A=y,w=u.length;A<=2*d.length-2&&S.push(new m.SequenceDiff(new o.OffsetRange(Math.floor((A+1)/2),d.length),new o.OffsetRange(w,w)));let T;for(;A>=0&&w>=0;)a.get(A,w)?(A%2===0?T===void 0&&(T={originalLineIndex:Math.floor(A/2),modifiedLineIndex:w}):(T!==void 0&&((T.originalLineIndex!==Math.floor(A/2)+1||T.modifiedLineIndex!==w)&&S.push(new m.SequenceDiff(new o.OffsetRange(Math.floor(A/2)+1,T.originalLineIndex),new o.OffsetRange(w,T.modifiedLineIndex))),T=void 0),A-=1),w-=1):(T=T||{originalLineIndex:Math.floor((A+1)/2),modifiedLineIndex:w},A-=1);return T!==void 0&&((T.originalLineIndex!==Math.floor(A/2)+1||T.modifiedLineIndex!==w)&&S.push(new m.SequenceDiff(new o.OffsetRange(Math.floor(A/2)+1,T.originalLineIndex),new o.OffsetRange(w,T.modifiedLineIndex))),T=void 0),S.reverse(),new m.DiffAlgorithmResult(S,!1)};class h extends E.DefaultLinesDiffComputer{computeDiff(u,_,f){if(u.length<=1&&(0,n.equals)(u,_,(M,k)=>M===k))return new s.LinesDiff([],[],!1);if(u.length===1&&u[0].length===0||_.length===1&&_[0].length===0)return new s.LinesDiff([new g.DetailedLineRangeMapping(new r.LineRange(1,u.length+1),new r.LineRange(1,_.length+1),[new g.RangeMapping(new l.Range(1,1,u.length,u[u.length-1].length+1),new l.Range(1,1,_.length,_[_.length-1].length+1))])],[],!1);const a=f.maxComputationTimeMs===0?m.InfiniteTimeout.instance:new m.DateTimeout(f.maxComputationTimeMs),b=new Map;function y(M){let k=b.get(M);return k===void 0&&(k=b.size,b.set(M,k)),k}const S=u.length*_.length<1e6&&f.onlyCareAboutPrefixOfOriginalLines,A=u.map(M=>y(S?M:M.trim())),w=_.map(M=>y(S?M:M.trim())),T=new p.LineSequence(A,u),D=new p.LineSequence(w,_),I=u.every(M=>M.trim().length===0);let O;S?I?O=m.DiffAlgorithmResult.trivial(T,D):O=c(T,D,a):T.length+D.length<1700?O=this.dynamicProgrammingDiffing.compute(T,D,a,(M,k)=>u[M]===_[k]?_[k].length===0?.1:1+Math.log(1+_[k].length):.99):O=this.myersDiffingAlgorithm.compute(T,D,a);const P=O.diffs,R=O.hitTimeout;if(S){const M=P.map(k=>new g.DetailedLineRangeMapping(new r.LineRange(k.seq1Range.start+1,k.seq1Range.endExclusive+1),new r.LineRange(k.seq2Range.start+1,k.seq2Range.endExclusive+1),[]));return new s.LinesDiff(M,[],R)}return super.computeDiff(u,_,f)}}t.InlineStreamDiffComputer=h},33062:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.InlineStreamDiffHandler=t.EComputerMode=void 0;const n=e(85608),r=e(76003),o=e(41869),l=e(20868),m=e(60304),E=e(52451),p=e(84968),v=e(46739),s=e(87822),g=e(25539),c=e(76755),h=e(80715);var d;(function(f){f.legacy="legacy",f.default="default"})(d||(t.EComputerMode=d={}));const u=new c.InlineStreamDiffComputer;let _=class extends o.Disposable{constructor(a){super(),this.monacoEditor=a,this._onDidEditChange=this.registerDispose(new o.Emitter),this.onDidEditChange=this._onDidEditChange.event,this.rawOriginalTextLinesTokens=[],this.currentEditLine=0,this.finallyDiffModel=null,this.isEditing=!1,this.undoRedoGroup=new g.UndoRedoGroup;const b=m.StandaloneServices.get(s.IModelService);this.virtualModel=b.createModel("",null,o.Uri.from({scheme:o.Schemes.inMemory,path:"inline-stream-diff/"+(0,o.randomString)(8)}),!0),this.originalModel=this.monacoEditor.getModel(),this.livePreviewDiffDecorationModel=this.injector.get(h.LivePreviewDiffDecorationModel,[this.monacoEditor]),this.addDispose(this.livePreviewDiffDecorationModel),this.addDispose(this.virtualModel);const y=this.livePreviewDiffDecorationModel.onDispose(()=>{this.dispose(),y.dispose()})}setPreviewerOptions(a){this.previewerOptions=a,this.livePreviewDiffDecorationModel.setPreviewerOptions({partialEditWidgetOptions:{hideAcceptPartialEditWidget:a.hideAcceptPartialEditWidget},renderRemovedWidgetImmediately:a.renderRemovedWidgetImmediately})}initialize(a){const b=this.originalModel.getEOL(),y=a.getStartPosition(),S=a.getEndPosition();this.rawOriginalTextLines=this.originalModel.getValueInRange(l.Range.fromPositions(y,S)).split(b),this.rawOriginalTextLinesTokens=this.rawOriginalTextLines.map((w,T)=>{const D=y.lineNumber+T;return this.originalModel.tokenization.forceTokenization(D),this.originalModel.tokenization.getLineTokens(D)});const A=E.LineRange.fromRangeInclusive(l.Range.fromPositions({lineNumber:a.startLineNumber,column:1},{lineNumber:a.endLineNumber,column:Number.MAX_SAFE_INTEGER}));this.livePreviewDiffDecorationModel.initialize(A)}restoreSnapshot(a){this._snapshotStore=a;const{rawOriginalTextLines:b,rawOriginalTextLinesTokens:y,undoRedoGroup:S,decorationSnapshotData:A,previewerOptions:w}=a;this.setPreviewerOptions(w),this.rawOriginalTextLines=b,this.rawOriginalTextLinesTokens=y,this.undoRedoGroup=S,this.livePreviewDiffDecorationModel.initialize(A.zone)}get currentSnapshotStore(){return this._snapshotStore}restoreDecorationSnapshot(a){this.livePreviewDiffDecorationModel.restoreSnapshot(a)}createSnapshot(){return{rawOriginalTextLines:this.rawOriginalTextLines,rawOriginalTextLinesTokens:this.rawOriginalTextLinesTokens,undoRedoGroup:this.undoRedoGroup,decorationSnapshotData:this.livePreviewDiffDecorationModel.createSnapshot(),previewerOptions:this.previewerOptions}}getVirtualModelValue(){return this.virtualModel.getValue()}getOriginModelValue(){return this.rawOriginalTextLines.join(`
|
|
28269
|
+
`?v.DefaultEndOfLine.CRLF:v.DefaultEndOfLine.LF,{textBuffer:O,disposable:P}=(0,s.createTextBuffer)(T,I),R=g.ModelService._computeEdits(D,O);D.pushEditOperations([],R,()=>[]),P.dispose(),(A=this.node)===null||A===void 0||A.layout()}onError(y){var S;(S=this.node)===null||S===void 0||S.layout()}onAbort(){var y;(y=this.node)===null||y===void 0||y.layout()}onEnd(){var y;(y=this.node)===null||y===void 0||y.layout()}};t.SideBySideInlineDiffWidget=f,f.AI_DIFF_WIDGET_ID="AI-DIFF-WIDGET",t.SideBySideInlineDiffWidget=f=n=r.__decorate([(0,o.Injectable)({multiple:!0})],f);let a=class extends _{listenNode(y){y.addDispose(y.onDidEditChange(()=>this.layout())),y.addDispose(y.onPartialEditWidgetListChange(A=>{var w;A.every(T=>T.isHidden)&&(this.dispose(),(w=this.inlineContentWidget)===null||w===void 0||w.dispose())}));const S=y.onDispose(()=>{this.dispose(),S.dispose()});this.addDispose(y)}createNode(){const y=this.injector.get(d.InlineStreamDiffHandler,[this.monacoEditor]);return y.initialize(this.selection),this.listenNode(y),y}attachNode(y){var S;if((S=this.node)===null||S===void 0||S.dispose(),this.node=y,y){const A=y.currentSnapshotStore;A&&(this.node.restoreDecorationSnapshot(A.decorationSnapshotData),this.listenNode(y))}}createNodeSnapshot(){if(!this.node)return this.createNode();const y=this.node.createSnapshot(),S=this.injector.get(d.InlineStreamDiffHandler,[this.monacoEditor]);return S.restoreSnapshot(y),S}getPosition(){var y;const S=(y=this.node)===null||y===void 0?void 0:y.getZone();return S?m.Position.lift({lineNumber:S.startLineNumber,column:1}):m.Position.lift({lineNumber:1,column:1})}handleAction(y){var S,A;switch(y){case h.EResultKind.ACCEPT:(S=this.node)===null||S===void 0||S.acceptAll();break;case h.EResultKind.DISCARD:case h.EResultKind.REGENERATE:(A=this.node)===null||A===void 0||A.rejectAll();break;default:break}}onLineCount(){return l.Disposable.NULL}layout(){var y,S,A;(y=this.inlineContentWidget)===null||y===void 0||y.setPositionPreference([E.ContentWidgetPositionPreference.ABOVE,E.ContentWidgetPositionPreference.BELOW]),super.layout();const w=this.getPosition();if(w&&this.inlineContentWidget){const T=(S=this.node)===null||S===void 0?void 0:S.livePreviewDiffDecorationModel.getRemovedWidgets();if(T?.length){const D=w.lineNumber,I=T[0];if(I&&((A=I.getLastPosition())===null||A===void 0?void 0:A.lineNumber)<=D){const P=this.inlineContentWidget.getLineHeight(),R=I.height;this.inlineContentWidget.setOffsetTop(-P*R-4)}}}}onData(y){var S;const{message:A}=y;(S=this.node)===null||S===void 0||S.addLinesToDiff(this.formatIndentation(A))}onEnd(){var y,S;const A=(y=this.node)===null||y===void 0?void 0:y.recompute(d.EComputerMode.legacy);A&&((S=this.node)===null||S===void 0||S.pushRateFinallyDiffStack(A))}getValue(){var y;return((y=this.node)===null||y===void 0?void 0:y.getVirtualModelValue())||""}getOriginValue(){var y;return((y=this.node)===null||y===void 0?void 0:y.getOriginModelValue())||""}setValue(y){var S,A;const w=(S=this.node)===null||S===void 0?void 0:S.recompute(d.EComputerMode.legacy,this.formatIndentation(y));w&&((A=this.node)===null||A===void 0||A.finallyRender(w))}revealFirstDiff(){var y;(y=this.node)===null||y===void 0||y.revealFirstDiff()}};t.LiveInlineDiffPreviewer=a,t.LiveInlineDiffPreviewer=a=r.__decorate([(0,o.Injectable)({multiple:!0})],a)},37679:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.InlineDiffWidget=void 0;const n=e(85608),r=n.__importStar(e(14041)),o=e(43144),l=n.__importDefault(e(25873)),m=e(76003),E=e(41869),p=n.__importStar(e(20868)),v=e(87822),s=e(34819),g=e(90626),c=n.__importDefault(e(69790)),h={fixedOverflowWidgets:!0,readOnly:!1,enableSplitViewResizing:!0,ignoreTrimWhitespace:!0,renderSideBySide:!0,lineNumbers:"on",glyphMargin:!0,scrollbar:{useShadows:!1,alwaysConsumeMouseWheel:!1,vertical:"hidden"},scrollBeyondLastLine:!1,renderMarginRevertIcon:!1,renderOverviewRuler:!1,rulers:void 0,overviewRulerBorder:void 0,overviewRulerLanes:0,padding:{top:0,bottom:0},folding:!1,diffCodeLens:!1,stickyScroll:{enabled:!1},minimap:{enabled:!1},automaticLayout:!0,renderIndicators:!1,inDiffEditor:!0},d=r.default.memo(_=>{const{range:f,onMaxLineCount:a,editor:b,onReady:y}=_,S=(0,E.useInjectable)(E.MonacoService),A=(0,r.useRef)(null);return(0,r.useEffect)(()=>{if(!f)return;const w=b.getModel();if(!w)return;const T=w.getValueInRange(f),D=S.createDiffEditor(A.current,{...h,lineDecorationsWidth:b.getLayoutInfo().decorationsWidth,lineNumbersMinChars:b.getOption(p.editor.EditorOption.lineNumbersMinChars)}),I=g.StandaloneServices.get(v.IModelService),O={languageId:w.getLanguageId(),onDidChange:E.Event.None},P=I.createModel(T,O,p.Uri.from({scheme:E.Schemes.inMemory,path:"inline-diff-widget/"+(0,E.randomString)(8)}),!0),R=I.createModel("",O,p.Uri.from({scheme:E.Schemes.inMemory,path:"inline-diff-widget/"+(0,E.randomString)(8)}),!0);D.setModel({original:P,modified:R}),D.revealLine(f.startLineNumber,p.editor.ScrollType.Immediate);const M=()=>{if(a){const k=P.getLineCount(),B=R.getLineCount();a(Math.max(k,B)+1)}};return y&&y({getModifiedModel:()=>R,getOriginModel:()=>P,layout:M}),M(),()=>{D&&D.dispose()}},[f,b]),r.default.createElement("div",{ref:A,className:c.default.diff_editor_widget})});let u=class extends s.ZoneWidget{setPreviewerOptions(f){this.previewerOptions=f}_fillContainer(f){this.setCssClass("inline-diff-widget"),this.root=l.default.createRoot(f);let a=null;if(this._resolveResultWidget)if(f.parentNode){const b=document.createElement("div");requestAnimationFrame(()=>{b.className=c.default.ai_diff_editor_resolve_result_widget;const y=this.editor.getLayoutInfo();b.style.width=`${y.contentWidth}px`,b.style.left=`${y.contentLeft}px`}),f.parentNode.appendChild(b),a=(0,o.createPortal)(this._resolveResultWidget,b),this.resultContainer=b}else throw new Error("[impossible path] container.parentNode is null");this.root.render(r.default.createElement(E.ConfigProvider,{value:this.configContext},r.default.createElement("div",{className:c.default.ai_diff_editor_container},r.default.createElement(d,{range:this.range,editor:this.editor,onMaxLineCount:b=>{b&&(this._relayout(b),this._onMaxLineCount.fire(b))},onReady:b=>{this.diffWidgetHandler=b,this._onReady.fire()}})),a))}computeResultWidgetWidth(){const f=this.editor.getLayoutInfo();return f.contentWidth+f.contentLeft}_onWidth(f){super._onWidth(f),requestAnimationFrame(()=>{this.resultContainer&&(this.resultContainer.style.width=`${this.computeResultWidgetWidth()}px`)})}getModifiedModel(){var f;return(f=this.diffWidgetHandler)===null||f===void 0?void 0:f.getModifiedModel()}getOriginModel(){var f;return(f=this.diffWidgetHandler)===null||f===void 0?void 0:f.getOriginModel()}layout(){var f;return(f=this.diffWidgetHandler)===null||f===void 0?void 0:f.layout()}constructor(f,a){super(a.editor,{showArrow:!1,showFrame:!1,arrowColor:void 0,frameColor:void 0,keepEditorSelection:!0,showInHiddenAreas:!0}),this.id=f,this._onMaxLineCount=new E.Emitter,this.onMaxLineCount=this._onMaxLineCount.event,this._onReady=new E.Emitter,this.onReady=this._onReady.event,this.diffWidgetHandler=null,this.resultContainer=null,this._resolveResultWidget=null;const{selection:b,hiddenArea:y,editor:S}=a;this.range=b,this.hiddenArea=y||b,S.setHiddenAreas([this.hiddenArea],this.id)}revealRange(f,a){}setContainerStyle(f){var a;const b=Object.keys(f);for(const y of b)Object.prototype.hasOwnProperty.call((a=this.container)===null||a===void 0?void 0:a.style,y)&&(this.container.style[y]=f[y])}addClassName(f){return this.setCssClass(f),this}dispose(){this.hide(),super.dispose()}hide(){this.editor.setHiddenAreas([],this.id),super.hide(),this.root&&this.root.unmount()}showByLine(f,a=20){this.editor._modelData.viewModel.coordinatesConverter.modelPositionIsVisible=()=>!0,super.show({startLineNumber:f,startColumn:1,endLineNumber:f,endColumn:Number.MAX_SAFE_INTEGER},a)}setResolveResultWidget(f){this._resolveResultWidget=f}};t.InlineDiffWidget=u,n.__decorate([(0,m.Autowired)(E.AppConfig),n.__metadata("design:type",Object)],u.prototype,"configContext",void 0),t.InlineDiffWidget=u=n.__decorate([(0,m.Injectable)({multiple:!0}),n.__metadata("design:paramtypes",[String,Object])],u)},38890:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.InlineDiffController=void 0;const n=e(41869),r=e(43718),o=e(57517),l=e(99906),m=e(83854),E=e(40111),p=e(49444);class v extends l.BaseAIMonacoEditorController{constructor(){super(...arguments),this._onMaxLineCount=new r.Emitter,this.onMaxLineCount=this._onMaxLineCount.event,this._previewerNodeStore=new Map}static get(g){return g.getContribution(v.ID)}get preferenceService(){return this.injector.get(n.PreferenceService)}get eventBus(){return this.injector.get(r.IEventBus)}mount(){return this.featureDisposable.addDispose(this.eventBus.on(o.EditorGroupCloseEvent,g=>{const c=g.payload.resource.uri.toString(),h=this.getStoredState(c);h&&h.previewerOptions.disposeWhenEditorClosed&&this.destroyPreviewer(c)})),this.registerInlineDiffFeature(this.monacoEditor),this.featureDisposable}storeState(g){if(!this.previewer)return;const c=this.previewer.createNodeSnapshot();c&&this._previewerNodeStore.set(g,c)}tryRestoreState(g,c){const h=this.getStoredState(c);if(h){if(h.disposed){this.destroyPreviewer(c);return}return this.restoreState(g,h)}}restoreState(g,c){var h;if((h=g.getModel())===null||h===void 0?void 0:h.uri){this.previewer=this.injector.get(p.LiveInlineDiffPreviewer,[g]),this.previewer.attachNode(c),this.listenPreviewer(this.previewer);const u=this.previewer.onDispose(()=>{this.destroyPreviewer(),u.dispose()})}}registerInlineDiffFeature(g){const c=g.getModel();this.featureDisposable.addDispose(g.onWillChangeModel(h=>{if(!h.oldModelUrl)return;const d=h.oldModelUrl.toString();this.storeState(d),this.destroyPreviewer()})),this.featureDisposable.addDispose(g.onDidChangeModel(h=>{h.newModelUrl&&this.tryRestoreState(g,h.newModelUrl.toString())})),c&&this.featureDisposable.addDispose(c.onWillDispose(()=>{const h=c.uri.toString();this.destroyPreviewer(h)}))}showPreviewerByStream(g,c){const{crossSelection:h,chatResponse:d}=c,u=new r.Disposable,_=this.createDiffPreviewer(g,h,c.previewerOptions),f=()=>{_.layout(),u.dispose()};return u.addDispose(_.onReady(()=>{if(E.InlineChatController.is(d)){const a=d;u.addDispose([a.onData(b=>{r.ReplyResponse.is(b)&&_.onData(b)}),a.onError(b=>{_.onError(b),f()}),a.onAbort(()=>{_.onAbort(),f()}),a.onEnd(()=>{_.onEnd(),f()})]),a.listen()}else _.setValue(d.message),f()})),_.layout(),_}createDiffPreviewer(g,c,h){const d=this.preferenceService.getValid(r.AINativeSettingSectionsId.InlineDiffPreviewMode,m.EInlineDiffPreviewMode.inlineLive);return this.destroyPreviewer(),d===m.EInlineDiffPreviewMode.sideBySide?this.previewer=this.injector.get(p.SideBySideInlineDiffWidget,[g]):this.previewer=this.injector.get(p.LiveInlineDiffPreviewer,[g]),this.previewer.create(c,h),this.previewer.show(c.startLineNumber-1,c.endLineNumber-c.startLineNumber+2),this.listenPreviewer(this.previewer),this.previewer}listenPreviewer(g){g&&g.addDispose(g.onLineCount(c=>this._onMaxLineCount.fire(c)))}getPreviewer(){return this.previewer}getStoredState(g){return this._previewerNodeStore.get(g)}handleAction(g){var c;(c=this.previewer)===null||c===void 0||c.handleAction(g)}getModifyContent(){var g;return(g=this.previewer)===null||g===void 0?void 0:g.getValue()}getOriginContent(){var g;return(g=this.previewer)===null||g===void 0?void 0:g.getOriginValue()}destroyPreviewer(g){var c;(c=this.previewer)===null||c===void 0||c.dispose(),this.previewer=void 0,g&&this._previewerNodeStore.delete(g)}revealFirstDiff(){var g;(g=this.previewer)===null||g===void 0||g.revealFirstDiff()}}t.InlineDiffController=v,v.ID="editor.contrib.ai.inline.diff"},51347:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.InlineDiffService=void 0;const n=e(85608),r=e(76003),o=e(70392);let l=class{constructor(){this._partialEventEmitter=new o.Emitter,this.onPartialEdit=this._partialEventEmitter.event}firePartialEdit(E){this._partialEventEmitter.fire(E)}};t.InlineDiffService=l,t.InlineDiffService=l=n.__decorate([(0,r.Injectable)()],l)},53182:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.InlineHintLineDecoration=void 0;const n=e(85608),r=e(76003),o=e(41869),l=e(57925),m=e(43718),E=e(20868),p=e(60304),v=e(52416),s=e(75189),g="inline_hint_description",c="inline_hint_description_key";let h=class extends m.Disposable{constructor(u){super(),this.monacoEditor=u,this.colorRegister=(0,v.getColorRegistry)(),p.StandaloneServices.get(s.ICodeEditorService).registerDecorationType(g,c,{isWholeLine:!0}),this.addDispose(m.Disposable.create(()=>{this.monacoEditor.setDecorationsByType(g,c,[])}))}getSequenceKeyString(u="+"){var _;const a=(_=this.keybindingRegistry.getKeybindingsForCommand(l.AI_INLINE_CHAT_INTERACTIVE_INPUT_VISIBLE.id)[0])===null||_===void 0?void 0:_.resolved;return a?this.keybindingRegistry.acceleratorForSequence(a,u):""}async show(u){var _;const f=(0,m.formatLocalize)("aiNative.inline.hint.widget.placeholder",this.getSequenceKeyString("")),a=await this.themeService.getCurrentTheme(),b=this.colorRegister.resolveDefaultColor(v.inputPlaceholderForeground,a);this.monacoEditor.setDecorationsByType(g,c,[{range:E.Range.fromPositions(u),renderOptions:{after:{contentText:f,opacity:"0.5",color:(_=b?.toString())!==null&&_!==void 0?_:"",padding:"0 0 0 12px",width:"max-content",fontFamily:"-apple-system,BlinkMacSystemFont,PingFang SC,Hiragino Sans GB,sans-serif"}}}])}};t.InlineHintLineDecoration=h,n.__decorate([(0,r.Autowired)(o.KeybindingRegistry),n.__metadata("design:type",Object)],h.prototype,"keybindingRegistry",void 0),n.__decorate([(0,r.Autowired)(v.IThemeService),n.__metadata("design:type",Object)],h.prototype,"themeService",void 0),t.InlineHintLineDecoration=h=n.__decorate([(0,r.Injectable)({multiple:!0}),n.__metadata("design:paramtypes",[Object])],h)},77886:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.InlineHintController=void 0;const n=e(85608),r=n.__importDefault(e(97331)),o=e(43718),l=n.__importStar(e(20868)),m=e(77659),E=e(99906),p=e(71863),v=e(74353),s=e(19520),g=e(53182);class c extends E.BaseAIMonacoEditorController{static get(d){return d.getContribution(c.ID)}get inlineCompletionsService(){return this.injector.get(p.AICompletionsService)}get inlineInputChatService(){return this.injector.get(v.InlineInputChatService)}mount(){return this.registerHintLineFeature(this.monacoEditor)}registerHintLineFeature(d){const u=new o.Disposable,_=this.injector.get(m.AINativeContextKey,[d.contextKeyService]),f=()=>{u.dispose()},a=y=>{var S;const A=d.getModel();if(!A||this.inlineCompletionsService.isVisibleCompletion)return;if(!A.getLineDecorations(y.lineNumber).some(D=>D.options.description===s.InlineInputPreviewDecorationID)){const D=this.injector.get(g.InlineHintLineDecoration,[d]),I=(S=d.getModel())===null||S===void 0?void 0:S.getLineContent(y.lineNumber);I?.trim()||D.show(y),this.inlineInputChatService.setCurrentVisiblePosition(y),_.inlineHintWidgetIsVisible.set(!0),u.addDispose(D.onDispose(()=>{_.inlineHintWidgetIsVisible.set(!1)})),u.addDispose(D)}},b=(0,r.default)(async y=>{f(),a(y)},100);return this.featureDisposable.addDispose(d.onDidChangeCursorPosition(y=>{b(y.position)})),this.featureDisposable.addDispose(d.onDidChangeModelContent(y=>{var S,A;b(new l.Position((S=y.changes[0])===null||S===void 0?void 0:S.range.endLineNumber,(A=y.changes[0])===null||A===void 0?void 0:A.range.endColumn))})),this.featureDisposable.addDispose(d.onDidFocusEditorWidget(()=>{const y=d.getPosition();y&&(f(),a(y))})),this.featureDisposable.addDispose(d.onDidBlurEditorWidget(()=>{f()})),this.featureDisposable.addDispose(this.inlineCompletionsService.onVisibleCompletion(y=>{y&&f()})),this.featureDisposable.addDispose(u),this.featureDisposable}}t.InlineHintController=c,c.ID="editor.contrib.ai.inline.hint"},32213:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.InlineInputChatWidget=void 0;const n=e(85608),r=n.__importStar(e(14041)),o=e(76003),l=e(89195),m=e(43718),E=e(90052),p=e(90614),v=e(31031),s=e(26664),g=n.__importDefault(e(13185)),c=e(74353),h=u=>{const{onClose:_,onInteractiveInputSend:f,onLayoutChange:a,onChatStatus:b,onResultClick:y}=u,[S,A]=(0,r.useState)(v.EInlineChatStatus.READY);(0,r.useEffect)(()=>{const P=new m.Disposable;return P.addDispose(b(R=>A(R))),()=>{P.dispose()}},[b]);const w=(0,r.useMemo)(()=>S===v.EInlineChatStatus.THINKING,[S]),T=(0,r.useMemo)(()=>S===v.EInlineChatStatus.DONE,[S]),D=(0,r.useMemo)(()=>S===v.EInlineChatStatus.ERROR,[S]),I=(0,r.useCallback)(()=>{_?.()},[_]),O=(0,r.useCallback)(P=>{f?.(P)},[f]);return D?null:T?r.default.createElement(p.InlineResultAction,{onResultClick:y}):r.default.createElement(l.AIAction,{loadingShowOperation:!0,onClose:I,loading:w,customOperationRender:r.default.createElement(l.InteractiveInput,{autoFocus:!0,onHeightChange:P=>a(P),size:"small",placeholder:(0,m.localize)("aiNative.inline.chat.input.placeholder.default"),width:320,disabled:w,onSend:O})})};let d=class extends s.AIInlineContentWidget{constructor(){super(...arguments),this.allowEditorOverflow=!0,this.positionPreference=[E.ContentWidgetPositionPreference.ABOVE]}dispose(){super.dispose(),this.inlineInputChatService.hide()}id(){return m.AIInlineInputChatContentWidgetId}renderView(){return r.default.createElement("div",{className:g.default.input_wrapper},r.default.createElement(h,{onClose:()=>this.dispose(),onChatStatus:this.onStatusChange.bind(this),onLayoutChange:()=>{this.editor.layoutContentWidget(this)},onInteractiveInputSend:_=>{this.launchChatStatus(v.EInlineChatStatus.THINKING),this._onInteractiveInputValue.fire(_)},onResultClick:_=>{this._onResultClick.fire(_)}}))}};t.InlineInputChatWidget=d,n.__decorate([(0,o.Autowired)(c.InlineInputChatService),n.__metadata("design:type",c.InlineInputChatService)],d.prototype,"inlineInputChatService",void 0),t.InlineInputChatWidget=d=n.__decorate([(0,o.Injectable)({multiple:!0})],d)},89060:(L,t,e)=>{"use strict";var n;Object.defineProperty(t,"__esModule",{value:!0}),t.InlineInputController=void 0;const r=e(85608),o=e(76003),l=e(43718),m=r.__importStar(e(20868)),E=e(2261),p=e(52451),v=e(74547),s=e(77659),g=e(99906),c=e(85679),h=e(77633),d=e(40111),u=e(31031),_=e(19520),f=e(32213),a=r.__importDefault(e(13185)),b=e(74353);let y=n=class extends g.BaseAIMonacoEditorController{static get(A){return A.getContribution(n.ID)}get inlineInputChatService(){return this.injector.get(b.InlineInputChatService)}get inlineChatFeatureRegistry(){return this.injector.get(l.InlineChatFeatureRegistryToken)}get languageParserService(){return this.injector.get(c.LanguageParserService)}mount(){return this.registerInlineInputFeature(this.monacoEditor)}async doRequestReadable(A,w,T,D,I,O){const P=this.inlineChatFeatureRegistry.getInteractiveInputHandler(),R=T.getModel();if(!P||!R)return;w.launchChatStatus(u.EInlineChatStatus.THINKING);const M=await this.inlineChatFeatureRegistry.getInteractiveInputStrategyHandler()(T,A);if(M===h.ERunStrategy.EXECUTE&&P.execute){P.execute(T,A,this.token),w.launchChatStatus(u.EInlineChatStatus.DONE),O();return}if(M===h.ERunStrategy.PREVIEW&&P.providePreviewStrategy){const k=await P.providePreviewStrategy(T,A,this.token);if(l.CancelResponse.is(k)){w.launchChatStatus(u.EInlineChatStatus.READY),O();return}if(d.InlineChatController.is(k)){const B=k;let x;const N=this.registerDispose(new l.RunOnceScheduler(()=>{const j=I.getRange(0);j&&x&&R.pushEditOperations(null,[E.EditOperation.replace(j,x)],()=>null)},16*12.5));D.addDispose([B.onData(async j=>{l.ReplyResponse.is(j)&&(x=j.message,N.isScheduled()||N.schedule())}),B.onError(j=>{w.launchChatStatus(u.EInlineChatStatus.ERROR)}),B.onAbort(()=>{w.launchChatStatus(u.EInlineChatStatus.READY)}),B.onEnd(()=>{R.pushStackElement(),w.launchChatStatus(u.EInlineChatStatus.DONE)})]),B.listen()}}}registerInlineInputFeature(A){const w=new l.Disposable,T=this.injector.get(s.AINativeContextKey,[A.contextKeyService]),D=()=>{w.dispose()};this.featureDisposable.addDispose(this.inlineInputChatService.onInteractiveInputVisibleInPosition(O=>{D(),O?I(O,A):setTimeout(()=>{A.focus()},0)}));const I=async(O,P)=>{var R;this.featureDisposable.addDispose(P.onWillChangeModel(()=>{D()}));const M=P.getModel();if(!M||!P.hasTextFocus())return;const B=P.getSelection();if(B&&B.startLineNumber!==B.endLineNumber)return;const x=this.injector.get(f.InlineInputChatWidget,[P]),N=P.createDecorationsCollection();if(!!(!((R=P.getModel())===null||R===void 0)&&R.getLineContent(O.lineNumber).trim())){const X=P.getPosition(),z=P.getModel(),Q=z?.getOffsetAt(X),Y=z?.getLanguageId(),Z=this.languageParserService.createParser(Y),G=await Z?.findNearestCodeBlockWithPosition(z?.getValue()||"",Q);if(G){const H=new m.Selection(G.range.start.line+1,G.range.start.character,G.range.end.line+1,G.range.end.character);P.setSelection(H)}else P.setSelection(new m.Selection(O.lineNumber,1,O.lineNumber,1/0));return}N.append([{range:m.Range.fromPositions(O),options:v.ModelDecorationOptions.register({description:_.InlineInputPreviewDecorationID,isWholeLine:!0,className:a.default.input_decoration_readable_container,inlineClassName:a.default.inline_chat_inserted_range})}]);const K=N.getRange(0);let U;K&&(U=p.LineRange.fromRange(K),x.show({position:K.getStartPosition()})),T.inlineInputWidgetIsVisible.set(!0),w.addDispose(x.onDispose(()=>{this.cancelToken(),N.clear(),T.inlineInputWidgetIsVisible.set(!1)})),w.addDispose(x.onResultClick(async X=>{const z=()=>{const Q=N.getRange(0);M.pushStackElement(),M.pushEditOperations(null,[E.EditOperation.delete(Q)],()=>null),M.pushStackElement()};switch(X){case u.EResultKind.ACCEPT:D();break;case u.EResultKind.DISCARD:z(),D();break;case u.EResultKind.REGENERATE:z(),await this.doRequestReadable(x.interactiveInputValue,x,P,w,N,D);break;default:break}})),w.addDispose(l.Event.debounce(N.onDidChange.bind(N),()=>{},l.FRAME_THREE)(()=>{if(!N.getRange(0))return;const X=N.getRange(0),z=p.LineRange.fromRange(X);U.equals(z)||(x.setOptions({position:X.getStartPosition()}),x.layoutContentWidget()),U=z})),w.addDispose(x.onInteractiveInputValue(async X=>{await this.doRequestReadable(X,x,P,w,N,D)})),w.addDispose(x)};return this.featureDisposable.addDispose(w),this.featureDisposable}};t.InlineInputController=y,y.ID="editor.contrib.ai.inline.input",t.InlineInputController=y=n=r.__decorate([(0,o.Injectable)()],y)},74353:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.InlineInputChatService=void 0;const n=e(85608),r=e(76003),o=e(43718);let l=class{constructor(){this._onInteractiveInputVisibleInPosition=new o.Emitter,this.onInteractiveInputVisibleInPosition=this._onInteractiveInputVisibleInPosition.event}get currentVisiblePosition(){return this._currentVisiblePosition}setCurrentVisiblePosition(E){this._currentVisiblePosition=E}visible(){this._onInteractiveInputVisibleInPosition.fire(this._currentVisiblePosition)}hide(){this._onInteractiveInputVisibleInPosition.fire(void 0)}};t.InlineInputChatService=l,t.InlineInputChatService=l=n.__decorate([(0,r.Injectable)()],l)},76755:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.InlineStreamDiffComputer=void 0;const n=e(9514),r=e(52451),o=e(37348),l=e(44781),m=e(68450),E=e(56702),p=e(89216),v=e(10438),s=e(30861),g=e(46739),c=(d,u,_=m.InfiniteTimeout.instance)=>{if(!d.length||!u.length)return m.DiffAlgorithmResult.trivial(d,u);const f=new v.Array2D(2*d.length+1,u.length+1),a=new v.Array2D(2*d.length+1,u.length+1);for(let D=0;D<=u.length;D++)f.set(0,D,D),a.set(0,D,D>0);for(let D=0;D<=2*d.length;D++)f.set(D,0,Math.floor((D+1)/2)),a.set(D,0,!1);for(let D=1;D<=u.length;D++)for(let I=1;I<=2*d.length;I++){if(!_.isValid())return m.DiffAlgorithmResult.trivialTimedOut(d,u);if(I%2===0){const O=f.get(I,D-1)+1,P=f.get(I-1,D),R=O<P;f.set(I,D,R?O:P),a.set(I,D,R)}else{const O=f.get(I-1,D)+.4,P=d.getElement(Math.floor(I/2))===u.getElement(D-1)?f.get(I-1,D-1):Number.MAX_VALUE,R=P<O;f.set(I,D,R?P:O),a.set(I,D,R)}}let b=Number.MAX_VALUE,y=-1;for(let D=0;D<=2*d.length;D++){const I=f.get(D,u.length);I<b&&(b=I,y=D)}const S=[];let A=y,w=u.length;A<=2*d.length-2&&S.push(new m.SequenceDiff(new o.OffsetRange(Math.floor((A+1)/2),d.length),new o.OffsetRange(w,w)));let T;for(;A>=0&&w>=0;)a.get(A,w)?(A%2===0?T===void 0&&(T={originalLineIndex:Math.floor(A/2),modifiedLineIndex:w}):(T!==void 0&&((T.originalLineIndex!==Math.floor(A/2)+1||T.modifiedLineIndex!==w)&&S.push(new m.SequenceDiff(new o.OffsetRange(Math.floor(A/2)+1,T.originalLineIndex),new o.OffsetRange(w,T.modifiedLineIndex))),T=void 0),A-=1),w-=1):(T=T||{originalLineIndex:Math.floor((A+1)/2),modifiedLineIndex:w},A-=1);return T!==void 0&&((T.originalLineIndex!==Math.floor(A/2)+1||T.modifiedLineIndex!==w)&&S.push(new m.SequenceDiff(new o.OffsetRange(Math.floor(A/2)+1,T.originalLineIndex),new o.OffsetRange(w,T.modifiedLineIndex))),T=void 0),S.reverse(),new m.DiffAlgorithmResult(S,!1)};class h extends E.DefaultLinesDiffComputer{computeDiff(u,_,f){if(u.length<=1&&(0,n.equals)(u,_,(M,k)=>M===k))return new s.LinesDiff([],[],!1);if(u.length===1&&u[0].length===0||_.length===1&&_[0].length===0)return new s.LinesDiff([new g.DetailedLineRangeMapping(new r.LineRange(1,u.length+1),new r.LineRange(1,_.length+1),[new g.RangeMapping(new l.Range(1,1,u.length,u[u.length-1].length+1),new l.Range(1,1,_.length,_[_.length-1].length+1))])],[],!1);const a=f.maxComputationTimeMs===0?m.InfiniteTimeout.instance:new m.DateTimeout(f.maxComputationTimeMs),b=new Map;function y(M){let k=b.get(M);return k===void 0&&(k=b.size,b.set(M,k)),k}const S=u.length*_.length<1e6&&f.onlyCareAboutPrefixOfOriginalLines,A=u.map(M=>y(S?M:M.trim())),w=_.map(M=>y(S?M:M.trim())),T=new p.LineSequence(A,u),D=new p.LineSequence(w,_),I=u.every(M=>M.trim().length===0);let O;S?I?O=m.DiffAlgorithmResult.trivial(T,D):O=c(T,D,a):T.length+D.length<1700?O=this.dynamicProgrammingDiffing.compute(T,D,a,(M,k)=>u[M]===_[k]?_[k].length===0?.1:1+Math.log(1+_[k].length):.99):O=this.myersDiffingAlgorithm.compute(T,D,a);const P=O.diffs,R=O.hitTimeout;if(S){const M=P.map(k=>new g.DetailedLineRangeMapping(new r.LineRange(k.seq1Range.start+1,k.seq1Range.endExclusive+1),new r.LineRange(k.seq2Range.start+1,k.seq2Range.endExclusive+1),[]));return new s.LinesDiff(M,[],R)}return super.computeDiff(u,_,f)}}t.InlineStreamDiffComputer=h},33062:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.InlineStreamDiffHandler=t.EComputerMode=void 0;const n=e(85608),r=e(76003),o=e(41869),l=e(20868),m=e(60304),E=e(52451),p=e(84968),v=e(46739),s=e(87822),g=e(25539),c=e(76755),h=e(80715);var d;(function(f){f.legacy="legacy",f.default="default"})(d||(t.EComputerMode=d={}));const u=new c.InlineStreamDiffComputer;let _=class extends o.Disposable{constructor(a){super(),this.monacoEditor=a,this._onDidEditChange=this.registerDispose(new o.Emitter),this.onDidEditChange=this._onDidEditChange.event,this.rawOriginalTextLinesTokens=[],this.currentEditLine=0,this.finallyDiffModel=null,this.isEditing=!1,this.undoRedoGroup=new g.UndoRedoGroup;const b=m.StandaloneServices.get(s.IModelService);this.virtualModel=b.createModel("",null,o.Uri.from({scheme:o.Schemes.inMemory,path:"inline-stream-diff/"+(0,o.randomString)(8)}),!0),this.originalModel=this.monacoEditor.getModel(),this.livePreviewDiffDecorationModel=this.injector.get(h.LivePreviewDiffDecorationModel,[this.monacoEditor]),this.addDispose(this.livePreviewDiffDecorationModel),this.addDispose(this.virtualModel);const y=this.livePreviewDiffDecorationModel.onDispose(()=>{this.dispose(),y.dispose()})}setPreviewerOptions(a){this.previewerOptions=a,this.livePreviewDiffDecorationModel.setPreviewerOptions({partialEditWidgetOptions:{hideAcceptPartialEditWidget:a.hideAcceptPartialEditWidget},renderRemovedWidgetImmediately:a.renderRemovedWidgetImmediately})}initialize(a){const b=this.originalModel.getEOL(),y=a.getStartPosition(),S=a.getEndPosition();this.rawOriginalTextLines=this.originalModel.getValueInRange(l.Range.fromPositions(y,S)).split(b),this.rawOriginalTextLinesTokens=this.rawOriginalTextLines.map((w,T)=>{const D=y.lineNumber+T;return this.originalModel.tokenization.forceTokenization(D),this.originalModel.tokenization.getLineTokens(D)});const A=E.LineRange.fromRangeInclusive(l.Range.fromPositions({lineNumber:a.startLineNumber,column:1},{lineNumber:a.endLineNumber,column:Number.MAX_SAFE_INTEGER}));this.livePreviewDiffDecorationModel.initialize(A)}restoreSnapshot(a){this._snapshotStore=a;const{rawOriginalTextLines:b,rawOriginalTextLinesTokens:y,undoRedoGroup:S,decorationSnapshotData:A,previewerOptions:w}=a;this.setPreviewerOptions(w),this.rawOriginalTextLines=b,this.rawOriginalTextLinesTokens=y,this.undoRedoGroup=S,this.livePreviewDiffDecorationModel.initialize(A.zone)}get currentSnapshotStore(){return this._snapshotStore}restoreDecorationSnapshot(a){this.livePreviewDiffDecorationModel.restoreSnapshot(a)}createSnapshot(){return{rawOriginalTextLines:this.rawOriginalTextLines,rawOriginalTextLinesTokens:this.rawOriginalTextLinesTokens,undoRedoGroup:this.undoRedoGroup,decorationSnapshotData:this.livePreviewDiffDecorationModel.createSnapshot(),previewerOptions:this.previewerOptions}}getVirtualModelValue(){return this.virtualModel.getValue()}getOriginModelValue(){return this.rawOriginalTextLines.join(`
|
|
28270
28270
|
`)}get onPartialEditWidgetListChange(){return this.livePreviewDiffDecorationModel.onPartialEditWidgetListChange}computeDiff(a,b,y=d.default){const S=(y===d.default?u:p.linesDiffComputers.getLegacy()).computeDiff(a,b,{computeMoves:!1,maxComputationTimeMs:200,ignoreTrimWhitespace:!1,onlyCareAboutPrefixOfOriginalLines:!0});let A=S.changes;S.hitTimeout&&(A=[new v.DetailedLineRangeMapping(new E.LineRange(1,a.length+1),new E.LineRange(1,b.length+1),void 0)]);const w=[];let T=[];for(const P of A)if(P.modified.endLineNumberExclusive===b.length+1&&y===d.default){if(T=a.slice(P.original.startLineNumber-1,P.original.endLineNumberExclusive-1),P.modified.isEmpty)continue;w.push({removedTextLines:[],removedLinesOriginalRange:new E.LineRange(P.original.startLineNumber,P.original.startLineNumber),addedRange:P.modified,relativeInnerChanges:void 0})}else w.push({removedTextLines:a.slice(P.original.startLineNumber-1,P.original.endLineNumberExclusive-1),removedLinesOriginalRange:P.original,addedRange:P.modified,relativeInnerChanges:P.innerChanges?P.innerChanges.map(R=>({originalRange:R.originalRange.delta(-P.original.startLineNumber+1),modifiedRange:R.modifiedRange.delta(-P.modified.startLineNumber+1)})):void 0});const D=[...b,...T];let I=0,O=new E.LineRange(1,1);return T.length>0&&(I=b.length+1,O=new E.LineRange(b.length+1,b.length+1+T.length)),{changes:w,newFullRangeTextLines:D,activeLine:I,pendingRange:O}}calculateAddedDecorationCollectionState(a){const b=this.getZone();return a.changes.map(S=>{const A=S.addedRange,w={lineNumber:b.startLineNumber+A.startLineNumber-1,column:1},T={lineNumber:b.startLineNumber+A.endLineNumberExclusive-2,column:1};return{startPosition:w,endPosition:T,len:A.endLineNumberExclusive-A.startLineNumber}})}renderPartialEditWidgets(a){const b=this.calculateAddedDecorationCollectionState(a);this.livePreviewDiffDecorationModel.touchPartialEditWidgets(b.map(y=>y.startPosition.lineNumber))}renderAddedRangeDecoration(a){const b=this.calculateAddedDecorationCollectionState(a);this.livePreviewDiffDecorationModel.touchAddedRange(b)}renderRemovedRangeDecoration(a){const{changes:b}=a,y=this.getZone();let S=0;const A=[];for(const w of b){const{removedTextLines:T,removedLinesOriginalRange:D,addedRange:I}=w;T.length>0&&A.push({position:{column:1,lineNumber:y.startLineNumber+D.startLineNumber-2-S},textLines:T.map((O,P)=>({text:O,lineTokens:this.rawOriginalTextLinesTokens[D.startLineNumber-1+P]}))}),S+=D.length-I.length}this.livePreviewDiffDecorationModel.touchRemovedWidget(A)}pushStackElement(){const a=this.livePreviewDiffDecorationModel.createEditStackElement(this.undoRedoGroup);a.attachModel(this.livePreviewDiffDecorationModel),a.registerUndo(b=>{b.dispose()})}handleEdits(a){const{activeLine:b,newFullRangeTextLines:y,pendingRange:S}=a,A=this.originalModel.getEOL(),w=this.getZone(),T=w.startLineNumber<w.endLineNumberExclusive?new l.Range(w.startLineNumber,1,w.endLineNumberExclusive-1,this.originalModel.getLineMaxColumn(w.endLineNumberExclusive-1)):new l.Range(w.startLineNumber,1,w.startLineNumber,1),D=this.originalModel.getValueInRange(T).split(A),I=p.linesDiffComputers.getDefault().computeDiff(D,y,{computeMoves:!1,maxComputationTimeMs:200,ignoreTrimWhitespace:!1}),O=[];if(I.hitTimeout){let P=y.join(A);T.isEmpty()&&(P+=A);const R={range:T,text:P,forceMoveMarkers:!1};O.push(R)}else for(const P of I.changes){let R=y.slice(P.modified.startLineNumber-1,P.modified.endLineNumberExclusive-1).join(A),M;P.original.isEmpty?(M=new l.Range(T.startLineNumber+P.original.startLineNumber-1,1,T.startLineNumber+P.original.startLineNumber-1,1),R+=A):P.modified.isEmpty?(M=new l.Range(T.startLineNumber+P.original.startLineNumber-1,1,T.startLineNumber+P.original.endLineNumberExclusive-1,1),R=null):M=new l.Range(T.startLineNumber+P.original.startLineNumber-1,1,T.startLineNumber+P.original.endLineNumberExclusive-2,this.originalModel.getLineMaxColumn(T.startLineNumber+P.original.endLineNumberExclusive-2));const k={range:M,text:R,forceMoveMarkers:!1};O.push(k)}this.originalModel.pushEditOperations(null,O,()=>null,this.undoRedoGroup),this.livePreviewDiffDecorationModel.updateZone(new E.LineRange(w.startLineNumber,w.startLineNumber+y.length)),b>0?this.livePreviewDiffDecorationModel.touchActiveLine(b):this.livePreviewDiffDecorationModel.clearActiveLine(),this.renderAddedRangeDecoration(a),S.length>0?this.livePreviewDiffDecorationModel.touchPendingRange(S):this.livePreviewDiffDecorationModel.clearPendingLine(),this.renderRemovedRangeDecoration(a),this._onDidEditChange.fire()}recompute(a,b){b&&this.virtualModel.setValue(b);const y=this.virtualModel.getLinesContent();return this.computeDiff(this.rawOriginalTextLines,y,a)}async rateEditController(){if(this.isEditing===!1){for(this.isEditing=!0;this.currentEditLine<=this.virtualModel.getLinesContent().length;){if(this.disposed)return;const b=this.virtualModel.getLinesContent().slice(0,this.currentEditLine),y=this.computeDiff(this.rawOriginalTextLines,b);this.handleEdits(y),this.currentEditLine+=1,await(0,o.sleep)(o.FRAME_THREE)}this.finallyDiffModel&&this.finallyRender(this.finallyDiffModel),this.isEditing=!1}}addLinesToDiff(a,b=d.default){this.recompute(b,a),this.rateEditController()}pushRateFinallyDiffStack(a){this.finallyDiffModel=a,this.isEditing===!1&&this.finallyRender(this.finallyDiffModel)}finallyRender(a){this.renderPartialEditWidgets(a),this.handleEdits(a),this.pushStackElement(),this.monacoEditor.focus()}acceptAll(){this.livePreviewDiffDecorationModel.acceptUnProcessed(),this.dispose()}rejectAll(){this.livePreviewDiffDecorationModel.discardUnProcessed(),this.dispose()}revealFirstDiff(){this.livePreviewDiffDecorationModel.revealFirstDiff()}getZone(){return this.livePreviewDiffDecorationModel.getZone()}getTotalCodeInfo(){return this.livePreviewDiffDecorationModel.getTotalCodeInfo()}};t.InlineStreamDiffHandler=_,n.__decorate([(0,r.Autowired)(r.INJECTOR_TOKEN),n.__metadata("design:type",r.Injector)],_.prototype,"injector",void 0),t.InlineStreamDiffHandler=_=n.__decorate([(0,r.Injectable)({multiple:!0}),n.__metadata("design:paramtypes",[Object])],_)},22169:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.InlineStreamDiffService=void 0;const n=e(85608),r=e(76003),o=e(43718);let l=class{constructor(){this._onAcceptDiscardPartialEdit=new o.Emitter,this.onAcceptDiscardPartialEdit=this._onAcceptDiscardPartialEdit.event}launchAcceptDiscardPartialEdit(E){this._onAcceptDiscardPartialEdit.fire(E)}};t.InlineStreamDiffService=l,t.InlineStreamDiffService=l=n.__decorate([(0,r.Injectable)()],l)},54362:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.LivePreviewUndoRedoStackElement=void 0;const n=e(25539);class r{get type(){return n.UndoRedoElementType.Resource}get label(){return"Live.Preview.UndoRedo"}get code(){return"Live.Preview.UndoRedo"}get resource(){return this.model.uri}constructor(l){this.model=l,this.confirmBeforeUndo=!1}attachModel(l){this.decorationModel=l}registerUndo(l){this._undo=l}undo(){var l;(l=this._undo)===null||l===void 0||l.call(this,this.decorationModel)}registerRedo(l){this._redo=l}redo(){var l;(l=this._redo)===null||l===void 0||l.call(this,this.decorationModel)}}t.LivePreviewUndoRedoStackElement=r},8106:(L,t,e)=>{"use strict";var n;Object.defineProperty(t,"__esModule",{value:!0}),t.RemovedZoneWidget=t.AcceptPartialEditWidget=t.EPartialEdit=t.PendingRangeDecoration=t.AddedRangeDecoration=t.ActiveLineDecoration=void 0;const r=e(85608),o=r.__importDefault(e(53373)),l=r.__importStar(e(14041)),m=r.__importDefault(e(25873)),E=e(76003),p=e(41869),v=e(57925),s=e(43718),g=e(52659),c=e(90052),h=e(31324),d=e(34819),u=e(24522),_=r.__importDefault(e(71749));t.ActiveLineDecoration="activeLine-decoration",t.AddedRangeDecoration="added-range-decoration",t.PendingRangeDecoration="pending-range-decoration";var f;(function(A){A.accept="accept",A.discard="discard"})(f||(t.EPartialEdit=f={}));const a=A=>{const{keyStrings:w,onAccept:T,onDiscard:D,editor:I}=A,[O,P]=l.default.useState(0),R=(0,l.useCallback)(()=>{T?.()},[T]),M=(0,l.useCallback)(()=>{D?.()},[D]);return(0,p.useDisposable)(()=>I.onDidScrollChange(k=>{const{scrollLeftChanged:B,scrollLeft:x}=k;B&&P(x)}),[I]),l.default.createElement("div",{className:(0,o.default)("kt-inline-diff-accept-partial-widget-container",_.default.inline_diff_accept_partial_widget_container),style:{marginLeft:O}},l.default.createElement("div",{className:_.default.content},l.default.createElement("span",{className:(0,o.default)(_.default.accept_btn,_.default.btn),onClick:R},(0,s.localize)("aiNative.inline.diff.accept"),l.default.createElement("span",null,w.acceptSequence)),l.default.createElement("span",{className:(0,o.default)(_.default.discard_btn,_.default.btn),onClick:M},(0,s.localize)("aiNative.inline.diff.reject"),l.default.createElement("span",null,w.discardSequence))))};let b=n=class extends g.ReactInlineContentWidget{constructor(w,T){super(w),this.editor=w,this.editWidgetOptions=T,this._onAccept=this.registerDispose(new s.Emitter),this.onAccept=this._onAccept.event,this._onDiscard=this.registerDispose(new s.Emitter),this.onDiscard=this._onDiscard.event,this.positionPreference=[c.ContentWidgetPositionPreference.EXACT],this.addedLinesCount=0,this.deletedLinesCount=0,this.status="pending"}get group(){return this._group}getSequenceKeyStrings(){let w=this.keybindingRegistry.getKeybindingsForCommand(v.AI_INLINE_DIFF_PARTIAL_EDIT.id);if(w=w.sort((T,D)=>D.args-T.args),!(!w||w.length!==2&&w.some(T=>(0,s.isUndefined)(T.resolved))))return{acceptSequence:this.keybindingRegistry.acceleratorForSequence(w[0].resolved,"")[0],discardSequence:this.keybindingRegistry.acceleratorForSequence(w[1].resolved,"")[0]}}renderView(){var w;if(!((w=this.editWidgetOptions)===null||w===void 0)&&w.hideAcceptPartialEditWidget)return;const T=this.getSequenceKeyStrings();if(T)return l.default.createElement(a,{keyStrings:T,onAccept:()=>this._onAccept.fire(),onDiscard:()=>this._onDiscard.fire(),editor:this.editor})}id(){return this._id||(this._id=`${n.ID}_${(0,s.uuid)(4)}`),this._id}getClassName(){return _.default.accept_partial_edit_widget_id}recordDecorationId(w){this._decorationId=w}getDecorationId(){return this._decorationId}resume(){this.status="pending",this.addedLinesCount=0,this.deletedLinesCount=0,super.resume()}setGroup(w){this._group=w}get isPending(){return this.status==="pending"}accept(w,T){this.status="accept",this.addedLinesCount=w,this.deletedLinesCount=T,super.hide()}get isAccepted(){return this.status==="accept"}discard(w,T){this.status="discard",this.addedLinesCount=w,this.deletedLinesCount=T,super.hide()}get isRejected(){return this.status==="discard"}};t.AcceptPartialEditWidget=b,b.ID="AcceptPartialEditWidgetID",r.__decorate([(0,E.Autowired)(p.KeybindingRegistry),r.__metadata("design:type",Object)],b.prototype,"keybindingRegistry",void 0),t.AcceptPartialEditWidget=b=n=r.__decorate([(0,E.Injectable)({multiple:!0}),r.__metadata("design:paramtypes",[Object,Object])],b);const y=({dom:A,editor:w})=>{const T=l.default.useRef(null),[D,I]=l.default.useState(0),[O,P]=l.default.useState(0);return(0,l.useEffect)(()=>{A&&T&&T.current&&T.current.appendChild(A)},[A,T]),(0,p.useDisposable)(()=>w.onDidScrollChange(R=>{const{scrollLeftChanged:M,scrollLeft:k}=R;M&&I(k)}),[w]),(0,p.useDisposable)(()=>(P(w.getOption(h.EditorOption.layoutInfo).contentLeft),w.onDidChangeConfiguration(R=>{R.hasChanged(h.EditorOption.layoutInfo)&&P(w.getOption(h.EditorOption.layoutInfo).contentLeft)})),[w]),l.default.createElement("div",{className:_.default.inline_diff_remove_zone_fixed_box,style:{marginLeft:O+"px"}},l.default.createElement("div",{className:_.default.inline_diff_remove_zone,ref:T,style:{marginLeft:-D+"px"}}))};class S extends d.ZoneWidget{get isHidden(){return this._hidden}get group(){return this._group}constructor(w,T,D){super(w,D),this.textLines=T,this._hidden=!1,(0,s.isDefined)(D.isHidden)&&(this._hidden=D.isHidden),(0,s.isDefined)(D.recordPosition)&&(this._recordPosition=D.recordPosition),(0,s.isDefined)(D.undoRedoGroup)&&(this._group=D.undoRedoGroup);const I=this._positionMarkerId;this._disposables.add(I.onDidChange(O=>{const P=I.getRange(0);P&&(this._recordPosition=P.getStartPosition())}))}setGroup(w){this._group=w}_fillContainer(w){w.classList.add(_.default.inline_diff_remove_zone_widget_container),this.root=m.default.createRoot(w)}getRemovedTextLines(){return this.textLines.map(w=>w.text)}get height(){return this.textLines.length}getLastPosition(){return this.position||this._recordPosition}hide(){this._hidden=!0,super.hide()}resume(){const w=this.getLastPosition();w&&this.show(w,this.height)}show(w,T){this._hidden=!1,super.show(w,T)}revealRange(){}create(){super.create(),this.mountRender()}mountRender(){const w=document.createElement("div");(0,u.renderLines)(w,this.editor.getOption(h.EditorOption.tabIndex),this.textLines.map(({text:T,lineTokens:D})=>({content:T,decorations:[],lineTokens:D})),this.editor.getOptions()),this.root.render(l.default.createElement(y,{dom:w,editor:this.editor}))}dispose(){this.root.unmount(),super.dispose()}}t.RemovedZoneWidget=S},80715:(L,t,e)=>{"use strict";var n;Object.defineProperty(t,"__esModule",{value:!0}),t.LivePreviewDiffDecorationModel=void 0;const r=e(85608),o=e(76003),l=e(41869),m=e(43718),E=e(20868),p=e(60304),v=e(2261),s=e(74547),g=e(25539),c=e(77659),h=e(53617),d=e(15989),u=r.__importDefault(e(71749)),_=e(22169),f=e(54362),a=e(8106);let b=n=class extends m.Disposable{constructor(S){super(),this.monacoEditor=S,this._onPartialEditWidgetListChange=this.registerDispose(new m.Emitter),this.onPartialEditWidgetListChange=this._onPartialEditWidgetListChange.event,this.options={partialEditWidgetOptions:{}},this.partialEditWidgetList=[],this.removedZoneWidgets=[],this.model=this.monacoEditor.getModel(),this.undoRedoService=p.StandaloneServices.get(g.IUndoRedoService),this.activeLineDec=this.monacoEditor.createDecorationsCollection(),this.pendingRangeDec=this.monacoEditor.createDecorationsCollection(),this.aiNativeContextKey=this.injector.get(c.AINativeContextKey,[this.monacoEditor.contextKeyService]),this.addDispose(this.inlineStreamDiffService.onAcceptDiscardPartialEdit(A=>{const w=this.monacoEditor.getPosition(),T=this.partialEditWidgetList.filter(D=>!D.isHidden).sort((D,I)=>{var O,P,R,M;const k=((P=(O=D.getPosition())===null||O===void 0?void 0:O.position)===null||P===void 0?void 0:P.lineNumber)||1,B=((M=(R=I.getPosition())===null||R===void 0?void 0:R.position)===null||M===void 0?void 0:M.lineNumber)||1,x=Math.abs(w.lineNumber-k),N=Math.abs(w.lineNumber-B);return x-N});T.length>0&&this.handlePartialEditAction(A?a.EPartialEdit.accept:a.EPartialEdit.discard,T[0])})),this.addedRangeDec=new h.EnhanceDecorationsCollection(this.monacoEditor),this.addDispose(this.addedRangeDec.onDidDecorationsChange(A=>{this.aiNativeContextKey.inlineDiffPartialEditsIsVisible.get()&&this.partialEditWidgetList.forEach(T=>{const D=A.find(I=>T.getDecorationId()===I.id);if(D){const I=D.getRange();T.setOptions({position:{lineNumber:I.startLineNumber,column:1}}),T.layoutContentWidget()}})})),this.addDispose(m.Disposable.create(()=>{this.clear()}))}clear(){this.clearPendingLine(),this.clearActiveLine(),this.clearAddedLine(),this.clearRemovedWidgets(),this.clearPartialEditWidgetList()}initialize(S){this.updateZone(S)}getRemovedWidgets(){return this.removedZoneWidgets}restoreSnapshot(S){const{addedDecList:A,removedWidgetList:w,zone:T,editStackSnapshot:D,partialEditWidgetList:I}=S;this.updateZone(T),this.addedRangeDec.set(A),this.clearRemovedWidgets(),w.forEach(R=>{const M=R.getLastPosition();M&&this.showRemovedWidgetByLineNumber(M.lineNumber,R.textLines,{isHidden:R.isHidden,recordPosition:R.getLastPosition(),undoRedoGroup:R.group})}),this.clearPartialEditWidgetList(),I.forEach(R=>{var M,k;const B=(k=(M=R.getPosition())===null||M===void 0?void 0:M.position)===null||k===void 0?void 0:k.lineNumber;if(B){const x=this.createPartialEditWidget(B);R.status==="accept"?x.accept(R.addedLinesCount,R.deletedLinesCount):R.status==="discard"&&x.discard(R.addedLinesCount,R.deletedLinesCount),x.setGroup(R.group),this.partialEditWidgetList.push(x)}}),this.firePartialEditWidgetList(),this.recordPartialEditWidgetWithAddedDec();const O=this.model.uri;this.undoRedoService.restoreSnapshot(D);const P=this.undoRedoService.getElements(O);P.future.concat(P.past).forEach(R=>{R instanceof f.LivePreviewUndoRedoStackElement&&R.attachModel(this)})}createSnapshot(){return{addedDecList:this.addedRangeDec.getDecorations(),partialEditWidgetList:this.partialEditWidgetList,removedWidgetList:this.removedZoneWidgets,editStackSnapshot:this.undoRedoService.createSnapshot(this.model.uri),zone:this.zone}}showRemovedWidgetByLineNumber(S,A,w){const T=new E.Position(S,1),D=A.length,I=new a.RemovedZoneWidget(this.monacoEditor,A,{...w,showInHiddenAreas:!0,showFrame:!1,showArrow:!1});I.create(),this.removedZoneWidgets.push(I),w.isHidden?I.hide():I.show(T,D)}updateZone(S){this.zone=S}getZone(){return this.zone}touchActiveLine(S){const A=this.getZone();this.activeLineDec.set([{range:E.Range.fromPositions({lineNumber:A.startLineNumber+S-1,column:0}),options:s.ModelDecorationOptions.register({description:a.ActiveLineDecoration,isWholeLine:!0,className:u.default.inline_diff_current,zIndex:l.StackingLevel.Workbench})}])}doDiscardPartialWidget(S,A,w){let T=null,D=0,I=0;if(A&&A.length>0){const O=A.getRange();T=v.EditOperation.delete(E.Range.lift({startLineNumber:O.startLineNumber,startColumn:O.startColumn,endLineNumber:O.endLineNumber+1,endColumn:1})),D=A.length,A.hide()}if(w){const O=w.getLastPosition(),P=this.model.getEOL(),R=w.getRemovedTextLines();I=R.length;const M=R.join(P)+P;T?T=v.EditOperation.replace(E.Range.lift(T.range),M):T=v.EditOperation.insert(O.delta(1),M),w.hide()}return S.discard(D,I),T}handlePartialEditAction(S,A,w=!0,T=!1){const D=A.getPosition().position,I=this.aiReporter.getRelationId(),O=this.model,P=this.removedZoneWidgets.find(G=>G.getLastPosition().lineNumber===Math.max(1,D.lineNumber-1)),R=this.addedRangeDec.getDecorationByLineNumber(D.lineNumber),M=R?.length||0,k=P?.height||0,B=new g.UndoRedoGroup;A.setGroup(B),P?.setGroup(B),R?.setGroup(B);const x=G=>G.partialEditWidgetList.find(H=>H.group===B),N=G=>G.removedZoneWidgets.find(H=>H.group===B),j=G=>G.addedRangeDec.getDecorationByGroup(B);let K;const U=P?.getRemovedTextLines().join(`
|
|
28271
28271
|
`)||"",X=R?.getRange();X&&(K=O.getValueInRange({...X,endColumn:O.getLineMaxColumn(X.endLineNumber)}));const z=G=>{T&&this.aiReporter.end(I,{message:"discard",success:!0,isDrop:!0,code:K,originCode:U,actionSource:m.ActionSourceEnum.InlineChat,actionType:m.ActionTypeEnum.LineDiscard});const H=N(G);H?.hide();const $=j(G);$?.hide();const J=x(G);return this.doDiscardPartialWidget(J,$,H)},Q=G=>{T&&this.aiReporter.end(I,{message:"accept",success:!0,isReceive:!0,code:K,originCode:U,actionSource:m.ActionSourceEnum.InlineChat,actionType:m.ActionTypeEnum.lineAccept});const H=x(G);H?.accept(M,k);const $=N(G);$?.hide();const J=j(G);J?.hide()},Y=G=>{const H=x(G);H?.resume();const $=N(G);$?.resume();const J=j(G);J?.resume()};switch(S){case a.EPartialEdit.accept:if(Q(this),w){const G=this.createEditStackElement(B);G.attachModel(this),G.registerUndo(H=>{Y(H)}),G.registerRedo(H=>{Q(H)})}break;case a.EPartialEdit.discard:{const G=z(this);if(G){if(w){const H=this.createEditStackElement(B);H.attachModel(this),H.registerUndo($=>{Y($)}),H.registerRedo($=>{z($)})}O.pushStackElement(),O.pushEditOperations(null,[G],()=>null,B),O.pushStackElement()}}break;default:break}const Z={uri:this.model.uri,totalPartialEditCount:this.partialEditWidgetList.length,resolvedPartialEditCount:this.partialEditWidgetList.filter(G=>G.isHidden).length,currentPartialEdit:{addedLinesCount:M,deletedLinesCount:k,type:S},...this.getTotalCodeInfo()};this.monacoEditor.focus(),this.inlineDiffService.firePartialEdit(Z),this.firePartialEditWidgetList()}firePartialEditWidgetList(){this._onPartialEditWidgetListChange.fire(this.partialEditWidgetList);const S=this.partialEditWidgetList.filter(A=>!A.isHidden);this.aiNativeContextKey.inlineDiffPartialEditsIsVisible.set(S.length!==0)}createEditStackElement(S){const A=new f.LivePreviewUndoRedoStackElement(this.model);return this.undoRedoService.pushElement(A,S),A}static computeCodeInfo(S,A,w){const T=I(S),D={added:0,deleted:0,changed:0};return S.forEach((O,P)=>{if(O.status==="pending"){const R=A[P],M=w[P],k=R?.length||0,B=M?.height||0;D.added+=k,D.deleted+=B,D.changed+=Math.max(k,B)}}),{totalAddedLinesCount:T.added,totalDeletedLinesCount:T.deleted,totalChangedLinesCount:T.changed,unresolvedAddedLinesCount:D.added,unresolvedDeletedLinesCount:D.deleted,unresolvedChangedLinesCount:D.changed};function I(O){const P={added:0,deleted:0,changed:0};return O.forEach(R=>{const M=R.addedLinesCount,k=R.deletedLinesCount;P.added+=M,P.deleted+=k,P.changed+=Math.max(M,k)}),P}}getTotalCodeInfo(){const S=this.partialEditWidgetList,A=this.addedRangeDec.getDecorations(),w=this.removedZoneWidgets;return n.computeCodeInfo(S,A,w)}recordPartialEditWidgetWithAddedDec(){this.partialEditWidgetList.forEach(S=>{var A,w;const T=(w=(A=S.getPosition())===null||A===void 0?void 0:A.position)===null||w===void 0?void 0:w.lineNumber;if(T){const D=this.addedRangeDec.getDecorationByLineNumber(T);D&&S.recordDecorationId(D.id)}})}acceptUnProcessed(){this.partialEditWidgetList.filter(A=>!A.isHidden).forEach(A=>{this.handlePartialEditAction(a.EPartialEdit.accept,A,!1)})}discardUnProcessed(){this.partialEditWidgetList.filter(A=>!A.isHidden).forEach(A=>{this.handlePartialEditAction(a.EPartialEdit.discard,A,!1)})}createPartialEditWidget(S){const A=this.injector.get(a.AcceptPartialEditWidget,[this.monacoEditor,this.options.partialEditWidgetOptions]);A.show({position:{lineNumber:S,column:1}});const w=A.onDispose(()=>{const T=A.getId();this.partialEditWidgetList=this.partialEditWidgetList.filter(D=>D.getId()!==T),w.dispose()});return A.addDispose([A.onAccept(()=>{this.handlePartialEditAction(a.EPartialEdit.accept,A,!0,!0)}),A.onDiscard(()=>{this.handlePartialEditAction(a.EPartialEdit.discard,A,!0,!0)})]),A}touchPartialEditWidgets(S){this.clearPartialEditWidgetList(),this.partialEditWidgetList=S.map(A=>this.createPartialEditWidget(A)),this.firePartialEditWidgetList()}touchAddedRange(S){this.addedRangeDec.set(S.map(A=>{const w=A.startPosition,T=A.endPosition,D=A.len;let I=E.Range.fromPositions(w,T),O=u.default.inline_diff_added_range+" ";return D===0&&(I=E.Range.fromPositions(w),O+=u.default.hide),{length:D,range:I,isHidden:D===0,options:s.ModelDecorationOptions.register({description:a.AddedRangeDecoration,isWholeLine:!0,className:O})}})),this.recordPartialEditWidgetWithAddedDec()}touchRemovedWidget(S){const A=()=>{this.clearRemovedWidgets(),S.forEach(({textLines:w,position:T})=>{this.showRemovedWidgetByLineNumber(T.lineNumber,w,{})})};this.options.renderRemovedWidgetImmediately?A():(0,m.runWhenIdle)(A)}touchPendingRange(S){const A=this.getZone();this.pendingRangeDec.set([{range:E.Range.fromPositions({lineNumber:A.startLineNumber+S.startLineNumber-1,column:0},{lineNumber:A.startLineNumber+S.endLineNumberExclusive-2,column:Number.MAX_SAFE_INTEGER}),options:s.ModelDecorationOptions.register({description:a.PendingRangeDecoration,isWholeLine:!0,className:u.default.inline_diff_pending_range})}])}clearPendingLine(){this.pendingRangeDec.clear()}clearActiveLine(){this.activeLineDec.clear()}clearAddedLine(){this.addedRangeDec.clear()}clearPartialEditWidgetList(){this.partialEditWidgetList.forEach(S=>{S.dispose()}),this.partialEditWidgetList=[],this.aiNativeContextKey.inlineDiffPartialEditsIsVisible.set(!1)}clearRemovedWidgets(){this.removedZoneWidgets.forEach(S=>{S.dispose()}),this.removedZoneWidgets=[]}revealFirstDiff(){const S=this.removedZoneWidgets[0];if(S){const A=S.getLastPosition();A&&this.monacoEditor.revealLineInCenterIfOutsideViewport(A.lineNumber)}}setPreviewerOptions(S){this.options=S}};t.LivePreviewDiffDecorationModel=b,r.__decorate([(0,o.Autowired)(o.INJECTOR_TOKEN),r.__metadata("design:type",o.Injector)],b.prototype,"injector",void 0),r.__decorate([(0,o.Autowired)(m.IAIReporter),r.__metadata("design:type",Object)],b.prototype,"aiReporter",void 0),r.__decorate([(0,o.Autowired)(_.InlineStreamDiffService),r.__metadata("design:type",_.InlineStreamDiffService)],b.prototype,"inlineStreamDiffService",void 0),r.__decorate([(0,o.Autowired)(d.InlineDiffService),r.__metadata("design:type",d.InlineDiffService)],b.prototype,"inlineDiffService",void 0),t.LivePreviewDiffDecorationModel=b=n=r.__decorate([(0,o.Injectable)({multiple:!0}),r.__metadata("design:paramtypes",[Object])],b)},19520:(L,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.InlineInputPreviewDecorationID=void 0,t.InlineInputPreviewDecorationID="InlineInputPreviewDecorationID"},90058:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SumiLightBulbWidget=void 0;const n=e(41869),r=e(3908),o=e(19202);class l extends o.LightBulbWidget{_updateLightBulbTitleAndIcon(){super._updateLightBulbTitleAndIcon();const E=super.state;if(E.type!==1)return;let p=super.icon;(E.actions.allAIFixes||E.actions.hasAutoFix&&E.actions.hasAIFix||E.actions.hasAIFix)&&(p=r.Sumicon.magicWand),p&&(this.getDomNode().classList.remove(...this._iconClasses),this.getDomNode().classList.add(...(0,n.asClassNameArrayWrapper)(p)))}}t.SumiLightBulbWidget=l},8191:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.RewriteWidget=t.REWRITE_DECORATION_INLINE_ADD=void 0;const n=e(85608),r=n.__importDefault(e(53373)),o=n.__importStar(e(14041)),l=n.__importDefault(e(25873)),m=e(76003),E=e(41869),p=n.__importStar(e(20868)),v=e(52659),s=e(90052),g=e(77714),c=e(2261),h=e(87822),d=e(90626),u=n.__importDefault(e(32518)),_={fixedOverflowWidgets:!0,readOnly:!0,domReadOnly:!0,lineNumbers:"off",glyphMargin:!1,scrollBeyondLastLine:!1,rulers:void 0,overviewRulerBorder:void 0,overviewRulerLanes:0,padding:{top:0,bottom:0},folding:!1,stickyScroll:{enabled:!1},minimap:{enabled:!1},automaticLayout:!0,scrollbar:{horizontal:"hidden",vertical:"hidden",horizontalScrollbarSize:0,verticalScrollbarSize:0,arrowSize:0,verticalSliderSize:0,horizontalSliderSize:0,ignoreHorizontalScrollbarInContentHeight:!0},hover:{enabled:!1},guides:{indentation:!1}};t.REWRITE_DECORATION_INLINE_ADD="rewrite-decoration-inline-add";const f=o.default.memo(b=>{const{editor:y,onReady:S}=b,A=(0,E.useInjectable)(E.MonacoService),w=(0,o.useRef)(null),T=(0,o.useRef)(null),[D,I]=(0,o.useState)(null),[O,P]=(0,o.useState)(0),[R,M]=(0,o.useState)(null),k=(0,o.useCallback)((j,K,U)=>{const X=y.getModel().getEOL();let z=K.startLineNumber,Q=K.startColumn;const Y=j.getModel();j.changeDecorations(ce=>{if(j){Y.getAllDecorations().map(he=>he.id).forEach(he=>ce.removeDecoration(he));for(const he of U){if(he.removed)continue;const Ae=he.value.split(X);for(let te=0;te<Ae.length;te++){const Pe=Ae[te];te!==0&&(z++,Q=1),he.added&&ce.addDecoration(new p.Range(z,Q,z,Q+Pe.length),{description:t.REWRITE_DECORATION_INLINE_ADD,className:u.default.ghost_text_decoration_inline_add}),Q+=Pe.length}}}});const Z=j.getOption(p.editor.EditorOption.lineHeight);j?.setScrollTop(Math.max(K.startLineNumber-1,0)*Z);const G=z-K.startLineNumber,H=j.getOption(p.editor.EditorOption.fontInfo).spaceWidth,$=j.getOption(p.editor.EditorOption.layoutInfo).contentLeft;let J=0;const re=Y.getOptions().tabSize;Array.from({length:G+1},(ce,he)=>K.startLineNumber+he).forEach(ce=>{const he=Y.getLineContent(ce);let Ae=0;for(const te of he)te===g.space?Ae+=re:Ae+=1,J=Math.max(J,Ae)}),I({width:J*H+$*2,height:Z*(G+1)})},[D,y]);(0,o.useEffect)(()=>{if(y.getModel())return S&&S({getVirtualEditor:()=>R,renderVirtualEditor:(K,U,X)=>B(K,U,X),renderTextLineThrough:K=>x(K),layout:K=>N(K)}),()=>{R&&R.dispose(),T.current&&(0,E.runWhenIdle)(()=>{var K;(K=T.current)===null||K===void 0||K.unmount(),T.current=null})}},[y,S,R]);const B=(0,o.useCallback)((j,K,U)=>{if(!w.current)return;const X=y.getModel();if(!X)return;let z=R;if(!z){z=A.createCodeEditor(w.current,_);const Q=d.StandaloneServices.get(h.IModelService),Y={languageId:X.getLanguageId(),onDidChange:E.Event.None},Z=Q.createModel("",Y);z.setModel(Z),M(z)}z.setValue(j),k(z,K,U)},[w,R]),x=(0,o.useCallback)(j=>{if(!w.current)return;R&&(R.dispose(),M(null));const K=({changes:U})=>{const X=y.getOption(p.editor.EditorOption.lineHeight),z=y.getOption(p.editor.EditorOption.fontInfo).spaceWidth,Q=(Z,G=u.default.ghost_text_decoration)=>o.default.createElement("span",{className:(0,r.default)(u.default.space_span,G),style:{width:`${z*Z}px`}},g.space.repeat(Z)),Y=(Z,G)=>o.default.createElement("span",{className:(0,r.default)(u.default.text_span,G)},Z);return o.default.createElement(o.default.Fragment,null,U.map((Z,G)=>{let H=!0,$="",J=0;const re=[];for(const ce of Z){const{value:he,added:Ae,removed:te}=ce;if(te)$+=he;else{H=!1,J+=he.length;const Pe=he.length-he.trimStart().length,Te=he.length-he.trimEnd().length,ie=he.trim();re.push(Q(Pe)),ie&&(re.push(Y(ie,Ae?u.default.ghost_text_decoration_inline_add:u.default.ghost_text_decoration)),re.push(Q(Te)))}}if(H){const ce=$.length-$.trimStart().length,he=$.length-$.trimEnd().length,Ae=$.trim();re.push(Q(ce,u.default.ghost_text_decoration_remove)),Ae&&(re.push(Y(Ae,u.default.ghost_text_decoration_inline_remove)),re.push(Q(he,u.default.ghost_text_decoration_inline_remove)))}return o.default.createElement("div",{key:G,className:u.default.deletions_code_line,style:{height:`${X}px`}},re)}))};T.current&&(T.current.unmount(),T.current=null),T.current=l.default.createRoot(w.current),T.current.render(o.default.createElement(o.default.Fragment,null,j.map((U,X)=>o.default.createElement(K,{key:X,changes:U.changes}))))},[y,w,R,T]),N=(0,o.useCallback)(j=>{const K=y.getOption(p.editor.EditorOption.fontInfo).spaceWidth;let U=0;for(let X=j.startLineNumber;X<=j.endLineNumber;X++){const z=y.getModel().getLineMaxColumn(X);U=Math.max(U,z)}P(U*K+10)},[y]);return o.default.createElement("div",{className:u.default.rewrite_widget_container,style:{width:D?.width,height:D?.height,marginLeft:O}},o.default.createElement("div",{className:u.default.virtual_editor_container,ref:w}))});let a=class extends v.ReactInlineContentWidget{constructor(){super(...arguments),this.virtualEditorHandler=null,this.positionPreference=[s.ContentWidgetPositionPreference.EXACT],this.defered=new E.Deferred,this.updateFontStyle=()=>{const y=this.editor.getOption(p.editor.EditorOption.fontInfo);this.domNode.style.fontFamily=y.fontFamily,this.domNode.style.fontSize=y.fontSize+"px"}}renderView(){return this.updateFontStyle(),o.default.createElement(f,{editor:this.editor,onReady:y=>{this.defered.resolve(),this.virtualEditorHandler=y}})}id(){return"RewriteWidget"}show(y){const{position:S}=y;if(!S)return;const{lineNumber:A}=S;super.show({position:p.Position.lift({lineNumber:A,column:1})})}setInsertText(y){this.insertText=y}setEditArea(y){this.editArea=y}getEditArea(){return this.editArea}getVirtualEditor(){var y,S;return(S=(y=this.virtualEditorHandler)===null||y===void 0?void 0:y.getVirtualEditor())!==null&&S!==void 0?S:null}renderTextLineThrough(y){var S,A;(S=this.virtualEditorHandler)===null||S===void 0||S.renderTextLineThrough(y),(A=this.virtualEditorHandler)===null||A===void 0||A.layout(this.editArea)}renderVirtualEditor(y,S){this.virtualEditorHandler.renderVirtualEditor(y,this.editArea,S),this.virtualEditorHandler.layout(this.editArea)}accept(){(0,E.isUndefined)(this.insertText)||(this.editor.pushUndoStop(),this.editor.getModel().pushEditOperations(null,[c.EditOperation.replace(p.Range.lift(this.editArea),this.insertText)],()=>null))}};t.RewriteWidget=a,t.RewriteWidget=a=n.__decorate([(0,m.Injectable)({multiple:!0})],a)},19413:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.IAIInlineCompletionsProvider=t.EResultKind=t.EInlineChatStatus=t.ChatProxyServiceToken=t.IChatAgentService=t.IChatManagerService=t.IChatInternalService=t.ChatCompletionRequestMessageRoleEnum=t.AT_SIGN_SYMBOL=t.SLASH_SYMBOL=t.AI_MENUBAR_CONTAINER_VIEW_ID=t.AI_MENU_BAR_DEBUG_TOOLBAR=t.AI_CHAT_LOGO_AVATAR_ID=t.AI_CHAT_CONTAINER_ID=t.AI_CHAT_VIEW_ID=t.AIInlineChatContentWidget=t.IAINativeService=void 0;const n=e(43718),r=e(66338);t.IAINativeService=Symbol("IAINativeService"),t.AIInlineChatContentWidget=n.AIInlineChatContentWidgetId,t.AI_CHAT_VIEW_ID="AI-Chat",t.AI_CHAT_CONTAINER_ID="AI-Chat-Container",t.AI_CHAT_LOGO_AVATAR_ID="AI-Chat-Logo-Avatar",t.AI_MENU_BAR_DEBUG_TOOLBAR="AI_MENU_BAR_DEBUG_TOOLBAR",t.AI_MENUBAR_CONTAINER_VIEW_ID=r.DESIGN_MENUBAR_CONTAINER_VIEW_ID,t.SLASH_SYMBOL="/",t.AT_SIGN_SYMBOL="@";var o;(function(E){E.System="system",E.User="user",E.Assistant="assistant"})(o||(t.ChatCompletionRequestMessageRoleEnum=o={})),t.IChatInternalService=Symbol("IChatInternalService"),t.IChatManagerService=Symbol("IChatManagerService"),t.IChatAgentService=Symbol("IChatAgentService"),t.ChatProxyServiceToken=Symbol("ChatProxyServiceToken");var l;(function(E){E[E.READY=0]="READY",E[E.THINKING=1]="THINKING",E[E.DONE=2]="DONE",E[E.ERROR=3]="ERROR"})(l||(t.EInlineChatStatus=l={}));var m;(function(E){E.ACCEPT="ACCEPT",E.DISCARD="DISCARD",E.REGENERATE="REGENERATE"})(m||(t.EResultKind=m={})),t.IAIInlineCompletionsProvider=Symbol("IAIInlineCompletionsProvider")},69820:(L,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.NearestCodeBlockType=void 0;var e;(function(n){n.Block="block",n.Line="line"})(e||(t.NearestCodeBlockType=e={}))},98864:(L,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.extractCodeBlocks=t.isDocumentValid=t.isDocumentTooShort=t.isDocumentTooLarge=void 0;const e="```",n=10,r=E=>{try{E.getText()}catch(p){if(p instanceof RangeError)return!0}return!1};t.isDocumentTooLarge=r;const o=E=>E.getText().length<n;t.isDocumentTooShort=o;const l=E=>!((0,t.isDocumentTooLarge)(E)||(0,t.isDocumentTooShort)(E));t.isDocumentValid=l;const m=E=>{const p=E.split(`
|
|
28272
28272
|
`);let v=[],s=!1,g=0;return p.forEach((c,h)=>{if(!s&&c.startsWith(e))s=!0,g=h+1;else if(s&&c.startsWith(e)){s=!1;const d=h;v=p.slice(g,d)}s&&g!==h+1&&v.push(c)}),v.join(`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opensumi/cli-engine",
|
|
3
|
-
"version": "3.6.5-next-
|
|
3
|
+
"version": "3.6.5-next-1735790538.0",
|
|
4
4
|
"description": "Integration engine runtime for opensumi-cli and opensumi extension",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"files": [
|
|
@@ -26,14 +26,14 @@
|
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"@koa/cors": "^5.0.0",
|
|
28
28
|
"@opensumi/di": "^1.8.0",
|
|
29
|
-
"@opensumi/ide-core-browser": "3.6.5-next-
|
|
30
|
-
"@opensumi/ide-core-common": "3.6.5-next-
|
|
31
|
-
"@opensumi/ide-core-node": "3.6.5-next-
|
|
32
|
-
"@opensumi/ide-express-file-server": "3.6.5-next-
|
|
33
|
-
"@opensumi/ide-extension": "3.6.5-next-
|
|
34
|
-
"@opensumi/ide-i18n": "3.6.5-next-
|
|
35
|
-
"@opensumi/ide-main-layout": "3.6.5-next-
|
|
36
|
-
"@opensumi/ide-startup": "3.6.5-next-
|
|
29
|
+
"@opensumi/ide-core-browser": "3.6.5-next-1735790538.0",
|
|
30
|
+
"@opensumi/ide-core-common": "3.6.5-next-1735790538.0",
|
|
31
|
+
"@opensumi/ide-core-node": "3.6.5-next-1735790538.0",
|
|
32
|
+
"@opensumi/ide-express-file-server": "3.6.5-next-1735790538.0",
|
|
33
|
+
"@opensumi/ide-extension": "3.6.5-next-1735790538.0",
|
|
34
|
+
"@opensumi/ide-i18n": "3.6.5-next-1735790538.0",
|
|
35
|
+
"@opensumi/ide-main-layout": "3.6.5-next-1735790538.0",
|
|
36
|
+
"@opensumi/ide-startup": "3.6.5-next-1735790538.0",
|
|
37
37
|
"chalk": "^4.1.2",
|
|
38
38
|
"ejs": "^3.1.7",
|
|
39
39
|
"ip": "^1.1.8",
|
|
@@ -72,5 +72,5 @@
|
|
|
72
72
|
"webpack": "^5.90.0",
|
|
73
73
|
"webpack-cli": "^5.1.4"
|
|
74
74
|
},
|
|
75
|
-
"gitHead": "
|
|
75
|
+
"gitHead": "3ffad09b8ab135cbb8aa45b854d4fa888d294b8d"
|
|
76
76
|
}
|