UNPKG

bulib-wc

Version:

collection of web components and styles used at Boston University Libraries

593 lines 122 kB
import{TemplateResult as TemplateResult$1}from"lit-html";/** * @license * Copyright (c) 2018 The Polymer Project Authors. All rights reserved. * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt * Code distributed by Google as part of the polymer project is also * subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */(function(){function e(){window.WebComponents.ready=!0,document.dispatchEvent(new CustomEvent("WebComponentsReady",{bubbles:!0}))}function t(){window.customElements&&customElements.polyfillWrapFlushCallback&&customElements.polyfillWrapFlushCallback(function(e){i=e,l&&i()})}function r(){t(),n()}function n(){window.HTMLTemplateElement&&HTMLTemplateElement.bootstrap&&HTMLTemplateElement.bootstrap(window.document),a=!0,s().then(e)}function s(){l=!1;var e=o.map(function(e){return e instanceof Function?e():e});return o=[],Promise.all(e).then(function(){l=!0,i&&i()}).catch(function(e){console.error(e)})}/** * Basic flow of the loader process * * There are 4 flows the loader can take when booting up * * - Synchronous script, no polyfills needed * - wait for `DOMContentLoaded` * - fire WCR event, as there could not be any callbacks passed to `waitFor` * * - Synchronous script, polyfills needed * - document.write the polyfill bundle * - wait on the `load` event of the bundle to batch Custom Element upgrades * - wait for `DOMContentLoaded` * - run callbacks passed to `waitFor` * - fire WCR event * * - Asynchronous script, no polyfills needed * - wait for `DOMContentLoaded` * - run callbacks passed to `waitFor` * - fire WCR event * * - Asynchronous script, polyfills needed * - Append the polyfill bundle script * - wait for `load` event of the bundle * - batch Custom Element Upgrades * - run callbacks pass to `waitFor` * - fire WCR event */var i,a=!1,o=[],l=!1;window.WebComponents=window.WebComponents||{},window.WebComponents.ready=window.WebComponents.ready||!1,window.WebComponents.waitFor=window.WebComponents.waitFor||function(e){e&&(o.push(e),a&&s())},window.WebComponents._batchCustomElements=t;var d=[];// Feature detect which polyfill needs to be imported. (!("attachShadow"in Element.prototype&&"getRootNode"in Element.prototype)||window.ShadyDOM&&window.ShadyDOM.force)&&d.push("sd"),(!window.customElements||window.customElements.forcePolyfill)&&d.push("ce");var u=function(){// no real <template> because no `content` property (IE and older browsers) var e=document.createElement("template");if(!("content"in e))return!0;// broken doc fragment (older Edge) if(!(e.content.cloneNode()instanceof DocumentFragment))return!0;// broken <template> cloning (Edge up to at least version 17) var t=document.createElement("template");t.content.appendChild(document.createElement("div")),e.content.appendChild(t);var r=e.cloneNode(!0);return 0===r.content.childNodes.length||0===r.content.firstChild.content.childNodes.length}();// NOTE: any browser that does not have template or ES6 features // must load the full suite of polyfills. if(window.Promise&&Array.from&&window.URL&&window.Symbol&&!u||(d=["sd-ce-pf"]),d.length){var c,p="bundles/webcomponents-"+d.join("-")+".js";// Load it from the right place. if(window.WebComponents.root)c=window.WebComponents.root+p;else{var h=document.querySelector("script[src*=\"webcomponents-loader.js\"]");// Load it from the right place. c=h.src.replace("webcomponents-loader.js",p)}var b=document.createElement("script");b.src=c,"loading"===document.readyState?(b.setAttribute("onload","window.WebComponents._batchCustomElements()"),document.write(b.outerHTML),document.addEventListener("DOMContentLoaded",n)):(b.addEventListener("load",function(){r()}),b.addEventListener("error",function(){throw new Error("Could not load polyfill bundle"+c)}),document.head.appendChild(b))}else"complete"===document.readyState?(a=!0,e()):(window.addEventListener("load",n),window.addEventListener("DOMContentLoaded",function(){window.removeEventListener("load",n),n()}))})(),WebComponents.waitFor(function(){Promise.resolve().then(function(){return bulibFeedback}),Promise.resolve().then(function(){return bulibAnnounce}),Promise.resolve().then(function(){return bulibCard}),Promise.resolve().then(function(){return bulibHours}),Promise.resolve().then(function(){return bulibSearch}),Promise.resolve().then(function(){return bulibColor}),Promise.resolve().then(function(){return bulibLocoso}),Promise.resolve().then(function(){return bulibSubmenu}),Promise.resolve().then(function(){return bulibFooter}),Promise.resolve().then(function(){return bulibPromo})});/** * @license * Copyright (c) 2017 The Polymer Project Authors. All rights reserved. * This code may only be used under the BSD style license found at * http://polymer.github.io/LICENSE.txt * The complete set of authors may be found at * http://polymer.github.io/AUTHORS.txt * The complete set of contributors may be found at * http://polymer.github.io/CONTRIBUTORS.txt * Code distributed by Google as part of the polymer project is also * subject to an additional IP rights grant found at * http://polymer.github.io/PATENTS.txt */ /** * True if the custom elements polyfill is in use. */const isCEPolyfill=window.customElements!==void 0&&window.customElements.polyfillWrapFlushCallback!==void 0,removeNodes=(e,t,r=null)=>{for(;t!==r;){const r=t.nextSibling;e.removeChild(t),t=r}},marker=`{{lit-${(Math.random()+"").slice(2)}}}`,nodeMarker=`<!--${marker}-->`,markerRegex=new RegExp(`${marker}|${nodeMarker}`),boundAttributeSuffix="$lit$";/** * Removes nodes, starting from `start` (inclusive) to `end` (exclusive), from * `container`. */ /** * An updateable Template that tracks the location of dynamic parts. */class Template{constructor(e,t){this.parts=[],this.element=t;const r=[],n=[],s=document.createTreeWalker(t.content,133/* NodeFilter.SHOW_{ELEMENT|COMMENT|TEXT} */,null,!1);// Keeps track of the last index associated with a part. We try to delete // unnecessary nodes, but we never want to associate two different parts // to the same index. They must have a constant node between. let i=0,a=-1,o=0;for(const{strings:l,values:{length:d}}=e;o<d;){const e=s.nextNode();if(null===e){s.currentNode=n.pop();continue}if(a++,1===e.nodeType/* Node.ELEMENT_NODE */){if(e.hasAttributes()){const t=e.attributes,{length:r}=t;// Per // https://developer.mozilla.org/en-US/docs/Web/API/NamedNodeMap, // attributes are not guaranteed to be returned in document order. // In particular, Edge/IE can return them out of order, so we cannot // assume a correspondence between part index and attribute index. let n=0;for(let e=0;e<r;e++)endsWith(t[e].name,boundAttributeSuffix)&&n++;for(;0<n--;){// Get the template literal section leading up to the first // expression in this attribute const t=l[o],r=lastAttributeNameRegex.exec(t)[2],n=r.toLowerCase()+boundAttributeSuffix,s=e.getAttribute(n);// Find the attribute name e.removeAttribute(n);const i=s.split(markerRegex);this.parts.push({type:"attribute",index:a,name:r,strings:i}),o+=i.length-1}}"TEMPLATE"===e.tagName&&(n.push(e),s.currentNode=e.content)}else if(3===e.nodeType/* Node.TEXT_NODE */){const t=e.data;if(0<=t.indexOf(marker)){const n=e.parentNode,l=t.split(markerRegex),d=l.length-1;// Generate a new text node for each literal section // These nodes are also used as the markers for node parts for(let t=0;t<d;t++){let r,i=l[t];if(""===i)r=createMarker();else{const e=lastAttributeNameRegex.exec(i);null!==e&&endsWith(e[2],boundAttributeSuffix)&&(i=i.slice(0,e.index)+e[1]+e[2].slice(0,-boundAttributeSuffix.length)+e[3]),r=document.createTextNode(i)}n.insertBefore(r,e),this.parts.push({type:"node",index:++a})}// If there's no text, we must insert a comment to mark our place. // Else, we can trust it will stick around after cloning. ""===l[d]?(n.insertBefore(createMarker(),e),r.push(e)):e.data=l[d],o+=d}}else if(8===e.nodeType/* Node.COMMENT_NODE */)if(e.data===marker){const t=e.parentNode;// Add a new marker node to be the startNode of the Part if any of // the following are true: // * We don't have a previousSibling // * The previousSibling is already the start of a previous part (null===e.previousSibling||a===i)&&(a++,t.insertBefore(createMarker(),e)),i=a,this.parts.push({type:"node",index:a}),null===e.nextSibling?e.data="":(r.push(e),a--),o++}else for(let t=-1;-1!==(t=e.data.indexOf(marker,t+1));)// Comment node has a binding marker inside, make an inactive part // The binding won't work, but subsequent bindings will // TODO (justinfagnani): consider whether it's even worth it to // make bindings in comments work this.parts.push({type:"node",index:-1}),o++}// Remove text binding nodes after the walk to not disturb the TreeWalker for(const s of r)s.parentNode.removeChild(s)}}const endsWith=(e,t)=>{const r=e.length-t.length;return 0<=r&&e.slice(r)===t},isTemplatePartActive=e=>-1!==e.index,createMarker=()=>document.createComment(""),lastAttributeNameRegex=/([ \x09\x0a\x0c\x0d])([^\0-\x1F\x7F-\x9F "'>=/]+)([ \x09\x0a\x0c\x0d]*=[ \x09\x0a\x0c\x0d]*(?:[^ \x09\x0a\x0c\x0d"'`<>=]*|"[^"]*|'[^']*))$/,walkerNodeFilter=133/* NodeFilter.SHOW_{ELEMENT|COMMENT|TEXT} */;/** * Removes the list of nodes from a Template safely. In addition to removing * nodes from the Template, the Template part indices are updated to match * the mutated Template DOM. * * As the template is walked the removal state is tracked and * part indices are adjusted as needed. * * div * div#1 (remove) <-- start removing (removing node is div#1) * div * div#2 (remove) <-- continue removing (removing node is still div#1) * div * div <-- stop removing since previous sibling is the removing node (div#1, * removed 4 nodes) */function removeNodesFromTemplate(e,t){const{element:{content:n},parts:r}=e,s=document.createTreeWalker(n,walkerNodeFilter,null,!1);let i=nextActiveIndexInTemplateParts(r),a=r[i],o=-1,l=0;const d=[];for(let n=null;s.nextNode();){o++;const e=s.currentNode;// End removal if stepped past the removing node for(e.previousSibling===n&&(n=null),t.has(e)&&(d.push(e),null===n&&(n=e)),null!==n&&l++;a!==void 0&&a.index===o;)// If part is in a removed node deactivate it by setting index to -1 or // adjust the index as needed. // go to the next active part. a.index=null===n?a.index-l:-1,i=nextActiveIndexInTemplateParts(r,i),a=r[i]}d.forEach(e=>e.parentNode.removeChild(e))}const countNodes=e=>{let t=11===e.nodeType/* Node.DOCUMENT_FRAGMENT_NODE */?0:1;for(const r=document.createTreeWalker(e,walkerNodeFilter,null,!1);r.nextNode();)t++;return t},nextActiveIndexInTemplateParts=(e,t=-1)=>{for(let r=t+1;r<e.length;r++){const t=e[r];if(isTemplatePartActive(t))return r}return-1};/** * Inserts the given node into the Template, optionally before the given * refNode. In addition to inserting the node into the Template, the Template * part indices are updated to match the mutated Template DOM. */function insertNodeIntoTemplate(e,t,r=null){const{element:{content:s},parts:n}=e;// If there's no refNode, then put node at end of template. // No part indices need to be shifted in this case. if(null===r||void 0===r)return void s.appendChild(t);const i=document.createTreeWalker(s,walkerNodeFilter,null,!1);let a=nextActiveIndexInTemplateParts(n),o=0,l=-1;for(;i.nextNode();){l++;const e=i.currentNode;for(e===r&&(o=countNodes(t),r.parentNode.insertBefore(t,r));-1!==a&&n[a].index===l;){// If we've inserted the node, simply adjust all subsequent parts if(0<o){for(;-1!==a;)n[a].index+=o,a=nextActiveIndexInTemplateParts(n,a);return}a=nextActiveIndexInTemplateParts(n,a)}}}/** * @license * Copyright (c) 2017 The Polymer Project Authors. All rights reserved. * This code may only be used under the BSD style license found at * http://polymer.github.io/LICENSE.txt * The complete set of authors may be found at * http://polymer.github.io/AUTHORS.txt * The complete set of contributors may be found at * http://polymer.github.io/CONTRIBUTORS.txt * Code distributed by Google as part of the polymer project is also * subject to an additional IP rights grant found at * http://polymer.github.io/PATENTS.txt */const directives=new WeakMap,directive=e=>(...t)=>{const r=e(...t);return directives.set(r,!0),r},isDirective=e=>"function"==typeof e&&directives.has(e),noChange={},nothing={};/** * Brands a function as a directive factory function so that lit-html will call * the function during template rendering, rather than passing as a value. * * A _directive_ is a function that takes a Part as an argument. It has the * signature: `(part: Part) => void`. * * A directive _factory_ is a function that takes arguments for data and * configuration and returns a directive. Users of directive usually refer to * the directive factory as the directive. For example, "The repeat directive". * * Usually a template author will invoke a directive factory in their template * with relevant arguments, which will then return a directive function. * * Here's an example of using the `repeat()` directive factory that takes an * array and a function to render an item: * * ```js * html`<ul><${repeat(items, (item) => html`<li>${item}</li>`)}</ul>` * ``` * * When `repeat` is invoked, it returns a directive function that closes over * `items` and the template function. When the outer template is rendered, the * return directive function is called with the Part for the expression. * `repeat` then performs it's custom logic to render multiple items. * * @param f The directive factory function. Must be a function that returns a * function of the signature `(part: Part) => void`. The returned function will * be called with the part object. * * @example * * import {directive, html} from 'lit-html'; * * const immutable = directive((v) => (part) => { * if (part.value !== v) { * part.setValue(v) * } * }); */ /** * @license * Copyright (c) 2017 The Polymer Project Authors. All rights reserved. * This code may only be used under the BSD style license found at * http://polymer.github.io/LICENSE.txt * The complete set of authors may be found at * http://polymer.github.io/AUTHORS.txt * The complete set of contributors may be found at * http://polymer.github.io/CONTRIBUTORS.txt * Code distributed by Google as part of the polymer project is also * subject to an additional IP rights grant found at * http://polymer.github.io/PATENTS.txt */ /** * An instance of a `Template` that can be attached to the DOM and updated * with new values. */class TemplateInstance{constructor(e,t,r){this.__parts=[],this.template=e,this.processor=t,this.options=r}update(e){let t=0;for(const r of this.__parts)void 0!==r&&r.setValue(e[t]),t++;for(const t of this.__parts)void 0!==t&&t.commit()}_clone(){// There are a number of steps in the lifecycle of a template instance's // DOM fragment: // 1. Clone - create the instance fragment // 2. Adopt - adopt into the main document // 3. Process - find part markers and create parts // 4. Upgrade - upgrade custom elements // 5. Update - set node, attribute, property, etc., values // 6. Connect - connect to the document. Optional and outside of this // method. // // We have a few constraints on the ordering of these steps: // * We need to upgrade before updating, so that property values will pass // through any property setters. // * We would like to process before upgrading so that we're sure that the // cloned fragment is inert and not disturbed by self-modifying DOM. // * We want custom elements to upgrade even in disconnected fragments. // // Given these constraints, with full custom elements support we would // prefer the order: Clone, Process, Adopt, Upgrade, Update, Connect // // But Safari dooes not implement CustomElementRegistry#upgrade, so we // can not implement that order and still have upgrade-before-update and // upgrade disconnected fragments. So we instead sacrifice the // process-before-upgrade constraint, since in Custom Elements v1 elements // must not modify their light DOM in the constructor. We still have issues // when co-existing with CEv0 elements like Polymer 1, and with polyfills // that don't strictly adhere to the no-modification rule because shadow // DOM, which may be created in the constructor, is emulated by being placed // in the light DOM. // // The resulting order is on native is: Clone, Adopt, Upgrade, Process, // Update, Connect. document.importNode() performs Clone, Adopt, and Upgrade // in one step. // // The Custom Elements v1 polyfill supports upgrade(), so the order when // polyfilled is the more ideal: Clone, Process, Adopt, Upgrade, Update, // Connect. const e=isCEPolyfill?this.template.element.content.cloneNode(!0):document.importNode(this.template.element.content,!0),t=[],r=this.template.parts,n=document.createTreeWalker(e,133/* NodeFilter.SHOW_{ELEMENT|COMMENT|TEXT} */,null,!1);let s,i=0,a=0,o=n.nextNode();// Loop through all the nodes and parts of a template for(;i<r.length;){if(s=r[i],!isTemplatePartActive(s)){this.__parts.push(void 0),i++;continue}// Progress the tree walker until we find our next part's node. // Note that multiple parts may share the same node (attribute parts // on a single element), so this loop may not run at all. for(;a<s.index;)a++,"TEMPLATE"===o.nodeName&&(t.push(o),n.currentNode=o.content),null===(o=n.nextNode())&&(n.currentNode=t.pop(),o=n.nextNode());// We've arrived at our part's node. if("node"===s.type){const e=this.processor.handleTextExpression(this.options);e.insertAfterNode(o.previousSibling),this.__parts.push(e)}else this.__parts.push(...this.processor.handleAttributeExpressions(o,s.name,s.strings,this.options));i++}return isCEPolyfill&&(document.adoptNode(e),customElements.upgrade(e)),e}}/** * @license * Copyright (c) 2017 The Polymer Project Authors. All rights reserved. * This code may only be used under the BSD style license found at * http://polymer.github.io/LICENSE.txt * The complete set of authors may be found at * http://polymer.github.io/AUTHORS.txt * The complete set of contributors may be found at * http://polymer.github.io/CONTRIBUTORS.txt * Code distributed by Google as part of the polymer project is also * subject to an additional IP rights grant found at * http://polymer.github.io/PATENTS.txt */const commentMarker=` ${marker} `;/** * The return type of `html`, which holds a Template and the values from * interpolated expressions. */class TemplateResult{constructor(e,t,r,n){this.strings=e,this.values=t,this.type=r,this.processor=n}/** * Returns a string of HTML used to create a `<template>` element. */getHTML(){const e=this.strings.length-1;let t="",r=!1;for(let n=0;n<e;n++){const e=this.strings[n],s=e.lastIndexOf("<!--");// For each binding we want to determine the kind of marker to insert // into the template source before it's parsed by the browser's HTML // parser. The marker type is based on whether the expression is in an // attribute, text, or comment poisition. // * For node-position bindings we insert a comment with the marker // sentinel as its text content, like <!--{{lit-guid}}-->. // * For attribute bindings we insert just the marker sentinel for the // first binding, so that we support unquoted attribute bindings. // Subsequent bindings can use a comment marker because multi-binding // attributes must be quoted. // * For comment bindings we insert just the marker sentinel so we don't // close the comment. // // The following code scans the template source, but is *not* an HTML // parser. We don't need to track the tree structure of the HTML, only // whether a binding is inside a comment, and if not, if it appears to be // the first binding in an attribute. r=(-1<s||r)&&-1===e.indexOf("-->",s+1);// Check to see if we have an attribute-like sequence preceeding the // expression. This can match "name=value" like structures in text, // comments, and attribute values, so there can be false-positives. const i=lastAttributeNameRegex.exec(e);t+=null===i?e+(r?commentMarker:nodeMarker):e.substr(0,i.index)+i[1]+i[2]+boundAttributeSuffix+i[3]+marker}return t+=this.strings[e],t}getTemplateElement(){const e=document.createElement("template");return e.innerHTML=this.getHTML(),e}}/** * @license * Copyright (c) 2017 The Polymer Project Authors. All rights reserved. * This code may only be used under the BSD style license found at * http://polymer.github.io/LICENSE.txt * The complete set of authors may be found at * http://polymer.github.io/AUTHORS.txt * The complete set of contributors may be found at * http://polymer.github.io/CONTRIBUTORS.txt * Code distributed by Google as part of the polymer project is also * subject to an additional IP rights grant found at * http://polymer.github.io/PATENTS.txt */const isPrimitive=e=>null===e||"object"!=typeof e&&"function"!=typeof e,isIterable=e=>Array.isArray(e)||// tslint:disable-next-line:no-any !!(e&&e[Symbol.iterator]);/** * Writes attribute values to the DOM for a group of AttributeParts bound to a * single attibute. The value is only set once even if there are multiple parts * for an attribute. */class AttributeCommitter{constructor(e,t,r){this.dirty=!0,this.element=e,this.name=t,this.strings=r,this.parts=[];for(let n=0;n<r.length-1;n++)this.parts[n]=this._createPart()}/** * Creates a single part. Override this to create a differnt type of part. */_createPart(){return new AttributePart(this)}_getValue(){const e=this.strings,t=e.length-1;let r="";for(let n=0;n<t;n++){r+=e[n];const t=this.parts[n];if(void 0!==t){const e=t.value;if(isPrimitive(e)||!isIterable(e))r+="string"==typeof e?e:e+"";else for(const n of e)r+="string"==typeof n?n:n+""}}return r+=e[t],r}commit(){this.dirty&&(this.dirty=!1,this.element.setAttribute(this.name,this._getValue()))}}/** * A Part that controls all or part of an attribute value. */class AttributePart{constructor(e){this.value=void 0,this.committer=e}setValue(e){e===noChange||isPrimitive(e)&&e===this.value||(this.value=e,!isDirective(e)&&(this.committer.dirty=!0))}commit(){for(;isDirective(this.value);){const e=this.value;this.value=noChange,e(this)}this.value===noChange||this.committer.commit()}}/** * A Part that controls a location within a Node tree. Like a Range, NodePart * has start and end locations and can set and update the Nodes between those * locations. * * NodeParts support several value types: primitives, Nodes, TemplateResults, * as well as arrays and iterables of those types. */class NodePart{constructor(e){this.value=void 0,this.__pendingValue=void 0,this.options=e}/** * Appends this part into a container. * * This part must be empty, as its contents are not automatically moved. */appendInto(e){this.startNode=e.appendChild(createMarker()),this.endNode=e.appendChild(createMarker())}/** * Inserts this part after the `ref` node (between `ref` and `ref`'s next * sibling). Both `ref` and its next sibling must be static, unchanging nodes * such as those that appear in a literal section of a template. * * This part must be empty, as its contents are not automatically moved. */insertAfterNode(e){this.startNode=e,this.endNode=e.nextSibling}/** * Appends this part into a parent part. * * This part must be empty, as its contents are not automatically moved. */appendIntoPart(e){e.__insert(this.startNode=createMarker()),e.__insert(this.endNode=createMarker())}/** * Inserts this part after the `ref` part. * * This part must be empty, as its contents are not automatically moved. */insertAfterPart(e){e.__insert(this.startNode=createMarker()),this.endNode=e.endNode,e.endNode=this.startNode}setValue(e){this.__pendingValue=e}commit(){for(;isDirective(this.__pendingValue);){const e=this.__pendingValue;this.__pendingValue=noChange,e(this)}const e=this.__pendingValue;e===noChange||(isPrimitive(e)?e!==this.value&&this.__commitText(e):e instanceof TemplateResult?this.__commitTemplateResult(e):e instanceof Node?this.__commitNode(e):isIterable(e)?this.__commitIterable(e):e===nothing?(this.value=nothing,this.clear()):this.__commitText(e))}__insert(e){this.endNode.parentNode.insertBefore(e,this.endNode)}__commitNode(e){this.value===e||(this.clear(),this.__insert(e),this.value=e)}__commitText(e){const t=this.startNode.nextSibling;e=null==e?"":e;// If `value` isn't already a string, we explicitly convert it here in case // it can't be implicitly converted - i.e. it's a symbol. const r="string"==typeof e?e:e+"";t===this.endNode.previousSibling&&3===t.nodeType/* Node.TEXT_NODE */?t.data=r:this.__commitNode(document.createTextNode(r)),this.value=e}__commitTemplateResult(e){const t=this.options.templateFactory(e);if(this.value instanceof TemplateInstance&&this.value.template===t)this.value.update(e.values);else{// Make sure we propagate the template processor from the TemplateResult // so that we use its syntax extension, etc. The template factory comes // from the render function options so that it can control template // caching and preprocessing. const r=new TemplateInstance(t,e.processor,this.options),n=r._clone();r.update(e.values),this.__commitNode(n),this.value=r}}__commitIterable(e){Array.isArray(this.value)||(this.value=[],this.clear());// Lets us keep track of how many items we stamped so we can clear leftover // items from a previous render const t=this.value;let r,n=0;for(const s of e)// Try to reuse an existing part r=t[n],void 0===r&&(r=new NodePart(this.options),t.push(r),0===n?r.appendIntoPart(this):r.insertAfterPart(t[n-1])),r.setValue(s),r.commit(),n++;n<t.length&&(t.length=n,this.clear(r&&r.endNode))}clear(e=this.startNode){removeNodes(this.startNode.parentNode,e.nextSibling,this.endNode)}}/** * Implements a boolean attribute, roughly as defined in the HTML * specification. * * If the value is truthy, then the attribute is present with a value of * ''. If the value is falsey, the attribute is removed. */class BooleanAttributePart{constructor(e,t,r){if(this.value=void 0,this.__pendingValue=void 0,2!==r.length||""!==r[0]||""!==r[1])throw new Error("Boolean attributes can only contain a single expression");this.element=e,this.name=t,this.strings=r}setValue(e){this.__pendingValue=e}commit(){for(;isDirective(this.__pendingValue);){const e=this.__pendingValue;this.__pendingValue=noChange,e(this)}if(this.__pendingValue!==noChange){const e=!!this.__pendingValue;this.value!==e&&(e?this.element.setAttribute(this.name,""):this.element.removeAttribute(this.name),this.value=e),this.__pendingValue=noChange}}}/** * Sets attribute values for PropertyParts, so that the value is only set once * even if there are multiple parts for a property. * * If an expression controls the whole property value, then the value is simply * assigned to the property under control. If there are string literals or * multiple expressions, then the strings are expressions are interpolated into * a string first. */class PropertyCommitter extends AttributeCommitter{constructor(e,t,r){super(e,t,r),this.single=2===r.length&&""===r[0]&&""===r[1]}_createPart(){return new PropertyPart(this)}_getValue(){return this.single?this.parts[0].value:super._getValue()}commit(){this.dirty&&(this.dirty=!1,this.element[this.name]=this._getValue())}}class PropertyPart extends AttributePart{}// Detect event listener options support. If the `capture` property is read // from the options object, then options are supported. If not, then the thrid // argument to add/removeEventListener is interpreted as the boolean capture // value so we should only pass the `capture` property. let eventOptionsSupported=!1;try{const e={get capture(){return eventOptionsSupported=!0,!1}};// tslint:disable-next-line:no-any // tslint:disable-next-line:no-any window.addEventListener("test",e,e),window.removeEventListener("test",e,e)}catch(e){}class EventPart{constructor(e,t,r){this.value=void 0,this.__pendingValue=void 0,this.element=e,this.eventName=t,this.eventContext=r,this.__boundHandleEvent=t=>this.handleEvent(t)}setValue(e){this.__pendingValue=e}commit(){for(;isDirective(this.__pendingValue);){const e=this.__pendingValue;this.__pendingValue=noChange,e(this)}if(this.__pendingValue===noChange)return;const e=this.__pendingValue,t=this.value,r=null==e||null!=t&&(e.capture!==t.capture||e.once!==t.once||e.passive!==t.passive);r&&this.element.removeEventListener(this.eventName,this.__boundHandleEvent,this.__options),null!=e&&(null==t||r)&&(this.__options=getOptions(e),this.element.addEventListener(this.eventName,this.__boundHandleEvent,this.__options)),this.value=e,this.__pendingValue=noChange}handleEvent(e){"function"==typeof this.value?this.value.call(this.eventContext||this.element,e):this.value.handleEvent(e)}}// We copy options because of the inconsistent behavior of browsers when reading // the third argument of add/removeEventListener. IE11 doesn't support options // at all. Chrome 41 only reads `capture` if the argument is an object. const getOptions=e=>e&&(eventOptionsSupported?{capture:e.capture,passive:e.passive,once:e.once}:e.capture);/** * @license * Copyright (c) 2017 The Polymer Project Authors. All rights reserved. * This code may only be used under the BSD style license found at * http://polymer.github.io/LICENSE.txt * The complete set of authors may be found at * http://polymer.github.io/AUTHORS.txt * The complete set of contributors may be found at * http://polymer.github.io/CONTRIBUTORS.txt * Code distributed by Google as part of the polymer project is also * subject to an additional IP rights grant found at * http://polymer.github.io/PATENTS.txt */ /** * The default TemplateFactory which caches Templates keyed on * result.type and result.strings. */function templateFactory(e){let t=templateCaches.get(e.type);void 0===t&&(t={stringsArray:new WeakMap,keyString:new Map},templateCaches.set(e.type,t));let r=t.stringsArray.get(e.strings);if(void 0!==r)return r;// If the TemplateStringsArray is new, generate a key from the strings // This key is shared between all templates with identical content const n=e.strings.join(marker);// Check if we already have a Template for this key return r=t.keyString.get(n),void 0===r&&(r=new Template(e,e.getTemplateElement()),t.keyString.set(n,r)),t.stringsArray.set(e.strings,r),r}const templateCaches=new Map,parts=new WeakMap,render=(e,t,r)=>{let n=parts.get(t);n===void 0&&(removeNodes(t,t.firstChild),parts.set(t,n=new NodePart(Object.assign({templateFactory},r))),n.appendInto(t)),n.setValue(e),n.commit()};/** * @license * Copyright (c) 2017 The Polymer Project Authors. All rights reserved. * This code may only be used under the BSD style license found at * http://polymer.github.io/LICENSE.txt * The complete set of authors may be found at * http://polymer.github.io/AUTHORS.txt * The complete set of contributors may be found at * http://polymer.github.io/CONTRIBUTORS.txt * Code distributed by Google as part of the polymer project is also * subject to an additional IP rights grant found at * http://polymer.github.io/PATENTS.txt */ /** * @license * Copyright (c) 2017 The Polymer Project Authors. All rights reserved. * This code may only be used under the BSD style license found at * http://polymer.github.io/LICENSE.txt * The complete set of authors may be found at * http://polymer.github.io/AUTHORS.txt * The complete set of contributors may be found at * http://polymer.github.io/CONTRIBUTORS.txt * Code distributed by Google as part of the polymer project is also * subject to an additional IP rights grant found at * http://polymer.github.io/PATENTS.txt */ /** * Creates Parts when a template is instantiated. */class DefaultTemplateProcessor{/** * Create parts for an attribute-position binding, given the event, attribute * name, and string literals. * * @param element The element containing the binding * @param name The attribute name * @param strings The string literals. There are always at least two strings, * event for fully-controlled bindings with a single expression. */handleAttributeExpressions(e,t,r,n){const s=t[0];if("."===s){const n=new PropertyCommitter(e,t.slice(1),r);return n.parts}if("@"===s)return[new EventPart(e,t.slice(1),n.eventContext)];if("?"===s)return[new BooleanAttributePart(e,t.slice(1),r)];const i=new AttributeCommitter(e,t,r);return i.parts}/** * Create parts for a text-position binding. * @param templateFactory */handleTextExpression(e){return new NodePart(e)}}const defaultTemplateProcessor=new DefaultTemplateProcessor;/** * @license * Copyright (c) 2017 The Polymer Project Authors. All rights reserved. * This code may only be used under the BSD style license found at * http://polymer.github.io/LICENSE.txt * The complete set of authors may be found at * http://polymer.github.io/AUTHORS.txt * The complete set of contributors may be found at * http://polymer.github.io/CONTRIBUTORS.txt * Code distributed by Google as part of the polymer project is also * subject to an additional IP rights grant found at * http://polymer.github.io/PATENTS.txt */ // IMPORTANT: do not change the property name or the assignment expression. // This line will be used in regexes to search for lit-html usage. // TODO(justinfagnani): inject version number at build time (window.litHtmlVersions||(window.litHtmlVersions=[])).push("1.1.2");/** * Interprets a template literal as an HTML template that can efficiently * render to and update a container. */const html=(e,...t)=>new TemplateResult(e,t,"html",defaultTemplateProcessor),getTemplateCacheKey=(e,t)=>`${e}--${t}`;/** * @license * Copyright (c) 2017 The Polymer Project Authors. All rights reserved. * This code may only be used under the BSD style license found at * http://polymer.github.io/LICENSE.txt * The complete set of authors may be found at * http://polymer.github.io/AUTHORS.txt * The complete set of contributors may be found at * http://polymer.github.io/CONTRIBUTORS.txt * Code distributed by Google as part of the polymer project is also * subject to an additional IP rights grant found at * http://polymer.github.io/PATENTS.txt */ // Get a key to lookup in `templateCaches`. let compatibleShadyCSSVersion=!0;"undefined"==typeof window.ShadyCSS?compatibleShadyCSSVersion=!1:"undefined"==typeof window.ShadyCSS.prepareTemplateDom&&(console.warn("Incompatible ShadyCSS version detected. Please update to at least @webcomponents/webcomponentsjs@2.0.2 and @webcomponents/shadycss@1.3.1."),compatibleShadyCSSVersion=!1);/** * Template factory which scopes template DOM using ShadyCSS. * @param scopeName {string} */const shadyTemplateFactory=e=>t=>{const r=getTemplateCacheKey(t.type,e);let n=templateCaches.get(r);void 0===n&&(n={stringsArray:new WeakMap,keyString:new Map},templateCaches.set(r,n));let s=n.stringsArray.get(t.strings);if(void 0!==s)return s;const i=t.strings.join(marker);if(s=n.keyString.get(i),void 0===s){const r=t.getTemplateElement();compatibleShadyCSSVersion&&window.ShadyCSS.prepareTemplateDom(r,e),s=new Template(t,r),n.keyString.set(i,s)}return n.stringsArray.set(t.strings,s),s},TEMPLATE_TYPES=["html","svg"],removeStylesFromLitTemplates=e=>{TEMPLATE_TYPES.forEach(t=>{const r=templateCaches.get(getTemplateCacheKey(t,e));r!==void 0&&r.keyString.forEach(e=>{const{element:{content:t}}=e,r=new Set;// IE 11 doesn't support the iterable param Set constructor Array.from(t.querySelectorAll("style")).forEach(e=>{r.add(e)}),removeNodesFromTemplate(e,r)})})},shadyRenderSet=new Set,prepareTemplateStyles=(e,t,r)=>{shadyRenderSet.add(e);// If `renderedDOM` is stamped from a Template, then we need to edit that // Template's underlying template element. Otherwise, we create one here // to give to ShadyCSS, which still requires one while scoping. const n=!r?document.createElement("template"):r.element,s=t.querySelectorAll("style"),{length:a}=s;// Move styles out of rendered DOM and store. // If there are no styles, skip unnecessary work if(0===a)return void window.ShadyCSS.prepareTemplateStyles(n,e);const o=document.createElement("style");// Collect styles into a single style. This helps us make sure ShadyCSS // manipulations will not prevent us from being able to fix up template // part indices. // NOTE: collecting styles is inefficient for browsers but ShadyCSS // currently does this anyway. When it does not, this should be changed. for(let n=0;n<a;n++){const e=s[n];e.parentNode.removeChild(e),o.textContent+=e.textContent}// Remove styles from nested templates in this scope. removeStylesFromLitTemplates(e);// And then put the condensed style into the "root" template passed in as // `template`. const l=n.content;!r?l.insertBefore(o,l.firstChild):insertNodeIntoTemplate(r,o,l.firstChild),window.ShadyCSS.prepareTemplateStyles(n,e);const d=l.querySelector("style");if(window.ShadyCSS.nativeShadow&&null!==d)// When in native Shadow DOM, ensure the style created by ShadyCSS is // included in initially rendered output (`renderedDOM`). t.insertBefore(d.cloneNode(!0),t.firstChild);else if(!!r){l.insertBefore(o,l.firstChild);const e=new Set;e.add(o),removeNodesFromTemplate(r,e)}},render$1=(e,t,r)=>{if(!r||"object"!=typeof r||!r.scopeName)throw new Error("The `scopeName` option is required.");const n=r.scopeName,s=parts.has(t),i=compatibleShadyCSSVersion&&11===t.nodeType/* Node.DOCUMENT_FRAGMENT_NODE */&&!!t.host,a=i&&!shadyRenderSet.has(n),o=a?document.createDocumentFragment():t;// When performing first scope render, // (1) We've rendered into a fragment so that there's a chance to // `prepareTemplateStyles` before sub-elements hit the DOM // (which might cause them to render based on a common pattern of // rendering in a custom element's `connectedCallback`); // (2) Scope the template with ShadyCSS one time only for this scope. // (3) Render the fragment into the container and make sure the // container knows its `part` is the one we just rendered. This ensures // DOM will be re-used on subsequent renders. if(render(e,o,Object.assign({templateFactory:shadyTemplateFactory(n)},r)),a){const e=parts.get(o);parts.delete(o);// ShadyCSS might have style sheets (e.g. from `prepareAdoptedCssText`) // that should apply to `renderContainer` even if the rendered value is // not a TemplateInstance. However, it will only insert scoped styles // into the document if `prepareTemplateStyles` has already been called // for the given scope name. const r=e.value instanceof TemplateInstance?e.value.template:void 0;prepareTemplateStyles(n,o,r),removeNodes(t,t.firstChild),t.appendChild(o),parts.set(t,e)}// After elements have hit the DOM, update styling if this is the // initial render to this container. // This is needed whenever dynamic changes are made so it would be // safest to do every render; however, this would regress performance // so we leave it up to the user to call `ShadyCSS.styleElement` // for dynamic changes. !s&&i&&window.ShadyCSS.styleElement(t.host)};/** * @license * Copyright (c) 2017 The Polymer Project Authors. All rights reserved. * This code may only be used under the BSD style license found at * http://polymer.github.io/LICENSE.txt * The complete set of authors may be found at * http://polymer.github.io/AUTHORS.txt * The complete set of contributors may be found at * http://polymer.github.io/CONTRIBUTORS.txt * Code distributed by Google as part of the polymer project is also * subject to an additional IP rights grant found at * http://polymer.github.io/PATENTS.txt */var _a;/** * When using Closure Compiler, JSCompiler_renameProperty(property, object) is * replaced at compile time by the munged name for object[property]. We cannot * alias this function, so we have to use a small shim that has the same * behavior when not compiling. */window.JSCompiler_renameProperty=e=>e;const defaultConverter={toAttribute(e,t){return t===Boolean?e?"":null:t===Object||t===Array?null==e?e:JSON.stringify(e):e},fromAttribute(e,t){return t===Boolean?null!==e:t===Number?null===e?null:+e:t===Object||t===Array?JSON.parse(e):e}},notEqual=(e,t)=>t!==e&&(t===t||e===e),defaultPropertyDeclaration={attribute:!0,type:String,converter:defaultConverter,reflect:!1,hasChanged:notEqual},microtaskPromise=Promise.resolve(!0),STATE_HAS_UPDATED=1,STATE_UPDATE_REQUESTED=4,STATE_IS_REFLECTING_TO_ATTRIBUTE=8,STATE_IS_REFLECTING_TO_PROPERTY=16,STATE_HAS_CONNECTED=32,finalized="finalized";/** * Change function that returns true if `value` is different from `oldValue`. * This method is used as the default for a property's `hasChanged` function. */ /** * Base element class which manages element properties and attributes. When * properties change, the `update` method is asynchronously called. This method * should be supplied by subclassers to render updates as desired. */class UpdatingElement extends HTMLElement{constructor(){/** * Map with keys for any properties that have changed since the last * update cycle with previous values. */ /** * Map with keys of properties that should be reflected when updated. */super(),this._updateState=0,this._instanceProperties=void 0,this._updatePromise=microtaskPromise,this._hasConnectedResolver=void 0,this._changedProperties=new Map,this._reflectingProperties=void 0,this.initialize()}/** * Returns a list of attributes corresponding to the registered properties. * @nocollapse */static get observedAttributes(){this.finalize();const e=[];// Use forEach so this works even if for/of loops are compiled to for loops // expecting arrays return this._classProperties.forEach((t,r)=>{const n=this._attributeNameForProperty(r,t);void 0!==n&&(this._attributeToPropertyMap.set(n,r),e.push(n))}),e}/** * Ensures the private `_classProperties` property metadata is created. * In addition to `finalize` this is also called in `createProperty` to * ensure the `@property` decorator can add property metadata. */ /** @nocollapse */static _ensureClassProperties(){// ensure private storage for property declarations. if(!this.hasOwnProperty(JSCompiler_renameProperty("_classProperties",this))){this._classProperties=new Map;// NOTE: Workaround IE11 not supporting Map constructor argument. const e=Object.getPrototypeOf(this)._classProperties;e!==void 0&&e.forEach((e,t)=>this._classProperties.set(t,e))}}/** * Creates a property accessor on the element prototype if one does not exist. * The property setter calls the property's `hasChanged` property option * or uses a strict identity check to determine whether or not to request * an update. * @nocollapse */static createProperty(e,t=defaultPropertyDeclaration){// Do not generate an accessor if the prototype already has one, since // it would be lost otherwise and that would never be the user's intention; // Instead, we expect users to call `requestUpdate` themselves from // user-defined accessors. Note that if the super has an accessor we will // still overwrite it if(this._ensureClassProperties(),this._classProperties.set(e,t),t.noAccessor||this.prototype.hasOwnProperty(e))return;const r="symbol"==typeof e?Symbol():`__${e}`;Object.defineProperty(this.prototype,e,{// tslint:disable-next-line:no-any no symbol in index get(){return this[r]},set(t){const n=this[e];this[r]=t,this._requestUpdate(e,n)},configurable:!0,enumerable:!0})}/** * Creates property accessors for registered properties and ensures * any superclasses are also finalized. * @nocollapse */static finalize(){// finalize any superclasses const e=Object.getPrototypeOf(this);// make any properties // Note, only process "own" properties since this element will inherit // any properties defined on the superClass, and finalization ensures // the entire prototype chain is finalized. if(e.hasOwnProperty(finalized)||e.finalize(),this[finalized]=!0,this._ensureClassProperties(),this._attributeToPropertyMap=new Map,this.hasOwnProperty(JSCompiler_renameProperty("properties",this))){const e=this.properties,t=[...Object.getOwnPropertyNames(e),...("function"==typeof Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(e):[])];// support symbols in properties (IE11 does not support this) // This for/of is ok because propKeys is an array for(const r of t)// note, use of `any` is due to TypeSript lack of support for symbol in // index types // tslint:disable-next-line:no-any no symbol in index this.createProperty(r,e[r])}}/** * Returns the property name for the given attribute `name`. * @nocollapse */static _attributeNameForProperty(e,t){const r=t.attribute;return!1===r?void 0:"string"==typeof r?r:"string"==typeof e?e.toLowerCase():void 0}/** * Returns true if a property should request an update. * Called when a property value is set and uses the `hasChanged` * option for the property if present or a strict identity check. * @nocollapse */static _valueHasChanged(e,t,r=notEqual){return r(e,t)}/** * Returns the property value for the given attribute value. * Called via the `attributeChangedCallback` and uses the property's * `converter` or `converter.fromAttribute` property option. * @nocollapse */static _propertyValueFromAttribute(e,t){const r=t.type,n=t.converter||defaultConverter,s="function"==typeof n?n:n.fromAttribute;return s?s(e,r):e}/** * Returns the attribute value for the given property value. If this * returns undefined, the property will *not* be reflected to an attribute. * If this returns null, the attribute will be removed, otherwise the * attribute will be set to the value. * This uses the property's `reflect` and `type.toAttribute` property options. * @nocollapse */static _propertyValueToAttribute(e,t){if(void 0===t.reflect)return;const r=t.type,n=t.converter,s=n&&n.toAttribute||defaultConverter.toAttribute;return s(e,r)}/** * Performs element initialization. By default captures any pre-set values for * registered properties. */initialize(){// ensures first update will be caught by an early access of // `updateComplete` this._saveInstanceProperties(),this._requestUpdate()}/** * Fixes any properties set on the instance before upgrade time. * Otherwise these would shadow the accessor and break these properties. * The properties are stored in a Map which is played back after the * constructor runs. Note, on very old versions of Safari (<=9) or Chrome * (<=41), properties created for native platform properties like (`id` or * `name`) may not have default values set in the element constructor. On * these browsers native properties appear on instances and therefore their * default value will overwrite any element default (e.g. if the element sets * this.id = 'id' in the constructor, the 'id' will become '' since this is * the native platform default). */_saveInstanceProperties(){// Use forEach so this works even if for/of loops are compiled to for loops // expecting arrays this.constructor._classProperties.forEach((e,t)=>{if(this.hasOwnProperty(t)){const e=this[t];delete this[t],this._instanceProperties||(this._instanceProperties=new Map),this._instanceProperties.set(t,e)}})}/** * Applies previously saved instance properties. */_applyInstanceProperties(){// Use forEach so this works even if for/of loops are compiled to for loops // expecting arrays // tslint:disable-next-line:no-any this._instanceProperties.forEach((e,t)=>this[t]=e),this._instanceProperties=void 0}connectedCallback(){this._updateState|=STATE_HAS_CONNECTED,this._hasConnectedResolver&&(this._hasConnectedResolver(),this._hasConnectedResolver=void 0)}/** * Allows for `super.disconnectedCallback()` in extensions while * reserving the possibility of making non-breaking feature additions * when disconnecting at some point in the future. */disconnectedCallback(){}/** * Synchronizes property values when attributes change. */attributeChangedCallback(e,t,r){t!==r&&this._attributeToProperty(e,r)}_propertyToAttribute(e,t,r=defaultPropertyDeclaration){const n=this.constructor,s=n._attributeNameForProperty(e,r);if(s!==void 0){const e=n._propertyValueToAttribute(t,r);// an undefined value does not change the attribute. if(e===void 0)return;// Track if the property is being reflected to avoid // setting the property again via `attributeChangedCallback`. Note: // 1. this takes advantage of the fact that the callback is synchronous. // 2. will behave incorrectly if multiple attributes are in the reaction // stack at time of calling. However, since we process attributes // in `update` this should not be possible (or an extreme corner case // that we'd like to discover). // mark state reflecting // mark state not reflecting this._updateState|=STATE_IS_REFLECTING_TO_ATTRIBUTE,null==e?this.removeAttribute(s):this.setAttribute(s,e),this._updateState&=~STATE_IS_REFLECTING_TO_ATTRIBUTE}}_attributeToProperty(e,t){// Use tracking info to avoid deserializing attribute value if it was // just set from a property setter. if(this._updateState&STATE_IS_REFLECTING_TO_ATTRIBUTE)return;const r=this.constructor,n=r._attributeToPropertyMap.get(e);if(n!==void 0){const e=r._classProperties.get(n)||defaultPropertyDeclaration;// mark state reflecting // mark state not reflecting this._updateState|=STATE_IS_REFLECTING_TO_PROPERTY,this[n]=// tslint:disable-next-line:no-any r._propertyValueFromAttribute(t,e),this._updateState&=~STATE_IS_REFLECTING_TO_PROPERTY}}/** * This private version of `requestUpdate` does not access or return the * `updateComplete` pro