UNPKG

chrome-devtools-frontend

Version:
14 lines (13 loc) • 7.87 kB
/** * @license * Copyright 2017 Google LLC * SPDX-License-Identifier: BSD-3-Clause */ const t=globalThis,e=t.trustedTypes,s=e?e.createPolicy("lit-html",{createHTML:t=>t}):void 0,i="$lit$",n=`lit$${Math.random().toFixed(9).slice(2)}$`,o="?"+n,r=`<${o}>`,h=document,l=()=>h.createComment(""),$=t=>null===t||"object"!=typeof t&&"function"!=typeof t,a=Array.isArray,c="[ \t\n\f\r]",_=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,A=/-->/g,p=/>/g,d=RegExp(`>|${c}(?:([^\\s"'>=/]+)(${c}*=${c}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),u=/'/g,g=/"/g,f=/^(?:script|style|textarea|title)$/i,v=t=>(e,...s)=>({_$litType$:t,strings:e,values:s}),m=v(1),y=v(2),x=v(3),H=Symbol.for("lit-noChange"),N=Symbol.for("lit-nothing"),b=new WeakMap,S=h.createTreeWalker(h,129);function T(t,e){if(!a(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==s?s.createHTML(e):e}const M=(t,e)=>{const s=t.length-1,o=[];let h,l=2===e?"<svg>":3===e?"<math>":"",$=_;for(let e=0;e<s;e++){const s=t[e];let a,c,v=-1,m=0;for(;m<s.length&&($.lastIndex=m,c=$.exec(s),null!==c);)m=$.lastIndex,$===_?"!--"===c[1]?$=A:void 0!==c[1]?$=p:void 0!==c[2]?(f.test(c[2])&&(h=RegExp("</"+c[2],"g")),$=d):void 0!==c[3]&&($=d):$===d?">"===c[0]?($=h??_,v=-1):void 0===c[1]?v=-2:(v=$.lastIndex-c[2].length,a=c[1],$=void 0===c[3]?d:'"'===c[3]?g:u):$===g||$===u?$=d:$===A||$===p?$=_:($=d,h=void 0);const y=$===d&&t[e+1].startsWith("/>")?" ":"";l+=$===_?s+r:v>=0?(o.push(a),s.slice(0,v)+i+s.slice(v)+n+y):s+n+(-2===v?e:y)}return[T(t,l+(t[s]||"<?>")+(2===e?"</svg>":3===e?"</math>":"")),o]};class w{constructor({strings:t,_$litType$:s},r){let h;this.parts=[];let $=0,a=0;const c=t.length-1,_=this.parts,[A,p]=M(t,s);if(this.el=w.createElement(A,r),S.currentNode=this.el.content,2===s||3===s){const t=this.el.content.firstChild;t.replaceWith(...t.childNodes)}for(;null!==(h=S.nextNode())&&_.length<c;){if(1===h.nodeType){if(h.hasAttributes())for(const t of h.getAttributeNames())if(t.endsWith(i)){const e=p[a++],s=h.getAttribute(t).split(n),i=/([.?@])?(.*)/.exec(e);_.push({type:1,index:$,name:i[2],strings:s,ctor:"."===i[1]?O:"?"===i[1]?R:"@"===i[1]?j:U}),h.removeAttribute(t)}else t.startsWith(n)&&(_.push({type:6,index:$}),h.removeAttribute(t));if(f.test(h.tagName)){const t=h.textContent.split(n),s=t.length-1;if(s>0){h.textContent=e?e.emptyScript:"";for(let e=0;e<s;e++)h.append(t[e],l()),S.nextNode(),_.push({type:2,index:++$});h.append(t[s],l())}}}else if(8===h.nodeType)if(h.data===o)_.push({type:2,index:$});else{let t=-1;for(;-1!==(t=h.data.indexOf(n,t+1));)_.push({type:7,index:$}),t+=n.length-1}$++}}static createElement(t,e){const s=h.createElement("template");return s.innerHTML=t,s}}function C(t,e,s=t,i){if(e===H)return e;let n=void 0!==i?s._$Co?.[i]:s._$Cl;const o=$(e)?void 0:e._$litDirective$;return n?.constructor!==o&&(n?._$AO?.(!1),void 0===o?n=void 0:(n=new o(t),n._$AT(t,s,i)),void 0!==i?(s._$Co??=[])[i]=n:s._$Cl=n),void 0!==n&&(e=C(t,n._$AS(t,e.values),n,i)),e}class E{constructor(t,e){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=e}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){const{el:{content:e},parts:s}=this._$AD,i=(t?.creationScope??h).importNode(e,!0);S.currentNode=i;let n=S.nextNode(),o=0,r=0,l=s[0];for(;void 0!==l;){if(o===l.index){let e;2===l.type?e=new I(n,n.nextSibling,this,t):1===l.type?e=new l.ctor(n,l.name,l.strings,this,t):6===l.type&&(e=new B(n,this,t)),this._$AV.push(e),l=s[++r]}o!==l?.index&&(n=S.nextNode(),o++)}return S.currentNode=h,i}p(t){let e=0;for(const s of this._$AV)void 0!==s&&(void 0!==s.strings?(s._$AI(t,s,e),e+=s.strings.length-2):s._$AI(t[e])),e++}}class I{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(t,e,s,i){this.type=2,this._$AH=N,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=s,this.options=i,this._$Cv=i?.isConnected??!0}get parentNode(){let t=this._$AA.parentNode;const e=this._$AM;return void 0!==e&&11===t?.nodeType&&(t=e.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,e=this){t=C(this,t,e),$(t)?t===N||null==t||""===t?(this._$AH!==N&&this._$AR(),this._$AH=N):t!==this._$AH&&t!==H&&this._(t):void 0!==t._$litType$?this.$(t):void 0!==t.nodeType?this.T(t):(t=>a(t)||"function"==typeof t?.[Symbol.iterator])(t)?this.k(t):this._(t)}O(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.O(t))}_(t){this._$AH!==N&&$(this._$AH)?this._$AA.nextSibling.data=t:this.T(h.createTextNode(t)),this._$AH=t}$(t){const{values:e,_$litType$:s}=t,i="number"==typeof s?this._$AC(t):(void 0===s.el&&(s.el=w.createElement(T(s.h,s.h[0]),this.options)),s);if(this._$AH?._$AD===i)this._$AH.p(e);else{const t=new E(i,this),s=t.u(this.options);t.p(e),this.T(s),this._$AH=t}}_$AC(t){let e=b.get(t.strings);return void 0===e&&b.set(t.strings,e=new w(t)),e}k(t){a(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let s,i=0;for(const n of t)i===e.length?e.push(s=new I(this.O(l()),this.O(l()),this,this.options)):s=e[i],s._$AI(n),i++;i<e.length&&(this._$AR(s&&s._$AB.nextSibling,i),e.length=i)}_$AR(t=this._$AA.nextSibling,e){for(this._$AP?.(!1,!0,e);t!==this._$AB;){const e=t.nextSibling;t.remove(),t=e}}setConnected(t){void 0===this._$AM&&(this._$Cv=t,this._$AP?.(t))}}class U{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,e,s,i,n){this.type=1,this._$AH=N,this._$AN=void 0,this.element=t,this.name=e,this._$AM=i,this.options=n,s.length>2||""!==s[0]||""!==s[1]?(this._$AH=Array(s.length-1).fill(new String),this.strings=s):this._$AH=N}_$AI(t,e=this,s,i){const n=this.strings;let o=!1;if(void 0===n)t=C(this,t,e,0),o=!$(t)||t!==this._$AH&&t!==H,o&&(this._$AH=t);else{const i=t;let r,h;for(t=n[0],r=0;r<n.length-1;r++)h=C(this,i[s+r],e,r),h===H&&(h=this._$AH[r]),o||=!$(h)||h!==this._$AH[r],h===N?t=N:t!==N&&(t+=(h??"")+n[r+1]),this._$AH[r]=h}o&&!i&&this.j(t)}j(t){t===N?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}}class O extends U{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===N?void 0:t}}class R extends U{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==N)}}class j extends U{constructor(t,e,s,i,n){super(t,e,s,i,n),this.type=5}_$AI(t,e=this){if((t=C(this,t,e,0)??N)===H)return;const s=this._$AH,i=t===N&&s!==N||t.capture!==s.capture||t.once!==s.once||t.passive!==s.passive,n=t!==N&&(s===N||i);i&&this.element.removeEventListener(this.name,this,s),n&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){"function"==typeof this._$AH?this._$AH.call(this.options?.host??this.element,t):this._$AH.handleEvent(t)}}class B{constructor(t,e,s){this.element=t,this.type=6,this._$AN=void 0,this._$AM=e,this.options=s}get _$AU(){return this._$AM._$AU}_$AI(t){C(this,t)}}const W=t.litHtmlPolyfillSupport;W?.(w,I),(t.litHtmlVersions??=[]).push("3.3.1"); /** * @license * Copyright 2020 Google LLC * SPDX-License-Identifier: BSD-3-Clause */ const k=Symbol.for(""),L=t=>{if(t?.r===k)return t?._$litStatic$},P=t=>({_$litStatic$:t,r:k}),V=(t,...e)=>({_$litStatic$:e.reduce((e,s,i)=>e+(t=>{if(void 0!==t._$litStatic$)return t._$litStatic$;throw Error(`Value passed to 'literal' function must be a 'literal' result: ${t}. Use 'unsafeStatic' to pass non-literal values, but\n take care to ensure page security.`)})(s)+t[i+1],t[0]),r:k}),D=new Map,z=t=>(e,...s)=>{const i=s.length;let n,o;const r=[],h=[];let l,$=0,a=!1;for(;$<i;){for(l=e[$];$<i&&void 0!==(o=s[$],n=L(o));)l+=n+e[++$],a=!0;$!==i&&h.push(o),r.push(l),$++}if($===i&&r.push(e[i]),a){const t=r.join("$$lit$$");void 0===(e=D.get(t))&&(r.raw=r,D.set(t,e=r)),s=h}return t(e,...s)},Z=z(m),F=z(y),q=z(x);export{Z as html,V as literal,q as mathml,F as svg,P as unsafeStatic,z as withStatic}; //# sourceMappingURL=static-html.js.map