/*!--------------------------------------------------------
 * Copyright (C) Microsoft Corporation. All rights reserved.
 *--------------------------------------------------------*/(function(){var y=["vs/workbench/services/languageDetection/browser/languageDetectionSimpleWorker","require","exports","vs/base/common/stopwatch","vs/editor/common/services/editorSimpleWorker"],m=function(e){for(var n=[],i=0,u=e.length;i<u;i++)n[i]=y[e[i]];return n},O=this&&this.__createBinding||(Object.create?function(e,n,i,u){u===void 0&&(u=i);var d=Object.getOwnPropertyDescriptor(n,i);(!d||("get"in d?!n.__esModule:d.writable||d.configurable))&&(d={enumerable:!0,get:function(){return n[i]}}),Object.defineProperty(e,u,d)}:function(e,n,i,u){u===void 0&&(u=i),e[u]=n[i]}),M=this&&this.__setModuleDefault||(Object.create?function(e,n){Object.defineProperty(e,"default",{enumerable:!0,value:n})}:function(e,n){e.default=n}),b=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var n={};if(e!=null)for(var i in e)i!=="default"&&Object.prototype.hasOwnProperty.call(e,i)&&O(n,e,i);return M(n,e),n};define(y[0],m([1,2,3,4]),function(e,n,i,u){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.LanguageDetectionSimpleWorker=void 0,n.create=d;function d(_){return new f(_,null)}class f extends u.EditorSimpleWorker{constructor(){super(...arguments),this.v=!1,this.y=!1,this.z=new Map}static{this.q=.2}static{this.r=.05}static{this.s=.025}static{this.t=.5}async detectLanguage(c,s,t,a){const o=[],r=[],w=new i.$fe,g=this.A(c);if(!g)return;const v=async()=>{for await(const h of this.F(g)){this.z.has(h.languageId)||this.z.set(h.languageId,await this.d.fhr("getLanguageId",[h.languageId]));const l=this.z.get(h.languageId);l&&(!a?.length||a.includes(l))&&(o.push(l),r.push(h.confidence))}if(w.stop(),o.length)return this.d.fhr("sendTelemetryEvent",[o,r,w.elapsed()]),o[0]},p=async()=>this.C(g,s??{},a);if(t){const h=await p();if(h)return h;const l=await v();if(l)return l}else{const h=await v();if(h)return h;const l=await p();if(l)return l}}A(c){const s=this.j(c);if(!s)return;const t=s.positionAt(1e4);return s.getValueInRange({startColumn:1,startLineNumber:1,endColumn:t.column,endLineNumber:t.lineNumber})}async B(){if(this.v)return;if(this.u)return this.u;const c=await this.d.fhr("getRegexpModelUri",[]);try{return this.u=await new Promise((s,t)=>{e([c],s,t)}).then(b),this.u}catch{this.v=!0;return}}async C(c,s,t){const a=await this.B();if(!a)return;if(t?.length)for(const r of Object.keys(s))t.includes(r)?s[r]=1:s[r]=0;return a.detect(c,s,t)}async D(){if(this.w)return this.w;const c=await this.d.fhr("getIndexJsUri",[]),{ModelOperations:s}=await new Promise((t,a)=>{e([c],t,a)}).then(b);return this.w=new s({modelJsonLoaderFunc:async()=>{const t=await fetch(await this.d.fhr("getModelJsonUri",[]));try{return await t.json()}catch{const o="Failed to parse model JSON.";throw new Error(o)}},weightsLoaderFunc:async()=>await(await fetch(await this.d.fhr("getWeightsUri",[]))).arrayBuffer()}),this.w}E(c){switch(c.languageId){case"js":case"html":case"json":case"ts":case"css":case"py":case"xml":case"php":c.confidence+=f.r;break;case"cpp":case"sh":case"java":case"cs":case"c":c.confidence+=f.s;break;case"bat":case"ini":case"makefile":case"sql":case"csv":case"toml":c.confidence-=f.t;break;default:break}return c}async*F(c){if(this.y)return;let s;try{s=await this.D()}catch(r){console.log(r),this.y=!0;return}let t;try{t=await s.runModel(c)}catch(r){console.warn(r)}if(!t||t.length===0||t[0].confidence<f.q)return;const a=this.E(t[0]);if(a.confidence<f.q)return;const o=[a];for(let r of t){if(r===a)continue;if(r=this.E(r),o[o.length-1].confidence-r.confidence>=f.q){for(;o.length;)yield o.shift();if(r.confidence>f.q){o.push(r);continue}return}else{if(r.confidence>f.q){o.push(r);continue}return}}}}n.LanguageDetectionSimpleWorker=f})}).call(this);

//# sourceMappingURL=https://main.vscode-cdn.net/sourcemaps/fee1edb8d6d72a0ddff41e5f71a671c23ed924b9/core/vs/workbench/services/languageDetection/browser/languageDetectionSimpleWorker.js.map
