import{noChange as e}from"../lit-html.js";import{AsyncDirective as t}from"../async-directive.js";import{PseudoWeakRef as s,Pauser as i,forAwaitOf as r}from"./private-async-helpers.js";import{directive as n}from"../directive.js";
/**
 * @license
 * Copyright 2017 Google LLC
 * SPDX-License-Identifier: BSD-3-Clause
 */class o extends t{constructor(){super(...arguments),this._$CK=new s(this),this._$CX=new i}render(t,s){return e}update(t,[s,i]){if(this.isConnected||this.disconnected(),s===this._$CJ)return e;this._$CJ=s;let n=0;const{_$CK:c,_$CX:a}=this;return r(s,(async e=>{for(;a.get();)await a.get();const t=c.deref();if(void 0!==t){if(t._$CJ!==s)return!1;void 0!==i&&(e=i(e,n)),t.commitValue(e,n),n++}return!0})),e}commitValue(e,t){this.setValue(e)}disconnected(){this._$CK.disconnect(),this._$CX.pause()}reconnected(){this._$CK.reconnect(this),this._$CX.resume()}}const c=n(o);export{o as AsyncReplaceDirective,c as asyncReplace};