UNPKG

@sandlada/mdc

Version:

@sandlada/mdc is an open source component library that follows the Material Design 3 design specifications.

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