UNPKG

chrome-devtools-frontend

Version:
50 lines (49 loc) • 15.3 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$",r=`lit$${Math.random().toFixed(9).slice(2)}$`,o="?"+r,h=`<${o}>`,l=document,c=()=>l.createComment(""),a=t=>null===t||"object"!=typeof t&&"function"!=typeof t,d=Array.isArray,u="[ \t\n\f\r]",$=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,_=/-->/g,A=/>/g,f=RegExp(`>|${u}(?:([^\\s"'>=/]+)(${u}*=${u}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),p=/'/g,v=/"/g,g=/^(?:script|style|textarea|title)$/i,y=Symbol.for("lit-noChange"),m=Symbol.for("lit-nothing"),b=new WeakMap,C=l.createTreeWalker(l,129);function x(t,e){if(!d(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==i?i.createHTML(e):e}class w{constructor({strings:t,_$litType$:e},i){let l;this.parts=[];let a=0,d=0;const u=t.length-1,y=this.parts,[m,b]=((t,e)=>{const s=t.length-1,i=[];let o,l=2===e?"<svg>":3===e?"<math>":"",c=$;for(let e=0;e<s;e++){const s=t[e];let a,d,u=-1,y=0;for(;y<s.length&&(c.lastIndex=y,d=c.exec(s),null!==d);)y=c.lastIndex,c===$?"!--"===d[1]?c=_:void 0!==d[1]?c=A:void 0!==d[2]?(g.test(d[2])&&(o=RegExp("</"+d[2],"g")),c=f):void 0!==d[3]&&(c=f):c===f?">"===d[0]?(c=o??$,u=-1):void 0===d[1]?u=-2:(u=c.lastIndex-d[2].length,a=d[1],c=void 0===d[3]?f:'"'===d[3]?v:p):c===v||c===p?c=f:c===_||c===A?c=$:(c=f,o=void 0);const m=c===f&&t[e+1].startsWith("/>")?" ":"";l+=c===$?s+h:u>=0?(i.push(a),s.slice(0,u)+n+s.slice(u)+r+m):s+r+(-2===u?e:m)}return[x(t,l+(t[s]||"<?>")+(2===e?"</svg>":3===e?"</math>":"")),i]})(t,e);if(this.el=w.createElement(m,i),C.currentNode=this.el.content,2===e||3===e){const t=this.el.content.firstChild;t.replaceWith(...t.childNodes)}for(;null!==(l=C.nextNode())&&y.length<u;){if(1===l.nodeType){if(l.hasAttributes())for(const t of l.getAttributeNames())if(t.endsWith(n)){const e=b[d++],s=l.getAttribute(t).split(r),i=/([.?@])?(.*)/.exec(e);y.push({type:1,index:a,name:i[2],strings:s,ctor:"."===i[1]?S:"?"===i[1]?E:"@"===i[1]?G:T}),l.removeAttribute(t)}else t.startsWith(r)&&(y.push({type:6,index:a}),l.removeAttribute(t));if(g.test(l.tagName)){const t=l.textContent.split(r),e=t.length-1;if(e>0){l.textContent=s?s.emptyScript:"";for(let s=0;s<e;s++)l.append(t[s],c()),C.nextNode(),y.push({type:2,index:++a});l.append(t[e],c())}}}else if(8===l.nodeType)if(l.data===o)y.push({type:2,index:a});else{let t=-1;for(;-1!==(t=l.data.indexOf(r,t+1));)y.push({type:7,index:a}),t+=r.length-1}a++}}static createElement(t,e){const s=l.createElement("template");return s.innerHTML=t,s}}function H(t,e,s=t,i){if(e===y)return e;let n=void 0!==i?s._$Co?.[i]:s._$Cl;const r=a(e)?void 0:e._$litDirective$;return n?.constructor!==r&&(n?._$AO?.(!1),void 0===r?n=void 0:(n=new r(t),n._$AT(t,s,i)),void 0!==i?(s._$Co??=[])[i]=n:s._$Cl=n),void 0!==n&&(e=H(t,n._$AS(t,e.values),n,i)),e}class N{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);C.currentNode=i;let n=C.nextNode(),r=0,o=0,h=s[0];for(;void 0!==h;){if(r===h.index){let e;2===h.type?e=new M(n,n.nextSibling,this,t):1===h.type?e=new h.ctor(n,h.name,h.strings,this,t):6===h.type&&(e=new I(n,this,t)),this._$AV.push(e),h=s[++o]}r!==h?.index&&(n=C.nextNode(),r++)}return C.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 M{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(t,e,s,i){this.type=2,this._$AH=m,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=H(this,t,e),a(t)?t===m||null==t||""===t?(this._$AH!==m&&this._$AR(),this._$AH=m):t!==this._$AH&&t!==y&&this._(t):void 0!==t._$litType$?this.$(t):void 0!==t.nodeType?this.T(t):(t=>d(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!==m&&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=w.createElement(x(s.h,s.h[0]),this.options)),s);if(this._$AH?._$AD===i)this._$AH.p(e);else{const t=new N(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){d(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 M(this.O(c()),this.O(c()),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 T{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,e,s,i,n){this.type=1,this._$AH=m,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=m}_$AI(t,e=this,s,i){const n=this.strings;let r=!1;if(void 0===n)t=H(this,t,e,0),r=!a(t)||t!==this._$AH&&t!==y,r&&(this._$AH=t);else{const i=t;let o,h;for(t=n[0],o=0;o<n.length-1;o++)h=H(this,i[s+o],e,o),h===y&&(h=this._$AH[o]),r||=!a(h)||h!==this._$AH[o],h===m?t=m:t!==m&&(t+=(h??"")+n[o+1]),this._$AH[o]=h}r&&!i&&this.j(t)}j(t){t===m?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}}class S extends T{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===m?void 0:t}}class E extends T{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==m)}}class G extends T{constructor(t,e,s,i,n){super(t,e,s,i,n),this.type=5}_$AI(t,e=this){if((t=H(this,t,e,0)??m)===y)return;const s=this._$AH,i=t===m&&s!==m||t.capture!==s.capture||t.once!==s.once||t.passive!==s.passive,n=t!==m&&(s===m||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 I{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){H(this,t)}}const U={I:M},k=t.litHtmlPolyfillSupport;k?.(w,M),(t.litHtmlVersions??=[]).push("3.3.3"); /** * @license * Copyright 2017 Google LLC * SPDX-License-Identifier: BSD-3-Clause */ const O=1,P=2,j=3,B=4,L=t=>(...e)=>({_$litDirective$:t,values:e});let R=class{constructor(t){}get _$AU(){return this._$AM._$AU}_$AT(t,e,s){this._$Ct=t,this._$AM=e,this._$Ci=s}_$AS(t,e){return this.update(t,e)}update(t,e){return this.render(...e)}}; /** * @license * Copyright 2018 Google LLC * SPDX-License-Identifier: BSD-3-Clause */const W=L(class extends R{constructor(t){if(super(t),t.type!==O||"class"!==t.name||t.strings?.length>2)throw Error("`classMap()` can only be used in the `class` attribute and must be the only part in the attribute.")}render(t){return" "+Object.keys(t).filter(e=>t[e]).join(" ")+" "}update(t,[e]){if(void 0===this.st){this.st=new Set,void 0!==t.strings&&(this.nt=new Set(t.strings.join(" ").split(/\s/).filter(t=>""!==t)));for(const t in e)e[t]&&!this.nt?.has(t)&&this.st.add(t);return this.render(e)}const s=t.element.classList;for(const t of this.st)t in e||(s.remove(t),this.st.delete(t));for(const t in e){const i=!!e[t];i===this.st.has(t)||this.nt?.has(t)||(i?(s.add(t),this.st.add(t)):(s.remove(t),this.st.delete(t)))}return y}}),D=t=>t??m,{I:Z}=U,V=t=>t,z=t=>void 0===t.strings,K=()=>document.createComment(""),X=(t,e,s)=>{const i=t._$AA.parentNode,n=void 0===e?t._$AB:e._$AA;if(void 0===s){const e=i.insertBefore(K(),n),r=i.insertBefore(K(),n);s=new Z(e,r,t,t.options)}else{const e=s._$AB.nextSibling,r=s._$AM,o=r!==t;if(o){let e;s._$AQ?.(t),s._$AM=t,void 0!==s._$AP&&(e=t._$AU)!==r._$AU&&s._$AP(e)}if(e!==n||o){let t=s._$AA;for(;t!==e;){const e=V(t).nextSibling;V(i).insertBefore(t,n),t=e}}}return s},Y=(t,e,s=t)=>(t._$AI(e,s),t),Q={},F=(t,e=Q)=>t._$AH=e,q=t=>{t._$AR(),t._$AA.remove()},J=L(class extends R{constructor(t){if(super(t),t.type!==j&&t.type!==O&&t.type!==B)throw Error("The `live` directive is not allowed on child or event bindings");if(!z(t))throw Error("`live` bindings can only contain a single expression")}render(t){return t}update(t,[e]){if(e===y||e===m)return e;const s=t.element,i=t.name;if(t.type===j){if(e===s[i])return y}else if(t.type===B){if(!!e===s.hasAttribute(i))return y}else if(t.type===O&&s.getAttribute(i)===e+"")return y;return F(t),e}}),tt=(t,e,s)=>{const i=new Map;for(let n=e;n<=s;n++)i.set(t[n],n);return i},et=L(class extends R{constructor(t){if(super(t),t.type!==P)throw Error("repeat() can only be used in text expressions")}dt(t,e,s){let i;void 0===s?s=e:void 0!==e&&(i=e);const n=[],r=[];let o=0;for(const e of t)n[o]=i?i(e,o):o,r[o]=s(e,o),o++;return{values:r,keys:n}}render(t,e,s){return this.dt(t,e,s).values}update(t,[e,s,i]){const n=(t=>t._$AH)(t),{values:r,keys:o}=this.dt(e,s,i);if(!Array.isArray(n))return this.ut=o,r;const h=this.ut??=[],l=[];let c,a,d=0,u=n.length-1,$=0,_=r.length-1;for(;d<=u&&$<=_;)if(null===n[d])d++;else if(null===n[u])u--;else if(h[d]===o[$])l[$]=Y(n[d],r[$]),d++,$++;else if(h[u]===o[_])l[_]=Y(n[u],r[_]),u--,_--;else if(h[d]===o[_])l[_]=Y(n[d],r[_]),X(t,l[_+1],n[d]),d++,_--;else if(h[u]===o[$])l[$]=Y(n[u],r[$]),X(t,n[d],n[u]),u--,$++;else if(void 0===c&&(c=tt(o,$,_),a=tt(h,d,u)),c.has(h[d]))if(c.has(h[u])){const e=a.get(o[$]),s=void 0!==e?n[e]:null;if(null===s){const e=X(t,n[d]);Y(e,r[$]),l[$]=e}else l[$]=Y(s,r[$]),X(t,n[d],s),n[e]=null;$++}else q(n[u]),u--;else q(n[d]),d++;for(;$<=_;){const e=X(t,l[_+1]);Y(e,r[$]),l[$++]=e}for(;d<=u;){const t=n[d++];null!==t&&q(t)}return this.ut=o,F(t,l),y}}),st="important",it=" !"+st,nt=L(class extends R{constructor(t){if(super(t),t.type!==O||"style"!==t.name||t.strings?.length>2)throw Error("The `styleMap` directive must be used in the `style` attribute and must be the only part in the attribute.")}render(t){return Object.keys(t).reduce((e,s)=>{const i=t[s];return null==i?e:e+`${s=s.includes("-")?s:s.replace(/(?:^(webkit|moz|ms|o)|)(?=[A-Z])/g,"-$&").toLowerCase()}:${i};`},"")}update(t,[e]){const{style:s}=t.element;if(void 0===this.ft)return this.ft=new Set(Object.keys(e)),this.render(e);for(const t of this.ft)null==e[t]&&(this.ft.delete(t),t.includes("-")?s.removeProperty(t):s[t]=null);for(const t in e){const i=e[t];if(null!=i){this.ft.add(t);const e="string"==typeof i&&i.endsWith(it);t.includes("-")||e?s.setProperty(t,e?i.slice(0,-11):i,e?st:""):s[t]=i}}return y}}); /** * @license * Copyright 2018 Google LLC * SPDX-License-Identifier: BSD-3-Clause */ /** * @license * Copyright 2017 Google LLC * SPDX-License-Identifier: BSD-3-Clause */ let rt=class extends R{constructor(t){if(super(t),this.it=m,t.type!==P)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(t){if(t===m||null==t)return this._t=void 0,this.it=t;if(t===y)return t;if("string"!=typeof t)throw Error(this.constructor.directiveName+"() called with a non-string value");if(t===this.it)return this._t;this.it=t;const e=[t];return e.raw=e,this._t={_$litType$:this.constructor.resultType,strings:e,values:[]}}};rt.directiveName="unsafeHTML",rt.resultType=1;const ot=L(rt),ht=(t,e)=>{const s=t._$AN;if(void 0===s)return!1;for(const t of s)t._$AO?.(e,!1),ht(t,e);return!0},lt=t=>{let e,s;do{if(void 0===(e=t._$AM))break;s=e._$AN,s.delete(t),t=e}while(0===s?.size)},ct=t=>{for(let e;e=t._$AM;t=e){let s=e._$AN;if(void 0===s)e._$AN=s=new Set;else if(s.has(t))break;s.add(t),ut(e)}}; /** * @license * Copyright 2017 Google LLC * SPDX-License-Identifier: BSD-3-Clause */function at(t){void 0!==this._$AN?(lt(this),this._$AM=t,ct(this)):this._$AM=t}function dt(t,e=!1,s=0){const i=this._$AH,n=this._$AN;if(void 0!==n&&0!==n.size)if(e)if(Array.isArray(i))for(let t=s;t<i.length;t++)ht(i[t],!1),lt(i[t]);else null!=i&&(ht(i,!1),lt(i));else ht(this,t)}const ut=t=>{t.type==P&&(t._$AP??=dt,t._$AQ??=at)};class $t extends R{constructor(){super(...arguments),this._$AN=void 0}_$AT(t,e,s){super._$AT(t,e,s),ct(this),this.isConnected=t._$AU}_$AO(t,e=!0){t!==this.isConnected&&(this.isConnected=t,t?this.reconnected?.():this.disconnected?.()),e&&(ht(this,t),lt(this))}setValue(t){if(z(this._$Ct))this._$Ct._$AI(t,this);else{const e=[...this._$Ct._$AH];e[this._$Ci]=t,this._$Ct._$AI(e,this,0)}}disconnected(){}reconnected(){}} /** * @license * Copyright 2021 Google LLC * SPDX-License-Identifier: BSD-3-Clause */class _t{constructor(t){this.G=t}disconnect(){this.G=void 0}reconnect(t){this.G=t}deref(){return this.G}}class At{constructor(){this.Y=void 0,this.Z=void 0}get(){return this.Y}pause(){this.Y??=new Promise(t=>this.Z=t)}resume(){this.Z?.(),this.Y=this.Z=void 0}} /** * @license * Copyright 2017 Google LLC * SPDX-License-Identifier: BSD-3-Clause */const ft=t=>!(t=>null===t||"object"!=typeof t&&"function"!=typeof t)(t)&&"function"==typeof t.then,pt=1073741823;class vt extends $t{constructor(){super(...arguments),this._$Cwt=pt,this._$Cbt=[],this._$CK=new _t(this),this._$CX=new At}render(...t){return t.find(t=>!ft(t))??y}update(t,e){const s=this._$Cbt;let i=s.length;this._$Cbt=e;const n=this._$CK,r=this._$CX;this.isConnected||this.disconnected();for(let t=0;t<e.length&&!(t>this._$Cwt);t++){const o=e[t];if(!ft(o))return this._$Cwt=t,o;t<i&&o===s[t]||(this._$Cwt=pt,i=0,Promise.resolve(o).then(async t=>{for(;r.get();)await r.get();const e=n.deref();if(void 0!==e){const s=e._$Cbt.indexOf(o);s>-1&&s<e._$Cwt&&(e._$Cwt=s,e.setValue(t))}}))}return y}disconnected(){this._$CK.disconnect(),this._$CX.pause()}reconnected(){this._$CK.reconnect(this),this._$CX.resume()}}const gt=L(vt),yt=()=>new mt; /** * @license * Copyright 2020 Google LLC * SPDX-License-Identifier: BSD-3-Clause */class mt{}const bt=new WeakMap,Ct=L(class extends $t{render(t){return m}update(t,[e]){const s=e!==this.G;return s&&this.rt(void 0),(s||this.lt!==this.ct)&&(this.G=e,this.ht=t.options?.host,this.rt(this.ct=t.element)),m}rt(t){if(void 0!==this.G)if(this.isConnected||(t=void 0),"function"==typeof this.G){const e=this.ht??globalThis;let s=bt.get(e);void 0===s&&(s=new WeakMap,bt.set(e,s)),void 0!==s.get(this.G)&&this.G.call(this.ht,void 0),s.set(this.G,t),void 0!==t&&this.G.call(this.ht,t)}else this.G.value=t}get lt(){return"function"==typeof this.G?bt.get(this.ht??globalThis)?.get(this.G):this.G?.value}disconnected(){this.lt===this.ct&&this.rt(void 0)}reconnected(){this.rt(this.ct)}});export{rt as UnsafeHTMLDirective,vt as UntilDirective,W as classMap,yt as createRef,D as ifDefined,J as live,Ct as ref,et as repeat,nt as styleMap,ot as unsafeHTML,gt as until}; //# sourceMappingURL=directives.js.map