@haxtheweb/haxcms-nodejs
Version:
HAXcms single and multisite nodejs server, api, and administration
6 lines • 16.9 kB
JavaScript
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/
const t=globalThis,debugLogEvent=e=>{t.emitLitDebugLogEvents&&t.dispatchEvent(new CustomEvent("lit-debug",{detail:e}))};let e,i=0;t.litIssuedWarnings??=new Set,e=(e,i)=>{i+=e?` See https://lit.dev/msg/${e} for more information.`:"",t.litIssuedWarnings.has(i)||t.litIssuedWarnings.has(e)||(console.warn(i),t.litIssuedWarnings.add(i))},queueMicrotask((()=>{e("dev-mode","Lit is in dev mode. Not recommended for production!")}));const n=t.ShadyDOM?.inUse&&!0===t.ShadyDOM?.noPatch?t.ShadyDOM.wrap:t=>t,s=t.trustedTypes,o=s?s.createPolicy("lit-html",{createHTML:t=>t}):void 0,identityFunction=t=>t,noopSanitizer=(t,e,i)=>identityFunction,setSanitizer=t=>{if(x!==noopSanitizer)throw new Error("Attempted to overwrite existing lit-html security policy. setSanitizeDOMValueFactory should be called at most once.");x=t},_testOnlyClearSanitizerFactoryDoNotCallOrElse=()=>{x=noopSanitizer},createSanitizer=(t,e,i)=>x(t,e,i),r="$lit$",a=`lit$${Math.random().toFixed(9).slice(2)}$`,l="?"+a,d=`<${l}>`,h=document,createMarker=()=>h.createComment(""),isPrimitive=t=>null===t||"object"!=typeof t&&"function"!=typeof t,c=Array.isArray,isIterable=t=>c(t)||"function"==typeof t?.[Symbol.iterator],m="[ \t\n\f\r]",p=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,u=/-->/g,_=/>/g,g=new RegExp(`>|${m}(?:([^\\s"'>=/]+)(${m}*=${m}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),$=/'/g,v=/"/g,f=/^(?:script|style|textarea|title)$/i,tag=t=>(i,...n)=>(i.some((t=>void 0===t))&&console.warn("Some template strings are undefined.\nThis is probably caused by illegal octal escape sequences."),n.some((t=>t?._$litStatic$))&&e("","Static values 'literal' or 'unsafeStatic' cannot be used as values to non-static templates.\nPlease use the static 'html' tag function. See https://lit.dev/docs/templates/expressions/#static-expressions"),{_$litType$:t,strings:i,values:n});export const html=tag(1);export const svg=tag(2);export const mathml=tag(3);export const noChange=Symbol.for("lit-noChange");export const nothing=Symbol.for("lit-nothing");const y=new WeakMap,b=h.createTreeWalker(h,129);let x=noopSanitizer;function trustFromTemplateString(t,e){if(!c(t)||!t.hasOwnProperty("raw")){let t="invalid template strings array";throw t="\n Internal Error: expected template strings to be an array\n with a 'raw' field. Faking a template strings array by\n calling html or svg like an ordinary function is effectively\n the same as calling unsafeHtml and can lead to major security\n issues, e.g. opening your code up to XSS attacks.\n If you're using the html or svg tagged template functions normally\n and still seeing this error, please file a bug at\n https://github.com/lit/lit/issues/new?template=bug_report.md\n and include information about your build tooling, if any.\n ".trim().replace(/\n */g,"\n"),new Error(t)}return void 0!==o?o.createHTML(e):e}const getTemplateHtml=(t,e)=>{const i=t.length-1,n=[];let s,o=2===e?"<svg>":3===e?"<math>":"",l=p;for(let e=0;e<i;e++){const i=t[e];let h,c,m=-1,y=0;for(;y<i.length&&(l.lastIndex=y,c=l.exec(i),null!==c);)if(y=l.lastIndex,l===p){if("!--"===c[1])l=u;else if(void 0!==c[1])l=_;else if(void 0!==c[2])f.test(c[2])&&(s=new RegExp(`</${c[2]}`,"g")),l=g;else if(void 0!==c[3])throw new Error("Bindings in tag names are not supported. Please use static templates instead. See https://lit.dev/docs/templates/expressions/#static-expressions")}else l===g?">"===c[0]?(l=s??p,m=-1):void 0===c[1]?m=-2:(m=l.lastIndex-c[2].length,h=c[1],l=void 0===c[3]?g:'"'===c[3]?v:$):l===v||l===$?l=g:l===u||l===_?l=p:(l=g,s=void 0);console.assert(-1===m||l===g||l===$||l===v,"unexpected parse state B");const b=l===g&&t[e+1].startsWith("/>")?" ":"";o+=l===p?i+d:m>=0?(n.push(h),i.slice(0,m)+r+i.slice(m)+a+b):i+a+(-2===m?e:b)}return[trustFromTemplateString(t,o+(t[i]||"<?>")+(2===e?"</svg>":3===e?"</math>":"")),n]};class Template{constructor({strings:t,_$litType$:i},n){let o;this.parts=[];let d=0,h=0;const c=t.length-1,m=this.parts,[p,u]=getTemplateHtml(t,i);if(this.el=Template.createElement(p,n),b.currentNode=this.el.content,2===i||3===i){const t=this.el.content.firstChild;t.replaceWith(...t.childNodes)}for(;null!==(o=b.nextNode())&&m.length<c;){if(1===o.nodeType){{const t=o.localName;if(/^(?:textarea|template)$/i.test(t)&&o.innerHTML.includes(a)){const i=`Expressions are not supported inside \`${t}\` elements. See https://lit.dev/msg/expression-in-${t} for more information.`;if("template"===t)throw new Error(i);e("",i)}}if(o.hasAttributes())for(const t of o.getAttributeNames())if(t.endsWith(r)){const e=u[h++],i=o.getAttribute(t).split(a),n=/([.?@])?(.*)/.exec(e);m.push({type:1,index:d,name:n[2],strings:i,ctor:"."===n[1]?PropertyPart:"?"===n[1]?BooleanAttributePart:"@"===n[1]?EventPart:AttributePart}),o.removeAttribute(t)}else t.startsWith(a)&&(m.push({type:6,index:d}),o.removeAttribute(t));if(f.test(o.tagName)){const t=o.textContent.split(a),e=t.length-1;if(e>0){o.textContent=s?s.emptyScript:"";for(let i=0;i<e;i++)o.append(t[i],createMarker()),b.nextNode(),m.push({type:2,index:++d});o.append(t[e],createMarker())}}}else if(8===o.nodeType){if(o.data===l)m.push({type:2,index:d});else{let t=-1;for(;-1!==(t=o.data.indexOf(a,t+1));)m.push({type:7,index:d}),t+=a.length-1}}d++}if(u.length!==h)throw new Error('Detected duplicate attribute bindings. This occurs if your template has duplicate attributes on an element tag. For example "<input ?disabled=${true} ?disabled=${false}>" contains a duplicate "disabled" attribute. The error was detected in the following template: \n`'+t.join("${...}")+"`");debugLogEvent&&debugLogEvent({kind:"template prep",template:this,clonableTemplate:this.el,parts:this.parts,strings:t})}static createElement(t,e){const i=h.createElement("template");return i.innerHTML=t,i}}function resolveDirective(t,e,i=t,n){if(e===noChange)return e;let s=void 0!==n?i.__directives?.[n]:i.__directive;const o=isPrimitive(e)?void 0:e._$litDirective$;return s?.constructor!==o&&(s?._$notifyDirectiveConnectionChanged?.(!1),void 0===o?s=void 0:(s=new o(t),s._$initialize(t,i,n)),void 0!==n?(i.__directives??=[])[n]=s:i.__directive=s),void 0!==s&&(e=resolveDirective(t,s._$resolve(t,e.values),s,n)),e}class TemplateInstance{constructor(t,e){this._$parts=[],this._$disconnectableChildren=void 0,this._$template=t,this._$parent=e}get parentNode(){return this._$parent.parentNode}get _$isConnected(){return this._$parent._$isConnected}_clone(t){const{el:{content:e},parts:i}=this._$template,n=(t?.creationScope??h).importNode(e,!0);b.currentNode=n;let s=b.nextNode(),o=0,r=0,a=i[0];for(;void 0!==a;){if(o===a.index){let e;2===a.type?e=new ChildPart(s,s.nextSibling,this,t):1===a.type?e=new a.ctor(s,a.name,a.strings,this,t):6===a.type&&(e=new ElementPart(s,this,t)),this._$parts.push(e),a=i[++r]}o!==a?.index&&(s=b.nextNode(),o++)}return b.currentNode=h,n}_update(t){let e=0;for(const i of this._$parts)void 0!==i&&(debugLogEvent&&debugLogEvent({kind:"set part",part:i,value:t[e],valueIndex:e,values:t,templateInstance:this}),void 0!==i.strings?(i._$setValue(t,i,e),e+=i.strings.length-2):i._$setValue(t[e])),e++}}class ChildPart{get _$isConnected(){return this._$parent?._$isConnected??this.__isConnected}constructor(t,e,i,n){this.type=2,this._$committedValue=nothing,this._$disconnectableChildren=void 0,this._$startNode=t,this._$endNode=e,this._$parent=i,this.options=n,this.__isConnected=n?.isConnected??!0,this._textSanitizer=void 0}get parentNode(){let t=n(this._$startNode).parentNode;const e=this._$parent;return void 0!==e&&11===t?.nodeType&&(t=e.parentNode),t}get startNode(){return this._$startNode}get endNode(){return this._$endNode}_$setValue(t,e=this){if(null===this.parentNode)throw new Error("This `ChildPart` has no `parentNode` and therefore cannot accept a value. This likely means the element containing the part was manipulated in an unsupported way outside of Lit's control such that the part's marker nodes were ejected from DOM. For example, setting the element's `innerHTML` or `textContent` can do this.");if(t=resolveDirective(this,t,e),isPrimitive(t))t===nothing||null==t||""===t?(this._$committedValue!==nothing&&(debugLogEvent&&debugLogEvent({kind:"commit nothing to child",start:this._$startNode,end:this._$endNode,parent:this._$parent,options:this.options}),this._$clear()),this._$committedValue=nothing):t!==this._$committedValue&&t!==noChange&&this._commitText(t);else if(void 0!==t._$litType$)this._commitTemplateResult(t);else if(void 0!==t.nodeType){if(this.options?.host===t)return this._commitText("[probable mistake: rendered a template's host in itself (commonly caused by writing ${this} in a template]"),void console.warn("Attempted to render the template host",t,"inside itself. This is almost always a mistake, and in dev mode ","we render some warning text. In production however, we'll ","render it, which will usually result in an error, and sometimes ","in the element disappearing from the DOM.");this._commitNode(t)}else isIterable(t)?this._commitIterable(t):this._commitText(t)}_insert(t){return n(n(this._$startNode).parentNode).insertBefore(t,this._$endNode)}_commitNode(t){if(this._$committedValue!==t){if(this._$clear(),x!==noopSanitizer){const t=this._$startNode.parentNode?.nodeName;if("STYLE"===t||"SCRIPT"===t){let e="Forbidden";throw e="STYLE"===t?"Lit does not support binding inside style nodes. This is a security risk, as style injection attacks can exfiltrate data and spoof UIs. Consider instead using css`...` literals to compose styles, and do dynamic styling with css custom properties, ::parts, <slot>s, and by mutating the DOM rather than stylesheets.":"Lit does not support binding inside script nodes. This is a security risk, as it could allow arbitrary code execution.",new Error(e)}}debugLogEvent&&debugLogEvent({kind:"commit node",start:this._$startNode,parent:this._$parent,value:t,options:this.options}),this._$committedValue=this._insert(t)}}_commitText(t){if(this._$committedValue!==nothing&&isPrimitive(this._$committedValue)){const e=n(this._$startNode).nextSibling;void 0===this._textSanitizer&&(this._textSanitizer=createSanitizer(e,"data","property")),t=this._textSanitizer(t),debugLogEvent&&debugLogEvent({kind:"commit text",node:e,value:t,options:this.options}),e.data=t}else{const e=h.createTextNode("");this._commitNode(e),void 0===this._textSanitizer&&(this._textSanitizer=createSanitizer(e,"data","property")),t=this._textSanitizer(t),debugLogEvent&&debugLogEvent({kind:"commit text",node:e,value:t,options:this.options}),e.data=t}this._$committedValue=t}_commitTemplateResult(t){const{values:e,_$litType$:i}=t,n="number"==typeof i?this._$getTemplate(t):(void 0===i.el&&(i.el=Template.createElement(trustFromTemplateString(i.h,i.h[0]),this.options)),i);if(this._$committedValue?._$template===n)debugLogEvent&&debugLogEvent({kind:"template updating",template:n,instance:this._$committedValue,parts:this._$committedValue._$parts,options:this.options,values:e}),this._$committedValue._update(e);else{const t=new TemplateInstance(n,this),i=t._clone(this.options);debugLogEvent&&debugLogEvent({kind:"template instantiated",template:n,instance:t,parts:t._$parts,options:this.options,fragment:i,values:e}),t._update(e),debugLogEvent&&debugLogEvent({kind:"template instantiated and updated",template:n,instance:t,parts:t._$parts,options:this.options,fragment:i,values:e}),this._commitNode(i),this._$committedValue=t}}_$getTemplate(t){let e=y.get(t.strings);return void 0===e&&y.set(t.strings,e=new Template(t)),e}_commitIterable(t){c(this._$committedValue)||(this._$committedValue=[],this._$clear());const e=this._$committedValue;let i,s=0;for(const n of t)s===e.length?e.push(i=new ChildPart(this._insert(createMarker()),this._insert(createMarker()),this,this.options)):i=e[s],i._$setValue(n),s++;s<e.length&&(this._$clear(i&&n(i._$endNode).nextSibling,s),e.length=s)}_$clear(t=n(this._$startNode).nextSibling,e){for(this._$notifyConnectionChanged?.(!1,!0,e);t&&t!==this._$endNode;){const e=n(t).nextSibling;n(t).remove(),t=e}}setConnected(t){if(void 0!==this._$parent)throw new Error("part.setConnected() may only be called on a RootPart returned from render().");this.__isConnected=t,this._$notifyConnectionChanged?.(t)}}class AttributePart{get tagName(){return this.element.tagName}get _$isConnected(){return this._$parent._$isConnected}constructor(t,e,i,n,s){this.type=1,this._$committedValue=nothing,this._$disconnectableChildren=void 0,this.element=t,this.name=e,this._$parent=n,this.options=s,i.length>2||""!==i[0]||""!==i[1]?(this._$committedValue=new Array(i.length-1).fill(new String),this.strings=i):this._$committedValue=nothing,this._sanitizer=void 0}_$setValue(t,e=this,i,n){const s=this.strings;let o=!1;if(void 0===s)t=resolveDirective(this,t,e,0),o=!isPrimitive(t)||t!==this._$committedValue&&t!==noChange,o&&(this._$committedValue=t);else{const n=t;let r,a;for(t=s[0],r=0;r<s.length-1;r++)a=resolveDirective(this,n[i+r],e,r),a===noChange&&(a=this._$committedValue[r]),o||=!isPrimitive(a)||a!==this._$committedValue[r],a===nothing?t=nothing:t!==nothing&&(t+=(a??"")+s[r+1]),this._$committedValue[r]=a}o&&!n&&this._commitValue(t)}_commitValue(t){t===nothing?n(this.element).removeAttribute(this.name):(void 0===this._sanitizer&&(this._sanitizer=x(this.element,this.name,"attribute")),t=this._sanitizer(t??""),debugLogEvent&&debugLogEvent({kind:"commit attribute",element:this.element,name:this.name,value:t,options:this.options}),n(this.element).setAttribute(this.name,t??""))}}class PropertyPart extends AttributePart{constructor(){super(...arguments),this.type=3}_commitValue(t){void 0===this._sanitizer&&(this._sanitizer=x(this.element,this.name,"property")),t=this._sanitizer(t),debugLogEvent&&debugLogEvent({kind:"commit property",element:this.element,name:this.name,value:t,options:this.options}),this.element[this.name]=t===nothing?void 0:t}}class BooleanAttributePart extends AttributePart{constructor(){super(...arguments),this.type=4}_commitValue(t){debugLogEvent&&debugLogEvent({kind:"commit boolean attribute",element:this.element,name:this.name,value:!(!t||t===nothing),options:this.options}),n(this.element).toggleAttribute(this.name,!!t&&t!==nothing)}}class EventPart extends AttributePart{constructor(t,e,i,n,s){if(super(t,e,i,n,s),this.type=5,void 0!==this.strings)throw new Error(`A \`<${t.localName}>\` has a \`@${e}=...\` listener with invalid content. Event listeners in templates must have exactly one expression and no surrounding text.`)}_$setValue(t,e=this){if((t=resolveDirective(this,t,e,0)??nothing)===noChange)return;const i=this._$committedValue,n=t===nothing&&i!==nothing||t.capture!==i.capture||t.once!==i.once||t.passive!==i.passive,s=t!==nothing&&(i===nothing||n);debugLogEvent&&debugLogEvent({kind:"commit event listener",element:this.element,name:this.name,value:t,options:this.options,removeListener:n,addListener:s,oldListener:i}),n&&this.element.removeEventListener(this.name,this,i),s&&this.element.addEventListener(this.name,this,t),this._$committedValue=t}handleEvent(t){"function"==typeof this._$committedValue?this._$committedValue.call(this.options?.host??this.element,t):this._$committedValue.handleEvent(t)}}class ElementPart{constructor(t,e,i){this.element=t,this.type=6,this._$disconnectableChildren=void 0,this._$parent=e,this.options=i}get _$isConnected(){return this._$parent._$isConnected}_$setValue(t){debugLogEvent&&debugLogEvent({kind:"commit to element binding",element:this.element,value:t,options:this.options}),resolveDirective(this,t)}}export const _$LH={_boundAttributeSuffix:r,_marker:a,_markerMatch:l,_HTML_RESULT:1,_getTemplateHtml:getTemplateHtml,_TemplateInstance:TemplateInstance,_isIterable:isIterable,_resolveDirective:resolveDirective,_ChildPart:ChildPart,_AttributePart:AttributePart,_BooleanAttributePart:BooleanAttributePart,_EventPart:EventPart,_PropertyPart:PropertyPart,_ElementPart:ElementPart};const w=t.litHtmlPolyfillSupportDevMode;w?.(Template,ChildPart),(t.litHtmlVersions??=[]).push("3.3.0"),t.litHtmlVersions.length>1&&queueMicrotask((()=>{e("multiple-versions","Multiple versions of Lit loaded. Loading multiple versions is not recommended.")}));export const render=(t,e,n)=>{if(null==e)throw new TypeError(`The container to render into may not be ${e}`);const s=i++,o=n?.renderBefore??e;let r=o._$litPart$;if(debugLogEvent&&debugLogEvent({kind:"begin render",id:s,value:t,container:e,options:n,part:r}),void 0===r){const t=n?.renderBefore??null;o._$litPart$=r=new ChildPart(e.insertBefore(createMarker(),t),t,void 0,n??{})}return r._$setValue(t),debugLogEvent&&debugLogEvent({kind:"end render",id:s,value:t,container:e,options:n,part:r}),r};render.setSanitizer=setSanitizer,render.createSanitizer=createSanitizer,render._testOnlyClearSanitizerFactoryDoNotCallOrElse=_testOnlyClearSanitizerFactoryDoNotCallOrElse;