"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("../../_util/canUseDom.js"),p=require("./contains.js"),a="data-vc-order",y="vc-util-key",d=new Map;function f({mark:e}={}){return e?e.startsWith("data-")?e:`data-${e}`:y}function u(e){return e.attachTo?e.attachTo:document.querySelector("head")||document.body}function m(e){return e==="queue"?"prependQueue":e?"prepend":"append"}function l(e){return Array.from((d.get(e)||e).children).filter(r=>r.tagName==="STYLE")}function s(e,r={}){if(!g.default())return null;const{csp:t,prepend:c}=r,n=document.createElement("style");n.setAttribute(a,m(c)),t?.nonce&&(n.nonce=t?.nonce),n.innerHTML=e;const i=u(r),{firstChild:h}=i;if(c){if(c==="queue"){const o=l(i).filter(C=>["prepend","prependQueue"].includes(C.getAttribute(a)));if(o.length)return i.insertBefore(n,o[o.length-1].nextSibling),n}i.insertBefore(n,h)}else i.appendChild(n);return n}function S(e,r={}){const t=u(r);return l(t).find(c=>c.getAttribute(f(r))===e)}function b(e,r={}){const t=S(e,r);t&&u(r).removeChild(t)}function N(e,r){const t=d.get(e);if(!t||!p.default(document,t)){const c=s("",r),{parentNode:n}=c;d.set(e,n),e.removeChild(c)}}function v(e,r,t={}){const c=u(t);N(c,t);const n=S(r,t);if(n)return t.csp?.nonce&&n.nonce!==t.csp?.nonce&&(n.nonce=t.csp?.nonce),n.innerHTML!==e&&(n.innerHTML=e),n;const i=s(e,t);return i.setAttribute(f(t),r),i}exports.injectCSS=s;exports.removeCSS=b;exports.updateCSS=v;
