import{nothing as t}from"lit/html.js";import{directive as i,PartType as s}from"lit/directive.js";import{AsyncDirective as o}from"lit/async-directive.js";const r=["top","right","bottom","left"];class e extends o{constructor(t){if(super(t),t.type!==s.ELEMENT)throw Error("The `position` directive must be used in attribute position.")}render(i,s){return t}update(t,[i,s]){return void 0===this.u&&(this.u=t.options?.host,this.u.addController(this)),this.S=t.element,this.C=i,this.F=s??["left","top","width","height"],this.render(i,s)}hostUpdated(){this.$()}$(){const t="function"==typeof this.C?this.C():this.C?.value,i=t.offsetParent;if(void 0===t||!i)return;const s=t.getBoundingClientRect(),o=i.getBoundingClientRect();this.F?.forEach((t=>{const i=r.includes(t)?s[t]-o[t]:s[t];this.S.style[t]=i+"px"}))}}const h=i(e);export{e as Position,h as position};
