-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathhydration-support.min.js
More file actions
40 lines (35 loc) · 13.1 KB
/
hydration-support.min.js
File metadata and controls
40 lines (35 loc) · 13.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
"use strict";(()=>{var U=globalThis,I=U.trustedTypes,F=I?I.createPolicy("lit-html",{createHTML:s=>s}):void 0,L="$lit$",A=`lit$${Math.random().toFixed(9).slice(2)}$`,V="?"+A,lt=`<${V}>`,v=document,P=()=>v.createComment(""),E=s=>s===null||typeof s!="object"&&typeof s!="function",j=Array.isArray,q=s=>j(s)||typeof s?.[Symbol.iterator]=="function",D=`[
\f\r]`,H=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,G=/-->/g,Z=/>/g,f=RegExp(`>|${D}(?:([^\\s"'>=/]+)(${D}*=${D}*(?:[^
\f\r"'\`<>=]|("|')|))|$)`,"g"),Y=/'/g,z=/"/g,J=/^(?:script|style|textarea|title)$/i,k=s=>(t,...e)=>({_$litType$:s,strings:t,values:e}),mt=k(1),ft=k(2),gt=k(3),_=Symbol.for("lit-noChange"),p=Symbol.for("lit-nothing"),Q=new WeakMap,g=v.createTreeWalker(v,129);function K(s,t){if(!j(s)||!s.hasOwnProperty("raw"))throw Error("invalid template strings array");return F!==void 0?F.createHTML(t):t}var X=(s,t)=>{let e=s.length-1,r=[],i,o=t===2?"<svg>":t===3?"<math>":"",n=H;for(let h=0;h<e;h++){let a=s[h],l,d,c=-1,u=0;for(;u<a.length&&(n.lastIndex=u,d=n.exec(a),d!==null);)u=n.lastIndex,n===H?d[1]==="!--"?n=G:d[1]!==void 0?n=Z:d[2]!==void 0?(J.test(d[2])&&(i=RegExp("</"+d[2],"g")),n=f):d[3]!==void 0&&(n=f):n===f?d[0]===">"?(n=i??H,c=-1):d[1]===void 0?c=-2:(c=n.lastIndex-d[2].length,l=d[1],n=d[3]===void 0?f:d[3]==='"'?z:Y):n===z||n===Y?n=f:n===G||n===Z?n=H:(n=f,i=void 0);let m=n===f&&s[h+1].startsWith("/>")?" ":"";o+=n===H?a+lt:c>=0?(r.push(l),a.slice(0,c)+L+a.slice(c)+A+m):a+A+(c===-2?h:m)}return[K(s,o+(s[e]||"<?>")+(t===2?"</svg>":t===3?"</math>":"")),r]},w=class s{constructor({strings:t,_$litType$:e},r){let i;this.parts=[];let o=0,n=0,h=t.length-1,a=this.parts,[l,d]=X(t,e);if(this.el=s.createElement(l,r),g.currentNode=this.el.content,e===2||e===3){let c=this.el.content.firstChild;c.replaceWith(...c.childNodes)}for(;(i=g.nextNode())!==null&&a.length<h;){if(i.nodeType===1){if(i.hasAttributes())for(let c of i.getAttributeNames())if(c.endsWith(L)){let u=d[n++],m=i.getAttribute(c).split(A),R=/([.?@])?(.*)/.exec(u);a.push({type:1,index:o,name:R[2],strings:m,ctor:R[1]==="."?S:R[1]==="?"?M:R[1]==="@"?O:b}),i.removeAttribute(c)}else c.startsWith(A)&&(a.push({type:6,index:o}),i.removeAttribute(c));if(J.test(i.tagName)){let c=i.textContent.split(A),u=c.length-1;if(u>0){i.textContent=I?I.emptyScript:"";for(let m=0;m<u;m++)i.append(c[m],P()),g.nextNode(),a.push({type:2,index:++o});i.append(c[u],P())}}}else if(i.nodeType===8)if(i.data===V)a.push({type:2,index:o});else{let c=-1;for(;(c=i.data.indexOf(A,c+1))!==-1;)a.push({type:7,index:o}),c+=A.length-1}o++}}static createElement(t,e){let r=v.createElement("template");return r.innerHTML=t,r}};function y(s,t,e=s,r){if(t===_)return t;let i=r!==void 0?e._$Co?.[r]:e._$Cl,o=E(t)?void 0:t._$litDirective$;return i?.constructor!==o&&(i?._$AO?.(!1),o===void 0?i=void 0:(i=new o(s),i._$AT(s,e,r)),r!==void 0?(e._$Co??=[])[r]=i:e._$Cl=i),i!==void 0&&(t=y(s,i._$AS(s,t.values),i,r)),t}var N=class{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){let{el:{content:e},parts:r}=this._$AD,i=(t?.creationScope??v).importNode(e,!0);g.currentNode=i;let o=g.nextNode(),n=0,h=0,a=r[0];for(;a!==void 0;){if(n===a.index){let l;a.type===2?l=new x(o,o.nextSibling,this,t):a.type===1?l=new a.ctor(o,a.name,a.strings,this,t):a.type===6&&(l=new B(o,this,t)),this._$AV.push(l),a=r[++h]}n!==a?.index&&(o=g.nextNode(),n++)}return g.currentNode=v,i}p(t){let e=0;for(let r of this._$AV)r!==void 0&&(r.strings!==void 0?(r._$AI(t,r,e),e+=r.strings.length-2):r._$AI(t[e])),e++}},x=class s{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(t,e,r,i){this.type=2,this._$AH=p,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=r,this.options=i,this._$Cv=i?.isConnected??!0}get parentNode(){let t=this._$AA.parentNode,e=this._$AM;return e!==void 0&&t?.nodeType===11&&(t=e.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,e=this){t=y(this,t,e),E(t)?t===p||t==null||t===""?(this._$AH!==p&&this._$AR(),this._$AH=p):t!==this._$AH&&t!==_&&this._(t):t._$litType$!==void 0?this.$(t):t.nodeType!==void 0?this.T(t):q(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!==p&&E(this._$AH)?this._$AA.nextSibling.data=t:this.T(v.createTextNode(t)),this._$AH=t}$(t){let{values:e,_$litType$:r}=t,i=typeof r=="number"?this._$AC(t):(r.el===void 0&&(r.el=w.createElement(K(r.h,r.h[0]),this.options)),r);if(this._$AH?._$AD===i)this._$AH.p(e);else{let o=new N(i,this),n=o.u(this.options);o.p(e),this.T(n),this._$AH=o}}_$AC(t){let e=Q.get(t.strings);return e===void 0&&Q.set(t.strings,e=new w(t)),e}k(t){j(this._$AH)||(this._$AH=[],this._$AR());let e=this._$AH,r,i=0;for(let o of t)i===e.length?e.push(r=new s(this.O(P()),this.O(P()),this,this.options)):r=e[i],r._$AI(o),i++;i<e.length&&(this._$AR(r&&r._$AB.nextSibling,i),e.length=i)}_$AR(t=this._$AA.nextSibling,e){for(this._$AP?.(!1,!0,e);t&&t!==this._$AB;){let r=t.nextSibling;t.remove(),t=r}}setConnected(t){this._$AM===void 0&&(this._$Cv=t,this._$AP?.(t))}},b=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,e,r,i,o){this.type=1,this._$AH=p,this._$AN=void 0,this.element=t,this.name=e,this._$AM=i,this.options=o,r.length>2||r[0]!==""||r[1]!==""?(this._$AH=Array(r.length-1).fill(new String),this.strings=r):this._$AH=p}_$AI(t,e=this,r,i){let o=this.strings,n=!1;if(o===void 0)t=y(this,t,e,0),n=!E(t)||t!==this._$AH&&t!==_,n&&(this._$AH=t);else{let h=t,a,l;for(t=o[0],a=0;a<o.length-1;a++)l=y(this,h[r+a],e,a),l===_&&(l=this._$AH[a]),n||=!E(l)||l!==this._$AH[a],l===p?t=p:t!==p&&(t+=(l??"")+o[a+1]),this._$AH[a]=l}n&&!i&&this.j(t)}j(t){t===p?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}},S=class extends b{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===p?void 0:t}},M=class extends b{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==p)}},O=class extends b{constructor(t,e,r,i,o){super(t,e,r,i,o),this.type=5}_$AI(t,e=this){if((t=y(this,t,e,0)??p)===_)return;let r=this._$AH,i=t===p&&r!==p||t.capture!==r.capture||t.once!==r.once||t.passive!==r.passive,o=t!==p&&(r===p||i);i&&this.element.removeEventListener(this.name,this,r),o&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){typeof this._$AH=="function"?this._$AH.call(this.options?.host??this.element,t):this._$AH.handleEvent(t)}},B=class{constructor(t,e,r){this.element=t,this.type=6,this._$AN=void 0,this._$AM=e,this.options=r}get _$AU(){return this._$AM._$AU}_$AI(t){y(this,t)}},$={M:L,P:A,A:V,C:1,L:X,R:N,D:q,V:y,I:x,H:b,N:M,U:O,B:S,F:B},ht=U.litHtmlPolyfillSupport;ht?.(w,x),(U.litHtmlVersions??=[]).push("3.2.1");var tt=(s,t,e)=>{let r=e?.renderBefore??t,i=r._$litPart$;if(i===void 0){let o=e?.renderBefore??null;r._$litPart$=i=new x(t.insertBefore(P(),o),o,void 0,e??{})}return i._$AI(s),i};var W=null,et={boundAttributeSuffix:$.M,marker:$.P,markerMatch:$.A,HTML_RESULT:$.C,getTemplateHtml:$.L,overrideDirectiveResolve:(s,t)=>class extends s{_$AS(e,r){return t(this,r)}},patchDirectiveResolve:(s,t)=>{if(s.prototype._$AS!==t){W??=s.prototype._$AS.name;for(let e=s.prototype;e!==Object.prototype;e=Object.getPrototypeOf(e))if(e.hasOwnProperty(W))return void(e[W]=t);throw Error("Internal error: It is possible that both dev mode and production mode Lit was mixed together during SSR. Please comment on the issue: https://github.com/lit/lit/issues/4527")}},setDirectiveClass(s,t){s._$litDirective$=t},getAttributePartCommittedValue:(s,t,e)=>{let r=_;return s.j=i=>r=i,s._$AI(t,s,e),r},connectedDisconnectable:s=>({...s,_$AU:!0}),resolveDirective:$.V,AttributePart:$.H,PropertyPart:$.B,BooleanAttributePart:$.N,EventPart:$.U,ElementPart:$.F,TemplateInstance:$.R,isIterable:$.D,ChildPart:$.I};var T={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6};var{I:Pt}=$,it=s=>s===null||typeof s!="object"&&typeof s!="function";var rt=(s,t)=>t===void 0?s?._$litType$!==void 0:s?._$litType$===t,st=s=>s?._$litType$?.h!=null;var nt=s=>s.strings===void 0;var{TemplateInstance:ct,isIterable:dt,resolveDirective:ot,ChildPart:C,ElementPart:pt}=et,at=(s,t,e={})=>{if(t._$litPart$!==void 0)throw Error("container already contains a live render");let r,i,o,n=[],h=document.createTreeWalker(t,NodeFilter.SHOW_COMMENT),a;for(;(a=h.nextNode())!==null;){let l=a.data;if(l.startsWith("lit-part")){if(n.length===0&&r!==void 0)throw Error(`There must be only one root part per container. Found a part marker (${a}) when we already have a root part marker (${i})`);o=$t(s,a,n,e),r===void 0&&(r=o),i??=a}else if(l.startsWith("lit-node"))At(a,n,e);else if(l.startsWith("/lit-part")){if(n.length===1&&o!==r)throw Error("internal error");o=ut(a,o,n)}}if(r===void 0){let l=t instanceof ShadowRoot?"{container.host.localName}'s shadow root":t instanceof DocumentFragment?"DocumentFragment":t.localName;console.error(`There should be exactly one root part in a render container, but we didn't find any in ${l}.`)}t._$litPart$=r},$t=(s,t,e,r)=>{let i,o;if(e.length===0)o=new C(t,null,void 0,r),i=s;else{let n=e[e.length-1];if(n.type==="template-instance")o=new C(t,null,n.instance,r),n.instance._$AV.push(o),i=n.result.values[n.instancePartIndex++],n.templatePartIndex++;else if(n.type==="iterable"){o=new C(t,null,n.part,r);let h=n.iterator.next();if(h.done)throw i=void 0,n.done=!0,Error("Unhandled shorter than expected iterable");i=h.value,n.part._$AH.push(o)}else o=new C(t,null,n.part,r)}if(i=ot(o,i),i===_)e.push({part:o,type:"leaf"});else if(it(i))e.push({part:o,type:"leaf"}),o._$AH=i;else if(rt(i)){if(st(i))throw Error("compiled templates are not supported");let n="lit-part "+_t(i);if(t.data!==n)throw Error("Hydration value mismatch: Unexpected TemplateResult rendered to part");{let h=C.prototype._$AC(i),a=new ct(h,o);e.push({type:"template-instance",instance:a,part:o,templatePartIndex:0,instancePartIndex:0,result:i}),o._$AH=a}}else dt(i)?(e.push({part:o,type:"iterable",value:i,iterator:i[Symbol.iterator](),done:!1}),o._$AH=[]):(e.push({part:o,type:"leaf"}),o._$AH=i??"");return o},ut=(s,t,e)=>{if(t===void 0)throw Error("unbalanced part marker");t._$AB=s;let r=e.pop();if(r.type==="iterable"&&!r.iterator.next().done)throw Error("unexpected longer than expected iterable");if(e.length>0)return e[e.length-1].part},At=(s,t,e)=>{let r=/lit-node (\d+)/.exec(s.data),i=parseInt(r[1]),o=s.nextElementSibling;if(o===null)throw Error("could not find node for attribute parts");o.removeAttribute("defer-hydration");let n=t[t.length-1];if(n.type!=="template-instance")throw Error("Hydration value mismatch: Primitive found where TemplateResult expected. This usually occurs due to conditional rendering that resulted in a different value or template being rendered between the server and client.");{let h=n.instance;for(;;){let a=h._$AD.parts[n.templatePartIndex];if(a===void 0||a.type!==T.ATTRIBUTE&&a.type!==T.ELEMENT||a.index!==i)break;if(a.type===T.ATTRIBUTE){let l=new a.ctor(o,a.name,a.strings,n.instance,e),d=nt(l)?n.result.values[n.instancePartIndex]:n.result.values,c=!(l.type===T.EVENT||l.type===T.PROPERTY);l._$AI(d,l,n.instancePartIndex,c),n.instancePartIndex+=a.strings.length-1,h._$AV.push(l)}else{let l=new pt(o,n.instance,e);ot(l,n.result.values[n.instancePartIndex++]),h._$AV.push(l)}n.templatePartIndex++}}},_t=s=>{let t=new Uint32Array(2).fill(5381);for(let r of s.strings)for(let i=0;i<r.length;i++)t[i%2]=33*t[i%2]^r.charCodeAt(i);let e=String.fromCharCode(...new Uint8Array(t.buffer));return btoa(e)};globalThis.litElementHydrateSupport=({LitElement:s})=>{let t=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(s),"observedAttributes").get;Object.defineProperty(s,"observedAttributes",{get(){return[...t.call(this),"defer-hydration"]}});let e=s.prototype.attributeChangedCallback;s.prototype.attributeChangedCallback=function(n,h,a){n==="defer-hydration"&&a===null&&r.call(this),e.call(this,n,h,a)};let r=s.prototype.connectedCallback;s.prototype.connectedCallback=function(){this.hasAttribute("defer-hydration")||r.call(this)};let i=s.prototype.createRenderRoot;s.prototype.createRenderRoot=function(){return this.shadowRoot?(this._$AG=!0,this.shadowRoot):i.call(this)};let o=Object.getPrototypeOf(s.prototype).update;s.prototype.update=function(n){let h=this.render();if(o.call(this,n),this._$AG){this._$AG=!1;for(let a=0;a<this.attributes.length;a++){let l=this.attributes[a];if(l.name.startsWith("hydrate-internals-")){let d=l.name.slice(18);this.removeAttribute(d),this.removeAttribute(l.name)}}at(h,this.renderRoot,this.renderOptions)}else tt(h,this.renderRoot,this.renderOptions)}};})();
/*! Bundled license information:
lit-html/lit-html.js:
(**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*)
lit-html/private-ssr-support.js:
(**
* @license
* Copyright 2019 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*)
lit-html/directive.js:
(**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*)
lit-html/directive-helpers.js:
(**
* @license
* Copyright 2020 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*)
@lit-labs/ssr-client/lib/hydrate-lit-html.js:
(**
* @license
* Copyright 2019 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*)
*/