UNPKG

chrome-devtools-frontend

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