From d5e64ea13aaf702e1bcbb43ef7e7ea447253a1c1 Mon Sep 17 00:00:00 2001 From: Nerwyn Singh Date: Sat, 27 Jul 2024 23:40:55 -0400 Subject: [PATCH] disable webkit tap highlight color on all elements including button sub-element --- dist/android-tv-card.min.js | 2 +- src/classes/remote-button.ts | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/dist/android-tv-card.min.js b/dist/android-tv-card.min.js index 48e74ab5..4d87eae4 100644 --- a/dist/android-tv-card.min.js +++ b/dist/android-tv-card.min.js @@ -1,5 +1,5 @@ /*! For license information please see android-tv-card.min.js.LICENSE.txt */ -(()=>{var t={767:(t,e,i)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.CONTEXT=void 0;const n=i(178),o=i(662),r=i(109);e.CONTEXT=t=>({True:!0,False:!1,None:null,hass:t,states:e=>(0,n.states)(t,e),is_state:(e,i)=>(0,n.is_state)(t,e,i),state_attr:(e,i)=>(0,n.state_attr)(t,e,i),is_state_attr:(e,i,o)=>(0,n.is_state_attr)(t,e,i,o),has_value:e=>(0,n.has_value)(t,e),iif:(e,i,n,r)=>(0,o.iif)(t,e,i,n,r),match_media:t=>(0,r.match_media)(t)})},865:function(t,e,i){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,i,n){void 0===n&&(n=i);var o=Object.getOwnPropertyDescriptor(e,i);o&&!("get"in o?!e.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return e[i]}}),Object.defineProperty(t,n,o)}:function(t,e,i,n){void 0===n&&(n=i),t[n]=e[i]}),o=this&&this.__exportStar||function(t,e){for(var i in t)"default"===i||Object.prototype.hasOwnProperty.call(e,i)||n(e,t,i)};Object.defineProperty(e,"__esModule",{value:!0}),o(i(537),e)},537:(t,e,i)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.renderTemplate=void 0;const n=i(802),o=i(767);e.renderTemplate=function(t,e,i){if("string"==typeof e&&(e.includes("{{")&&e.includes("}}")||e.includes("{%")&&e.includes("%}"))){if(e=(0,n.renderString)(structuredClone(e),Object.assign(Object.assign({},(0,o.CONTEXT)(t)),i)).trim(),[void 0,null,"undefined","null","None"].includes(e))return"";if("true"==e.toLowerCase())return!0;if("false"==e.toLowerCase())return!1}return e}},109:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.match_media=void 0,e.match_media=function(t){return window.matchMedia(t).matches}},662:(t,e,i)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.iif=void 0;const n=i(865);e.iif=function(t,e,i,o,r){if(r){const i=(0,n.renderTemplate)(t,e);if([void 0,null,"undefined","null","None"].includes(i))return r}const s=`\n\t\t{% if ${e} %}\n\t\t${null==i||i}\n\t\t{% else %}\n\t\t${null!=o&&o}\n\t\t{% endif %}\n\t`;return(0,n.renderTemplate)(t,s)}},178:(t,e)=>{"use strict";function i(t,e){try{return t.states[e].state}catch(t){return}}function n(t,e,i){try{return t.states[e].attributes[i]}catch(t){return}}Object.defineProperty(e,"__esModule",{value:!0}),e.has_value=e.is_state_attr=e.state_attr=e.is_state=e.states=void 0,e.states=i,e.is_state=function(t,e,n){try{const o=i(t,e);return Array.isArray(n)?n.includes(o):o==n}catch(t){return!1}},e.state_attr=n,e.is_state_attr=function(t,e,i,o){try{const r=n(t,e,i);return Array.isArray(o)?o.includes(r):r==o}catch(t){return!1}},e.has_value=function(t,e){try{const n=i(t,e);return!![!1,0,-0,""].includes(n)||Boolean(n)}catch(t){return!1}}},802:function(t){var e;"undefined"!=typeof self&&self,e=function(){return function(t){var e={};function i(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,i),o.l=!0,o.exports}return i.m=t,i.c=e,i.d=function(t,e,n){i.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:n})},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="",i(i.s=11)}([function(t,e,i){"use strict";var n=Array.prototype,o=Object.prototype,r={"&":"&",'"':""","'":"'","<":"<",">":">","\\":"\"},s=/[&"'<>\\]/g;function a(t,e){return o.hasOwnProperty.call(t,e)}function c(t){return r[t]}function l(t,e,i){var n,o,r;if(t instanceof Error&&(t=(o=t).name+": "+o.message),Object.setPrototypeOf?(n=new Error(t),Object.setPrototypeOf(n,l.prototype)):(n=this,Object.defineProperty(n,"message",{enumerable:!1,writable:!0,value:t})),Object.defineProperty(n,"name",{value:"Template render error"}),Error.captureStackTrace&&Error.captureStackTrace(n,this.constructor),o){var s=Object.getOwnPropertyDescriptor(o,"stack");(r=s&&(s.get||function(){return s.value}))||(r=function(){return o.stack})}else{var a=new Error(t).stack;r=function(){return a}}return Object.defineProperty(n,"stack",{get:function(){return r.call(n)}}),Object.defineProperty(n,"cause",{value:o}),n.lineno=e,n.colno=i,n.firstUpdate=!0,n.Update=function(t){var e="("+(t||"unknown path")+")";return this.firstUpdate&&(this.lineno&&this.colno?e+=" [Line "+this.lineno+", Column "+this.colno+"]":this.lineno&&(e+=" [Line "+this.lineno+"]")),e+="\n ",this.firstUpdate&&(e+=" "),this.message=e+(this.message||""),this.firstUpdate=!1,this},n}function h(t){return"[object Function]"===o.toString.call(t)}function u(t){return"[object Array]"===o.toString.call(t)}function p(t){return"[object String]"===o.toString.call(t)}function d(t){return"[object Object]"===o.toString.call(t)}function f(t){var e,i=(e=t)?"string"==typeof e?e.split("."):[e]:[];return function(t){for(var e=t,n=0;nt.length)s=o.slice(0,t.length),o.slice(s.length,l).forEach((function(t,i){i2?o-2:0),s=2;s0||!i)&&process.stdout.write(" ".repeat(e));var r=o===n.length-1?"":"\n";process.stdout.write(""+t+r)}))}t.exports={Node:c,Root:u,NodeList:h,Value:l,Literal:p,Symbol:d,Group:f,Array:m,Pair:v,Dict:y,Output:D,Capture:V,TemplateData:H,If:g,IfAsync:b,InlineIf:C,For:k,AsyncEach:L,AsyncAll:w,Macro:x,Caller:A,Import:E,FromImport:T,FunCall:O,Filter:S,FilterAsync:M,KeywordArgs:I,Block:N,Super:$,Extends:R,Include:P,Set:j,Switch:F,Case:B,LookupVal:_,BinOp:U,In:Z,Is:z,Or:W,And:Y,Not:G,Add:q,Concat:X,Sub:J,Mul:Q,Div:tt,FloorDiv:et,Mod:it,Pow:nt,Neg:ot,Pos:rt,Compare:st,CompareOperand:at,CallExtension:ct,CallExtensionAsync:lt,printNodes:function t(e,i){if(i=i||0,ht(e.typename+": ",i),e instanceof h)ht("\n"),e.children.forEach((function(e){t(e,i+2)}));else if(e instanceof ct)ht(e.extName+"."+e.prop+"\n"),e.args&&t(e.args,i+2),e.contentArgs&&e.contentArgs.forEach((function(e){t(e,i+2)}));else{var n=[],o=null;e.iterFields((function(t,e){t instanceof c?n.push([e,t]):(o=o||{})[e]=t})),o?ht(JSON.stringify(o,null,2)+"\n",null,!0):ht("\n"),n.forEach((function(e){var n=e[0],o=e[1];ht("["+n+"] =>",i+2),t(o,i+4)}))}}}},function(t,e){},function(t,e,i){"use strict";function n(t,e){return n=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},n(t,e)}var o=i(8),r=i(17),s=i(3),a=i(0).TemplateError,c=i(2).Frame,l=i(1).Obj,h={"==":"==","===":"===","!=":"!=","!==":"!==","<":"<",">":">","<=":"<=",">=":">="},u=function(t){var e,i;function o(){return t.apply(this,arguments)||this}i=t,(e=o).prototype=Object.create(i.prototype),e.prototype.constructor=e,n(e,i);var r=o.prototype;return r.init=function(t,e){this.templateName=t,this.codebuf=[],this.lastId=0,this.buffer=null,this.bufferStack=[],this._scopeClosers="",this.inBlock=!1,this.throwOnUndefined=e},r.fail=function(t,e,i){throw void 0!==e&&(e+=1),void 0!==i&&(i+=1),new a(t,e,i)},r._pushBuffer=function(){var t=this._tmpid();return this.bufferStack.push(this.buffer),this.buffer=t,this._emit("var "+this.buffer+' = "";'),t},r._popBuffer=function(){this.buffer=this.bufferStack.pop()},r._emit=function(t){this.codebuf.push(t)},r._emitLine=function(t){this._emit(t+"\n")},r._emitLines=function(){for(var t=this,e=arguments.length,i=new Array(e),n=0;n0&&o._emit(","),o.compile(t,e)})),n&&this._emit(n)},r._compileExpression=function(t,e){this.assertType(t,s.Literal,s.Symbol,s.Group,s.Array,s.Dict,s.FunCall,s.Caller,s.Filter,s.LookupVal,s.Compare,s.InlineIf,s.In,s.Is,s.And,s.Or,s.Not,s.Add,s.Concat,s.Sub,s.Mul,s.Div,s.FloorDiv,s.Mod,s.Pow,s.Neg,s.Pos,s.Compare,s.NodeList),this.compile(t,e)},r.assertType=function(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),n=1;n0&&n._emit(","),t){n._emitLine("function(cb) {"),n._emitLine("if(!cb) { cb = function(err) { if(err) { throw err; }}}");var o=n._pushBuffer();n._withScopedSyntax((function(){n.compile(t,e),n._emitLine("cb(null, "+o+");")})),n._popBuffer(),n._emitLine("return "+o+";"),n._emitLine("}")}else n._emit("null")})),i){var c=this._tmpid();this._emitLine(", "+this._makeCallback(c)),this._emitLine(this.buffer+" += runtime.suppressValue("+c+", "+a+" && env.opts.autoescape);"),this._addScopeLevel()}else this._emit(")"),this._emit(", "+a+" && env.opts.autoescape);\n")},r.compileCallExtensionAsync=function(t,e){this.compileCallExtension(t,e,!0)},r.compileNodeList=function(t,e){this._compileChildren(t,e)},r.compileLiteral=function(t){if("string"==typeof t.value){var e=t.value.replace(/\\/g,"\\\\");e=(e=(e=(e=(e=e.replace(/"/g,'\\"')).replace(/\n/g,"\\n")).replace(/\r/g,"\\r")).replace(/\t/g,"\\t")).replace(/\u2028/g,"\\u2028"),this._emit('"'+e+'"')}else null===t.value?this._emit("null"):this._emit(t.value.toString())},r.compileSymbol=function(t,e){var i=t.value,n=e.lookup(i);n?this._emit(n):this._emit('runtime.contextOrFrameLookup(context, frame, "'+i+'")')},r.compileGroup=function(t,e){this._compileAggregate(t,e,"(",")")},r.compileArray=function(t,e){this._compileAggregate(t,e,"[","]")},r.compileDict=function(t,e){this._compileAggregate(t,e,"{","}")},r.compilePair=function(t,e){var i=t.key,n=t.value;i instanceof s.Symbol?i=new s.Literal(i.lineno,i.colno,i.value):i instanceof s.Literal&&"string"==typeof i.value||this.fail("compilePair: Dict keys must be strings or names",i.lineno,i.colno),this.compile(i,e),this._emit(": "),this._compileExpression(n,e)},r.compileInlineIf=function(t,e){this._emit("("),this.compile(t.cond,e),this._emit("?"),this.compile(t.body,e),this._emit(":"),null!==t.else_?this.compile(t.else_,e):this._emit('""'),this._emit(")")},r.compileIn=function(t,e){this._emit("runtime.inOperator("),this.compile(t.left,e),this._emit(","),this.compile(t.right,e),this._emit(")")},r.compileIs=function(t,e){var i=t.right.name?t.right.name.value:t.right.value;this._emit('env.getTest("'+i+'").call(context, '),this.compile(t.left,e),t.right.args&&(this._emit(","),this.compile(t.right.args,e)),this._emit(") === true")},r._binOpEmitter=function(t,e,i){this.compile(t.left,e),this._emit(i),this.compile(t.right,e)},r.compileOr=function(t,e){return this._binOpEmitter(t,e," || ")},r.compileAnd=function(t,e){return this._binOpEmitter(t,e," && ")},r.compileAdd=function(t,e){return this._binOpEmitter(t,e," + ")},r.compileConcat=function(t,e){return this._binOpEmitter(t,e,' + "" + ')},r.compileSub=function(t,e){return this._binOpEmitter(t,e," - ")},r.compileMul=function(t,e){return this._binOpEmitter(t,e," * ")},r.compileDiv=function(t,e){return this._binOpEmitter(t,e," / ")},r.compileMod=function(t,e){return this._binOpEmitter(t,e," % ")},r.compileNot=function(t,e){this._emit("!"),this.compile(t.target,e)},r.compileFloorDiv=function(t,e){this._emit("Math.floor("),this.compile(t.left,e),this._emit(" / "),this.compile(t.right,e),this._emit(")")},r.compilePow=function(t,e){this._emit("Math.pow("),this.compile(t.left,e),this._emit(", "),this.compile(t.right,e),this._emit(")")},r.compileNeg=function(t,e){this._emit("-"),this.compile(t.target,e)},r.compilePos=function(t,e){this._emit("+"),this.compile(t.target,e)},r.compileCompare=function(t,e){var i=this;this.compile(t.expr,e),t.ops.forEach((function(t){i._emit(" "+h[t.type]+" "),i.compile(t.expr,e)}))},r.compileLookupVal=function(t,e){this._emit("runtime.memberLookup(("),this._compileExpression(t.target,e),this._emit("),"),this._compileExpression(t.val,e),this._emit(")")},r._getNodeName=function(t){switch(t.typename){case"Symbol":return t.value;case"FunCall":return"the return value of ("+this._getNodeName(t.name)+")";case"LookupVal":return this._getNodeName(t.target)+'["'+this._getNodeName(t.val)+'"]';case"Literal":return t.value.toString();default:return"--expression--"}},r.compileFunCall=function(t,e){this._emit("(lineno = "+t.lineno+", colno = "+t.colno+", "),this._emit("runtime.callWrap("),this._compileExpression(t.name,e),this._emit(', "'+this._getNodeName(t.name).replace(/"/g,'\\"')+'", context, '),this._compileAggregate(t.args,e,"[","])"),this._emit(")")},r.compileFilter=function(t,e){var i=t.name;this.assertType(i,s.Symbol),this._emit('env.getFilter("'+i.value+'").call(context, '),this._compileAggregate(t.args,e),this._emit(")")},r.compileFilterAsync=function(t,e){var i=t.name,n=t.symbol.value;this.assertType(i,s.Symbol),e.set(n,n),this._emit('env.getFilter("'+i.value+'").call(context, '),this._compileAggregate(t.args,e),this._emitLine(", "+this._makeCallback(n)),this._addScopeLevel()},r.compileKeywordArgs=function(t,e){this._emit("runtime.makeKeywordArgs("),this.compileDict(t,e),this._emit(")")},r.compileSet=function(t,e){var i=this,n=[];t.targets.forEach((function(t){var o=t.value,r=e.lookup(o);null==r&&(r=i._tmpid(),i._emitLine("var "+r+";")),n.push(r)})),t.value?(this._emit(n.join(" = ")+" = "),this._compileExpression(t.value,e),this._emitLine(";")):(this._emit(n.join(" = ")+" = "),this.compile(t.body,e),this._emitLine(";")),t.targets.forEach((function(t,e){var o=n[e],r=t.value;i._emitLine('frame.set("'+r+'", '+o+", true);"),i._emitLine("if(frame.topLevel) {"),i._emitLine('context.setVariable("'+r+'", '+o+");"),i._emitLine("}"),"_"!==r.charAt(0)&&(i._emitLine("if(frame.topLevel) {"),i._emitLine('context.addExport("'+r+'", '+o+");"),i._emitLine("}"))}))},r.compileSwitch=function(t,e){var i=this;this._emit("switch ("),this.compile(t.expr,e),this._emit(") {"),t.cases.forEach((function(t,n){i._emit("case "),i.compile(t.cond,e),i._emit(": "),i.compile(t.body,e),t.body.children.length&&i._emitLine("break;")})),t.default&&(this._emit("default:"),this.compile(t.default,e)),this._emit("}")},r.compileIf=function(t,e,i){var n=this;this._emit("if("),this._compileExpression(t.cond,e),this._emitLine(") {"),this._withScopedSyntax((function(){n.compile(t.body,e),i&&n._emit("cb()")})),t.else_?(this._emitLine("}\nelse {"),this._withScopedSyntax((function(){n.compile(t.else_,e),i&&n._emit("cb()")}))):i&&(this._emitLine("}\nelse {"),this._emit("cb()")),this._emitLine("}")},r.compileIfAsync=function(t,e){this._emit("(function(cb) {"),this.compileIf(t,e,!0),this._emit("})("+this._makeCallback()),this._addScopeLevel()},r._emitLoopBindings=function(t,e,i,n){var o=this;[{name:"index",val:i+" + 1"},{name:"index0",val:i},{name:"revindex",val:n+" - "+i},{name:"revindex0",val:n+" - "+i+" - 1"},{name:"first",val:i+" === 0"},{name:"last",val:i+" === "+n+" - 1"},{name:"length",val:n}].forEach((function(t){o._emitLine('frame.set("loop.'+t.name+'", '+t.val+");")}))},r.compileFor=function(t,e){var i=this,n=this._tmpid(),o=this._tmpid(),r=this._tmpid();if(e=e.push(),this._emitLine("frame = frame.push();"),this._emit("var "+r+" = "),this._compileExpression(t.arr,e),this._emitLine(";"),this._emit("if("+r+") {"),this._emitLine(r+" = runtime.fromIterator("+r+");"),t.name instanceof s.Array){this._emitLine("var "+n+";"),this._emitLine("if(runtime.isArray("+r+")) {"),this._emitLine("var "+o+" = "+r+".length;"),this._emitLine("for("+n+"=0; "+n+" < "+r+".length; "+n+"++) {"),t.name.children.forEach((function(o,s){var a=i._tmpid();i._emitLine("var "+a+" = "+r+"["+n+"]["+s+"];"),i._emitLine('frame.set("'+o+'", '+r+"["+n+"]["+s+"]);"),e.set(t.name.children[s].value,a)})),this._emitLoopBindings(t,r,n,o),this._withScopedSyntax((function(){i.compile(t.body,e)})),this._emitLine("}"),this._emitLine("} else {");var a=t.name.children,c=a[0],l=a[1],h=this._tmpid(),u=this._tmpid();e.set(c.value,h),e.set(l.value,u),this._emitLine(n+" = -1;"),this._emitLine("var "+o+" = runtime.keys("+r+").length;"),this._emitLine("for(var "+h+" in "+r+") {"),this._emitLine(n+"++;"),this._emitLine("var "+u+" = "+r+"["+h+"];"),this._emitLine('frame.set("'+c.value+'", '+h+");"),this._emitLine('frame.set("'+l.value+'", '+u+");"),this._emitLoopBindings(t,r,n,o),this._withScopedSyntax((function(){i.compile(t.body,e)})),this._emitLine("}"),this._emitLine("}")}else{var p=this._tmpid();e.set(t.name.value,p),this._emitLine("var "+o+" = "+r+".length;"),this._emitLine("for(var "+n+"=0; "+n+" < "+r+".length; "+n+"++) {"),this._emitLine("var "+p+" = "+r+"["+n+"];"),this._emitLine('frame.set("'+t.name.value+'", '+p+");"),this._emitLoopBindings(t,r,n,o),this._withScopedSyntax((function(){i.compile(t.body,e)})),this._emitLine("}")}this._emitLine("}"),t.else_&&(this._emitLine("if (!"+o+") {"),this.compile(t.else_,e),this._emitLine("}")),this._emitLine("frame = frame.pop();")},r._compileAsyncLoop=function(t,e,i){var n=this,o=this._tmpid(),r=this._tmpid(),a=this._tmpid(),c=i?"asyncAll":"asyncEach";if(e=e.push(),this._emitLine("frame = frame.push();"),this._emit("var "+a+" = runtime.fromIterator("),this._compileExpression(t.arr,e),this._emitLine(");"),t.name instanceof s.Array){var l=t.name.children.length;this._emit("runtime."+c+"("+a+", "+l+", function("),t.name.children.forEach((function(t){n._emit(t.value+",")})),this._emit(o+","+r+",next) {"),t.name.children.forEach((function(t){var i=t.value;e.set(i,i),n._emitLine('frame.set("'+i+'", '+i+");")}))}else{var h=t.name.value;this._emitLine("runtime."+c+"("+a+", 1, function("+h+", "+o+", "+r+",next) {"),this._emitLine('frame.set("'+h+'", '+h+");"),e.set(h,h)}this._emitLoopBindings(t,a,o,r),this._withScopedSyntax((function(){var r;i&&(r=n._pushBuffer()),n.compile(t.body,e),n._emitLine("next("+o+(r?","+r:"")+");"),i&&n._popBuffer()}));var u=this._tmpid();this._emitLine("}, "+this._makeCallback(u)),this._addScopeLevel(),i&&this._emitLine(this.buffer+" += "+u+";"),t.else_&&(this._emitLine("if (!"+a+".length) {"),this.compile(t.else_,e),this._emitLine("}")),this._emitLine("frame = frame.pop();")},r.compileAsyncEach=function(t,e){this._compileAsyncLoop(t,e)},r.compileAsyncAll=function(t,e){this._compileAsyncLoop(t,e,!0)},r._compileMacro=function(t,e){var i=this,n=[],o=null,r="macro_"+this._tmpid(),a=void 0!==e;t.args.children.forEach((function(e,r){r===t.args.children.length-1&&e instanceof s.Dict?o=e:(i.assertType(e,s.Symbol),n.push(e))}));var l,h=[].concat(n.map((function(t){return"l_"+t.value})),["kwargs"]),u=n.map((function(t){return'"'+t.value+'"'})),p=(o&&o.children||[]).map((function(t){return'"'+t.key.value+'"'}));l=a?e.push(!0):new c,this._emitLines("var "+r+" = runtime.makeMacro(","["+u.join(", ")+"], ","["+p.join(", ")+"], ","function ("+h.join(", ")+") {","var callerFrame = frame;","frame = "+(a?"frame.push(true);":"new runtime.Frame();"),"kwargs = kwargs || {};",'if (Object.prototype.hasOwnProperty.call(kwargs, "caller")) {','frame.set("caller", kwargs.caller); }'),n.forEach((function(t){i._emitLine('frame.set("'+t.value+'", l_'+t.value+");"),l.set(t.value,"l_"+t.value)})),o&&o.children.forEach((function(t){var e=t.key.value;i._emit('frame.set("'+e+'", '),i._emit('Object.prototype.hasOwnProperty.call(kwargs, "'+e+'")'),i._emit(' ? kwargs["'+e+'"] : '),i._compileExpression(t.value,l),i._emit(");")}));var d=this._pushBuffer();return this._withScopedSyntax((function(){i.compile(t.body,l)})),this._emitLine("frame = "+(a?"frame.pop();":"callerFrame;")),this._emitLine("return new runtime.SafeString("+d+");"),this._emitLine("});"),this._popBuffer(),r},r.compileMacro=function(t,e){var i=this._compileMacro(t),n=t.name.value;e.set(n,i),e.parent?this._emitLine('frame.set("'+n+'", '+i+");"):("_"!==t.name.value.charAt(0)&&this._emitLine('context.addExport("'+n+'");'),this._emitLine('context.setVariable("'+n+'", '+i+");"))},r.compileCaller=function(t,e){this._emit("(function (){");var i=this._compileMacro(t,e);this._emit("return "+i+";})()")},r._compileGetTemplate=function(t,e,i,n){var o=this._tmpid(),r=this._templateName(),s=this._makeCallback(o),a=i?"true":"false",c=n?"true":"false";return this._emit("env.getTemplate("),this._compileExpression(t.template,e),this._emitLine(", "+a+", "+r+", "+c+", "+s),o},r.compileImport=function(t,e){var i=t.target.value,n=this._compileGetTemplate(t,e,!1,!1);this._addScopeLevel(),this._emitLine(n+".getExported("+(t.withContext?"context.getVariables(), frame, ":"")+this._makeCallback(n)),this._addScopeLevel(),e.set(i,n),e.parent?this._emitLine('frame.set("'+i+'", '+n+");"):this._emitLine('context.setVariable("'+i+'", '+n+");")},r.compileFromImport=function(t,e){var i=this,n=this._compileGetTemplate(t,e,!1,!1);this._addScopeLevel(),this._emitLine(n+".getExported("+(t.withContext?"context.getVariables(), frame, ":"")+this._makeCallback(n)),this._addScopeLevel(),t.names.children.forEach((function(t){var o,r,a=i._tmpid();t instanceof s.Pair?(o=t.key.value,r=t.value.value):r=o=t.value,i._emitLine("if(Object.prototype.hasOwnProperty.call("+n+', "'+o+'")) {'),i._emitLine("var "+a+" = "+n+"."+o+";"),i._emitLine("} else {"),i._emitLine("cb(new Error(\"cannot import '"+o+"'\")); return;"),i._emitLine("}"),e.set(r,a),e.parent?i._emitLine('frame.set("'+r+'", '+a+");"):i._emitLine('context.setVariable("'+r+'", '+a+");")}))},r.compileBlock=function(t){var e=this._tmpid();this.inBlock||this._emit('(parentTemplate ? function(e, c, f, r, cb) { cb(""); } : '),this._emit('context.getBlock("'+t.name.value+'")'),this.inBlock||this._emit(")"),this._emitLine("(env, context, frame, runtime, "+this._makeCallback(e)),this._emitLine(this.buffer+" += "+e+";"),this._addScopeLevel()},r.compileSuper=function(t,e){var i=t.blockName.value,n=t.symbol.value,o=this._makeCallback(n);this._emitLine('context.getSuper(env, "'+i+'", b_'+i+", frame, runtime, "+o),this._emitLine(n+" = runtime.markSafe("+n+");"),this._addScopeLevel(),e.set(n,n)},r.compileExtends=function(t,e){var i=this._tmpid(),n=this._compileGetTemplate(t,e,!0,!1);this._emitLine("parentTemplate = "+n),this._emitLine("for(var "+i+" in parentTemplate.blocks) {"),this._emitLine("context.addBlock("+i+", parentTemplate.blocks["+i+"]);"),this._emitLine("}"),this._addScopeLevel()},r.compileInclude=function(t,e){this._emitLine("var tasks = [];"),this._emitLine("tasks.push("),this._emitLine("function(callback) {");var i=this._compileGetTemplate(t,e,!1,t.ignoreMissing);this._emitLine("callback(null,"+i+");});"),this._emitLine("});");var n=this._tmpid();this._emitLine("tasks.push("),this._emitLine("function(template, callback){"),this._emitLine("template.render(context.getVariables(), frame, "+this._makeCallback(n)),this._emitLine("callback(null,"+n+");});"),this._emitLine("});"),this._emitLine("tasks.push("),this._emitLine("function(result, callback){"),this._emitLine(this.buffer+" += result;"),this._emitLine("callback(null);"),this._emitLine("});"),this._emitLine("env.waterfall(tasks, function(){"),this._addScopeLevel()},r.compileTemplateData=function(t,e){this.compileLiteral(t,e)},r.compileCapture=function(t,e){var i=this,n=this.buffer;this.buffer="output",this._emitLine("(function() {"),this._emitLine('var output = "";'),this._withScopedSyntax((function(){i.compile(t.body,e)})),this._emitLine("return output;"),this._emitLine("})()"),this.buffer=n},r.compileOutput=function(t,e){var i=this;t.children.forEach((function(n){n instanceof s.TemplateData?n.value&&(i._emit(i.buffer+" += "),i.compileLiteral(n,e),i._emitLine(";")):(i._emit(i.buffer+" += runtime.suppressValue("),i.throwOnUndefined&&i._emit("runtime.ensureDefined("),i.compile(n,e),i.throwOnUndefined&&i._emit(","+t.lineno+","+t.colno+")"),i._emit(", env.opts.autoescape);\n"))}))},r.compileRoot=function(t,e){var i=this;e&&this.fail("compileRoot: root node can't have frame"),e=new c,this._emitFuncBegin(t,"root"),this._emitLine("var parentTemplate = null;"),this._compileChildren(t,e),this._emitLine("if(parentTemplate) {"),this._emitLine("parentTemplate.rootRenderFunc(env, context, frame, runtime, cb);"),this._emitLine("} else {"),this._emitLine("cb(null, "+this.buffer+");"),this._emitLine("}"),this._emitFuncEnd(!0),this.inBlock=!0;var n=[],o=t.findAll(s.Block);o.forEach((function(t,e){var o=t.name.value;if(-1!==n.indexOf(o))throw new Error('Block "'+o+'" defined more than once.');n.push(o),i._emitFuncBegin(t,"b_"+o);var r=new c;i._emitLine("var frame = frame.push(true);"),i.compile(t.body,r),i._emitFuncEnd()})),this._emitLine("return {"),o.forEach((function(t,e){var n="b_"+t.name.value;i._emitLine(n+": "+n+",")})),this._emitLine("root: root\n};")},r.compile=function(t,e){var i=this["compile"+t.typename];i?i.call(this,t,e):this.fail("compile: Cannot compile node: "+t.typename,t.lineno,t.colno)},r.getCode=function(){return this.codebuf.join("")},o}(l);t.exports={compile:function(t,e,i,n,s){void 0===s&&(s={});var a=new u(n,s.throwOnUndefined),c=(i||[]).map((function(t){return t.preprocess})).filter((function(t){return!!t})).reduce((function(t,e){return e(t)}),t);return a.compile(r.transform(o.parse(c,i,s),e,n)),a.getCode()},Compiler:u}},function(t,e,i){"use strict";function n(t,e){return n=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},n(t,e)}var o=i(4),r=i(1).EmitterObj;t.exports=function(t){var e,i;function r(){return t.apply(this,arguments)||this}i=t,(e=r).prototype=Object.create(i.prototype),e.prototype.constructor=e,n(e,i);var s=r.prototype;return s.resolve=function(t,e){return o.resolve(o.dirname(t),e)},s.isRelative=function(t){return 0===t.indexOf("./")||0===t.indexOf("../")},r}(r)},function(t,e,i){"use strict";function n(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,o(t,e)}function o(t,e){return o=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},o(t,e)}var r=i(12),s=i(15),a=i(0),c=i(5),l=i(18),h=i(10),u=h.FileSystemLoader,p=h.WebLoader,d=h.PrecompiledLoader,f=i(20),m=i(21),v=i(1),y=v.Obj,_=v.EmitterObj,g=i(2),b=g.handleError,C=g.Frame,k=i(22);function L(t,e,i){r((function(){t(e,i)}))}var w={type:"code",obj:{root:function(t,e,i,n,o){try{o(null,"")}catch(t){o(b(t,null,null))}}}},x=function(t){function e(){return t.apply(this,arguments)||this}n(e,t);var i=e.prototype;return i.init=function(t,e){var i=this;e=this.opts=e||{},this.opts.dev=!!e.dev,this.opts.autoescape=null==e.autoescape||e.autoescape,this.opts.throwOnUndefined=!!e.throwOnUndefined,this.opts.trimBlocks=!!e.trimBlocks,this.opts.lstripBlocks=!!e.lstripBlocks,this.loaders=[],t?this.loaders=a.isArray(t)?t:[t]:u?this.loaders=[new u("views")]:p&&(this.loaders=[new p("/views")]),"undefined"!=typeof window&&window.nunjucksPrecompiled&&this.loaders.unshift(new d(window.nunjucksPrecompiled)),this._initLoaders(),this.globals=m(),this.filters={},this.tests={},this.asyncFilters=[],this.extensions={},this.extensionsList=[],a._entries(l).forEach((function(t){var e=t[0],n=t[1];return i.addFilter(e,n)})),a._entries(f).forEach((function(t){var e=t[0],n=t[1];return i.addTest(e,n)}))},i._initLoaders=function(){var t=this;this.loaders.forEach((function(e){e.cache={},"function"==typeof e.on&&(e.on("update",(function(i,n){e.cache[i]=null,t.emit("update",i,n,e)})),e.on("load",(function(i,n){t.emit("load",i,n,e)})))}))},i.invalidateCache=function(){this.loaders.forEach((function(t){t.cache={}}))},i.addExtension=function(t,e){return e.__name=t,this.extensions[t]=e,this.extensionsList.push(e),this},i.removeExtension=function(t){var e=this.getExtension(t);e&&(this.extensionsList=a.without(this.extensionsList,e),delete this.extensions[t])},i.getExtension=function(t){return this.extensions[t]},i.hasExtension=function(t){return!!this.extensions[t]},i.addGlobal=function(t,e){return this.globals[t]=e,this},i.getGlobal=function(t){if(void 0===this.globals[t])throw new Error("global not found: "+t);return this.globals[t]},i.addFilter=function(t,e,i){var n=e;return i&&this.asyncFilters.push(t),this.filters[t]=n,this},i.getFilter=function(t){if(!this.filters[t])throw new Error("filter not found: "+t);return this.filters[t]},i.addTest=function(t,e){return this.tests[t]=e,this},i.getTest=function(t){if(!this.tests[t])throw new Error("test not found: "+t);return this.tests[t]},i.resolveTemplate=function(t,e,i){return t.isRelative&&e&&t.isRelative(i)&&t.resolve?t.resolve(e,i):i},i.getTemplate=function(t,e,i,n,o){var r,s=this,c=this,l=null;if(t&&t.raw&&(t=t.raw),a.isFunction(i)&&(o=i,i=null,e=e||!1),a.isFunction(e)&&(o=e,e=!1),t instanceof E)l=t;else{if("string"!=typeof t)throw new Error("template names must be a string: "+t);for(var h=0;h0&&!this.skip(o.TOKEN_COMMA)&&this.fail("parseFrom: expected comma",t.lineno,t.colno);var a=this.parsePrimary();if("_"===a.value.charAt(0)&&this.fail("parseFrom: names starting with an underscore cannot be imported",a.lineno,a.colno),this.skipSymbol("as")){var c=this.parsePrimary();n.addChild(new r.Pair(a.lineno,a.colno,a,c))}else n.addChild(a);i=this.parseWithContext()}return new r.FromImport(t.lineno,t.colno,e,n,i)},c.parseBlock=function(){var t=this.peekToken();this.skipSymbol("block")||this.fail("parseBlock: expected block",t.lineno,t.colno);var e=new r.Block(t.lineno,t.colno);e.name=this.parsePrimary(),e.name instanceof r.Symbol||this.fail("parseBlock: variable name expected",t.lineno,t.colno),this.advanceAfterBlockEnd(t.value),e.body=this.parseUntilBlocks("endblock"),this.skipSymbol("endblock"),this.skipSymbol(e.name.value);var i=this.peekToken();return i||this.fail("parseBlock: expected endblock, got end of file"),this.advanceAfterBlockEnd(i.value),e},c.parseExtends=function(){var t="extends",e=this.peekToken();this.skipSymbol(t)||this.fail("parseTemplateRef: expected "+t);var i=new r.Extends(e.lineno,e.colno);return i.template=this.parseExpression(),this.advanceAfterBlockEnd(e.value),i},c.parseInclude=function(){var t="include",e=this.peekToken();this.skipSymbol(t)||this.fail("parseInclude: expected "+t);var i=new r.Include(e.lineno,e.colno);return i.template=this.parseExpression(),this.skipSymbol("ignore")&&this.skipSymbol("missing")&&(i.ignoreMissing=!0),this.advanceAfterBlockEnd(e.value),i},c.parseIf=function(){var t,e=this.peekToken();this.skipSymbol("if")||this.skipSymbol("elif")||this.skipSymbol("elseif")?t=new r.If(e.lineno,e.colno):this.skipSymbol("ifAsync")?t=new r.IfAsync(e.lineno,e.colno):this.fail("parseIf: expected if, elif, or elseif",e.lineno,e.colno),t.cond=this.parseExpression(),this.advanceAfterBlockEnd(e.value),t.body=this.parseUntilBlocks("elif","elseif","else","endif");var i=this.peekToken();switch(i&&i.value){case"elseif":case"elif":t.else_=this.parseIf();break;case"else":this.advanceAfterBlockEnd(),t.else_=this.parseUntilBlocks("endif"),this.advanceAfterBlockEnd();break;case"endif":t.else_=null,this.advanceAfterBlockEnd();break;default:this.fail("parseIf: expected elif, else, or endif, got end of file")}return t},c.parseSet=function(){var t=this.peekToken();this.skipSymbol("set")||this.fail("parseSet: expected set",t.lineno,t.colno);for(var e,i=new r.Set(t.lineno,t.colno,[]);(e=this.parsePrimary())&&(i.targets.push(e),this.skip(o.TOKEN_COMMA)););return this.skipValue(o.TOKEN_OPERATOR,"=")?(i.value=this.parseExpression(),this.advanceAfterBlockEnd(t.value)):this.skip(o.TOKEN_BLOCK_END)?(i.body=new r.Capture(t.lineno,t.colno,this.parseUntilBlocks("endset")),i.value=null,this.advanceAfterBlockEnd()):this.fail("parseSet: expected = or block end in set tag",t.lineno,t.colno),i},c.parseSwitch=function(){var t="switch",e="endswitch",i="case",n="default",o=this.peekToken();this.skipSymbol(t)||this.skipSymbol(i)||this.skipSymbol(n)||this.fail('parseSwitch: expected "switch," "case" or "default"',o.lineno,o.colno);var s=this.parseExpression();this.advanceAfterBlockEnd(t),this.parseUntilBlocks(i,n,e);var a,c=this.peekToken(),l=[];do{this.skipSymbol(i);var h=this.parseExpression();this.advanceAfterBlockEnd(t);var u=this.parseUntilBlocks(i,n,e);l.push(new r.Case(c.line,c.col,h,u)),c=this.peekToken()}while(c&&c.value===i);switch(c.value){case n:this.advanceAfterBlockEnd(),a=this.parseUntilBlocks(e),this.advanceAfterBlockEnd();break;case e:this.advanceAfterBlockEnd();break;default:this.fail('parseSwitch: expected "case," "default" or "endswitch," got EOF.')}return new r.Switch(o.lineno,o.colno,s,l,a)},c.parseStatement=function(){var t=this.peekToken();if(t.type!==o.TOKEN_SYMBOL&&this.fail("tag name expected",t.lineno,t.colno),this.breakOnBlocks&&-1!==a.indexOf(this.breakOnBlocks,t.value))return null;switch(t.value){case"raw":return this.parseRaw();case"verbatim":return this.parseRaw("verbatim");case"if":case"ifAsync":return this.parseIf();case"for":case"asyncEach":case"asyncAll":return this.parseFor();case"block":return this.parseBlock();case"extends":return this.parseExtends();case"include":return this.parseInclude();case"set":return this.parseSet();case"macro":return this.parseMacro();case"call":return this.parseCall();case"import":return this.parseImport();case"from":return this.parseFrom();case"filter":return this.parseFilterStatement();case"switch":return this.parseSwitch();default:if(this.extensions.length)for(var e=0;e0;){var c=s[0],l=s[1],h=s[2];h===t?n+=1:h===e&&(n-=1),0===n?(o+=l,this.tokens.backN(c.length-l.length)):o+=c}return new r.Output(a.lineno,a.colno,[new r.TemplateData(a.lineno,a.colno,o)])},c.parsePostfix=function(t){for(var e,i=this.peekToken();i;){if(i.type===o.TOKEN_LEFT_PAREN)t=new r.FunCall(i.lineno,i.colno,t,this.parseSignature());else if(i.type===o.TOKEN_LEFT_BRACKET)(e=this.parseAggregate()).children.length>1&&this.fail("invalid index"),t=new r.LookupVal(i.lineno,i.colno,t,e.children[0]);else{if(i.type!==o.TOKEN_OPERATOR||"."!==i.value)break;this.nextToken();var n=this.nextToken();n.type!==o.TOKEN_SYMBOL&&this.fail("expected name as lookup value, got "+n.value,n.lineno,n.colno),e=new r.Literal(n.lineno,n.colno,n.value),t=new r.LookupVal(i.lineno,i.colno,t,e)}i=this.peekToken()}return t},c.parseExpression=function(){return this.parseInlineIf()},c.parseInlineIf=function(){var t=this.parseOr();if(this.skipSymbol("if")){var e=this.parseOr(),i=t;(t=new r.InlineIf(t.lineno,t.colno)).body=i,t.cond=e,this.skipSymbol("else")?t.else_=this.parseOr():t.else_=null}return t},c.parseOr=function(){for(var t=this.parseAnd();this.skipSymbol("or");){var e=this.parseAnd();t=new r.Or(t.lineno,t.colno,t,e)}return t},c.parseAnd=function(){for(var t=this.parseNot();this.skipSymbol("and");){var e=this.parseNot();t=new r.And(t.lineno,t.colno,t,e)}return t},c.parseNot=function(){var t=this.peekToken();return this.skipSymbol("not")?new r.Not(t.lineno,t.colno,this.parseNot()):this.parseIn()},c.parseIn=function(){for(var t=this.parseIs();;){var e=this.nextToken();if(!e)break;var i=e.type===o.TOKEN_SYMBOL&&"not"===e.value;if(i||this.pushToken(e),!this.skipSymbol("in")){i&&this.pushToken(e);break}var n=this.parseIs();t=new r.In(t.lineno,t.colno,t,n),i&&(t=new r.Not(t.lineno,t.colno,t))}return t},c.parseIs=function(){var t=this.parseCompare();if(this.skipSymbol("is")){var e=this.skipSymbol("not"),i=this.parseCompare();t=new r.Is(t.lineno,t.colno,t,i),e&&(t=new r.Not(t.lineno,t.colno,t))}return t},c.parseCompare=function(){for(var t=["==","===","!=","!==","<",">","<=",">="],e=this.parseConcat(),i=[];;){var n=this.nextToken();if(!n)break;if(-1===t.indexOf(n.value)){this.pushToken(n);break}i.push(new r.CompareOperand(n.lineno,n.colno,this.parseConcat(),n.value))}return i.length?new r.Compare(i[0].lineno,i[0].colno,e,i):e},c.parseConcat=function(){for(var t=this.parseAdd();this.skipValue(o.TOKEN_TILDE,"~");){var e=this.parseAdd();t=new r.Concat(t.lineno,t.colno,t,e)}return t},c.parseAdd=function(){for(var t=this.parseSub();this.skipValue(o.TOKEN_OPERATOR,"+");){var e=this.parseSub();t=new r.Add(t.lineno,t.colno,t,e)}return t},c.parseSub=function(){for(var t=this.parseMul();this.skipValue(o.TOKEN_OPERATOR,"-");){var e=this.parseMul();t=new r.Sub(t.lineno,t.colno,t,e)}return t},c.parseMul=function(){for(var t=this.parseDiv();this.skipValue(o.TOKEN_OPERATOR,"*");){var e=this.parseDiv();t=new r.Mul(t.lineno,t.colno,t,e)}return t},c.parseDiv=function(){for(var t=this.parseFloorDiv();this.skipValue(o.TOKEN_OPERATOR,"/");){var e=this.parseFloorDiv();t=new r.Div(t.lineno,t.colno,t,e)}return t},c.parseFloorDiv=function(){for(var t=this.parseMod();this.skipValue(o.TOKEN_OPERATOR,"//");){var e=this.parseMod();t=new r.FloorDiv(t.lineno,t.colno,t,e)}return t},c.parseMod=function(){for(var t=this.parsePow();this.skipValue(o.TOKEN_OPERATOR,"%");){var e=this.parsePow();t=new r.Mod(t.lineno,t.colno,t,e)}return t},c.parsePow=function(){for(var t=this.parseUnary();this.skipValue(o.TOKEN_OPERATOR,"**");){var e=this.parseUnary();t=new r.Pow(t.lineno,t.colno,t,e)}return t},c.parseUnary=function(t){var e,i=this.peekToken();return e=this.skipValue(o.TOKEN_OPERATOR,"-")?new r.Neg(i.lineno,i.colno,this.parseUnary(!0)):this.skipValue(o.TOKEN_OPERATOR,"+")?new r.Pos(i.lineno,i.colno,this.parseUnary(!0)):this.parsePrimary(),t||(e=this.parseFilter(e)),e},c.parsePrimary=function(t){var e,i=this.nextToken(),n=null;if(i?i.type===o.TOKEN_STRING?e=i.value:i.type===o.TOKEN_INT?e=parseInt(i.value,10):i.type===o.TOKEN_FLOAT?e=parseFloat(i.value):i.type===o.TOKEN_BOOLEAN?"true"===i.value?e=!0:"false"===i.value?e=!1:this.fail("invalid boolean: "+i.value,i.lineno,i.colno):i.type===o.TOKEN_NONE?e=null:i.type===o.TOKEN_REGEX&&(e=new RegExp(i.value.body,i.value.flags)):this.fail("expected expression, got end of file"),void 0!==e?n=new r.Literal(i.lineno,i.colno,e):i.type===o.TOKEN_SYMBOL?n=new r.Symbol(i.lineno,i.colno,i.value):(this.pushToken(i),n=this.parseAggregate()),t||(n=this.parsePostfix(n)),n)return n;throw this.error("unexpected token: "+i.value,i.lineno,i.colno)},c.parseFilterName=function(){for(var t=this.expect(o.TOKEN_SYMBOL),e=t.value;this.skipValue(o.TOKEN_OPERATOR,".");)e+="."+this.expect(o.TOKEN_SYMBOL).value;return new r.Symbol(t.lineno,t.colno,e)},c.parseFilterArgs=function(t){return this.peekToken().type===o.TOKEN_LEFT_PAREN?this.parsePostfix(t).args.children:[]},c.parseFilter=function(t){for(;this.skip(o.TOKEN_PIPE);){var e=this.parseFilterName();t=new r.Filter(e.lineno,e.colno,e,new r.NodeList(e.lineno,e.colno,[t].concat(this.parseFilterArgs(t))))}return t},c.parseFilterStatement=function(){var t=this.peekToken();this.skipSymbol("filter")||this.fail("parseFilterStatement: expected filter");var e=this.parseFilterName(),i=this.parseFilterArgs(e);this.advanceAfterBlockEnd(t.value);var n=new r.Capture(e.lineno,e.colno,this.parseUntilBlocks("endfilter"));this.advanceAfterBlockEnd();var o=new r.Filter(e.lineno,e.colno,e,new r.NodeList(e.lineno,e.colno,[n].concat(i)));return new r.Output(e.lineno,e.colno,[o])},c.parseAggregate=function(){var t,e=this.nextToken();switch(e.type){case o.TOKEN_LEFT_PAREN:t=new r.Group(e.lineno,e.colno);break;case o.TOKEN_LEFT_BRACKET:t=new r.Array(e.lineno,e.colno);break;case o.TOKEN_LEFT_CURLY:t=new r.Dict(e.lineno,e.colno);break;default:return null}for(;;){var i=this.peekToken().type;if(i===o.TOKEN_RIGHT_PAREN||i===o.TOKEN_RIGHT_BRACKET||i===o.TOKEN_RIGHT_CURLY){this.nextToken();break}if(t.children.length>0&&(this.skip(o.TOKEN_COMMA)||this.fail("parseAggregate: expected comma after expression",e.lineno,e.colno)),t instanceof r.Dict){var n=this.parsePrimary();this.skip(o.TOKEN_COLON)||this.fail("parseAggregate: expected colon after dict key",e.lineno,e.colno);var s=this.parseExpression();t.addChild(new r.Pair(n.lineno,n.colno,n,s))}else{var a=this.parseExpression();t.addChild(a)}}return t},c.parseSignature=function(t,e){var i=this.peekToken();if(!e&&i.type!==o.TOKEN_LEFT_PAREN){if(t)return null;this.fail("expected arguments",i.lineno,i.colno)}i.type===o.TOKEN_LEFT_PAREN&&(i=this.nextToken());for(var n=new r.NodeList(i.lineno,i.colno),s=new r.KeywordArgs(i.lineno,i.colno),a=!1;;){if(i=this.peekToken(),!e&&i.type===o.TOKEN_RIGHT_PAREN){this.nextToken();break}if(e&&i.type===o.TOKEN_BLOCK_END)break;if(a&&!this.skip(o.TOKEN_COMMA))this.fail("parseSignature: expected comma after expression",i.lineno,i.colno);else{var c=this.parseExpression();this.skipValue(o.TOKEN_OPERATOR,"=")?s.addChild(new r.Pair(c.lineno,c.colno,c,this.parseExpression())):n.addChild(c)}a=!0}return s.children.length&&n.addChild(s),n},c.parseUntilBlocks=function(){for(var t=this.breakOnBlocks,e=arguments.length,i=new Array(e),n=0;n=","//","**"],j=M+this.current();switch(-1!==n.indexOf(P,j)&&(this.forward(),M=j,-1!==n.indexOf(P,j+this.current())&&(M=j+this.current(),this.forward())),M){case"(":R=f;break;case")":R=m;break;case"[":R=v;break;case"]":R=y;break;case"{":R=_;break;case"}":R=g;break;case",":R=C;break;case":":R=k;break;case"~":R=L;break;case"|":R=w;break;default:R=b}return S(R,M,e,i)}if((t=this._extractUntil(o+r)).match(/^[-+]?[0-9]+$/)){if("."===this.current()){this.forward();var F=this._extract("0123456789");return S(x,t+"."+F,e,i)}return S("int",t,e,i)}if(t.match(/^(true|false)$/))return S(A,t,e,i);if("none"===t)return S(E,t,e,i);if("null"===t)return S(E,t,e,i);if(t)return S(T,t,e,i);throw new Error("Unexpected value while parsing: "+t)}var B,D=this.tags.BLOCK_START.charAt(0)+this.tags.VARIABLE_START.charAt(0)+this.tags.COMMENT_START.charAt(0)+this.tags.COMMENT_END.charAt(0);if(this.isFinished())return null;if((t=this._extractString(this.tags.BLOCK_START+"-"))||(t=this._extractString(this.tags.BLOCK_START)))return this.in_code=!0,S(l,t,e,i);if((t=this._extractString(this.tags.VARIABLE_START+"-"))||(t=this._extractString(this.tags.VARIABLE_START)))return this.in_code=!0,S(u,t,e,i);t="";var V=!1;for(this._matches(this.tags.COMMENT_START)&&(V=!0,t=this._extractString(this.tags.COMMENT_START));null!==(B=this._extractUntil(D));){if(t+=B,(this._matches(this.tags.BLOCK_START)||this._matches(this.tags.VARIABLE_START)||this._matches(this.tags.COMMENT_START))&&!V){if(this.lstripBlocks&&this._matches(this.tags.BLOCK_START)&&this.colno>0&&this.colno<=t.length){var H=t.slice(-this.colno);if(/^\s+$/.test(H)&&!(t=t.slice(0,-this.colno)).length)return this.nextToken()}break}if(this._matches(this.tags.COMMENT_END)){if(!V)throw new Error("unexpected end of comment");t+=this._extractString(this.tags.COMMENT_END);break}t+=this.current(),this.forward()}if(null===B&&V)throw new Error("expected end of comment, got end of file");return S(V?d:c,t,e,i)},e._parseString=function(t){this.forward();for(var e="";!this.isFinished()&&this.current()!==t;){var i=this.current();if("\\"===i){switch(this.forward(),this.current()){case"n":e+="\n";break;case"t":e+="\t";break;case"r":e+="\r";break;default:e+=this.current()}this.forward()}else e+=i,this.forward()}return this.forward(),e},e._matches=function(t){return this.index+t.length>this.len?null:this.str.slice(this.index,this.index+t.length)===t},e._extractString=function(t){return this._matches(t)?(this.forwardN(t.length),t):null},e._extractUntil=function(t){return this._extractMatching(!0,t||"")},e._extract=function(t){return this._extractMatching(!1,t)},e._extractMatching=function(t,e){if(this.isFinished())return null;var i=e.indexOf(this.current());if(t&&-1===i||!t&&-1!==i){var n=this.current();this.forward();for(var o=e.indexOf(this.current());(t&&-1===o||!t&&-1!==o)&&!this.isFinished();)n+=this.current(),this.forward(),o=e.indexOf(this.current());return n}return""},e._extractRegex=function(t){var e=this.currentStr().match(t);return e?(this.forwardN(e[0].length),e):null},e.isFinished=function(){return this.index>=this.len},e.forwardN=function(t){for(var e=0;e1024){for(var e=0,i=o.length-r;e0&&s.length>o&&!s.warned){s.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=t,c.type=e,c.count=s.length,a=c,console&&console.warn&&console.warn(a)}return t}function p(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function d(t,e,i){var n={fired:!1,wrapFn:void 0,target:t,type:e,listener:i},o=p.bind(n);return o.listener=i,n.wrapFn=o,o}function f(t,e,i){var n=t._events;if(void 0===n)return[];var o=n[e];return void 0===o?[]:"function"==typeof o?i?[o.listener||o]:[o]:i?function(t){for(var e=new Array(t.length),i=0;i0&&(s=e[0]),s instanceof Error)throw s;var a=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw a.context=s,a}var c=o[t];if(void 0===c)return!1;if("function"==typeof c)r(c,this,e);else{var l=c.length,h=v(c,l);for(i=0;i=0;r--)if(i[r]===e||i[r].listener===e){s=i[r].listener,o=r;break}if(o<0)return this;0===o?i.shift():function(t,e){for(;e+1=0;n--)this.removeListener(t,e[n]);return this},a.prototype.listeners=function(t){return f(this,t,!0)},a.prototype.rawListeners=function(t){return f(this,t,!1)},a.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):m.call(t,e)},a.prototype.listenerCount=m,a.prototype.eventNames=function(){return this._eventsCount>0?n(this._events):[]}},function(t,e,i){"use strict";var n=i(3),o=i(0),r=0;function s(){return"hole_"+r++}function a(t,e){for(var i=null,n=0;n=e)return t;var i=e-t.length,s=n.repeat(" ",i/2-i%2),a=n.repeat(" ",i/2);return o.copySafeness(t,s+t+a)},e.default=function(t,e,i){return i?t||e:void 0!==t?t:e},e.dictsort=function(t,e,i){if(!n.isObject(t))throw new n.TemplateError("dictsort filter: val must be an object");var o,r=[];for(var s in t)r.push([s,t[s]]);if(void 0===i||"key"===i)o=0;else{if("value"!==i)throw new n.TemplateError("dictsort filter: You can only sort by either key or value");o=1}return r.sort((function(t,i){var r=t[o],s=i[o];return e||(n.isString(r)&&(r=r.toUpperCase()),n.isString(s)&&(s=s.toUpperCase())),r>s?1:r===s?0:-1})),r},e.dump=function(t,e){return JSON.stringify(t,null,e)},e.escape=function(t){return t instanceof o.SafeString?t:(t=null==t?"":t,o.markSafe(n.escape(t.toString())))},e.safe=function(t){return t instanceof o.SafeString?t:(t=null==t?"":t,o.markSafe(t.toString()))},e.first=function(t){return t[0]},e.forceescape=function(t){return t=null==t?"":t,o.markSafe(n.escape(t.toString()))},e.groupby=function(t,e){return n.groupBy(t,e,this.env.opts.throwOnUndefined)},e.indent=function(t,e,i){if(""===(t=r(t,"")))return"";e=e||4;var s=t.split("\n"),a=n.repeat(" ",e),c=s.map((function(t,e){return 0!==e||i?""+a+t:t})).join("\n");return o.copySafeness(t,c)},e.join=function(t,e,i){return e=e||"",i&&(t=n.map(t,(function(t){return t[i]}))),t.join(e)},e.last=function(t){return t[t.length-1]},e.length=function(t){var e=r(t,"");return void 0!==e?"function"==typeof Map&&e instanceof Map||"function"==typeof Set&&e instanceof Set?e.size:!n.isObject(e)||e instanceof o.SafeString?e.length:n.keys(e).length:0},e.list=c,e.lower=function(t){return(t=r(t,"")).toLowerCase()},e.nl2br=function(t){return null==t?"":o.copySafeness(t,t.replace(/\r\n|\n/g,"
\n"))},e.random=function(t){return t[Math.floor(Math.random()*t.length)]},e.reject=l(!1),e.rejectattr=function(t,e){return t.filter((function(t){return!t[e]}))},e.select=l(!0),e.selectattr=function(t,e){return t.filter((function(t){return!!t[e]}))},e.replace=function(t,e,i,n){var r=t;if(e instanceof RegExp)return t.replace(e,i);void 0===n&&(n=-1);var s="";if("number"==typeof e)e=""+e;else if("string"!=typeof e)return t;if("number"==typeof t&&(t=""+t),"string"!=typeof t&&!(t instanceof o.SafeString))return t;if(""===e)return s=i+t.split("").join(i)+i,o.copySafeness(t,s);var a=t.indexOf(e);if(0===n||-1===a)return t;for(var c=0,l=0;a>-1&&(-1===n||l=o&&h.push(i),r.push(h)}return r},e.sum=function(t,e,i){return void 0===i&&(i=0),e&&(t=n.map(t,(function(t){return t[e]}))),i+t.reduce((function(t,e){return t+e}),0)},e.sort=o.makeMacro(["value","reverse","case_sensitive","attribute"],[],(function(t,e,i,o){var r=this,s=n.map(t,(function(t){return t})),a=n.getAttrGetter(o);return s.sort((function(t,s){var c=o?a(t):t,l=o?a(s):s;if(r.env.opts.throwOnUndefined&&o&&(void 0===c||void 0===l))throw new TypeError('sort: attribute "'+o+'" resolved to undefined');return!i&&n.isString(c)&&n.isString(l)&&(c=c.toLowerCase(),l=l.toLowerCase()),cl?e?-1:1:0})),s})),e.string=function(t){return o.copySafeness(t,t)},e.striptags=function(t,e){var i,n=h((t=r(t,"")).replace(/<\/?([a-z][a-z0-9]*)\b[^>]*>|/gi,""));return i=e?n.replace(/^ +| +$/gm,"").replace(/ +/g," ").replace(/(\r\n)/g,"\n").replace(/\n\n\n+/g,"\n\n"):n.replace(/\s+/gi," "),o.copySafeness(t,i)},e.title=function(t){var e=(t=r(t,"")).split(" ").map((function(t){return a(t)}));return o.copySafeness(t,e.join(" "))},e.trim=h,e.truncate=function(t,e,i,n){var s=t;if(e=e||255,(t=r(t,"")).length<=e)return t;if(i)t=t.substring(0,e);else{var a=t.lastIndexOf(" ",e);-1===a&&(a=e),t=t.substring(0,a)}return t+=null!=n?n:"...",o.copySafeness(s,t)},e.upper=function(t){return(t=r(t,"")).toUpperCase()},e.urlencode=function(t){var e=encodeURIComponent;return n.isString(t)?e(t):(n.isArray(t)?t:n._entries(t)).map((function(t){var i=t[0],n=t[1];return e(i)+"="+e(n)})).join("&")};var u=/^(?:\(|<|<)?(.*?)(?:\.|,|\)|\n|>)?$/,p=/^[\w.!#$%&'*+\-\/=?\^`{|}~]+@[a-z\d\-]+(\.[a-z\d\-]+)+$/i,d=/^https?:\/\/.*$/,f=/^www\./,m=/\.(?:org|net|com)(?:\:|\/|$)/;e.urlize=function(t,e,i){s(e)&&(e=1/0);var n=!0===i?' rel="nofollow"':"";return t.split(/(\s+)/).filter((function(t){return t&&t.length})).map((function(t){var i=t.match(u),o=i?i[1]:t,r=o.substr(0,e);return d.test(o)?'"+r+"":f.test(o)?'"+r+"":p.test(o)?''+o+"":m.test(o)?'"+r+"":t})).join("")},e.wordcount=function(t){var e=(t=r(t,""))?t.match(/\w+/g):null;return e?e.length:null},e.float=function(t,e){var i=parseFloat(t);return s(i)?e:i};var v=o.makeMacro(["value","default","base"],[],(function(t,e,i){void 0===i&&(i=10);var n=parseInt(t,i);return s(n)?e:n}));e.int=v,e.d=e.default,e.e=e.escape},function(t,e,i){"use strict";function n(t,e){return n=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},n(t,e)}var o=function(t){var e,i;function o(e){var i;return(i=t.call(this)||this).precompiled=e||{},i}return i=t,(e=o).prototype=Object.create(i.prototype),e.prototype.constructor=e,n(e,i),o.prototype.getSource=function(t){return this.precompiled[t]?{src:{type:"code",obj:this.precompiled[t]},path:t}:null},o}(i(6));t.exports={PrecompiledLoader:o}},function(t,e,i){"use strict";var n=i(2).SafeString;e.callable=function(t){return"function"==typeof t},e.defined=function(t){return void 0!==t},e.divisibleby=function(t,e){return t%e==0},e.escaped=function(t){return t instanceof n},e.equalto=function(t,e){return t===e},e.eq=e.equalto,e.sameas=e.equalto,e.even=function(t){return t%2==0},e.falsy=function(t){return!t},e.ge=function(t,e){return t>=e},e.greaterthan=function(t,e){return t>e},e.gt=e.greaterthan,e.le=function(t,e){return t<=e},e.lessthan=function(t,e){return t0)for(var o=t;oe;r+=i)n.push(r);return n},cycler:function(){return t=Array.prototype.slice.call(arguments),e=-1,{current:null,reset:function(){e=-1,this.current=null},next:function(){return++e>=t.length&&(e=0),this.current=t[e],this.current}};var t,e},joiner:function(t){return function(t){t=t||",";var e=!0;return function(){var i=e?"":t;return e=!1,i}}(t)}}}},function(t,e,i){var n=i(4);t.exports=function(t,e){function i(t,e){if(this.name=t,this.path=t,this.defaultEngine=e.defaultEngine,this.ext=n.extname(t),!this.ext&&!this.defaultEngine)throw new Error("No default engine was specified and no extension was provided.");this.ext||(this.name+=this.ext=("."!==this.defaultEngine[0]?".":"")+this.defaultEngine)}return i.prototype.render=function(e,i){t.render(this.name,e,i)},e.set("view",i),e.set("nunjucksEnv",t),t}},function(t,e,i){"use strict";var n=i(4),o=i(4),r=i(0)._prettifyError,s=i(5),a=i(7).Environment,c=i(24);function l(t,e){return!!Array.isArray(e)&&e.some((function(e){return t.match(e)}))}function h(t,e){(e=e||{}).isString=!0;var i=e.env||new a([]),n=e.wrapper||c;if(!e.name)throw new Error('the "name" option is required when compiling a string');return n([u(t,e.name,i)],e)}function u(t,e,i){var n,o=(i=i||new a([])).asyncFilters,c=i.extensionsList;e=e.replace(/\\/g,"/");try{n=s.compile(t,o,c,e,i.opts)}catch(t){throw r(e,!1,t)}return{name:e,template:n}}t.exports={precompile:function(t,e){var i=(e=e||{}).env||new a([]),r=e.wrapper||c;if(e.isString)return h(t,e);var s=n.existsSync(t)&&n.statSync(t),p=[],d=[];if(s.isFile())p.push(u(n.readFileSync(t,"utf-8"),e.name||t,i));else if(s.isDirectory()){!function i(r){n.readdirSync(r).forEach((function(s){var a=o.join(r,s),c=a.substr(o.join(t,"/").length),h=n.statSync(a);h&&h.isDirectory()?l(c+="/",e.exclude)||i(a):l(c,e.include)&&d.push(a)}))}(t);for(var f=0;ft.length||o>0&&s>=n||o<0&&s<=n);s+=o)r.push(i.memberLookup(t,s));return r}function d(t,e){return Object.prototype.hasOwnProperty.call(t,e)}var f={pop:function(t){if(void 0===t)return this.pop();if(t>=this.length||t<0)throw new Error("KeyError");return this.splice(t,1)},append:function(t){return this.push(t)},remove:function(t){for(var e=0;e{"use strict";const t=globalThis,e=t.ShadowRoot&&(void 0===t.ShadyCSS||t.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,n=Symbol(),o=new WeakMap;class r{constructor(t,e,i){if(this._$cssResult$=!0,i!==n)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e}get styleSheet(){let t=this.o;const i=this.t;if(e&&void 0===t){const e=void 0!==i&&1===i.length;e&&(t=o.get(i)),void 0===t&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),e&&o.set(i,t))}return t}toString(){return this.cssText}}const s=(t,...e)=>{const i=1===t.length?t[0]:e.reduce(((e,i,n)=>e+(t=>{if(!0===t._$cssResult$)return t.cssText;if("number"==typeof t)return t;throw Error("Value passed to 'css' function must be a 'css' function result: "+t+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(i)+t[n+1]),t[0]);return new r(i,t,n)},a=(i,n)=>{if(e)i.adoptedStyleSheets=n.map((t=>t instanceof CSSStyleSheet?t:t.styleSheet));else for(const e of n){const n=document.createElement("style"),o=t.litNonce;void 0!==o&&n.setAttribute("nonce",o),n.textContent=e.cssText,i.appendChild(n)}},c=e?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(const i of t.cssRules)e+=i.cssText;return(t=>new r("string"==typeof t?t:t+"",void 0,n))(e)})(t):t,{is:l,defineProperty:h,getOwnPropertyDescriptor:u,getOwnPropertyNames:p,getOwnPropertySymbols:d,getPrototypeOf:f}=Object,m=globalThis,v=m.trustedTypes,y=v?v.emptyScript:"",_=m.reactiveElementPolyfillSupport,g=(t,e)=>t,b={toAttribute(t,e){switch(e){case Boolean:t=t?y:null;break;case Object:case Array:t=null==t?t:JSON.stringify(t)}return t},fromAttribute(t,e){let i=t;switch(e){case Boolean:i=null!==t;break;case Number:i=null===t?null:Number(t);break;case Object:case Array:try{i=JSON.parse(t)}catch(t){i=null}}return i}},C=(t,e)=>!l(t,e),k={attribute:!0,type:String,converter:b,reflect:!1,hasChanged:C};Symbol.metadata??=Symbol("metadata"),m.litPropertyMetadata??=new WeakMap;class L extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??=[]).push(t)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,e=k){if(e.state&&(e.attribute=!1),this._$Ei(),this.elementProperties.set(t,e),!e.noAccessor){const i=Symbol(),n=this.getPropertyDescriptor(t,i,e);void 0!==n&&h(this.prototype,t,n)}}static getPropertyDescriptor(t,e,i){const{get:n,set:o}=u(this.prototype,t)??{get(){return this[e]},set(t){this[e]=t}};return{get(){return n?.call(this)},set(e){const r=n?.call(this);o.call(this,e),this.requestUpdate(t,r,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??k}static _$Ei(){if(this.hasOwnProperty(g("elementProperties")))return;const t=f(this);t.finalize(),void 0!==t.l&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(g("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(g("properties"))){const t=this.properties,e=[...p(t),...d(t)];for(const i of e)this.createProperty(i,t[i])}const t=this[Symbol.metadata];if(null!==t){const e=litPropertyMetadata.get(t);if(void 0!==e)for(const[t,i]of e)this.elementProperties.set(t,i)}this._$Eh=new Map;for(const[t,e]of this.elementProperties){const i=this._$Eu(t,e);void 0!==i&&this._$Eh.set(i,t)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(t){const e=[];if(Array.isArray(t)){const i=new Set(t.flat(1/0).reverse());for(const t of i)e.unshift(c(t))}else void 0!==t&&e.push(c(t));return e}static _$Eu(t,e){const i=e.attribute;return!1===i?void 0:"string"==typeof i?i:"string"==typeof t?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$Eg=new Promise((t=>this.enableUpdating=t)),this._$AL=new Map,this._$ES(),this.requestUpdate(),this.constructor.l?.forEach((t=>t(this)))}addController(t){(this._$E_??=new Set).add(t),void 0!==this.renderRoot&&this.isConnected&&t.hostConnected?.()}removeController(t){this._$E_?.delete(t)}_$ES(){const t=new Map,e=this.constructor.elementProperties;for(const i of e.keys())this.hasOwnProperty(i)&&(t.set(i,this[i]),delete this[i]);t.size>0&&(this._$Ep=t)}createRenderRoot(){const t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return a(t,this.constructor.elementStyles),t}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$E_?.forEach((t=>t.hostConnected?.()))}enableUpdating(t){}disconnectedCallback(){this._$E_?.forEach((t=>t.hostDisconnected?.()))}attributeChangedCallback(t,e,i){this._$AK(t,i)}_$EO(t,e){const i=this.constructor.elementProperties.get(t),n=this.constructor._$Eu(t,i);if(void 0!==n&&!0===i.reflect){const o=(void 0!==i.converter?.toAttribute?i.converter:b).toAttribute(e,i.type);this._$Em=t,null==o?this.removeAttribute(n):this.setAttribute(n,o),this._$Em=null}}_$AK(t,e){const i=this.constructor,n=i._$Eh.get(t);if(void 0!==n&&this._$Em!==n){const t=i.getPropertyOptions(n),o="function"==typeof t.converter?{fromAttribute:t.converter}:void 0!==t.converter?.fromAttribute?t.converter:b;this._$Em=n,this[n]=o.fromAttribute(e,t.type),this._$Em=null}}requestUpdate(t,e,i){if(void 0!==t){if(i??=this.constructor.getPropertyOptions(t),!(i.hasChanged??C)(this[t],e))return;this.C(t,e,i)}!1===this.isUpdatePending&&(this._$Eg=this._$EP())}C(t,e,i){this._$AL.has(t)||this._$AL.set(t,e),!0===i.reflect&&this._$Em!==t&&(this._$ET??=new Set).add(t)}async _$EP(){this.isUpdatePending=!0;try{await this._$Eg}catch(t){Promise.reject(t)}const t=this.scheduleUpdate();return null!=t&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(const[t,e]of this._$Ep)this[t]=e;this._$Ep=void 0}const t=this.constructor.elementProperties;if(t.size>0)for(const[e,i]of t)!0!==i.wrapped||this._$AL.has(e)||void 0===this[e]||this.C(e,this[e],i)}let t=!1;const e=this._$AL;try{t=this.shouldUpdate(e),t?(this.willUpdate(e),this._$E_?.forEach((t=>t.hostUpdate?.())),this.update(e)):this._$Ej()}catch(e){throw t=!1,this._$Ej(),e}t&&this._$AE(e)}willUpdate(t){}_$AE(t){this._$E_?.forEach((t=>t.hostUpdated?.())),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$Ej(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$Eg}shouldUpdate(t){return!0}update(t){this._$ET&&=this._$ET.forEach((t=>this._$EO(t,this[t]))),this._$Ej()}updated(t){}firstUpdated(t){}}L.elementStyles=[],L.shadowRootOptions={mode:"open"},L[g("elementProperties")]=new Map,L[g("finalized")]=new Map,_?.({ReactiveElement:L}),(m.reactiveElementVersions??=[]).push("2.0.3");const w=globalThis,x=w.trustedTypes,A=x?x.createPolicy("lit-html",{createHTML:t=>t}):void 0,E="$lit$",T=`lit$${(Math.random()+"").slice(9)}$`,O="?"+T,S=`<${O}>`,M=document,I=()=>M.createComment(""),N=t=>null===t||"object"!=typeof t&&"function"!=typeof t,$=Array.isArray,R="[ \t\n\f\r]",P=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,j=/-->/g,F=/>/g,B=RegExp(`>|${R}(?:([^\\s"'>=/]+)(${R}*=${R}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),D=/'/g,V=/"/g,H=/^(?:script|style|textarea|title)$/i,K=t=>(e,...i)=>({_$litType$:t,strings:e,values:i}),U=K(1),Z=(K(2),Symbol.for("lit-noChange")),z=Symbol.for("lit-nothing"),W=new WeakMap,Y=M.createTreeWalker(M,129);function G(t,e){if(!Array.isArray(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==A?A.createHTML(e):e}const q=(t,e)=>{const i=t.length-1,n=[];let o,r=2===e?"":"",s=P;for(let e=0;e"===c[0]?(s=o??P,l=-1):void 0===c[1]?l=-2:(l=s.lastIndex-c[2].length,a=c[1],s=void 0===c[3]?B:'"'===c[3]?V:D):s===V||s===D?s=B:s===j||s===F?s=P:(s=B,o=void 0);const u=s===B&&t[e+1].startsWith("/>")?" ":"";r+=s===P?i+S:l>=0?(n.push(a),i.slice(0,l)+E+i.slice(l)+T+u):i+T+(-2===l?e:u)}return[G(t,r+(t[i]||"")+(2===e?"":"")),n]};class X{constructor({strings:t,_$litType$:e},i){let n;this.parts=[];let o=0,r=0;const s=t.length-1,a=this.parts,[c,l]=q(t,e);if(this.el=X.createElement(c,i),Y.currentNode=this.el.content,2===e){const t=this.el.content.firstChild;t.replaceWith(...t.childNodes)}for(;null!==(n=Y.nextNode())&&a.length0){n.textContent=x?x.emptyScript:"";for(let i=0;i$(t)||"function"==typeof t?.[Symbol.iterator])(t)?this.T(t):this._(t)}k(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}$(t){this._$AH!==t&&(this._$AR(),this._$AH=this.k(t))}_(t){this._$AH!==z&&N(this._$AH)?this._$AA.nextSibling.data=t:this.$(M.createTextNode(t)),this._$AH=t}g(t){const{values:e,_$litType$:i}=t,n="number"==typeof i?this._$AC(t):(void 0===i.el&&(i.el=X.createElement(G(i.h,i.h[0]),this.options)),i);if(this._$AH?._$AD===n)this._$AH.p(e);else{const t=new Q(n,this),i=t.u(this.options);t.p(e),this.$(i),this._$AH=t}}_$AC(t){let e=W.get(t.strings);return void 0===e&&W.set(t.strings,e=new X(t)),e}T(t){$(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let i,n=0;for(const o of t)n===e.length?e.push(i=new tt(this.k(I()),this.k(I()),this,this.options)):i=e[n],i._$AI(o),n++;n2||""!==i[0]||""!==i[1]?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=z}_$AI(t,e=this,i,n){const o=this.strings;let r=!1;if(void 0===o)t=J(this,t,e,0),r=!N(t)||t!==this._$AH&&t!==Z,r&&(this._$AH=t);else{const n=t;let s,a;for(t=o[0],s=0;s{const n=i?.renderBefore??e;let o=n._$litPart$;if(void 0===o){const t=i?.renderBefore??null;n._$litPart$=o=new tt(e.insertBefore(I(),t),t,void 0,i??{})}return o._$AI(t),o})(e,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return Z}}at._$litElement$=!0,at.finalized=!0,globalThis.litElementHydrateSupport?.({LitElement:at});const ct=globalThis.litElementPolyfillSupport;ct?.({LitElement:at}),(globalThis.litElementVersions??=[]).push("4.0.3");const lt=t=>(e,i)=>{void 0!==i?i.addInitializer((()=>{customElements.define(t,e)})):customElements.define(t,e)},ht={attribute:!0,type:String,converter:b,reflect:!1,hasChanged:C},ut=(t=ht,e,i)=>{const{kind:n,metadata:o}=i;let r=globalThis.litPropertyMetadata.get(o);if(void 0===r&&globalThis.litPropertyMetadata.set(o,r=new Map),r.set(i.name,t),"accessor"===n){const{name:n}=i;return{set(i){const o=e.get.call(this);e.set.call(this,i),this.requestUpdate(n,o,t)},init(e){return void 0!==e&&this.C(n,void 0,t),e}}}if("setter"===n){const{name:n}=i;return function(i){const o=this[n];e.call(this,i),this.requestUpdate(n,o,t)}}throw Error("Unsupported decorator location: "+n)};function pt(t){return(e,i)=>"object"==typeof i?ut(t,e,i):((t,e,i)=>{const n=e.hasOwnProperty(i);return e.constructor.createProperty(i,n?{...t,wrapped:!0}:t),n?Object.getOwnPropertyDescriptor(e,i):void 0})(t,e,i)}function dt(t){return pt({...t,state:!0,attribute:!1})}function ft(t){return(e,i)=>{const n="function"==typeof e?e:e[i];Object.assign(n,t)}}class mt{constructor(t){}get _$AU(){return this._$AM._$AU}_$AT(t,e,i){this._$Ct=t,this._$AM=e,this._$Ci=i}_$AS(t,e){return this.update(t,e)}update(t,e){return this.render(...e)}}const vt="important",yt=" !"+vt,_t=(t=>(...e)=>({_$litDirective$:t,values:e}))(class extends mt{constructor(t){if(super(t),1!==t.type||"style"!==t.name||t.strings?.length>2)throw Error("The `styleMap` directive must be used in the `style` attribute and must be the only part in the attribute.")}render(t){return Object.keys(t).reduce(((e,i)=>{const n=t[i];return null==n?e:e+`${i=i.includes("-")?i:i.replace(/(?:^(webkit|moz|ms|o)|)(?=[A-Z])/g,"-$&").toLowerCase()}:${n};`}),"")}update(t,[e]){const{style:i}=t.element;if(void 0===this.ut)return this.ut=new Set(Object.keys(e)),this.render(e);for(const t of this.ut)null==e[t]&&(this.ut.delete(t),t.includes("-")?i.removeProperty(t):i[t]=null);for(const t in e){const n=e[t];if(null!=n){this.ut.add(t);const e="string"==typeof n&&n.endsWith(yt);t.includes("-")||e?i.setProperty(t,e?n.slice(0,-11):n,e?vt:""):i[t]=n}}return Z}});var gt=i(865);function bt(t){return null==t}var Ct={isNothing:bt,isObject:function(t){return"object"==typeof t&&null!==t},toArray:function(t){return Array.isArray(t)?t:bt(t)?[]:[t]},repeat:function(t,e){var i,n="";for(i=0;ia&&(e=n-a+(r=" ... ").length),i-n>a&&(i=n+a-(s=" ...").length),{str:r+t.slice(e,i).replace(/\t/g,"→")+s,pos:n-e+r.length}}function At(t,e){return Ct.repeat(" ",e-t.length)+t}var Et=function(t,e){if(e=Object.create(e||null),!t.buffer)return null;e.maxLength||(e.maxLength=79),"number"!=typeof e.indent&&(e.indent=1),"number"!=typeof e.linesBefore&&(e.linesBefore=3),"number"!=typeof e.linesAfter&&(e.linesAfter=2);for(var i,n=/\r?\n|\r|\0/g,o=[0],r=[],s=-1;i=n.exec(t.buffer);)r.push(i.index),o.push(i.index+i[0].length),t.position<=i.index&&s<0&&(s=o.length-2);s<0&&(s=o.length-1);var a,c,l="",h=Math.min(t.line+e.linesAfter,r.length).toString().length,u=e.maxLength-(e.indent+h+3);for(a=1;a<=e.linesBefore&&!(s-a<0);a++)c=xt(t.buffer,o[s-a],r[s-a],t.position-(o[s]-o[s-a]),u),l=Ct.repeat(" ",e.indent)+At((t.line-a+1).toString(),h)+" | "+c.str+"\n"+l;for(c=xt(t.buffer,o[s],r[s],t.position,u),l+=Ct.repeat(" ",e.indent)+At((t.line+1).toString(),h)+" | "+c.str+"\n",l+=Ct.repeat("-",e.indent+h+3+c.pos)+"^\n",a=1;a<=e.linesAfter&&!(s+a>=r.length);a++)c=xt(t.buffer,o[s+a],r[s+a],t.position-(o[s]-o[s+a]),u),l+=Ct.repeat(" ",e.indent)+At((t.line+a+1).toString(),h)+" | "+c.str+"\n";return l.replace(/\n$/,"")},Tt=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"],Ot=["scalar","sequence","mapping"],St=function(t,e){if(e=e||{},Object.keys(e).forEach((function(e){if(-1===Tt.indexOf(e))throw new wt('Unknown option "'+e+'" is met in definition of "'+t+'" YAML type.')})),this.options=e,this.tag=t,this.kind=e.kind||null,this.resolve=e.resolve||function(){return!0},this.construct=e.construct||function(t){return t},this.instanceOf=e.instanceOf||null,this.predicate=e.predicate||null,this.represent=e.represent||null,this.representName=e.representName||null,this.defaultStyle=e.defaultStyle||null,this.multi=e.multi||!1,this.styleAliases=function(t){var e={};return null!==t&&Object.keys(t).forEach((function(i){t[i].forEach((function(t){e[String(t)]=i}))})),e}(e.styleAliases||null),-1===Ot.indexOf(this.kind))throw new wt('Unknown kind "'+this.kind+'" is specified for "'+t+'" YAML type.')};function Mt(t,e){var i=[];return t[e].forEach((function(t){var e=i.length;i.forEach((function(i,n){i.tag===t.tag&&i.kind===t.kind&&i.multi===t.multi&&(e=n)})),i[e]=t})),i}function It(t){return this.extend(t)}It.prototype.extend=function(t){var e=[],i=[];if(t instanceof St)i.push(t);else if(Array.isArray(t))i=i.concat(t);else{if(!t||!Array.isArray(t.implicit)&&!Array.isArray(t.explicit))throw new wt("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })");t.implicit&&(e=e.concat(t.implicit)),t.explicit&&(i=i.concat(t.explicit))}e.forEach((function(t){if(!(t instanceof St))throw new wt("Specified list of YAML types (or a single Type object) contains a non-Type object.");if(t.loadKind&&"scalar"!==t.loadKind)throw new wt("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.");if(t.multi)throw new wt("There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.")})),i.forEach((function(t){if(!(t instanceof St))throw new wt("Specified list of YAML types (or a single Type object) contains a non-Type object.")}));var n=Object.create(It.prototype);return n.implicit=(this.implicit||[]).concat(e),n.explicit=(this.explicit||[]).concat(i),n.compiledImplicit=Mt(n,"implicit"),n.compiledExplicit=Mt(n,"explicit"),n.compiledTypeMap=function(){var t,e,i={scalar:{},sequence:{},mapping:{},fallback:{},multi:{scalar:[],sequence:[],mapping:[],fallback:[]}};function n(t){t.multi?(i.multi[t.kind].push(t),i.multi.fallback.push(t)):i[t.kind][t.tag]=i.fallback[t.tag]=t}for(t=0,e=arguments.length;t=0?"0b"+t.toString(2):"-0b"+t.toString(2).slice(1)},octal:function(t){return t>=0?"0o"+t.toString(8):"-0o"+t.toString(8).slice(1)},decimal:function(t){return t.toString(10)},hexadecimal:function(t){return t>=0?"0x"+t.toString(16).toUpperCase():"-0x"+t.toString(16).toUpperCase().slice(1)}},defaultStyle:"decimal",styleAliases:{binary:[2,"bin"],octal:[8,"oct"],decimal:[10,"dec"],hexadecimal:[16,"hex"]}}),Dt=new RegExp("^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$"),Vt=/^[-+]?[0-9]+e/,Ht=new St("tag:yaml.org,2002:float",{kind:"scalar",resolve:function(t){return null!==t&&!(!Dt.test(t)||"_"===t[t.length-1])},construct:function(t){var e,i;return i="-"===(e=t.replace(/_/g,"").toLowerCase())[0]?-1:1,"+-".indexOf(e[0])>=0&&(e=e.slice(1)),".inf"===e?1===i?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:".nan"===e?NaN:i*parseFloat(e,10)},predicate:function(t){return"[object Number]"===Object.prototype.toString.call(t)&&(t%1!=0||Ct.isNegativeZero(t))},represent:function(t,e){var i;if(isNaN(t))switch(e){case"lowercase":return".nan";case"uppercase":return".NAN";case"camelcase":return".NaN"}else if(Number.POSITIVE_INFINITY===t)switch(e){case"lowercase":return".inf";case"uppercase":return".INF";case"camelcase":return".Inf"}else if(Number.NEGATIVE_INFINITY===t)switch(e){case"lowercase":return"-.inf";case"uppercase":return"-.INF";case"camelcase":return"-.Inf"}else if(Ct.isNegativeZero(t))return"-0.0";return i=t.toString(10),Vt.test(i)?i.replace("e",".e"):i},defaultStyle:"lowercase"}),Kt=Nt.extend({implicit:[$t,Rt,Bt,Ht]}),Ut=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),Zt=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$"),zt=new St("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:function(t){return null!==t&&(null!==Ut.exec(t)||null!==Zt.exec(t))},construct:function(t){var e,i,n,o,r,s,a,c,l=0,h=null;if(null===(e=Ut.exec(t))&&(e=Zt.exec(t)),null===e)throw new Error("Date resolve error");if(i=+e[1],n=+e[2]-1,o=+e[3],!e[4])return new Date(Date.UTC(i,n,o));if(r=+e[4],s=+e[5],a=+e[6],e[7]){for(l=e[7].slice(0,3);l.length<3;)l+="0";l=+l}return e[9]&&(h=6e4*(60*+e[10]+ +(e[11]||0)),"-"===e[9]&&(h=-h)),c=new Date(Date.UTC(i,n,o,r,s,a,l)),h&&c.setTime(c.getTime()-h),c},instanceOf:Date,represent:function(t){return t.toISOString()}}),Wt=new St("tag:yaml.org,2002:merge",{kind:"scalar",resolve:function(t){return"<<"===t||null===t}}),Yt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r",Gt=new St("tag:yaml.org,2002:binary",{kind:"scalar",resolve:function(t){if(null===t)return!1;var e,i,n=0,o=t.length,r=Yt;for(i=0;i64)){if(e<0)return!1;n+=6}return n%8==0},construct:function(t){var e,i,n=t.replace(/[\r\n=]/g,""),o=n.length,r=Yt,s=0,a=[];for(e=0;e>16&255),a.push(s>>8&255),a.push(255&s)),s=s<<6|r.indexOf(n.charAt(e));return 0==(i=o%4*6)?(a.push(s>>16&255),a.push(s>>8&255),a.push(255&s)):18===i?(a.push(s>>10&255),a.push(s>>2&255)):12===i&&a.push(s>>4&255),new Uint8Array(a)},predicate:function(t){return"[object Uint8Array]"===Object.prototype.toString.call(t)},represent:function(t){var e,i,n="",o=0,r=t.length,s=Yt;for(e=0;e>18&63],n+=s[o>>12&63],n+=s[o>>6&63],n+=s[63&o]),o=(o<<8)+t[e];return 0==(i=r%3)?(n+=s[o>>18&63],n+=s[o>>12&63],n+=s[o>>6&63],n+=s[63&o]):2===i?(n+=s[o>>10&63],n+=s[o>>4&63],n+=s[o<<2&63],n+=s[64]):1===i&&(n+=s[o>>2&63],n+=s[o<<4&63],n+=s[64],n+=s[64]),n}}),qt=Object.prototype.hasOwnProperty,Xt=Object.prototype.toString,Jt=new St("tag:yaml.org,2002:omap",{kind:"sequence",resolve:function(t){if(null===t)return!0;var e,i,n,o,r,s=[],a=t;for(e=0,i=a.length;e>10),56320+(t-65536&1023))}for(var Ee=new Array(256),Te=new Array(256),Oe=0;Oe<256;Oe++)Ee[Oe]=xe(Oe)?1:0,Te[Oe]=xe(Oe);function Se(t,e){this.input=t,this.filename=e.filename||null,this.schema=e.schema||ne,this.onWarning=e.onWarning||null,this.legacy=e.legacy||!1,this.json=e.json||!1,this.listener=e.listener||null,this.implicitTypes=this.schema.compiledImplicit,this.typeMap=this.schema.compiledTypeMap,this.length=t.length,this.position=0,this.line=0,this.lineStart=0,this.lineIndent=0,this.firstTabInLine=-1,this.documents=[]}function Me(t,e){var i={name:t.filename,buffer:t.input.slice(0,-1),position:t.position,line:t.line,column:t.position-t.lineStart};return i.snippet=Et(i),new wt(e,i)}function Ie(t,e){throw Me(t,e)}function Ne(t,e){t.onWarning&&t.onWarning.call(null,Me(t,e))}var $e={YAML:function(t,e,i){var n,o,r;null!==t.version&&Ie(t,"duplication of %YAML directive"),1!==i.length&&Ie(t,"YAML directive accepts exactly one argument"),null===(n=/^([0-9]+)\.([0-9]+)$/.exec(i[0]))&&Ie(t,"ill-formed argument of the YAML directive"),o=parseInt(n[1],10),r=parseInt(n[2],10),1!==o&&Ie(t,"unacceptable YAML version of the document"),t.version=i[0],t.checkLineBreaks=r<2,1!==r&&2!==r&&Ne(t,"unsupported YAML version of the document")},TAG:function(t,e,i){var n,o;2!==i.length&&Ie(t,"TAG directive accepts exactly two arguments"),n=i[0],o=i[1],me.test(n)||Ie(t,"ill-formed tag handle (first argument) of the TAG directive"),oe.call(t.tagMap,n)&&Ie(t,'there is a previously declared suffix for "'+n+'" tag handle'),ve.test(o)||Ie(t,"ill-formed tag prefix (second argument) of the TAG directive");try{o=decodeURIComponent(o)}catch(e){Ie(t,"tag prefix is malformed: "+o)}t.tagMap[n]=o}};function Re(t,e,i,n){var o,r,s,a;if(e1&&(t.result+=Ct.repeat("\n",e-1))}function He(t,e){var i,n,o=t.tag,r=t.anchor,s=[],a=!1;if(-1!==t.firstTabInLine)return!1;for(null!==t.anchor&&(t.anchorMap[t.anchor]=s),n=t.input.charCodeAt(t.position);0!==n&&(-1!==t.firstTabInLine&&(t.position=t.firstTabInLine,Ie(t,"tab characters must not be used in indentation")),45===n)&&be(t.input.charCodeAt(t.position+1));)if(a=!0,t.position++,Be(t,!0,-1)&&t.lineIndent<=e)s.push(null),n=t.input.charCodeAt(t.position);else if(i=t.line,Ze(t,e,ae,!1,!0),s.push(t.result),Be(t,!0,-1),n=t.input.charCodeAt(t.position),(t.line===i||t.lineIndent>e)&&0!==n)Ie(t,"bad indentation of a sequence entry");else if(t.lineIndente?f=1:t.lineIndent===e?f=0:t.lineIndente?f=1:t.lineIndent===e?f=0:t.lineIndente)&&(y&&(s=t.line,a=t.lineStart,c=t.position),Ze(t,e,ce,!0,o)&&(y?m=t.result:v=t.result),y||(je(t,p,d,f,m,v,s,a,c),f=m=v=null),Be(t,!0,-1),l=t.input.charCodeAt(t.position)),(t.line===r||t.lineIndent>e)&&0!==l)Ie(t,"bad indentation of a mapping entry");else if(t.lineIndent=0))break;0===o?Ie(t,"bad explicit indentation width of a block scalar; it cannot be less than one"):c?Ie(t,"repeat of an indentation width identifier"):(l=e+o-1,c=!0)}if(ge(r)){do{r=t.input.charCodeAt(++t.position)}while(ge(r));if(35===r)do{r=t.input.charCodeAt(++t.position)}while(!_e(r)&&0!==r)}for(;0!==r;){for(Fe(t),t.lineIndent=0,r=t.input.charCodeAt(t.position);(!c||t.lineIndentl&&(l=t.lineIndent),_e(r))h++;else{if(t.lineIndent0){for(o=s,r=0;o>0;o--)(s=ke(a=t.input.charCodeAt(++t.position)))>=0?r=(r<<4)+s:Ie(t,"expected hexadecimal character");t.result+=Ae(r),t.position++}else Ie(t,"unknown escape sequence");i=n=t.position}else _e(a)?(Re(t,i,n,!0),Ve(t,Be(t,!1,e)),i=n=t.position):t.position===t.lineStart&&De(t)?Ie(t,"unexpected end of the document within a double quoted scalar"):(t.position++,n=t.position)}Ie(t,"unexpected end of the stream within a double quoted scalar")}(t,p)?v=!0:function(t){var e,i,n;if(42!==(n=t.input.charCodeAt(t.position)))return!1;for(n=t.input.charCodeAt(++t.position),e=t.position;0!==n&&!be(n)&&!Ce(n);)n=t.input.charCodeAt(++t.position);return t.position===e&&Ie(t,"name of an alias node must contain at least one character"),i=t.input.slice(e,t.position),oe.call(t.anchorMap,i)||Ie(t,'unidentified alias "'+i+'"'),t.result=t.anchorMap[i],Be(t,!0,-1),!0}(t)?(v=!0,null===t.tag&&null===t.anchor||Ie(t,"alias node should not have any properties")):function(t,e,i){var n,o,r,s,a,c,l,h,u=t.kind,p=t.result;if(be(h=t.input.charCodeAt(t.position))||Ce(h)||35===h||38===h||42===h||33===h||124===h||62===h||39===h||34===h||37===h||64===h||96===h)return!1;if((63===h||45===h)&&(be(n=t.input.charCodeAt(t.position+1))||i&&Ce(n)))return!1;for(t.kind="scalar",t.result="",o=r=t.position,s=!1;0!==h;){if(58===h){if(be(n=t.input.charCodeAt(t.position+1))||i&&Ce(n))break}else if(35===h){if(be(t.input.charCodeAt(t.position-1)))break}else{if(t.position===t.lineStart&&De(t)||i&&Ce(h))break;if(_e(h)){if(a=t.line,c=t.lineStart,l=t.lineIndent,Be(t,!1,-1),t.lineIndent>=e){s=!0,h=t.input.charCodeAt(t.position);continue}t.position=r,t.line=a,t.lineStart=c,t.lineIndent=l;break}}s&&(Re(t,o,r,!1),Ve(t,t.line-a),o=r=t.position,s=!1),ge(h)||(r=t.position+1),h=t.input.charCodeAt(++t.position)}return Re(t,o,r,!1),!!t.result||(t.kind=u,t.result=p,!1)}(t,p,re===i)&&(v=!0,null===t.tag&&(t.tag="?")),null!==t.anchor&&(t.anchorMap[t.anchor]=t.result)):0===f&&(v=a&&He(t,d))),null===t.tag)null!==t.anchor&&(t.anchorMap[t.anchor]=t.result);else if("?"===t.tag){for(null!==t.result&&"scalar"!==t.kind&&Ie(t,'unacceptable node kind for ! tag; it should be "scalar", not "'+t.kind+'"'),c=0,l=t.implicitTypes.length;c"),null!==t.result&&u.kind!==t.kind&&Ie(t,"unacceptable node kind for !<"+t.tag+'> tag; it should be "'+u.kind+'", not "'+t.kind+'"'),u.resolve(t.result,t.tag)?(t.result=u.construct(t.result,t.tag),null!==t.anchor&&(t.anchorMap[t.anchor]=t.result)):Ie(t,"cannot resolve a node with !<"+t.tag+"> explicit tag")}return null!==t.listener&&t.listener("close",t),null!==t.tag||null!==t.anchor||v}function ze(t){var e,i,n,o,r=t.position,s=!1;for(t.version=null,t.checkLineBreaks=t.legacy,t.tagMap=Object.create(null),t.anchorMap=Object.create(null);0!==(o=t.input.charCodeAt(t.position))&&(Be(t,!0,-1),o=t.input.charCodeAt(t.position),!(t.lineIndent>0||37!==o));){for(s=!0,o=t.input.charCodeAt(++t.position),e=t.position;0!==o&&!be(o);)o=t.input.charCodeAt(++t.position);for(n=[],(i=t.input.slice(e,t.position)).length<1&&Ie(t,"directive name must not be less than one character in length");0!==o;){for(;ge(o);)o=t.input.charCodeAt(++t.position);if(35===o){do{o=t.input.charCodeAt(++t.position)}while(0!==o&&!_e(o));break}if(_e(o))break;for(e=t.position;0!==o&&!be(o);)o=t.input.charCodeAt(++t.position);n.push(t.input.slice(e,t.position))}0!==o&&Fe(t),oe.call($e,i)?$e[i](t,i,n):Ne(t,'unknown document directive "'+i+'"')}Be(t,!0,-1),0===t.lineIndent&&45===t.input.charCodeAt(t.position)&&45===t.input.charCodeAt(t.position+1)&&45===t.input.charCodeAt(t.position+2)?(t.position+=3,Be(t,!0,-1)):s&&Ie(t,"directives end mark is expected"),Ze(t,t.lineIndent-1,ce,!1,!0),Be(t,!0,-1),t.checkLineBreaks&&de.test(t.input.slice(r,t.position))&&Ne(t,"non-ASCII line breaks are interpreted as content"),t.documents.push(t.result),t.position===t.lineStart&&De(t)?46===t.input.charCodeAt(t.position)&&(t.position+=3,Be(t,!0,-1)):t.position=0;a--)(o=t[a])&&(s=(r<3?o(s):r>3?o(e,i,s):o(e,i))||s);return r>3&&s&&Object.defineProperty(e,i,s),s};let ii=class extends at{constructor(){super(...arguments),this.onKeyDownFired=!1}getRokuId(t){return(this.haAction?.keyboard_id??"").split(".")[0]!=t?"media_player"===t?this.haAction?.media_player_id:this.haAction?.remote_id:this.haAction?.keyboard_id}forceCursorToEnd(){this.textarea.selectionStart=this.textarea.value.length,this.textarea.selectionEnd=this.textarea.value.length}forceCursorToEndEvent(t){t.preventDefault(),this.forceCursorToEnd()}kodiOnKeyDown(t){if(t.stopImmediatePropagation(),["Backspace","Enter"].includes(t.key)){const t=this.textarea?.value??"";this.hass.callService("kodi","call_method",{entity_id:this.haAction?.keyboard_id,method:"Input.SendText",text:t,done:!1})}}kodiOnInput(t){t.stopImmediatePropagation();const e=this.textarea?.value??"";this.hass.callService("kodi","call_method",{entity_id:this.haAction?.keyboard_id,method:"Input.SendText",text:e,done:!1})}rokuOnKeyDown(t){t.stopImmediatePropagation(),this.forceCursorToEnd();const e=t.key,i={Backspace:"backspace",Enter:"enter"}[e??""];i&&(this.onKeyDownFired=!0,this.hass.callService("remote","send_command",{entity_id:this.getRokuId("remote"),command:i}),"Enter"==e&&this.closeDialog())}rokuOnInput(t){t.stopImmediatePropagation(),this.forceCursorToEnd();const e=t.inputType??"",i=t.data??"";if(i&&"insertText"==e)this.hass.callService("remote","send_command",{entity_id:this.haAction?.keyboard_id,command:`Lit_${i}`});else if(!this.onKeyDownFired){const t={deleteContentBackward:"backspace",insertLineBreak:"enter"}[e??""];t&&this.hass.callService("remote","send_command",{entity_id:this.getRokuId("remote"),command:t})}this.onKeyDownFired=!1}fireTvOnKeyDown(t){t.stopImmediatePropagation(),this.forceCursorToEnd();const e=t.key,i={Backspace:"67",Enter:"66"}[e??""];if(i){let t,n;this.onKeyDownFired=!0,"media_player"===this.haAction?.keyboard_id?(t="androidtv",n="adb_command"):(t="remote",n="send_command"),this.hass.callService(t,n,{entity_id:this.haAction?.keyboard_id,command:`input keyevent ${i}`}),"Enter"==e&&this.closeDialog()}}fireTvOnInput(t){t.stopImmediatePropagation(),this.forceCursorToEnd();const e=t.inputType??"",i=t.data??"";if(i&&"insertText"==e)this.androidTvSendText(i);else if(!this.onKeyDownFired){const t={deleteContentBackward:"67",insertLineBreak:"66"}[e??""];if(t){let e,i;"media_player"===this.haAction?.keyboard_id?(e="androidtv",i="adb_command"):(e="remote",i="send_command"),this.hass.callService(e,i,{entity_id:this.haAction?.keyboard_id,command:`input keyevent ${t}`})}}this.onKeyDownFired=!1}androidTvOnKeyDown(t){t.stopImmediatePropagation(),this.forceCursorToEnd();const e=t.key,i={Backspace:"DEL",Enter:"ENTER"}[e??""];i&&(this.onKeyDownFired=!0,this.hass.callService("remote","send_command",{entity_id:this.haAction?.remote_id,command:i}),"Enter"==e&&this.closeDialog())}androidTvOnInput(t){t.stopImmediatePropagation(),this.forceCursorToEnd();const e=t.inputType??"",i=t.data??"";if(i&&"insertText"==e)this.androidTvSendText(i);else if(!this.onKeyDownFired){const t={deleteContentBackward:"DEL",insertLineBreak:"ENTER"}[e??""];t&&(this.hass.callService("remote","send_command",{entity_id:this.haAction?.remote_id,command:t}),"insertLineBreak"==e&&this.closeDialog())}this.onKeyDownFired=!1}androidTvSendText(t){let e,i;"media_player"===this.domain?(e="androidtv",i="adb_command"):(e="remote",i="send_command"),this.hass.callService(e,i,{entity_id:this.haAction?.keyboard_id,command:`input text "${t}"`})}keyboardOnPaste(t){t.stopImmediatePropagation(),"KODI"!=this.haAction?.platform&&this.forceCursorToEnd();const e=t.clipboardData?.getData("Text");if(e)switch(this.haAction?.platform){case"KODI":this.hass.callService("kodi","call_method",{entity_id:this.haAction?.keyboard_id,method:"Input.SendText",text:this.textarea?.value??"",done:!1});break;case"ROKU":this.hass.callService("remote","send_command",{entity_id:this.haAction?.keyboard_id,command:`Lit_${e}`});break;default:{let t,i;"remote"===this.domain?(t="remote",i="send_command"):(t="androidtv",i="adb_command"),this.hass.callService(t,i,{entity_id:this.haAction?.keyboard_id,command:`input text "${e}"`});break}}}textBox(t){const e=this.textarea?.value;if(e)switch(this.haAction?.platform){case"KODI":this.hass.callService("kodi","call_method",{entity_id:this.haAction?.keyboard_id,method:"Input.SendText",text:e,done:!1});break;case"ROKU":this.hass.callService("remote","send_command",{entity_id:this.getRokuId("remote"),command:`Lit_${e}`});break;default:{let t,i;"remote"===this.domain?(t="remote",i="send_command"):(t="androidtv",i="adb_command"),this.hass.callService(t,i,{entity_id:this.haAction?.keyboard_id,command:`input text "${e}"`});break}}this.closeDialog()}search(t){const e=this.textarea?.value;if(e)switch(this.haAction?.platform){case"KODI":{const t=this.haAction?.keyboard_id;Promise.resolve(this.hass.callService("kodi","call_method",{entity_id:t,method:"Addons.ExecuteAddon",addonid:"script.globalsearch"})),setTimeout((()=>{this.hass.callService("kodi","call_method",{entity_id:t,method:"Input.SendText",text:e,done:!0})}),1e3);break}case"ROKU":this.hass.callService("roku","search",{entity_id:this.getRokuId("media_player"),keyword:e});break;default:{let t,i;"remote"===this.domain?(t="remote",i="send_command"):(t="androidtv",i="adb_command"),this.hass.callService(t,i,{entity_id:this.haAction?.keyboard_id,command:`am start -a "android.search.action.GLOBAL_SEARCH" --es query "${e}"`});break}}this.closeDialog()}showDialog(t){this.haAction=t.detail,this.domain=(this.haAction?.keyboard_id??"").split(".")[0];const e=this.shadowRoot?.querySelector("dialog");if(e){try{e.showModal()}catch{e.close(),e.showModal()}window.addEventListener("popstate",(()=>this.closeDialog()))}this.textarea=this.shadowRoot?.querySelector("textarea");const i=this.textarea;setTimeout((()=>{i&&i.focus()}),.4)}cancelDialog(t){t.preventDefault(),this.closeDialog()}closeDialog(t){const e=this.shadowRoot?.querySelector("dialog");if(e){try{e.close()}catch{e.showModal(),e.close()}window.removeEventListener("popstate",(()=>this.closeDialog()))}this.textarea&&(this.textarea.value="",this.textarea.blur()),this.haAction=void 0,this.domain=void 0,this.textarea=void 0}buildDialogButton(t,e){return U`
${t}
`}render(){let t,e,i,n,o=U``,r=this.forceCursorToEndEvent;switch(this.haAction?.action){case"search":t="Search for something...",o=U`${this.buildDialogButton("Search",this.search)}${this.buildDialogButton("Close",this.closeDialog)}`;break;case"textbox":t="Type something...",o=U`${this.buildDialogButton("Send",this.textBox)}${this.buildDialogButton("Close",this.closeDialog)}`;break;default:switch(this.haAction?.platform){case"KODI":e=this.kodiOnInput,i=this.kodiOnKeyDown,r=void 0;break;case"ROKU":e=this.rokuOnInput,i=this.rokuOnKeyDown;break;case"FIRE TV":e=this.fireTvOnInput,i=this.fireTvOnKeyDown;break;default:e=this.androidTvOnInput,i=this.androidTvOnKeyDown}t="Type something...",n=this.keyboardOnPaste,o=this.buildDialogButton("Close",this.closeDialog)}t=this.haAction?.keyboard_prompt??t;const s=U``;return U`${s}
${o}
`}static get styles(){return s`:host{-webkit-tap-highlight-color:transparent;-webkit-tap-highlight-color:transparent}dialog{height:0;width:0;display:inline-flex;flex-direction:column;position:fixed;z-index:9;border:none;background:var(--ha-card-background,var(--card-background-color,#fff));border-radius:var(--ha-card-border-radius,12px);opacity:0;transition:all .1s ease-in-out;pointer-events:none}dialog[open]{height:fit-content;width:85%;opacity:1;transition:all .1s ease-in-out;pointer-events:all}textarea{position:relative;height:180px;padding:8px;outline:0;background:0 0;border:none;resize:none;font-family:inherit;font-weight:500;font-size:30px}.buttons{height:36px;display:inline-flex;flex-direction:row-reverse;justify-content:space-between;margin:0 12px}.button{height:100%;width:min-content;align-content:center;cursor:pointer;border-radius:var(--mdc-shape-small,4px);overflow:hidden}button{height:100%;width:100%;background:0 0;opacity:1;border:none;overflow:hidden;cursor:pointer;padding:0}@media (hover:hover){button:hover{background:var(--ha-ripple-color);opacity:var(--md-ripple-hover-opacity)}}button:active{background:var(--ha-ripple-color);opacity:var(--md-ripple-pressed-opacity)}.button span{font-family:inherit;font-size:var(--paper-font-body1_-_font-size);font-weight:600;text-transform:uppercase;color:var(--mdc-theme-primary,#6200ee);user-select:none;-webkit-user-select:none;-moz-user-select:none;position:relative;top:-32px;padding:0 8px;pointer-events:none}dialog::backdrop{background:#000;opacity:.7}`}};var ni,oi,ri;ei([pt()],ii.prototype,"hass",void 0),ei([dt()],ii.prototype,"haAction",void 0),ii=ei([lt("keyboard-dialog")],ii),(ri=ni||(ni={})).language="language",ri.system="system",ri.comma_decimal="comma_decimal",ri.decimal_comma="decimal_comma",ri.space_comma="space_comma",ri.none="none",function(t){t.language="language",t.system="system",t.am_pm="12",t.twenty_four="24"}(oi||(oi={})),new Set(["fan","input_boolean","light","switch","group","automation"]);new Set(["call-service","divider","section","weblink","cast","select"]);var si=function(t){!function(t,e,i,n){n=n||{},i=null==i?{}:i;var o=new Event(e,{bubbles:void 0===n.bubbles||n.bubbles,cancelable:Boolean(n.cancelable),composed:void 0===n.composed||n.composed});o.detail=i,t.dispatchEvent(o)}(window,"haptic",t)};function ai(t){let e=[];for(const i in t)if("object"==typeof t[i]){const n=ai(t[i]);e=e.concat(n.map((t=>i+"."+t)))}else e.push(i);return e}function ci(t,e){const i=e.split(".");if(null!=t)return 1==i.length?t[i[0]]:ci(t[i[0]],i.splice(1).join("."))}function li(t,e,i){const n=e.split(".");return 1==n.length?t[n[0]]=i:(n[0]in t&&"object"==typeof t[n[0]]||(/^-?\d+$/.test(n[1])?t[n[0]]=new Array(parseInt(n[1])):t[n[0]]={}),li(t[n[0]],n.splice(1).join("."),i)),t}var hi=function(t,e,i,n){var o,r=arguments.length,s=r<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,i,n);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(s=(r<3?o(s):r>3?o(e,i,s):o(e,i))||s);return r>3&&s&&Object.defineProperty(e,i,s),s};class ui extends at{constructor(){super(...arguments),this.autofillEntityId=!1,this.renderRipple=!0,this.value=0,this.getValueFromHass=!0,this.fireMouseEvent=!0,this.swiping=!1}fireHapticEvent(t){(this.renderTemplate(this.config.haptics)??1)&&si(t)}endAction(){this.buttonPressStart=void 0,this.buttonPressEnd=void 0,this.swiping=!1,this.initialX=void 0,this.initialY=void 0}sendAction(t,e=this.config){let i;switch(t){case"momentary_start_action":i=e.momentary_start_action;break;case"momentary_end_action":i=e.momentary_end_action;break;case"multi_hold_action":i=e.multi_hold_action??e.hold_action??e.multi_tap_action??e.tap_action;break;case"multi_double_tap_action":i=e.multi_double_tap_action??e.double_tap_action??e.multi_tap_action??e.tap_action;break;case"multi_tap_action":i=e.multi_tap_action??e.tap_action;break;case"hold_action":i=e.hold_action??e.tap_action;break;case"double_tap_action":i=e.double_tap_action??e.tap_action;break;default:i=e.tap_action}if(i&&this.handleConfirmation(i))try{switch(i.action){case"navigate":this.navigate(i);break;case"url":this.toUrl(i);break;case"assist":this.assist(i);break;case"more-info":this.moreInfo(i);break;case"call-service":this.callService(i);break;case"source":this.changeSource(i);break;case"key":this.sendCommand(i,t);break;case"fire-dom-event":this.fireDomEvent(i);break;case"textbox":case"search":case"keyboard":this.keyboard(i)}}catch(t){throw this.endAction(),t}}sendCommand(t,e){const i={entity_id:this.renderTemplate(t.remote_id),command:this.renderTemplate(t.key)};"hold_action"!=e||this.config.hold_action||(i.hold_secs=.5),this.hass.callService("remote","send_command",i)}changeSource(t){this.hass.callService("remote","turn_on",{entity_id:this.renderTemplate(t.remote_id),activity:this.renderTemplate(t.source)})}callService(t){const e=this.renderTemplate(t.service),[i,n]=e.split("."),o=structuredClone(t.data);for(const t in o)if(Array.isArray(o[t]))for(const e in o[t])o[t][e]=this.renderTemplate(o[t][e]);else o[t]=this.renderTemplate(o[t]);let r=structuredClone(t.target);for(const t in r)if(Array.isArray(r[t]))for(const e in r[t])r[t][e]=this.renderTemplate(r[t][e]);else r[t]=this.renderTemplate(r[t]);if(this.renderTemplate(this.autofillEntityId)){let e;switch(i){case"remote":e=t.remote_id;break;case"media_player":case"kodi":case"denonavr":e=t.media_player_id}!e||o?.entity_id||o?.device_id||o?.area_id||o?.label_id||r?.entity_id||r?.device_id||r?.area_id||r?.label_id||(r={...r,entity_id:this.renderTemplate(e)})}this.hass.callService(i,n,o,r)}navigate(t){const e=this.renderTemplate(t.navigation_path)??"",i=this.renderTemplate(t.navigation_replace)??!1;if(e.includes("//"))return void console.error('Protocol detected in navigation path. To navigate to another website use the action "url" with the key "url_path" instead.');1==i?window.history.replaceState(window.history.state?.root?{root:!0}:null,"",e):window.history.pushState(null,"",e);const n=new Event("location-changed",{bubbles:!1,cancelable:!0,composed:!1});n.detail={replace:1==i},window.dispatchEvent(n)}toUrl(t){let e=this.renderTemplate(t.url_path)??"";e.includes("//")||(e=`https://${e}`),window.open(e)}assist(t){this.hass?.auth?.external?.config?.hasAssist?this.hass?.auth?.external?.fireMessage({type:"assist/show",payload:{pipeline_id:t.pipeline_id,start_listening:t.start_listening}}):window.open(`${window.location.href}?conversation=1`,"_self")}moreInfo(t){const e=this.renderTemplate(t.target?.entity_id??t.data?.entity_id),i=new Event("hass-more-info",{bubbles:!0,cancelable:!0,composed:!0});i.detail={entityId:e},this.dispatchEvent(i)}keyboard(t){const e=new Event("keyboard-dialog-open",{composed:!0,bubbles:!0});e.detail=this.deepRenderTemplate(t),this.getRootNode().querySelector("keyboard-dialog").shadowRoot?.querySelector("dialog")?.dispatchEvent(e)}fireDomEvent(t){const e=new Event(t.event_type??"ll-custom",{composed:!0,bubbles:!0});e.detail=t,this.dispatchEvent(e)}handleConfirmation(t){if("confirmation"in t){let e=t.confirmation;if("string"==typeof e&&(e=this.renderTemplate(t.confirmation)),0!=e){this.fireHapticEvent("warning");let i="";if(i=1!=e&&e?.text?this.renderTemplate(e?.text):`Are you sure you want to run action '${this.renderTemplate(t.action)}'?`,1==e){if(!confirm(i))return!1}else if(e?.exemptions){if(!e.exemptions?.map((t=>this.renderTemplate(t.user))).includes(this.hass.user.id)&&!confirm(i))return!1}else if(!confirm(i))return!1}}return!0}setValue(){if(this.entityId=this.renderTemplate(this.config.tap_action?.data?.entity_id??""),this.getValueFromHass&&this.entityId){clearInterval(this.valueUpdateInterval),this.valueUpdateInterval=void 0;let t=(this.renderTemplate(this.config.value_attribute)??"state").toLowerCase();if(this.hass.states[this.entityId])if("state"==t)this.value=this.hass.states[this.entityId].state;else{let e;const i=t.match(/\[\d+\]$/);if(i){const n=parseInt(i[0].replace(/\[|\]/g,""));t=t.replace(i[0],""),e=this.hass.states[this.entityId].attributes[t],e&&Array.isArray(e)&&e.length&&(e=e[n])}else e=this.hass.states[this.entityId].attributes[t];if(null!=e||"elapsed"==t)switch(t){case"brightness":this.value=Math.round(100*parseInt(e??0)/255);break;case"media_position":try{const t=()=>{"playing"==this.hass.states[this.entityId].state?this.value=Math.min(Math.floor(Math.floor(e)+(Date.now()-Date.parse(this.hass.states[this.entityId].attributes.media_position_updated_at))/1e3),Math.floor(this.hass.states[this.entityId].attributes.media_duration)):this.value=e};t(),this.valueUpdateInterval=setInterval(t,500)}catch(t){console.error(t),this.value=e}break;case"elapsed":if(this.entityId.startsWith("timer.")){if("idle"==this.hass.states[this.entityId].state)this.value=0;else{const t=this.hass.states[this.entityId].attributes.duration.split(":"),e=3600*parseInt(t[0])+60*parseInt(t[1])+parseInt(t[2]),i=Date.parse(this.hass.states[this.entityId].attributes.finishes_at);try{const t=()=>{if("active"==this.hass.states[this.entityId].state){const t=(i-Date.now())/1e3,n=Math.floor(e-t);this.value=Math.min(n,e)}else{const t=this.hass.states[this.entityId].attributes.remaining.split(":"),i=3600*parseInt(t[0])+60*parseInt(t[1])+parseInt(t[2]);this.value=Math.floor(e-i)}};t(),this.valueUpdateInterval=setInterval(t,500)}catch(t){console.error(t),this.value=0}}break}default:this.value=e}else this.value=e}else this.value=void 0}}renderTemplate(t,e){let i=0;this.buttonPressStart&&this.buttonPressEnd&&(i=(this.buttonPressEnd-this.buttonPressStart)/1e3),e={VALUE:this.value,HOLD_SECS:i??0,value:this.value,hold_secs:i??0,config:{...this.config,entity:this.entityId},...e};let n=(e={render:t=>this.renderTemplate(t,e),...e}).value;null!=n&&"number"==typeof n&&null!=this.precision&&(n=Number(n).toFixed(this.precision),e={...e,VALUE:n,value:n});const o=(0,gt.renderTemplate)(this.hass,t,e);if(o!=t)return o;if("string"==typeof t)for(const i of["VALUE","HOLD_SECS"]){if(t==i)return e[i];t.toString().includes(i)&&(t=t.replace(new RegExp(i,"g"),e[i]??""))}return t}deepRenderTemplate(t,e){const i=structuredClone(t),n=ai(i);for(const t of n)li(i,t,this.renderTemplate(ci(i,t),e));return i}buildIcon(t,e){if(t=this.renderTemplate(t??"",e)){let e=U``;return e=t.includes(":")?U``:U``,U`
${e}
`}return""}buildLabel(t,e){if(t){const i=this.renderTemplate(t,e);if(i)return U`
${i}
`}return""}buildRipple(){return this.renderRipple?U``:""}buildStyle(t={},e){const i=structuredClone(t);for(const t in i)i[t]=this.renderTemplate(i[t],e);return i}buildStyles(t=this.config,e){return t.styles?U``:""}onStart(t){}onEnd(t){}onMove(t){}onMouseDown(t){this.fireMouseEvent&&this.onStart(t)}onMouseUp(t){this.fireMouseEvent&&this.onEnd(t),this.fireMouseEvent=!0}onMouseMove(t){this.fireMouseEvent&&this.onMove(t)}onTouchStart(t){this.fireMouseEvent=!1,this.onStart(t)}onTouchEnd(t){this.fireMouseEvent=!1,this.onEnd(t)}onTouchMove(t){this.fireMouseEvent=!1,this.onMove(t)}onContextMenu(t){if(!this.fireMouseEvent)return t.preventDefault(),t.stopPropagation(),!1}toggleRipple(){this.cancelRippleToggle(),this.renderRippleTransition=setTimeout((()=>this.rippleTransition=!1),400),this.renderRippleOff=setTimeout((()=>this.renderRipple=!1),800),this.renderRippleOn=setTimeout((()=>this.cancelRippleToggle()),850)}cancelRippleToggle(){clearTimeout(this.renderRippleOff),clearTimeout(this.renderRippleOn),clearTimeout(this.renderRippleTransition),this.renderRippleOff=void 0,this.renderRippleOn=void 0,this.renderRippleTransition=void 0,this.rippleTransition=!0,this.renderRipple=!0}static get styles(){return s`:host{display:flex;flex-flow:column;place-content:center space-evenly;align-items:center;position:relative;border:none;border-radius:10px;padding:0;box-sizing:border-box;outline:0;overflow:visible;font-size:inherit;color:inherit;-webkit-tap-highlight-color:transparent;-webkit-tap-highlight-color:transparent}ha-icon,svg{display:inline-flex;flex-direction:column;justify-content:center;text-align:center;align-items:center;vertical-align:middle;height:var(--size,48px);width:var(--size,48px);z-index:2;pointer-events:none}md-ripple.transition-on{opacity:1 transition: opacity 375ms linear}md-ripple.transition-off{opacity:0;transition:opacity 375ms linear}.icon{pointer-events:none;position:relative;flex-flow:column;place-content:center;z-index:2;display:var(--icon-display,inline-flex);transform:var(--icon-transform);color:var(--icon-color,var(--primary-text-color));filter:var(--icon-filter, none)}.label{position:relative;pointer-events:none;justify-content:center;align-items:center;height:15px;line-height:15px;width:inherit;margin:0;font-family:inherit;font-size:12px;font-weight:700;z-index:2;display:var(--label-display,inline-flex);transform:var(--label-transform);color:var(--label-color,inherit);filter:var(--label-filter, none)}`}}hi([pt({attribute:!1})],ui.prototype,"hass",void 0),hi([pt({attribute:!1})],ui.prototype,"config",void 0),hi([pt({attribute:!1})],ui.prototype,"icons",void 0),hi([pt({attribute:!1})],ui.prototype,"autofillEntityId",void 0),hi([dt()],ui.prototype,"renderRipple",void 0),hi([dt()],ui.prototype,"renderRippleOff",void 0),hi([dt()],ui.prototype,"renderRippleOn",void 0),hi([dt()],ui.prototype,"renderRippleTransition",void 0),hi([dt()],ui.prototype,"rippleTransition",void 0),hi([dt()],ui.prototype,"value",void 0),hi([ft({passive:!0})],ui.prototype,"onMouseDown",null),hi([ft({passive:!0})],ui.prototype,"onMouseMove",null),hi([ft({passive:!0})],ui.prototype,"onTouchStart",null),hi([ft({passive:!0})],ui.prototype,"onTouchMove",null);let pi=class extends ui{constructor(){super(...arguments),this.clickCount=0,this.hold=!1}onClick(t){if(t.stopImmediatePropagation(),this.clickCount++,"none"!=this.renderTemplate(this.config.double_tap_action?.action??"none"))if(this.clickCount>1)this.fireHapticEvent("success"),this.sendAction("double_tap_action"),this.endAction();else{const t="double_tap_window"in(this.config.double_tap_action??{})?this.renderTemplate(this.config.double_tap_action?.double_tap_window):200;this.clickTimer||(this.clickTimer=setTimeout((()=>{this.fireHapticEvent("light"),this.sendAction("tap_action"),this.endAction()}),t))}else this.fireHapticEvent("light"),this.sendAction("tap_action"),this.endAction()}onStart(t){if(this.cancelRippleToggle(),this.swiping=!1,"targetTouches"in t?(this.initialX=t.targetTouches[0].clientX,this.initialY=t.targetTouches[0].clientY):(this.initialX=t.clientX,this.initialY=t.clientY),"none"!=this.renderTemplate(this.config.momentary_start_action?.action??"none"))this.fireHapticEvent("light"),this.buttonPressStart=performance.now(),this.sendAction("momentary_start_action");else if("none"!=this.renderTemplate(this.config.momentary_end_action?.action??"none"))this.fireHapticEvent("light"),this.buttonPressStart=performance.now();else if(!this.holdTimer){const t=this.renderTemplate(this.config.hold_action?.hold_time??500);this.holdTimer=setTimeout((()=>{if(!this.swiping)if(this.hold=!0,"repeat"==this.renderTemplate(this.config.hold_action?.action)){const t=this.renderTemplate(this.config.hold_action?.repeat_delay??100);this.holdInterval||(this.holdInterval=setInterval((()=>{this.fireHapticEvent("selection"),this.sendAction("tap_action")}),t))}else this.fireHapticEvent("medium"),this.sendAction("hold_action")}),t)}}onEnd(t){this.swiping||("none"!=this.renderTemplate(this.config.momentary_end_action?.action??"none")?(this.fireHapticEvent("selection"),this.buttonPressEnd=performance.now(),this.sendAction("momentary_end_action"),this.endAction()):"none"!=this.renderTemplate(this.config.momentary_start_action?.action??"none")?this.endAction():this.hold?(t.stopImmediatePropagation(),t.preventDefault(),this.endAction()):this.onClick(t)),this.toggleRipple()}onMove(t){let e,i;"targetTouches"in t?(e=t.targetTouches[0].clientX,i=t.targetTouches[0].clientY):(e=t.clientX,i=t.clientY);const n=(this.initialX??e)-e,o=(this.initialY??i)-i;Math.abs(Math.abs(n)-Math.abs(o))>24&&(this.endAction(),this.swiping=!0)}onMouseLeave(t){this.endAction(),this.swiping=!0,this.toggleRipple()}onTouchCancel(t){this.endAction(),this.toggleRipple()}endAction(){clearTimeout(this.clickTimer),this.clickTimer=void 0,this.clickCount=0,clearTimeout(this.holdTimer),clearInterval(this.holdInterval),this.holdTimer=void 0,this.holdInterval=void 0,this.hold=!1,super.endAction()}render(){return this.setValue(),U``}static get styles(){return[super.styles,s`:host{align-content:center;text-align:center}button{display:flex;height:inherit;width:inherit;border-radius:var(--size,48px);overflow:visible;cursor:pointer;pointer-events:all;position:relative;opacity:1;padding:0;background:rgb(0,0,0,0);border:none;z-index:1;align-content:center;text-align:center;justify-content:center;align-items:center;--mdc-icon-size:var(--size, 48px)}`]}};pi=function(t,e,i,n){var o,r=arguments.length,s=r<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,i,n);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(s=(r<3?o(s):r>3?o(e,i,s):o(e,i))||s);return r>3&&s&&Object.defineProperty(e,i,s),s}([lt("remote-button")],pi);var di=function(t,e,i,n){var o,r=arguments.length,s=r<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,i,n);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(s=(r<3?o(s):r>3?o(e,i,s):o(e,i))||s);return r>3&&s&&Object.defineProperty(e,i,s),s};let fi=class extends ui{constructor(){super(...arguments),this.showTooltip=!1,this.thumbOffset=0,this.sliderOn=!0,this.currentValue=this.value,this.sliderWidth=0,this.speed=.02,this.range=[0,1],this.step=.01,this.vertical=!1,this.thumbWidth=50,this.resizeObserver=new ResizeObserver((t=>{for(const e of t)this.sliderWidth=this.vertical?e.contentRect.height:e.contentRect.width,this.setThumbOffset()}))}onInput(t){const e=t.currentTarget;if(this.swiping)null==this.value&&(this.getValueFromHass=!0),this.setValue(),this.currentValue=this.value??0,this.setThumbOffset(),this.showTooltip=!1;else{this.getValueFromHass=!1,clearTimeout(this.getValueFromHassTimer),this.value=e.value,this.fireHapticEvent("selection");const t=parseFloat(this.oldValue??this.value??"0"),i=parseFloat(e.value??t);this.newValue=i,this.currentValue=t,this.setThumbOffset(),this.showTooltip=!0,i>this.range[0]&&(this.sliderOn=!0),clearInterval(this.intervalId),this.intervalId=void 0;let n=t;t>i?this.intervalId=setInterval((()=>{n-=this.speed,this.currentValue=n,this.setThumbOffset(),i>=n&&(clearInterval(this.intervalId),this.intervalId=void 0,this.currentValue=i,this.setThumbOffset())}),1):t{n+=this.speed,this.currentValue=n,this.setThumbOffset(),i<=n&&(clearInterval(this.intervalId),this.intervalId=void 0,this.currentValue=i,this.setThumbOffset())}),1)):this.currentValue=i,this.oldValue=i}}onStart(t){const e=t.currentTarget;this.swiping||(this.getValueFromHass=!1,clearTimeout(this.getValueFromHassTimer),this.currentValue=e.value,this.value=e.value,this.setThumbOffset(),this.showTooltip=!0,this.sliderOn=!0)}onEnd(t){this.setThumbOffset(),this.showTooltip=!1,this.setValue(),this.swiping?(this.getValueFromHass=!0,this.setValue(),this.currentValue=this.value??0,this.setThumbOffset(),this.setSliderState(this.currentValue)):(this.newValue||0==this.newValue||(this.newValue=Number(this.value)),this.precision||(this.newValue=Math.trunc(this.newValue)),this.value=this.newValue,this.fireHapticEvent("light"),this.sendAction("tap_action")),this.endAction(),this.resetGetValueFromHass()}onMove(t){if(!this.vertical){let e,i;e="clientX"in t?t.clientX:t.touches[0].clientX,i="clientY"in t?t.clientY:t.touches[0].clientY,null==this.initialY&&(this.initialY=i),null==this.initialX?this.initialX=e:Math.abs(e-this.initialX)this.range[0]}resetGetValueFromHass(){const t=this.renderTemplate(this.config.value_from_hass_delay??1e3);this.getValueFromHassTimer=setTimeout((()=>this.getValueFromHass=!0),t)}endAction(){clearInterval(this.valueUpdateInterval),this.valueUpdateInterval=void 0,super.endAction()}buildBackground(t){const e={};return this.vertical&&(e.transform="rotateZ(270deg)",e.width=this.config.style?.height??`${this.sliderWidth}px`),U`
`}buildTooltip(t){const e=this.buildStyle({"--tooltip-label":`"${this.config?.style?.["--tooltip-label"]??"{{ value }}"}"`,"--tooltip-transform":this.config?.style?.["--tooltip-transform"]??(this.vertical?"translate(-50px, calc(-1 * var(--thumb-offset)))":"translate(var(--thumb-offset), -40px)"),"--tooltip-display":this.config?.style?.["--tooltip-display"]??"initial"},t);return"tooltip"in this.config&&(e["--tooltip-display"]=this.renderTemplate(this.config.tooltip,t)?"initial":"none"),U`
`}buildSlider(t){const e=t.value;this.setSliderState(e);const i={};return"none"==this.renderTemplate(this.config.tap_action?.action,t)&&(i["pointer-events"]="none"),this.vertical&&(i.transform="rotateZ(270deg)",i.width=this.config.style?.height??`${this.sliderWidth}px`),U``}render(){this.setValue(),this.getValueFromHass&&(this.currentValue=this.value);const t={VALUE:this.getValueFromHass?this.value:this.currentValue,value:this.getValueFromHass?this.value:this.currentValue};this.config.range&&(this.range[0]=parseFloat(this.renderTemplate(this.config.range[0],t)),this.range[1]=parseFloat(this.renderTemplate(this.config.range[1],t))),this.speed=(this.range[1]-this.range[0])/50,this.config.step?this.step=Number(this.renderTemplate(this.config.step,t)):this.step=(this.range[1]-this.range[0])/100;const e=this.step.toString().split(".");e.length>1?this.precision=e[1].length:this.precision=0,this.vertical=1==this.renderTemplate(this.config.vertical??!1,t),this.resizeObserver.observe(this.shadowRoot?.querySelector(".container")??this);const i=this.buildStyle(this.config.style??{},t);return this.thumbWidth=parseInt((i["--thumb-width"]??"50").replace("px","")),this.setThumbOffset(),this.style.setProperty("--thumb-offset",`${this.thumbOffset}px`),this.vertical&&(i.width?this.style.setProperty("width",i.width):this.style.width="50px",i.height||(i.height=`${this.sliderWidth}px`)),i["--icon-transform"]||(this.vertical?i["--icon-transform"]="translateY(calc(-1 * var(--thumb-offset)))":i["--icon-transform"]="translateX(var(--thumb-offset))"),U`${this.buildTooltip(t)}
${this.buildBackground(t)}${this.buildSlider(t)} ${this.buildIcon(this.config.icon??"",t)}
`}disconnectedCallback(){super.disconnectedCallback(),this.resizeObserver.disconnect()}static get styles(){return[super.styles,s`:host{display:flex;flex-flow:column;flex-grow:0;place-content:center space-evenly;align-items:center;align-self:stretch;position:relative;height:unset;width:100%;border:none;border-radius:25px;padding:0;box-sizing:border-box;line-height:0;outline:0;overflow:visible;font-size:inherit;color:inherit;pointer-events:none}.container{all:inherit;overflow:hidden;height:50px;align-self:center;color:var(--background,var(--primary-background-color));--color:var(--primary-text-color);--mdc-icon-size:var(--size, 32px)}.background{position:absolute;width:inherit;height:var(--background-height,100%);background:var( +(()=>{var t={767:(t,e,i)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.CONTEXT=void 0;const n=i(178),o=i(662),r=i(109);e.CONTEXT=t=>({True:!0,False:!1,None:null,hass:t,states:e=>(0,n.states)(t,e),is_state:(e,i)=>(0,n.is_state)(t,e,i),state_attr:(e,i)=>(0,n.state_attr)(t,e,i),is_state_attr:(e,i,o)=>(0,n.is_state_attr)(t,e,i,o),has_value:e=>(0,n.has_value)(t,e),iif:(e,i,n,r)=>(0,o.iif)(t,e,i,n,r),match_media:t=>(0,r.match_media)(t)})},865:function(t,e,i){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,i,n){void 0===n&&(n=i);var o=Object.getOwnPropertyDescriptor(e,i);o&&!("get"in o?!e.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return e[i]}}),Object.defineProperty(t,n,o)}:function(t,e,i,n){void 0===n&&(n=i),t[n]=e[i]}),o=this&&this.__exportStar||function(t,e){for(var i in t)"default"===i||Object.prototype.hasOwnProperty.call(e,i)||n(e,t,i)};Object.defineProperty(e,"__esModule",{value:!0}),o(i(537),e)},537:(t,e,i)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.renderTemplate=void 0;const n=i(802),o=i(767);e.renderTemplate=function(t,e,i){if("string"==typeof e&&(e.includes("{{")&&e.includes("}}")||e.includes("{%")&&e.includes("%}"))){if(e=(0,n.renderString)(structuredClone(e),Object.assign(Object.assign({},(0,o.CONTEXT)(t)),i)).trim(),[void 0,null,"undefined","null","None"].includes(e))return"";if("true"==e.toLowerCase())return!0;if("false"==e.toLowerCase())return!1}return e}},109:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.match_media=void 0,e.match_media=function(t){return window.matchMedia(t).matches}},662:(t,e,i)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.iif=void 0;const n=i(865);e.iif=function(t,e,i,o,r){if(r){const i=(0,n.renderTemplate)(t,e);if([void 0,null,"undefined","null","None"].includes(i))return r}const s=`\n\t\t{% if ${e} %}\n\t\t${null==i||i}\n\t\t{% else %}\n\t\t${null!=o&&o}\n\t\t{% endif %}\n\t`;return(0,n.renderTemplate)(t,s)}},178:(t,e)=>{"use strict";function i(t,e){try{return t.states[e].state}catch(t){return}}function n(t,e,i){try{return t.states[e].attributes[i]}catch(t){return}}Object.defineProperty(e,"__esModule",{value:!0}),e.has_value=e.is_state_attr=e.state_attr=e.is_state=e.states=void 0,e.states=i,e.is_state=function(t,e,n){try{const o=i(t,e);return Array.isArray(n)?n.includes(o):o==n}catch(t){return!1}},e.state_attr=n,e.is_state_attr=function(t,e,i,o){try{const r=n(t,e,i);return Array.isArray(o)?o.includes(r):r==o}catch(t){return!1}},e.has_value=function(t,e){try{const n=i(t,e);return!![!1,0,-0,""].includes(n)||Boolean(n)}catch(t){return!1}}},802:function(t){var e;"undefined"!=typeof self&&self,e=function(){return function(t){var e={};function i(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,i),o.l=!0,o.exports}return i.m=t,i.c=e,i.d=function(t,e,n){i.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:n})},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="",i(i.s=11)}([function(t,e,i){"use strict";var n=Array.prototype,o=Object.prototype,r={"&":"&",'"':""","'":"'","<":"<",">":">","\\":"\"},s=/[&"'<>\\]/g;function a(t,e){return o.hasOwnProperty.call(t,e)}function c(t){return r[t]}function l(t,e,i){var n,o,r;if(t instanceof Error&&(t=(o=t).name+": "+o.message),Object.setPrototypeOf?(n=new Error(t),Object.setPrototypeOf(n,l.prototype)):(n=this,Object.defineProperty(n,"message",{enumerable:!1,writable:!0,value:t})),Object.defineProperty(n,"name",{value:"Template render error"}),Error.captureStackTrace&&Error.captureStackTrace(n,this.constructor),o){var s=Object.getOwnPropertyDescriptor(o,"stack");(r=s&&(s.get||function(){return s.value}))||(r=function(){return o.stack})}else{var a=new Error(t).stack;r=function(){return a}}return Object.defineProperty(n,"stack",{get:function(){return r.call(n)}}),Object.defineProperty(n,"cause",{value:o}),n.lineno=e,n.colno=i,n.firstUpdate=!0,n.Update=function(t){var e="("+(t||"unknown path")+")";return this.firstUpdate&&(this.lineno&&this.colno?e+=" [Line "+this.lineno+", Column "+this.colno+"]":this.lineno&&(e+=" [Line "+this.lineno+"]")),e+="\n ",this.firstUpdate&&(e+=" "),this.message=e+(this.message||""),this.firstUpdate=!1,this},n}function h(t){return"[object Function]"===o.toString.call(t)}function u(t){return"[object Array]"===o.toString.call(t)}function p(t){return"[object String]"===o.toString.call(t)}function d(t){return"[object Object]"===o.toString.call(t)}function f(t){var e,i=(e=t)?"string"==typeof e?e.split("."):[e]:[];return function(t){for(var e=t,n=0;nt.length)s=o.slice(0,t.length),o.slice(s.length,l).forEach((function(t,i){i2?o-2:0),s=2;s0||!i)&&process.stdout.write(" ".repeat(e));var r=o===n.length-1?"":"\n";process.stdout.write(""+t+r)}))}t.exports={Node:c,Root:u,NodeList:h,Value:l,Literal:p,Symbol:d,Group:f,Array:m,Pair:v,Dict:y,Output:D,Capture:V,TemplateData:H,If:g,IfAsync:b,InlineIf:C,For:k,AsyncEach:L,AsyncAll:w,Macro:x,Caller:A,Import:E,FromImport:T,FunCall:O,Filter:S,FilterAsync:M,KeywordArgs:I,Block:N,Super:$,Extends:R,Include:P,Set:j,Switch:F,Case:B,LookupVal:_,BinOp:U,In:Z,Is:z,Or:W,And:Y,Not:G,Add:q,Concat:X,Sub:J,Mul:Q,Div:tt,FloorDiv:et,Mod:it,Pow:nt,Neg:ot,Pos:rt,Compare:st,CompareOperand:at,CallExtension:ct,CallExtensionAsync:lt,printNodes:function t(e,i){if(i=i||0,ht(e.typename+": ",i),e instanceof h)ht("\n"),e.children.forEach((function(e){t(e,i+2)}));else if(e instanceof ct)ht(e.extName+"."+e.prop+"\n"),e.args&&t(e.args,i+2),e.contentArgs&&e.contentArgs.forEach((function(e){t(e,i+2)}));else{var n=[],o=null;e.iterFields((function(t,e){t instanceof c?n.push([e,t]):(o=o||{})[e]=t})),o?ht(JSON.stringify(o,null,2)+"\n",null,!0):ht("\n"),n.forEach((function(e){var n=e[0],o=e[1];ht("["+n+"] =>",i+2),t(o,i+4)}))}}}},function(t,e){},function(t,e,i){"use strict";function n(t,e){return n=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},n(t,e)}var o=i(8),r=i(17),s=i(3),a=i(0).TemplateError,c=i(2).Frame,l=i(1).Obj,h={"==":"==","===":"===","!=":"!=","!==":"!==","<":"<",">":">","<=":"<=",">=":">="},u=function(t){var e,i;function o(){return t.apply(this,arguments)||this}i=t,(e=o).prototype=Object.create(i.prototype),e.prototype.constructor=e,n(e,i);var r=o.prototype;return r.init=function(t,e){this.templateName=t,this.codebuf=[],this.lastId=0,this.buffer=null,this.bufferStack=[],this._scopeClosers="",this.inBlock=!1,this.throwOnUndefined=e},r.fail=function(t,e,i){throw void 0!==e&&(e+=1),void 0!==i&&(i+=1),new a(t,e,i)},r._pushBuffer=function(){var t=this._tmpid();return this.bufferStack.push(this.buffer),this.buffer=t,this._emit("var "+this.buffer+' = "";'),t},r._popBuffer=function(){this.buffer=this.bufferStack.pop()},r._emit=function(t){this.codebuf.push(t)},r._emitLine=function(t){this._emit(t+"\n")},r._emitLines=function(){for(var t=this,e=arguments.length,i=new Array(e),n=0;n0&&o._emit(","),o.compile(t,e)})),n&&this._emit(n)},r._compileExpression=function(t,e){this.assertType(t,s.Literal,s.Symbol,s.Group,s.Array,s.Dict,s.FunCall,s.Caller,s.Filter,s.LookupVal,s.Compare,s.InlineIf,s.In,s.Is,s.And,s.Or,s.Not,s.Add,s.Concat,s.Sub,s.Mul,s.Div,s.FloorDiv,s.Mod,s.Pow,s.Neg,s.Pos,s.Compare,s.NodeList),this.compile(t,e)},r.assertType=function(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),n=1;n0&&n._emit(","),t){n._emitLine("function(cb) {"),n._emitLine("if(!cb) { cb = function(err) { if(err) { throw err; }}}");var o=n._pushBuffer();n._withScopedSyntax((function(){n.compile(t,e),n._emitLine("cb(null, "+o+");")})),n._popBuffer(),n._emitLine("return "+o+";"),n._emitLine("}")}else n._emit("null")})),i){var c=this._tmpid();this._emitLine(", "+this._makeCallback(c)),this._emitLine(this.buffer+" += runtime.suppressValue("+c+", "+a+" && env.opts.autoescape);"),this._addScopeLevel()}else this._emit(")"),this._emit(", "+a+" && env.opts.autoescape);\n")},r.compileCallExtensionAsync=function(t,e){this.compileCallExtension(t,e,!0)},r.compileNodeList=function(t,e){this._compileChildren(t,e)},r.compileLiteral=function(t){if("string"==typeof t.value){var e=t.value.replace(/\\/g,"\\\\");e=(e=(e=(e=(e=e.replace(/"/g,'\\"')).replace(/\n/g,"\\n")).replace(/\r/g,"\\r")).replace(/\t/g,"\\t")).replace(/\u2028/g,"\\u2028"),this._emit('"'+e+'"')}else null===t.value?this._emit("null"):this._emit(t.value.toString())},r.compileSymbol=function(t,e){var i=t.value,n=e.lookup(i);n?this._emit(n):this._emit('runtime.contextOrFrameLookup(context, frame, "'+i+'")')},r.compileGroup=function(t,e){this._compileAggregate(t,e,"(",")")},r.compileArray=function(t,e){this._compileAggregate(t,e,"[","]")},r.compileDict=function(t,e){this._compileAggregate(t,e,"{","}")},r.compilePair=function(t,e){var i=t.key,n=t.value;i instanceof s.Symbol?i=new s.Literal(i.lineno,i.colno,i.value):i instanceof s.Literal&&"string"==typeof i.value||this.fail("compilePair: Dict keys must be strings or names",i.lineno,i.colno),this.compile(i,e),this._emit(": "),this._compileExpression(n,e)},r.compileInlineIf=function(t,e){this._emit("("),this.compile(t.cond,e),this._emit("?"),this.compile(t.body,e),this._emit(":"),null!==t.else_?this.compile(t.else_,e):this._emit('""'),this._emit(")")},r.compileIn=function(t,e){this._emit("runtime.inOperator("),this.compile(t.left,e),this._emit(","),this.compile(t.right,e),this._emit(")")},r.compileIs=function(t,e){var i=t.right.name?t.right.name.value:t.right.value;this._emit('env.getTest("'+i+'").call(context, '),this.compile(t.left,e),t.right.args&&(this._emit(","),this.compile(t.right.args,e)),this._emit(") === true")},r._binOpEmitter=function(t,e,i){this.compile(t.left,e),this._emit(i),this.compile(t.right,e)},r.compileOr=function(t,e){return this._binOpEmitter(t,e," || ")},r.compileAnd=function(t,e){return this._binOpEmitter(t,e," && ")},r.compileAdd=function(t,e){return this._binOpEmitter(t,e," + ")},r.compileConcat=function(t,e){return this._binOpEmitter(t,e,' + "" + ')},r.compileSub=function(t,e){return this._binOpEmitter(t,e," - ")},r.compileMul=function(t,e){return this._binOpEmitter(t,e," * ")},r.compileDiv=function(t,e){return this._binOpEmitter(t,e," / ")},r.compileMod=function(t,e){return this._binOpEmitter(t,e," % ")},r.compileNot=function(t,e){this._emit("!"),this.compile(t.target,e)},r.compileFloorDiv=function(t,e){this._emit("Math.floor("),this.compile(t.left,e),this._emit(" / "),this.compile(t.right,e),this._emit(")")},r.compilePow=function(t,e){this._emit("Math.pow("),this.compile(t.left,e),this._emit(", "),this.compile(t.right,e),this._emit(")")},r.compileNeg=function(t,e){this._emit("-"),this.compile(t.target,e)},r.compilePos=function(t,e){this._emit("+"),this.compile(t.target,e)},r.compileCompare=function(t,e){var i=this;this.compile(t.expr,e),t.ops.forEach((function(t){i._emit(" "+h[t.type]+" "),i.compile(t.expr,e)}))},r.compileLookupVal=function(t,e){this._emit("runtime.memberLookup(("),this._compileExpression(t.target,e),this._emit("),"),this._compileExpression(t.val,e),this._emit(")")},r._getNodeName=function(t){switch(t.typename){case"Symbol":return t.value;case"FunCall":return"the return value of ("+this._getNodeName(t.name)+")";case"LookupVal":return this._getNodeName(t.target)+'["'+this._getNodeName(t.val)+'"]';case"Literal":return t.value.toString();default:return"--expression--"}},r.compileFunCall=function(t,e){this._emit("(lineno = "+t.lineno+", colno = "+t.colno+", "),this._emit("runtime.callWrap("),this._compileExpression(t.name,e),this._emit(', "'+this._getNodeName(t.name).replace(/"/g,'\\"')+'", context, '),this._compileAggregate(t.args,e,"[","])"),this._emit(")")},r.compileFilter=function(t,e){var i=t.name;this.assertType(i,s.Symbol),this._emit('env.getFilter("'+i.value+'").call(context, '),this._compileAggregate(t.args,e),this._emit(")")},r.compileFilterAsync=function(t,e){var i=t.name,n=t.symbol.value;this.assertType(i,s.Symbol),e.set(n,n),this._emit('env.getFilter("'+i.value+'").call(context, '),this._compileAggregate(t.args,e),this._emitLine(", "+this._makeCallback(n)),this._addScopeLevel()},r.compileKeywordArgs=function(t,e){this._emit("runtime.makeKeywordArgs("),this.compileDict(t,e),this._emit(")")},r.compileSet=function(t,e){var i=this,n=[];t.targets.forEach((function(t){var o=t.value,r=e.lookup(o);null==r&&(r=i._tmpid(),i._emitLine("var "+r+";")),n.push(r)})),t.value?(this._emit(n.join(" = ")+" = "),this._compileExpression(t.value,e),this._emitLine(";")):(this._emit(n.join(" = ")+" = "),this.compile(t.body,e),this._emitLine(";")),t.targets.forEach((function(t,e){var o=n[e],r=t.value;i._emitLine('frame.set("'+r+'", '+o+", true);"),i._emitLine("if(frame.topLevel) {"),i._emitLine('context.setVariable("'+r+'", '+o+");"),i._emitLine("}"),"_"!==r.charAt(0)&&(i._emitLine("if(frame.topLevel) {"),i._emitLine('context.addExport("'+r+'", '+o+");"),i._emitLine("}"))}))},r.compileSwitch=function(t,e){var i=this;this._emit("switch ("),this.compile(t.expr,e),this._emit(") {"),t.cases.forEach((function(t,n){i._emit("case "),i.compile(t.cond,e),i._emit(": "),i.compile(t.body,e),t.body.children.length&&i._emitLine("break;")})),t.default&&(this._emit("default:"),this.compile(t.default,e)),this._emit("}")},r.compileIf=function(t,e,i){var n=this;this._emit("if("),this._compileExpression(t.cond,e),this._emitLine(") {"),this._withScopedSyntax((function(){n.compile(t.body,e),i&&n._emit("cb()")})),t.else_?(this._emitLine("}\nelse {"),this._withScopedSyntax((function(){n.compile(t.else_,e),i&&n._emit("cb()")}))):i&&(this._emitLine("}\nelse {"),this._emit("cb()")),this._emitLine("}")},r.compileIfAsync=function(t,e){this._emit("(function(cb) {"),this.compileIf(t,e,!0),this._emit("})("+this._makeCallback()),this._addScopeLevel()},r._emitLoopBindings=function(t,e,i,n){var o=this;[{name:"index",val:i+" + 1"},{name:"index0",val:i},{name:"revindex",val:n+" - "+i},{name:"revindex0",val:n+" - "+i+" - 1"},{name:"first",val:i+" === 0"},{name:"last",val:i+" === "+n+" - 1"},{name:"length",val:n}].forEach((function(t){o._emitLine('frame.set("loop.'+t.name+'", '+t.val+");")}))},r.compileFor=function(t,e){var i=this,n=this._tmpid(),o=this._tmpid(),r=this._tmpid();if(e=e.push(),this._emitLine("frame = frame.push();"),this._emit("var "+r+" = "),this._compileExpression(t.arr,e),this._emitLine(";"),this._emit("if("+r+") {"),this._emitLine(r+" = runtime.fromIterator("+r+");"),t.name instanceof s.Array){this._emitLine("var "+n+";"),this._emitLine("if(runtime.isArray("+r+")) {"),this._emitLine("var "+o+" = "+r+".length;"),this._emitLine("for("+n+"=0; "+n+" < "+r+".length; "+n+"++) {"),t.name.children.forEach((function(o,s){var a=i._tmpid();i._emitLine("var "+a+" = "+r+"["+n+"]["+s+"];"),i._emitLine('frame.set("'+o+'", '+r+"["+n+"]["+s+"]);"),e.set(t.name.children[s].value,a)})),this._emitLoopBindings(t,r,n,o),this._withScopedSyntax((function(){i.compile(t.body,e)})),this._emitLine("}"),this._emitLine("} else {");var a=t.name.children,c=a[0],l=a[1],h=this._tmpid(),u=this._tmpid();e.set(c.value,h),e.set(l.value,u),this._emitLine(n+" = -1;"),this._emitLine("var "+o+" = runtime.keys("+r+").length;"),this._emitLine("for(var "+h+" in "+r+") {"),this._emitLine(n+"++;"),this._emitLine("var "+u+" = "+r+"["+h+"];"),this._emitLine('frame.set("'+c.value+'", '+h+");"),this._emitLine('frame.set("'+l.value+'", '+u+");"),this._emitLoopBindings(t,r,n,o),this._withScopedSyntax((function(){i.compile(t.body,e)})),this._emitLine("}"),this._emitLine("}")}else{var p=this._tmpid();e.set(t.name.value,p),this._emitLine("var "+o+" = "+r+".length;"),this._emitLine("for(var "+n+"=0; "+n+" < "+r+".length; "+n+"++) {"),this._emitLine("var "+p+" = "+r+"["+n+"];"),this._emitLine('frame.set("'+t.name.value+'", '+p+");"),this._emitLoopBindings(t,r,n,o),this._withScopedSyntax((function(){i.compile(t.body,e)})),this._emitLine("}")}this._emitLine("}"),t.else_&&(this._emitLine("if (!"+o+") {"),this.compile(t.else_,e),this._emitLine("}")),this._emitLine("frame = frame.pop();")},r._compileAsyncLoop=function(t,e,i){var n=this,o=this._tmpid(),r=this._tmpid(),a=this._tmpid(),c=i?"asyncAll":"asyncEach";if(e=e.push(),this._emitLine("frame = frame.push();"),this._emit("var "+a+" = runtime.fromIterator("),this._compileExpression(t.arr,e),this._emitLine(");"),t.name instanceof s.Array){var l=t.name.children.length;this._emit("runtime."+c+"("+a+", "+l+", function("),t.name.children.forEach((function(t){n._emit(t.value+",")})),this._emit(o+","+r+",next) {"),t.name.children.forEach((function(t){var i=t.value;e.set(i,i),n._emitLine('frame.set("'+i+'", '+i+");")}))}else{var h=t.name.value;this._emitLine("runtime."+c+"("+a+", 1, function("+h+", "+o+", "+r+",next) {"),this._emitLine('frame.set("'+h+'", '+h+");"),e.set(h,h)}this._emitLoopBindings(t,a,o,r),this._withScopedSyntax((function(){var r;i&&(r=n._pushBuffer()),n.compile(t.body,e),n._emitLine("next("+o+(r?","+r:"")+");"),i&&n._popBuffer()}));var u=this._tmpid();this._emitLine("}, "+this._makeCallback(u)),this._addScopeLevel(),i&&this._emitLine(this.buffer+" += "+u+";"),t.else_&&(this._emitLine("if (!"+a+".length) {"),this.compile(t.else_,e),this._emitLine("}")),this._emitLine("frame = frame.pop();")},r.compileAsyncEach=function(t,e){this._compileAsyncLoop(t,e)},r.compileAsyncAll=function(t,e){this._compileAsyncLoop(t,e,!0)},r._compileMacro=function(t,e){var i=this,n=[],o=null,r="macro_"+this._tmpid(),a=void 0!==e;t.args.children.forEach((function(e,r){r===t.args.children.length-1&&e instanceof s.Dict?o=e:(i.assertType(e,s.Symbol),n.push(e))}));var l,h=[].concat(n.map((function(t){return"l_"+t.value})),["kwargs"]),u=n.map((function(t){return'"'+t.value+'"'})),p=(o&&o.children||[]).map((function(t){return'"'+t.key.value+'"'}));l=a?e.push(!0):new c,this._emitLines("var "+r+" = runtime.makeMacro(","["+u.join(", ")+"], ","["+p.join(", ")+"], ","function ("+h.join(", ")+") {","var callerFrame = frame;","frame = "+(a?"frame.push(true);":"new runtime.Frame();"),"kwargs = kwargs || {};",'if (Object.prototype.hasOwnProperty.call(kwargs, "caller")) {','frame.set("caller", kwargs.caller); }'),n.forEach((function(t){i._emitLine('frame.set("'+t.value+'", l_'+t.value+");"),l.set(t.value,"l_"+t.value)})),o&&o.children.forEach((function(t){var e=t.key.value;i._emit('frame.set("'+e+'", '),i._emit('Object.prototype.hasOwnProperty.call(kwargs, "'+e+'")'),i._emit(' ? kwargs["'+e+'"] : '),i._compileExpression(t.value,l),i._emit(");")}));var d=this._pushBuffer();return this._withScopedSyntax((function(){i.compile(t.body,l)})),this._emitLine("frame = "+(a?"frame.pop();":"callerFrame;")),this._emitLine("return new runtime.SafeString("+d+");"),this._emitLine("});"),this._popBuffer(),r},r.compileMacro=function(t,e){var i=this._compileMacro(t),n=t.name.value;e.set(n,i),e.parent?this._emitLine('frame.set("'+n+'", '+i+");"):("_"!==t.name.value.charAt(0)&&this._emitLine('context.addExport("'+n+'");'),this._emitLine('context.setVariable("'+n+'", '+i+");"))},r.compileCaller=function(t,e){this._emit("(function (){");var i=this._compileMacro(t,e);this._emit("return "+i+";})()")},r._compileGetTemplate=function(t,e,i,n){var o=this._tmpid(),r=this._templateName(),s=this._makeCallback(o),a=i?"true":"false",c=n?"true":"false";return this._emit("env.getTemplate("),this._compileExpression(t.template,e),this._emitLine(", "+a+", "+r+", "+c+", "+s),o},r.compileImport=function(t,e){var i=t.target.value,n=this._compileGetTemplate(t,e,!1,!1);this._addScopeLevel(),this._emitLine(n+".getExported("+(t.withContext?"context.getVariables(), frame, ":"")+this._makeCallback(n)),this._addScopeLevel(),e.set(i,n),e.parent?this._emitLine('frame.set("'+i+'", '+n+");"):this._emitLine('context.setVariable("'+i+'", '+n+");")},r.compileFromImport=function(t,e){var i=this,n=this._compileGetTemplate(t,e,!1,!1);this._addScopeLevel(),this._emitLine(n+".getExported("+(t.withContext?"context.getVariables(), frame, ":"")+this._makeCallback(n)),this._addScopeLevel(),t.names.children.forEach((function(t){var o,r,a=i._tmpid();t instanceof s.Pair?(o=t.key.value,r=t.value.value):r=o=t.value,i._emitLine("if(Object.prototype.hasOwnProperty.call("+n+', "'+o+'")) {'),i._emitLine("var "+a+" = "+n+"."+o+";"),i._emitLine("} else {"),i._emitLine("cb(new Error(\"cannot import '"+o+"'\")); return;"),i._emitLine("}"),e.set(r,a),e.parent?i._emitLine('frame.set("'+r+'", '+a+");"):i._emitLine('context.setVariable("'+r+'", '+a+");")}))},r.compileBlock=function(t){var e=this._tmpid();this.inBlock||this._emit('(parentTemplate ? function(e, c, f, r, cb) { cb(""); } : '),this._emit('context.getBlock("'+t.name.value+'")'),this.inBlock||this._emit(")"),this._emitLine("(env, context, frame, runtime, "+this._makeCallback(e)),this._emitLine(this.buffer+" += "+e+";"),this._addScopeLevel()},r.compileSuper=function(t,e){var i=t.blockName.value,n=t.symbol.value,o=this._makeCallback(n);this._emitLine('context.getSuper(env, "'+i+'", b_'+i+", frame, runtime, "+o),this._emitLine(n+" = runtime.markSafe("+n+");"),this._addScopeLevel(),e.set(n,n)},r.compileExtends=function(t,e){var i=this._tmpid(),n=this._compileGetTemplate(t,e,!0,!1);this._emitLine("parentTemplate = "+n),this._emitLine("for(var "+i+" in parentTemplate.blocks) {"),this._emitLine("context.addBlock("+i+", parentTemplate.blocks["+i+"]);"),this._emitLine("}"),this._addScopeLevel()},r.compileInclude=function(t,e){this._emitLine("var tasks = [];"),this._emitLine("tasks.push("),this._emitLine("function(callback) {");var i=this._compileGetTemplate(t,e,!1,t.ignoreMissing);this._emitLine("callback(null,"+i+");});"),this._emitLine("});");var n=this._tmpid();this._emitLine("tasks.push("),this._emitLine("function(template, callback){"),this._emitLine("template.render(context.getVariables(), frame, "+this._makeCallback(n)),this._emitLine("callback(null,"+n+");});"),this._emitLine("});"),this._emitLine("tasks.push("),this._emitLine("function(result, callback){"),this._emitLine(this.buffer+" += result;"),this._emitLine("callback(null);"),this._emitLine("});"),this._emitLine("env.waterfall(tasks, function(){"),this._addScopeLevel()},r.compileTemplateData=function(t,e){this.compileLiteral(t,e)},r.compileCapture=function(t,e){var i=this,n=this.buffer;this.buffer="output",this._emitLine("(function() {"),this._emitLine('var output = "";'),this._withScopedSyntax((function(){i.compile(t.body,e)})),this._emitLine("return output;"),this._emitLine("})()"),this.buffer=n},r.compileOutput=function(t,e){var i=this;t.children.forEach((function(n){n instanceof s.TemplateData?n.value&&(i._emit(i.buffer+" += "),i.compileLiteral(n,e),i._emitLine(";")):(i._emit(i.buffer+" += runtime.suppressValue("),i.throwOnUndefined&&i._emit("runtime.ensureDefined("),i.compile(n,e),i.throwOnUndefined&&i._emit(","+t.lineno+","+t.colno+")"),i._emit(", env.opts.autoescape);\n"))}))},r.compileRoot=function(t,e){var i=this;e&&this.fail("compileRoot: root node can't have frame"),e=new c,this._emitFuncBegin(t,"root"),this._emitLine("var parentTemplate = null;"),this._compileChildren(t,e),this._emitLine("if(parentTemplate) {"),this._emitLine("parentTemplate.rootRenderFunc(env, context, frame, runtime, cb);"),this._emitLine("} else {"),this._emitLine("cb(null, "+this.buffer+");"),this._emitLine("}"),this._emitFuncEnd(!0),this.inBlock=!0;var n=[],o=t.findAll(s.Block);o.forEach((function(t,e){var o=t.name.value;if(-1!==n.indexOf(o))throw new Error('Block "'+o+'" defined more than once.');n.push(o),i._emitFuncBegin(t,"b_"+o);var r=new c;i._emitLine("var frame = frame.push(true);"),i.compile(t.body,r),i._emitFuncEnd()})),this._emitLine("return {"),o.forEach((function(t,e){var n="b_"+t.name.value;i._emitLine(n+": "+n+",")})),this._emitLine("root: root\n};")},r.compile=function(t,e){var i=this["compile"+t.typename];i?i.call(this,t,e):this.fail("compile: Cannot compile node: "+t.typename,t.lineno,t.colno)},r.getCode=function(){return this.codebuf.join("")},o}(l);t.exports={compile:function(t,e,i,n,s){void 0===s&&(s={});var a=new u(n,s.throwOnUndefined),c=(i||[]).map((function(t){return t.preprocess})).filter((function(t){return!!t})).reduce((function(t,e){return e(t)}),t);return a.compile(r.transform(o.parse(c,i,s),e,n)),a.getCode()},Compiler:u}},function(t,e,i){"use strict";function n(t,e){return n=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},n(t,e)}var o=i(4),r=i(1).EmitterObj;t.exports=function(t){var e,i;function r(){return t.apply(this,arguments)||this}i=t,(e=r).prototype=Object.create(i.prototype),e.prototype.constructor=e,n(e,i);var s=r.prototype;return s.resolve=function(t,e){return o.resolve(o.dirname(t),e)},s.isRelative=function(t){return 0===t.indexOf("./")||0===t.indexOf("../")},r}(r)},function(t,e,i){"use strict";function n(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,o(t,e)}function o(t,e){return o=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},o(t,e)}var r=i(12),s=i(15),a=i(0),c=i(5),l=i(18),h=i(10),u=h.FileSystemLoader,p=h.WebLoader,d=h.PrecompiledLoader,f=i(20),m=i(21),v=i(1),y=v.Obj,_=v.EmitterObj,g=i(2),b=g.handleError,C=g.Frame,k=i(22);function L(t,e,i){r((function(){t(e,i)}))}var w={type:"code",obj:{root:function(t,e,i,n,o){try{o(null,"")}catch(t){o(b(t,null,null))}}}},x=function(t){function e(){return t.apply(this,arguments)||this}n(e,t);var i=e.prototype;return i.init=function(t,e){var i=this;e=this.opts=e||{},this.opts.dev=!!e.dev,this.opts.autoescape=null==e.autoescape||e.autoescape,this.opts.throwOnUndefined=!!e.throwOnUndefined,this.opts.trimBlocks=!!e.trimBlocks,this.opts.lstripBlocks=!!e.lstripBlocks,this.loaders=[],t?this.loaders=a.isArray(t)?t:[t]:u?this.loaders=[new u("views")]:p&&(this.loaders=[new p("/views")]),"undefined"!=typeof window&&window.nunjucksPrecompiled&&this.loaders.unshift(new d(window.nunjucksPrecompiled)),this._initLoaders(),this.globals=m(),this.filters={},this.tests={},this.asyncFilters=[],this.extensions={},this.extensionsList=[],a._entries(l).forEach((function(t){var e=t[0],n=t[1];return i.addFilter(e,n)})),a._entries(f).forEach((function(t){var e=t[0],n=t[1];return i.addTest(e,n)}))},i._initLoaders=function(){var t=this;this.loaders.forEach((function(e){e.cache={},"function"==typeof e.on&&(e.on("update",(function(i,n){e.cache[i]=null,t.emit("update",i,n,e)})),e.on("load",(function(i,n){t.emit("load",i,n,e)})))}))},i.invalidateCache=function(){this.loaders.forEach((function(t){t.cache={}}))},i.addExtension=function(t,e){return e.__name=t,this.extensions[t]=e,this.extensionsList.push(e),this},i.removeExtension=function(t){var e=this.getExtension(t);e&&(this.extensionsList=a.without(this.extensionsList,e),delete this.extensions[t])},i.getExtension=function(t){return this.extensions[t]},i.hasExtension=function(t){return!!this.extensions[t]},i.addGlobal=function(t,e){return this.globals[t]=e,this},i.getGlobal=function(t){if(void 0===this.globals[t])throw new Error("global not found: "+t);return this.globals[t]},i.addFilter=function(t,e,i){var n=e;return i&&this.asyncFilters.push(t),this.filters[t]=n,this},i.getFilter=function(t){if(!this.filters[t])throw new Error("filter not found: "+t);return this.filters[t]},i.addTest=function(t,e){return this.tests[t]=e,this},i.getTest=function(t){if(!this.tests[t])throw new Error("test not found: "+t);return this.tests[t]},i.resolveTemplate=function(t,e,i){return t.isRelative&&e&&t.isRelative(i)&&t.resolve?t.resolve(e,i):i},i.getTemplate=function(t,e,i,n,o){var r,s=this,c=this,l=null;if(t&&t.raw&&(t=t.raw),a.isFunction(i)&&(o=i,i=null,e=e||!1),a.isFunction(e)&&(o=e,e=!1),t instanceof E)l=t;else{if("string"!=typeof t)throw new Error("template names must be a string: "+t);for(var h=0;h0&&!this.skip(o.TOKEN_COMMA)&&this.fail("parseFrom: expected comma",t.lineno,t.colno);var a=this.parsePrimary();if("_"===a.value.charAt(0)&&this.fail("parseFrom: names starting with an underscore cannot be imported",a.lineno,a.colno),this.skipSymbol("as")){var c=this.parsePrimary();n.addChild(new r.Pair(a.lineno,a.colno,a,c))}else n.addChild(a);i=this.parseWithContext()}return new r.FromImport(t.lineno,t.colno,e,n,i)},c.parseBlock=function(){var t=this.peekToken();this.skipSymbol("block")||this.fail("parseBlock: expected block",t.lineno,t.colno);var e=new r.Block(t.lineno,t.colno);e.name=this.parsePrimary(),e.name instanceof r.Symbol||this.fail("parseBlock: variable name expected",t.lineno,t.colno),this.advanceAfterBlockEnd(t.value),e.body=this.parseUntilBlocks("endblock"),this.skipSymbol("endblock"),this.skipSymbol(e.name.value);var i=this.peekToken();return i||this.fail("parseBlock: expected endblock, got end of file"),this.advanceAfterBlockEnd(i.value),e},c.parseExtends=function(){var t="extends",e=this.peekToken();this.skipSymbol(t)||this.fail("parseTemplateRef: expected "+t);var i=new r.Extends(e.lineno,e.colno);return i.template=this.parseExpression(),this.advanceAfterBlockEnd(e.value),i},c.parseInclude=function(){var t="include",e=this.peekToken();this.skipSymbol(t)||this.fail("parseInclude: expected "+t);var i=new r.Include(e.lineno,e.colno);return i.template=this.parseExpression(),this.skipSymbol("ignore")&&this.skipSymbol("missing")&&(i.ignoreMissing=!0),this.advanceAfterBlockEnd(e.value),i},c.parseIf=function(){var t,e=this.peekToken();this.skipSymbol("if")||this.skipSymbol("elif")||this.skipSymbol("elseif")?t=new r.If(e.lineno,e.colno):this.skipSymbol("ifAsync")?t=new r.IfAsync(e.lineno,e.colno):this.fail("parseIf: expected if, elif, or elseif",e.lineno,e.colno),t.cond=this.parseExpression(),this.advanceAfterBlockEnd(e.value),t.body=this.parseUntilBlocks("elif","elseif","else","endif");var i=this.peekToken();switch(i&&i.value){case"elseif":case"elif":t.else_=this.parseIf();break;case"else":this.advanceAfterBlockEnd(),t.else_=this.parseUntilBlocks("endif"),this.advanceAfterBlockEnd();break;case"endif":t.else_=null,this.advanceAfterBlockEnd();break;default:this.fail("parseIf: expected elif, else, or endif, got end of file")}return t},c.parseSet=function(){var t=this.peekToken();this.skipSymbol("set")||this.fail("parseSet: expected set",t.lineno,t.colno);for(var e,i=new r.Set(t.lineno,t.colno,[]);(e=this.parsePrimary())&&(i.targets.push(e),this.skip(o.TOKEN_COMMA)););return this.skipValue(o.TOKEN_OPERATOR,"=")?(i.value=this.parseExpression(),this.advanceAfterBlockEnd(t.value)):this.skip(o.TOKEN_BLOCK_END)?(i.body=new r.Capture(t.lineno,t.colno,this.parseUntilBlocks("endset")),i.value=null,this.advanceAfterBlockEnd()):this.fail("parseSet: expected = or block end in set tag",t.lineno,t.colno),i},c.parseSwitch=function(){var t="switch",e="endswitch",i="case",n="default",o=this.peekToken();this.skipSymbol(t)||this.skipSymbol(i)||this.skipSymbol(n)||this.fail('parseSwitch: expected "switch," "case" or "default"',o.lineno,o.colno);var s=this.parseExpression();this.advanceAfterBlockEnd(t),this.parseUntilBlocks(i,n,e);var a,c=this.peekToken(),l=[];do{this.skipSymbol(i);var h=this.parseExpression();this.advanceAfterBlockEnd(t);var u=this.parseUntilBlocks(i,n,e);l.push(new r.Case(c.line,c.col,h,u)),c=this.peekToken()}while(c&&c.value===i);switch(c.value){case n:this.advanceAfterBlockEnd(),a=this.parseUntilBlocks(e),this.advanceAfterBlockEnd();break;case e:this.advanceAfterBlockEnd();break;default:this.fail('parseSwitch: expected "case," "default" or "endswitch," got EOF.')}return new r.Switch(o.lineno,o.colno,s,l,a)},c.parseStatement=function(){var t=this.peekToken();if(t.type!==o.TOKEN_SYMBOL&&this.fail("tag name expected",t.lineno,t.colno),this.breakOnBlocks&&-1!==a.indexOf(this.breakOnBlocks,t.value))return null;switch(t.value){case"raw":return this.parseRaw();case"verbatim":return this.parseRaw("verbatim");case"if":case"ifAsync":return this.parseIf();case"for":case"asyncEach":case"asyncAll":return this.parseFor();case"block":return this.parseBlock();case"extends":return this.parseExtends();case"include":return this.parseInclude();case"set":return this.parseSet();case"macro":return this.parseMacro();case"call":return this.parseCall();case"import":return this.parseImport();case"from":return this.parseFrom();case"filter":return this.parseFilterStatement();case"switch":return this.parseSwitch();default:if(this.extensions.length)for(var e=0;e0;){var c=s[0],l=s[1],h=s[2];h===t?n+=1:h===e&&(n-=1),0===n?(o+=l,this.tokens.backN(c.length-l.length)):o+=c}return new r.Output(a.lineno,a.colno,[new r.TemplateData(a.lineno,a.colno,o)])},c.parsePostfix=function(t){for(var e,i=this.peekToken();i;){if(i.type===o.TOKEN_LEFT_PAREN)t=new r.FunCall(i.lineno,i.colno,t,this.parseSignature());else if(i.type===o.TOKEN_LEFT_BRACKET)(e=this.parseAggregate()).children.length>1&&this.fail("invalid index"),t=new r.LookupVal(i.lineno,i.colno,t,e.children[0]);else{if(i.type!==o.TOKEN_OPERATOR||"."!==i.value)break;this.nextToken();var n=this.nextToken();n.type!==o.TOKEN_SYMBOL&&this.fail("expected name as lookup value, got "+n.value,n.lineno,n.colno),e=new r.Literal(n.lineno,n.colno,n.value),t=new r.LookupVal(i.lineno,i.colno,t,e)}i=this.peekToken()}return t},c.parseExpression=function(){return this.parseInlineIf()},c.parseInlineIf=function(){var t=this.parseOr();if(this.skipSymbol("if")){var e=this.parseOr(),i=t;(t=new r.InlineIf(t.lineno,t.colno)).body=i,t.cond=e,this.skipSymbol("else")?t.else_=this.parseOr():t.else_=null}return t},c.parseOr=function(){for(var t=this.parseAnd();this.skipSymbol("or");){var e=this.parseAnd();t=new r.Or(t.lineno,t.colno,t,e)}return t},c.parseAnd=function(){for(var t=this.parseNot();this.skipSymbol("and");){var e=this.parseNot();t=new r.And(t.lineno,t.colno,t,e)}return t},c.parseNot=function(){var t=this.peekToken();return this.skipSymbol("not")?new r.Not(t.lineno,t.colno,this.parseNot()):this.parseIn()},c.parseIn=function(){for(var t=this.parseIs();;){var e=this.nextToken();if(!e)break;var i=e.type===o.TOKEN_SYMBOL&&"not"===e.value;if(i||this.pushToken(e),!this.skipSymbol("in")){i&&this.pushToken(e);break}var n=this.parseIs();t=new r.In(t.lineno,t.colno,t,n),i&&(t=new r.Not(t.lineno,t.colno,t))}return t},c.parseIs=function(){var t=this.parseCompare();if(this.skipSymbol("is")){var e=this.skipSymbol("not"),i=this.parseCompare();t=new r.Is(t.lineno,t.colno,t,i),e&&(t=new r.Not(t.lineno,t.colno,t))}return t},c.parseCompare=function(){for(var t=["==","===","!=","!==","<",">","<=",">="],e=this.parseConcat(),i=[];;){var n=this.nextToken();if(!n)break;if(-1===t.indexOf(n.value)){this.pushToken(n);break}i.push(new r.CompareOperand(n.lineno,n.colno,this.parseConcat(),n.value))}return i.length?new r.Compare(i[0].lineno,i[0].colno,e,i):e},c.parseConcat=function(){for(var t=this.parseAdd();this.skipValue(o.TOKEN_TILDE,"~");){var e=this.parseAdd();t=new r.Concat(t.lineno,t.colno,t,e)}return t},c.parseAdd=function(){for(var t=this.parseSub();this.skipValue(o.TOKEN_OPERATOR,"+");){var e=this.parseSub();t=new r.Add(t.lineno,t.colno,t,e)}return t},c.parseSub=function(){for(var t=this.parseMul();this.skipValue(o.TOKEN_OPERATOR,"-");){var e=this.parseMul();t=new r.Sub(t.lineno,t.colno,t,e)}return t},c.parseMul=function(){for(var t=this.parseDiv();this.skipValue(o.TOKEN_OPERATOR,"*");){var e=this.parseDiv();t=new r.Mul(t.lineno,t.colno,t,e)}return t},c.parseDiv=function(){for(var t=this.parseFloorDiv();this.skipValue(o.TOKEN_OPERATOR,"/");){var e=this.parseFloorDiv();t=new r.Div(t.lineno,t.colno,t,e)}return t},c.parseFloorDiv=function(){for(var t=this.parseMod();this.skipValue(o.TOKEN_OPERATOR,"//");){var e=this.parseMod();t=new r.FloorDiv(t.lineno,t.colno,t,e)}return t},c.parseMod=function(){for(var t=this.parsePow();this.skipValue(o.TOKEN_OPERATOR,"%");){var e=this.parsePow();t=new r.Mod(t.lineno,t.colno,t,e)}return t},c.parsePow=function(){for(var t=this.parseUnary();this.skipValue(o.TOKEN_OPERATOR,"**");){var e=this.parseUnary();t=new r.Pow(t.lineno,t.colno,t,e)}return t},c.parseUnary=function(t){var e,i=this.peekToken();return e=this.skipValue(o.TOKEN_OPERATOR,"-")?new r.Neg(i.lineno,i.colno,this.parseUnary(!0)):this.skipValue(o.TOKEN_OPERATOR,"+")?new r.Pos(i.lineno,i.colno,this.parseUnary(!0)):this.parsePrimary(),t||(e=this.parseFilter(e)),e},c.parsePrimary=function(t){var e,i=this.nextToken(),n=null;if(i?i.type===o.TOKEN_STRING?e=i.value:i.type===o.TOKEN_INT?e=parseInt(i.value,10):i.type===o.TOKEN_FLOAT?e=parseFloat(i.value):i.type===o.TOKEN_BOOLEAN?"true"===i.value?e=!0:"false"===i.value?e=!1:this.fail("invalid boolean: "+i.value,i.lineno,i.colno):i.type===o.TOKEN_NONE?e=null:i.type===o.TOKEN_REGEX&&(e=new RegExp(i.value.body,i.value.flags)):this.fail("expected expression, got end of file"),void 0!==e?n=new r.Literal(i.lineno,i.colno,e):i.type===o.TOKEN_SYMBOL?n=new r.Symbol(i.lineno,i.colno,i.value):(this.pushToken(i),n=this.parseAggregate()),t||(n=this.parsePostfix(n)),n)return n;throw this.error("unexpected token: "+i.value,i.lineno,i.colno)},c.parseFilterName=function(){for(var t=this.expect(o.TOKEN_SYMBOL),e=t.value;this.skipValue(o.TOKEN_OPERATOR,".");)e+="."+this.expect(o.TOKEN_SYMBOL).value;return new r.Symbol(t.lineno,t.colno,e)},c.parseFilterArgs=function(t){return this.peekToken().type===o.TOKEN_LEFT_PAREN?this.parsePostfix(t).args.children:[]},c.parseFilter=function(t){for(;this.skip(o.TOKEN_PIPE);){var e=this.parseFilterName();t=new r.Filter(e.lineno,e.colno,e,new r.NodeList(e.lineno,e.colno,[t].concat(this.parseFilterArgs(t))))}return t},c.parseFilterStatement=function(){var t=this.peekToken();this.skipSymbol("filter")||this.fail("parseFilterStatement: expected filter");var e=this.parseFilterName(),i=this.parseFilterArgs(e);this.advanceAfterBlockEnd(t.value);var n=new r.Capture(e.lineno,e.colno,this.parseUntilBlocks("endfilter"));this.advanceAfterBlockEnd();var o=new r.Filter(e.lineno,e.colno,e,new r.NodeList(e.lineno,e.colno,[n].concat(i)));return new r.Output(e.lineno,e.colno,[o])},c.parseAggregate=function(){var t,e=this.nextToken();switch(e.type){case o.TOKEN_LEFT_PAREN:t=new r.Group(e.lineno,e.colno);break;case o.TOKEN_LEFT_BRACKET:t=new r.Array(e.lineno,e.colno);break;case o.TOKEN_LEFT_CURLY:t=new r.Dict(e.lineno,e.colno);break;default:return null}for(;;){var i=this.peekToken().type;if(i===o.TOKEN_RIGHT_PAREN||i===o.TOKEN_RIGHT_BRACKET||i===o.TOKEN_RIGHT_CURLY){this.nextToken();break}if(t.children.length>0&&(this.skip(o.TOKEN_COMMA)||this.fail("parseAggregate: expected comma after expression",e.lineno,e.colno)),t instanceof r.Dict){var n=this.parsePrimary();this.skip(o.TOKEN_COLON)||this.fail("parseAggregate: expected colon after dict key",e.lineno,e.colno);var s=this.parseExpression();t.addChild(new r.Pair(n.lineno,n.colno,n,s))}else{var a=this.parseExpression();t.addChild(a)}}return t},c.parseSignature=function(t,e){var i=this.peekToken();if(!e&&i.type!==o.TOKEN_LEFT_PAREN){if(t)return null;this.fail("expected arguments",i.lineno,i.colno)}i.type===o.TOKEN_LEFT_PAREN&&(i=this.nextToken());for(var n=new r.NodeList(i.lineno,i.colno),s=new r.KeywordArgs(i.lineno,i.colno),a=!1;;){if(i=this.peekToken(),!e&&i.type===o.TOKEN_RIGHT_PAREN){this.nextToken();break}if(e&&i.type===o.TOKEN_BLOCK_END)break;if(a&&!this.skip(o.TOKEN_COMMA))this.fail("parseSignature: expected comma after expression",i.lineno,i.colno);else{var c=this.parseExpression();this.skipValue(o.TOKEN_OPERATOR,"=")?s.addChild(new r.Pair(c.lineno,c.colno,c,this.parseExpression())):n.addChild(c)}a=!0}return s.children.length&&n.addChild(s),n},c.parseUntilBlocks=function(){for(var t=this.breakOnBlocks,e=arguments.length,i=new Array(e),n=0;n=","//","**"],j=M+this.current();switch(-1!==n.indexOf(P,j)&&(this.forward(),M=j,-1!==n.indexOf(P,j+this.current())&&(M=j+this.current(),this.forward())),M){case"(":R=f;break;case")":R=m;break;case"[":R=v;break;case"]":R=y;break;case"{":R=_;break;case"}":R=g;break;case",":R=C;break;case":":R=k;break;case"~":R=L;break;case"|":R=w;break;default:R=b}return S(R,M,e,i)}if((t=this._extractUntil(o+r)).match(/^[-+]?[0-9]+$/)){if("."===this.current()){this.forward();var F=this._extract("0123456789");return S(x,t+"."+F,e,i)}return S("int",t,e,i)}if(t.match(/^(true|false)$/))return S(A,t,e,i);if("none"===t)return S(E,t,e,i);if("null"===t)return S(E,t,e,i);if(t)return S(T,t,e,i);throw new Error("Unexpected value while parsing: "+t)}var B,D=this.tags.BLOCK_START.charAt(0)+this.tags.VARIABLE_START.charAt(0)+this.tags.COMMENT_START.charAt(0)+this.tags.COMMENT_END.charAt(0);if(this.isFinished())return null;if((t=this._extractString(this.tags.BLOCK_START+"-"))||(t=this._extractString(this.tags.BLOCK_START)))return this.in_code=!0,S(l,t,e,i);if((t=this._extractString(this.tags.VARIABLE_START+"-"))||(t=this._extractString(this.tags.VARIABLE_START)))return this.in_code=!0,S(u,t,e,i);t="";var V=!1;for(this._matches(this.tags.COMMENT_START)&&(V=!0,t=this._extractString(this.tags.COMMENT_START));null!==(B=this._extractUntil(D));){if(t+=B,(this._matches(this.tags.BLOCK_START)||this._matches(this.tags.VARIABLE_START)||this._matches(this.tags.COMMENT_START))&&!V){if(this.lstripBlocks&&this._matches(this.tags.BLOCK_START)&&this.colno>0&&this.colno<=t.length){var H=t.slice(-this.colno);if(/^\s+$/.test(H)&&!(t=t.slice(0,-this.colno)).length)return this.nextToken()}break}if(this._matches(this.tags.COMMENT_END)){if(!V)throw new Error("unexpected end of comment");t+=this._extractString(this.tags.COMMENT_END);break}t+=this.current(),this.forward()}if(null===B&&V)throw new Error("expected end of comment, got end of file");return S(V?d:c,t,e,i)},e._parseString=function(t){this.forward();for(var e="";!this.isFinished()&&this.current()!==t;){var i=this.current();if("\\"===i){switch(this.forward(),this.current()){case"n":e+="\n";break;case"t":e+="\t";break;case"r":e+="\r";break;default:e+=this.current()}this.forward()}else e+=i,this.forward()}return this.forward(),e},e._matches=function(t){return this.index+t.length>this.len?null:this.str.slice(this.index,this.index+t.length)===t},e._extractString=function(t){return this._matches(t)?(this.forwardN(t.length),t):null},e._extractUntil=function(t){return this._extractMatching(!0,t||"")},e._extract=function(t){return this._extractMatching(!1,t)},e._extractMatching=function(t,e){if(this.isFinished())return null;var i=e.indexOf(this.current());if(t&&-1===i||!t&&-1!==i){var n=this.current();this.forward();for(var o=e.indexOf(this.current());(t&&-1===o||!t&&-1!==o)&&!this.isFinished();)n+=this.current(),this.forward(),o=e.indexOf(this.current());return n}return""},e._extractRegex=function(t){var e=this.currentStr().match(t);return e?(this.forwardN(e[0].length),e):null},e.isFinished=function(){return this.index>=this.len},e.forwardN=function(t){for(var e=0;e1024){for(var e=0,i=o.length-r;e0&&s.length>o&&!s.warned){s.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=t,c.type=e,c.count=s.length,a=c,console&&console.warn&&console.warn(a)}return t}function p(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function d(t,e,i){var n={fired:!1,wrapFn:void 0,target:t,type:e,listener:i},o=p.bind(n);return o.listener=i,n.wrapFn=o,o}function f(t,e,i){var n=t._events;if(void 0===n)return[];var o=n[e];return void 0===o?[]:"function"==typeof o?i?[o.listener||o]:[o]:i?function(t){for(var e=new Array(t.length),i=0;i0&&(s=e[0]),s instanceof Error)throw s;var a=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw a.context=s,a}var c=o[t];if(void 0===c)return!1;if("function"==typeof c)r(c,this,e);else{var l=c.length,h=v(c,l);for(i=0;i=0;r--)if(i[r]===e||i[r].listener===e){s=i[r].listener,o=r;break}if(o<0)return this;0===o?i.shift():function(t,e){for(;e+1=0;n--)this.removeListener(t,e[n]);return this},a.prototype.listeners=function(t){return f(this,t,!0)},a.prototype.rawListeners=function(t){return f(this,t,!1)},a.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):m.call(t,e)},a.prototype.listenerCount=m,a.prototype.eventNames=function(){return this._eventsCount>0?n(this._events):[]}},function(t,e,i){"use strict";var n=i(3),o=i(0),r=0;function s(){return"hole_"+r++}function a(t,e){for(var i=null,n=0;n=e)return t;var i=e-t.length,s=n.repeat(" ",i/2-i%2),a=n.repeat(" ",i/2);return o.copySafeness(t,s+t+a)},e.default=function(t,e,i){return i?t||e:void 0!==t?t:e},e.dictsort=function(t,e,i){if(!n.isObject(t))throw new n.TemplateError("dictsort filter: val must be an object");var o,r=[];for(var s in t)r.push([s,t[s]]);if(void 0===i||"key"===i)o=0;else{if("value"!==i)throw new n.TemplateError("dictsort filter: You can only sort by either key or value");o=1}return r.sort((function(t,i){var r=t[o],s=i[o];return e||(n.isString(r)&&(r=r.toUpperCase()),n.isString(s)&&(s=s.toUpperCase())),r>s?1:r===s?0:-1})),r},e.dump=function(t,e){return JSON.stringify(t,null,e)},e.escape=function(t){return t instanceof o.SafeString?t:(t=null==t?"":t,o.markSafe(n.escape(t.toString())))},e.safe=function(t){return t instanceof o.SafeString?t:(t=null==t?"":t,o.markSafe(t.toString()))},e.first=function(t){return t[0]},e.forceescape=function(t){return t=null==t?"":t,o.markSafe(n.escape(t.toString()))},e.groupby=function(t,e){return n.groupBy(t,e,this.env.opts.throwOnUndefined)},e.indent=function(t,e,i){if(""===(t=r(t,"")))return"";e=e||4;var s=t.split("\n"),a=n.repeat(" ",e),c=s.map((function(t,e){return 0!==e||i?""+a+t:t})).join("\n");return o.copySafeness(t,c)},e.join=function(t,e,i){return e=e||"",i&&(t=n.map(t,(function(t){return t[i]}))),t.join(e)},e.last=function(t){return t[t.length-1]},e.length=function(t){var e=r(t,"");return void 0!==e?"function"==typeof Map&&e instanceof Map||"function"==typeof Set&&e instanceof Set?e.size:!n.isObject(e)||e instanceof o.SafeString?e.length:n.keys(e).length:0},e.list=c,e.lower=function(t){return(t=r(t,"")).toLowerCase()},e.nl2br=function(t){return null==t?"":o.copySafeness(t,t.replace(/\r\n|\n/g,"
\n"))},e.random=function(t){return t[Math.floor(Math.random()*t.length)]},e.reject=l(!1),e.rejectattr=function(t,e){return t.filter((function(t){return!t[e]}))},e.select=l(!0),e.selectattr=function(t,e){return t.filter((function(t){return!!t[e]}))},e.replace=function(t,e,i,n){var r=t;if(e instanceof RegExp)return t.replace(e,i);void 0===n&&(n=-1);var s="";if("number"==typeof e)e=""+e;else if("string"!=typeof e)return t;if("number"==typeof t&&(t=""+t),"string"!=typeof t&&!(t instanceof o.SafeString))return t;if(""===e)return s=i+t.split("").join(i)+i,o.copySafeness(t,s);var a=t.indexOf(e);if(0===n||-1===a)return t;for(var c=0,l=0;a>-1&&(-1===n||l=o&&h.push(i),r.push(h)}return r},e.sum=function(t,e,i){return void 0===i&&(i=0),e&&(t=n.map(t,(function(t){return t[e]}))),i+t.reduce((function(t,e){return t+e}),0)},e.sort=o.makeMacro(["value","reverse","case_sensitive","attribute"],[],(function(t,e,i,o){var r=this,s=n.map(t,(function(t){return t})),a=n.getAttrGetter(o);return s.sort((function(t,s){var c=o?a(t):t,l=o?a(s):s;if(r.env.opts.throwOnUndefined&&o&&(void 0===c||void 0===l))throw new TypeError('sort: attribute "'+o+'" resolved to undefined');return!i&&n.isString(c)&&n.isString(l)&&(c=c.toLowerCase(),l=l.toLowerCase()),cl?e?-1:1:0})),s})),e.string=function(t){return o.copySafeness(t,t)},e.striptags=function(t,e){var i,n=h((t=r(t,"")).replace(/<\/?([a-z][a-z0-9]*)\b[^>]*>|/gi,""));return i=e?n.replace(/^ +| +$/gm,"").replace(/ +/g," ").replace(/(\r\n)/g,"\n").replace(/\n\n\n+/g,"\n\n"):n.replace(/\s+/gi," "),o.copySafeness(t,i)},e.title=function(t){var e=(t=r(t,"")).split(" ").map((function(t){return a(t)}));return o.copySafeness(t,e.join(" "))},e.trim=h,e.truncate=function(t,e,i,n){var s=t;if(e=e||255,(t=r(t,"")).length<=e)return t;if(i)t=t.substring(0,e);else{var a=t.lastIndexOf(" ",e);-1===a&&(a=e),t=t.substring(0,a)}return t+=null!=n?n:"...",o.copySafeness(s,t)},e.upper=function(t){return(t=r(t,"")).toUpperCase()},e.urlencode=function(t){var e=encodeURIComponent;return n.isString(t)?e(t):(n.isArray(t)?t:n._entries(t)).map((function(t){var i=t[0],n=t[1];return e(i)+"="+e(n)})).join("&")};var u=/^(?:\(|<|<)?(.*?)(?:\.|,|\)|\n|>)?$/,p=/^[\w.!#$%&'*+\-\/=?\^`{|}~]+@[a-z\d\-]+(\.[a-z\d\-]+)+$/i,d=/^https?:\/\/.*$/,f=/^www\./,m=/\.(?:org|net|com)(?:\:|\/|$)/;e.urlize=function(t,e,i){s(e)&&(e=1/0);var n=!0===i?' rel="nofollow"':"";return t.split(/(\s+)/).filter((function(t){return t&&t.length})).map((function(t){var i=t.match(u),o=i?i[1]:t,r=o.substr(0,e);return d.test(o)?'"+r+"":f.test(o)?'"+r+"":p.test(o)?''+o+"":m.test(o)?'"+r+"":t})).join("")},e.wordcount=function(t){var e=(t=r(t,""))?t.match(/\w+/g):null;return e?e.length:null},e.float=function(t,e){var i=parseFloat(t);return s(i)?e:i};var v=o.makeMacro(["value","default","base"],[],(function(t,e,i){void 0===i&&(i=10);var n=parseInt(t,i);return s(n)?e:n}));e.int=v,e.d=e.default,e.e=e.escape},function(t,e,i){"use strict";function n(t,e){return n=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},n(t,e)}var o=function(t){var e,i;function o(e){var i;return(i=t.call(this)||this).precompiled=e||{},i}return i=t,(e=o).prototype=Object.create(i.prototype),e.prototype.constructor=e,n(e,i),o.prototype.getSource=function(t){return this.precompiled[t]?{src:{type:"code",obj:this.precompiled[t]},path:t}:null},o}(i(6));t.exports={PrecompiledLoader:o}},function(t,e,i){"use strict";var n=i(2).SafeString;e.callable=function(t){return"function"==typeof t},e.defined=function(t){return void 0!==t},e.divisibleby=function(t,e){return t%e==0},e.escaped=function(t){return t instanceof n},e.equalto=function(t,e){return t===e},e.eq=e.equalto,e.sameas=e.equalto,e.even=function(t){return t%2==0},e.falsy=function(t){return!t},e.ge=function(t,e){return t>=e},e.greaterthan=function(t,e){return t>e},e.gt=e.greaterthan,e.le=function(t,e){return t<=e},e.lessthan=function(t,e){return t0)for(var o=t;oe;r+=i)n.push(r);return n},cycler:function(){return t=Array.prototype.slice.call(arguments),e=-1,{current:null,reset:function(){e=-1,this.current=null},next:function(){return++e>=t.length&&(e=0),this.current=t[e],this.current}};var t,e},joiner:function(t){return function(t){t=t||",";var e=!0;return function(){var i=e?"":t;return e=!1,i}}(t)}}}},function(t,e,i){var n=i(4);t.exports=function(t,e){function i(t,e){if(this.name=t,this.path=t,this.defaultEngine=e.defaultEngine,this.ext=n.extname(t),!this.ext&&!this.defaultEngine)throw new Error("No default engine was specified and no extension was provided.");this.ext||(this.name+=this.ext=("."!==this.defaultEngine[0]?".":"")+this.defaultEngine)}return i.prototype.render=function(e,i){t.render(this.name,e,i)},e.set("view",i),e.set("nunjucksEnv",t),t}},function(t,e,i){"use strict";var n=i(4),o=i(4),r=i(0)._prettifyError,s=i(5),a=i(7).Environment,c=i(24);function l(t,e){return!!Array.isArray(e)&&e.some((function(e){return t.match(e)}))}function h(t,e){(e=e||{}).isString=!0;var i=e.env||new a([]),n=e.wrapper||c;if(!e.name)throw new Error('the "name" option is required when compiling a string');return n([u(t,e.name,i)],e)}function u(t,e,i){var n,o=(i=i||new a([])).asyncFilters,c=i.extensionsList;e=e.replace(/\\/g,"/");try{n=s.compile(t,o,c,e,i.opts)}catch(t){throw r(e,!1,t)}return{name:e,template:n}}t.exports={precompile:function(t,e){var i=(e=e||{}).env||new a([]),r=e.wrapper||c;if(e.isString)return h(t,e);var s=n.existsSync(t)&&n.statSync(t),p=[],d=[];if(s.isFile())p.push(u(n.readFileSync(t,"utf-8"),e.name||t,i));else if(s.isDirectory()){!function i(r){n.readdirSync(r).forEach((function(s){var a=o.join(r,s),c=a.substr(o.join(t,"/").length),h=n.statSync(a);h&&h.isDirectory()?l(c+="/",e.exclude)||i(a):l(c,e.include)&&d.push(a)}))}(t);for(var f=0;ft.length||o>0&&s>=n||o<0&&s<=n);s+=o)r.push(i.memberLookup(t,s));return r}function d(t,e){return Object.prototype.hasOwnProperty.call(t,e)}var f={pop:function(t){if(void 0===t)return this.pop();if(t>=this.length||t<0)throw new Error("KeyError");return this.splice(t,1)},append:function(t){return this.push(t)},remove:function(t){for(var e=0;e{"use strict";const t=globalThis,e=t.ShadowRoot&&(void 0===t.ShadyCSS||t.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,n=Symbol(),o=new WeakMap;class r{constructor(t,e,i){if(this._$cssResult$=!0,i!==n)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e}get styleSheet(){let t=this.o;const i=this.t;if(e&&void 0===t){const e=void 0!==i&&1===i.length;e&&(t=o.get(i)),void 0===t&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),e&&o.set(i,t))}return t}toString(){return this.cssText}}const s=(t,...e)=>{const i=1===t.length?t[0]:e.reduce(((e,i,n)=>e+(t=>{if(!0===t._$cssResult$)return t.cssText;if("number"==typeof t)return t;throw Error("Value passed to 'css' function must be a 'css' function result: "+t+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(i)+t[n+1]),t[0]);return new r(i,t,n)},a=(i,n)=>{if(e)i.adoptedStyleSheets=n.map((t=>t instanceof CSSStyleSheet?t:t.styleSheet));else for(const e of n){const n=document.createElement("style"),o=t.litNonce;void 0!==o&&n.setAttribute("nonce",o),n.textContent=e.cssText,i.appendChild(n)}},c=e?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(const i of t.cssRules)e+=i.cssText;return(t=>new r("string"==typeof t?t:t+"",void 0,n))(e)})(t):t,{is:l,defineProperty:h,getOwnPropertyDescriptor:u,getOwnPropertyNames:p,getOwnPropertySymbols:d,getPrototypeOf:f}=Object,m=globalThis,v=m.trustedTypes,y=v?v.emptyScript:"",_=m.reactiveElementPolyfillSupport,g=(t,e)=>t,b={toAttribute(t,e){switch(e){case Boolean:t=t?y:null;break;case Object:case Array:t=null==t?t:JSON.stringify(t)}return t},fromAttribute(t,e){let i=t;switch(e){case Boolean:i=null!==t;break;case Number:i=null===t?null:Number(t);break;case Object:case Array:try{i=JSON.parse(t)}catch(t){i=null}}return i}},C=(t,e)=>!l(t,e),k={attribute:!0,type:String,converter:b,reflect:!1,hasChanged:C};Symbol.metadata??=Symbol("metadata"),m.litPropertyMetadata??=new WeakMap;class L extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??=[]).push(t)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,e=k){if(e.state&&(e.attribute=!1),this._$Ei(),this.elementProperties.set(t,e),!e.noAccessor){const i=Symbol(),n=this.getPropertyDescriptor(t,i,e);void 0!==n&&h(this.prototype,t,n)}}static getPropertyDescriptor(t,e,i){const{get:n,set:o}=u(this.prototype,t)??{get(){return this[e]},set(t){this[e]=t}};return{get(){return n?.call(this)},set(e){const r=n?.call(this);o.call(this,e),this.requestUpdate(t,r,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??k}static _$Ei(){if(this.hasOwnProperty(g("elementProperties")))return;const t=f(this);t.finalize(),void 0!==t.l&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(g("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(g("properties"))){const t=this.properties,e=[...p(t),...d(t)];for(const i of e)this.createProperty(i,t[i])}const t=this[Symbol.metadata];if(null!==t){const e=litPropertyMetadata.get(t);if(void 0!==e)for(const[t,i]of e)this.elementProperties.set(t,i)}this._$Eh=new Map;for(const[t,e]of this.elementProperties){const i=this._$Eu(t,e);void 0!==i&&this._$Eh.set(i,t)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(t){const e=[];if(Array.isArray(t)){const i=new Set(t.flat(1/0).reverse());for(const t of i)e.unshift(c(t))}else void 0!==t&&e.push(c(t));return e}static _$Eu(t,e){const i=e.attribute;return!1===i?void 0:"string"==typeof i?i:"string"==typeof t?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$Eg=new Promise((t=>this.enableUpdating=t)),this._$AL=new Map,this._$ES(),this.requestUpdate(),this.constructor.l?.forEach((t=>t(this)))}addController(t){(this._$E_??=new Set).add(t),void 0!==this.renderRoot&&this.isConnected&&t.hostConnected?.()}removeController(t){this._$E_?.delete(t)}_$ES(){const t=new Map,e=this.constructor.elementProperties;for(const i of e.keys())this.hasOwnProperty(i)&&(t.set(i,this[i]),delete this[i]);t.size>0&&(this._$Ep=t)}createRenderRoot(){const t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return a(t,this.constructor.elementStyles),t}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$E_?.forEach((t=>t.hostConnected?.()))}enableUpdating(t){}disconnectedCallback(){this._$E_?.forEach((t=>t.hostDisconnected?.()))}attributeChangedCallback(t,e,i){this._$AK(t,i)}_$EO(t,e){const i=this.constructor.elementProperties.get(t),n=this.constructor._$Eu(t,i);if(void 0!==n&&!0===i.reflect){const o=(void 0!==i.converter?.toAttribute?i.converter:b).toAttribute(e,i.type);this._$Em=t,null==o?this.removeAttribute(n):this.setAttribute(n,o),this._$Em=null}}_$AK(t,e){const i=this.constructor,n=i._$Eh.get(t);if(void 0!==n&&this._$Em!==n){const t=i.getPropertyOptions(n),o="function"==typeof t.converter?{fromAttribute:t.converter}:void 0!==t.converter?.fromAttribute?t.converter:b;this._$Em=n,this[n]=o.fromAttribute(e,t.type),this._$Em=null}}requestUpdate(t,e,i){if(void 0!==t){if(i??=this.constructor.getPropertyOptions(t),!(i.hasChanged??C)(this[t],e))return;this.C(t,e,i)}!1===this.isUpdatePending&&(this._$Eg=this._$EP())}C(t,e,i){this._$AL.has(t)||this._$AL.set(t,e),!0===i.reflect&&this._$Em!==t&&(this._$ET??=new Set).add(t)}async _$EP(){this.isUpdatePending=!0;try{await this._$Eg}catch(t){Promise.reject(t)}const t=this.scheduleUpdate();return null!=t&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(const[t,e]of this._$Ep)this[t]=e;this._$Ep=void 0}const t=this.constructor.elementProperties;if(t.size>0)for(const[e,i]of t)!0!==i.wrapped||this._$AL.has(e)||void 0===this[e]||this.C(e,this[e],i)}let t=!1;const e=this._$AL;try{t=this.shouldUpdate(e),t?(this.willUpdate(e),this._$E_?.forEach((t=>t.hostUpdate?.())),this.update(e)):this._$Ej()}catch(e){throw t=!1,this._$Ej(),e}t&&this._$AE(e)}willUpdate(t){}_$AE(t){this._$E_?.forEach((t=>t.hostUpdated?.())),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$Ej(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$Eg}shouldUpdate(t){return!0}update(t){this._$ET&&=this._$ET.forEach((t=>this._$EO(t,this[t]))),this._$Ej()}updated(t){}firstUpdated(t){}}L.elementStyles=[],L.shadowRootOptions={mode:"open"},L[g("elementProperties")]=new Map,L[g("finalized")]=new Map,_?.({ReactiveElement:L}),(m.reactiveElementVersions??=[]).push("2.0.3");const w=globalThis,x=w.trustedTypes,A=x?x.createPolicy("lit-html",{createHTML:t=>t}):void 0,E="$lit$",T=`lit$${(Math.random()+"").slice(9)}$`,O="?"+T,S=`<${O}>`,M=document,I=()=>M.createComment(""),N=t=>null===t||"object"!=typeof t&&"function"!=typeof t,$=Array.isArray,R="[ \t\n\f\r]",P=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,j=/-->/g,F=/>/g,B=RegExp(`>|${R}(?:([^\\s"'>=/]+)(${R}*=${R}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),D=/'/g,V=/"/g,H=/^(?:script|style|textarea|title)$/i,K=t=>(e,...i)=>({_$litType$:t,strings:e,values:i}),U=K(1),Z=(K(2),Symbol.for("lit-noChange")),z=Symbol.for("lit-nothing"),W=new WeakMap,Y=M.createTreeWalker(M,129);function G(t,e){if(!Array.isArray(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==A?A.createHTML(e):e}const q=(t,e)=>{const i=t.length-1,n=[];let o,r=2===e?"":"",s=P;for(let e=0;e"===c[0]?(s=o??P,l=-1):void 0===c[1]?l=-2:(l=s.lastIndex-c[2].length,a=c[1],s=void 0===c[3]?B:'"'===c[3]?V:D):s===V||s===D?s=B:s===j||s===F?s=P:(s=B,o=void 0);const u=s===B&&t[e+1].startsWith("/>")?" ":"";r+=s===P?i+S:l>=0?(n.push(a),i.slice(0,l)+E+i.slice(l)+T+u):i+T+(-2===l?e:u)}return[G(t,r+(t[i]||"")+(2===e?"":"")),n]};class X{constructor({strings:t,_$litType$:e},i){let n;this.parts=[];let o=0,r=0;const s=t.length-1,a=this.parts,[c,l]=q(t,e);if(this.el=X.createElement(c,i),Y.currentNode=this.el.content,2===e){const t=this.el.content.firstChild;t.replaceWith(...t.childNodes)}for(;null!==(n=Y.nextNode())&&a.length0){n.textContent=x?x.emptyScript:"";for(let i=0;i$(t)||"function"==typeof t?.[Symbol.iterator])(t)?this.T(t):this._(t)}k(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}$(t){this._$AH!==t&&(this._$AR(),this._$AH=this.k(t))}_(t){this._$AH!==z&&N(this._$AH)?this._$AA.nextSibling.data=t:this.$(M.createTextNode(t)),this._$AH=t}g(t){const{values:e,_$litType$:i}=t,n="number"==typeof i?this._$AC(t):(void 0===i.el&&(i.el=X.createElement(G(i.h,i.h[0]),this.options)),i);if(this._$AH?._$AD===n)this._$AH.p(e);else{const t=new Q(n,this),i=t.u(this.options);t.p(e),this.$(i),this._$AH=t}}_$AC(t){let e=W.get(t.strings);return void 0===e&&W.set(t.strings,e=new X(t)),e}T(t){$(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let i,n=0;for(const o of t)n===e.length?e.push(i=new tt(this.k(I()),this.k(I()),this,this.options)):i=e[n],i._$AI(o),n++;n2||""!==i[0]||""!==i[1]?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=z}_$AI(t,e=this,i,n){const o=this.strings;let r=!1;if(void 0===o)t=J(this,t,e,0),r=!N(t)||t!==this._$AH&&t!==Z,r&&(this._$AH=t);else{const n=t;let s,a;for(t=o[0],s=0;s{const n=i?.renderBefore??e;let o=n._$litPart$;if(void 0===o){const t=i?.renderBefore??null;n._$litPart$=o=new tt(e.insertBefore(I(),t),t,void 0,i??{})}return o._$AI(t),o})(e,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return Z}}at._$litElement$=!0,at.finalized=!0,globalThis.litElementHydrateSupport?.({LitElement:at});const ct=globalThis.litElementPolyfillSupport;ct?.({LitElement:at}),(globalThis.litElementVersions??=[]).push("4.0.3");const lt=t=>(e,i)=>{void 0!==i?i.addInitializer((()=>{customElements.define(t,e)})):customElements.define(t,e)},ht={attribute:!0,type:String,converter:b,reflect:!1,hasChanged:C},ut=(t=ht,e,i)=>{const{kind:n,metadata:o}=i;let r=globalThis.litPropertyMetadata.get(o);if(void 0===r&&globalThis.litPropertyMetadata.set(o,r=new Map),r.set(i.name,t),"accessor"===n){const{name:n}=i;return{set(i){const o=e.get.call(this);e.set.call(this,i),this.requestUpdate(n,o,t)},init(e){return void 0!==e&&this.C(n,void 0,t),e}}}if("setter"===n){const{name:n}=i;return function(i){const o=this[n];e.call(this,i),this.requestUpdate(n,o,t)}}throw Error("Unsupported decorator location: "+n)};function pt(t){return(e,i)=>"object"==typeof i?ut(t,e,i):((t,e,i)=>{const n=e.hasOwnProperty(i);return e.constructor.createProperty(i,n?{...t,wrapped:!0}:t),n?Object.getOwnPropertyDescriptor(e,i):void 0})(t,e,i)}function dt(t){return pt({...t,state:!0,attribute:!1})}function ft(t){return(e,i)=>{const n="function"==typeof e?e:e[i];Object.assign(n,t)}}class mt{constructor(t){}get _$AU(){return this._$AM._$AU}_$AT(t,e,i){this._$Ct=t,this._$AM=e,this._$Ci=i}_$AS(t,e){return this.update(t,e)}update(t,e){return this.render(...e)}}const vt="important",yt=" !"+vt,_t=(t=>(...e)=>({_$litDirective$:t,values:e}))(class extends mt{constructor(t){if(super(t),1!==t.type||"style"!==t.name||t.strings?.length>2)throw Error("The `styleMap` directive must be used in the `style` attribute and must be the only part in the attribute.")}render(t){return Object.keys(t).reduce(((e,i)=>{const n=t[i];return null==n?e:e+`${i=i.includes("-")?i:i.replace(/(?:^(webkit|moz|ms|o)|)(?=[A-Z])/g,"-$&").toLowerCase()}:${n};`}),"")}update(t,[e]){const{style:i}=t.element;if(void 0===this.ut)return this.ut=new Set(Object.keys(e)),this.render(e);for(const t of this.ut)null==e[t]&&(this.ut.delete(t),t.includes("-")?i.removeProperty(t):i[t]=null);for(const t in e){const n=e[t];if(null!=n){this.ut.add(t);const e="string"==typeof n&&n.endsWith(yt);t.includes("-")||e?i.setProperty(t,e?n.slice(0,-11):n,e?vt:""):i[t]=n}}return Z}});var gt=i(865);function bt(t){return null==t}var Ct={isNothing:bt,isObject:function(t){return"object"==typeof t&&null!==t},toArray:function(t){return Array.isArray(t)?t:bt(t)?[]:[t]},repeat:function(t,e){var i,n="";for(i=0;ia&&(e=n-a+(r=" ... ").length),i-n>a&&(i=n+a-(s=" ...").length),{str:r+t.slice(e,i).replace(/\t/g,"→")+s,pos:n-e+r.length}}function At(t,e){return Ct.repeat(" ",e-t.length)+t}var Et=function(t,e){if(e=Object.create(e||null),!t.buffer)return null;e.maxLength||(e.maxLength=79),"number"!=typeof e.indent&&(e.indent=1),"number"!=typeof e.linesBefore&&(e.linesBefore=3),"number"!=typeof e.linesAfter&&(e.linesAfter=2);for(var i,n=/\r?\n|\r|\0/g,o=[0],r=[],s=-1;i=n.exec(t.buffer);)r.push(i.index),o.push(i.index+i[0].length),t.position<=i.index&&s<0&&(s=o.length-2);s<0&&(s=o.length-1);var a,c,l="",h=Math.min(t.line+e.linesAfter,r.length).toString().length,u=e.maxLength-(e.indent+h+3);for(a=1;a<=e.linesBefore&&!(s-a<0);a++)c=xt(t.buffer,o[s-a],r[s-a],t.position-(o[s]-o[s-a]),u),l=Ct.repeat(" ",e.indent)+At((t.line-a+1).toString(),h)+" | "+c.str+"\n"+l;for(c=xt(t.buffer,o[s],r[s],t.position,u),l+=Ct.repeat(" ",e.indent)+At((t.line+1).toString(),h)+" | "+c.str+"\n",l+=Ct.repeat("-",e.indent+h+3+c.pos)+"^\n",a=1;a<=e.linesAfter&&!(s+a>=r.length);a++)c=xt(t.buffer,o[s+a],r[s+a],t.position-(o[s]-o[s+a]),u),l+=Ct.repeat(" ",e.indent)+At((t.line+a+1).toString(),h)+" | "+c.str+"\n";return l.replace(/\n$/,"")},Tt=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"],Ot=["scalar","sequence","mapping"],St=function(t,e){if(e=e||{},Object.keys(e).forEach((function(e){if(-1===Tt.indexOf(e))throw new wt('Unknown option "'+e+'" is met in definition of "'+t+'" YAML type.')})),this.options=e,this.tag=t,this.kind=e.kind||null,this.resolve=e.resolve||function(){return!0},this.construct=e.construct||function(t){return t},this.instanceOf=e.instanceOf||null,this.predicate=e.predicate||null,this.represent=e.represent||null,this.representName=e.representName||null,this.defaultStyle=e.defaultStyle||null,this.multi=e.multi||!1,this.styleAliases=function(t){var e={};return null!==t&&Object.keys(t).forEach((function(i){t[i].forEach((function(t){e[String(t)]=i}))})),e}(e.styleAliases||null),-1===Ot.indexOf(this.kind))throw new wt('Unknown kind "'+this.kind+'" is specified for "'+t+'" YAML type.')};function Mt(t,e){var i=[];return t[e].forEach((function(t){var e=i.length;i.forEach((function(i,n){i.tag===t.tag&&i.kind===t.kind&&i.multi===t.multi&&(e=n)})),i[e]=t})),i}function It(t){return this.extend(t)}It.prototype.extend=function(t){var e=[],i=[];if(t instanceof St)i.push(t);else if(Array.isArray(t))i=i.concat(t);else{if(!t||!Array.isArray(t.implicit)&&!Array.isArray(t.explicit))throw new wt("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })");t.implicit&&(e=e.concat(t.implicit)),t.explicit&&(i=i.concat(t.explicit))}e.forEach((function(t){if(!(t instanceof St))throw new wt("Specified list of YAML types (or a single Type object) contains a non-Type object.");if(t.loadKind&&"scalar"!==t.loadKind)throw new wt("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.");if(t.multi)throw new wt("There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.")})),i.forEach((function(t){if(!(t instanceof St))throw new wt("Specified list of YAML types (or a single Type object) contains a non-Type object.")}));var n=Object.create(It.prototype);return n.implicit=(this.implicit||[]).concat(e),n.explicit=(this.explicit||[]).concat(i),n.compiledImplicit=Mt(n,"implicit"),n.compiledExplicit=Mt(n,"explicit"),n.compiledTypeMap=function(){var t,e,i={scalar:{},sequence:{},mapping:{},fallback:{},multi:{scalar:[],sequence:[],mapping:[],fallback:[]}};function n(t){t.multi?(i.multi[t.kind].push(t),i.multi.fallback.push(t)):i[t.kind][t.tag]=i.fallback[t.tag]=t}for(t=0,e=arguments.length;t=0?"0b"+t.toString(2):"-0b"+t.toString(2).slice(1)},octal:function(t){return t>=0?"0o"+t.toString(8):"-0o"+t.toString(8).slice(1)},decimal:function(t){return t.toString(10)},hexadecimal:function(t){return t>=0?"0x"+t.toString(16).toUpperCase():"-0x"+t.toString(16).toUpperCase().slice(1)}},defaultStyle:"decimal",styleAliases:{binary:[2,"bin"],octal:[8,"oct"],decimal:[10,"dec"],hexadecimal:[16,"hex"]}}),Dt=new RegExp("^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$"),Vt=/^[-+]?[0-9]+e/,Ht=new St("tag:yaml.org,2002:float",{kind:"scalar",resolve:function(t){return null!==t&&!(!Dt.test(t)||"_"===t[t.length-1])},construct:function(t){var e,i;return i="-"===(e=t.replace(/_/g,"").toLowerCase())[0]?-1:1,"+-".indexOf(e[0])>=0&&(e=e.slice(1)),".inf"===e?1===i?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:".nan"===e?NaN:i*parseFloat(e,10)},predicate:function(t){return"[object Number]"===Object.prototype.toString.call(t)&&(t%1!=0||Ct.isNegativeZero(t))},represent:function(t,e){var i;if(isNaN(t))switch(e){case"lowercase":return".nan";case"uppercase":return".NAN";case"camelcase":return".NaN"}else if(Number.POSITIVE_INFINITY===t)switch(e){case"lowercase":return".inf";case"uppercase":return".INF";case"camelcase":return".Inf"}else if(Number.NEGATIVE_INFINITY===t)switch(e){case"lowercase":return"-.inf";case"uppercase":return"-.INF";case"camelcase":return"-.Inf"}else if(Ct.isNegativeZero(t))return"-0.0";return i=t.toString(10),Vt.test(i)?i.replace("e",".e"):i},defaultStyle:"lowercase"}),Kt=Nt.extend({implicit:[$t,Rt,Bt,Ht]}),Ut=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),Zt=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$"),zt=new St("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:function(t){return null!==t&&(null!==Ut.exec(t)||null!==Zt.exec(t))},construct:function(t){var e,i,n,o,r,s,a,c,l=0,h=null;if(null===(e=Ut.exec(t))&&(e=Zt.exec(t)),null===e)throw new Error("Date resolve error");if(i=+e[1],n=+e[2]-1,o=+e[3],!e[4])return new Date(Date.UTC(i,n,o));if(r=+e[4],s=+e[5],a=+e[6],e[7]){for(l=e[7].slice(0,3);l.length<3;)l+="0";l=+l}return e[9]&&(h=6e4*(60*+e[10]+ +(e[11]||0)),"-"===e[9]&&(h=-h)),c=new Date(Date.UTC(i,n,o,r,s,a,l)),h&&c.setTime(c.getTime()-h),c},instanceOf:Date,represent:function(t){return t.toISOString()}}),Wt=new St("tag:yaml.org,2002:merge",{kind:"scalar",resolve:function(t){return"<<"===t||null===t}}),Yt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r",Gt=new St("tag:yaml.org,2002:binary",{kind:"scalar",resolve:function(t){if(null===t)return!1;var e,i,n=0,o=t.length,r=Yt;for(i=0;i64)){if(e<0)return!1;n+=6}return n%8==0},construct:function(t){var e,i,n=t.replace(/[\r\n=]/g,""),o=n.length,r=Yt,s=0,a=[];for(e=0;e>16&255),a.push(s>>8&255),a.push(255&s)),s=s<<6|r.indexOf(n.charAt(e));return 0==(i=o%4*6)?(a.push(s>>16&255),a.push(s>>8&255),a.push(255&s)):18===i?(a.push(s>>10&255),a.push(s>>2&255)):12===i&&a.push(s>>4&255),new Uint8Array(a)},predicate:function(t){return"[object Uint8Array]"===Object.prototype.toString.call(t)},represent:function(t){var e,i,n="",o=0,r=t.length,s=Yt;for(e=0;e>18&63],n+=s[o>>12&63],n+=s[o>>6&63],n+=s[63&o]),o=(o<<8)+t[e];return 0==(i=r%3)?(n+=s[o>>18&63],n+=s[o>>12&63],n+=s[o>>6&63],n+=s[63&o]):2===i?(n+=s[o>>10&63],n+=s[o>>4&63],n+=s[o<<2&63],n+=s[64]):1===i&&(n+=s[o>>2&63],n+=s[o<<4&63],n+=s[64],n+=s[64]),n}}),qt=Object.prototype.hasOwnProperty,Xt=Object.prototype.toString,Jt=new St("tag:yaml.org,2002:omap",{kind:"sequence",resolve:function(t){if(null===t)return!0;var e,i,n,o,r,s=[],a=t;for(e=0,i=a.length;e>10),56320+(t-65536&1023))}for(var Ee=new Array(256),Te=new Array(256),Oe=0;Oe<256;Oe++)Ee[Oe]=xe(Oe)?1:0,Te[Oe]=xe(Oe);function Se(t,e){this.input=t,this.filename=e.filename||null,this.schema=e.schema||ne,this.onWarning=e.onWarning||null,this.legacy=e.legacy||!1,this.json=e.json||!1,this.listener=e.listener||null,this.implicitTypes=this.schema.compiledImplicit,this.typeMap=this.schema.compiledTypeMap,this.length=t.length,this.position=0,this.line=0,this.lineStart=0,this.lineIndent=0,this.firstTabInLine=-1,this.documents=[]}function Me(t,e){var i={name:t.filename,buffer:t.input.slice(0,-1),position:t.position,line:t.line,column:t.position-t.lineStart};return i.snippet=Et(i),new wt(e,i)}function Ie(t,e){throw Me(t,e)}function Ne(t,e){t.onWarning&&t.onWarning.call(null,Me(t,e))}var $e={YAML:function(t,e,i){var n,o,r;null!==t.version&&Ie(t,"duplication of %YAML directive"),1!==i.length&&Ie(t,"YAML directive accepts exactly one argument"),null===(n=/^([0-9]+)\.([0-9]+)$/.exec(i[0]))&&Ie(t,"ill-formed argument of the YAML directive"),o=parseInt(n[1],10),r=parseInt(n[2],10),1!==o&&Ie(t,"unacceptable YAML version of the document"),t.version=i[0],t.checkLineBreaks=r<2,1!==r&&2!==r&&Ne(t,"unsupported YAML version of the document")},TAG:function(t,e,i){var n,o;2!==i.length&&Ie(t,"TAG directive accepts exactly two arguments"),n=i[0],o=i[1],me.test(n)||Ie(t,"ill-formed tag handle (first argument) of the TAG directive"),oe.call(t.tagMap,n)&&Ie(t,'there is a previously declared suffix for "'+n+'" tag handle'),ve.test(o)||Ie(t,"ill-formed tag prefix (second argument) of the TAG directive");try{o=decodeURIComponent(o)}catch(e){Ie(t,"tag prefix is malformed: "+o)}t.tagMap[n]=o}};function Re(t,e,i,n){var o,r,s,a;if(e1&&(t.result+=Ct.repeat("\n",e-1))}function He(t,e){var i,n,o=t.tag,r=t.anchor,s=[],a=!1;if(-1!==t.firstTabInLine)return!1;for(null!==t.anchor&&(t.anchorMap[t.anchor]=s),n=t.input.charCodeAt(t.position);0!==n&&(-1!==t.firstTabInLine&&(t.position=t.firstTabInLine,Ie(t,"tab characters must not be used in indentation")),45===n)&&be(t.input.charCodeAt(t.position+1));)if(a=!0,t.position++,Be(t,!0,-1)&&t.lineIndent<=e)s.push(null),n=t.input.charCodeAt(t.position);else if(i=t.line,Ze(t,e,ae,!1,!0),s.push(t.result),Be(t,!0,-1),n=t.input.charCodeAt(t.position),(t.line===i||t.lineIndent>e)&&0!==n)Ie(t,"bad indentation of a sequence entry");else if(t.lineIndente?f=1:t.lineIndent===e?f=0:t.lineIndente?f=1:t.lineIndent===e?f=0:t.lineIndente)&&(y&&(s=t.line,a=t.lineStart,c=t.position),Ze(t,e,ce,!0,o)&&(y?m=t.result:v=t.result),y||(je(t,p,d,f,m,v,s,a,c),f=m=v=null),Be(t,!0,-1),l=t.input.charCodeAt(t.position)),(t.line===r||t.lineIndent>e)&&0!==l)Ie(t,"bad indentation of a mapping entry");else if(t.lineIndent=0))break;0===o?Ie(t,"bad explicit indentation width of a block scalar; it cannot be less than one"):c?Ie(t,"repeat of an indentation width identifier"):(l=e+o-1,c=!0)}if(ge(r)){do{r=t.input.charCodeAt(++t.position)}while(ge(r));if(35===r)do{r=t.input.charCodeAt(++t.position)}while(!_e(r)&&0!==r)}for(;0!==r;){for(Fe(t),t.lineIndent=0,r=t.input.charCodeAt(t.position);(!c||t.lineIndentl&&(l=t.lineIndent),_e(r))h++;else{if(t.lineIndent0){for(o=s,r=0;o>0;o--)(s=ke(a=t.input.charCodeAt(++t.position)))>=0?r=(r<<4)+s:Ie(t,"expected hexadecimal character");t.result+=Ae(r),t.position++}else Ie(t,"unknown escape sequence");i=n=t.position}else _e(a)?(Re(t,i,n,!0),Ve(t,Be(t,!1,e)),i=n=t.position):t.position===t.lineStart&&De(t)?Ie(t,"unexpected end of the document within a double quoted scalar"):(t.position++,n=t.position)}Ie(t,"unexpected end of the stream within a double quoted scalar")}(t,p)?v=!0:function(t){var e,i,n;if(42!==(n=t.input.charCodeAt(t.position)))return!1;for(n=t.input.charCodeAt(++t.position),e=t.position;0!==n&&!be(n)&&!Ce(n);)n=t.input.charCodeAt(++t.position);return t.position===e&&Ie(t,"name of an alias node must contain at least one character"),i=t.input.slice(e,t.position),oe.call(t.anchorMap,i)||Ie(t,'unidentified alias "'+i+'"'),t.result=t.anchorMap[i],Be(t,!0,-1),!0}(t)?(v=!0,null===t.tag&&null===t.anchor||Ie(t,"alias node should not have any properties")):function(t,e,i){var n,o,r,s,a,c,l,h,u=t.kind,p=t.result;if(be(h=t.input.charCodeAt(t.position))||Ce(h)||35===h||38===h||42===h||33===h||124===h||62===h||39===h||34===h||37===h||64===h||96===h)return!1;if((63===h||45===h)&&(be(n=t.input.charCodeAt(t.position+1))||i&&Ce(n)))return!1;for(t.kind="scalar",t.result="",o=r=t.position,s=!1;0!==h;){if(58===h){if(be(n=t.input.charCodeAt(t.position+1))||i&&Ce(n))break}else if(35===h){if(be(t.input.charCodeAt(t.position-1)))break}else{if(t.position===t.lineStart&&De(t)||i&&Ce(h))break;if(_e(h)){if(a=t.line,c=t.lineStart,l=t.lineIndent,Be(t,!1,-1),t.lineIndent>=e){s=!0,h=t.input.charCodeAt(t.position);continue}t.position=r,t.line=a,t.lineStart=c,t.lineIndent=l;break}}s&&(Re(t,o,r,!1),Ve(t,t.line-a),o=r=t.position,s=!1),ge(h)||(r=t.position+1),h=t.input.charCodeAt(++t.position)}return Re(t,o,r,!1),!!t.result||(t.kind=u,t.result=p,!1)}(t,p,re===i)&&(v=!0,null===t.tag&&(t.tag="?")),null!==t.anchor&&(t.anchorMap[t.anchor]=t.result)):0===f&&(v=a&&He(t,d))),null===t.tag)null!==t.anchor&&(t.anchorMap[t.anchor]=t.result);else if("?"===t.tag){for(null!==t.result&&"scalar"!==t.kind&&Ie(t,'unacceptable node kind for ! tag; it should be "scalar", not "'+t.kind+'"'),c=0,l=t.implicitTypes.length;c"),null!==t.result&&u.kind!==t.kind&&Ie(t,"unacceptable node kind for !<"+t.tag+'> tag; it should be "'+u.kind+'", not "'+t.kind+'"'),u.resolve(t.result,t.tag)?(t.result=u.construct(t.result,t.tag),null!==t.anchor&&(t.anchorMap[t.anchor]=t.result)):Ie(t,"cannot resolve a node with !<"+t.tag+"> explicit tag")}return null!==t.listener&&t.listener("close",t),null!==t.tag||null!==t.anchor||v}function ze(t){var e,i,n,o,r=t.position,s=!1;for(t.version=null,t.checkLineBreaks=t.legacy,t.tagMap=Object.create(null),t.anchorMap=Object.create(null);0!==(o=t.input.charCodeAt(t.position))&&(Be(t,!0,-1),o=t.input.charCodeAt(t.position),!(t.lineIndent>0||37!==o));){for(s=!0,o=t.input.charCodeAt(++t.position),e=t.position;0!==o&&!be(o);)o=t.input.charCodeAt(++t.position);for(n=[],(i=t.input.slice(e,t.position)).length<1&&Ie(t,"directive name must not be less than one character in length");0!==o;){for(;ge(o);)o=t.input.charCodeAt(++t.position);if(35===o){do{o=t.input.charCodeAt(++t.position)}while(0!==o&&!_e(o));break}if(_e(o))break;for(e=t.position;0!==o&&!be(o);)o=t.input.charCodeAt(++t.position);n.push(t.input.slice(e,t.position))}0!==o&&Fe(t),oe.call($e,i)?$e[i](t,i,n):Ne(t,'unknown document directive "'+i+'"')}Be(t,!0,-1),0===t.lineIndent&&45===t.input.charCodeAt(t.position)&&45===t.input.charCodeAt(t.position+1)&&45===t.input.charCodeAt(t.position+2)?(t.position+=3,Be(t,!0,-1)):s&&Ie(t,"directives end mark is expected"),Ze(t,t.lineIndent-1,ce,!1,!0),Be(t,!0,-1),t.checkLineBreaks&&de.test(t.input.slice(r,t.position))&&Ne(t,"non-ASCII line breaks are interpreted as content"),t.documents.push(t.result),t.position===t.lineStart&&De(t)?46===t.input.charCodeAt(t.position)&&(t.position+=3,Be(t,!0,-1)):t.position=0;a--)(o=t[a])&&(s=(r<3?o(s):r>3?o(e,i,s):o(e,i))||s);return r>3&&s&&Object.defineProperty(e,i,s),s};let ii=class extends at{constructor(){super(...arguments),this.onKeyDownFired=!1}getRokuId(t){return(this.haAction?.keyboard_id??"").split(".")[0]!=t?"media_player"===t?this.haAction?.media_player_id:this.haAction?.remote_id:this.haAction?.keyboard_id}forceCursorToEnd(){this.textarea.selectionStart=this.textarea.value.length,this.textarea.selectionEnd=this.textarea.value.length}forceCursorToEndEvent(t){t.preventDefault(),this.forceCursorToEnd()}kodiOnKeyDown(t){if(t.stopImmediatePropagation(),["Backspace","Enter"].includes(t.key)){const t=this.textarea?.value??"";this.hass.callService("kodi","call_method",{entity_id:this.haAction?.keyboard_id,method:"Input.SendText",text:t,done:!1})}}kodiOnInput(t){t.stopImmediatePropagation();const e=this.textarea?.value??"";this.hass.callService("kodi","call_method",{entity_id:this.haAction?.keyboard_id,method:"Input.SendText",text:e,done:!1})}rokuOnKeyDown(t){t.stopImmediatePropagation(),this.forceCursorToEnd();const e=t.key,i={Backspace:"backspace",Enter:"enter"}[e??""];i&&(this.onKeyDownFired=!0,this.hass.callService("remote","send_command",{entity_id:this.getRokuId("remote"),command:i}),"Enter"==e&&this.closeDialog())}rokuOnInput(t){t.stopImmediatePropagation(),this.forceCursorToEnd();const e=t.inputType??"",i=t.data??"";if(i&&"insertText"==e)this.hass.callService("remote","send_command",{entity_id:this.haAction?.keyboard_id,command:`Lit_${i}`});else if(!this.onKeyDownFired){const t={deleteContentBackward:"backspace",insertLineBreak:"enter"}[e??""];t&&this.hass.callService("remote","send_command",{entity_id:this.getRokuId("remote"),command:t})}this.onKeyDownFired=!1}fireTvOnKeyDown(t){t.stopImmediatePropagation(),this.forceCursorToEnd();const e=t.key,i={Backspace:"67",Enter:"66"}[e??""];if(i){let t,n;this.onKeyDownFired=!0,"media_player"===this.haAction?.keyboard_id?(t="androidtv",n="adb_command"):(t="remote",n="send_command"),this.hass.callService(t,n,{entity_id:this.haAction?.keyboard_id,command:`input keyevent ${i}`}),"Enter"==e&&this.closeDialog()}}fireTvOnInput(t){t.stopImmediatePropagation(),this.forceCursorToEnd();const e=t.inputType??"",i=t.data??"";if(i&&"insertText"==e)this.androidTvSendText(i);else if(!this.onKeyDownFired){const t={deleteContentBackward:"67",insertLineBreak:"66"}[e??""];if(t){let e,i;"media_player"===this.haAction?.keyboard_id?(e="androidtv",i="adb_command"):(e="remote",i="send_command"),this.hass.callService(e,i,{entity_id:this.haAction?.keyboard_id,command:`input keyevent ${t}`})}}this.onKeyDownFired=!1}androidTvOnKeyDown(t){t.stopImmediatePropagation(),this.forceCursorToEnd();const e=t.key,i={Backspace:"DEL",Enter:"ENTER"}[e??""];i&&(this.onKeyDownFired=!0,this.hass.callService("remote","send_command",{entity_id:this.haAction?.remote_id,command:i}),"Enter"==e&&this.closeDialog())}androidTvOnInput(t){t.stopImmediatePropagation(),this.forceCursorToEnd();const e=t.inputType??"",i=t.data??"";if(i&&"insertText"==e)this.androidTvSendText(i);else if(!this.onKeyDownFired){const t={deleteContentBackward:"DEL",insertLineBreak:"ENTER"}[e??""];t&&(this.hass.callService("remote","send_command",{entity_id:this.haAction?.remote_id,command:t}),"insertLineBreak"==e&&this.closeDialog())}this.onKeyDownFired=!1}androidTvSendText(t){let e,i;"media_player"===this.domain?(e="androidtv",i="adb_command"):(e="remote",i="send_command"),this.hass.callService(e,i,{entity_id:this.haAction?.keyboard_id,command:`input text "${t}"`})}keyboardOnPaste(t){t.stopImmediatePropagation(),"KODI"!=this.haAction?.platform&&this.forceCursorToEnd();const e=t.clipboardData?.getData("Text");if(e)switch(this.haAction?.platform){case"KODI":this.hass.callService("kodi","call_method",{entity_id:this.haAction?.keyboard_id,method:"Input.SendText",text:this.textarea?.value??"",done:!1});break;case"ROKU":this.hass.callService("remote","send_command",{entity_id:this.haAction?.keyboard_id,command:`Lit_${e}`});break;default:{let t,i;"remote"===this.domain?(t="remote",i="send_command"):(t="androidtv",i="adb_command"),this.hass.callService(t,i,{entity_id:this.haAction?.keyboard_id,command:`input text "${e}"`});break}}}textBox(t){const e=this.textarea?.value;if(e)switch(this.haAction?.platform){case"KODI":this.hass.callService("kodi","call_method",{entity_id:this.haAction?.keyboard_id,method:"Input.SendText",text:e,done:!1});break;case"ROKU":this.hass.callService("remote","send_command",{entity_id:this.getRokuId("remote"),command:`Lit_${e}`});break;default:{let t,i;"remote"===this.domain?(t="remote",i="send_command"):(t="androidtv",i="adb_command"),this.hass.callService(t,i,{entity_id:this.haAction?.keyboard_id,command:`input text "${e}"`});break}}this.closeDialog()}search(t){const e=this.textarea?.value;if(e)switch(this.haAction?.platform){case"KODI":{const t=this.haAction?.keyboard_id;Promise.resolve(this.hass.callService("kodi","call_method",{entity_id:t,method:"Addons.ExecuteAddon",addonid:"script.globalsearch"})),setTimeout((()=>{this.hass.callService("kodi","call_method",{entity_id:t,method:"Input.SendText",text:e,done:!0})}),1e3);break}case"ROKU":this.hass.callService("roku","search",{entity_id:this.getRokuId("media_player"),keyword:e});break;default:{let t,i;"remote"===this.domain?(t="remote",i="send_command"):(t="androidtv",i="adb_command"),this.hass.callService(t,i,{entity_id:this.haAction?.keyboard_id,command:`am start -a "android.search.action.GLOBAL_SEARCH" --es query "${e}"`});break}}this.closeDialog()}showDialog(t){this.haAction=t.detail,this.domain=(this.haAction?.keyboard_id??"").split(".")[0];const e=this.shadowRoot?.querySelector("dialog");if(e){try{e.showModal()}catch{e.close(),e.showModal()}window.addEventListener("popstate",(()=>this.closeDialog()))}this.textarea=this.shadowRoot?.querySelector("textarea");const i=this.textarea;setTimeout((()=>{i&&i.focus()}),.4)}cancelDialog(t){t.preventDefault(),this.closeDialog()}closeDialog(t){const e=this.shadowRoot?.querySelector("dialog");if(e){try{e.close()}catch{e.showModal(),e.close()}window.removeEventListener("popstate",(()=>this.closeDialog()))}this.textarea&&(this.textarea.value="",this.textarea.blur()),this.haAction=void 0,this.domain=void 0,this.textarea=void 0}buildDialogButton(t,e){return U`
${t}
`}render(){let t,e,i,n,o=U``,r=this.forceCursorToEndEvent;switch(this.haAction?.action){case"search":t="Search for something...",o=U`${this.buildDialogButton("Search",this.search)}${this.buildDialogButton("Close",this.closeDialog)}`;break;case"textbox":t="Type something...",o=U`${this.buildDialogButton("Send",this.textBox)}${this.buildDialogButton("Close",this.closeDialog)}`;break;default:switch(this.haAction?.platform){case"KODI":e=this.kodiOnInput,i=this.kodiOnKeyDown,r=void 0;break;case"ROKU":e=this.rokuOnInput,i=this.rokuOnKeyDown;break;case"FIRE TV":e=this.fireTvOnInput,i=this.fireTvOnKeyDown;break;default:e=this.androidTvOnInput,i=this.androidTvOnKeyDown}t="Type something...",n=this.keyboardOnPaste,o=this.buildDialogButton("Close",this.closeDialog)}t=this.haAction?.keyboard_prompt??t;const s=U``;return U`${s}
${o}
`}static get styles(){return s`:host{-webkit-tap-highlight-color:transparent;-webkit-tap-highlight-color:transparent}dialog{height:0;width:0;display:inline-flex;flex-direction:column;position:fixed;z-index:9;border:none;background:var(--ha-card-background,var(--card-background-color,#fff));border-radius:var(--ha-card-border-radius,12px);opacity:0;transition:all .1s ease-in-out;pointer-events:none}dialog[open]{height:fit-content;width:85%;opacity:1;transition:all .1s ease-in-out;pointer-events:all}textarea{position:relative;height:180px;padding:8px;outline:0;background:0 0;border:none;resize:none;font-family:inherit;font-weight:500;font-size:30px}.buttons{height:36px;display:inline-flex;flex-direction:row-reverse;justify-content:space-between;margin:0 12px}.button{height:100%;width:min-content;align-content:center;cursor:pointer;border-radius:var(--mdc-shape-small,4px);overflow:hidden}button{height:100%;width:100%;background:0 0;opacity:1;border:none;overflow:hidden;cursor:pointer;padding:0}@media (hover:hover){button:hover{background:var(--ha-ripple-color);opacity:var(--md-ripple-hover-opacity)}}button:active{background:var(--ha-ripple-color);opacity:var(--md-ripple-pressed-opacity)}.button span{font-family:inherit;font-size:var(--paper-font-body1_-_font-size);font-weight:600;text-transform:uppercase;color:var(--mdc-theme-primary,#6200ee);user-select:none;-webkit-user-select:none;-moz-user-select:none;position:relative;top:-32px;padding:0 8px;pointer-events:none}dialog::backdrop{background:#000;opacity:.7}`}};var ni,oi,ri;ei([pt()],ii.prototype,"hass",void 0),ei([dt()],ii.prototype,"haAction",void 0),ii=ei([lt("keyboard-dialog")],ii),(ri=ni||(ni={})).language="language",ri.system="system",ri.comma_decimal="comma_decimal",ri.decimal_comma="decimal_comma",ri.space_comma="space_comma",ri.none="none",function(t){t.language="language",t.system="system",t.am_pm="12",t.twenty_four="24"}(oi||(oi={})),new Set(["fan","input_boolean","light","switch","group","automation"]);new Set(["call-service","divider","section","weblink","cast","select"]);var si=function(t){!function(t,e,i,n){n=n||{},i=null==i?{}:i;var o=new Event(e,{bubbles:void 0===n.bubbles||n.bubbles,cancelable:Boolean(n.cancelable),composed:void 0===n.composed||n.composed});o.detail=i,t.dispatchEvent(o)}(window,"haptic",t)};function ai(t){let e=[];for(const i in t)if("object"==typeof t[i]){const n=ai(t[i]);e=e.concat(n.map((t=>i+"."+t)))}else e.push(i);return e}function ci(t,e){const i=e.split(".");if(null!=t)return 1==i.length?t[i[0]]:ci(t[i[0]],i.splice(1).join("."))}function li(t,e,i){const n=e.split(".");return 1==n.length?t[n[0]]=i:(n[0]in t&&"object"==typeof t[n[0]]||(/^-?\d+$/.test(n[1])?t[n[0]]=new Array(parseInt(n[1])):t[n[0]]={}),li(t[n[0]],n.splice(1).join("."),i)),t}var hi=function(t,e,i,n){var o,r=arguments.length,s=r<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,i,n);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(s=(r<3?o(s):r>3?o(e,i,s):o(e,i))||s);return r>3&&s&&Object.defineProperty(e,i,s),s};class ui extends at{constructor(){super(...arguments),this.autofillEntityId=!1,this.renderRipple=!0,this.value=0,this.getValueFromHass=!0,this.fireMouseEvent=!0,this.swiping=!1}fireHapticEvent(t){(this.renderTemplate(this.config.haptics)??1)&&si(t)}endAction(){this.buttonPressStart=void 0,this.buttonPressEnd=void 0,this.swiping=!1,this.initialX=void 0,this.initialY=void 0}sendAction(t,e=this.config){let i;switch(t){case"momentary_start_action":i=e.momentary_start_action;break;case"momentary_end_action":i=e.momentary_end_action;break;case"multi_hold_action":i=e.multi_hold_action??e.hold_action??e.multi_tap_action??e.tap_action;break;case"multi_double_tap_action":i=e.multi_double_tap_action??e.double_tap_action??e.multi_tap_action??e.tap_action;break;case"multi_tap_action":i=e.multi_tap_action??e.tap_action;break;case"hold_action":i=e.hold_action??e.tap_action;break;case"double_tap_action":i=e.double_tap_action??e.tap_action;break;default:i=e.tap_action}if(i&&this.handleConfirmation(i))try{switch(i.action){case"navigate":this.navigate(i);break;case"url":this.toUrl(i);break;case"assist":this.assist(i);break;case"more-info":this.moreInfo(i);break;case"call-service":this.callService(i);break;case"source":this.changeSource(i);break;case"key":this.sendCommand(i,t);break;case"fire-dom-event":this.fireDomEvent(i);break;case"textbox":case"search":case"keyboard":this.keyboard(i)}}catch(t){throw this.endAction(),t}}sendCommand(t,e){const i={entity_id:this.renderTemplate(t.remote_id),command:this.renderTemplate(t.key)};"hold_action"!=e||this.config.hold_action||(i.hold_secs=.5),this.hass.callService("remote","send_command",i)}changeSource(t){this.hass.callService("remote","turn_on",{entity_id:this.renderTemplate(t.remote_id),activity:this.renderTemplate(t.source)})}callService(t){const e=this.renderTemplate(t.service),[i,n]=e.split("."),o=structuredClone(t.data);for(const t in o)if(Array.isArray(o[t]))for(const e in o[t])o[t][e]=this.renderTemplate(o[t][e]);else o[t]=this.renderTemplate(o[t]);let r=structuredClone(t.target);for(const t in r)if(Array.isArray(r[t]))for(const e in r[t])r[t][e]=this.renderTemplate(r[t][e]);else r[t]=this.renderTemplate(r[t]);if(this.renderTemplate(this.autofillEntityId)){let e;switch(i){case"remote":e=t.remote_id;break;case"media_player":case"kodi":case"denonavr":e=t.media_player_id}!e||o?.entity_id||o?.device_id||o?.area_id||o?.label_id||r?.entity_id||r?.device_id||r?.area_id||r?.label_id||(r={...r,entity_id:this.renderTemplate(e)})}this.hass.callService(i,n,o,r)}navigate(t){const e=this.renderTemplate(t.navigation_path)??"",i=this.renderTemplate(t.navigation_replace)??!1;if(e.includes("//"))return void console.error('Protocol detected in navigation path. To navigate to another website use the action "url" with the key "url_path" instead.');1==i?window.history.replaceState(window.history.state?.root?{root:!0}:null,"",e):window.history.pushState(null,"",e);const n=new Event("location-changed",{bubbles:!1,cancelable:!0,composed:!1});n.detail={replace:1==i},window.dispatchEvent(n)}toUrl(t){let e=this.renderTemplate(t.url_path)??"";e.includes("//")||(e=`https://${e}`),window.open(e)}assist(t){this.hass?.auth?.external?.config?.hasAssist?this.hass?.auth?.external?.fireMessage({type:"assist/show",payload:{pipeline_id:t.pipeline_id,start_listening:t.start_listening}}):window.open(`${window.location.href}?conversation=1`,"_self")}moreInfo(t){const e=this.renderTemplate(t.target?.entity_id??t.data?.entity_id),i=new Event("hass-more-info",{bubbles:!0,cancelable:!0,composed:!0});i.detail={entityId:e},this.dispatchEvent(i)}keyboard(t){const e=new Event("keyboard-dialog-open",{composed:!0,bubbles:!0});e.detail=this.deepRenderTemplate(t),this.getRootNode().querySelector("keyboard-dialog").shadowRoot?.querySelector("dialog")?.dispatchEvent(e)}fireDomEvent(t){const e=new Event(t.event_type??"ll-custom",{composed:!0,bubbles:!0});e.detail=t,this.dispatchEvent(e)}handleConfirmation(t){if("confirmation"in t){let e=t.confirmation;if("string"==typeof e&&(e=this.renderTemplate(t.confirmation)),0!=e){this.fireHapticEvent("warning");let i="";if(i=1!=e&&e?.text?this.renderTemplate(e?.text):`Are you sure you want to run action '${this.renderTemplate(t.action)}'?`,1==e){if(!confirm(i))return!1}else if(e?.exemptions){if(!e.exemptions?.map((t=>this.renderTemplate(t.user))).includes(this.hass.user.id)&&!confirm(i))return!1}else if(!confirm(i))return!1}}return!0}setValue(){if(this.entityId=this.renderTemplate(this.config.tap_action?.data?.entity_id??""),this.getValueFromHass&&this.entityId){clearInterval(this.valueUpdateInterval),this.valueUpdateInterval=void 0;let t=(this.renderTemplate(this.config.value_attribute)??"state").toLowerCase();if(this.hass.states[this.entityId])if("state"==t)this.value=this.hass.states[this.entityId].state;else{let e;const i=t.match(/\[\d+\]$/);if(i){const n=parseInt(i[0].replace(/\[|\]/g,""));t=t.replace(i[0],""),e=this.hass.states[this.entityId].attributes[t],e&&Array.isArray(e)&&e.length&&(e=e[n])}else e=this.hass.states[this.entityId].attributes[t];if(null!=e||"elapsed"==t)switch(t){case"brightness":this.value=Math.round(100*parseInt(e??0)/255);break;case"media_position":try{const t=()=>{"playing"==this.hass.states[this.entityId].state?this.value=Math.min(Math.floor(Math.floor(e)+(Date.now()-Date.parse(this.hass.states[this.entityId].attributes.media_position_updated_at))/1e3),Math.floor(this.hass.states[this.entityId].attributes.media_duration)):this.value=e};t(),this.valueUpdateInterval=setInterval(t,500)}catch(t){console.error(t),this.value=e}break;case"elapsed":if(this.entityId.startsWith("timer.")){if("idle"==this.hass.states[this.entityId].state)this.value=0;else{const t=this.hass.states[this.entityId].attributes.duration.split(":"),e=3600*parseInt(t[0])+60*parseInt(t[1])+parseInt(t[2]),i=Date.parse(this.hass.states[this.entityId].attributes.finishes_at);try{const t=()=>{if("active"==this.hass.states[this.entityId].state){const t=(i-Date.now())/1e3,n=Math.floor(e-t);this.value=Math.min(n,e)}else{const t=this.hass.states[this.entityId].attributes.remaining.split(":"),i=3600*parseInt(t[0])+60*parseInt(t[1])+parseInt(t[2]);this.value=Math.floor(e-i)}};t(),this.valueUpdateInterval=setInterval(t,500)}catch(t){console.error(t),this.value=0}}break}default:this.value=e}else this.value=e}else this.value=void 0}}renderTemplate(t,e){let i=0;this.buttonPressStart&&this.buttonPressEnd&&(i=(this.buttonPressEnd-this.buttonPressStart)/1e3),e={VALUE:this.value,HOLD_SECS:i??0,value:this.value,hold_secs:i??0,config:{...this.config,entity:this.entityId},...e};let n=(e={render:t=>this.renderTemplate(t,e),...e}).value;null!=n&&"number"==typeof n&&null!=this.precision&&(n=Number(n).toFixed(this.precision),e={...e,VALUE:n,value:n});const o=(0,gt.renderTemplate)(this.hass,t,e);if(o!=t)return o;if("string"==typeof t)for(const i of["VALUE","HOLD_SECS"]){if(t==i)return e[i];t.toString().includes(i)&&(t=t.replace(new RegExp(i,"g"),e[i]??""))}return t}deepRenderTemplate(t,e){const i=structuredClone(t),n=ai(i);for(const t of n)li(i,t,this.renderTemplate(ci(i,t),e));return i}buildIcon(t,e){if(t=this.renderTemplate(t??"",e)){let e=U``;return e=t.includes(":")?U``:U``,U`
${e}
`}return""}buildLabel(t,e){if(t){const i=this.renderTemplate(t,e);if(i)return U`
${i}
`}return""}buildRipple(){return this.renderRipple?U``:""}buildStyle(t={},e){const i=structuredClone(t);for(const t in i)i[t]=this.renderTemplate(i[t],e);return i}buildStyles(t=this.config,e){return t.styles?U``:""}onStart(t){}onEnd(t){}onMove(t){}onMouseDown(t){this.fireMouseEvent&&this.onStart(t)}onMouseUp(t){this.fireMouseEvent&&this.onEnd(t),this.fireMouseEvent=!0}onMouseMove(t){this.fireMouseEvent&&this.onMove(t)}onTouchStart(t){this.fireMouseEvent=!1,this.onStart(t)}onTouchEnd(t){this.fireMouseEvent=!1,this.onEnd(t)}onTouchMove(t){this.fireMouseEvent=!1,this.onMove(t)}onContextMenu(t){if(!this.fireMouseEvent)return t.preventDefault(),t.stopPropagation(),!1}toggleRipple(){this.cancelRippleToggle(),this.renderRippleTransition=setTimeout((()=>this.rippleTransition=!1),400),this.renderRippleOff=setTimeout((()=>this.renderRipple=!1),800),this.renderRippleOn=setTimeout((()=>this.cancelRippleToggle()),850)}cancelRippleToggle(){clearTimeout(this.renderRippleOff),clearTimeout(this.renderRippleOn),clearTimeout(this.renderRippleTransition),this.renderRippleOff=void 0,this.renderRippleOn=void 0,this.renderRippleTransition=void 0,this.rippleTransition=!0,this.renderRipple=!0}static get styles(){return s`:host{display:flex;flex-flow:column;place-content:center space-evenly;align-items:center;position:relative;border:none;border-radius:10px;padding:0;box-sizing:border-box;outline:0;overflow:visible;font-size:inherit;color:inherit;-webkit-tap-highlight-color:transparent;-webkit-tap-highlight-color:transparent}ha-icon,svg{display:inline-flex;flex-direction:column;justify-content:center;text-align:center;align-items:center;vertical-align:middle;height:var(--size,48px);width:var(--size,48px);z-index:2;pointer-events:none}md-ripple.transition-on{opacity:1 transition: opacity 375ms linear}md-ripple.transition-off{opacity:0;transition:opacity 375ms linear}.icon{pointer-events:none;position:relative;flex-flow:column;place-content:center;z-index:2;display:var(--icon-display,inline-flex);transform:var(--icon-transform);color:var(--icon-color,var(--primary-text-color));filter:var(--icon-filter, none)}.label{position:relative;pointer-events:none;justify-content:center;align-items:center;height:15px;line-height:15px;width:inherit;margin:0;font-family:inherit;font-size:12px;font-weight:700;z-index:2;display:var(--label-display,inline-flex);transform:var(--label-transform);color:var(--label-color,inherit);filter:var(--label-filter, none)}`}}hi([pt({attribute:!1})],ui.prototype,"hass",void 0),hi([pt({attribute:!1})],ui.prototype,"config",void 0),hi([pt({attribute:!1})],ui.prototype,"icons",void 0),hi([pt({attribute:!1})],ui.prototype,"autofillEntityId",void 0),hi([dt()],ui.prototype,"renderRipple",void 0),hi([dt()],ui.prototype,"renderRippleOff",void 0),hi([dt()],ui.prototype,"renderRippleOn",void 0),hi([dt()],ui.prototype,"renderRippleTransition",void 0),hi([dt()],ui.prototype,"rippleTransition",void 0),hi([dt()],ui.prototype,"value",void 0),hi([ft({passive:!0})],ui.prototype,"onMouseDown",null),hi([ft({passive:!0})],ui.prototype,"onMouseMove",null),hi([ft({passive:!0})],ui.prototype,"onTouchStart",null),hi([ft({passive:!0})],ui.prototype,"onTouchMove",null);let pi=class extends ui{constructor(){super(...arguments),this.clickCount=0,this.hold=!1}onClick(t){if(t.stopImmediatePropagation(),this.clickCount++,"none"!=this.renderTemplate(this.config.double_tap_action?.action??"none"))if(this.clickCount>1)this.fireHapticEvent("success"),this.sendAction("double_tap_action"),this.endAction();else{const t="double_tap_window"in(this.config.double_tap_action??{})?this.renderTemplate(this.config.double_tap_action?.double_tap_window):200;this.clickTimer||(this.clickTimer=setTimeout((()=>{this.fireHapticEvent("light"),this.sendAction("tap_action"),this.endAction()}),t))}else this.fireHapticEvent("light"),this.sendAction("tap_action"),this.endAction()}onStart(t){if(this.cancelRippleToggle(),this.swiping=!1,"targetTouches"in t?(this.initialX=t.targetTouches[0].clientX,this.initialY=t.targetTouches[0].clientY):(this.initialX=t.clientX,this.initialY=t.clientY),"none"!=this.renderTemplate(this.config.momentary_start_action?.action??"none"))this.fireHapticEvent("light"),this.buttonPressStart=performance.now(),this.sendAction("momentary_start_action");else if("none"!=this.renderTemplate(this.config.momentary_end_action?.action??"none"))this.fireHapticEvent("light"),this.buttonPressStart=performance.now();else if(!this.holdTimer){const t=this.renderTemplate(this.config.hold_action?.hold_time??500);this.holdTimer=setTimeout((()=>{if(!this.swiping)if(this.hold=!0,"repeat"==this.renderTemplate(this.config.hold_action?.action)){const t=this.renderTemplate(this.config.hold_action?.repeat_delay??100);this.holdInterval||(this.holdInterval=setInterval((()=>{this.fireHapticEvent("selection"),this.sendAction("tap_action")}),t))}else this.fireHapticEvent("medium"),this.sendAction("hold_action")}),t)}}onEnd(t){this.swiping||("none"!=this.renderTemplate(this.config.momentary_end_action?.action??"none")?(this.fireHapticEvent("selection"),this.buttonPressEnd=performance.now(),this.sendAction("momentary_end_action"),this.endAction()):"none"!=this.renderTemplate(this.config.momentary_start_action?.action??"none")?this.endAction():this.hold?(t.stopImmediatePropagation(),t.preventDefault(),this.endAction()):this.onClick(t)),this.toggleRipple()}onMove(t){let e,i;"targetTouches"in t?(e=t.targetTouches[0].clientX,i=t.targetTouches[0].clientY):(e=t.clientX,i=t.clientY);const n=(this.initialX??e)-e,o=(this.initialY??i)-i;Math.abs(Math.abs(n)-Math.abs(o))>24&&(this.endAction(),this.swiping=!0)}onMouseLeave(t){this.endAction(),this.swiping=!0,this.toggleRipple()}onTouchCancel(t){this.endAction(),this.toggleRipple()}endAction(){clearTimeout(this.clickTimer),this.clickTimer=void 0,this.clickCount=0,clearTimeout(this.holdTimer),clearInterval(this.holdInterval),this.holdTimer=void 0,this.holdInterval=void 0,this.hold=!1,super.endAction()}render(){return this.setValue(),U``}static get styles(){return[super.styles,s`:host{align-content:center;text-align:center}button{display:flex;height:inherit;width:inherit;border-radius:var(--size,48px);overflow:visible;cursor:pointer;pointer-events:all;position:relative;opacity:1;padding:0;background:rgb(0,0,0,0);border:none;z-index:1;align-content:center;text-align:center;justify-content:center;align-items:center;-webkit-tap-highlight-color:transparent;-webkit-tap-highlight-color:transparent;--mdc-icon-size:var(--size, 48px)}`]}};pi=function(t,e,i,n){var o,r=arguments.length,s=r<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,i,n);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(s=(r<3?o(s):r>3?o(e,i,s):o(e,i))||s);return r>3&&s&&Object.defineProperty(e,i,s),s}([lt("remote-button")],pi);var di=function(t,e,i,n){var o,r=arguments.length,s=r<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,i,n);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(s=(r<3?o(s):r>3?o(e,i,s):o(e,i))||s);return r>3&&s&&Object.defineProperty(e,i,s),s};let fi=class extends ui{constructor(){super(...arguments),this.showTooltip=!1,this.thumbOffset=0,this.sliderOn=!0,this.currentValue=this.value,this.sliderWidth=0,this.speed=.02,this.range=[0,1],this.step=.01,this.vertical=!1,this.thumbWidth=50,this.resizeObserver=new ResizeObserver((t=>{for(const e of t)this.sliderWidth=this.vertical?e.contentRect.height:e.contentRect.width,this.setThumbOffset()}))}onInput(t){const e=t.currentTarget;if(this.swiping)null==this.value&&(this.getValueFromHass=!0),this.setValue(),this.currentValue=this.value??0,this.setThumbOffset(),this.showTooltip=!1;else{this.getValueFromHass=!1,clearTimeout(this.getValueFromHassTimer),this.value=e.value,this.fireHapticEvent("selection");const t=parseFloat(this.oldValue??this.value??"0"),i=parseFloat(e.value??t);this.newValue=i,this.currentValue=t,this.setThumbOffset(),this.showTooltip=!0,i>this.range[0]&&(this.sliderOn=!0),clearInterval(this.intervalId),this.intervalId=void 0;let n=t;t>i?this.intervalId=setInterval((()=>{n-=this.speed,this.currentValue=n,this.setThumbOffset(),i>=n&&(clearInterval(this.intervalId),this.intervalId=void 0,this.currentValue=i,this.setThumbOffset())}),1):t{n+=this.speed,this.currentValue=n,this.setThumbOffset(),i<=n&&(clearInterval(this.intervalId),this.intervalId=void 0,this.currentValue=i,this.setThumbOffset())}),1)):this.currentValue=i,this.oldValue=i}}onStart(t){const e=t.currentTarget;this.swiping||(this.getValueFromHass=!1,clearTimeout(this.getValueFromHassTimer),this.currentValue=e.value,this.value=e.value,this.setThumbOffset(),this.showTooltip=!0,this.sliderOn=!0)}onEnd(t){this.setThumbOffset(),this.showTooltip=!1,this.setValue(),this.swiping?(this.getValueFromHass=!0,this.setValue(),this.currentValue=this.value??0,this.setThumbOffset(),this.setSliderState(this.currentValue)):(this.newValue||0==this.newValue||(this.newValue=Number(this.value)),this.precision||(this.newValue=Math.trunc(this.newValue)),this.value=this.newValue,this.fireHapticEvent("light"),this.sendAction("tap_action")),this.endAction(),this.resetGetValueFromHass()}onMove(t){if(!this.vertical){let e,i;e="clientX"in t?t.clientX:t.touches[0].clientX,i="clientY"in t?t.clientY:t.touches[0].clientY,null==this.initialY&&(this.initialY=i),null==this.initialX?this.initialX=e:Math.abs(e-this.initialX)this.range[0]}resetGetValueFromHass(){const t=this.renderTemplate(this.config.value_from_hass_delay??1e3);this.getValueFromHassTimer=setTimeout((()=>this.getValueFromHass=!0),t)}endAction(){clearInterval(this.valueUpdateInterval),this.valueUpdateInterval=void 0,super.endAction()}buildBackground(t){const e={};return this.vertical&&(e.transform="rotateZ(270deg)",e.width=this.config.style?.height??`${this.sliderWidth}px`),U`
`}buildTooltip(t){const e=this.buildStyle({"--tooltip-label":`"${this.config?.style?.["--tooltip-label"]??"{{ value }}"}"`,"--tooltip-transform":this.config?.style?.["--tooltip-transform"]??(this.vertical?"translate(-50px, calc(-1 * var(--thumb-offset)))":"translate(var(--thumb-offset), -40px)"),"--tooltip-display":this.config?.style?.["--tooltip-display"]??"initial"},t);return"tooltip"in this.config&&(e["--tooltip-display"]=this.renderTemplate(this.config.tooltip,t)?"initial":"none"),U`
`}buildSlider(t){const e=t.value;this.setSliderState(e);const i={};return"none"==this.renderTemplate(this.config.tap_action?.action,t)&&(i["pointer-events"]="none"),this.vertical&&(i.transform="rotateZ(270deg)",i.width=this.config.style?.height??`${this.sliderWidth}px`),U``}render(){this.setValue(),this.getValueFromHass&&(this.currentValue=this.value);const t={VALUE:this.getValueFromHass?this.value:this.currentValue,value:this.getValueFromHass?this.value:this.currentValue};this.config.range&&(this.range[0]=parseFloat(this.renderTemplate(this.config.range[0],t)),this.range[1]=parseFloat(this.renderTemplate(this.config.range[1],t))),this.speed=(this.range[1]-this.range[0])/50,this.config.step?this.step=Number(this.renderTemplate(this.config.step,t)):this.step=(this.range[1]-this.range[0])/100;const e=this.step.toString().split(".");e.length>1?this.precision=e[1].length:this.precision=0,this.vertical=1==this.renderTemplate(this.config.vertical??!1,t),this.resizeObserver.observe(this.shadowRoot?.querySelector(".container")??this);const i=this.buildStyle(this.config.style??{},t);return this.thumbWidth=parseInt((i["--thumb-width"]??"50").replace("px","")),this.setThumbOffset(),this.style.setProperty("--thumb-offset",`${this.thumbOffset}px`),this.vertical&&(i.width?this.style.setProperty("width",i.width):this.style.width="50px",i.height||(i.height=`${this.sliderWidth}px`)),i["--icon-transform"]||(this.vertical?i["--icon-transform"]="translateY(calc(-1 * var(--thumb-offset)))":i["--icon-transform"]="translateX(var(--thumb-offset))"),U`${this.buildTooltip(t)}
${this.buildBackground(t)}${this.buildSlider(t)} ${this.buildIcon(this.config.icon??"",t)}
`}disconnectedCallback(){super.disconnectedCallback(),this.resizeObserver.disconnect()}static get styles(){return[super.styles,s`:host{display:flex;flex-flow:column;flex-grow:0;place-content:center space-evenly;align-items:center;align-self:stretch;position:relative;height:unset;width:100%;border:none;border-radius:25px;padding:0;box-sizing:border-box;line-height:0;outline:0;overflow:visible;font-size:inherit;color:inherit;pointer-events:none}.container{all:inherit;overflow:hidden;height:50px;align-self:center;color:var(--background,var(--primary-background-color));--color:var(--primary-text-color);--mdc-icon-size:var(--size, 32px)}.background{position:absolute;width:inherit;height:var(--background-height,100%);background:var( --background, var(--primary-background-color) )}.off,.slider{position:absolute;appearance:none;-webkit-appearance:none;-moz-appearance:none;pointer-events:all;height:100%;width:inherit;background:0 0;overflow:hidden}.slider::-webkit-slider-thumb{appearance:none;-webkit-appearance:none;height:50px;width:var(--thumb-width,50px);cursor:pointer;background:var(--color);border-color:rgb(0,0,0,0);z-index:1;box-shadow:var(--thumb-box-shadow,calc(-100vw - (var(--thumb-width,50px)/ 2)) 0 0 100vw var(--color));border-radius:var(--thumb-border-radius,50px)}.slider::-moz-range-thumb{appearance:none;-webkit-appearance:none;height:50px;width:var(--thumb-width,50px);cursor:pointer;background:var(--color);border-color:rgb(0,0,0,0);z-index:1;box-shadow:var(--thumb-box-shadow,calc(-100vw - (var(--thumb-width,50px)/ 2)) 0 0 100vw var(--color));border-radius:var(--thumb-border-radius,50px)}.off::-webkit-slider-thumb{visibility:hidden}.off::-moz-range-thumb{visibility:hidden}.tooltip{z-index:3;background:var(--clear-background-color);color:var(--primary-text-color);position:absolute;border-radius:.8em;padding:.2em .4em;height:20px;width:fit-content;line-height:20px;transform:var(--tooltip-transform);display:var(--tooltip-display)}.faded-out{opacity:0;transition:opacity 180ms ease-in-out 0s,left 180ms ease-in-out 0s,bottom 180ms ease-in-out 0s}.faded-in{opacity:1;transition:opacity 540ms ease-in-out 0s}.tooltip::after{content:var(--tooltip-label)}`]}};di([dt()],fi.prototype,"showTooltip",void 0),di([dt()],fi.prototype,"thumbOffset",void 0),di([dt()],fi.prototype,"sliderOn",void 0),di([dt()],fi.prototype,"currentValue",void 0),di([dt()],fi.prototype,"sliderWidth",void 0),fi=di([lt("remote-slider")],fi);var mi=function(t,e,i,n){var o,r=arguments.length,s=r<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,i,n);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(s=(r<3?o(s):r>3?o(e,i,s):o(e,i))||s);return r>3&&s&&Object.defineProperty(e,i,s),s};let vi=class extends ui{constructor(){super(...arguments),this.clickCount=0,this.hold=!1,this.holdStart=!1,this.holdMove=!1}onClick(t){t.stopImmediatePropagation(),this.clickCount++;const e=this.targetTouches?.length||1;if("none"!=this.renderTemplate(this.config.double_tap_action?.action??"none")||"none"!=this.renderTemplate(this.config.multi_double_tap_action?.action??"none")){const t=`${this.getMultiPrefix()}double_tap_action`;if(this.clickCount>e)this.fireHapticEvent("success"),this.sendAction(t),this.endAction();else if(!this.clickTimer){const e="double_tap_window"in(this.config[t]??{})?this.renderTemplate(this.config[t]?.double_tap_window):200;this.clickTimer=setTimeout((()=>{this.fireHapticEvent("light"),this.sendAction(`${this.getMultiPrefix()}tap_action`),this.endAction()}),e)}}else this.fireHapticEvent("light"),this.sendAction(`${this.getMultiPrefix()}tap_action`),this.endAction()}onStart(t){if(this.cancelRippleToggle(),this.holdStart=!0,this.holdAction||"none"==this.renderTemplate(this.config.momentary_start_action?.action??"none")?this.holdAction||"none"==this.renderTemplate(this.config.momentary_end_action?.action??"none")?this.holdTimer||this.setHoldTimer():(this.fireHapticEvent("light"),this.buttonPressStart=performance.now()):(this.fireHapticEvent("light"),this.buttonPressStart=performance.now(),this.sendAction("momentary_start_action")),"targetTouches"in t){let e=0,i=0;this.targetTouches=t.targetTouches;for(const t of this.targetTouches)e+=t.clientX,i+=t.clientY;this.initialX=e/this.targetTouches.length,this.initialY=i/this.targetTouches.length}else this.initialX=t.clientX,this.initialY=t.clientY}onEnd(t){this.holdAction||"none"==this.renderTemplate(this.config.momentary_end_action?.action??"none")?this.holdAction||"none"==this.renderTemplate(this.config.momentary_start_action?.action??"none")?this.hold||this.holdMove?(t.stopImmediatePropagation(),t.preventDefault(),this.endAction(),"targetTouches"in t&&t.targetTouches?.length&&(this.hold=!0)):"targetTouches"in t&&t.targetTouches.length||this.onClick(t):this.endAction():(this.buttonPressEnd=performance.now(),this.fireHapticEvent("selection"),this.sendAction("momentary_end_action"),this.endAction()),this.toggleRipple()}onMove(t){if(!this.initialX||!this.initialY||!this.holdStart)return;let e=0,i=0;if("targetTouches"in t){this.targetTouches=t.targetTouches;for(const t of this.targetTouches)e+=t.clientX,i+=t.clientY;e/=this.targetTouches.length,i/=this.targetTouches.length}else e=t.clientX||0,i=t.clientY||0;const n=this.initialX-e,o=this.initialY-i;Math.abs(Math.abs(n)-Math.abs(o))>2&&(Math.abs(n)>Math.abs(o)?this.holdAction=n>0?"left":"right":this.holdAction=o>0?"up":"down",this.holdMove||(this.fireHapticEvent("light"),this.sendAction(`${this.getMultiPrefix()}tap_action`,this.getActions()),this.holdMove=!0,this.holdTimer&&(clearTimeout(this.holdTimer),this.holdTimer=void 0,this.setHoldTimer())))}onMouseLeave(t){this.endAction(),this.toggleRipple()}onTouchCancel(t){this.endAction(),this.toggleRipple()}endAction(){clearTimeout(this.holdTimer),clearInterval(this.holdInterval),clearTimeout(this.clickTimer),this.holdTimer=void 0,this.holdInterval=void 0,this.clickTimer=void 0,this.hold=!1,this.holdStart=!1,this.holdMove=!1,this.holdAction=void 0,this.clickCount=0,this.initialX=void 0,this.initialY=void 0,this.targetTouches=void 0,super.endAction()}getActions(){return this.holdAction?this.directionActions[this.holdAction]:this.config}getMultiPrefix(){return this.targetTouches&&this.targetTouches.length>1?"multi_":""}setHoldTimer(){const t=`${this.getMultiPrefix()}hold_action`,e=this.getActions(),i=this.renderTemplate(e[t]?.hold_time??500);this.holdTimer=setTimeout((()=>{this.hold=!0;const t=this.getActions(),e=this.getMultiPrefix();let i="repeat"==this.renderTemplate(t.hold_action?.action),n=this.renderTemplate(t.hold_action?.repeat_delay??100);"multi_"==e&&t.multi_hold_action&&(i="repeat"==this.renderTemplate(t.multi_hold_action?.action),n=this.renderTemplate(t.multi_hold_action?.repeat_delay??100)),i?this.holdInterval||(this.holdInterval=setInterval((()=>{this.fireHapticEvent("selection"),this.sendAction(`${this.getMultiPrefix()}tap_action`,this.getActions())}),n)):(this.fireHapticEvent("medium"),this.sendAction(`${this.getMultiPrefix()}hold_action`,t))}),i)}render(){return this.setValue(),U`${this.buildRipple()}`}static get styles(){return[super.styles,s`:host{display:contents}toucharea{border-radius:32px;flex-grow:1;height:250px;width:-moz-available;width:-webkit-fill-available;width:fill-available;background:var(--primary-background-color,#6f767d);touch-action:none;text-align:center;position:relative;z-index:0;overflow:hidden;--mdc-ripple-press-opacity:0.04}`]}};mi([pt({attribute:!1})],vi.prototype,"directionActions",void 0),vi=mi([lt("remote-touchpad")],vi);var yi=function(t,e,i,n){var o,r=arguments.length,s=r<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,i,n);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(s=(r<3?o(s):r>3?o(e,i,s):o(e,i))||s);return r>3&&s&&Object.defineProperty(e,i,s),s};console.info("%c ANDROID-TV-CARD v3.9.1","color: white; font-weight: bold; background: green");class _i extends at{constructor(){super(...arguments),this.defaultActions={},this.customActions={},this.icons={},this.nRows=0,this.nColumns=0}static get properties(){return{hass:{},config:{}}}static getStubConfig(){return{type:"custom:android-tv-card",rows:[]}}getCardSize(){let t=this.config.rows?.length??0;return this.config.title&&(t+=1),t}async setConfig(t){if(!t)throw new Error("Invalid configuration");t=structuredClone(t),t=this.setToggles(t),t=this.updateDeprecatedKeys(t),this.defaultActions={...structuredClone(ti),...structuredClone(Qe)},this.customActions=t.custom_actions||{},this.customActions.slider={...this.defaultActions.slider,...this.customActions.slider},t.slider_id&&(this.customActions.slider.tap_action.data.entity_id=t.slider_id),this.icons={...structuredClone(qe),...t.custom_icons},this.config=t}updateDeprecatedKeys(t){if("adb_id"in t&&(t.keyboard_id=t.adb_id),"keyboard_mode"in t&&(t.platform=t.keyboard_mode),t.media_player_id&&!t.slider_id&&(t.slider_id=t.media_player_id),"touchpad_height"in t){const e=t.touchpad_style??{};e.height||(e.height=t.touchpad_height),t.touchpad_style=e}if("enable_button_feedback"in t&&(t.button_haptics=t.enable_button_feedback),"enable_touchpad_feedback"in t&&(t.touchpad_haptics=t.enable_touchpad_feedback),!t.rows){const e=[],i=Object.keys(t).filter((t=>t.includes("_row")));for(const n of i){let i=t[n];"string"==typeof i&&(i=[i]),"volume_row"==n?i=["volume_"+i[0]]:"navigation_row"==n&&(i=["navigation_"+i[0]]),e.push(i)}t.rows=e}t.custom_actions={...t.custom_actions,...t.custom_keys,...t.custom_sources};const e=t.custom_actions;for(const i in e){const n=e[i];"svg_path"in n&&(n.icon=n.svg_path);const o=["key","source","service","service_data","data","target","navigation_path","navigation_replace","url_path","confirmation","pipeline_id","start_listening"],r=n.tap_action??{};let s=!1;for(const t of o)t in n&&(s=!0,r[t]=n[t]);s&&(n.tap_action=r),"slider"==i&&("slider_style"in t&&(n.style=t.slider_style),"slider_range"in t&&(n.range=t.slider_range),"slider_step"in t&&(n.step=t.slider_step),"slider_attribute"in t&&(n.value_attribute=t.slider_attribute),"enable_slider_feedback"in t&&(n.haptics=t.enable_slider_feedback));for(const t of Je)if(n[t]){const e=n[t];n.template||e.action||(e.key?e.action="key":e.source?e.action="source":e.service?e.action="call-service":e.navigation_path?e.action="navigate":e.url_path?e.action="url":e.browser_mod?e.action="fire-dom-event":e.pipeline_id||e.start_listening?e.action="assist":e.keyboard_id?e.action="keyboard":e.action="none"),["data","target","service_data"].some((t=>e[t]))&&(e.data={...e.data,...e.service_data,...e.target})}}return t}setToggles(t){const e={button_haptics:!0,touchpad_haptics:!0,enable_button_feedback:!0,enable_touchpad_feedback:!0,enable_double_click:!1,enable_slider_feedback:!0};for(const i in e)i in t||(t[i]=e[i]);return t}getElementConfig(t){const e=this.defaultActions[t]||{};let i=structuredClone(this.customActions[t]||e);if(i.template){const t=this.defaultActions[i.template]||{},e=this.customActions[i.template]||t;i=this.mergeDeep(structuredClone(e),i)}!i.icon&&e.icon&&(i.icon=e?.icon);for(const t of Je)if(!i[t]&&e[t]&&(i[t]=e[t]),i[t]){const e=i[t]??{};switch(e.platform=e.platform??this.config.platform,e.platform?.toUpperCase()){case"KODI":case"ROKU":break;case"FIRE":case"FIRETV":case"FIRE_TV":case"FIRE TV":e.platform="FIRE TV";break;default:e.platform="ANDROID TV"}e.keyboard_id=e.keyboard_id??this.config.keyboard_id,e.media_player_id=e.media_player_id??this.config.media_player_id,e.remote_id=e.remote_id??this.config.remote_id,i[t]=e}return this.config.hold_time&&(i.hold_action&&!i.hold_action?.hold_time&&(i.hold_action.hold_time=this.config.hold_time),i.multi_hold_action&&!i.multi_hold_action?.hold_time&&(i.multi_hold_action.hold_time=this.config.hold_time)),this.config.repeat_delay&&(i.hold_action&&"repeat"==i.hold_action?.action&&!i.hold_action.repeat_delay&&(i.hold_action.repeat_delay=this.config.repeat_delay),i.multi_hold_action&&"repeat"==i.multi_hold_action?.action&&!i.multi_hold_action.repeat_delay&&(i.multi_hold_action.repeat_delay=this.config.repeat_delay)),this.config.double_tap_window&&(i.double_tap_action&&!i.double_tap_action.double_tap_window&&(i.double_tap_action.double_tap_window=this.config.double_tap_window),i.multi_double_tap_action&&!i.multi_double_tap_action.double_tap_window&&(i.multi_double_tap_action.double_tap_window=this.config.double_tap_window)),i}mergeDeep(t,...e){function i(t){return t&&"object"==typeof t&&!Array.isArray(t)}if(!e.length)return t;const n=e.shift();if(i(t)&&i(n))for(const e in n)i(n[e])?(t[e]||Object.assign(t,{[e]:{}}),this.mergeDeep(t[e],n[e])):Object.assign(t,{[e]:n[e]});return this.mergeDeep(t,...e)}buildStyle(t={},e){const i=structuredClone(t);for(const t in i)i[t]=(0,gt.renderTemplate)(this.hass,i[t],e);return i}buildRow(t,e){this.nRows++;const i=`row-${this.nRows}`,n=_t(this.buildStyle({...this.config.row_styles?.rows,...this.config.row_styles?.[i]},e));return U`
${t}
`}buildColumn(t,e){this.nColumns++;const i=`column-${this.nColumns}`,n=_t(this.buildStyle({...this.config.row_styles?.columns,...this.config.row_styles?.[i]},e));return U`
${t}
`}buildButton(t,e){const i=this.getElementConfig(t),n={...this.config.button_style,...i.style};return Object.keys(i).length?(i.style=n,"haptics"in i||(i.haptics=this.config.button_haptics),U``):U`
`}buildVolumeButtons(t){return[this.buildButton("volume_down",t),this.buildButton("volume_mute",t),this.buildButton("volume_up",t)]}buildSlider(){return U``}buildNavButtons(t){return this.buildColumn([this.buildRow([this.buildButton("up",t)],t),this.buildRow([this.buildButton("left",t),this.buildButton("center",t),this.buildButton("right",t)],t),this.buildRow([this.buildButton("down",t)],t)],t)}buildPad(t,e){return U`
${t.map((t=>this.buildButton(t,e)))}
`}buildTouchpad(t){const e=this.getElementConfig("center");if((0,gt.renderTemplate)(this.hass,this.config.enable_double_click,t)&&!e.double_tap_action){const i=(0,gt.renderTemplate)(this.hass,this.config.double_click_keycode,t)??"back",n=this.getElementConfig(i);e.double_tap_action=n.tap_action}if(e.haptics=this.config.touchpad_haptics,e.style=this.config.touchpad_style,(0,gt.renderTemplate)(this.hass,this.config.long_click_keycode,t)&&!e.hold_action){const i=(0,gt.renderTemplate)(this.hass,this.config.long_click_keycode,t)??"center",n=this.getElementConfig(i);e.hold_action=n.tap_action}const i={up:this.getElementConfig("up"),down:this.getElementConfig("down"),left:this.getElementConfig("left"),right:this.getElementConfig("right")};return U``}buildElements(t,e=!1,i={}){"string"==typeof t&&(t=[t]);const n=[];for(let o of t)if(o=(0,gt.renderTemplate)(this.hass,o,i),"string"==typeof o&&o.includes("- ")&&(o=Xe(o)),"object"==typeof o&&null!=o)n.push(this.buildElements(o,!e,i));else switch(o){case"vol_buttons":case"volume_buttons":{const t=this.buildVolumeButtons(i);e&&t.reverse(),n.push(...t);break}case"slider":case"volume_slider":n.push(this.buildSlider());break;case"nav_buttons":case"navigation_buttons":n.push(this.buildNavButtons(i));break;case"dpad":case"d_pad":case"direction_pad":n.push(this.buildPad(["","up","","left","center","right","","down",""],i));break;case"numpad":case"num_pad":case"number_pad":n.push(this.buildPad(["n7","n8","n9","n4","n5","n6","n1","n2","n3"],i));break;case"xpad":case"x_pad":case"gamepad":case"xgamepad":case"x_gamepad":n.push(this.buildPad(["","y","","x","","b","","a",""],i));break;case"npad":case"n_pad":case"ngamepad":case"n_gamepad":n.push(this.buildPad(["","x","","y","","a","","b",""],i));break;case"touchpad":case"nav_touchpad":case"navigation_touchpad":n.push(this.buildTouchpad(i));break;default:n.push(this.buildButton(o,i))}return e?this.buildColumn(n,i):this.buildRow(n,i)}buildDialog(){return U``}openKeyboardDialog(){}render(){if(!this.config||!this.hass)return U``;const t={config:{...this.config,entity:(0,gt.renderTemplate)(this.hass,this.config.remote_id??this.config.media_player_id??this.config.keyboard_id??this.config.slider_id??"")}},e=[];this.nRows=0,this.nColumns=0;for(const i of this.config.rows??[]){const n=this.buildElements(i,!1,t);e.push(n)}return U`${e}${this.buildDialog()}`}static get styles(){return s`ha-card{padding:12px;-webkit-tap-highlight-color:transparent;-webkit-tap-highlight-color:transparent;--md-ripple-hover-opacity:var(--ha-ripple-hover-opacity, 0.08);--md-ripple-pressed-opacity:var( diff --git a/src/classes/remote-button.ts b/src/classes/remote-button.ts index b4d1d766..2ca7653c 100644 --- a/src/classes/remote-button.ts +++ b/src/classes/remote-button.ts @@ -235,6 +235,8 @@ export class RemoteButton extends BaseRemoteElement { text-align: center; justify-content: center; align-items: center; + -webkit-tap-highlight-color: transparent; + -webkit-tap-highlight-color: rgba(0, 0, 0, 0); --mdc-icon-size: var(--size, 48px); }