/*! For license information please see style-map.js.LICENSE.txt */
import{AttributePart,directive,PropertyPart}from"../lit-html.js";const previousStylePropertyCache=new WeakMap;export const styleMap=directive((t=>e=>{if(!(e instanceof AttributePart)||e instanceof PropertyPart||"style"!==e.committer.name||e.committer.parts.length>1)throw new Error("The `styleMap` directive must be used in the style attribute and must be the only part in the attribute.");const{committer:r}=e,{style:i}=r.element;let o=previousStylePropertyCache.get(e);void 0===o&&(i.cssText=r.strings.join(" "),previousStylePropertyCache.set(e,o=new Set)),o.forEach((e=>{e in t||(o.delete(e),-1===e.indexOf("-")?i[e]=null:i.removeProperty(e))}));for(const n in t)o.add(n),-1===n.indexOf("-")?i[n]=t[n]:i.setProperty(n,t[n])}));