!function(){function t(t){return function(t){if(Array.isArray(t))return e(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,r){if(!t)return;if("string"==typeof t)return e(t,r);var n=Object.prototype.toString.call(t).slice(8,-1);"Object"===n&&t.constructor&&(n=t.constructor.name);if("Map"===n||"Set"===n)return Array.from(t);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return e(t,r)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function e(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r0?c.push(a):(c.length>0&&(n.push(c.join("")),r.push("%BLOCK%"),c=[]),r.push(a)),"{"===a&&o++}return c.length>0&&(n.push(c.join("")),r.push("%BLOCK%")),{escapedString:r.join(""),blocks:n}},x=function(t,e,r){return t.replace(e,function(){for(var t=arguments.length,e=new Array(t),n=0;n-1?_(t,e,r):t+e+r+", "+e+" "+t+r},S=function t(e,r,n,o,c){return w(e,function(e){var c=e.selector,s=e.content;return"@"!==e.selector[0]?c=function(t,e,r,n){return t.split(",").map(function(t){return n&&t.indexOf("."+n)>-1?t.trim():function(t,e){return!function(t){return t=t.replace(/\[/g,"\\[").replace(/\]/g,"\\]"),new RegExp("^("+t+")([>\\s~+[.,{:][\\s\\S]*)?$","m")}(e).test(t)}(t,e)?function(t,e,r){for(var n,o="."+(e=e.replace(/\[is=([^\]]*)\]/g,function(t){return arguments.length<=1?void 0:arguments[1]})),c=function(t){var n=t.trim();if(!n)return"";if(t.indexOf("-shadowcsshost-no-combinator")>-1)n=function(t,e,r){if(l.lastIndex=0,l.test(t)){var n=".".concat(r);return t.replace(i,function(t,e){return e.replace(/([^:]*)(:*)(.*)/,function(t,e,r,o){return e+n+r+o})}).replace(l,n+" ")}return e+" "+t}(t,e,r);else{var c=t.replace(l,"");if(c.length>0){var s=c.match(/([^:]*)(:*)(.*)/);s&&(n=s[1]+o+s[2]+s[3])}}return n},s=function(t){var e=[],r=0;return{content:(t=t.replace(/(\[[^\]]*\])/g,function(t,n){var o="__ph-".concat(r,"__");return e.push(n),r++,o})).replace(/(:nth-[-\w]+)(\([^)]+\))/g,function(t,n,o){var c="__ph-".concat(r,"__");return e.push(o),r++,n+c}),placeholders:e}}(t),a="",u=0,h=/( |>|\+|~(?!=))\s*/g,f=!((t=s.content).indexOf("-shadowcsshost-no-combinator")>-1);null!==(n=h.exec(t));){var p=n[1],d=t.slice(u,n.index).trim();f=f||d.indexOf("-shadowcsshost-no-combinator")>-1,a+="".concat(f?c(d):d," ").concat(p," "),u=h.lastIndex}var g,m=t.substring(u);return a+=(f=f||m.indexOf("-shadowcsshost-no-combinator")>-1)?c(m):m,g=s.placeholders,a.replace(/__ph-(\d+)__/g,function(t,e){return g[+e]})}(t,e,r).trim():t.trim()}).join(", ")}(e.selector,r,n,o):(e.selector.startsWith("@media")||e.selector.startsWith("@supports")||e.selector.startsWith("@page")||e.selector.startsWith("@document"))&&(s=t(e.content,r,n,o)),{selector:c.replace(/\s{2,}/g," ").trim(),content:s}})},O=function(e,r,n){var o=r+"-h",i=r+"-s",l=e.match(g)||[];e=e.replace(d,"");var m=[];if(n){var v=function(t){var e="/*!@___".concat(m.length,"___*/");return m.push({placeholder:e,comment:"/*!@".concat(t.selector,"*/")}),t.selector=e+t.selector,t};e=w(e,function(t){return"@"!==t.selector[0]?v(t):t.selector.startsWith("@media")||t.selector.startsWith("@supports")||t.selector.startsWith("@page")||t.selector.startsWith("@document")?(t.content=w(t.content,v),t):t})}var b=function(t,e,r,n,o){var i=function(t,e){var r="."+e+" > ",n=[];return t=t.replace(a,function(){for(var t=arguments.length,e=new Array(t),o=0;o=0;i--){var u=e[5][i];if("}"===u||","===u)break;a=u+a}var l=a+s,h="".concat(a.trimRight()).concat(s.trim());return l.trim()!==h.trim()&&n.push({orgSelector:l,updatedSelector:"".concat(h,", ").concat(l)}),s}return"-shadowcsshost-no-combinator"+e[3]}),{selectors:n,cssText:t}}(t=function(t){return x(t,s,y)}(t=function(t){return x(t,c,_)}(t=t.replace(p,"-shadowcsscontext").replace(h,"-shadowcsshost").replace(f,"-shadowcssslotted"))),n);return t=function(t){return u.reduce(function(t,e){return t.replace(e," ")},t)}(t=i.cssText),e&&(t=S(t,e,r,n)),{cssText:(t=(t=t.replace(/-shadowcsshost-no-combinator/g,".".concat(r))).replace(/>\s*\*\s+([^{, ]+)/gm," $1 ")).trim(),slottedSelectors:i.selectors}}(e,r,o,i);return e=[b.cssText].concat(t(l)).join("\n"),n&&m.forEach(function(t){var r=t.placeholder,n=t.comment;e=e.replace(r,n)}),b.slottedSelectors.forEach(function(t){e=e.replace(t.orgSelector,t.updatedSelector)}),e}}}])}();