@keditor/components
Version:
A library of generic web components that are accessible, framework agnostic, possible to style, and easy to use with data provided by Contentful
288 lines (284 loc) • 50.3 kB
JavaScript
/**
* @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 t="undefined"!=typeof window&&null!=window.customElements&&void 0!==window.customElements.polyfillWrapFlushCallback,e=(t,e,n=null)=>{for(;e!==n;){const n=e.nextSibling;t.removeChild(e),e=n}},n=`{{lit-${String(Math.random()).slice(2)}}}`,r=`\x3c!--${n}--\x3e`,s=new RegExp(`${n}|${r}`);class i{constructor(t,e){this.parts=[],this.element=e;const r=[],i=[],a=document.createTreeWalker(e.content,133,null,!1);let u=0,h=-1,p=0;const{strings:d,values:{length:f}}=t;for(;p<f;){const t=a.nextNode();if(null!==t){if(h++,1===t.nodeType){if(t.hasAttributes()){const e=t.attributes,{length:n}=e;let r=0;for(let t=0;t<n;t++)o(e[t].name,"$lit$")&&r++;for(;r-- >0;){const e=d[p],n=c.exec(e)[2],r=n.toLowerCase()+"$lit$",i=t.getAttribute(r);t.removeAttribute(r);const o=i.split(s);this.parts.push({type:"attribute",index:h,name:n,strings:o}),p+=o.length-1}}"TEMPLATE"===t.tagName&&(i.push(t),a.currentNode=t.content)}else if(3===t.nodeType){const e=t.data;if(e.indexOf(n)>=0){const n=t.parentNode,i=e.split(s),a=i.length-1;for(let e=0;e<a;e++){let r,s=i[e];if(""===s)r=l();else{const t=c.exec(s);null!==t&&o(t[2],"$lit$")&&(s=s.slice(0,t.index)+t[1]+t[2].slice(0,-"$lit$".length)+t[3]),r=document.createTextNode(s)}n.insertBefore(r,t),this.parts.push({type:"node",index:++h})}""===i[a]?(n.insertBefore(l(),t),r.push(t)):t.data=i[a],p+=a}}else if(8===t.nodeType)if(t.data===n){const e=t.parentNode;null!==t.previousSibling&&h!==u||(h++,e.insertBefore(l(),t)),u=h,this.parts.push({type:"node",index:h}),null===t.nextSibling?t.data="":(r.push(t),h--),p++}else{let e=-1;for(;-1!==(e=t.data.indexOf(n,e+1));)this.parts.push({type:"node",index:-1}),p++}}else a.currentNode=i.pop()}for(const n of r)n.parentNode.removeChild(n)}}const o=(t,e)=>{const n=t.length-e.length;return n>=0&&t.slice(n)===e},a=t=>-1!==t.index,l=()=>document.createComment(""),c=/([ \x09\x0a\x0c\x0d])([^\0-\x1F\x7F-\x9F "'>=/]+)([ \x09\x0a\x0c\x0d]*=[ \x09\x0a\x0c\x0d]*(?:[^ \x09\x0a\x0c\x0d"'`<>=]*|"[^"]*|'[^']*))$/;function u(t,e){const{element:{content:n},parts:r}=t,s=document.createTreeWalker(n,133,null,!1);let i=p(r),o=r[i],a=-1,l=0;const c=[];let u=null;for(;s.nextNode();){a++;const t=s.currentNode;for(t.previousSibling===u&&(u=null),e.has(t)&&(c.push(t),null===u&&(u=t)),null!==u&&l++;void 0!==o&&o.index===a;)o.index=null!==u?-1:o.index-l,i=p(r,i),o=r[i]}c.forEach((t=>t.parentNode.removeChild(t)))}const h=t=>{let e=11===t.nodeType?0:1;const n=document.createTreeWalker(t,133,null,!1);for(;n.nextNode();)e++;return e},p=(t,e=-1)=>{for(let n=e+1;n<t.length;n++){const e=t[n];if(a(e))return n}return-1};
/**
* @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 d=new WeakMap,f=t=>"function"==typeof t&&d.has(t),m={},y={};
/**
* @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
*/
class v{constructor(t,e,n){this.__parts=[],this.template=t,this.processor=e,this.options=n}update(t){let e=0;for(const n of this.__parts)void 0!==n&&n.setValue(t[e]),e++;for(const n of this.__parts)void 0!==n&&n.commit()}_clone(){const e=t?this.template.element.content.cloneNode(!0):document.importNode(this.template.element.content,!0),n=[],r=this.template.parts,s=document.createTreeWalker(e,133,null,!1);let i,o=0,l=0,c=s.nextNode();for(;o<r.length;)if(i=r[o],a(i)){for(;l<i.index;)l++,"TEMPLATE"===c.nodeName&&(n.push(c),s.currentNode=c.content),null===(c=s.nextNode())&&(s.currentNode=n.pop(),c=s.nextNode());if("node"===i.type){const t=this.processor.handleTextExpression(this.options);t.insertAfterNode(c.previousSibling),this.__parts.push(t)}else this.__parts.push(...this.processor.handleAttributeExpressions(c,i.name,i.strings,this.options));o++}else this.__parts.push(void 0),o++;return t&&(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 g=window.trustedTypes&&trustedTypes.createPolicy("lit-html",{createHTML:t=>t}),_=` ${n} `;class b{constructor(t,e,n,r){this.strings=t,this.values=e,this.type=n,this.processor=r}getHTML(){const t=this.strings.length-1;let e="",s=!1;for(let i=0;i<t;i++){const t=this.strings[i],o=t.lastIndexOf("\x3c!--");s=(o>-1||s)&&-1===t.indexOf("--\x3e",o+1);const a=c.exec(t);e+=null===a?t+(s?_:r):t.substr(0,a.index)+a[1]+a[2]+"$lit$"+a[3]+n}return e+=this.strings[t],e}getTemplateElement(){const t=document.createElement("template");let e=this.getHTML();return void 0!==g&&(e=g.createHTML(e)),t.innerHTML=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
*/const w=t=>null===t||!("object"==typeof t||"function"==typeof t),S=t=>Array.isArray(t)||!(!t||!t[Symbol.iterator]);class x{constructor(t,e,n){this.dirty=!0,this.element=t,this.name=e,this.strings=n,this.parts=[];for(let r=0;r<n.length-1;r++)this.parts[r]=this._createPart()}_createPart(){return new P(this)}_getValue(){const t=this.strings,e=t.length-1,n=this.parts;if(1===e&&""===t[0]&&""===t[1]){const t=n[0].value;if("symbol"==typeof t)return String(t);if("string"==typeof t||!S(t))return t}let r="";for(let s=0;s<e;s++){r+=t[s];const e=n[s];if(void 0!==e){const t=e.value;if(w(t)||!S(t))r+="string"==typeof t?t:String(t);else for(const e of t)r+="string"==typeof e?e:String(e)}}return r+=t[e],r}commit(){this.dirty&&(this.dirty=!1,this.element.setAttribute(this.name,this._getValue()))}}class P{constructor(t){this.value=void 0,this.committer=t}setValue(t){t===m||w(t)&&t===this.value||(this.value=t,f(t)||(this.committer.dirty=!0))}commit(){for(;f(this.value);){const t=this.value;this.value=m,t(this)}this.value!==m&&this.committer.commit()}}class T{constructor(t){this.value=void 0,this.__pendingValue=void 0,this.options=t}appendInto(t){this.startNode=t.appendChild(l()),this.endNode=t.appendChild(l())}insertAfterNode(t){this.startNode=t,this.endNode=t.nextSibling}appendIntoPart(t){t.__insert(this.startNode=l()),t.__insert(this.endNode=l())}insertAfterPart(t){t.__insert(this.startNode=l()),this.endNode=t.endNode,t.endNode=this.startNode}setValue(t){this.__pendingValue=t}commit(){if(null===this.startNode.parentNode)return;for(;f(this.__pendingValue);){const t=this.__pendingValue;this.__pendingValue=m,t(this)}const t=this.__pendingValue;t!==m&&(w(t)?t!==this.value&&this.__commitText(t):t instanceof b?this.__commitTemplateResult(t):t instanceof Node?this.__commitNode(t):S(t)?this.__commitIterable(t):t===y?(this.value=y,this.clear()):this.__commitText(t))}__insert(t){this.endNode.parentNode.insertBefore(t,this.endNode)}__commitNode(t){this.value!==t&&(this.clear(),this.__insert(t),this.value=t)}__commitText(t){const e=this.startNode.nextSibling,n="string"==typeof(t=null==t?"":t)?t:String(t);e===this.endNode.previousSibling&&3===e.nodeType?e.data=n:this.__commitNode(document.createTextNode(n)),this.value=t}__commitTemplateResult(t){const e=this.options.templateFactory(t);if(this.value instanceof v&&this.value.template===e)this.value.update(t.values);else{const n=new v(e,t.processor,this.options),r=n._clone();n.update(t.values),this.__commitNode(r),this.value=n}}__commitIterable(t){Array.isArray(this.value)||(this.value=[],this.clear());const e=this.value;let n,r=0;for(const s of t)n=e[r],void 0===n&&(n=new T(this.options),e.push(n),0===r?n.appendIntoPart(this):n.insertAfterPart(e[r-1])),n.setValue(s),n.commit(),r++;r<e.length&&(e.length=r,this.clear(n&&n.endNode))}clear(t=this.startNode){e(this.startNode.parentNode,t.nextSibling,this.endNode)}}class k{constructor(t,e,n){if(this.value=void 0,this.__pendingValue=void 0,2!==n.length||""!==n[0]||""!==n[1])throw new Error("Boolean attributes can only contain a single expression");this.element=t,this.name=e,this.strings=n}setValue(t){this.__pendingValue=t}commit(){for(;f(this.__pendingValue);){const t=this.__pendingValue;this.__pendingValue=m,t(this)}if(this.__pendingValue===m)return;const t=!!this.__pendingValue;this.value!==t&&(t?this.element.setAttribute(this.name,""):this.element.removeAttribute(this.name),this.value=t),this.__pendingValue=m}}class O extends x{constructor(t,e,n){super(t,e,n),this.single=2===n.length&&""===n[0]&&""===n[1]}_createPart(){return new C(this)}_getValue(){return this.single?this.parts[0].value:super._getValue()}commit(){this.dirty&&(this.dirty=!1,this.element[this.name]=this._getValue())}}class C extends P{}let A=!1;(()=>{try{const t={get capture(){return A=!0,!1}};window.addEventListener("test",t,t),window.removeEventListener("test",t,t)}catch(t){}})();class E{constructor(t,e,n){this.value=void 0,this.__pendingValue=void 0,this.element=t,this.eventName=e,this.eventContext=n,this.__boundHandleEvent=t=>this.handleEvent(t)}setValue(t){this.__pendingValue=t}commit(){for(;f(this.__pendingValue);){const t=this.__pendingValue;this.__pendingValue=m,t(this)}if(this.__pendingValue===m)return;const t=this.__pendingValue,e=this.value,n=null==t||null!=e&&(t.capture!==e.capture||t.once!==e.once||t.passive!==e.passive),r=null!=t&&(null==e||n);n&&this.element.removeEventListener(this.eventName,this.__boundHandleEvent,this.__options),r&&(this.__options=j(t),this.element.addEventListener(this.eventName,this.__boundHandleEvent,this.__options)),this.value=t,this.__pendingValue=m}handleEvent(t){"function"==typeof this.value?this.value.call(this.eventContext||this.element,t):this.value.handleEvent(t)}}const j=t=>t&&(A?{capture:t.capture,passive:t.passive,once:t.once}:t.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
*/;function N(t){let e=$.get(t.type);void 0===e&&(e={stringsArray:new WeakMap,keyString:new Map},$.set(t.type,e));let r=e.stringsArray.get(t.strings);if(void 0!==r)return r;const s=t.strings.join(n);return r=e.keyString.get(s),void 0===r&&(r=new i(t,t.getTemplateElement()),e.keyString.set(s,r)),e.stringsArray.set(t.strings,r),r}const $=new Map,M=new WeakMap;
/**
* @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 U=new
/**
* @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
*/
class{handleAttributeExpressions(t,e,n,r){const s=e[0];if("."===s){return new O(t,e.slice(1),n).parts}if("@"===s)return[new E(t,e.slice(1),r.eventContext)];if("?"===s)return[new k(t,e.slice(1),n)];return new x(t,e,n).parts}handleTextExpression(t){return new T(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
*/"undefined"!=typeof window&&(window.litHtmlVersions||(window.litHtmlVersions=[])).push("1.4.1");const V=(t,...e)=>new b(t,e,"html",U)
/**
* @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
*/,L=(t,e)=>`${t}--${e}`;let R=!0;void 0===window.ShadyCSS?R=!1:void 0===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."),R=!1);const z=t=>e=>{const r=L(e.type,t);let s=$.get(r);void 0===s&&(s={stringsArray:new WeakMap,keyString:new Map},$.set(r,s));let o=s.stringsArray.get(e.strings);if(void 0!==o)return o;const a=e.strings.join(n);if(o=s.keyString.get(a),void 0===o){const n=e.getTemplateElement();R&&window.ShadyCSS.prepareTemplateDom(n,t),o=new i(e,n),s.keyString.set(a,o)}return s.stringsArray.set(e.strings,o),o},I=["html","svg"],F=new Set,W=(t,e,n)=>{F.add(t);const r=n?n.element:document.createElement("template"),s=e.querySelectorAll("style"),{length:i}=s;if(0===i)return void window.ShadyCSS.prepareTemplateStyles(r,t);const o=document.createElement("style");for(let c=0;c<i;c++){const t=s[c];t.parentNode.removeChild(t),o.textContent+=t.textContent}(t=>{I.forEach((e=>{const n=$.get(L(e,t));void 0!==n&&n.keyString.forEach((t=>{const{element:{content:e}}=t,n=new Set;Array.from(e.querySelectorAll("style")).forEach((t=>{n.add(t)})),u(t,n)}))}))})(t);const a=r.content;n?function(t,e,n=null){const{element:{content:r},parts:s}=t;if(null==n)return void r.appendChild(e);const i=document.createTreeWalker(r,133,null,!1);let o=p(s),a=0,l=-1;for(;i.nextNode();)for(l++,i.currentNode===n&&(a=h(e),n.parentNode.insertBefore(e,n));-1!==o&&s[o].index===l;){if(a>0){for(;-1!==o;)s[o].index+=a,o=p(s,o);return}o=p(s,o)}}(n,o,a.firstChild):a.insertBefore(o,a.firstChild),window.ShadyCSS.prepareTemplateStyles(r,t);const l=a.querySelector("style");if(window.ShadyCSS.nativeShadow&&null!==l)e.insertBefore(l.cloneNode(!0),e.firstChild);else if(n){a.insertBefore(o,a.firstChild);const t=new Set;t.add(o),u(n,t)}};window.JSCompiler_renameProperty=(t,e)=>t;const q={toAttribute(t,e){switch(e){case Boolean:return t?"":null;case Object:case Array:return null==t?t:JSON.stringify(t)}return t},fromAttribute(t,e){switch(e){case Boolean:return null!==t;case Number:return null===t?null:Number(t);case Object:case Array:return JSON.parse(t)}return t}},D=(t,e)=>e!==t&&(e==e||t==t),B={attribute:!0,type:String,converter:q,reflect:!1,hasChanged:D};class H extends HTMLElement{constructor(){super(),this.initialize()}static get observedAttributes(){this.finalize();const t=[];return this._classProperties.forEach(((e,n)=>{const r=this._attributeNameForProperty(n,e);void 0!==r&&(this._attributeToPropertyMap.set(r,n),t.push(r))})),t}static _ensureClassProperties(){if(!this.hasOwnProperty(JSCompiler_renameProperty("_classProperties",this))){this._classProperties=new Map;const t=Object.getPrototypeOf(this)._classProperties;void 0!==t&&t.forEach(((t,e)=>this._classProperties.set(e,t)))}}static createProperty(t,e=B){if(this._ensureClassProperties(),this._classProperties.set(t,e),e.noAccessor||this.prototype.hasOwnProperty(t))return;const n="symbol"==typeof t?Symbol():`__${t}`,r=this.getPropertyDescriptor(t,n,e);void 0!==r&&Object.defineProperty(this.prototype,t,r)}static getPropertyDescriptor(t,e,n){return{get(){return this[e]},set(r){const s=this[t];this[e]=r,this.requestUpdateInternal(t,s,n)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this._classProperties&&this._classProperties.get(t)||B}static finalize(){const t=Object.getPrototypeOf(this);if(t.hasOwnProperty("finalized")||t.finalize(),this.finalized=!0,this._ensureClassProperties(),this._attributeToPropertyMap=new Map,this.hasOwnProperty(JSCompiler_renameProperty("properties",this))){const t=this.properties,e=[...Object.getOwnPropertyNames(t),..."function"==typeof Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(t):[]];for(const n of e)this.createProperty(n,t[n])}}static _attributeNameForProperty(t,e){const n=e.attribute;return!1===n?void 0:"string"==typeof n?n:"string"==typeof t?t.toLowerCase():void 0}static _valueHasChanged(t,e,n=D){return n(t,e)}static _propertyValueFromAttribute(t,e){const n=e.type,r=e.converter||q,s="function"==typeof r?r:r.fromAttribute;return s?s(t,n):t}static _propertyValueToAttribute(t,e){if(void 0===e.reflect)return;const n=e.type,r=e.converter;return(r&&r.toAttribute||q.toAttribute)(t,n)}initialize(){this._updateState=0,this._updatePromise=new Promise((t=>this._enableUpdatingResolver=t)),this._changedProperties=new Map,this._saveInstanceProperties(),this.requestUpdateInternal()}_saveInstanceProperties(){this.constructor._classProperties.forEach(((t,e)=>{if(this.hasOwnProperty(e)){const t=this[e];delete this[e],this._instanceProperties||(this._instanceProperties=new Map),this._instanceProperties.set(e,t)}}))}_applyInstanceProperties(){this._instanceProperties.forEach(((t,e)=>this[e]=t)),this._instanceProperties=void 0}connectedCallback(){this.enableUpdating()}enableUpdating(){void 0!==this._enableUpdatingResolver&&(this._enableUpdatingResolver(),this._enableUpdatingResolver=void 0)}disconnectedCallback(){}attributeChangedCallback(t,e,n){e!==n&&this._attributeToProperty(t,n)}_propertyToAttribute(t,e,n=B){const r=this.constructor,s=r._attributeNameForProperty(t,n);if(void 0!==s){const t=r._propertyValueToAttribute(e,n);if(void 0===t)return;this._updateState=8|this._updateState,null==t?this.removeAttribute(s):this.setAttribute(s,t),this._updateState=-9&this._updateState}}_attributeToProperty(t,e){if(8&this._updateState)return;const n=this.constructor,r=n._attributeToPropertyMap.get(t);if(void 0!==r){const t=n.getPropertyOptions(r);this._updateState=16|this._updateState,this[r]=n._propertyValueFromAttribute(e,t),this._updateState=-17&this._updateState}}requestUpdateInternal(t,e,n){let r=!0;if(void 0!==t){const s=this.constructor;n=n||s.getPropertyOptions(t),s._valueHasChanged(this[t],e,n.hasChanged)?(this._changedProperties.has(t)||this._changedProperties.set(t,e),!0!==n.reflect||16&this._updateState||(void 0===this._reflectingProperties&&(this._reflectingProperties=new Map),this._reflectingProperties.set(t,n))):r=!1}!this._hasRequestedUpdate&&r&&(this._updatePromise=this._enqueueUpdate())}requestUpdate(t,e){return this.requestUpdateInternal(t,e),this.updateComplete}async _enqueueUpdate(){this._updateState=4|this._updateState;try{await this._updatePromise}catch(e){}const t=this.performUpdate();return null!=t&&await t,!this._hasRequestedUpdate}get _hasRequestedUpdate(){return 4&this._updateState}get hasUpdated(){return 1&this._updateState}performUpdate(){if(!this._hasRequestedUpdate)return;this._instanceProperties&&this._applyInstanceProperties();let t=!1;const e=this._changedProperties;try{t=this.shouldUpdate(e),t?this.update(e):this._markUpdated()}catch(n){throw t=!1,this._markUpdated(),n}t&&(1&this._updateState||(this._updateState=1|this._updateState,this.firstUpdated(e)),this.updated(e))}_markUpdated(){this._changedProperties=new Map,this._updateState=-5&this._updateState}get updateComplete(){return this._getUpdateComplete()}_getUpdateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._updatePromise}shouldUpdate(t){return!0}update(t){void 0!==this._reflectingProperties&&this._reflectingProperties.size>0&&(this._reflectingProperties.forEach(((t,e)=>this._propertyToAttribute(e,this[e],t))),this._reflectingProperties=void 0),this._markUpdated()}updated(t){}firstUpdated(t){}}H.finalized=!0;
/**
@license
Copyright (c) 2019 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 J=window.ShadowRoot&&(void 0===window.ShadyCSS||window.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Q=Symbol();class G{constructor(t,e){if(e!==Q)throw new Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t}get styleSheet(){return void 0===this._styleSheet&&(J?(this._styleSheet=new CSSStyleSheet,this._styleSheet.replaceSync(this.cssText)):this._styleSheet=null),this._styleSheet}toString(){return this.cssText}}const K=(t,...e)=>{const n=e.reduce(((e,n,r)=>e+(t=>{if(t instanceof G)return t.cssText;if("number"==typeof t)return t;throw new Error(`Value passed to 'css' function must be a 'css' function result: ${t}. Use 'unsafeCSS' to pass non-literal values, but\n take care to ensure page security.`)})(n)+t[r+1]),t[0]);return new G(n,Q)};
/**
* @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
*/
(window.litElementVersions||(window.litElementVersions=[])).push("2.5.1");const X={};class Y extends H{static getStyles(){return this.styles}static _getUniqueStyles(){if(this.hasOwnProperty(JSCompiler_renameProperty("_styles",this)))return;const t=this.getStyles();if(Array.isArray(t)){const e=(t,n)=>t.reduceRight(((t,n)=>Array.isArray(n)?e(n,t):(t.add(n),t)),n),n=e(t,new Set),r=[];n.forEach((t=>r.unshift(t))),this._styles=r}else this._styles=void 0===t?[]:[t];this._styles=this._styles.map((t=>{if(t instanceof CSSStyleSheet&&!J){const e=Array.prototype.slice.call(t.cssRules).reduce(((t,e)=>t+e.cssText),"");return new G(String(e),Q)}return t}))}initialize(){super.initialize(),this.constructor._getUniqueStyles(),this.renderRoot=this.createRenderRoot(),window.ShadowRoot&&this.renderRoot instanceof window.ShadowRoot&&this.adoptStyles()}createRenderRoot(){return this.attachShadow(this.constructor.shadowRootOptions)}adoptStyles(){const t=this.constructor._styles;0!==t.length&&(void 0===window.ShadyCSS||window.ShadyCSS.nativeShadow?J?this.renderRoot.adoptedStyleSheets=t.map((t=>t instanceof CSSStyleSheet?t:t.styleSheet)):this._needsShimAdoptedStyleSheets=!0:window.ShadyCSS.ScopingShim.prepareAdoptedCssText(t.map((t=>t.cssText)),this.localName))}connectedCallback(){super.connectedCallback(),this.hasUpdated&&void 0!==window.ShadyCSS&&window.ShadyCSS.styleElement(this)}update(t){const e=this.render();super.update(t),e!==X&&this.constructor.render(e,this.renderRoot,{scopeName:this.localName,eventContext:this}),this._needsShimAdoptedStyleSheets&&(this._needsShimAdoptedStyleSheets=!1,this.constructor._styles.forEach((t=>{const e=document.createElement("style");e.textContent=t.cssText,this.renderRoot.appendChild(e)})))}render(){return X}}Y.finalized=!0,Y.render=(t,n,r)=>{if(!r||"object"!=typeof r||!r.scopeName)throw new Error("The `scopeName` option is required.");const s=r.scopeName,i=M.has(n),o=R&&11===n.nodeType&&!!n.host,a=o&&!F.has(s),l=a?document.createDocumentFragment():n;if(((t,n,r)=>{let s=M.get(n);void 0===s&&(e(n,n.firstChild),M.set(n,s=new T(Object.assign({templateFactory:N},r))),s.appendInto(n)),s.setValue(t),s.commit()})(t,l,Object.assign({templateFactory:z(s)},r)),a){const t=M.get(l);M.delete(l);const r=t.value instanceof v?t.value.template:void 0;W(s,l,r),e(n,n.firstChild),n.appendChild(l),M.set(n,t)}!i&&o&&window.ShadyCSS.styleElement(n.host)},Y.shadowRootOptions={mode:"open"};var Z="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},tt={},et={},nt={},rt=Z&&Z.__assign||function(){return(rt=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var s in e=arguments[n])Object.prototype.hasOwnProperty.call(e,s)&&(t[s]=e[s]);return t}).apply(this,arguments)},st=Z&&Z.__rest||function(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var s=0;for(r=Object.getOwnPropertySymbols(t);s<r.length;s++)e.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(t,r[s])&&(n[r[s]]=t[r[s]])}return n},it=Z&&Z.__spreadArray||function(t,e){for(var n=0,r=e.length,s=t.length;n<r;n++,s++)t[s]=e[n];return t};Object.defineProperty(nt,"__esModule",{value:!0}),nt.Linkset=void 0;var ot=function(){function t(t){this.elements=t,this.size=t.length}return t.prototype.hasLinkTo=function(t){return this.elements.some((function(e){return e.rel===t}))},t.prototype.linkTo=function(t){return this.elements.find((function(e){return e.rel===t}))},t.prototype.linksTo=function(e){return new t(this.elements.filter((function(t){return t.rel===e})))},t.prototype.linksFrom=function(e){return new t(this.elements.filter((function(t){return t.anchor===e})))},t.prototype.linksWithAttribute=function(e){return new t(this.elements.filter((function(t){return Object.prototype.hasOwnProperty.call(t.attributes,e)})))},t.prototype.linksWithAttributeValue=function(e,n){return new t(this.linksWithAttribute(e).elements.filter((function(t){return(Array.isArray(t.attributes[e])?t.attributes[e]:[t.attributes[e]]).some((function(t){return function(t,e){if(typeof t!=typeof e)return!1;if("string"==typeof t&&"string"==typeof e)return t===e;return t.value==t.value&&t.language==t.language}(t,n)}))})))},t.prototype[Symbol.iterator]=function(){var t=this.elements,e=0;return{next:function(){return e<t.length?{value:t[e++],done:!1}:{value:void 0,done:!0}}}},t.prototype.normalize=function(){var t={};return this.elements.forEach((function(e){var n=e.anchor,r=e.rel,s=st(e,["anchor","rel"]);Object.hasOwnProperty.call(t,n)||(t[n]={}),Object.hasOwnProperty.call(t[n],r)||(t[n][r]=[]);var i=s.href,o=s.attributes,a=rt({href:i},o);t[n][r].push(a)})),{linkset:Object.entries(t).reduce((function(t,e){var n=e[0],r=e[1];return it(it([],t),[rt({anchor:n},r)])}),[])}},t}();nt.Linkset=ot;var at={},lt=Z&&Z.__spreadArray||function(t,e){for(var n=0,r=e.length,s=t.length;n<r;n++,s++)t[s]=e[n];return t};Object.defineProperty(at,"__esModule",{value:!0}),at.buildTree=at.MenuElement=void 0;var ct=function(){function t(t,e){void 0===e&&(e=[]),this.link=t,this.children=ut(lt([],e))}return Object.defineProperty(t.prototype,"title",{get:function(){return this.link.attributes.title},enumerable:!1,configurable:!0}),t}();function ut(t){if(t.length<2)return t.length?[new ct(t.shift())]:[];t.sort((function(t,e){return t.attributes["drupal-menu-hierarchy"][0].localeCompare(e.attributes["drupal-menu-hierarchy"][0])}));var e,n=[],r=[];do{var s=t.shift();e?s.attributes["drupal-menu-hierarchy"][0].length>e.attributes["drupal-menu-hierarchy"][0].length?r.push(s):(n.push(new ct(e,r)),e=s,r=[]):e=s}while(t.length);return n.push(new ct(e,r)),n}at.MenuElement=ct,at.buildTree=ut;var ht,pt=Z&&Z.__extends||(ht=function(t,e){return(ht=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])})(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}ht(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),dt=Z&&Z.__spreadArray||function(t,e){for(var n=0,r=e.length,s=t.length;n<r;n++,s++)t[s]=e[n];return t};Object.defineProperty(et,"__esModule",{value:!0}),et.Menu=void 0;var ft=at,mt=function(t){function e(e,n){var r=t.call(this,n.elements)||this;return r.id=e,r.tree=ft.buildTree(dt([],r.elements)),r}return pt(e,t),e.prototype.linksTo=function(n){return new e(this.id,t.prototype.linksTo.call(this,n))},e.prototype.linksFrom=function(n){return new e(this.id,t.prototype.linksTo.call(this,n))},e.prototype.linksWithAttribute=function(n){return new e(this.id,t.prototype.linksWithAttribute.call(this,n))},e.prototype.linksWithAttributeValue=function(n,r){return new e(this.id,t.prototype.linksWithAttributeValue.call(this,n,r))},e}(nt.Linkset);et.Menu=mt;var yt={},vt={},gt=Z&&Z.__rest||function(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var s=0;for(r=Object.getOwnPropertySymbols(t);s<r.length;s++)e.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(t,r[s])&&(n[r[s]]=t[r[s]])}return n};Object.defineProperty(vt,"__esModule",{value:!0}),vt.Link=void 0;var _t=function(t){var e=t.anchor,n=t.rel,r=t.href,s=gt(t,["anchor","rel","href"]);this.anchor=e,this.rel=n,this.href=r,this.attributes=s};vt.Link=_t;var bt=Z&&Z.__assign||function(){return(bt=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var s in e=arguments[n])Object.prototype.hasOwnProperty.call(e,s)&&(t[s]=e[s]);return t}).apply(this,arguments)},wt=Z&&Z.__rest||function(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var s=0;for(r=Object.getOwnPropertySymbols(t);s<r.length;s++)e.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(t,r[s])&&(n[r[s]]=t[r[s]])}return n};Object.defineProperty(yt,"__esModule",{value:!0}),yt.denormalize=yt.parse=void 0;var St=nt,xt=vt;function Pt(t){var e=[];return t.linkset.forEach((function(t){var n=t.anchor,r=wt(t,["anchor"]);Object.keys(r).forEach((function(r){t[r].forEach((function(t){e.push(new xt.Link(bt({anchor:n,rel:r},t)))}))}))})),new St.Linkset(e)}yt.denormalize=Pt,yt.parse=function(t){return Pt(JSON.parse(t))},Object.defineProperty(tt,"__esModule",{value:!0});var Tt=tt.denormalize=tt.parse=void 0,kt=et,Ot=yt;function Ct(t,e){var n=Ot.denormalize(t),r=[];e?r.push(e):n.linksWithAttribute("drupal-menu-machine-name").elements.forEach((function(t){r.includes(t.attributes["drupal-menu-machine-name"][0])||r.push(t.attributes["drupal-menu-machine-name"][0])}));var s=r.map((function(t){return new kt.Menu(t,n.linksWithAttributeValue("drupal-menu-machine-name",t))}));return e?s.shift():s}Tt=tt.denormalize=Ct,tt.parse=function(t,e){return Ct(JSON.parse(t),e)};class At extends Y{static get styles(){return K`
:host {
display: block;
}
:host(.dark) {
background-color: black;
color: white;
}
:host(.light) {
background-color: lightgrey;
}
.gdwc-menu li > ul {
display: none;
}
.gdwc-menu ul.show {
display: block;
}
`}static get properties(){return{baseUrl:{type:String},menuId:{type:String},branding:{type:String},tree:{type:Array},isLoading:{type:Boolean,attribute:!1},loadingMessage:{type:String}}}constructor(){super(),this.tree=[],this.isLoading=!1,this.loadingMessage="Loading..."}connectedCallback(){super.connectedCallback(),this.baseUrl&&this.menuId&&this.fetchData(this.baseUrl,this.menuId)}static menuLevelTemplate(t){return V`<ul part="menu-level">
${t}
</ul>`}menuParentTemplate(t,e){return V`<li part="menu-item">
<a
@click="${At.openMenu}"
role="button"
aria-expanded="false"
aria-haspopup="true"
href="#"
>
${t}
</a>
${this.renderMenuLevel(e)}
</li>`}static menuLinkTemplate(t,e){return V`<li part="menu-item"><a href=${e}>${t}</a></li>`}static menuItemTemplate(t){return V`<li part="menu-item">${t}</li>`}renderMenuLevel(t){const e=t.map((t=>this.renderMenuItem(t)));return At.menuLevelTemplate(e)}renderMenuItem(t){var e,n,r;const s=null==(n=null==(e=null==t?void 0:t.link)?void 0:e.attributes)?void 0:n.title,i=null==(r=null==t?void 0:t.link)?void 0:r.href,o=null==t?void 0:t.children;return o&&o.length?this.menuParentTemplate(s,o):i?At.menuLinkTemplate(s,i):At.menuItemTemplate(s)}fetchData(t,e){this.isLoading=!0;const n=`${t}/system/menu/${e}/linkset`;fetch(n,{}).then((t=>{if(t.ok)return t.json();throw this.isLoading=!1,new Error(`Unable to fetch ${n}. ${t.status} ${t.statusText}`)})).then((t=>{try{const n=Tt(t,e);this.tree=n.tree}catch(n){throw new Error("Unable to denormalize menu.")}this.isLoading=!1}))}render(){return V`
<div class="gdwc-menu">
<slot name="brand"><h2>${this.branding}</h2></slot>
${this.isLoading?V`<slot name="loading">${this.loadingMessage}</slot>`:this.renderMenuLevel(this.tree)}
</div>
`}static openMenu(t){t.preventDefault();const{target:e}=t;"true"===e.getAttribute("aria-expanded")?(e.setAttribute("aria-expanded","false"),e.nextElementSibling.classList.remove("show")):(e.setAttribute("aria-expanded","true"),e.nextElementSibling.classList.add("show"))}}customElements.get("gdwc-menu")||customElements.define("gdwc-menu",At);var Et=Array.isArray,jt="object"==typeof Z&&Z&&Z.Object===Object&&Z,Nt="object"==typeof self&&self&&self.Object===Object&&self,$t=jt||Nt||Function("return this")(),Mt=$t.Symbol,Ut=Mt,Vt=Object.prototype,Lt=Vt.hasOwnProperty,Rt=Vt.toString,zt=Ut?Ut.toStringTag:void 0;var It=function(t){var e=Lt.call(t,zt),n=t[zt];try{t[zt]=void 0;var r=!0}catch(i){}var s=Rt.call(t);return r&&(e?t[zt]=n:delete t[zt]),s},Ft=Object.prototype.toString;var Wt=It,qt=function(t){return Ft.call(t)},Dt=Mt?Mt.toStringTag:void 0;var Bt=function(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":Dt&&Dt in Object(t)?Wt(t):qt(t)};var Ht=Bt,Jt=function(t){return null!=t&&"object"==typeof t};var Qt=function(t){return"symbol"==typeof t||Jt(t)&&"[object Symbol]"==Ht(t)},Gt=Et,Kt=Qt,Xt=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Yt=/^\w*$/;var Zt=function(t,e){if(Gt(t))return!1;var n=typeof t;return!("number"!=n&&"symbol"!=n&&"boolean"!=n&&null!=t&&!Kt(t))||(Yt.test(t)||!Xt.test(t)||null!=e&&t in Object(e))};var te=function(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)},ee=Bt,ne=te;var re,se=function(t){if(!ne(t))return!1;var e=ee(t);return"[object Function]"==e||"[object GeneratorFunction]"==e||"[object AsyncFunction]"==e||"[object Proxy]"==e},ie=$t["__core-js_shared__"],oe=(re=/[^.]+$/.exec(ie&&ie.keys&&ie.keys.IE_PROTO||""))?"Symbol(src)_1."+re:"";var ae=function(t){return!!oe&&oe in t},le=Function.prototype.toString;var ce=se,ue=ae,he=te,pe=function(t){if(null!=t){try{return le.call(t)}catch(e){}try{return t+""}catch(e){}}return""},de=/^\[object .+?Constructor\]$/,fe=Function.prototype,me=Object.prototype,ye=fe.toString,ve=me.hasOwnProperty,ge=RegExp("^"+ye.call(ve).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");var _e=function(t){return!(!he(t)||ue(t))&&(ce(t)?ge:de).test(pe(t))},be=function(t,e){return null==t?void 0:t[e]};var we=function(t,e){var n=be(t,e);return _e(n)?n:void 0},Se=we(Object,"create"),xe=Se;var Pe=function(){this.__data__=xe?xe(null):{},this.size=0};var Te=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e},ke=Se,Oe=Object.prototype.hasOwnProperty;var Ce=function(t){var e=this.__data__;if(ke){var n=e[t];return"__lodash_hash_undefined__"===n?void 0:n}return Oe.call(e,t)?e[t]:void 0},Ae=Se,Ee=Object.prototype.hasOwnProperty;var je=Se;var Ne=Pe,$e=Te,Me=Ce,Ue=function(t){var e=this.__data__;return Ae?void 0!==e[t]:Ee.call(e,t)},Ve=function(t,e){var n=this.__data__;return this.size+=this.has(t)?0:1,n[t]=je&&void 0===e?"__lodash_hash_undefined__":e,this};function Le(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}Le.prototype.clear=Ne,Le.prototype.delete=$e,Le.prototype.get=Me,Le.prototype.has=Ue,Le.prototype.set=Ve;var Re=Le;var ze=function(){this.__data__=[],this.size=0};var Ie=function(t,e){return t===e||t!=t&&e!=e};var Fe=function(t,e){for(var n=t.length;n--;)if(Ie(t[n][0],e))return n;return-1},We=Fe,qe=Array.prototype.splice;var De=Fe;var Be=Fe;var He=Fe;var Je=ze,Qe=function(t){var e=this.__data__,n=We(e,t);return!(n<0)&&(n==e.length-1?e.pop():qe.call(e,n,1),--this.size,!0)},Ge=function(t){var e=this.__data__,n=De(e,t);return n<0?void 0:e[n][1]},Ke=function(t){return Be(this.__data__,t)>-1},Xe=function(t,e){var n=this.__data__,r=He(n,t);return r<0?(++this.size,n.push([t,e])):n[r][1]=e,this};function Ye(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}Ye.prototype.clear=Je,Ye.prototype.delete=Qe,Ye.prototype.get=Ge,Ye.prototype.has=Ke,Ye.prototype.set=Xe;var Ze=Ye,tn=we($t,"Map"),en=Re,nn=Ze,rn=tn;var sn=function(t){var e=typeof t;return"string"==e||"number"==e||"symbol"==e||"boolean"==e?"__proto__"!==t:null===t};var on=function(t,e){var n=t.__data__;return sn(e)?n["string"==typeof e?"string":"hash"]:n.map},an=on;var ln=on;var cn=on;var un=on;var hn=function(){this.size=0,this.__data__={hash:new en,map:new(rn||nn),string:new en}},pn=function(t){var e=an(this,t).delete(t);return this.size-=e?1:0,e},dn=function(t){return ln(this,t).get(t)},fn=function(t){return cn(this,t).has(t)},mn=function(t,e){var n=un(this,t),r=n.size;return n.set(t,e),this.size+=n.size==r?0:1,this};function yn(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}yn.prototype.clear=hn,yn.prototype.delete=pn,yn.prototype.get=dn,yn.prototype.has=fn,yn.prototype.set=mn;var vn=yn;function gn(t,e){if("function"!=typeof t||null!=e&&"function"!=typeof e)throw new TypeError("Expected a function");var n=function(){var r=arguments,s=e?e.apply(this,r):r[0],i=n.cache;if(i.has(s))return i.get(s);var o=t.apply(this,r);return n.cache=i.set(s,o)||i,o};return n.cache=new(gn.Cache||vn),n}gn.Cache=vn;var _n=gn;var bn=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,wn=/\\(\\)?/g,Sn=function(t){var e=_n(t,(function(t){return 500===n.size&&n.clear(),t})),n=e.cache;return e}((function(t){var e=[];return 46===t.charCodeAt(0)&&e.push(""),t.replace(bn,(function(t,n,r,s){e.push(r?s.replace(wn,"$1"):n||t)})),e}));var xn=function(t,e){for(var n=-1,r=null==t?0:t.length,s=Array(r);++n<r;)s[n]=e(t[n],n,t);return s},Pn=Et,Tn=Qt,kn=Mt?Mt.prototype:void 0,On=kn?kn.toString:void 0;var Cn=function t(e){if("string"==typeof e)return e;if(Pn(e))return xn(e,t)+"";if(Tn(e))return On?On.call(e):"";var n=e+"";return"0"==n&&1/e==-Infinity?"-0":n};var An=Et,En=Zt,jn=Sn,Nn=function(t){return null==t?"":Cn(t)};var $n=Qt;var Mn=function(t,e){return An(t)?t:En(t,e)?[t]:jn(Nn(t))},Un=function(t){if("string"==typeof t||$n(t))return t;var e=t+"";return"0"==e&&1/t==-Infinity?"-0":e};var Vn=function(t,e){for(var n=0,r=(e=Mn(e,t)).length;null!=t&&n<r;)t=t[Un(e[n++])];return n&&n==r?t:void 0};var Ln=function(t,e,n){var r=null==t?void 0:Vn(t,e);return void 0===r?n:r};async function Rn(t,e,n,r){await new Promise((t=>setTimeout(t,3e3)));const s=await fetch(`https://cdn.contentful.com/spaces/${n}/environments/${r}/entries/${t}?access_token=${e}`),i=await s.json();return i.fields.ContentType=Ln(i,"sys.contentType.sys.id")?Ln(i,"sys.contentType.sys.id"):"empty",i.fields}async function zn(t,e,n,r){await new Promise((t=>setTimeout(t,3e3)));const s=await fetch(`https://cdn.contentful.com/spaces/${n}/environments/${r}/assets/${t}?access_token=${e}`),i=await s.json();return Ln(i,"fields.file.url")}class In extends Y{constructor(){super(),this.id="Somebody",this.accessToken="accessToken",this.space="space",this.environment="environment",this.content="",this.socialMediaCheckTwitter=!0}static get properties(){return{id:{type:String},accessToken:{type:String},space:{type:String},environment:{type:String},entryData:{type:Array},socialMediaCheckTwitter:{type:Boolean},blockQuote:{type:String}}}async firstUpdated(){this.entryData=await Rn(this.id,this.accessToken,this.space,this.environment)}script(){const t=document.createElement("script");return t.onload=this.onLoad.bind(this),!0===this.socialMediaCheckTwitter?t.src="https://platform.twitter.com/widgets.js":t.src="https://www.instagram.com/static/bundles/es6/EmbedSDK.js/58b07fec4121.js",t}onLoad(){!1===this.socialMediaCheckTwitter&&window.instgrm.Embeds.process()}updated(){}render(){"twitter"===Ln(this.entryData,"ContentType")?(this.socialMediaCheckTwitter=!0,this.blockQuote=Ln(this.entryData,"twitterBlockquote")):(this.socialMediaCheckTwitter=!1,this.blockQuote=Ln(this.entryData,"instagramBlockquote"));const t=document.createElement("div");return t.innerHTML=this.blockQuote,V`
${t}
${this.script()}
`}createRenderRoot(){return this}}customElements.get("social-media")||customElements.define("social-media",In);class Fn extends Y{constructor(){super(),this.id="Somebody",this.accessToken="accessToken",this.space="space",this.environment="environment",this.content=""}static get properties(){return{id:{type:String},accessToken:{type:String},space:{type:String},environment:{type:String},description:{type:String},heading:{type:String},image:{type:Array}}}async firstUpdated(){const t=await Rn(this.id,this.accessToken,this.space,this.environment);this.description=Ln(t,"description.content[0].content[0].value"),this.heading=Ln(t,"heading"),this.imgId=Ln(t,"image.sys.id"),this.image=await zn(this.imgId,this.accessToken,this.space,this.environment)}updated(){}render(){return V`
<section class="card-component">
<div class="card-image">
<img src="${this.image}" alt="img"/>
</div>
<h2 class="section-title" >${this.heading}</h2>
<p class="card-desc">${this.description}</p>
</section>
`}}customElements.get("card-component")||customElements.define("card-component",Fn);class Wn extends Y{constructor(){super(),this.id="Somebody",this.accessToken="accessToken",this.space="space",this.environment="environment",this.image=[]}static get properties(){return{id:{type:String},accessToken:{type:String},space:{type:String},environment:{type:String},entryData:{type:Array},image:{type:Array}}}async firstUpdated(){const t=await Rn(this.id,this.accessToken,this.space,this.environment);this.image=await async function(t,e,n,r){return await Promise.all(t&&t.map((async t=>{const s=Ln(t,"sys.id"),i=await zn(s,e,n,r);return await new Promise((t=>setTimeout(t,3e3))),i})))}(Ln(t,"image"),this.accessToken,this.space,this.environment)}script(){}onLoad(){}updated(){}render(){return V`
<div id="myCarousel" class="carousel slide" data-ride="carousel">
<!-- Indicators -->
<ol class="carousel-indicators">
${this.image.map(((t,e)=>V`<li data-target="#myCarousel" data-slide-to=${e} class=${0===e?"active":""}></li>`))}
</ol>
<!-- Wrapper for slides -->
<div class="carousel-inner">
${this.image.map(((t,e)=>V`
<div class=${0===e?"item active":"item"}>
<img src=${t} alt="img">
</div>
`))}
<!-- Left and right controls -->
<a class="left carousel-control" href="#myCarousel" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left"></span>
<span class="sr-only">Previous</span>
</a>
<a class="right carousel-control" href="#myCarousel" data-slide="next">
<span class="glyphicon glyphicon-chevron-right"></span>
<span class="sr-only">Next</span>
</a>
</div>
`}createRenderRoot(){return this}}customElements.get("slider-component")||customElements.define("slider-component",Wn);class qn extends Y{constructor(){super(),this.id="Somebody",this.accessToken="accessToken",this.space="space",this.environment="environment",this.image=[]}static get properties(){return{id:{type:String},accessToken:{type:String},space:{type:String},environment:{type:String},entryData:{type:Array},image:{type:Array}}}async firstUpdated(){let t=[];const e=await Rn(this.id,this.accessToken,this.space,this.environment),n=Ln(e,"heromediaSlides"),r=await async function(t,e,n,r){return await Promise.all(t&&t.map((async t=>{const s=Ln(t,"sys.id"),i={};i[s]=await Rn(s,e,n,r);const o=await zn(Ln(i[s],"image.sys.id"),e,n,r);return i[s].imageUrl=null!==o?o:"default.jpg",await new Promise((t=>setTimeout(t,3e3))),i})))}(n,this.accessToken,this.space,this.environment);r&&(t=r.map((t=>{const e=Object.values(t);return{image:e[0].imageUrl,title:e[0].title,short_title:e[0].shortTitle,subhead:e[0].subhead,summary:e[0].description.content[0]&&e[0].description.content[0].content[0].value,link_url:e[0].linkurl,link_text:e[0].linkText,text_position:e[0].textPosition,background_color:e[0].textBackgroundColor}}))),this.image=t}render(){return V`
<div id="heromedia" class="carousel slide" data-ride="carousel">
<div class="carousel-inner" >
${this.image.map(((t,e)=>V`
<div class=${0===e?"item active":"item"}>
<div >
<div class="photo-panel">
<img src=${t.image} width="100%" height="" alt=""/>
</div>
<div class="photo-overlay ${t.text_position}" style="background-color:${t.background_color};">
<div class="photo_title">
<h1>${t.title}</h1>
</div>
<div class="photo_short_title">
<h4>${t.short_title}</h4>
</div>
<div class="photo_subhead">${t.subhead}</div>
<div class="photo_desc">
${t.summary}
</div>
${t.link_url?V`<div class="photo_btn_wrapper">
<a href=${t.link_url} class="rounded-0" tabindex="0">${t.link_text}</a>
</div>`:V``}
</div>
</div>
</div>
`))}
</div>
${this.image.length>1?V`<!-- Left and right controls -->
<a class="left carousel-control" href="#heromedia" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left"></span>
<span class="sr-only">Previous</span>
</a>
<a class="right carousel-control" href="#heromedia" data-slide="next">
<span class="glyphicon glyphicon-chevron-right"></span>
<span class="sr-only">Next</span>
</a>
`:V``}
</div>
<style>
#heromedia .carousel-control {
top: 22px;
width: 5%;
}
#heromedia #text-left {
text-align: left;
}
#heromedia #text-center {
text-align: center;
}
#heromedia #text-right {
text-align: end;
}
.photo-overlay {
position: relative;
bottom: 0;
width: 100%