import{$u as e,Bs as t,Ec as n,a as r,i,o as a,od as o,vo as s,ys as c}from"./iconRegistry-DTFrTa1x.js";var l=n(`ILanguageFeaturesService`),u=class e{static capture(t){if(t.getScrollTop()===0||t.hasPendingScrollAnimation())return new e(t.getScrollTop(),t.getContentHeight(),null,0,null);let n=null,r=0,i=t.getVisibleRanges();if(i.length>0){n=i[0].getStartPosition();let e=t.getTopForPosition(n.lineNumber,n.column);r=t.getScrollTop()-e}return new e(t.getScrollTop(),t.getContentHeight(),n,r,t.getPosition())}constructor(e,t,n,r,i){this._initialScrollTop=e,this._initialContentHeight=t,this._visiblePosition=n,this._visiblePositionScrollDelta=r,this._cursorPosition=i}restore(e){if((this._initialContentHeight!==e.getContentHeight()||this._initialScrollTop!==e.getScrollTop())&&this._visiblePosition){let t=e.getTopForPosition(this._visiblePosition.lineNumber,this._visiblePosition.column);e.setScrollTop(t+this._visiblePositionScrollDelta)}}restoreRelativeVerticalPositionOfCursor(e){if(this._initialContentHeight===e.getContentHeight()&&this._initialScrollTop===e.getScrollTop())return;let t=e.getPosition();if(!this._cursorPosition||!t)return;let n=e.getTopForLineNumber(t.lineNumber)-e.getTopForLineNumber(this._cursorPosition.lineNumber);e.setScrollTop(e.getScrollTop()+n,1)}},d=n(`environmentService`),f=function(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a},p=function(e,t){return function(n,r){t(n,r,e)}},m=n(`ILanguageFeatureDebounceService`),h;(function(e){let t=new WeakMap,n=0;function r(e){let r=t.get(e);return r===void 0&&(r=++n,t.set(e,r)),r}e.of=r})(h||={});var g=class{constructor(e){this._default=e}get(e){return this._default}update(e,t){return this._default}default(){return this._default}},_=class{constructor(e,n,r,i,a,o){this._logService=e,this._name=n,this._registry=r,this._default=i,this._min=a,this._max=o,this._cache=new t(50,.7)}_key(t){return t.id+this._registry.all(t).reduce((t,n)=>e(h.of(n),t),0)}get(e){let t=this._key(e),n=this._cache.get(t);return n?a(n.value,this._min,this._max):this.default()}update(e,t){let n=this._key(e),i=this._cache.get(n);i||(i=new r(6),this._cache.set(n,i));let s=a(i.update(t),this._min,this._max);return o(e.uri,`output`)||this._logService.trace(`[DEBOUNCE: ${this._name}] for ${e.uri.toString()} is ${s}ms`),s}_overall(){let e=new i;for(let[,t]of this._cache)e.update(t.value);return e.value}default(){let e=this._overall()|0||this._default;return a(e,this._min,this._max)}},v=class{constructor(e,t){this._logService=e,this._data=new Map,this._isDev=t.isExtensionDevelopment||!t.isBuilt}for(e,t,n){let r=n?.min??50,i=n?.max??r**2,a=n?.key??void 0,o=`${h.of(e)},${r}${a?`,`+a:``}`,s=this._data.get(o);return s||(this._isDev?(this._logService.debug(`[DEBOUNCE: ${t}] is disabled in developed mode`),s=new g(r*1.5)):s=new _(this._logService,t,e,this._overallAverage()|0||r*1.5,r,i),this._data.set(o,s)),s}_overallAverage(){let e=new i;for(let t of this._data.values())e.update(t.default());return e.value}};v=f([p(0,c),p(1,d)],v),s(m,v,1);export{l as i,d as n,u as r,m as t};