@buckneri/custom-tags
Version:
Custom HTML tags using Polymer
71 lines (70 loc) • 47.2 kB
JavaScript
const e=new WeakMap,t=t=>"function"==typeof t&&e.has(t),s=void 0!==window.customElements&&void 0!==window.customElements.polyfillWrapFlushCallback,i=(e,t,s=null)=>{for(;t!==s;){const s=t.nextSibling;e.removeChild(t),t=s}},n={},o={},r=`{{lit-${String(Math.random()).slice(2)}}}`,a=`\x3c!--${r}--\x3e`,l=new RegExp(`${r}|${a}`),d="$lit$";class h{constructor(e,t){this.parts=[],this.element=t;const s=[],i=[],n=document.createTreeWalker(t.content,133,null,!1);let o=0,a=-1,h=0;const{strings:p,values:{length:m}}=e;for(;h<m;){const e=n.nextNode();if(null!==e){if(a++,1===e.nodeType){if(e.hasAttributes()){const t=e.attributes,{length:s}=t;let i=0;for(let e=0;e<s;e++)c(t[e].name,d)&&i++;for(;i-- >0;){const t=p[h],s=f.exec(t)[2],i=s.toLowerCase()+d,n=e.getAttribute(i);e.removeAttribute(i);const o=n.split(l);this.parts.push({type:"attribute",index:a,name:s,strings:o}),h+=o.length-1}}"TEMPLATE"===e.tagName&&(i.push(e),n.currentNode=e.content)}else if(3===e.nodeType){const t=e.data;if(t.indexOf(r)>=0){const i=e.parentNode,n=t.split(l),o=n.length-1;for(let t=0;t<o;t++){let s,o=n[t];if(""===o)s=u();else{const e=f.exec(o);null!==e&&c(e[2],d)&&(o=o.slice(0,e.index)+e[1]+e[2].slice(0,-d.length)+e[3]),s=document.createTextNode(o)}i.insertBefore(s,e),this.parts.push({type:"node",index:++a})}""===n[o]?(i.insertBefore(u(),e),s.push(e)):e.data=n[o],h+=o}}else if(8===e.nodeType)if(e.data===r){const t=e.parentNode;null!==e.previousSibling&&a!==o||(a++,t.insertBefore(u(),e)),o=a,this.parts.push({type:"node",index:a}),null===e.nextSibling?e.data="":(s.push(e),a--),h++}else{let t=-1;for(;-1!==(t=e.data.indexOf(r,t+1));)this.parts.push({type:"node",index:-1}),h++}}else n.currentNode=i.pop()}for(const e of s)e.parentNode.removeChild(e)}}const c=(e,t)=>{const s=e.length-t.length;return s>=0&&e.slice(s)===t},p=e=>-1!==e.index,u=()=>document.createComment(""),f=/([ \x09\x0a\x0c\x0d])([^\0-\x1F\x7F-\x9F "'>=\/]+)([ \x09\x0a\x0c\x0d]*=[ \x09\x0a\x0c\x0d]*(?:[^ \x09\x0a\x0c\x0d"'`<>=]*|"[^"]*|'[^']*))$/;class m{constructor(e,t,s){this.__parts=[],this.template=e,this.processor=t,this.options=s}update(e){let t=0;for(const s of this.__parts)void 0!==s&&s.setValue(e[t]),t++;for(const e of this.__parts)void 0!==e&&e.commit()}_clone(){const e=s?this.template.element.content.cloneNode(!0):document.importNode(this.template.element.content,!0),t=[],i=this.template.parts,n=document.createTreeWalker(e,133,null,!1);let o,r=0,a=0,l=n.nextNode();for(;r<i.length;)if(o=i[r],p(o)){for(;a<o.index;)a++,"TEMPLATE"===l.nodeName&&(t.push(l),n.currentNode=l.content),null===(l=n.nextNode())&&(n.currentNode=t.pop(),l=n.nextNode());if("node"===o.type){const e=this.processor.handleTextExpression(this.options);e.insertAfterNode(l.previousSibling),this.__parts.push(e)}else this.__parts.push(...this.processor.handleAttributeExpressions(l,o.name,o.strings,this.options));r++}else this.__parts.push(void 0),r++;return s&&(document.adoptNode(e),customElements.upgrade(e)),e}}const g=` ${r} `;class y{constructor(e,t,s,i){this.strings=e,this.values=t,this.type=s,this.processor=i}getHTML(){const e=this.strings.length-1;let t="",s=!1;for(let i=0;i<e;i++){const e=this.strings[i],n=e.lastIndexOf("\x3c!--");s=(n>-1||s)&&-1===e.indexOf("--\x3e",n+1);const o=f.exec(e);t+=null===o?e+(s?g:a):e.substr(0,o.index)+o[1]+o[2]+d+o[3]+r}return t+=this.strings[e]}getTemplateElement(){const e=document.createElement("template");return e.innerHTML=this.getHTML(),e}}const b=e=>null===e||!("object"==typeof e||"function"==typeof e),_=e=>Array.isArray(e)||!(!e||!e[Symbol.iterator]);class v{constructor(e,t,s){this.dirty=!0,this.element=e,this.name=t,this.strings=s,this.parts=[];for(let e=0;e<s.length-1;e++)this.parts[e]=this._createPart()}_createPart(){return new w(this)}_getValue(){const e=this.strings,t=e.length-1;let s="";for(let i=0;i<t;i++){s+=e[i];const t=this.parts[i];if(void 0!==t){const e=t.value;if(b(e)||!_(e))s+="string"==typeof e?e:String(e);else for(const t of e)s+="string"==typeof t?t:String(t)}}return s+=e[t]}commit(){this.dirty&&(this.dirty=!1,this.element.setAttribute(this.name,this._getValue()))}}class w{constructor(e){this.value=void 0,this.committer=e}setValue(e){e===n||b(e)&&e===this.value||(this.value=e,t(e)||(this.committer.dirty=!0))}commit(){for(;t(this.value);){const e=this.value;this.value=n,e(this)}this.value!==n&&this.committer.commit()}}class S{constructor(e){this.value=void 0,this.__pendingValue=void 0,this.options=e}appendInto(e){this.startNode=e.appendChild(u()),this.endNode=e.appendChild(u())}insertAfterNode(e){this.startNode=e,this.endNode=e.nextSibling}appendIntoPart(e){e.__insert(this.startNode=u()),e.__insert(this.endNode=u())}insertAfterPart(e){e.__insert(this.startNode=u()),this.endNode=e.endNode,e.endNode=this.startNode}setValue(e){this.__pendingValue=e}commit(){for(;t(this.__pendingValue);){const e=this.__pendingValue;this.__pendingValue=n,e(this)}const e=this.__pendingValue;e!==n&&(b(e)?e!==this.value&&this.__commitText(e):e instanceof y?this.__commitTemplateResult(e):e instanceof Node?this.__commitNode(e):_(e)?this.__commitIterable(e):e===o?(this.value=o,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,s="string"==typeof(e=null==e?"":e)?e:String(e);t===this.endNode.previousSibling&&3===t.nodeType?t.data=s:this.__commitNode(document.createTextNode(s)),this.value=e}__commitTemplateResult(e){const t=this.options.templateFactory(e);if(this.value instanceof m&&this.value.template===t)this.value.update(e.values);else{const s=new m(t,e.processor,this.options),i=s._clone();s.update(e.values),this.__commitNode(i),this.value=s}}__commitIterable(e){Array.isArray(this.value)||(this.value=[],this.clear());const t=this.value;let s,i=0;for(const n of e)void 0===(s=t[i])&&(s=new S(this.options),t.push(s),0===i?s.appendIntoPart(this):s.insertAfterPart(t[i-1])),s.setValue(n),s.commit(),i++;i<t.length&&(t.length=i,this.clear(s&&s.endNode))}clear(e=this.startNode){i(this.startNode.parentNode,e.nextSibling,this.endNode)}}class x{constructor(e,t,s){if(this.value=void 0,this.__pendingValue=void 0,2!==s.length||""!==s[0]||""!==s[1])throw new Error("Boolean attributes can only contain a single expression");this.element=e,this.name=t,this.strings=s}setValue(e){this.__pendingValue=e}commit(){for(;t(this.__pendingValue);){const e=this.__pendingValue;this.__pendingValue=n,e(this)}if(this.__pendingValue===n)return;const e=!!this.__pendingValue;this.value!==e&&(e?this.element.setAttribute(this.name,""):this.element.removeAttribute(this.name),this.value=e),this.__pendingValue=n}}class k extends v{constructor(e,t,s){super(e,t,s),this.single=2===s.length&&""===s[0]&&""===s[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 w{}let E=!1;try{const e={get capture(){return E=!0,!1}};window.addEventListener("test",e,e),window.removeEventListener("test",e,e)}catch(e){}class P{constructor(e,t,s){this.value=void 0,this.__pendingValue=void 0,this.element=e,this.eventName=t,this.eventContext=s,this.__boundHandleEvent=e=>this.handleEvent(e)}setValue(e){this.__pendingValue=e}commit(){for(;t(this.__pendingValue);){const e=this.__pendingValue;this.__pendingValue=n,e(this)}if(this.__pendingValue===n)return;const e=this.__pendingValue,s=this.value,i=null==e||null!=s&&(e.capture!==s.capture||e.once!==s.once||e.passive!==s.passive),o=null!=e&&(null==s||i);i&&this.element.removeEventListener(this.eventName,this.__boundHandleEvent,this.__options),o&&(this.__options=R(e),this.element.addEventListener(this.eventName,this.__boundHandleEvent,this.__options)),this.value=e,this.__pendingValue=n}handleEvent(e){"function"==typeof this.value?this.value.call(this.eventContext||this.element,e):this.value.handleEvent(e)}}const R=e=>e&&(E?{capture:e.capture,passive:e.passive,once:e.once}:e.capture);const N=new class{handleAttributeExpressions(e,t,s,i){const n=t[0];if("."===n){return new k(e,t.slice(1),s).parts}return"@"===n?[new P(e,t.slice(1),i.eventContext)]:"?"===n?[new x(e,t.slice(1),s)]:new v(e,t,s).parts}handleTextExpression(e){return new S(e)}};function j(e){let t=$.get(e.type);void 0===t&&(t={stringsArray:new WeakMap,keyString:new Map},$.set(e.type,t));let s=t.stringsArray.get(e.strings);if(void 0!==s)return s;const i=e.strings.join(r);return void 0===(s=t.keyString.get(i))&&(s=new h(e,e.getTemplateElement()),t.keyString.set(i,s)),t.stringsArray.set(e.strings,s),s}const $=new Map,O=new WeakMap;(window.litHtmlVersions||(window.litHtmlVersions=[])).push("1.1.2");const T=(e,...t)=>new y(e,t,"html",N),A=133;function z(e,t){const{element:{content:s},parts:i}=e,n=document.createTreeWalker(s,A,null,!1);let o=V(i),r=i[o],a=-1,l=0;const d=[];let h=null;for(;n.nextNode();){a++;const e=n.currentNode;for(e.previousSibling===h&&(h=null),t.has(e)&&(d.push(e),null===h&&(h=e)),null!==h&&l++;void 0!==r&&r.index===a;)r.index=null!==h?-1:r.index-l,r=i[o=V(i,o)]}d.forEach(e=>e.parentNode.removeChild(e))}const B=e=>{let t=11===e.nodeType?0:1;const s=document.createTreeWalker(e,A,null,!1);for(;s.nextNode();)t++;return t},V=(e,t=-1)=>{for(let s=t+1;s<e.length;s++){const t=e[s];if(p(t))return s}return-1};const L=(e,t)=>`${e}--${t}`;let U=!0;void 0===window.ShadyCSS?U=!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."),U=!1);const M=e=>t=>{const s=L(t.type,e);let i=$.get(s);void 0===i&&(i={stringsArray:new WeakMap,keyString:new Map},$.set(s,i));let n=i.stringsArray.get(t.strings);if(void 0!==n)return n;const o=t.strings.join(r);if(void 0===(n=i.keyString.get(o))){const s=t.getTemplateElement();U&&window.ShadyCSS.prepareTemplateDom(s,e),n=new h(t,s),i.keyString.set(o,n)}return i.stringsArray.set(t.strings,n),n},q=["html","svg"],D=new Set,I=(e,t,s)=>{D.add(e);const i=s?s.element:document.createElement("template"),n=t.querySelectorAll("style"),{length:o}=n;if(0===o)return void window.ShadyCSS.prepareTemplateStyles(i,e);const r=document.createElement("style");for(let e=0;e<o;e++){const t=n[e];t.parentNode.removeChild(t),r.textContent+=t.textContent}(e=>{q.forEach(t=>{const s=$.get(L(t,e));void 0!==s&&s.keyString.forEach(e=>{const{element:{content:t}}=e,s=new Set;Array.from(t.querySelectorAll("style")).forEach(e=>{s.add(e)}),z(e,s)})})})(e);const a=i.content;s?function(e,t,s=null){const{element:{content:i},parts:n}=e;if(null==s)return void i.appendChild(t);const o=document.createTreeWalker(i,A,null,!1);let r=V(n),a=0,l=-1;for(;o.nextNode();){for(l++,o.currentNode===s&&(a=B(t),s.parentNode.insertBefore(t,s));-1!==r&&n[r].index===l;){if(a>0){for(;-1!==r;)n[r].index+=a,r=V(n,r);return}r=V(n,r)}}}(s,r,a.firstChild):a.insertBefore(r,a.firstChild),window.ShadyCSS.prepareTemplateStyles(i,e);const l=a.querySelector("style");if(window.ShadyCSS.nativeShadow&&null!==l)t.insertBefore(l.cloneNode(!0),t.firstChild);else if(s){a.insertBefore(r,a.firstChild);const e=new Set;e.add(r),z(s,e)}};window.JSCompiler_renameProperty=(e,t)=>e;const H={toAttribute(e,t){switch(t){case Boolean:return e?"":null;case Object:case Array:return null==e?e:JSON.stringify(e)}return e},fromAttribute(e,t){switch(t){case Boolean:return null!==e;case Number:return null===e?null:Number(e);case Object:case Array:return JSON.parse(e)}return e}},F=(e,t)=>t!==e&&(t==t||e==e),W={attribute:!0,type:String,converter:H,reflect:!1,hasChanged:F},J=Promise.resolve(!0),X=1,G=4,K=8,Q=16,Y=32,Z="finalized";class ee extends HTMLElement{constructor(){super(),this._updateState=0,this._instanceProperties=void 0,this._updatePromise=J,this._hasConnectedResolver=void 0,this._changedProperties=new Map,this._reflectingProperties=void 0,this.initialize()}static get observedAttributes(){this.finalize();const e=[];return this._classProperties.forEach((t,s)=>{const i=this._attributeNameForProperty(s,t);void 0!==i&&(this._attributeToPropertyMap.set(i,s),e.push(i))}),e}static _ensureClassProperties(){if(!this.hasOwnProperty(JSCompiler_renameProperty("_classProperties",this))){this._classProperties=new Map;const e=Object.getPrototypeOf(this)._classProperties;void 0!==e&&e.forEach((e,t)=>this._classProperties.set(t,e))}}static createProperty(e,t=W){if(this._ensureClassProperties(),this._classProperties.set(e,t),t.noAccessor||this.prototype.hasOwnProperty(e))return;const s="symbol"==typeof e?Symbol():`__${e}`;Object.defineProperty(this.prototype,e,{get(){return this[s]},set(t){const i=this[e];this[s]=t,this._requestUpdate(e,i)},configurable:!0,enumerable:!0})}static finalize(){const e=Object.getPrototypeOf(this);if(e.hasOwnProperty(Z)||e.finalize(),this[Z]=!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):[]];for(const s of t)this.createProperty(s,e[s])}}static _attributeNameForProperty(e,t){const s=t.attribute;return!1===s?void 0:"string"==typeof s?s:"string"==typeof e?e.toLowerCase():void 0}static _valueHasChanged(e,t,s=F){return s(e,t)}static _propertyValueFromAttribute(e,t){const s=t.type,i=t.converter||H,n="function"==typeof i?i:i.fromAttribute;return n?n(e,s):e}static _propertyValueToAttribute(e,t){if(void 0===t.reflect)return;const s=t.type,i=t.converter;return(i&&i.toAttribute||H.toAttribute)(e,s)}initialize(){this._saveInstanceProperties(),this._requestUpdate()}_saveInstanceProperties(){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)}})}_applyInstanceProperties(){this._instanceProperties.forEach((e,t)=>this[t]=e),this._instanceProperties=void 0}connectedCallback(){this._updateState=this._updateState|Y,this._hasConnectedResolver&&(this._hasConnectedResolver(),this._hasConnectedResolver=void 0)}disconnectedCallback(){}attributeChangedCallback(e,t,s){t!==s&&this._attributeToProperty(e,s)}_propertyToAttribute(e,t,s=W){const i=this.constructor,n=i._attributeNameForProperty(e,s);if(void 0!==n){const e=i._propertyValueToAttribute(t,s);if(void 0===e)return;this._updateState=this._updateState|K,null==e?this.removeAttribute(n):this.setAttribute(n,e),this._updateState=this._updateState&~K}}_attributeToProperty(e,t){if(this._updateState&K)return;const s=this.constructor,i=s._attributeToPropertyMap.get(e);if(void 0!==i){const e=s._classProperties.get(i)||W;this._updateState=this._updateState|Q,this[i]=s._propertyValueFromAttribute(t,e),this._updateState=this._updateState&~Q}}_requestUpdate(e,t){let s=!0;if(void 0!==e){const i=this.constructor,n=i._classProperties.get(e)||W;i._valueHasChanged(this[e],t,n.hasChanged)?(this._changedProperties.has(e)||this._changedProperties.set(e,t),!0!==n.reflect||this._updateState&Q||(void 0===this._reflectingProperties&&(this._reflectingProperties=new Map),this._reflectingProperties.set(e,n))):s=!1}!this._hasRequestedUpdate&&s&&this._enqueueUpdate()}requestUpdate(e,t){return this._requestUpdate(e,t),this.updateComplete}async _enqueueUpdate(){let e,t;this._updateState=this._updateState|G;const s=this._updatePromise;this._updatePromise=new Promise((s,i)=>{e=s,t=i});try{await s}catch(e){}this._hasConnected||await new Promise(e=>this._hasConnectedResolver=e);try{const e=this.performUpdate();null!=e&&await e}catch(e){t(e)}e(!this._hasRequestedUpdate)}get _hasConnected(){return this._updateState&Y}get _hasRequestedUpdate(){return this._updateState&G}get hasUpdated(){return this._updateState&X}performUpdate(){this._instanceProperties&&this._applyInstanceProperties();let e=!1;const t=this._changedProperties;try{(e=this.shouldUpdate(t))&&this.update(t)}catch(t){throw e=!1,t}finally{this._markUpdated()}e&&(this._updateState&X||(this._updateState=this._updateState|X,this.firstUpdated(t)),this.updated(t))}_markUpdated(){this._changedProperties=new Map,this._updateState=this._updateState&~G}get updateComplete(){return this._getUpdateComplete()}_getUpdateComplete(){return this._updatePromise}shouldUpdate(e){return!0}update(e){void 0!==this._reflectingProperties&&this._reflectingProperties.size>0&&(this._reflectingProperties.forEach((e,t)=>this._propertyToAttribute(t,this[t],e)),this._reflectingProperties=void 0)}updated(e){}firstUpdated(e){}}ee[Z]=!0;const te=e=>t=>"function"==typeof t?((e,t)=>(window.customElements.define(e,t),t))(e,t):((e,t)=>{const{kind:s,elements:i}=t;return{kind:s,elements:i,finisher(t){window.customElements.define(e,t)}}})(e,t),se=(e,t)=>"method"!==t.kind||!t.descriptor||"value"in t.descriptor?{kind:"field",key:Symbol(),placement:"own",descriptor:{},initializer(){"function"==typeof t.initializer&&(this[t.key]=t.initializer.call(this))},finisher(s){s.createProperty(t.key,e)}}:Object.assign({},t,{finisher(s){s.createProperty(t.key,e)}}),ie=(e,t,s)=>{t.constructor.createProperty(s,e)};function ne(e){return(t,s)=>void 0!==s?ie(e,t,s):se(e,t)}const oe="adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,re=Symbol();class ae{constructor(e,t){if(t!==re)throw new Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=e}get styleSheet(){return void 0===this._styleSheet&&(oe?(this._styleSheet=new CSSStyleSheet,this._styleSheet.replaceSync(this.cssText)):this._styleSheet=null),this._styleSheet}toString(){return this.cssText}}const le=(e,...t)=>{const s=t.reduce((t,s,i)=>t+(e=>{if(e instanceof ae)return e.cssText;if("number"==typeof e)return e;throw new Error(`Value passed to 'css' function must be a 'css' function result: ${e}. Use 'unsafeCSS' to pass non-literal values, but\n take care to ensure page security.`)})(s)+e[i+1],e[0]);return new ae(s,re)};(window.litElementVersions||(window.litElementVersions=[])).push("2.2.1");const de=e=>e.flat?e.flat(1/0):function e(t,s=[]){for(let i=0,n=t.length;i<n;i++){const n=t[i];Array.isArray(n)?e(n,s):s.push(n)}return s}(e);class he extends ee{static finalize(){super.finalize.call(this),this._styles=this.hasOwnProperty(JSCompiler_renameProperty("styles",this))?this._getUniqueStyles():this._styles||[]}static _getUniqueStyles(){const e=this.styles,t=[];if(Array.isArray(e)){de(e).reduceRight((e,t)=>(e.add(t),e),new Set).forEach(e=>t.unshift(e))}else e&&t.push(e);return t}initialize(){super.initialize(),this.renderRoot=this.createRenderRoot(),window.ShadowRoot&&this.renderRoot instanceof window.ShadowRoot&&this.adoptStyles()}createRenderRoot(){return this.attachShadow({mode:"open"})}adoptStyles(){const e=this.constructor._styles;0!==e.length&&(void 0===window.ShadyCSS||window.ShadyCSS.nativeShadow?oe?this.renderRoot.adoptedStyleSheets=e.map(e=>e.styleSheet):this._needsShimAdoptedStyleSheets=!0:window.ShadyCSS.ScopingShim.prepareAdoptedCssText(e.map(e=>e.cssText),this.localName))}connectedCallback(){super.connectedCallback(),this.hasUpdated&&void 0!==window.ShadyCSS&&window.ShadyCSS.styleElement(this)}update(e){super.update(e);const t=this.render();t instanceof y&&this.constructor.render(t,this.renderRoot,{scopeName:this.localName,eventContext:this}),this._needsShimAdoptedStyleSheets&&(this._needsShimAdoptedStyleSheets=!1,this.constructor._styles.forEach(e=>{const t=document.createElement("style");t.textContent=e.cssText,this.renderRoot.appendChild(t)}))}render(){}}he.finalized=!0,he.render=(e,t,s)=>{if(!s||"object"!=typeof s||!s.scopeName)throw new Error("The `scopeName` option is required.");const n=s.scopeName,o=O.has(t),r=U&&11===t.nodeType&&!!t.host,a=r&&!D.has(n),l=a?document.createDocumentFragment():t;if(((e,t,s)=>{let n=O.get(t);void 0===n&&(i(t,t.firstChild),O.set(t,n=new S(Object.assign({templateFactory:j},s))),n.appendInto(t)),n.setValue(e),n.commit()})(e,l,Object.assign({templateFactory:M(n)},s)),a){const e=O.get(l);O.delete(l);const s=e.value instanceof m?e.value.template:void 0;I(n,l,s),i(t,t.firstChild),t.appendChild(l),O.set(t,e)}!o&&r&&window.ShadyCSS.styleElement(t.host)};var ce=function(e,t,s,i){var n,o=arguments.length,r=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,s):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(e,t,s,i);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(r=(o<3?n(r):o>3?n(t,s,r):n(t,s))||r);return o>3&&r&&Object.defineProperty(t,s,r),r},pe=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},ue=function(e,t,s,i){return new(s||(s=Promise))((function(n,o){function r(e){try{l(i.next(e))}catch(e){o(e)}}function a(e){try{l(i.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?n(e.value):(t=e.value,t instanceof s?t:new s((function(e){e(t)}))).then(r,a)}l((i=i.apply(e,t||[])).next())}))};class fe extends he{constructor(){super(...arguments),this.disabled=!1,this.hidden=!1}connectedCallback(){super.connectedCallback(),this.id=this.id?this.id:"_"+Math.random().toString(36).substr(2,15)}fire(e,t,s=!0,i=!0){if(e){const n={detail:t,bubbles:"boolean"!=typeof s||s,composed:"boolean"!=typeof i||i};this.dispatchEvent(new CustomEvent(e,n))}}performUpdate(){const e=Object.create(null,{performUpdate:{get:()=>super.performUpdate}});return ue(this,void 0,void 0,(function*(){yield new Promise(e=>setTimeout(e)),yield e.performUpdate.call(this)}))}}ce([ne({type:Boolean,reflect:!0}),pe("design:type",Boolean)],fe.prototype,"disabled",void 0),ce([ne({type:Boolean,reflect:!0}),pe("design:type",Boolean)],fe.prototype,"hidden",void 0);var me=function(e,t,s,i){var n,o=arguments.length,r=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,s):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(e,t,s,i);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(r=(o<3?n(r):o>3?n(t,s,r):n(t,s))||r);return o>3&&r&&Object.defineProperty(t,s,r),r},ge=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)};let ye=class extends fe{constructor(){super(...arguments),this.open=!1,this.size=2,this._E_close="expand-item:close",this._E_open="expand-item:open"}static get styles(){return[le`:host { width: 100% }`,le`:host([disabled]) { cursor: not-allowed; opacity: 0.5; pointer-events: none; user-select: none }`,le`:host([hidden]) { display: none !important }`,le`details > .content { padding: 1rem }`,le`summary { align-items: center; cursor: pointer; display: flex; justify-contents: center; padding: 0.5rem 0.5rem 0.5rem 1rem }`,le`summary:focus, details:focus { outline: none }`,le`summary::-webkit-details-marker { display: none }`,le`.title { width: 100% }`,le`.title > ::slotted(*) { align-items: center; display: flex; flex-flow: row nowrap; justify-content: space-between; padding-left: 10px; user-select: none }`,le`.expand-item { display: block; line-height: 1.5; margin-bottom: 8px; width: 100% }`]}firstUpdated(){this.shadowRoot&&(this._details=this.shadowRoot.querySelector("details"),this._details.addEventListener("toggle",()=>{this.open=this._details.open,this.parentNode&&this.fire.apply(this.parentNode,[this.open?this._E_open:this._E_close,this])})),this.addEventListener("keydown",this._key),this.addEventListener("click",this._click)}render(){return T`<style>
.icon { border-radius: 50%; height: ${this.size}rem; width: ${this.size}rem }
.expand-item[open] > summary > .icon { background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' height='${this.size}rem' width='${this.size}rem' aria-hidden='true'%3E%3Ccircle cx='12' cy='12' r='10' fill='%23005eb8'%3E%3C/circle%3E%3Cpath fill='none' stroke='%23fff' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M8 12h8'%3E%3C/path%3E%3C/svg%3E%0A") center no-repeat }
.expand-item:not([open]) > summary > .icon { background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' height='${this.size}rem' width='${this.size}rem' aria-hidden='true'%3E%3Ccircle cx='12' cy='12' r='10' fill='%23005eb8'%3E%3C/circle%3E%3Cpath fill='none' stroke='%23fff' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M12 8v8M8 12h8'%3E%3C/path%3E%3C/svg%3E%0A") center no-repeat }
</style>
<details class="expand-item"
tabindex="${this.disabled?"":"0"}" ?open=${this.open}>
<summary role="button" tabindex="-1">
<div class="icon"><slot name="icon"></slot></div>
<div class="title"><slot name="title"></slot></div>
</summary>
<div class="content">
<slot name="content" aria-hidden="true" tabindex="-1"></slot>
</div>
</details>`}_click(e){if(this.disabled||this.hidden)return e.preventDefault(),void e.stopPropagation();this.open=this._details.open}_key(e){if(this.disabled||this.hidden)return e.preventDefault(),void e.stopPropagation();if(!e.isComposing&&229!==e.keyCode)switch(e.code){case"Space":this.open=!this.open}}};me([ne({type:Boolean,reflect:!0}),ge("design:type",Boolean)],ye.prototype,"open",void 0),me([ne({type:Number,reflect:!0}),ge("design:type",Number)],ye.prototype,"size",void 0),ye=me([te("expand-item")],ye);var be=function(e,t,s,i){var n,o=arguments.length,r=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,s):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(e,t,s,i);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(r=(o<3?n(r):o>3?n(t,s,r):n(t,s))||r);return o>3&&r&&Object.defineProperty(t,s,r),r},_e=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)};let ve=class extends fe{constructor(){super(...arguments),this.erase=!1,this.halign=!1,this.resizable=!1,this.sortable=!0,this.valign=!0,this._E_erase="item-collection:erased",this._E_sort="item-collection:sorted",this._observerConfig={attributes:!1,childList:!0,subtree:!1}}static get styles(){return[le`:host { max-height: inherit; max-width: inherit }`,le`:host([disabled]) { cursor: not-allowed; opacity: 0.5; pointer-events: none; user-select: none }`,le`:host([hidden]) { display: none !important }`,le`.item-collection:focus { outline: none }`,le`.item-collection { box-sizing: border-box; display: flex; height: 100%; max-height: inherit; min-width: inherit; min-height: 1rem; min-width: 4rem; width: 100% }`,le`.horizontal { align-items: flex-start; flex-flow: row nowrap;
justify-content: flex-start; overflow-x: auto; overflow-y: hidden }`,le`.resize-h:focus { border: dashed 1px #ccc; resize: horizontal }`,le`.resize-v:focus { border: dashed 1px #ccc; resize: vertical }`,le`.vertical { align-items: flex-start; flex-flow: column nowrap; justify-content: flex-start; overflow-x: hidden; overflow-y: auto }`]}attributeChangedCallback(e,t,s){super.attributeChangedCallback(e,t,s),this.shadowRoot&&0===this.shadowRoot.children.length||"erase"===e&&this._erase()}firstUpdated(){const e=new MutationObserver(t=>{let s=0;e.disconnect();for(let e of t)"childList"===e.type&&e.addedNodes.length>0&&this.sortable&&++s;s>0&&(this._sort(),s=0),e.observe(this,this._observerConfig)});e.observe(this,this._observerConfig)}render(){return T`<div class="item-collection${this.valign?" vertical":" horizontal"}${!this.disabled&&this.resizable&&this.valign?" resize-v":!this.disabled&&this.resizable&&this.halign?" resize-h":""}"
tabindex="${this.disabled?"":"0"}"
?disabled="${this.disabled}">
<slot></slot>
</div>`}_erase(){for(let e of[].slice.call(this.children))this.removeChild(e);this.erase=!1,this.fire.apply(this.parentNode,[this._E_erase,this])}_sort(){const e=[].slice.call(this.children).sort((e,t)=>(e.textContent||"")>(t.textContent||"")?1:-1);[].slice.call(this.children).map(e=>this.removeChild(e)),e.map(e=>this.appendChild(e)),this.fire.apply(this.parentNode,[this._E_sort,this])}};be([ne({type:Boolean,reflect:!0}),_e("design:type",Boolean)],ve.prototype,"erase",void 0),be([ne({type:Boolean,reflect:!0}),_e("design:type",Boolean)],ve.prototype,"halign",void 0),be([ne({type:Boolean,reflect:!0}),_e("design:type",Boolean)],ve.prototype,"resizable",void 0),be([ne({type:Boolean,reflect:!0}),_e("design:type",Boolean)],ve.prototype,"sortable",void 0),be([ne({type:Boolean,reflect:!0}),_e("design:type",Boolean)],ve.prototype,"valign",void 0),ve=be([te("item-collection")],ve);var we=function(e,t,s,i){var n,o=arguments.length,r=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,s):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(e,t,s,i);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(r=(o<3?n(r):o>3?n(t,s,r):n(t,s))||r);return o>3&&r&&Object.defineProperty(t,s,r),r},Se=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)};let xe=class extends fe{constructor(){super(...arguments),this.color="#eeeeee",this.deletable=!1,this.selectable=!1,this._E_del="list-item:delete",this._E_sel="list-item:select"}static get styles(){return[le`:host([disabled]) { cursor: not-allowed; opacity: 0.5; pointer-events: none; user-select: none }`,le`:host([hidden]) { display: none !important }`,le`.selectable { cursor: pointer }`,le`.list-item {
align-content: center; align-items: center;
display: flex; flex-flow: row nowrap; justify-content: center;
margin: 1px }`,le`.list-item:focus { outline: none }`,le`.bullet { border-radius: 50%; display: inline-block;
height: 0.8rem; width: 0.8rem }`,le`.text { display: inline-block; margin-left: 0.5rem }`]}firstUpdated(){this.addEventListener("keydown",this._key),this.addEventListener("click",this._click),this.addEventListener("blur",this._deselect),this.addEventListener("focus",this._select)}render(){return T`<style>.bullet { background-color: ${this.color}; border: 1px solid ${this.color} }</style>
<div class="list-item"
tabindex="${this.selectable&&!this.disabled?"0":""}"
?disabled="${this.disabled}">
<div class="bullet${this.selectable&&!this.disabled?" selectable":""}"></div>
<div class="text${this.selectable&&!this.disabled?" selectable":""}">
<slot></slot>
</div>
</div>`}_click(e){if(!this.disabled&&!this.hidden&&this.selectable&&(e.preventDefault(),e.stopPropagation(),this.shadowRoot)){this.shadowRoot.querySelector(".list-item").focus()}}_delete(){if(this.disabled||this.hidden||!this.deletable)return;let e=this.parentNode;this.nextElementSibling&&this.nextElementSibling.selectable?e=this.nextElementSibling:this.previousElementSibling&&this.previousElementSibling.selectable&&(e=this.previousElementSibling);const t=this.parentNode;t.removeChild(this),e.click(),this.fire.apply(t,[this._E_del,this])}_deselect(){this.disabled||this.hidden||!this.selectable||this.classList.contains("selected")&&this.classList.remove("selected")}_key(e){if(!this.disabled&&!this.hidden&&!e.isComposing&&229!==e.keyCode)switch(e.code){case"Backspace":case"Delete":this._delete()}}_select(){this.disabled||this.hidden||!this.selectable||this.classList.contains("selected")||(this.classList.add("selected"),this.fire.apply(this.parentNode,[this._E_sel,this]))}};we([ne({type:String,reflect:!0}),Se("design:type",String)],xe.prototype,"color",void 0),we([ne({type:Boolean,reflect:!0}),Se("design:type",Boolean)],xe.prototype,"deletable",void 0),we([ne({type:Boolean,reflect:!0}),Se("design:type",Boolean)],xe.prototype,"selectable",void 0),xe=we([te("list-item")],xe);var ke=function(e,t,s,i){var n,o=arguments.length,r=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,s):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(e,t,s,i);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(r=(o<3?n(r):o>3?n(t,s,r):n(t,s))||r);return o>3&&r&&Object.defineProperty(t,s,r),r},Ce=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)};let Ee=class extends fe{constructor(){super(...arguments),this.alignment="center",this.open=!1,this._E_close="modal-view:close",this._E_open="modal-view:open"}static get styles(){return[le`:host { pointer-events: none }`,le`:host([open]) { pointer-events: auto }`,le`.modal-view { opacity: 0; transition: opacity 500ms }`,le`.modal-view[open] {
background-color: rgba(0, 0, 0, 0.5); bottom: 0; display: block;
left: 0; opacity: 1; position: fixed; right: 0; top: 0;
transition: opacity 500ms; z-index: 10000 }`,le`.modal-content { position: absolute }`,le`.bottom { bottom: 0%; left: 50%; transform: translate(-50%, 0%); }`,le`.center { left: 50%; top: 50%; transform: translate(-50%, -50%); }`,le`.top { left: 50%; top: 0%; transform: translate(-50%, 0%); }`]}attributeChangedCallback(e,t,s){super.attributeChangedCallback(e,t,s),this.shadowRoot&&0===this.shadowRoot.children.length||"open"===e&&this.fire.apply(window,[this.open?this._E_open:this._E_close,this])}render(){return T`<div class="modal-view" ?open=${this.open}>
<div class="modal-content ${this.alignment}">
<slot></slot>
</div>
</div>`}};ke([ne({type:String,reflect:!0}),Ce("design:type",String)],Ee.prototype,"alignment",void 0),ke([ne({type:Boolean,reflect:!0}),Ce("design:type",Boolean)],Ee.prototype,"open",void 0),Ee=ke([te("modal-view")],Ee);var Pe=function(e,t,s,i){var n,o=arguments.length,r=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,s):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(e,t,s,i);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(r=(o<3?n(r):o>3?n(t,s,r):n(t,s))||r);return o>3&&r&&Object.defineProperty(t,s,r),r},Re=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)};let Ne=class extends fe{constructor(){super(),this.available=!0,this._E_off="network-connection:offline",this._E_on="network-connection:online",this.available=navigator.onLine}static get styles(){return[le`:host([hidden]) { display: none !important }`]}firstUpdated(){window.addEventListener("online",()=>this._update()),window.addEventListener("offline",()=>this._update())}render(){return T`<slot ?hidden="${this.available}"></slot>`}_update(){this.available=navigator.onLine,this.fire.apply(window,[this.available?this._E_on:this._E_off])}};Pe([ne({type:Boolean,reflect:!0}),Re("design:type",Boolean)],Ne.prototype,"available",void 0),Ne=Pe([te("network-connection"),Re("design:paramtypes",[])],Ne);var je=function(e,t,s,i){var n,o=arguments.length,r=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,s):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(e,t,s,i);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(r=(o<3?n(r):o>3?n(t,s,r):n(t,s))||r);return o>3&&r&&Object.defineProperty(t,s,r),r},$e=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)};let Oe=class extends fe{constructor(){super(...arguments),this.color="#000000",this.on=!1,this.size=4,this._E_chg="on-off:change"}static get styles(){return[le`:host { display: inline-block }`,le`:host([disabled]) { cursor: not-allowed; opacity: 0.5; pointer-events: none; user-select: none }`,le`:host([hidden]) { display: none !important }`,le`input {
-moz-appearance: none; -webkit-appearance: none; appearance: none;
background-color: #eee; border: 1px solid #ccc; border-radius: calc(4rem / 2);
box-shadow: 0 0 0 3px #ddd; cursor: pointer; outline: none;
position: relative; transition: background 450ms ease }`,le`input:before, input:after {
border-radius: 100%; content: ""; display: block; position: absolute;
transition: background 450ms ease, -webkit-transform 450ms ease;
transition: background 450ms ease, transform 450ms ease;
transition: background 450ms ease, transform 450ms ease, -webkit-transform 450ms ease;
}`,le`input:before { background-color: #999 }`,le`input:checked:before { transform: translateX(100%) }`]}render(){const e=this.size/2;return T`<style>input { height: ${e}rem; width: ${this.size}rem }
input:before { height: ${e}rem; width: ${e}rem }
input:checked:before { background-color: ${this.color}; }
</style>
<input type="checkbox"
?disabled="${this.disabled}"
.checked="${this.on}"
@change="${this._changeEvent}">`}update(e){super.update(e),e.has("checked")&&this._change(this.on)}_change(e){this.setAttribute("aria-checked",`${e}`),this.setAttribute("title",e?"on":"off"),this.fire.apply(this.parentNode,[this._E_chg,this])}_changeEvent(e){const t=e.composedPath()[0];this.on=t.checked,this.fire(this._E_chg,{sourceEvent:e})}};je([ne({type:String,reflect:!0}),$e("design:type",String)],Oe.prototype,"color",void 0),je([ne({type:Boolean,reflect:!0}),$e("design:type",Boolean)],Oe.prototype,"on",void 0),je([ne({type:Number,reflect:!0}),$e("design:type",Number)],Oe.prototype,"size",void 0),Oe=je([te("on-off")],Oe);var Te=function(e,t,s,i){var n,o=arguments.length,r=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,s):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(e,t,s,i);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(r=(o<3?n(r):o>3?n(t,s,r):n(t,s))||r);return o>3&&r&&Object.defineProperty(t,s,r),r},Ae=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)};let ze=class extends fe{constructor(){super(),this.mask="",this.maxlength=-1,this.minlength=-1,this.pattern=".*",this.placeholder="",this.spellcheck=!1,this.value="",this._re=/.*/}static get styles(){return[le`:host([disabled]) { cursor: not-allowed; opacity: 0.5; pointer-events: none; user-select: none }`,le`:host([hidden]) { display: none !important }`,le`input { border: 2px solid #aaa; box-sizing: border-box; padding: 4px; outline: transparent;
transition: border-color 0.25s ease, color 0.25s ease; z-index: 9 }`,le`input:focus { border: 2px solid #000 }`,le`input::placeholder { color: #aaa }`,le`input::-webkit-search-cancel-button { cursor: pointer }`]}attributeChangedCallback(e,t,s){super.attributeChangedCallback(e,t,s),this.shadowRoot&&0===this.shadowRoot.children.length||"mask"===e&&(this._re=new RegExp(s))}firstUpdated(){this.addEventListener("keydown",this._key),this.addEventListener("paste",this._paste),this.addEventListener("input",this._input),this._re=new RegExp(this.mask),this.shadowRoot&&(this._txt=this.shadowRoot.querySelector("input"))}render(){return T`<input type="search"
?disabled="${this.disabled}"
maxlength="${this.maxlength}"
minlength="${this.minlength}"
pattern="${this.pattern}"
placeholder="${this.placeholder}"
.value="${this.value}"
?spellcheck=${this.spellcheck}>`}_input(){this.value=this._txt.value}_key(e){return!this.disabled&&!this.hidden&&(!e.isComposing&&229!==e.keyCode&&(this._re.test(e.key)?void 0:(e.preventDefault(),e.stopPropagation(),!1)))}_paste(e){if(this.disabled||this.hidden)return!1;if(e.clipboardData){const t=e.clipboardData.getData("text/plain");if(!this._re.test(t))return e.preventDefault(),e.stopPropagation(),!1}}};Te([ne({type:String,reflect:!0}),Ae("design:type",String)],ze.prototype,"mask",void 0),Te([ne({type:Number,reflect:!0}),Ae("design:type",Number)],ze.prototype,"maxlength",void 0),Te([ne({type:Number,reflect:!0}),Ae("design:type",Number)],ze.prototype,"minlength",void 0),Te([ne({type:String,reflect:!0}),Ae("design:type",String)],ze.prototype,"pattern",void 0),Te([ne({type:String,reflect:!0}),Ae("design:type",String)],ze.prototype,"placeholder",void 0),Te([ne({type:Boolean,reflect:!0}),Ae("design:type",Boolean)],ze.prototype,"spellcheck",void 0),Te([ne({type:String,reflect:!0}),Ae("design:type",String)],ze.prototype,"value",void 0),ze=Te([te("text-input"),Ae("design:paramtypes",[])],ze);class Be{constructor(e){let t;if(this.r=0,this.g=0,this.b=0,e=e.toLowerCase().replace("#",""),void 0===Be.CSS[e])if(3===e.length){const t=e.substr(0,1);this.r=this._n(parseInt(`${t}${t}`,16));const s=e.substr(1,1);this.g=this._n(parseInt(`${s}${s}`,16));const i=e.substr(2,1);this.b=this._n(parseInt(`${i}${i}`,16))}else 6===e.length&&(t=parseInt(e,16),this.r=this._n(this._rshift(t)),this.g=this._n(this._gshift(t)),this.b=this._n(this._bshift(t)));else t=Be.CSS[e],this.r=this._n(this._rshift(t)),this.g=this._n(this._gshift(t)),this.b=this._n(this._bshift(t))}get brightness(){return(299*this.r+587*this.g+114*this.b)/1e3}colorDifference(e){return Math.max(this.r,e.r)-Math.min(this.r,e.r)+(Math.max(this.g,e.g)-Math.min(this.g,e.g))+(Math.max(this.b,e.b)-Math.min(this.b,e.b))}toCSSString(){const e=parseInt(this.toHex(),16);return Object.keys(Be.CSS).find(t=>Be.CSS[t]===e)}toHex(){return this._hex(this.r)+this._hex(this.g)+this._hex(this.b)}toString(){return"#"+this.toHex()}_rshift(e){return e>>16&255}_gshift(e){return e>>8&255}_bshift(e){return e>>0&255}_hex(e){return(e<16?"0":"")+e.toString(16)}_n(e){return e>255?255:e<0?0:e}}Be.brightnessThreshold=125,Be.CSS={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},Be.differenceThreshold=500;var Ve=function(e,t,s,i){var n,o=arguments.length,r=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,s):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(e,t,s,i);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(r=(o<3?n(r):o>3?n(t,s,r):n(t,s))||r);return o>3&&r&&Object.defineProperty(t,s,r),r},Le=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)};let Ue=class extends fe{constructor(){super(...arguments),this.color="#aaa",this.contenteditable="false",this.deletable=!1,this.label="",this.selectable=!1,this._E_del="text-tag:delete",this._E_sel="text-tag:select",this._foreColor="#000000"}static get styles(){return[le`:host([disabled]) { cursor: not-allowed; opacity: 0.5; pointer-events: none; user-select: none }`,le`:host([hidden]) { display: none !important }`,le`.selectable { cursor: pointer }`,le`.text-tag:focus { box-shadow: 0 0 0 4px #ffcd60; outline: none }`,le`mark { -webkit-box-decoration-break: clone; border-radius: 0.35em; box-decoration-break: clone; line-height: 1.3rem; margin: auto 0.25rem; padding: 0.2em; user-select: none }`,le`mark > span { font-size: 0.7em; font-weight: bold; text-transform: uppercase }`]}attributeChangedCallback(e,t,s){super.attributeChangedCallback(e,t,s),"color"===e&&(this._foreColor=new Be(s).brightness>Be.brightnessThreshold?"#000000":"#ffffff")}firstUpdated(){this._foreColor=new Be(this.color).brightness>Be.brightnessThreshold?"#000000":"#ffffff",this.addEventListener("click",this._click),this.addEventListener("keydown",this._key),this.addEventListener("blur",this._select),this.addEventListener("focus",this._select)}render(){return T`<style>.text-tag { background-color: ${this.color}; color: ${this._foreColor} }</style>
<mark class="text-tag${this.selectable?" selectable":""}"
tabindex="${this.selectable?"0":""}"
role="button"
?disabled="${this.disabled}">
<slot></slot>
<span>${this.label?" "+this.label:""}</span>
</mark>`}_click(){this.disabled||this.hidden||!this.selectable||this.shadowRoot&&this.shadowRoot.querySelector(".text-tag").focus()}_delete(){if(this.disabled||this.hidden||!this.deletable)return;const e=this.parentNode;this.fire.apply(e,[this._E_del,this]),this.insertAdjacentText("beforebegin",this.textContent||""),e.removeChild(this),e.normalize()}_key(e){if(!this.disabled&&!this.hidden&&this.selectable&&!e.isComposing&&229!==e.keyCode)switch(e.code){case"Backspace":case"Delete":this._delete()}}_select(){this.disabled||this.hidden||!this.selectable||(this.classList.contains("selected")?this.classList.remove("selected"):this.classList.add("selected"),this.fire.apply(this.parentNode,[this._E_sel,this]))}};Ve([ne({type:String,reflect:!0}),Le("design:type",String)],Ue.prototype,"color",void 0),Ve([ne({type:String,reflect:!0}),Le("design:type",String)],Ue.prototype,"contenteditable",void 0),Ve([ne({type:Boolean,reflect:!0}),Le("design:type",Boolean)],Ue.prototype,"deletable",void 0),Ve([ne({type:String,reflect:!0}),Le("design:type",String)],Ue.prototype,"label",void 0),Ve([ne({type:Boolean,reflect:!0}),Le("design:type",Boolean)],Ue.prototype,"selectable",void 0),Ue=Ve([te("text-tag")],Ue);export{ye as ExpandItem,ve as ItemCollection,xe as ListItem,Ee as ModalView,Ne as NetworkConnection,Oe as OnOff,ze as TextInput,Ue as TextTag};