@lmjs/core 2.0.2 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -59218,8 +59218,8 @@ var _upw = `let _w=self;var files=[];function defer(){var e,t,s=new Promise(((s,
59218
59218
  //# sourceMappingURL=astring.min.js.map
59219
59219
  class WalkerBase{constructor(){this.should_skip=false;this.should_remove=false;this.replacement=null;this.context={skip:()=>this.should_skip=true,remove:()=>this.should_remove=true,replace:node=>this.replacement=node}}replace(parent,prop,index,node){if(parent&&prop){if(index!=null){parent[prop][index]=node}else{parent[prop]=node}}}remove(parent,prop,index){if(parent&&prop){if(index!==null&&index!==void 0){parent[prop].splice(index,1)}else{delete parent[prop]}}}}class SyncWalker extends WalkerBase{constructor(enter,leave){super();this.should_skip=false;this.should_remove=false;this.replacement=null;this.context={skip:()=>this.should_skip=true,remove:()=>this.should_remove=true,replace:node=>this.replacement=node};this.enter=enter;this.leave=leave}visit(node,parent,prop,index){if(node){if(this.enter){const _should_skip=this.should_skip;const _should_remove=this.should_remove;const _replacement=this.replacement;this.should_skip=false;this.should_remove=false;this.replacement=null;this.enter.call(this.context,node,parent,prop,index);if(this.replacement){if(Array.isArray(this.replacement)){var expressions=[];for(let rp=0;rp<this.replacement.length;rp++){expressions.push(this.replacement[rp])}if(this.replacement.length>1){node={"type":"VariableDeclaration","start":node.start,"kind":"let","declarations":expressions,"level":node.level,"scope":node.scope}}else{node={"type":"ExpressionStatement","expression":{"type":"SequenceExpression","expressions":expressions,"level":node.level,"scope":node.scope},"level":node.level,"scope":node.scope}}this.replace(parent,prop,index,node)}else{node=this.replacement;this.replace(parent,prop,index,node)}}if(this.should_remove){this.remove(parent,prop,index)}const skipped=this.should_skip;const removed=this.should_remove;this.should_skip=_should_skip;this.should_remove=_should_remove;this.replacement=_replacement;if(skipped)return node;if(removed)return null}let key;for(key in node){const value=node[key];if(value&&typeof value==="object"){if(Array.isArray(value)){const nodes=value;for(let i=0;i<nodes.length;i+=1){const item=nodes[i];if(isNode(item)){if(!this.visit(item,node,key,i)){i--}}}}else if(isNode(value)){this.visit(value,node,key,null)}}}if(this.leave){const _replacement=this.replacement;const _should_remove=this.should_remove;this.replacement=null;this.should_remove=false;this.leave.call(this.context,node,parent,prop,index);if(this.replacement){if(Array.isArray(this.replacement)){for(let rp=0;rp<this.replacement.length;rp++){node=this.replacement[rp];this.replace(parent,prop,index,node)}}else{node=this.replacement;this.replace(parent,prop,index,node)}}if(this.should_remove){this.remove(parent,prop,index)}const removed=this.should_remove;this.replacement=_replacement;this.should_remove=_should_remove;if(removed)return null}}return node}}function isNode(value){return value!==null&&typeof value==="object"&&"type"in value&&typeof value.type==="string"}function walk(ast,{enter,leave}){const instance=new SyncWalker(enter,leave);return instance.visit(ast,null)}function getProgramBody(node){if(node.type=="Program"){return node.body}return node}function parseNode(node){}function checkNodeL1(node,varz,vazzz){try{if(node&&typeof node==="object"){if(Array.isArray(node)){for(let i=0;i<node.length;i++){const nd=node[i];if(isNode(nd)){if(nd.type==="VariableDeclaration"){let declarators=nd.declarations;for(let x=0;x<declarators.length;x++){let dec=declarators[x].id;if(vazzz.includes(dec.name)){varz.push({name:dec.name,node:dec});dec.marked=true}}}else if(nd.type=="Identifier"){}parseNode(nd)}}}else if(isNode(node)){}}}catch(e){}}function getL1Vs(AST,view,vazzz){var level=0,block=[{start:0}];var varz=view?.varz??[];let nodes=getProgramBody(AST);checkNodeL1(nodes,varz,vazzz);return{"varz":varz,"AST":AST}}function getWatcher(AST,view,vazzz,targetKey="View"){AST=JSON.parse(JSON.stringify(AST));let Vars=getL1Vs(AST,view,vazzz);AST=Vars["AST"];let varz=Vars["varz"];validateBeforeRewrite(AST,view);AST=changeReactiveVarsOccurences(AST,vazzz,targetKey);AST=transformTopLevelDeclarations(AST,vazzz,targetKey);return{"code":astring.generate(AST),"varz":varz}}function validateBeforeRewrite(AST,view){try{new Function(astring.generate(AST))}catch(e){if(typeof reportLumenError==="function"){reportLumenError({stage:"validate",view:view?.name,error:e,hint:"This is a real JavaScript error in your <script> block (for example, a variable declared twice with let/const) \u2014 fix it in the .view file; it will not surface again once rewritten."})}}}function buildTargetRootExpr(targetKey){const segments=Array.isArray(targetKey)?targetKey:[targetKey];let expr={type:"Identifier",name:"_vt"};for(const seg of segments){if(typeof seg==="number"){expr={type:"MemberExpression",object:expr,property:{type:"Literal",value:seg,raw:String(seg)},computed:true}}else{expr={type:"MemberExpression",object:expr,property:{type:"Identifier",name:seg},computed:false}}}return expr}function changeReactiveVarsOccurences(AST,reactiveVariables,targetKey="View"){const reactive=new Set(reactiveVariables||[]);const scopeStack=[];const bindingIdNodes=new WeakSet;const pushScope=isFunction=>scopeStack.push({isFunction:!!isFunction,names:new Set});const popScope=()=>scopeStack.pop();const currentScope=()=>scopeStack[scopeStack.length-1];function declare(name,kind){if(!name)return;if(kind==="var"||kind==="function"){for(let i=scopeStack.length-1;i>=0;i--){if(scopeStack[i].isFunction||i===0){scopeStack[i].names.add(name);return}}}else{currentScope().names.add(name)}}function rootHas(name){return scopeStack.length>0&&scopeStack[0].names.has(name)}function isShadowedFromRoot(name){for(let i=scopeStack.length-1;i>=1;i--){if(scopeStack[i].names.has(name))return true}return false}function visitPattern(node,onId){if(!node)return;switch(node.type){case"Identifier":onId(node);break;case"RestElement":visitPattern(node.argument,onId);break;case"AssignmentPattern":visitPattern(node.left,onId);break;case"ArrayPattern":for(const el of node.elements)if(el)visitPattern(el,onId);break;case"ObjectPattern":for(const p of node.properties){if(p.type==="Property")visitPattern(p.value,onId);else if(p.type==="RestElement")visitPattern(p.argument,onId)}break;default:break}}function markPatternBindings(pattern,kind="var"){if(!pattern)return;visitPattern(pattern,idNode=>{bindingIdNodes.add(idNode);declare(idNode.name,kind)})}function predeclareProgram(programNode){if(!programNode||!Array.isArray(programNode.body))return;for(const stmt of programNode.body){if(stmt.type==="VariableDeclaration"){for(const d of stmt.declarations){visitPattern(d.id,id=>{bindingIdNodes.add(id);declare(id.name,stmt.kind)})}}else if(stmt.type==="FunctionDeclaration"&&stmt.id){bindingIdNodes.add(stmt.id);declare(stmt.id.name,"function")}else if(stmt.type==="ClassDeclaration"&&stmt.id){bindingIdNodes.add(stmt.id);declare(stmt.id.name,"let")}else if(stmt.type==="ImportDeclaration"){for(const spec of stmt.specifiers||[]){if(spec.local){bindingIdNodes.add(spec.local);declare(spec.local.name,"const")}}}}}function predeclareBlockLexicals(blockNode){if(!blockNode||!Array.isArray(blockNode.body))return;for(const stmt of blockNode.body){if(stmt.type==="VariableDeclaration"&&stmt.kind!=="var"){for(const d of stmt.declarations){visitPattern(d.id,id=>{bindingIdNodes.add(id);currentScope().names.add(id.name)})}}else if(stmt.type==="FunctionDeclaration"&&stmt.id){bindingIdNodes.add(stmt.id);currentScope().names.add(stmt.id.name)}else if(stmt.type==="ClassDeclaration"&&stmt.id){bindingIdNodes.add(stmt.id);currentScope().names.add(stmt.id.name)}}}function predeclareForHeader(node){const header=node.type==="ForStatement"?node.init:node.left;if(header&&header.type==="VariableDeclaration"&&header.kind!=="var"){for(const d of header.declarations){visitPattern(d.id,id=>{bindingIdNodes.add(id);currentScope().names.add(id.name)})}}}function shouldSkipIdentifier(node,parent,prop){if(!parent)return false;if(parent.type==="LabeledStatement"&&prop==="label"||(parent.type==="BreakStatement"||parent.type==="ContinueStatement")&&prop==="label")return true;if(parent.type==="MemberExpression"){if(prop==="property"&&parent.computed===false)return true}if(parent.type==="Property"){if(prop==="key"&&parent.computed===false)return true}if((parent.type==="MethodDefinition"||parent.type==="ClassProperty"||parent.type==="PropertyDefinition")&&prop==="key"&&parent.computed===false)return true;if(parent.type==="ImportSpecifier"||parent.type==="ImportDefaultSpecifier"||parent.type==="ImportNamespaceSpecifier"||parent.type==="ExportSpecifier")return true;return false}function walk2(node,parent,prop,index){if(!node||typeof node!=="object")return;switch(node.type){case"Program":pushScope(true);predeclareProgram(node);break;case"BlockStatement":case"StaticBlock":pushScope(false);predeclareBlockLexicals(node);break;case"FunctionDeclaration":if(node.id){bindingIdNodes.add(node.id);declare(node.id.name,"function")}pushScope(true);for(const p of node.params)markPatternBindings(p,"param");break;case"FunctionExpression":pushScope(true);if(node.id){bindingIdNodes.add(node.id);declare(node.id.name,"let")}for(const p of node.params)markPatternBindings(p,"param");break;case"ArrowFunctionExpression":pushScope(true);for(const p of node.params)markPatternBindings(p,"param");break;case"CatchClause":pushScope(false);if(node.param)markPatternBindings(node.param,"let");break;case"ForStatement":case"ForInStatement":case"ForOfStatement":pushScope(false);predeclareForHeader(node);break;case"VariableDeclaration":for(const decl of node.declarations){markPatternBindings(decl.id,node.kind||"var")}break;case"ClassDeclaration":if(node.id){bindingIdNodes.add(node.id);declare(node.id.name,"let")}break;case"ImportDeclaration":for(const spec of node.specifiers||[]){if(spec.local){bindingIdNodes.add(spec.local);declare(spec.local.name,"const")}}break}for(const key in node){if(key==="parent")continue;const child=node[key];if(Array.isArray(child)){for(let i=0;i<child.length;i++){if(child[i]&&typeof child[i]==="object"){walk2(child[i],node,key,i)}}}else if(child&&typeof child==="object"){walk2(child,node,key,null)}}if(node.type==="Identifier"){const name=node.name;if(!reactive.has(name)||bindingIdNodes.has(node)){}else if(!rootHas(name)){}else if(isShadowedFromRoot(name)){}else if(shouldSkipIdentifier(node,parent,prop)){}else{if(parent&&parent.type==="Property"&&parent.shorthand&&prop==="value"){parent.shorthand=false}const replacement={type:"MemberExpression",object:{type:"MemberExpression",object:buildTargetRootExpr(targetKey),property:{type:"Identifier",name:"vars"},computed:false},property:{type:"Literal",value:name,raw:JSON.stringify(name)},computed:true};if(parent){if(index!==null&&Array.isArray(parent[prop])){parent[prop][index]=replacement}else{parent[prop]=replacement}}else{Object.keys(node).forEach(k=>delete node[k]);Object.assign(node,replacement)}}}switch(node.type){case"Program":case"BlockStatement":case"StaticBlock":case"FunctionDeclaration":case"FunctionExpression":case"ArrowFunctionExpression":case"CatchClause":case"ForStatement":case"ForInStatement":case"ForOfStatement":popScope();break;default:break}}walk2(AST,null,null,null);return AST}function _reactiveAssignStatement(name,init,targetKey="View"){return{type:"ExpressionStatement",expression:{type:"AssignmentExpression",operator:"=",left:{type:"MemberExpression",computed:true,object:{type:"MemberExpression",computed:false,object:buildTargetRootExpr(targetKey),property:{type:"Identifier",name:"vars"}},property:{type:"Literal",value:name}},right:init||{type:"Identifier",name:"undefined"}}}}function _fnRegisterStatement(name,targetKey){return{type:"ExpressionStatement",expression:{type:"AssignmentExpression",operator:"=",left:{type:"MemberExpression",computed:true,object:{type:"MemberExpression",computed:false,object:buildTargetRootExpr(targetKey),property:{type:"Identifier",name:"fns"}},property:{type:"Literal",value:name}},right:{type:"Identifier",name}}}}function transformTopLevelDeclarations(AST,reactiveVariables,targetKey="View"){const reactive=new Set(reactiveVariables||[]);const newBody=[];for(const stmt of AST.body){if(stmt.type==="FunctionDeclaration"&&stmt.id){newBody.push(stmt);newBody.push(_fnRegisterStatement(stmt.id.name,targetKey));continue}if(stmt.type!=="VariableDeclaration"){newBody.push(stmt);continue}const reactiveDecls=stmt.declarations.filter(d=>reactive.has(d.id.name));const nonReactiveDecls=stmt.declarations.filter(d=>!reactive.has(d.id.name));if(reactiveDecls.length===0){newBody.push(stmt);continue}for(const decl of reactiveDecls){newBody.push(_reactiveAssignStatement(decl.id.name,decl.init,targetKey))}if(nonReactiveDecls.length>0){newBody.push({type:"VariableDeclaration",kind:stmt.kind,declarations:nonReactiveDecls})}}AST.body=newBody;return AST}if(typeof module!=="undefined"&&module.exports){module.exports={getWatcher,changeReactiveVarsOccurences,transformTopLevelDeclarations,validateBeforeRewrite}}
59220
59220
 
59221
- var cl=console.log;class _v{static name;static type;static vars;static fns;static rvs;static _pv;static mx;static views;static hst;static settings;constructor(obj){this.name=obj.name??"home";this.type=obj.type??"main";this.hst=obj.hst??[];this.views=obj.views??[];this.vars=obj.vars??{};this.fns=obj.fns??{};this.rvs=obj.rvs??{};this._pv=obj._pv??null;this.mx=obj.mx??[];this.settings=obj.settings??{layout:"default",requireAuth:false}}}const consoleLogOriginal=console.log;console.log=function(){for(let i=0;i<arguments.length;i++){const arg=arguments[i];if(arg&&arg.hasOwnProperty("__isProxy")||arg?.target){arguments[i]=arguments[i].target}}consoleLogOriginal.apply(console,arguments)};var _lumenDevMode=true;var _lumenErrorLog=[];var EXPECTED_HST_FORMAT_VERSION=1;function _translateLumenError(message){if(!message)return message;return message.replace(/_vt\.View\.vars\[["'`]([^"'`\]]+)["'`]\]/g,"$1")}function reportLumenError(info){info=info||{};var rawMessage=info.message||info.error&&info.error.message||"Unknown error";var entry={time:new Date().toISOString(),stage:info.stage||"runtime",view:info.view||(typeof _vt!=="undefined"&&_vt.View?_vt.View.name:void 0),expr:info.expr,message:_translateLumenError(rawMessage),hint:info.hint};_lumenErrorLog.push(entry);if(_lumenDevMode){console.error("[LumenJS] "+entry.stage+' error in "'+(entry.view||"unknown")+'"'+(entry.expr?" \u2014 "+entry.expr:"")+": "+entry.message+(entry.hint?"\n "+entry.hint:""))}return entry}function _x(_x2){var currPath=[];function _dispatchVarsUpdate(key){let varsIdx=currPath.indexOf("vars");if(varsIdx===-1)return;let varName=varsIdx<currPath.length-1?currPath[varsIdx+1]:key;let rootPath=currPath.slice(0,varsIdx);if(rootPath[0]==="Global"){try{if(typeof window!=="undefined")window[varName]=_x2.Global.vars[varName]}catch(e){}if(_vt.View._re)_vt.View._re.update(varName);return}let owner=_x2;for(let i=0;i<rootPath.length&&owner;i++){owner=owner[rootPath[i]]}if(owner&&owner._re)owner._re.update(varName)}const handler={get(target,key){if(key=="__isProxy")return true;if(key=="View"||key=="Global")currPath=[];currPath.push(key);if(typeof target[key]==="object"&&target[key]!==null&&key!="_re"){return new Proxy(target[key],handler)}else{return target[key]??(key=="target"?target:void 0)??void 0}},set(target,key,value){target[key]=value;try{_dispatchVarsUpdate(key)}catch(e){cl(e)}currPath=[];return true},deleteProperty(target,key){if(!(key in target)){return false}delete target[key];try{_dispatchVarsUpdate(key)}catch(e){cl(e)}return true},ownKeys(target){return Reflect.ownKeys(target)},has(target,key){return key in target},defineProperty(target,key,descriptor){if(descriptor&&"value"in descriptor){target[key]=descriptor.value}return target},getOwnPropertyDescriptor(target,key){const value=target[key];return key in target?{value,enumerable:true,configurable:true}:void 0}};var x=new Proxy(_x2,handler);return x}let _vt=_x({"View":new _v({}),"Global":{"vars":{},"fns":{}}});class _lm{_RealDOM=[];_effects={};_cc={};_jj={};_ready=false;view=void 0;sbscrbs=[];reactiveVariables=[];vrs={};_CXR=[];_LXR=[];constructor(view){this.view=view;this.view._re=this;this.reactiveVariables=view?.rvs??{};this.init();if(this.view.type=="main")_vt.View=this.view;if(this.view._pv){this.view._pv.subscribe(this.view)}return this}init(){var par2=this;this.view.hst.forEach(function(doc2){par2.walk(doc2,null)})}subscribe(view){this.sbscrbs.push(view)}scopedEval(context,expr,kk){let ctx=this.concatVarsAtLevel(context,this);if(kk){if(!ctx.hasOwnProperty(kk))return void 0;delete ctx[kk]}try{const evaluator=Function.apply(null,[...Object.keys(ctx),"expr","return eval(expr)"]);return evaluator.apply(null,[...Object.values(ctx),expr])}catch(e){if(e instanceof TypeError){return this.scopedEval(ctx,expr,e.message.split(" ")[0])}reportLumenError({stage:"expression",expr,error:e});return void 0}}getVals(effect){let val="";if(effect.type=="text"){if(!effect.isSplit){for(let i=0;i<effect.splits.length;i++){let split=effect.splits[i];if(split.type=="mustache"){val+=this.getVal(split.content)}else{val+=split.content}}}else{val=this.getVal(effect.content)}}else if(effect.type=="attr"||effect.type=="event"){for(let i=0;i<effect.splits.length;i++){let split=effect.splits[i];if(split.type=="mustache"){val+=this.getVal(split.content)}else{val+=split.content}}}return val}renderAll(){if(this._ready)return;this._ready=true;for(const rv in this._effects){if(Object.prototype.hasOwnProperty.call(this._effects,rv)){const effects=this._effects[rv];for(let ei=0;ei<effects.length;ei++){const effect=effects[ei];if(!effect.nd)continue;try{if(effect.type=="text"){effect.nd.textContent=this.render(effect)}else if(effect.type=="attr"){if(effect.name=="value"){effect.nd.value=this.render(effect)}else{effect.nd.setAttribute(effect.name,this.render(effect));if(effect.name=="view"){effect.nd.subPath=this.render(effect);renderView(this.render(effect),true,{})}}}else if(effect.type=="event"){effect.nd.events[effect.name]=this.render(effect)}}catch(e){cl("Eeeeee",e)}}}}this.updateCXRs();this.updateLXRs();this.updateVXRs();if(typeof appSettings!=="undefined"&&appSettings&&typeof appSettings.tick==="function"){try{appSettings.tick()}catch(e){cl(e)}}}chainConnected(cx){for(let i=cx.chain.length-1;i>=0;i--){const cxs=cx.chain[i];if(cxs.ref.isPreConnected){return true}}return false}async updateVXRs(k){let subsNames=[];for(let i=0;i<this.view.views.length;i++){const _view=this.view.views[i];if(!subsNames.includes(_view.subPath))subsNames.push(_view.subPath)}for(let i=0;i<subsNames.length;i++){const n=subsNames[i];renderView(n,true,{},"views",this.view.views,this.view.scopePath||["View"])}}async updateCXRs(k){for(let i=0;i<this._CXR.length;i++){const cx=this._CXR[i];if(cx.name=="if"){let isTrue=this.evalExp(cx.content,this.reactiveVariables);if(isTrue){await this.showSectionCX(cx,k)}else{await this.hideSectionCX(cx)}}else if(cx.name=="else-if"){if(!this.chainConnected(cx)){let isTrue=this.evalExp(cx.content,this.reactiveVariables);if(isTrue){await this.showSectionCX(cx,k)}else{await this.hideSectionCX(cx)}}else{await this.hideSectionCX(cx)}}else if(cx.name=="else"){if(!this.chainConnected(cx)){await this.showSectionCX(cx,k)}else{await this.hideSectionCX(cx)}}}}async showSectionCX(cx,k){let wasConnected=cx.ref.node.isConnected;cx.ref.isPreConnected=true;await renderSection(cx.ref,cx.doc,this,k);if(!wasConnected)await fireRenderHook(cx,"after-render",cx.ref.node,{visible:true})}async hideSectionCX(cx){if(cx.ref.node.isConnected)await fireRenderHook(cx,"before-render",cx.ref.node,{visible:false});cx.ref.isPreConnected=false;cx.ref.node.replaceWith(cx.ref)}render(effect){let x="";try{if(effect.type=="text"||effect.type=="attr"||effect.type=="event"){x=this.getVals(effect)}}catch(e){cl(e)}return x}update(k){if(!this._ready)return;if(this._effects.hasOwnProperty(k)){const effects=this._effects[k];for(let ei=0;ei<effects.length;ei++){const effect=effects[ei];if(!effect.nd)continue;try{if(effect.type=="text"){effect.nd.textContent=this.render(effect)}else if(effect.type=="attr"){if(effect.name=="value"){effect.nd.value=this.render(effect)}else{effect.nd.setAttribute(effect.name,this.render(effect));if(effect.name=="view"){effect.nd.subPath=this.render(effect);renderView(this.render(effect),true,{})}}}else if(effect.type=="event"){effect.nd.events[effect.name]=this.render(effect)}}catch(e){cl("Eeeeee",e)}}}this.updateCXRs(k);this.updateLXRs(k);for(let sbscsi=0;sbscsi<this.sbscrbs.length;sbscsi++){const sbscr=this.sbscrbs[sbscsi];sbscr._re.update(k)}if(typeof appSettings!=="undefined"&&appSettings&&typeof appSettings.tick==="function"){try{appSettings.tick()}catch(e){cl(e)}}}async updateLXRs(k){for(let i=0;i<this._LXR.length;i++){var cx=this._LXR[i];var forX=cx.forX;if(k&&k!=forX["js"])continue;var val=this.getVal(forX["js"],"");var tempVal=[];if(this.typeStr(val)=="number"){for(let i2=0;i2<val;i2++){tempVal.push(i2)}val=tempVal}let vals=[];let isObj=false;if(this.typeStr(val)=="object"){isObj=true;for(const oKey in val){if(Object.hasOwnProperty.call(val,oKey)){const item=val[oKey];let objj={key:oKey,value:item};vals.push(objj)}}}else vals=clone(val);if(this.typeStr(vals)=="array"&&vals.length>0){let forIf=cx.cond;let limit=vals.length;let offset=0;if(cx.limit)limit=(isNaN(cx.limit)?cx.limit:limit)>vals.length?vals.length:cx.limit*1;if(cx.offset)offset=(isNaN(cx.offset)?cx.offset:offset)<0?0:cx.offset*1;let marray=[];if(forIf){marray=vals.slice(offset*1,vals.length)}else{marray=vals.slice(offset*1,limit*1+offset*1)}let myLimit=0;let arrayToRender=[];let arrayToRenderVXs=[];for(var index=0;index<marray.length;index++){if(myLimit==limit*1)break;try{let vx={};vx["index"]=myLimit;if(forX["dx"]!="")vx[forX["dx"]]=myLimit;if(isObj){if(forX["as"]["v"]!=""){if(forX["as"]["k"])vx[forX["as"]["k"]]=marray[index]["key"];if(forX["as"]["v"])vx[forX["as"]["v"]]=marray[index]["value"]}else{if(forX["as"]["k"])vx[forX["as"]["k"]]=marray[index]}vx["key"]=marray[index]["key"];vx["value"]=marray[index]["value"]}else{if(forX["as"]["k"])vx[forX["as"]["k"]]=marray[index];else if(marray[index]&&typeof marray[index]==="object"){for(const k2 in marray[index]){if(Object.prototype.hasOwnProperty.call(marray[index],k2)){vx[k2]=marray[index][k2]}}}}if(forIf){let _prevVrs=this.vrs;this.vrs=vx;let isTrue;try{isTrue=this.evalExp(forIf,[])}finally{this.vrs=_prevVrs}if(!isTrue)continue}let miIndexx=offset*1+index*1;arrayToRender.push(marray[index]);arrayToRenderVXs.push(vx);myLimit++}catch(e){cl(e)}}let oldATR=cx.atr;cx.atr=clone(arrayToRender);const actions=this.compareArrays(oldATR,arrayToRender);if(actions.length)await fireRenderHook(cx,"before-render",cx.ref.parentElement,{items:arrayToRender,actions});for(let ai=0;ai<actions.length;ai++){const actn=actions[ai];if(actn.action=="add"){let vx=arrayToRenderVXs[actn.index];let cln=await this.createSection(cx,vx,isObj,forX);cx.ref.before(cln);cln.replaceWith(cln.node)}else if(actn.action=="remove"){var keyed=cx.key+"_"+actn.index;let tx2=cx.ref?.nodes[keyed];if(tx2){tx2.remove();tx2.node.remove();delete cx.tx?.nodes[keyed]}}else{var keyed=cx.key+"_"+actn.index;let tx2=cx.ref?.nodes[keyed];let vx=arrayToRenderVXs[actn.index];if(tx2){tx2._re.vrs=vx;if(tx2.isObj){if(tx2.forX.as["k"]!="")tx2._re.update(tx2.forX.as["k"]);else tx2._re.update(tx2.forX.js);if(tx2.forX.as["v"]!="")tx2._re.update(tx2.forX.as["v"]);for(let actnsi=0;actnsi<actn.updates.length;actnsi++){const actnu=actn.updates[actnsi];tx2._re.update(actnu.property)}}else{if(tx2.forX.as["k"]!="")tx2._re.update(tx2.forX.as["k"]);else tx2._re.update(tx2.forX.js)}}}}if(actions.length)await fireRenderHook(cx,"after-render",cx.ref.parentElement,{items:arrayToRender,actions})}else{cx.nodes=[]}}}compareLogic(array1,array2){if(array1.length===array2.length){return 1}else{if(array1.length>array2.length){return 2}else{return 3}}}compareArrays(array1,array2){const actions=[];const maxLength=Math.max(array1.length,array2.length);for(let i=0;i<maxLength;i++){const element1=array1[i];const element2=array2[i];if(!element2){actions.push({action:"remove",index:i})}else if(!element1){actions.push({action:"add",index:i,element:element2})}else if(!this.deepCompare(element1,element2)){actions.push({action:"update",index:i,updates:this.getUpdates(element1,element2)})}}return actions}findDeletedIndexes(array1,array2){const deletedIndexes=[];let par2=this;array1.forEach((item,index)=>{const foundIndex=array2.findIndex(el2=>par2.deepCompare(el2,item));if(foundIndex===-1){deletedIndexes.push(index)}});return deletedIndexes}findAddedIndexes(array1,array2){const addedIndexes=[];let par2=this;array2.forEach((item,index)=>{const foundIndex=array1.findIndex(el2=>par2.deepCompare(el2,item));if(foundIndex===-1){addedIndexes.push(index)}});return addedIndexes}deepCompare(obj1,obj2){return JSON.stringify(obj1)===JSON.stringify(obj2)}getUpdates(oldObj,newObj){const updates=[];for(const key in newObj){if(newObj.hasOwnProperty(key)&&newObj[key]!==oldObj[key]){updates.push({property:key,value:newObj[key]})}}return updates}getVal(mo,indexName){let vars={};try{for(let i=0;i<this.reactiveVariables.length;i++){let __name=this.reactiveVariables[i];vars[__name]=_vt.View.vars.hasOwnProperty(__name)?_vt.View.vars[__name]:_vt.Global.vars[__name]}for(const ky in this.vrs){if(Object.prototype.hasOwnProperty.call(this.vrs,ky)){vars[ky]=this.vrs[ky]}}if(this.view&&this.view.vars){for(const ky in this.view.vars){if(Object.prototype.hasOwnProperty.call(this.view.vars,ky)){vars[ky]=this.view.vars[ky]}}}}catch(e){cl(e)}mo=mo.trim();if(mo.slice(0,2)=="{{"){mo=mo.slice(2,-2)}let value="";let _mo=mo;if(mo.indexOf("`")>-1){var matchesVal=_mo.match(/\.`[\s\S]*?`/g);if(matchesVal)for(var y=0;y<matchesVal.length;y++){_mo=_mo.split(matchesVal[y]).join("."+this.getVal(matchesVal[y].substr(1).slice(1,-1),indexName))}var matchesVal=_mo.match(/`[\s\S]*?`/g);if(matchesVal)for(var y=0;y<matchesVal.length;y++){_mo=_mo.split(matchesVal[y]).join("'"+this.getVal(matchesVal[y].slice(1,-1),indexName)+"'")}return this.getVal(_mo,indexName)}if(mo.indexOf(";")>-1){let zxx=mo.split(";");mo=$.trim(zxx[0])}if(mo.indexOf(" as ")>-1){mo=mo.split(" as ");return this.getVal(mo[0],indexName)}if(indexName){indexName=indexName.toString();if(mo.indexOf(indexName)>-1&&mo!=indexName&&vars.hasOwnProperty(indexName)&&mo!="index"){mo=mo.split(indexName).join(vars[indexName]);return this.getVal(mo,indexName)}}var Ondex=mo.match(/\bindex\b/g);if(Ondex&&mo!="index"&&vars.hasOwnProperty("index")){_mo=mo.replace(/\bindex\b/g,vars["index"]);return this.getVal(_mo,indexName)}value=this.lookup(mo,vars);return value??""}concatVarsAtLevel(levelVars,parent2){if(!parent2.view._pv){var concatenatedVars={...levelVars};if(parent2.view.vars){concatenatedVars={..._vt.Global.vars,...parent2.view.vars,...concatenatedVars}}return concatenatedVars}var concatenatedVars={...levelVars};if(parent2.view.vars){concatenatedVars={...parent2.view.vars,...concatenatedVars}}return this.concatVarsAtLevel(concatenatedVars,parent2.view._pv)}lookup(name,vaz){let vars=this.concatVarsAtLevel(vaz,this);try{var value;var names,index,lookupHit=false;if(this.hasProperty(vars,name)){value=vars[name]}else if(name.indexOf(".")>-1&&name.indexOf("[")==-1){var value=this.scopedEval(vars,name);if(!(value||value==0)){value=vars;names=name.split(".");index=0;while(value!=null&&index<names.length){if(index===names.length-1)lookupHit=this.hasProperty(value,names[index]);value=value[names[index++]]}}}else{var value=this.scopedEval(vars,name);if(!(value||value==0)){if(name.indexOf(".")==-1&&name.indexOf("[")>-1){let _name=name;var matchesVal=_name.match(/\[[\s\S]*?\]/g);for(var y=0;y<matchesVal.length;y++){if(matchesVal[y].indexOf("'")==-1&&matchesVal[y].indexOf('"')==-1)_name=_name.split(matchesVal[y]).join("['"+matchesVal[y].slice(1,-1)+"']")}var value=this.scopedEval(vars,_name)}}}if(this.isFunction(value))value=value.call(value)}catch(e){reportLumenError({stage:"lookup",expr:name,error:e});return""}return value}objectToString=Object.prototype.toString;isArray=Array.isArray||function isArrayPolyfill(object){return objectToString.call(object)==="[object Array]"};isFunction(object){return typeof object==="function"}typeStr(obj){return this.isArray(obj)?"array":typeof obj}hasProperty(obj,propName){return obj!=null&&typeof obj==="object"&&propName in obj}createEl(tag,attrs,children,events,doc2){const _el2=document.createElement(tag);Object.defineProperty(_el2,"_ownerRe",{value:this,enumerable:false,configurable:true,writable:true});_el2.isSub=false;if(attrs.hasOwnProperty("view")){_el2.isSub=true;_el2.subPath=attrs["view"];_el2.vars={};_el2.views=[];_el2.fns={};if(doc2&&doc2.evs&&doc2.evs.hasOwnProperty("@init")){let _initAttr=doc2.evs["@init"];if(_initAttr){let _initResult=evalEvAttr(_initAttr,{cType:"init"},$(_el2),"init",this.vrs);if(_initResult&&typeof _initResult==="object"&&typeof _initResult.then!=="function"){Object.assign(_el2.vars,_initResult)}}}this.view.views.push(_el2)}_el2.events={};for(const prop in attrs){if(prop=="view"||prop==":data"||prop==":if"||prop==":else-if"||prop==":else"||prop==":for"||prop==":for-limit"||prop==":for-offset"||prop==":for-if")continue;try{let val=doc2&&doc2.ax.hasOwnProperty(prop)?"":attrs[prop];if(prop=="value"){_el2.value=val}else _el2.setAttribute(prop,val)}catch(e){cl(e)}}for(const prop in events){try{_el2.events[prop]=events[prop]}catch(e){cl(e)}}if(children.length)_el2.append(...children);if(events&&events["@after-render"]&&!(attrs&&(attrs.hasOwnProperty(":for")||attrs.hasOwnProperty(":if")||attrs.hasOwnProperty(":else-if")||attrs.hasOwnProperty(":else")))){fireRenderHook({doc:doc2},"after-render",_el2,{})}autoInitPlugins(_el2,attrs);return _el2}evalExp(expr,vars){let rvars={};try{for(let i=0;i<vars.length;i++){let __name=vars[i];rvars[__name]=_vt.View.vars.hasOwnProperty(__name)?_vt.View.vars[__name]:_vt.Global.vars[__name]}for(const ky in this.vrs){if(Object.prototype.hasOwnProperty.call(this.vrs,ky)){rvars[ky]=this.vrs[ky]}}if(this.view&&this.view.vars){for(const ky in this.view.vars){if(Object.prototype.hasOwnProperty.call(this.view.vars,ky)){rvars[ky]=this.view.vars[ky]}}}}catch(e){cl(e)}try{var value=this.scopedEval(rvars,expr);if(value&&value!=0)return true}catch(e){reportLumenError({stage:"condition",expr,error:e});return false}return false}splitTextWithMustaches(text,mustaches){mustaches.sort((a,b)=>a.start-b.start);const elements=[];let currentIndex=0;for(const mustache of mustaches){if(currentIndex<mustache.start){elements.push({type:"static",content:text.substring(currentIndex,mustache.start)})}elements.push({type:"mustache",jst:mustache.jst,rvs:mustache.rvs,content:text.substring(mustache.start,mustache.end)});currentIndex=mustache.end}if(currentIndex<text.length){elements.push({type:"static",content:text.substring(currentIndex)})}return elements}walk(doc,parent){var par=this;var tx,el;switch(doc.type){case"text":if(doc.mss.length){let splitIt=true;if(doc.tag=="textarea"){splitIt=false}if(splitIt){let splits=this.splitTextWithMustaches(doc.content,doc.mss);for(let si=0;si<splits.length;si++){const split=splits[si];if(split.type=="static"){let txnd=document.createTextNode(split.content);if(!parent)par._RealDOM.push(txnd);(tx??(tx=[])).push(txnd)}else{let txnd=document.createTextNode("");for(let ri=0;ri<split.rvs.length;ri++){const element=split.rvs[ri];(this._effects[element]??(this._effects[element]=[])).push({"type":"text","content":split.content,"jst":split.jst,"rvs":split.rvs,"isSplit":true,"nd":txnd,"tag":doc.tag})}if(!parent)par._RealDOM.push(txnd);(tx??(tx=[])).push(txnd)}}return tx}else{tx=document.createTextNode("");for(let mui=0;mui<doc.mss.length;mui++){const mus=doc.mss[mui];for(let ri=0;ri<mus.rvs.length;ri++){const element=mus.rvs[ri];(this._effects[element]??(this._effects[element]=[])).push({"type":"text","content":doc.content,"splits":this.splitTextWithMustaches(doc.content,doc.mss),"jst":mus.jst,"rvs":mus.rvs,"isSplit":false,"nd":tx,"tag":doc.tag})}}if(!parent)par._RealDOM.push(tx);return tx}}else{tx=document.createTextNode(doc.content);if(!parent)par._RealDOM.push(tx);return tx}break;case"sections":case"section":var _dd=md5(new Date().getTime()/1e3+"::"+Math.random());tx=document.createTextNode("");var typeN=null;if(doc.attrs.hasOwnProperty(":else"))typeN="else";else if(doc.attrs.hasOwnProperty(":else-if"))typeN="else-if";else if(doc.attrs.hasOwnProperty(":if"))typeN="if";else typeN="for";if(doc.type=="section"){var chain=[];if(typeN=="else-if"||typeN=="else"){try{let lastInChain=this._CXR.at(-1);if(lastInChain){_dd=lastInChain.key;chain.push(...lastInChain.chain,lastInChain)}}catch(e){}}el=par.createEl(doc.name,doc.attrs,[],doc.evs,doc);tx.node=el;this._CXR.push({"type":"section","name":typeN,"content":doc.cond,"doc":doc,"key":_dd,"chain":chain,"ref":tx});this.setEffects(doc,el)}else if(doc.type=="sections"){tx.key=_dd;tx.node=null;tx.nodes={};let docRaw=doc;this._LXR.push({"type":"sections","name":typeN,"cond":doc.attrs.hasOwnProperty(":for-if")?doc.attrs[":for-if"]:null,"limit":doc.attrs.hasOwnProperty(":for-limit")?doc.attrs[":for-limit"]:0,"offset":doc.attrs.hasOwnProperty(":for-offset")?doc.attrs[":for-offset"]:0,"content":doc.content,"forX":doc.forX,"doc":docRaw,"key":_dd,"atr":[],"ref":tx})}if(!parent)par._RealDOM.push(tx);return tx;break;case"tag":var _dd=md5(new Date().getTime()/1e3+"::"+Math.random());if(doc.name.toLowerCase()=="settings"){if(par.view.type=="main"){var defaultSettings={layout:"default",requireAuth:false};try{let settingsC=doc.children[0].content;let settings={};eval("settings = "+settingsC+";");if(settings){if(settings.layout==null)settings.layout="default";if(settings.requireAuth==null)settings.requireAuth=false;par.view.settings=settings}else{par.view.settings=defaultSettings}}catch(e){setError(e,"Error in your settings tag inside the '"+par.view.name.toLowerCase()+"' main view!");par.view.settings=defaultSettings}}}else if(doc.name.toLowerCase()=="script"||doc.name.toLowerCase()=="js"){let child=doc.children[0];let js=child.content;let jst=child.jst;let isScoped=false;if(doc.attrs.hasOwnProperty("scoped")){delete doc.attrs["scoped"];isScoped=true}el=par.createEl("script",doc.attrs,[],doc.evs,doc);el._sc=isScoped;el._dd=_dd;el._jst=jst;(par._jj[_dd]??(par._jj[_dd]=[])).push({"nd":el})}else if(doc.name.toLowerCase()=="style"){let css=doc.children[0].content;let isScoped=false;el=par.createEl("style",{},[],doc.evs,doc);if(doc.attrs.hasOwnProperty("scoped")){if(!parent){if(par.view._dd)_dd=par.view._dd;else{par.view._dd=_dd;if(par.view.type=="main")$("[body]")[0].setAttribute("vuid",_dd)}}else{if(parent._dd)_dd=parent._dd;else{parent._dd=_dd;parent.setAttribute("vuid",_dd)}}delete doc.attrs["scoped"];isScoped=true;el._sc=isScoped;el._dd=_dd;el._css=css;(par._cc[_dd]??(par._cc[_dd]=[])).push({"nd":el,"_css":css})}else{el._sc=isScoped;el._dd=_dd;el.textContent=css}for(const prop in doc.attrs){try{_el.setAttribute(prop,doc.attrs[prop])}catch(e){cl(e)}}}else if(doc.name.toLowerCase()=="icon"){let child=par.createEl("span",{"class":"iconify","data-icon":doc?.icon??"mdi:home"},[],{},null);el=par.createEl("span",doc.attrs,[child],doc.evs,doc)}else if(doc.name.toLowerCase()=="slot"){let slotName=doc.attrs&&doc.attrs.name;if(slotName){let tempWrapper=document.createElement("div");let childs=[];for(let i=0;i<doc.children.length;i++){const dc=doc.children[i];let chils=par.walk(dc,tempWrapper);if(chils){if(Array.isArray(chils)){if(chils.length)childs=[...childs,...chils]}else{childs.push(chils)}}}(par.view._slots??(par.view._slots={}))[slotName]=childs}}else if(doc.attrs&&doc.attrs.hasOwnProperty("tpl")&&!doc.attrs.hasOwnProperty(":for")){reportLumenError({stage:"tpl",error:new Error('tpl="'+doc.attrs["tpl"]+'" must be used together with :for on the same element \u2014 templates only render inside a repeated/list context.')})}else{el=par.createEl(doc.name,doc.attrs,[],doc.evs,doc);if(!doc.isV&&!el.isSub){let childs=[];for(let i=0;i<doc.children.length;i++){const dc=doc.children[i];let chils=par.walk(dc,el);if(chils){if(Array.isArray(chils)){if(chils.length)childs=[...childs,...chils]}else{childs.push(chils)}}}childs.length?el.append(...childs):null}}this.setEffects(doc,el);if(el){if(!parent)par._RealDOM.push(el)}return el;break;case"comment":break;default:break}}setEffects(doc2,el2){let rvs=[];if(Object.keys(doc2.ax).length){for(const attrName in doc2.ax){if(Object.hasOwnProperty.call(doc2.ax,attrName)){const attrMustaches=doc2.ax[attrName];for(let i=0;i<attrMustaches.length;i++){const mus=attrMustaches[i];for(let ri=0;ri<mus.rvs.length;ri++){const element=mus.rvs[ri];rvs.push(element);(this._effects[element]??(this._effects[element]=[])).push({"type":"attr","name":attrName,"content":doc2.attrs[attrName],"splits":this.splitTextWithMustaches(doc2.attrs[attrName],doc2.ax[attrName]),"jst":mus.jst,"rvs":mus.rvs,"nd":el2})}}}}}if(Object.keys(doc2.ex).length){for(const ky in doc2.ex){if(Object.hasOwnProperty.call(doc2.ex,ky)){const mss=doc2.ex[ky];for(let i=0;i<mss.length;i++){const mus=mss[i];for(let ri=0;ri<mus.rvs.length;ri++){const element=mus.rvs[ri];rvs.push(element);(this._effects[element]??(this._effects[element]=[])).push({"type":"event","name":ky,"content":doc2.evs[ky],"splits":this.splitTextWithMustaches(doc2.evs[ky],doc2.ex[ky]),"jst":mus.jst,"rvs":mus.rvs,"nd":el2})}}}}}return rvs.filter((value,index,self)=>{return self.indexOf(value)===index})}async createSection(cx,vx,isObj,forX){var keyed=cx.key+"_"+vx.index;var tx2=document.createTextNode("");var typeN2=null;if(cx.doc.attrs.hasOwnProperty(":else"))typeN2="else";else if(cx.doc.attrs.hasOwnProperty(":else-if"))typeN2="else-if";else if(cx.doc.attrs.hasOwnProperty(":if"))typeN2="if";else typeN2="for";let el2=this.createEl(cx.doc.name,cx.doc.attrs,[],cx.doc.evs,cx.doc);tx2.node=el2;tx2.key=cx.key;tx2.keyed=keyed;tx2.isObj=isObj;tx2.forX=forX;tx2.vx=vx;let scsc=await renderSection(tx2,cx.doc,this,cx.key);scsc._re=scsc;cx.ref.nodes[keyed]=tx2;return tx2}attrString(attrs){var buff=[];for(var key in attrs){buff.push(key+'="'+attrs[key]+'"')}if(!buff.length)return"";return" "+buff.join(" ")}_stringify(buff,doc2){var par2=this;switch(doc2.type){case"text":return buff+doc2.content;case"tag":buff+="<"+doc2.name+(doc2.attrs?par2.attrString(doc2.attrs):"")+(doc2.isV?"/>":">");if(doc2.isV)return buff;for(let i=0;i<doc2.children.length;i++){const dc=doc2.children[i];buff=buff+par2._stringify("",dc)}return buff+"</"+doc2.name+">";case"comment":return buff;default:return""}}stringify(doc2){var par2=this;return doc2.reduce(function(token,rootEl){return token+par2._stringify("",rootEl)},"")}}async function renderHST(hst,n,type="main",tx2,_pv=null,scopePath=["View"],ownVars,ownFns,ownViews){var reactiveVariables=hst.reactiveVars;hst=hst.hst;let _re=new _lm(new _v({"name":n,"type":type,"hst":hst,"vars":ownVars??tx2?.vx,"fns":ownFns,"views":ownViews,"rvs":reactiveVariables,"_pv":_pv}));_re.view.scopePath=scopePath;if(Object.keys(_re._cc).length){for(const ky in _re._cc){if(Object.hasOwnProperty.call(_re._cc,ky)){const csses=_re._cc[ky];for(let inde=0;inde<csses.length;inde++){let prom=new defer;const css=csses[inde];_csswrk.trigger("css-ready",{"csses":[css._css],"pre":"[vuid='"+ky+"']","key":ky});_vuid[ky]=prom;let _csses=await prom;css.nd.textContent=_csses[0]}}}}if(Object.keys(_re._jj).length){for(const ky in _re._jj){if(Object.hasOwnProperty.call(_re._jj,ky)){const jses=_re._jj[ky];for(let inde=0;inde<jses.length;inde++){const nd=jses[inde].nd;let code=getWatcher(nd._jst,_re.view,reactiveVariables,scopePath).code;code=`try { `+code+` } catch (e) { reportLumenError({ stage: 'script', error: e }); }`;code=code+`
59222
- //# sourceURL=`+(_re.view?.name||"view")+`.view.generated.js`;nd.textContent=code}}}}return _re}async function fireRenderHook(cx,n,containerEl,extra){if(!containerEl)return;let attrKey="@"+n;if(!cx.doc||!cx.doc.evs||!cx.doc.evs.hasOwnProperty(attrKey))return;let attrVal=cx.doc.evs[attrKey];if(!attrVal)return;let ev=Object.assign({cType:n},extra||{});let result=evalEvAttr(attrVal,ev,$(containerEl),n);if(result&&typeof result.then==="function"){try{return await result}catch(e){return void 0}}return result}function autoInitPlugins(el2,attrs){if(!attrs)return;try{if(attrs.hasOwnProperty("sl")&&typeof $.fn.select2==="function"){initSl($(el2))}if(attrs.hasOwnProperty("color")&&typeof $.fn.colorpicker==="function"){$(el2).removeAttr("color").colorpicker({format:"rgba"})}if(typeof $.fn.datetimepicker==="function"){if(attrs.hasOwnProperty("time"))dtp($(el2),"time");if(attrs.hasOwnProperty("date"))dtp($(el2),"date");if(attrs.hasOwnProperty("datetime"))dtp($(el2),"datetime")}}catch(e){cl(e)}}function initSl(t){if(t.hasClass("select2-hidden-accessible"))return;try{var plchldr=t.attr("placeholder")?t.attr("placeholder"):"";var dir=$("body").hasClass("rtl")?"rtl":"ltr";var nr=t.attr("sl-nrmsg")?t.attr("sl-nrmsg"):"No results found";var minResultsForSearch=t.attr("sl-mins")?t.attr("sl-mins"):10;var allowNewTags=t.attr("sl-ntgs")?true:false;var dropdownParent=t.attr("sl-prt")?t.attr("sl-prt"):"body";if(dropdownParent=="self")dropdownParent=t.parent();else dropdownParent=$(dropdownParent);var query=t.attr("sl-query")?t.attr("sl-query"):null;var uniquer=Date.now();if(typeof window[query]==="function"){t.select2.amd.define("adapt_"+uniquer,["select2/data/array","select2/utils"],function(ArrayAdapter,Utils){function CustomDataAdapter($element,options){CustomDataAdapter.__super__.constructor.call(this,$element,options)}Utils.Extend(CustomDataAdapter,ArrayAdapter);CustomDataAdapter.prototype.query=function(params,callback){clearTimeout(_dbcrs[uniquer]);let _t=t;_dbcrs[uniquer]=setTimeout(function(){window[query](params,callback,_t)},!_dbcrs.hasOwnProperty(uniquer)?0:_dbcrsTime)};return CustomDataAdapter});t.select2({dropdownParent,minimumResultsForSearch:minResultsForSearch,placeholder:plchldr,dir,tags:allowNewTags,allowClear:true,language:{noResults:function(){return nr}},...t.select2.amd.require("adapt_"+uniquer)?{ajax:{},dataAdapter:t.select2.amd.require("adapt_"+uniquer)}:{}})}else{t.select2({dropdownParent,minimumResultsForSearch:minResultsForSearch,placeholder:plchldr,dir,tags:allowNewTags,allowClear:true,language:{noResults:function(){return nr}}})}if(t.attr("sl-nosrch"))t.on("select2:opening select2:closing",function(event){$(this).parent().find(".select2-search__field").prop("disabled",true)});if(t.attr("sl-class")){t.on("select2:opening",function(event){dropdownParent.addClass(t.attr("sl-class"))});t.on("select2:closing",function(event){dropdownParent.removeClass(t.attr("sl-class"))})}if(t.attr("sl-id")||t.attr("sl-text")){let text=t.attr("sl-text");let id=t.attr("sl-id");if(!text)text=id;if(!id)id=text;let newOption=new Option(text,id,true,true);t.append(newOption).trigger("select")}else{t.select2("val","")}if(t.attr("sl-value"))t.val(t.attr("sl-value")).trigger("change")}catch(e){cl(e)}}var _dbcrs={};var _dbcrsTime=250;function dtp(el2,t){el2.removeAttr(t);let opts={format:t=="date"?"yyyy-mm-dd":t=="time"?"hh:ii":"yyyy-mm-dd hh:ii",weekStart:el2.attr("date-week-start")??1,startView:t=="time"?1:el2.attr("startview")?el2.attr("startview"):2,minView:el2.attr("minview")?el2.attr("minview"):t=="time"?0:t=="datetime"?0:2,maxView:el2.attr("maxview")?el2.attr("maxview"):t=="time"?1:4,todayBtn:t=="time"?0:el2.attr("date-today")=="false"?0:1,todayHighlight:t=="time"?0:el2.attr("date-today")=="false"?0:1,language:el2.attr("date-lang")??"en",minuteStep:el2.attr("date-minute-step")??5,pickerPosition:el2.attr("date-position")??"top-right",autoclose:1,showMeridian:false};if(el2.attr("date-start"))opts["startDate"]=el2.attr("date-start");if(el2.attr("date-end"))opts["endDate"]=el2.attr("date-end");if(el2.attr("date-value"))opts["date"]=el2.attr("date-value");el2.datetimepicker(opts);if(t=="time"){el2.on("show",function(ev){$(".table-condensed > thead, .table-condensed > thead > tr > th, .table-condensed > thead > tr > th > i").attr("style","visibility: hidden; font-size:0px !important; overflow: hidden; height: 0px;")}).on("hide",function(ev){$(".table-condensed > thead, .table-condensed > thead > tr > th, .table-condensed > thead > tr > th > i").attr("style","visibility: visible;")})}if(el2.attr("date-link-start")){el2.on("change",function(e){let dp1=el2.data("datetimepicker");let dp2=$(el2.attr("date-link-start")).data("datetimepicker");dp2.setStartDate(dp1.getFormattedDate());if(dp2.getFormattedDate()<dp1.getFormattedDate()||dp2.getFormattedDate()=="")$(el2.attr("date-link-start")).val(dp1.getFormattedDate())})}else if(el2.attr("date-link-end")){el2.on("change",function(e){let dp1=$(el2.attr("date-link-end")).data("datetimepicker");let dp2=el2.data("datetimepicker");dp1.setEndDate(dp2.getFormattedDate())});opts["useCurrent"]=false}}async function renderSection(tx2,doc2,par2,k,sectionsData){if(tx2.node.isConnected){if(k){tx2._re.update(k)}return tx2._re}var hst=doc2.children;if(doc2.attrs&&doc2.attrs.hasOwnProperty("tpl")){let _payload=typeof _vcD!=="undefined"&&_vcD||(typeof _vcData!=="undefined"?_vcData:void 0);let _tplName=doc2.attrs["tpl"];let _tplKey=btoa("src/tpls/"+_tplName+".tpl");let _tplEntry=_payload&&_payload.tpls&&_payload.tpls[_tplKey];if(_tplEntry){hst=_tplEntry.hst}else{reportLumenError({stage:"tpl",error:new Error('tpl="'+_tplName+'" \u2014 no such file at src/tpls/'+_tplName+".tpl")})}}let _re=await renderHST({hst,mxes:[]},tx2.key,"section",tx2,par2,par2?.view?.scopePath||["View"],void 0,void 0,par2?.view?.views);tx2._re=_re;if(tx2.node){tx2.replaceWith(tx2.node);tx2.node.innerHTML="";tx2.node.append(..._re._RealDOM);_re.setEffects(doc2,tx2.node);_re.renderAll("section")}return _re}async function renderView(n,isSub,d,type="views",viewsArr,scopeBase=["View"]){let filePath="src/views/"+n+".view";if(type=="layouts")filePath="src/layouts/"+n+".layout";cl(arguments);let fileKey=btoa(filePath);if(!isSub){View.props=d??{};var _queryParams=window.location.href.split("?");var nn=_queryParams.shift();View.params=paraToObj(_queryParams)??{}}n=prepareNode(n);var _queryParams=n.split("?");n=_queryParams.shift();let _payload=_vcD||(typeof _vcData!=="undefined"?_vcData:void 0);if(_payload&&!_payload.__hstVersionChecked){_payload.__hstVersionChecked=true;if(_payload.hstFormatVersion!==void 0&&_payload.hstFormatVersion!==EXPECTED_HST_FORMAT_VERSION){reportLumenError({stage:"hst-version-mismatch",error:new Error("This project was compiled for HST format v"+_payload.hstFormatVersion+", but this LumenJS runtime expects v"+EXPECTED_HST_FORMAT_VERSION+". @lmjs/cli and @lmjs/core are out of sync \u2014 reinstall/upgrade both together.")});return}}if(_payload&&_payload[type].hasOwnProperty(fileKey)&&_csswrk.isStarted()){if(isSub)cl("Rendering",n,fileKey);var hst=_payload[type][fileKey];if(isSub){let searchArr=viewsArr||_vt.View.views;let els=[];for(let i=0;i<searchArr.length;i++){let _el2=searchArr[i];if(_el2.__isProxy)_el2=_el2.target;if(_el2.subPath==n)els.push({el:_el2,viewsIndex:i})}if(els.length){for(let i=0;i<els.length;i++){const{el:el2,viewsIndex}=els[i];el2.vars=el2.vars||{};el2.views=el2.views||[];el2.fns=el2.fns||{};let _re=await renderHST(hst,n,"sub",void 0,null,scopeBase.concat(["views",viewsIndex]),el2.vars,el2.fns,el2.views);el2._re=_re;el2.innerHTML="";el2.append(..._re._RealDOM);_re.renderAll()}}}else{if(type=="layouts"){let appSelector=appSettings.App??"[app]";var appContainer=$(appSelector);if(appContainer.length){let _rel=await renderHST(hst,n,"layout");appContainer.data("layout",n).html(_rel._RealDOM);_rel.renderAll();goToNode()}}else{let _re=await renderHST(hst,n,"main");let layout=_re.view.settings.layout;let filePathL="src/layouts/"+layout+".layout";let fileKeyL=btoa(filePathL);let hstL=_payload["layouts"][fileKeyL];let appSelector=appSettings.App??"[app]";var appContainer=$(appSelector);if(appContainer.length){let currentLayout=$(appSelector).data("layout");if(currentLayout!=layout){let _rel=await renderHST(hstL,layout,"layout");appContainer.data("layout",layout).html(_rel._RealDOM);_rel.renderAll()}else{}}else{$("body").prepend("<div "+appSelector+"></div>");let _rel=await renderHST(hstL,layout,"layout");appContainer=$(appSelector);appContainer.data("layout",layout).html(_rel._RealDOM);_rel.renderAll()}$("[body]").html(_re._RealDOM);if(_re.view._slots){for(const slotName in _re.view._slots){if(Object.prototype.hasOwnProperty.call(_re.view._slots,slotName)){$('[slot="'+slotName+'"]').html(_re.view._slots[slotName])}}}_re.renderAll()}}}else{setTimeout(()=>{renderView(n,isSub,d)},10)}}
59221
+ var cl=console.log;class _v{static name;static type;static vars;static fns;static rvs;static _pv;static mx;static views;static hst;static settings;constructor(obj){this.name=obj.name??"home";this.type=obj.type??"main";this.hst=obj.hst??[];this.views=obj.views??[];this.vars=obj.vars??{};this.fns=obj.fns??{};this.rvs=obj.rvs??{};this._pv=obj._pv??null;this.mx=obj.mx??[];this.settings=obj.settings??{layout:"default",requireAuth:false}}}const consoleLogOriginal=console.log;console.log=function(){for(let i=0;i<arguments.length;i++){const arg=arguments[i];if(arg&&arg.hasOwnProperty("__isProxy")||arg?.target){arguments[i]=arguments[i].target}}consoleLogOriginal.apply(console,arguments)};var _lumenDevMode=true;var _lumenErrorLog=[];var EXPECTED_HST_FORMAT_VERSION=1;function _translateLumenError(message){if(!message)return message;return message.replace(/_vt\.View\.vars\[["'`]([^"'`\]]+)["'`]\]/g,"$1")}function reportLumenError(info){info=info||{};var rawMessage=info.message||info.error&&info.error.message||"Unknown error";var entry={time:new Date().toISOString(),stage:info.stage||"runtime",view:info.view||(typeof _vt!=="undefined"&&_vt.View?_vt.View.name:void 0),expr:info.expr,message:_translateLumenError(rawMessage),hint:info.hint};_lumenErrorLog.push(entry);if(_lumenDevMode){console.error("[LumenJS] "+entry.stage+' error in "'+(entry.view||"unknown")+'"'+(entry.expr?" \u2014 "+entry.expr:"")+": "+entry.message+(entry.hint?"\n "+entry.hint:""))}return entry}function _x(_x2){var currPath=[];function _dispatchVarsUpdate(key){let varsIdx=currPath.indexOf("vars");if(varsIdx===-1)return;let varName=varsIdx<currPath.length-1?currPath[varsIdx+1]:key;let rootPath=currPath.slice(0,varsIdx);if(rootPath[0]==="Global"){try{if(typeof window!=="undefined")window[varName]=_x2.Global.vars[varName]}catch(e){}if(_vt.View._re)_vt.View._re.update(varName);return}let owner=_x2;for(let i=0;i<rootPath.length&&owner;i++){owner=owner[rootPath[i]]}if(owner&&owner._re)owner._re.update(varName)}const handler={get(target,key){if(key=="__isProxy")return true;if(target===_x2)currPath=[];currPath.push(key);if(typeof target[key]==="object"&&target[key]!==null&&key!="_re"){return new Proxy(target[key],handler)}else{return target[key]??(key=="target"?target:void 0)??void 0}},set(target,key,value){target[key]=value;try{_dispatchVarsUpdate(key)}catch(e){cl(e)}currPath=[];return true},deleteProperty(target,key){if(!(key in target)){return false}delete target[key];try{_dispatchVarsUpdate(key)}catch(e){cl(e)}return true},ownKeys(target){return Reflect.ownKeys(target)},has(target,key){return key in target},defineProperty(target,key,descriptor){if(descriptor&&"value"in descriptor){target[key]=descriptor.value}return target},getOwnPropertyDescriptor(target,key){const value=target[key];return key in target?{value,enumerable:true,configurable:true}:void 0}};var x=new Proxy(_x2,handler);return x}let _vt=_x({"View":new _v({}),"Global":{"vars":{},"fns":{}},"Widgets":{}});function _lookupInWidgets(name){for(const wname in _vt.Widgets){if(_vt.Widgets[wname].vars.hasOwnProperty(name))return _vt.Widgets[wname].vars[name]}return void 0}function _mergedWidgetsVars(){let out={};let names=Object.keys(_vt.Widgets).reverse();for(const wname of names){out={...out,..._vt.Widgets[wname].vars}}return out}class _lm{_RealDOM=[];_effects={};_cc={};_jj={};_ready=false;view=void 0;sbscrbs=[];reactiveVariables=[];vrs={};_CXR=[];_LXR=[];constructor(view){this.view=view;this.view._re=this;this.reactiveVariables=view?.rvs??{};this.init();if(this.view.type=="main")_vt.View=this.view;if(this.view._pv){this.view._pv.subscribe(this.view)}return this}init(){var par2=this;this.view.hst.forEach(function(doc2){par2.walk(doc2,null)})}subscribe(view){this.sbscrbs.push(view)}scopedEval(context,expr,kk){let ctx=this.concatVarsAtLevel(context,this);if(kk){if(!ctx.hasOwnProperty(kk))return void 0;delete ctx[kk]}try{const evaluator=Function.apply(null,[...Object.keys(ctx),"expr","return eval(expr)"]);return evaluator.apply(null,[...Object.values(ctx),expr])}catch(e){if(e instanceof TypeError){return this.scopedEval(ctx,expr,e.message.split(" ")[0])}reportLumenError({stage:"expression",expr,error:e});return void 0}}getVals(effect){let val="";if(effect.type=="text"){if(!effect.isSplit){for(let i=0;i<effect.splits.length;i++){let split=effect.splits[i];if(split.type=="mustache"){val+=this.getVal(split.content)}else{val+=split.content}}}else{val=this.getVal(effect.content)}}else if(effect.type=="attr"||effect.type=="event"){for(let i=0;i<effect.splits.length;i++){let split=effect.splits[i];if(split.type=="mustache"){val+=this.getVal(split.content)}else{val+=split.content}}}return val}renderAll(){if(this._ready)return;this._ready=true;for(const rv in this._effects){if(Object.prototype.hasOwnProperty.call(this._effects,rv)){const effects=this._effects[rv];for(let ei=0;ei<effects.length;ei++){const effect=effects[ei];if(!effect.nd)continue;try{if(effect.type=="text"){effect.nd.textContent=this.render(effect)}else if(effect.type=="attr"){if(effect.name=="value"){effect.nd.value=this.render(effect)}else{effect.nd.setAttribute(effect.name,this.render(effect));if(effect.name=="view"){effect.nd.subPath=this.render(effect);renderView(this.render(effect),true,{})}}}else if(effect.type=="event"){effect.nd.events[effect.name]=this.render(effect)}}catch(e){cl("Eeeeee",e)}}}}this.updateCXRs();this.updateLXRs();this.updateVXRs();if(typeof appSettings!=="undefined"&&appSettings&&typeof appSettings.tick==="function"){try{appSettings.tick()}catch(e){cl(e)}}}chainConnected(cx){for(let i=cx.chain.length-1;i>=0;i--){const cxs=cx.chain[i];if(cxs.ref.isPreConnected){return true}}return false}async updateVXRs(k){let subsNames=[];for(let i=0;i<this.view.views.length;i++){const _view=this.view.views[i];if(!subsNames.includes(_view.subPath))subsNames.push(_view.subPath)}for(let i=0;i<subsNames.length;i++){const n=subsNames[i];renderView(n,true,{},"views",this.view.views,this.view.scopePath||["View"])}}async updateCXRs(k){for(let i=0;i<this._CXR.length;i++){const cx=this._CXR[i];if(cx.name=="if"){let isTrue=this.evalExp(cx.content,this.reactiveVariables);if(isTrue){await this.showSectionCX(cx,k)}else{await this.hideSectionCX(cx)}}else if(cx.name=="else-if"){if(!this.chainConnected(cx)){let isTrue=this.evalExp(cx.content,this.reactiveVariables);if(isTrue){await this.showSectionCX(cx,k)}else{await this.hideSectionCX(cx)}}else{await this.hideSectionCX(cx)}}else if(cx.name=="else"){if(!this.chainConnected(cx)){await this.showSectionCX(cx,k)}else{await this.hideSectionCX(cx)}}}}async showSectionCX(cx,k){let wasConnected=cx.ref.node.isConnected;cx.ref.isPreConnected=true;await renderSection(cx.ref,cx.doc,this,k);if(!wasConnected)await fireRenderHook(cx,"after-render",cx.ref.node,{visible:true})}async hideSectionCX(cx){if(cx.ref.node.isConnected)await fireRenderHook(cx,"before-render",cx.ref.node,{visible:false});cx.ref.isPreConnected=false;cx.ref.node.replaceWith(cx.ref)}render(effect){let x="";try{if(effect.type=="text"||effect.type=="attr"||effect.type=="event"){x=this.getVals(effect)}}catch(e){cl(e)}return x}update(k){if(!this._ready)return;if(this._effects.hasOwnProperty(k)){const effects=this._effects[k];for(let ei=0;ei<effects.length;ei++){const effect=effects[ei];if(!effect.nd)continue;try{if(effect.type=="text"){effect.nd.textContent=this.render(effect)}else if(effect.type=="attr"){if(effect.name=="value"){effect.nd.value=this.render(effect)}else{effect.nd.setAttribute(effect.name,this.render(effect));if(effect.name=="view"){effect.nd.subPath=this.render(effect);renderView(this.render(effect),true,{})}}}else if(effect.type=="event"){effect.nd.events[effect.name]=this.render(effect)}}catch(e){cl("Eeeeee",e)}}}this.updateCXRs(k);this.updateLXRs(k);for(let sbscsi=0;sbscsi<this.sbscrbs.length;sbscsi++){const sbscr=this.sbscrbs[sbscsi];sbscr._re.update(k)}if(typeof appSettings!=="undefined"&&appSettings&&typeof appSettings.tick==="function"){try{appSettings.tick()}catch(e){cl(e)}}}async updateLXRs(k){for(let i=0;i<this._LXR.length;i++){var cx=this._LXR[i];var forX=cx.forX;if(k&&k!=forX["js"])continue;var val=this.getVal(forX["js"],"");var tempVal=[];if(this.typeStr(val)=="number"){for(let i2=0;i2<val;i2++){tempVal.push(i2)}val=tempVal}let vals=[];let isObj=false;if(this.typeStr(val)=="object"){isObj=true;for(const oKey in val){if(Object.hasOwnProperty.call(val,oKey)){const item=val[oKey];let objj={key:oKey,value:item};vals.push(objj)}}}else vals=clone(val);if(this.typeStr(vals)=="array"&&vals.length>0){let forIf=cx.cond;let limit=vals.length;let offset=0;if(cx.limit)limit=(isNaN(cx.limit)?cx.limit:limit)>vals.length?vals.length:cx.limit*1;if(cx.offset)offset=(isNaN(cx.offset)?cx.offset:offset)<0?0:cx.offset*1;let marray=[];if(forIf){marray=vals.slice(offset*1,vals.length)}else{marray=vals.slice(offset*1,limit*1+offset*1)}let myLimit=0;let arrayToRender=[];let arrayToRenderVXs=[];for(var index=0;index<marray.length;index++){if(myLimit==limit*1)break;try{let vx={};vx["index"]=myLimit;if(forX["dx"]!="")vx[forX["dx"]]=myLimit;if(isObj){if(forX["as"]["v"]!=""){if(forX["as"]["k"])vx[forX["as"]["k"]]=marray[index]["key"];if(forX["as"]["v"])vx[forX["as"]["v"]]=marray[index]["value"]}else{if(forX["as"]["k"])vx[forX["as"]["k"]]=marray[index]}vx["key"]=marray[index]["key"];vx["value"]=marray[index]["value"]}else{if(forX["as"]["k"])vx[forX["as"]["k"]]=marray[index];else if(marray[index]&&typeof marray[index]==="object"){for(const k2 in marray[index]){if(Object.prototype.hasOwnProperty.call(marray[index],k2)){vx[k2]=marray[index][k2]}}}}if(forIf){let _prevVrs=this.vrs;this.vrs=vx;let isTrue;try{isTrue=this.evalExp(forIf,[])}finally{this.vrs=_prevVrs}if(!isTrue)continue}let miIndexx=offset*1+index*1;arrayToRender.push(marray[index]);arrayToRenderVXs.push(vx);myLimit++}catch(e){cl(e)}}let oldATR=cx.atr;cx.atr=clone(arrayToRender);const actions=this.compareArrays(oldATR,arrayToRender);if(actions.length)await fireRenderHook(cx,"before-render",cx.ref.parentElement,{items:arrayToRender,actions});for(let ai=0;ai<actions.length;ai++){const actn=actions[ai];if(actn.action=="add"){let vx=arrayToRenderVXs[actn.index];let cln=await this.createSection(cx,vx,isObj,forX);cx.ref.before(cln);cln.replaceWith(cln.node)}else if(actn.action=="remove"){var keyed=cx.key+"_"+actn.index;let tx2=cx.ref?.nodes[keyed];if(tx2){tx2.remove();tx2.node.remove();delete cx.tx?.nodes[keyed]}}else{var keyed=cx.key+"_"+actn.index;let tx2=cx.ref?.nodes[keyed];let vx=arrayToRenderVXs[actn.index];if(tx2){tx2._re.vrs=vx;if(tx2.isObj){if(tx2.forX.as["k"]!="")tx2._re.update(tx2.forX.as["k"]);else tx2._re.update(tx2.forX.js);if(tx2.forX.as["v"]!="")tx2._re.update(tx2.forX.as["v"]);for(let actnsi=0;actnsi<actn.updates.length;actnsi++){const actnu=actn.updates[actnsi];tx2._re.update(actnu.property)}}else{if(tx2.forX.as["k"]!="")tx2._re.update(tx2.forX.as["k"]);else tx2._re.update(tx2.forX.js)}}}}if(actions.length)await fireRenderHook(cx,"after-render",cx.ref.parentElement,{items:arrayToRender,actions})}else{cx.nodes=[]}}}compareLogic(array1,array2){if(array1.length===array2.length){return 1}else{if(array1.length>array2.length){return 2}else{return 3}}}compareArrays(array1,array2){const actions=[];const maxLength=Math.max(array1.length,array2.length);for(let i=0;i<maxLength;i++){const element1=array1[i];const element2=array2[i];if(!element2){actions.push({action:"remove",index:i})}else if(!element1){actions.push({action:"add",index:i,element:element2})}else if(!this.deepCompare(element1,element2)){actions.push({action:"update",index:i,updates:this.getUpdates(element1,element2)})}}return actions}findDeletedIndexes(array1,array2){const deletedIndexes=[];let par2=this;array1.forEach((item,index)=>{const foundIndex=array2.findIndex(el2=>par2.deepCompare(el2,item));if(foundIndex===-1){deletedIndexes.push(index)}});return deletedIndexes}findAddedIndexes(array1,array2){const addedIndexes=[];let par2=this;array2.forEach((item,index)=>{const foundIndex=array1.findIndex(el2=>par2.deepCompare(el2,item));if(foundIndex===-1){addedIndexes.push(index)}});return addedIndexes}deepCompare(obj1,obj2){return JSON.stringify(obj1)===JSON.stringify(obj2)}getUpdates(oldObj,newObj){const updates=[];for(const key in newObj){if(newObj.hasOwnProperty(key)&&newObj[key]!==oldObj[key]){updates.push({property:key,value:newObj[key]})}}return updates}getVal(mo,indexName){let vars={};try{for(let i=0;i<this.reactiveVariables.length;i++){let __name=this.reactiveVariables[i];if(_vt.View.vars.hasOwnProperty(__name)){vars[__name]=_vt.View.vars[__name]}else{let _wv=_lookupInWidgets(__name);vars[__name]=_wv!==void 0?_wv:_vt.Global.vars[__name]}}for(const ky in this.vrs){if(Object.prototype.hasOwnProperty.call(this.vrs,ky)){vars[ky]=this.vrs[ky]}}if(this.view&&this.view.vars){for(const ky in this.view.vars){if(Object.prototype.hasOwnProperty.call(this.view.vars,ky)){vars[ky]=this.view.vars[ky]}}}}catch(e){cl(e)}mo=mo.trim();if(mo.slice(0,2)=="{{"){mo=mo.slice(2,-2)}let value="";let _mo=mo;if(mo.indexOf("`")>-1){var matchesVal=_mo.match(/\.`[\s\S]*?`/g);if(matchesVal)for(var y=0;y<matchesVal.length;y++){_mo=_mo.split(matchesVal[y]).join("."+this.getVal(matchesVal[y].substr(1).slice(1,-1),indexName))}var matchesVal=_mo.match(/`[\s\S]*?`/g);if(matchesVal)for(var y=0;y<matchesVal.length;y++){_mo=_mo.split(matchesVal[y]).join("'"+this.getVal(matchesVal[y].slice(1,-1),indexName)+"'")}return this.getVal(_mo,indexName)}if(mo.indexOf(";")>-1){let zxx=mo.split(";");mo=$.trim(zxx[0])}if(mo.indexOf(" as ")>-1){mo=mo.split(" as ");return this.getVal(mo[0],indexName)}if(indexName){indexName=indexName.toString();if(mo.indexOf(indexName)>-1&&mo!=indexName&&vars.hasOwnProperty(indexName)&&mo!="index"){mo=mo.split(indexName).join(vars[indexName]);return this.getVal(mo,indexName)}}var Ondex=mo.match(/\bindex\b/g);if(Ondex&&mo!="index"&&vars.hasOwnProperty("index")){_mo=mo.replace(/\bindex\b/g,vars["index"]);return this.getVal(_mo,indexName)}value=this.lookup(mo,vars);return value??""}concatVarsAtLevel(levelVars,parent2){if(!parent2.view._pv){var concatenatedVars={...levelVars};if(parent2.view.vars){concatenatedVars={..._vt.Global.vars,..._mergedWidgetsVars(),...parent2.view.vars,...concatenatedVars}}return concatenatedVars}var concatenatedVars={...levelVars};if(parent2.view.vars){concatenatedVars={...parent2.view.vars,...concatenatedVars}}return this.concatVarsAtLevel(concatenatedVars,parent2.view._pv)}lookup(name,vaz){let vars=this.concatVarsAtLevel(vaz,this);try{var value;var names,index,lookupHit=false;if(this.hasProperty(vars,name)){value=vars[name]}else if(name.indexOf(".")>-1&&name.indexOf("[")==-1){var value=this.scopedEval(vars,name);if(!(value||value==0)){value=vars;names=name.split(".");index=0;while(value!=null&&index<names.length){if(index===names.length-1)lookupHit=this.hasProperty(value,names[index]);value=value[names[index++]]}}}else{var value=this.scopedEval(vars,name);if(!(value||value==0)){if(name.indexOf(".")==-1&&name.indexOf("[")>-1){let _name=name;var matchesVal=_name.match(/\[[\s\S]*?\]/g);for(var y=0;y<matchesVal.length;y++){if(matchesVal[y].indexOf("'")==-1&&matchesVal[y].indexOf('"')==-1)_name=_name.split(matchesVal[y]).join("['"+matchesVal[y].slice(1,-1)+"']")}var value=this.scopedEval(vars,_name)}}}if(this.isFunction(value))value=value.call(value)}catch(e){reportLumenError({stage:"lookup",expr:name,error:e});return""}return value}objectToString=Object.prototype.toString;isArray=Array.isArray||function isArrayPolyfill(object){return objectToString.call(object)==="[object Array]"};isFunction(object){return typeof object==="function"}typeStr(obj){return this.isArray(obj)?"array":typeof obj}hasProperty(obj,propName){return obj!=null&&typeof obj==="object"&&propName in obj}createEl(tag,attrs,children,events,doc2){const _el2=document.createElement(tag);Object.defineProperty(_el2,"_ownerRe",{value:this,enumerable:false,configurable:true,writable:true});_el2.isSub=false;if(attrs.hasOwnProperty("view")){_el2.isSub=true;_el2.subPath=attrs["view"];_el2.vars={};_el2.views=[];_el2.fns={};if(doc2&&doc2.evs&&doc2.evs.hasOwnProperty("@init")){let _initAttr=doc2.evs["@init"];if(_initAttr){let _initResult=evalEvAttr(_initAttr,{cType:"init"},$(_el2),"init",this.vrs);if(_initResult&&typeof _initResult==="object"&&typeof _initResult.then!=="function"){Object.assign(_el2.vars,_initResult)}}}this.view.views.push(_el2)}_el2.events={};for(const prop in attrs){if(prop=="view"||prop==":data"||prop==":if"||prop==":else-if"||prop==":else"||prop==":for"||prop==":for-limit"||prop==":for-offset"||prop==":for-if")continue;try{let val=doc2&&doc2.ax.hasOwnProperty(prop)?"":attrs[prop];if(prop=="value"){_el2.value=val}else _el2.setAttribute(prop,val)}catch(e){cl(e)}}for(const prop in events){try{_el2.events[prop]=events[prop]}catch(e){cl(e)}}if(children.length)_el2.append(...children);if(events&&events["@after-render"]&&!(attrs&&(attrs.hasOwnProperty(":for")||attrs.hasOwnProperty(":if")||attrs.hasOwnProperty(":else-if")||attrs.hasOwnProperty(":else")))){fireRenderHook({doc:doc2},"after-render",_el2,{})}autoInitPlugins(_el2,attrs);return _el2}evalExp(expr,vars){let rvars={};try{for(let i=0;i<vars.length;i++){let __name=vars[i];if(_vt.View.vars.hasOwnProperty(__name)){rvars[__name]=_vt.View.vars[__name]}else{let _wv=_lookupInWidgets(__name);rvars[__name]=_wv!==void 0?_wv:_vt.Global.vars[__name]}}for(const ky in this.vrs){if(Object.prototype.hasOwnProperty.call(this.vrs,ky)){rvars[ky]=this.vrs[ky]}}if(this.view&&this.view.vars){for(const ky in this.view.vars){if(Object.prototype.hasOwnProperty.call(this.view.vars,ky)){rvars[ky]=this.view.vars[ky]}}}}catch(e){cl(e)}try{var value=this.scopedEval(rvars,expr);if(value&&value!=0)return true}catch(e){reportLumenError({stage:"condition",expr,error:e});return false}return false}splitTextWithMustaches(text,mustaches){mustaches.sort((a,b)=>a.start-b.start);const elements=[];let currentIndex=0;for(const mustache of mustaches){if(currentIndex<mustache.start){elements.push({type:"static",content:text.substring(currentIndex,mustache.start)})}elements.push({type:"mustache",jst:mustache.jst,rvs:mustache.rvs,content:text.substring(mustache.start,mustache.end)});currentIndex=mustache.end}if(currentIndex<text.length){elements.push({type:"static",content:text.substring(currentIndex)})}return elements}walk(doc,parent){var par=this;var tx,el;switch(doc.type){case"text":if(doc.mss.length){let splitIt=true;if(doc.tag=="textarea"){splitIt=false}if(splitIt){let splits=this.splitTextWithMustaches(doc.content,doc.mss);for(let si=0;si<splits.length;si++){const split=splits[si];if(split.type=="static"){let txnd=document.createTextNode(split.content);if(!parent)par._RealDOM.push(txnd);(tx??(tx=[])).push(txnd)}else{let txnd=document.createTextNode("");for(let ri=0;ri<split.rvs.length;ri++){const element=split.rvs[ri];(this._effects[element]??(this._effects[element]=[])).push({"type":"text","content":split.content,"jst":split.jst,"rvs":split.rvs,"isSplit":true,"nd":txnd,"tag":doc.tag})}if(!parent)par._RealDOM.push(txnd);(tx??(tx=[])).push(txnd)}}return tx}else{tx=document.createTextNode("");for(let mui=0;mui<doc.mss.length;mui++){const mus=doc.mss[mui];for(let ri=0;ri<mus.rvs.length;ri++){const element=mus.rvs[ri];(this._effects[element]??(this._effects[element]=[])).push({"type":"text","content":doc.content,"splits":this.splitTextWithMustaches(doc.content,doc.mss),"jst":mus.jst,"rvs":mus.rvs,"isSplit":false,"nd":tx,"tag":doc.tag})}}if(!parent)par._RealDOM.push(tx);return tx}}else{tx=document.createTextNode(doc.content);if(!parent)par._RealDOM.push(tx);return tx}break;case"sections":case"section":var _dd=md5(new Date().getTime()/1e3+"::"+Math.random());tx=document.createTextNode("");var typeN=null;if(doc.attrs.hasOwnProperty(":else"))typeN="else";else if(doc.attrs.hasOwnProperty(":else-if"))typeN="else-if";else if(doc.attrs.hasOwnProperty(":if"))typeN="if";else typeN="for";if(doc.type=="section"){var chain=[];if(typeN=="else-if"||typeN=="else"){try{let lastInChain=this._CXR.at(-1);if(lastInChain){_dd=lastInChain.key;chain.push(...lastInChain.chain,lastInChain)}}catch(e){}}el=par.createEl(doc.name,doc.attrs,[],doc.evs,doc);tx.node=el;this._CXR.push({"type":"section","name":typeN,"content":doc.cond,"doc":doc,"key":_dd,"chain":chain,"ref":tx});this.setEffects(doc,el)}else if(doc.type=="sections"){tx.key=_dd;tx.node=null;tx.nodes={};let docRaw=doc;this._LXR.push({"type":"sections","name":typeN,"cond":doc.attrs.hasOwnProperty(":for-if")?doc.attrs[":for-if"]:null,"limit":doc.attrs.hasOwnProperty(":for-limit")?doc.attrs[":for-limit"]:0,"offset":doc.attrs.hasOwnProperty(":for-offset")?doc.attrs[":for-offset"]:0,"content":doc.content,"forX":doc.forX,"doc":docRaw,"key":_dd,"atr":[],"ref":tx})}if(!parent)par._RealDOM.push(tx);return tx;break;case"tag":var _dd=md5(new Date().getTime()/1e3+"::"+Math.random());if(doc.name.toLowerCase()=="settings"){if(par.view.type=="main"){var defaultSettings={layout:"default",requireAuth:false};try{let settingsC=doc.children[0].content;let settings={};eval("settings = "+settingsC+";");if(settings){if(settings.layout==null)settings.layout="default";if(settings.requireAuth==null)settings.requireAuth=false;par.view.settings=settings}else{par.view.settings=defaultSettings}}catch(e){setError(e,"Error in your settings tag inside the '"+par.view.name.toLowerCase()+"' main view!");par.view.settings=defaultSettings}}}else if(doc.name.toLowerCase()=="script"||doc.name.toLowerCase()=="js"){let child=doc.children[0];let js=child.content;let jst=child.jst;let isScoped=false;if(doc.attrs.hasOwnProperty("scoped")){delete doc.attrs["scoped"];isScoped=true}el=par.createEl("script",doc.attrs,[],doc.evs,doc);el._sc=isScoped;el._dd=_dd;el._jst=jst;(par._jj[_dd]??(par._jj[_dd]=[])).push({"nd":el})}else if(doc.name.toLowerCase()=="style"){let css=doc.children[0].content;let isScoped=false;el=par.createEl("style",{},[],doc.evs,doc);if(doc.attrs.hasOwnProperty("scoped")){if(!parent){if(par.view._dd)_dd=par.view._dd;else{par.view._dd=_dd;if(par.view.type=="main")$("[body]")[0].setAttribute("vuid",_dd)}}else{if(parent._dd)_dd=parent._dd;else{parent._dd=_dd;parent.setAttribute("vuid",_dd)}}delete doc.attrs["scoped"];isScoped=true;el._sc=isScoped;el._dd=_dd;el._css=css;(par._cc[_dd]??(par._cc[_dd]=[])).push({"nd":el,"_css":css})}else{el._sc=isScoped;el._dd=_dd;el.textContent=css}for(const prop in doc.attrs){try{_el.setAttribute(prop,doc.attrs[prop])}catch(e){cl(e)}}}else if(doc.name.toLowerCase()=="icon"){let child=par.createEl("span",{"class":"iconify","data-icon":doc?.icon??"mdi:home"},[],{},null);el=par.createEl("span",doc.attrs,[child],doc.evs,doc)}else if(doc.name.toLowerCase()=="slot"){let slotName=doc.attrs&&doc.attrs.name;if(slotName){let tempWrapper=document.createElement("div");let childs=[];for(let i=0;i<doc.children.length;i++){const dc=doc.children[i];let chils=par.walk(dc,tempWrapper);if(chils){if(Array.isArray(chils)){if(chils.length)childs=[...childs,...chils]}else{childs.push(chils)}}}(par.view._slots??(par.view._slots={}))[slotName]=childs}}else if(doc.attrs&&doc.attrs.hasOwnProperty("tpl")&&!doc.attrs.hasOwnProperty(":for")){reportLumenError({stage:"tpl",error:new Error('tpl="'+doc.attrs["tpl"]+'" must be used together with :for on the same element \u2014 templates only render inside a repeated/list context.')})}else{el=par.createEl(doc.name,doc.attrs,[],doc.evs,doc);if(!doc.isV&&!el.isSub){let childs=[];for(let i=0;i<doc.children.length;i++){const dc=doc.children[i];let chils=par.walk(dc,el);if(chils){if(Array.isArray(chils)){if(chils.length)childs=[...childs,...chils]}else{childs.push(chils)}}}childs.length?el.append(...childs):null}}this.setEffects(doc,el);if(el){if(!parent)par._RealDOM.push(el)}return el;break;case"comment":break;default:break}}setEffects(doc2,el2){let rvs=[];if(Object.keys(doc2.ax).length){for(const attrName in doc2.ax){if(Object.hasOwnProperty.call(doc2.ax,attrName)){const attrMustaches=doc2.ax[attrName];for(let i=0;i<attrMustaches.length;i++){const mus=attrMustaches[i];for(let ri=0;ri<mus.rvs.length;ri++){const element=mus.rvs[ri];rvs.push(element);(this._effects[element]??(this._effects[element]=[])).push({"type":"attr","name":attrName,"content":doc2.attrs[attrName],"splits":this.splitTextWithMustaches(doc2.attrs[attrName],doc2.ax[attrName]),"jst":mus.jst,"rvs":mus.rvs,"nd":el2})}}}}}if(Object.keys(doc2.ex).length){for(const ky in doc2.ex){if(Object.hasOwnProperty.call(doc2.ex,ky)){const mss=doc2.ex[ky];for(let i=0;i<mss.length;i++){const mus=mss[i];for(let ri=0;ri<mus.rvs.length;ri++){const element=mus.rvs[ri];rvs.push(element);(this._effects[element]??(this._effects[element]=[])).push({"type":"event","name":ky,"content":doc2.evs[ky],"splits":this.splitTextWithMustaches(doc2.evs[ky],doc2.ex[ky]),"jst":mus.jst,"rvs":mus.rvs,"nd":el2})}}}}}return rvs.filter((value,index,self)=>{return self.indexOf(value)===index})}async createSection(cx,vx,isObj,forX){var keyed=cx.key+"_"+vx.index;var tx2=document.createTextNode("");var typeN2=null;if(cx.doc.attrs.hasOwnProperty(":else"))typeN2="else";else if(cx.doc.attrs.hasOwnProperty(":else-if"))typeN2="else-if";else if(cx.doc.attrs.hasOwnProperty(":if"))typeN2="if";else typeN2="for";let el2=this.createEl(cx.doc.name,cx.doc.attrs,[],cx.doc.evs,cx.doc);tx2.node=el2;tx2.key=cx.key;tx2.keyed=keyed;tx2.isObj=isObj;tx2.forX=forX;tx2.vx=vx;let scsc=await renderSection(tx2,cx.doc,this,cx.key);scsc._re=scsc;cx.ref.nodes[keyed]=tx2;return tx2}attrString(attrs){var buff=[];for(var key in attrs){buff.push(key+'="'+attrs[key]+'"')}if(!buff.length)return"";return" "+buff.join(" ")}_stringify(buff,doc2){var par2=this;switch(doc2.type){case"text":return buff+doc2.content;case"tag":buff+="<"+doc2.name+(doc2.attrs?par2.attrString(doc2.attrs):"")+(doc2.isV?"/>":">");if(doc2.isV)return buff;for(let i=0;i<doc2.children.length;i++){const dc=doc2.children[i];buff=buff+par2._stringify("",dc)}return buff+"</"+doc2.name+">";case"comment":return buff;default:return""}}stringify(doc2){var par2=this;return doc2.reduce(function(token,rootEl){return token+par2._stringify("",rootEl)},"")}}async function renderHST(hst,n,type="main",tx2,_pv=null,scopePath=["View"],ownVars,ownFns,ownViews){var reactiveVariables=hst.reactiveVars;hst=hst.hst;let _re=new _lm(new _v({"name":n,"type":type,"hst":hst,"vars":ownVars??tx2?.vx,"fns":ownFns,"views":ownViews,"rvs":reactiveVariables,"_pv":_pv}));_re.view.scopePath=scopePath;if(Object.keys(_re._cc).length){for(const ky in _re._cc){if(Object.hasOwnProperty.call(_re._cc,ky)){const csses=_re._cc[ky];for(let inde=0;inde<csses.length;inde++){let prom=new defer;const css=csses[inde];_csswrk.trigger("css-ready",{"csses":[css._css],"pre":"[vuid='"+ky+"']","key":ky});_vuid[ky]=prom;let _csses=await prom;css.nd.textContent=_csses[0]}}}}if(Object.keys(_re._jj).length){for(const ky in _re._jj){if(Object.hasOwnProperty.call(_re._jj,ky)){const jses=_re._jj[ky];for(let inde=0;inde<jses.length;inde++){const nd=jses[inde].nd;let code=getWatcher(nd._jst,_re.view,reactiveVariables,scopePath).code;code=`try { `+code+` } catch (e) { reportLumenError({ stage: 'script', error: e }); }`;code=code+`
59222
+ //# sourceURL=`+(_re.view?.name||"view")+`.view.generated.js`;nd.textContent=code}}}}return _re}async function fireRenderHook(cx,n,containerEl,extra){if(!containerEl)return;let attrKey="@"+n;if(!cx.doc||!cx.doc.evs||!cx.doc.evs.hasOwnProperty(attrKey))return;let attrVal=cx.doc.evs[attrKey];if(!attrVal)return;let ev=Object.assign({cType:n},extra||{});let result=evalEvAttr(attrVal,ev,$(containerEl),n);if(result&&typeof result.then==="function"){try{return await result}catch(e){return void 0}}return result}function autoInitPlugins(el2,attrs){if(!attrs)return;try{if(attrs.hasOwnProperty("sl")&&typeof $.fn.select2==="function"){initSl($(el2))}if(attrs.hasOwnProperty("color")&&typeof $.fn.colorpicker==="function"){$(el2).removeAttr("color").colorpicker({format:"rgba"})}if(typeof $.fn.datetimepicker==="function"){if(attrs.hasOwnProperty("time"))dtp($(el2),"time");if(attrs.hasOwnProperty("date"))dtp($(el2),"date");if(attrs.hasOwnProperty("datetime"))dtp($(el2),"datetime")}}catch(e){cl(e)}}function initSl(t){if(t.hasClass("select2-hidden-accessible"))return;try{var plchldr=t.attr("placeholder")?t.attr("placeholder"):"";var dir=$("body").hasClass("rtl")?"rtl":"ltr";var nr=t.attr("sl-nrmsg")?t.attr("sl-nrmsg"):"No results found";var minResultsForSearch=t.attr("sl-mins")?t.attr("sl-mins"):10;var allowNewTags=t.attr("sl-ntgs")?true:false;var dropdownParent=t.attr("sl-prt")?t.attr("sl-prt"):"body";if(dropdownParent=="self")dropdownParent=t.parent();else dropdownParent=$(dropdownParent);var query=t.attr("sl-query")?t.attr("sl-query"):null;var uniquer=Date.now();if(typeof window[query]==="function"){t.select2.amd.define("adapt_"+uniquer,["select2/data/array","select2/utils"],function(ArrayAdapter,Utils){function CustomDataAdapter($element,options){CustomDataAdapter.__super__.constructor.call(this,$element,options)}Utils.Extend(CustomDataAdapter,ArrayAdapter);CustomDataAdapter.prototype.query=function(params,callback){clearTimeout(_dbcrs[uniquer]);let _t=t;_dbcrs[uniquer]=setTimeout(function(){window[query](params,callback,_t)},!_dbcrs.hasOwnProperty(uniquer)?0:_dbcrsTime)};return CustomDataAdapter});t.select2({dropdownParent,minimumResultsForSearch:minResultsForSearch,placeholder:plchldr,dir,tags:allowNewTags,allowClear:true,language:{noResults:function(){return nr}},...t.select2.amd.require("adapt_"+uniquer)?{ajax:{},dataAdapter:t.select2.amd.require("adapt_"+uniquer)}:{}})}else{t.select2({dropdownParent,minimumResultsForSearch:minResultsForSearch,placeholder:plchldr,dir,tags:allowNewTags,allowClear:true,language:{noResults:function(){return nr}}})}if(t.attr("sl-nosrch"))t.on("select2:opening select2:closing",function(event){$(this).parent().find(".select2-search__field").prop("disabled",true)});if(t.attr("sl-class")){t.on("select2:opening",function(event){dropdownParent.addClass(t.attr("sl-class"))});t.on("select2:closing",function(event){dropdownParent.removeClass(t.attr("sl-class"))})}if(t.attr("sl-id")||t.attr("sl-text")){let text=t.attr("sl-text");let id=t.attr("sl-id");if(!text)text=id;if(!id)id=text;let newOption=new Option(text,id,true,true);t.append(newOption).trigger("select")}else{t.select2("val","")}if(t.attr("sl-value"))t.val(t.attr("sl-value")).trigger("change")}catch(e){cl(e)}}var _dbcrs={};var _dbcrsTime=250;function dtp(el2,t){el2.removeAttr(t);let opts={format:t=="date"?"yyyy-mm-dd":t=="time"?"hh:ii":"yyyy-mm-dd hh:ii",weekStart:el2.attr("date-week-start")??1,startView:t=="time"?1:el2.attr("startview")?el2.attr("startview"):2,minView:el2.attr("minview")?el2.attr("minview"):t=="time"?0:t=="datetime"?0:2,maxView:el2.attr("maxview")?el2.attr("maxview"):t=="time"?1:4,todayBtn:t=="time"?0:el2.attr("date-today")=="false"?0:1,todayHighlight:t=="time"?0:el2.attr("date-today")=="false"?0:1,language:el2.attr("date-lang")??"en",minuteStep:el2.attr("date-minute-step")??5,pickerPosition:el2.attr("date-position")??"top-right",autoclose:1,showMeridian:false};if(el2.attr("date-start"))opts["startDate"]=el2.attr("date-start");if(el2.attr("date-end"))opts["endDate"]=el2.attr("date-end");if(el2.attr("date-value"))opts["date"]=el2.attr("date-value");el2.datetimepicker(opts);if(t=="time"){el2.on("show",function(ev){$(".table-condensed > thead, .table-condensed > thead > tr > th, .table-condensed > thead > tr > th > i").attr("style","visibility: hidden; font-size:0px !important; overflow: hidden; height: 0px;")}).on("hide",function(ev){$(".table-condensed > thead, .table-condensed > thead > tr > th, .table-condensed > thead > tr > th > i").attr("style","visibility: visible;")})}if(el2.attr("date-link-start")){el2.on("change",function(e){let dp1=el2.data("datetimepicker");let dp2=$(el2.attr("date-link-start")).data("datetimepicker");dp2.setStartDate(dp1.getFormattedDate());if(dp2.getFormattedDate()<dp1.getFormattedDate()||dp2.getFormattedDate()=="")$(el2.attr("date-link-start")).val(dp1.getFormattedDate())})}else if(el2.attr("date-link-end")){el2.on("change",function(e){let dp1=$(el2.attr("date-link-end")).data("datetimepicker");let dp2=el2.data("datetimepicker");dp1.setEndDate(dp2.getFormattedDate())});opts["useCurrent"]=false}}async function renderSection(tx2,doc2,par2,k,sectionsData){if(tx2.node.isConnected){if(k){tx2._re.update(k)}return tx2._re}var hst=doc2.children;if(doc2.attrs&&doc2.attrs.hasOwnProperty("tpl")){let _payload=typeof _vcD!=="undefined"&&_vcD||(typeof _vcData!=="undefined"?_vcData:void 0);let _tplName=doc2.attrs["tpl"];let _tplKey=btoa("src/tpls/"+_tplName+".tpl");let _tplEntry=_payload&&_payload.tpls&&_payload.tpls[_tplKey];if(_tplEntry){hst=_tplEntry.hst}else{reportLumenError({stage:"tpl",error:new Error('tpl="'+_tplName+'" \u2014 no such file at src/tpls/'+_tplName+".tpl")})}}let _re=await renderHST({hst,mxes:[]},tx2.key,"section",tx2,par2,par2?.view?.scopePath||["View"],void 0,void 0,par2?.view?.views);tx2._re=_re;if(tx2.node){tx2.replaceWith(tx2.node);tx2.node.innerHTML="";tx2.node.append(..._re._RealDOM);_re.setEffects(doc2,tx2.node);_re.renderAll("section")}return _re}async function renderView(n,isSub,d,type="views",viewsArr,scopeBase=["View"]){let filePath="src/views/"+n+".view";if(type=="layouts")filePath="src/layouts/"+n+".layout";let fileKey=btoa(filePath);if(!isSub){View.props=d??{};var _queryParams=window.location.href.split("?");var nn=_queryParams.shift();View.params=paraToObj(_queryParams)??{}}n=prepareNode(n);var _queryParams=n.split("?");n=_queryParams.shift();let _payload=_vcD||(typeof _vcData!=="undefined"?_vcData:void 0);if(_payload&&!_payload.__hstVersionChecked){_payload.__hstVersionChecked=true;if(_payload.hstFormatVersion!==void 0&&_payload.hstFormatVersion!==EXPECTED_HST_FORMAT_VERSION){reportLumenError({stage:"hst-version-mismatch",error:new Error("This project was compiled for HST format v"+_payload.hstFormatVersion+", but this LumenJS runtime expects v"+EXPECTED_HST_FORMAT_VERSION+". @lmjs/cli and @lmjs/core are out of sync \u2014 reinstall/upgrade both together.")});return}}if(_payload&&_payload[type].hasOwnProperty(fileKey)&&_csswrk.isStarted()){if(isSub)cl("Rendering",n,fileKey);var hst=_payload[type][fileKey];if(isSub){let searchArr=viewsArr||_vt.View.views;let els=[];for(let i=0;i<searchArr.length;i++){let _el2=searchArr[i];if(_el2.__isProxy)_el2=_el2.target;if(_el2.subPath==n)els.push({el:_el2,viewsIndex:i})}if(els.length){for(let i=0;i<els.length;i++){const{el:el2,viewsIndex}=els[i];el2.vars=el2.vars||{};el2.views=el2.views||[];el2.fns=el2.fns||{};let _re=await renderHST(hst,n,"sub",void 0,null,scopeBase.concat(["views",viewsIndex]),el2.vars,el2.fns,el2.views);el2._re=_re;el2.innerHTML="";el2.append(..._re._RealDOM);_re.renderAll()}}}else{if(type=="layouts"){let appSelector=appSettings.App??"[app]";var appContainer=$(appSelector);if(appContainer.length){let _rel=await renderHST(hst,n,"layout");appContainer.data("layout",n).html(_rel._RealDOM);_rel.renderAll();goToNode()}}else{let _re=await renderHST(hst,n,"main");let layout=_re.view.settings.layout;let filePathL="src/layouts/"+layout+".layout";let fileKeyL=btoa(filePathL);let hstL=_payload["layouts"][fileKeyL];let appSelector=appSettings.App??"[app]";var appContainer=$(appSelector);let layoutJustSwapped=false;if(appContainer.length){let currentLayout=$(appSelector).data("layout");if(currentLayout!=layout){let _rel=await renderHST(hstL,layout,"layout");appContainer.data("layout",layout).html(_rel._RealDOM);_rel.renderAll();layoutJustSwapped=true}else{}}else{$("body").prepend("<div "+appSelector+"></div>");let _rel=await renderHST(hstL,layout,"layout");appContainer=$(appSelector);appContainer.data("layout",layout).html(_rel._RealDOM);_rel.renderAll();layoutJustSwapped=true}let declaredRegions=hstL&&hstL.regions||[];for(const regionName of declaredRegions){let settingsKey="has"+regionName[0].toUpperCase()+regionName.slice(1);let want=_re.view.settings.hasOwnProperty(settingsKey)?_re.view.settings[settingsKey]:true;let resolvedFile=want===false?null:want===true?regionName:want;let w=_vt.Widgets[regionName]||(_vt.Widgets[regionName]={vars:{},fns:{},views:[],_re:null,_resolvedFile:void 0});if(resolvedFile!==w._resolvedFile){if(resolvedFile===null){$("["+regionName+"]").html("");w._re=null}else{let wFilePath="src/views/widgets/"+resolvedFile+".view";let wHst=_payload["views"][btoa(wFilePath)];if(wHst){let _rew=await renderHST(wHst,resolvedFile,"widget",void 0,null,["Widgets",regionName],w.vars,w.fns,w.views);w._re=_rew;$("["+regionName+"]").html(_rew._RealDOM);_rew.renderAll()}}w._resolvedFile=resolvedFile}else if(layoutJustSwapped&&w._re){$("["+regionName+"]").html(w._re._RealDOM)}}$("[body]").html(_re._RealDOM);if(_re.view._slots){for(const slotName in _re.view._slots){if(Object.prototype.hasOwnProperty.call(_re.view._slots,slotName)){$('[slot="'+slotName+'"]').html(_re.view._slots[slotName])}}}_re.renderAll()}}}else{setTimeout(()=>{renderView(n,isSub,d)},10)}}
59223
59223
 
59224
59224
  !(function(a,b){"function"==typeof define&&define.amd?define([],b):"undefined"!=typeof module&&module.exports?module.exports=b():a.ReconnectingWebSocket=b()})(this,function(){function a(b,c,d){function l(a2,b2){var c2=document.createEvent("CustomEvent");return c2.initCustomEvent(a2,false,false,b2),c2}var e={debug:false,automaticOpen:true,reconnectInterval:1e3,maxReconnectInterval:3e4,reconnectDecay:1,timeoutInterval:3e3};d||(d={});for(var f in e)this[f]="undefined"!=typeof d[f]?d[f]:e[f];this.url=b,this.reconnectAttempts=0,this.readyState=WebSocket.CONNECTING,this.protocol=null;var h,g=this,i2=false,j=false,k=document.createElement("div");k.addEventListener("open",function(a2){g.onopen(a2)}),k.addEventListener("close",function(a2){g.onclose(a2)}),k.addEventListener("connecting",function(a2){g.onconnecting(a2)}),k.addEventListener("message",function(a2){g.onmessage(a2)}),k.addEventListener("error",function(a2){g.onerror(a2)}),this.addEventListener=k.addEventListener.bind(k),this.removeEventListener=k.removeEventListener.bind(k),this.dispatchEvent=k.dispatchEvent.bind(k),this.open=function(b2){try{h=new WebSocket(g.url,c||[]),b2||k.dispatchEvent(l("connecting")),(g.debug||a.debugAll)&&console.debug("ReconnectingWebSocket","attempt-connect",g.url);var d2=h,e2=setTimeout(function(){(g.debug||a.debugAll)&&console.debug("ReconnectingWebSocket","connection-timeout",g.url),j=true,j=false;if(d2.readyState==1)d2.close()},g.timeoutInterval);h.onopen=function(){clearTimeout(e2),(g.debug||a.debugAll)&&console.debug("ReconnectingWebSocket","onopen",g.url),g.protocol=h.protocol,g.readyState=WebSocket.OPEN,g.reconnectAttempts=0;var d3=l("open");d3.isReconnect=b2,b2=false,k.dispatchEvent(d3)},h.onclose=function(c2){if(clearTimeout(e3),h=null,i2)g.readyState=WebSocket.CLOSED,k.dispatchEvent(l("close"));else{g.readyState=WebSocket.CONNECTING;var d3=l("connecting");d3.code=c2.code,d3.reason=c2.reason,d3.wasClean=c2.wasClean,k.dispatchEvent(d3),b2||j||((g.debug||a.debugAll)&&console.debug("ReconnectingWebSocket","onclose",g.url),k.dispatchEvent(l("close")));var e3=g.reconnectInterval*Math.pow(g.reconnectDecay,g.reconnectAttempts);setTimeout(function(){g.reconnectAttempts++,g.open(true)},e3>g.maxReconnectInterval?g.maxReconnectInterval:e3)}},h.onmessage=function(b3){(g.debug||a.debugAll)&&console.debug("ReconnectingWebSocket","onmessage",g.url,b3.data);var c2=l("message");c2.data=b3.data,k.dispatchEvent(c2)},h.onerror=function(b3){(g.debug||a.debugAll)&&console.debug("ReconnectingWebSocket","onerror",g.url,b3),k.dispatchEvent(l("error"))}}catch(error){console.error("WebSocket connection error:",error)}},1==this.automaticOpen&&this.open(false),this.send=function(b2){if(h)return(g.debug||a.debugAll)&&console.debug("ReconnectingWebSocket","send",g.url,b2),h.send(b2);throw"INVALID_STATE_ERR : Pausing to reconnect websocket"},this.close=function(a2,b2){"undefined"==typeof a2&&(a2=1e3),i2=true,h&&h.close(a2,b2)},this.refresh=function(){h&&h.readyState==1&&h.close()}}return a.prototype.onopen=function(){},a.prototype.onclose=function(){},a.prototype.onconnecting=function(){},a.prototype.onmessage=function(){},a.prototype.onerror=function(){},a.debugAll=false,a.CONNECTING=WebSocket.CONNECTING,a.OPEN=WebSocket.OPEN,a.CLOSING=WebSocket.CLOSING,a.CLOSED=WebSocket.CLOSED,a});let _isTipped=false;var _debugMode=false;var _initialized=null;var _dbcrs={};var _dbcrsTime=200;var _tickTime=20;var _scW=0;var cl=console.log;if(!_vcData)var _vcData=void 0;if(!_beaTn)var _beaTn=void 0;var beas;var appSettings;var execEl="";var currentlyValidTags=new Array;var _upwrk=new WebWorker("_upw");var _csswrk=new WebWorker("_cssw");_csswrk.start();var _ups=[];(function(e,t2){typeof module!="undefined"&&module.exports?module.exports=t2():typeof define=="function"&&define.amd?define(t2):this[e]=t2()})("bea",function(){function p(e2,t3){for(var n3=0,i3=e2.length;n3<i3;++n3)if(!t3(e2[n3]))return r2;return 1}function d(e2,t3){p(e2,function(e3){return t3(e3),1})}function v(e2,t3,n3){function g(e3){return e3.call?e3():u[e3]}function y(){if(!--h2){u[o2]=1,s2&&s2();for(var e3 in f)p(e3.split("|"),g)&&!d(f[e3],g)&&(f[e3]=[])}}e2=e2[i2]?e2:[e2];var r3=t3&&t3.call,s2=r3?t3:n3,o2=r3?e2.join(""):t3,h2=e2.length;return setTimeout(function(){d(e2,function t4(e3,n4){if(e3===null)return y();/*!n &&
59225
59225
  !/^https?:\/\//.test(e) &&
@@ -10,8 +10,8 @@ var _upw = `let _w=self;var files=[];function defer(){var e,t,s=new Promise(((s,
10
10
  //# sourceMappingURL=astring.min.js.map
11
11
  class WalkerBase{constructor(){this.should_skip=false;this.should_remove=false;this.replacement=null;this.context={skip:()=>this.should_skip=true,remove:()=>this.should_remove=true,replace:node=>this.replacement=node}}replace(parent,prop,index,node){if(parent&&prop){if(index!=null){parent[prop][index]=node}else{parent[prop]=node}}}remove(parent,prop,index){if(parent&&prop){if(index!==null&&index!==void 0){parent[prop].splice(index,1)}else{delete parent[prop]}}}}class SyncWalker extends WalkerBase{constructor(enter,leave){super();this.should_skip=false;this.should_remove=false;this.replacement=null;this.context={skip:()=>this.should_skip=true,remove:()=>this.should_remove=true,replace:node=>this.replacement=node};this.enter=enter;this.leave=leave}visit(node,parent,prop,index){if(node){if(this.enter){const _should_skip=this.should_skip;const _should_remove=this.should_remove;const _replacement=this.replacement;this.should_skip=false;this.should_remove=false;this.replacement=null;this.enter.call(this.context,node,parent,prop,index);if(this.replacement){if(Array.isArray(this.replacement)){var expressions=[];for(let rp=0;rp<this.replacement.length;rp++){expressions.push(this.replacement[rp])}if(this.replacement.length>1){node={"type":"VariableDeclaration","start":node.start,"kind":"let","declarations":expressions,"level":node.level,"scope":node.scope}}else{node={"type":"ExpressionStatement","expression":{"type":"SequenceExpression","expressions":expressions,"level":node.level,"scope":node.scope},"level":node.level,"scope":node.scope}}this.replace(parent,prop,index,node)}else{node=this.replacement;this.replace(parent,prop,index,node)}}if(this.should_remove){this.remove(parent,prop,index)}const skipped=this.should_skip;const removed=this.should_remove;this.should_skip=_should_skip;this.should_remove=_should_remove;this.replacement=_replacement;if(skipped)return node;if(removed)return null}let key;for(key in node){const value=node[key];if(value&&typeof value==="object"){if(Array.isArray(value)){const nodes=value;for(let i=0;i<nodes.length;i+=1){const item=nodes[i];if(isNode(item)){if(!this.visit(item,node,key,i)){i--}}}}else if(isNode(value)){this.visit(value,node,key,null)}}}if(this.leave){const _replacement=this.replacement;const _should_remove=this.should_remove;this.replacement=null;this.should_remove=false;this.leave.call(this.context,node,parent,prop,index);if(this.replacement){if(Array.isArray(this.replacement)){for(let rp=0;rp<this.replacement.length;rp++){node=this.replacement[rp];this.replace(parent,prop,index,node)}}else{node=this.replacement;this.replace(parent,prop,index,node)}}if(this.should_remove){this.remove(parent,prop,index)}const removed=this.should_remove;this.replacement=_replacement;this.should_remove=_should_remove;if(removed)return null}}return node}}function isNode(value){return value!==null&&typeof value==="object"&&"type"in value&&typeof value.type==="string"}function walk(ast,{enter,leave}){const instance=new SyncWalker(enter,leave);return instance.visit(ast,null)}function getProgramBody(node){if(node.type=="Program"){return node.body}return node}function parseNode(node){}function checkNodeL1(node,varz,vazzz){try{if(node&&typeof node==="object"){if(Array.isArray(node)){for(let i=0;i<node.length;i++){const nd=node[i];if(isNode(nd)){if(nd.type==="VariableDeclaration"){let declarators=nd.declarations;for(let x=0;x<declarators.length;x++){let dec=declarators[x].id;if(vazzz.includes(dec.name)){varz.push({name:dec.name,node:dec});dec.marked=true}}}else if(nd.type=="Identifier"){}parseNode(nd)}}}else if(isNode(node)){}}}catch(e){}}function getL1Vs(AST,view,vazzz){var level=0,block=[{start:0}];var varz=view?.varz??[];let nodes=getProgramBody(AST);checkNodeL1(nodes,varz,vazzz);return{"varz":varz,"AST":AST}}function getWatcher(AST,view,vazzz,targetKey="View"){AST=JSON.parse(JSON.stringify(AST));let Vars=getL1Vs(AST,view,vazzz);AST=Vars["AST"];let varz=Vars["varz"];validateBeforeRewrite(AST,view);AST=changeReactiveVarsOccurences(AST,vazzz,targetKey);AST=transformTopLevelDeclarations(AST,vazzz,targetKey);return{"code":astring.generate(AST),"varz":varz}}function validateBeforeRewrite(AST,view){try{new Function(astring.generate(AST))}catch(e){if(typeof reportLumenError==="function"){reportLumenError({stage:"validate",view:view?.name,error:e,hint:"This is a real JavaScript error in your <script> block (for example, a variable declared twice with let/const) \u2014 fix it in the .view file; it will not surface again once rewritten."})}}}function buildTargetRootExpr(targetKey){const segments=Array.isArray(targetKey)?targetKey:[targetKey];let expr={type:"Identifier",name:"_vt"};for(const seg of segments){if(typeof seg==="number"){expr={type:"MemberExpression",object:expr,property:{type:"Literal",value:seg,raw:String(seg)},computed:true}}else{expr={type:"MemberExpression",object:expr,property:{type:"Identifier",name:seg},computed:false}}}return expr}function changeReactiveVarsOccurences(AST,reactiveVariables,targetKey="View"){const reactive=new Set(reactiveVariables||[]);const scopeStack=[];const bindingIdNodes=new WeakSet;const pushScope=isFunction=>scopeStack.push({isFunction:!!isFunction,names:new Set});const popScope=()=>scopeStack.pop();const currentScope=()=>scopeStack[scopeStack.length-1];function declare(name,kind){if(!name)return;if(kind==="var"||kind==="function"){for(let i=scopeStack.length-1;i>=0;i--){if(scopeStack[i].isFunction||i===0){scopeStack[i].names.add(name);return}}}else{currentScope().names.add(name)}}function rootHas(name){return scopeStack.length>0&&scopeStack[0].names.has(name)}function isShadowedFromRoot(name){for(let i=scopeStack.length-1;i>=1;i--){if(scopeStack[i].names.has(name))return true}return false}function visitPattern(node,onId){if(!node)return;switch(node.type){case"Identifier":onId(node);break;case"RestElement":visitPattern(node.argument,onId);break;case"AssignmentPattern":visitPattern(node.left,onId);break;case"ArrayPattern":for(const el of node.elements)if(el)visitPattern(el,onId);break;case"ObjectPattern":for(const p of node.properties){if(p.type==="Property")visitPattern(p.value,onId);else if(p.type==="RestElement")visitPattern(p.argument,onId)}break;default:break}}function markPatternBindings(pattern,kind="var"){if(!pattern)return;visitPattern(pattern,idNode=>{bindingIdNodes.add(idNode);declare(idNode.name,kind)})}function predeclareProgram(programNode){if(!programNode||!Array.isArray(programNode.body))return;for(const stmt of programNode.body){if(stmt.type==="VariableDeclaration"){for(const d of stmt.declarations){visitPattern(d.id,id=>{bindingIdNodes.add(id);declare(id.name,stmt.kind)})}}else if(stmt.type==="FunctionDeclaration"&&stmt.id){bindingIdNodes.add(stmt.id);declare(stmt.id.name,"function")}else if(stmt.type==="ClassDeclaration"&&stmt.id){bindingIdNodes.add(stmt.id);declare(stmt.id.name,"let")}else if(stmt.type==="ImportDeclaration"){for(const spec of stmt.specifiers||[]){if(spec.local){bindingIdNodes.add(spec.local);declare(spec.local.name,"const")}}}}}function predeclareBlockLexicals(blockNode){if(!blockNode||!Array.isArray(blockNode.body))return;for(const stmt of blockNode.body){if(stmt.type==="VariableDeclaration"&&stmt.kind!=="var"){for(const d of stmt.declarations){visitPattern(d.id,id=>{bindingIdNodes.add(id);currentScope().names.add(id.name)})}}else if(stmt.type==="FunctionDeclaration"&&stmt.id){bindingIdNodes.add(stmt.id);currentScope().names.add(stmt.id.name)}else if(stmt.type==="ClassDeclaration"&&stmt.id){bindingIdNodes.add(stmt.id);currentScope().names.add(stmt.id.name)}}}function predeclareForHeader(node){const header=node.type==="ForStatement"?node.init:node.left;if(header&&header.type==="VariableDeclaration"&&header.kind!=="var"){for(const d of header.declarations){visitPattern(d.id,id=>{bindingIdNodes.add(id);currentScope().names.add(id.name)})}}}function shouldSkipIdentifier(node,parent,prop){if(!parent)return false;if(parent.type==="LabeledStatement"&&prop==="label"||(parent.type==="BreakStatement"||parent.type==="ContinueStatement")&&prop==="label")return true;if(parent.type==="MemberExpression"){if(prop==="property"&&parent.computed===false)return true}if(parent.type==="Property"){if(prop==="key"&&parent.computed===false)return true}if((parent.type==="MethodDefinition"||parent.type==="ClassProperty"||parent.type==="PropertyDefinition")&&prop==="key"&&parent.computed===false)return true;if(parent.type==="ImportSpecifier"||parent.type==="ImportDefaultSpecifier"||parent.type==="ImportNamespaceSpecifier"||parent.type==="ExportSpecifier")return true;return false}function walk2(node,parent,prop,index){if(!node||typeof node!=="object")return;switch(node.type){case"Program":pushScope(true);predeclareProgram(node);break;case"BlockStatement":case"StaticBlock":pushScope(false);predeclareBlockLexicals(node);break;case"FunctionDeclaration":if(node.id){bindingIdNodes.add(node.id);declare(node.id.name,"function")}pushScope(true);for(const p of node.params)markPatternBindings(p,"param");break;case"FunctionExpression":pushScope(true);if(node.id){bindingIdNodes.add(node.id);declare(node.id.name,"let")}for(const p of node.params)markPatternBindings(p,"param");break;case"ArrowFunctionExpression":pushScope(true);for(const p of node.params)markPatternBindings(p,"param");break;case"CatchClause":pushScope(false);if(node.param)markPatternBindings(node.param,"let");break;case"ForStatement":case"ForInStatement":case"ForOfStatement":pushScope(false);predeclareForHeader(node);break;case"VariableDeclaration":for(const decl of node.declarations){markPatternBindings(decl.id,node.kind||"var")}break;case"ClassDeclaration":if(node.id){bindingIdNodes.add(node.id);declare(node.id.name,"let")}break;case"ImportDeclaration":for(const spec of node.specifiers||[]){if(spec.local){bindingIdNodes.add(spec.local);declare(spec.local.name,"const")}}break}for(const key in node){if(key==="parent")continue;const child=node[key];if(Array.isArray(child)){for(let i=0;i<child.length;i++){if(child[i]&&typeof child[i]==="object"){walk2(child[i],node,key,i)}}}else if(child&&typeof child==="object"){walk2(child,node,key,null)}}if(node.type==="Identifier"){const name=node.name;if(!reactive.has(name)||bindingIdNodes.has(node)){}else if(!rootHas(name)){}else if(isShadowedFromRoot(name)){}else if(shouldSkipIdentifier(node,parent,prop)){}else{if(parent&&parent.type==="Property"&&parent.shorthand&&prop==="value"){parent.shorthand=false}const replacement={type:"MemberExpression",object:{type:"MemberExpression",object:buildTargetRootExpr(targetKey),property:{type:"Identifier",name:"vars"},computed:false},property:{type:"Literal",value:name,raw:JSON.stringify(name)},computed:true};if(parent){if(index!==null&&Array.isArray(parent[prop])){parent[prop][index]=replacement}else{parent[prop]=replacement}}else{Object.keys(node).forEach(k=>delete node[k]);Object.assign(node,replacement)}}}switch(node.type){case"Program":case"BlockStatement":case"StaticBlock":case"FunctionDeclaration":case"FunctionExpression":case"ArrowFunctionExpression":case"CatchClause":case"ForStatement":case"ForInStatement":case"ForOfStatement":popScope();break;default:break}}walk2(AST,null,null,null);return AST}function _reactiveAssignStatement(name,init,targetKey="View"){return{type:"ExpressionStatement",expression:{type:"AssignmentExpression",operator:"=",left:{type:"MemberExpression",computed:true,object:{type:"MemberExpression",computed:false,object:buildTargetRootExpr(targetKey),property:{type:"Identifier",name:"vars"}},property:{type:"Literal",value:name}},right:init||{type:"Identifier",name:"undefined"}}}}function _fnRegisterStatement(name,targetKey){return{type:"ExpressionStatement",expression:{type:"AssignmentExpression",operator:"=",left:{type:"MemberExpression",computed:true,object:{type:"MemberExpression",computed:false,object:buildTargetRootExpr(targetKey),property:{type:"Identifier",name:"fns"}},property:{type:"Literal",value:name}},right:{type:"Identifier",name}}}}function transformTopLevelDeclarations(AST,reactiveVariables,targetKey="View"){const reactive=new Set(reactiveVariables||[]);const newBody=[];for(const stmt of AST.body){if(stmt.type==="FunctionDeclaration"&&stmt.id){newBody.push(stmt);newBody.push(_fnRegisterStatement(stmt.id.name,targetKey));continue}if(stmt.type!=="VariableDeclaration"){newBody.push(stmt);continue}const reactiveDecls=stmt.declarations.filter(d=>reactive.has(d.id.name));const nonReactiveDecls=stmt.declarations.filter(d=>!reactive.has(d.id.name));if(reactiveDecls.length===0){newBody.push(stmt);continue}for(const decl of reactiveDecls){newBody.push(_reactiveAssignStatement(decl.id.name,decl.init,targetKey))}if(nonReactiveDecls.length>0){newBody.push({type:"VariableDeclaration",kind:stmt.kind,declarations:nonReactiveDecls})}}AST.body=newBody;return AST}if(typeof module!=="undefined"&&module.exports){module.exports={getWatcher,changeReactiveVarsOccurences,transformTopLevelDeclarations,validateBeforeRewrite}}
12
12
 
13
- var cl=console.log;class _v{static name;static type;static vars;static fns;static rvs;static _pv;static mx;static views;static hst;static settings;constructor(obj){this.name=obj.name??"home";this.type=obj.type??"main";this.hst=obj.hst??[];this.views=obj.views??[];this.vars=obj.vars??{};this.fns=obj.fns??{};this.rvs=obj.rvs??{};this._pv=obj._pv??null;this.mx=obj.mx??[];this.settings=obj.settings??{layout:"default",requireAuth:false}}}const consoleLogOriginal=console.log;console.log=function(){for(let i=0;i<arguments.length;i++){const arg=arguments[i];if(arg&&arg.hasOwnProperty("__isProxy")||arg?.target){arguments[i]=arguments[i].target}}consoleLogOriginal.apply(console,arguments)};var _lumenDevMode=true;var _lumenErrorLog=[];var EXPECTED_HST_FORMAT_VERSION=1;function _translateLumenError(message){if(!message)return message;return message.replace(/_vt\.View\.vars\[["'`]([^"'`\]]+)["'`]\]/g,"$1")}function reportLumenError(info){info=info||{};var rawMessage=info.message||info.error&&info.error.message||"Unknown error";var entry={time:new Date().toISOString(),stage:info.stage||"runtime",view:info.view||(typeof _vt!=="undefined"&&_vt.View?_vt.View.name:void 0),expr:info.expr,message:_translateLumenError(rawMessage),hint:info.hint};_lumenErrorLog.push(entry);if(_lumenDevMode){console.error("[LumenJS] "+entry.stage+' error in "'+(entry.view||"unknown")+'"'+(entry.expr?" \u2014 "+entry.expr:"")+": "+entry.message+(entry.hint?"\n "+entry.hint:""))}return entry}function _x(_x2){var currPath=[];function _dispatchVarsUpdate(key){let varsIdx=currPath.indexOf("vars");if(varsIdx===-1)return;let varName=varsIdx<currPath.length-1?currPath[varsIdx+1]:key;let rootPath=currPath.slice(0,varsIdx);if(rootPath[0]==="Global"){try{if(typeof window!=="undefined")window[varName]=_x2.Global.vars[varName]}catch(e){}if(_vt.View._re)_vt.View._re.update(varName);return}let owner=_x2;for(let i=0;i<rootPath.length&&owner;i++){owner=owner[rootPath[i]]}if(owner&&owner._re)owner._re.update(varName)}const handler={get(target,key){if(key=="__isProxy")return true;if(key=="View"||key=="Global")currPath=[];currPath.push(key);if(typeof target[key]==="object"&&target[key]!==null&&key!="_re"){return new Proxy(target[key],handler)}else{return target[key]??(key=="target"?target:void 0)??void 0}},set(target,key,value){target[key]=value;try{_dispatchVarsUpdate(key)}catch(e){cl(e)}currPath=[];return true},deleteProperty(target,key){if(!(key in target)){return false}delete target[key];try{_dispatchVarsUpdate(key)}catch(e){cl(e)}return true},ownKeys(target){return Reflect.ownKeys(target)},has(target,key){return key in target},defineProperty(target,key,descriptor){if(descriptor&&"value"in descriptor){target[key]=descriptor.value}return target},getOwnPropertyDescriptor(target,key){const value=target[key];return key in target?{value,enumerable:true,configurable:true}:void 0}};var x=new Proxy(_x2,handler);return x}let _vt=_x({"View":new _v({}),"Global":{"vars":{},"fns":{}}});class _lm{_RealDOM=[];_effects={};_cc={};_jj={};_ready=false;view=void 0;sbscrbs=[];reactiveVariables=[];vrs={};_CXR=[];_LXR=[];constructor(view){this.view=view;this.view._re=this;this.reactiveVariables=view?.rvs??{};this.init();if(this.view.type=="main")_vt.View=this.view;if(this.view._pv){this.view._pv.subscribe(this.view)}return this}init(){var par2=this;this.view.hst.forEach(function(doc2){par2.walk(doc2,null)})}subscribe(view){this.sbscrbs.push(view)}scopedEval(context,expr,kk){let ctx=this.concatVarsAtLevel(context,this);if(kk){if(!ctx.hasOwnProperty(kk))return void 0;delete ctx[kk]}try{const evaluator=Function.apply(null,[...Object.keys(ctx),"expr","return eval(expr)"]);return evaluator.apply(null,[...Object.values(ctx),expr])}catch(e){if(e instanceof TypeError){return this.scopedEval(ctx,expr,e.message.split(" ")[0])}reportLumenError({stage:"expression",expr,error:e});return void 0}}getVals(effect){let val="";if(effect.type=="text"){if(!effect.isSplit){for(let i=0;i<effect.splits.length;i++){let split=effect.splits[i];if(split.type=="mustache"){val+=this.getVal(split.content)}else{val+=split.content}}}else{val=this.getVal(effect.content)}}else if(effect.type=="attr"||effect.type=="event"){for(let i=0;i<effect.splits.length;i++){let split=effect.splits[i];if(split.type=="mustache"){val+=this.getVal(split.content)}else{val+=split.content}}}return val}renderAll(){if(this._ready)return;this._ready=true;for(const rv in this._effects){if(Object.prototype.hasOwnProperty.call(this._effects,rv)){const effects=this._effects[rv];for(let ei=0;ei<effects.length;ei++){const effect=effects[ei];if(!effect.nd)continue;try{if(effect.type=="text"){effect.nd.textContent=this.render(effect)}else if(effect.type=="attr"){if(effect.name=="value"){effect.nd.value=this.render(effect)}else{effect.nd.setAttribute(effect.name,this.render(effect));if(effect.name=="view"){effect.nd.subPath=this.render(effect);renderView(this.render(effect),true,{})}}}else if(effect.type=="event"){effect.nd.events[effect.name]=this.render(effect)}}catch(e){cl("Eeeeee",e)}}}}this.updateCXRs();this.updateLXRs();this.updateVXRs();if(typeof appSettings!=="undefined"&&appSettings&&typeof appSettings.tick==="function"){try{appSettings.tick()}catch(e){cl(e)}}}chainConnected(cx){for(let i=cx.chain.length-1;i>=0;i--){const cxs=cx.chain[i];if(cxs.ref.isPreConnected){return true}}return false}async updateVXRs(k){let subsNames=[];for(let i=0;i<this.view.views.length;i++){const _view=this.view.views[i];if(!subsNames.includes(_view.subPath))subsNames.push(_view.subPath)}for(let i=0;i<subsNames.length;i++){const n=subsNames[i];renderView(n,true,{},"views",this.view.views,this.view.scopePath||["View"])}}async updateCXRs(k){for(let i=0;i<this._CXR.length;i++){const cx=this._CXR[i];if(cx.name=="if"){let isTrue=this.evalExp(cx.content,this.reactiveVariables);if(isTrue){await this.showSectionCX(cx,k)}else{await this.hideSectionCX(cx)}}else if(cx.name=="else-if"){if(!this.chainConnected(cx)){let isTrue=this.evalExp(cx.content,this.reactiveVariables);if(isTrue){await this.showSectionCX(cx,k)}else{await this.hideSectionCX(cx)}}else{await this.hideSectionCX(cx)}}else if(cx.name=="else"){if(!this.chainConnected(cx)){await this.showSectionCX(cx,k)}else{await this.hideSectionCX(cx)}}}}async showSectionCX(cx,k){let wasConnected=cx.ref.node.isConnected;cx.ref.isPreConnected=true;await renderSection(cx.ref,cx.doc,this,k);if(!wasConnected)await fireRenderHook(cx,"after-render",cx.ref.node,{visible:true})}async hideSectionCX(cx){if(cx.ref.node.isConnected)await fireRenderHook(cx,"before-render",cx.ref.node,{visible:false});cx.ref.isPreConnected=false;cx.ref.node.replaceWith(cx.ref)}render(effect){let x="";try{if(effect.type=="text"||effect.type=="attr"||effect.type=="event"){x=this.getVals(effect)}}catch(e){cl(e)}return x}update(k){if(!this._ready)return;if(this._effects.hasOwnProperty(k)){const effects=this._effects[k];for(let ei=0;ei<effects.length;ei++){const effect=effects[ei];if(!effect.nd)continue;try{if(effect.type=="text"){effect.nd.textContent=this.render(effect)}else if(effect.type=="attr"){if(effect.name=="value"){effect.nd.value=this.render(effect)}else{effect.nd.setAttribute(effect.name,this.render(effect));if(effect.name=="view"){effect.nd.subPath=this.render(effect);renderView(this.render(effect),true,{})}}}else if(effect.type=="event"){effect.nd.events[effect.name]=this.render(effect)}}catch(e){cl("Eeeeee",e)}}}this.updateCXRs(k);this.updateLXRs(k);for(let sbscsi=0;sbscsi<this.sbscrbs.length;sbscsi++){const sbscr=this.sbscrbs[sbscsi];sbscr._re.update(k)}if(typeof appSettings!=="undefined"&&appSettings&&typeof appSettings.tick==="function"){try{appSettings.tick()}catch(e){cl(e)}}}async updateLXRs(k){for(let i=0;i<this._LXR.length;i++){var cx=this._LXR[i];var forX=cx.forX;if(k&&k!=forX["js"])continue;var val=this.getVal(forX["js"],"");var tempVal=[];if(this.typeStr(val)=="number"){for(let i2=0;i2<val;i2++){tempVal.push(i2)}val=tempVal}let vals=[];let isObj=false;if(this.typeStr(val)=="object"){isObj=true;for(const oKey in val){if(Object.hasOwnProperty.call(val,oKey)){const item=val[oKey];let objj={key:oKey,value:item};vals.push(objj)}}}else vals=clone(val);if(this.typeStr(vals)=="array"&&vals.length>0){let forIf=cx.cond;let limit=vals.length;let offset=0;if(cx.limit)limit=(isNaN(cx.limit)?cx.limit:limit)>vals.length?vals.length:cx.limit*1;if(cx.offset)offset=(isNaN(cx.offset)?cx.offset:offset)<0?0:cx.offset*1;let marray=[];if(forIf){marray=vals.slice(offset*1,vals.length)}else{marray=vals.slice(offset*1,limit*1+offset*1)}let myLimit=0;let arrayToRender=[];let arrayToRenderVXs=[];for(var index=0;index<marray.length;index++){if(myLimit==limit*1)break;try{let vx={};vx["index"]=myLimit;if(forX["dx"]!="")vx[forX["dx"]]=myLimit;if(isObj){if(forX["as"]["v"]!=""){if(forX["as"]["k"])vx[forX["as"]["k"]]=marray[index]["key"];if(forX["as"]["v"])vx[forX["as"]["v"]]=marray[index]["value"]}else{if(forX["as"]["k"])vx[forX["as"]["k"]]=marray[index]}vx["key"]=marray[index]["key"];vx["value"]=marray[index]["value"]}else{if(forX["as"]["k"])vx[forX["as"]["k"]]=marray[index];else if(marray[index]&&typeof marray[index]==="object"){for(const k2 in marray[index]){if(Object.prototype.hasOwnProperty.call(marray[index],k2)){vx[k2]=marray[index][k2]}}}}if(forIf){let _prevVrs=this.vrs;this.vrs=vx;let isTrue;try{isTrue=this.evalExp(forIf,[])}finally{this.vrs=_prevVrs}if(!isTrue)continue}let miIndexx=offset*1+index*1;arrayToRender.push(marray[index]);arrayToRenderVXs.push(vx);myLimit++}catch(e){cl(e)}}let oldATR=cx.atr;cx.atr=clone(arrayToRender);const actions=this.compareArrays(oldATR,arrayToRender);if(actions.length)await fireRenderHook(cx,"before-render",cx.ref.parentElement,{items:arrayToRender,actions});for(let ai=0;ai<actions.length;ai++){const actn=actions[ai];if(actn.action=="add"){let vx=arrayToRenderVXs[actn.index];let cln=await this.createSection(cx,vx,isObj,forX);cx.ref.before(cln);cln.replaceWith(cln.node)}else if(actn.action=="remove"){var keyed=cx.key+"_"+actn.index;let tx2=cx.ref?.nodes[keyed];if(tx2){tx2.remove();tx2.node.remove();delete cx.tx?.nodes[keyed]}}else{var keyed=cx.key+"_"+actn.index;let tx2=cx.ref?.nodes[keyed];let vx=arrayToRenderVXs[actn.index];if(tx2){tx2._re.vrs=vx;if(tx2.isObj){if(tx2.forX.as["k"]!="")tx2._re.update(tx2.forX.as["k"]);else tx2._re.update(tx2.forX.js);if(tx2.forX.as["v"]!="")tx2._re.update(tx2.forX.as["v"]);for(let actnsi=0;actnsi<actn.updates.length;actnsi++){const actnu=actn.updates[actnsi];tx2._re.update(actnu.property)}}else{if(tx2.forX.as["k"]!="")tx2._re.update(tx2.forX.as["k"]);else tx2._re.update(tx2.forX.js)}}}}if(actions.length)await fireRenderHook(cx,"after-render",cx.ref.parentElement,{items:arrayToRender,actions})}else{cx.nodes=[]}}}compareLogic(array1,array2){if(array1.length===array2.length){return 1}else{if(array1.length>array2.length){return 2}else{return 3}}}compareArrays(array1,array2){const actions=[];const maxLength=Math.max(array1.length,array2.length);for(let i=0;i<maxLength;i++){const element1=array1[i];const element2=array2[i];if(!element2){actions.push({action:"remove",index:i})}else if(!element1){actions.push({action:"add",index:i,element:element2})}else if(!this.deepCompare(element1,element2)){actions.push({action:"update",index:i,updates:this.getUpdates(element1,element2)})}}return actions}findDeletedIndexes(array1,array2){const deletedIndexes=[];let par2=this;array1.forEach((item,index)=>{const foundIndex=array2.findIndex(el2=>par2.deepCompare(el2,item));if(foundIndex===-1){deletedIndexes.push(index)}});return deletedIndexes}findAddedIndexes(array1,array2){const addedIndexes=[];let par2=this;array2.forEach((item,index)=>{const foundIndex=array1.findIndex(el2=>par2.deepCompare(el2,item));if(foundIndex===-1){addedIndexes.push(index)}});return addedIndexes}deepCompare(obj1,obj2){return JSON.stringify(obj1)===JSON.stringify(obj2)}getUpdates(oldObj,newObj){const updates=[];for(const key in newObj){if(newObj.hasOwnProperty(key)&&newObj[key]!==oldObj[key]){updates.push({property:key,value:newObj[key]})}}return updates}getVal(mo,indexName){let vars={};try{for(let i=0;i<this.reactiveVariables.length;i++){let __name=this.reactiveVariables[i];vars[__name]=_vt.View.vars.hasOwnProperty(__name)?_vt.View.vars[__name]:_vt.Global.vars[__name]}for(const ky in this.vrs){if(Object.prototype.hasOwnProperty.call(this.vrs,ky)){vars[ky]=this.vrs[ky]}}if(this.view&&this.view.vars){for(const ky in this.view.vars){if(Object.prototype.hasOwnProperty.call(this.view.vars,ky)){vars[ky]=this.view.vars[ky]}}}}catch(e){cl(e)}mo=mo.trim();if(mo.slice(0,2)=="{{"){mo=mo.slice(2,-2)}let value="";let _mo=mo;if(mo.indexOf("`")>-1){var matchesVal=_mo.match(/\.`[\s\S]*?`/g);if(matchesVal)for(var y=0;y<matchesVal.length;y++){_mo=_mo.split(matchesVal[y]).join("."+this.getVal(matchesVal[y].substr(1).slice(1,-1),indexName))}var matchesVal=_mo.match(/`[\s\S]*?`/g);if(matchesVal)for(var y=0;y<matchesVal.length;y++){_mo=_mo.split(matchesVal[y]).join("'"+this.getVal(matchesVal[y].slice(1,-1),indexName)+"'")}return this.getVal(_mo,indexName)}if(mo.indexOf(";")>-1){let zxx=mo.split(";");mo=$.trim(zxx[0])}if(mo.indexOf(" as ")>-1){mo=mo.split(" as ");return this.getVal(mo[0],indexName)}if(indexName){indexName=indexName.toString();if(mo.indexOf(indexName)>-1&&mo!=indexName&&vars.hasOwnProperty(indexName)&&mo!="index"){mo=mo.split(indexName).join(vars[indexName]);return this.getVal(mo,indexName)}}var Ondex=mo.match(/\bindex\b/g);if(Ondex&&mo!="index"&&vars.hasOwnProperty("index")){_mo=mo.replace(/\bindex\b/g,vars["index"]);return this.getVal(_mo,indexName)}value=this.lookup(mo,vars);return value??""}concatVarsAtLevel(levelVars,parent2){if(!parent2.view._pv){var concatenatedVars={...levelVars};if(parent2.view.vars){concatenatedVars={..._vt.Global.vars,...parent2.view.vars,...concatenatedVars}}return concatenatedVars}var concatenatedVars={...levelVars};if(parent2.view.vars){concatenatedVars={...parent2.view.vars,...concatenatedVars}}return this.concatVarsAtLevel(concatenatedVars,parent2.view._pv)}lookup(name,vaz){let vars=this.concatVarsAtLevel(vaz,this);try{var value;var names,index,lookupHit=false;if(this.hasProperty(vars,name)){value=vars[name]}else if(name.indexOf(".")>-1&&name.indexOf("[")==-1){var value=this.scopedEval(vars,name);if(!(value||value==0)){value=vars;names=name.split(".");index=0;while(value!=null&&index<names.length){if(index===names.length-1)lookupHit=this.hasProperty(value,names[index]);value=value[names[index++]]}}}else{var value=this.scopedEval(vars,name);if(!(value||value==0)){if(name.indexOf(".")==-1&&name.indexOf("[")>-1){let _name=name;var matchesVal=_name.match(/\[[\s\S]*?\]/g);for(var y=0;y<matchesVal.length;y++){if(matchesVal[y].indexOf("'")==-1&&matchesVal[y].indexOf('"')==-1)_name=_name.split(matchesVal[y]).join("['"+matchesVal[y].slice(1,-1)+"']")}var value=this.scopedEval(vars,_name)}}}if(this.isFunction(value))value=value.call(value)}catch(e){reportLumenError({stage:"lookup",expr:name,error:e});return""}return value}objectToString=Object.prototype.toString;isArray=Array.isArray||function isArrayPolyfill(object){return objectToString.call(object)==="[object Array]"};isFunction(object){return typeof object==="function"}typeStr(obj){return this.isArray(obj)?"array":typeof obj}hasProperty(obj,propName){return obj!=null&&typeof obj==="object"&&propName in obj}createEl(tag,attrs,children,events,doc2){const _el2=document.createElement(tag);Object.defineProperty(_el2,"_ownerRe",{value:this,enumerable:false,configurable:true,writable:true});_el2.isSub=false;if(attrs.hasOwnProperty("view")){_el2.isSub=true;_el2.subPath=attrs["view"];_el2.vars={};_el2.views=[];_el2.fns={};if(doc2&&doc2.evs&&doc2.evs.hasOwnProperty("@init")){let _initAttr=doc2.evs["@init"];if(_initAttr){let _initResult=evalEvAttr(_initAttr,{cType:"init"},$(_el2),"init",this.vrs);if(_initResult&&typeof _initResult==="object"&&typeof _initResult.then!=="function"){Object.assign(_el2.vars,_initResult)}}}this.view.views.push(_el2)}_el2.events={};for(const prop in attrs){if(prop=="view"||prop==":data"||prop==":if"||prop==":else-if"||prop==":else"||prop==":for"||prop==":for-limit"||prop==":for-offset"||prop==":for-if")continue;try{let val=doc2&&doc2.ax.hasOwnProperty(prop)?"":attrs[prop];if(prop=="value"){_el2.value=val}else _el2.setAttribute(prop,val)}catch(e){cl(e)}}for(const prop in events){try{_el2.events[prop]=events[prop]}catch(e){cl(e)}}if(children.length)_el2.append(...children);if(events&&events["@after-render"]&&!(attrs&&(attrs.hasOwnProperty(":for")||attrs.hasOwnProperty(":if")||attrs.hasOwnProperty(":else-if")||attrs.hasOwnProperty(":else")))){fireRenderHook({doc:doc2},"after-render",_el2,{})}autoInitPlugins(_el2,attrs);return _el2}evalExp(expr,vars){let rvars={};try{for(let i=0;i<vars.length;i++){let __name=vars[i];rvars[__name]=_vt.View.vars.hasOwnProperty(__name)?_vt.View.vars[__name]:_vt.Global.vars[__name]}for(const ky in this.vrs){if(Object.prototype.hasOwnProperty.call(this.vrs,ky)){rvars[ky]=this.vrs[ky]}}if(this.view&&this.view.vars){for(const ky in this.view.vars){if(Object.prototype.hasOwnProperty.call(this.view.vars,ky)){rvars[ky]=this.view.vars[ky]}}}}catch(e){cl(e)}try{var value=this.scopedEval(rvars,expr);if(value&&value!=0)return true}catch(e){reportLumenError({stage:"condition",expr,error:e});return false}return false}splitTextWithMustaches(text,mustaches){mustaches.sort((a,b)=>a.start-b.start);const elements=[];let currentIndex=0;for(const mustache of mustaches){if(currentIndex<mustache.start){elements.push({type:"static",content:text.substring(currentIndex,mustache.start)})}elements.push({type:"mustache",jst:mustache.jst,rvs:mustache.rvs,content:text.substring(mustache.start,mustache.end)});currentIndex=mustache.end}if(currentIndex<text.length){elements.push({type:"static",content:text.substring(currentIndex)})}return elements}walk(doc,parent){var par=this;var tx,el;switch(doc.type){case"text":if(doc.mss.length){let splitIt=true;if(doc.tag=="textarea"){splitIt=false}if(splitIt){let splits=this.splitTextWithMustaches(doc.content,doc.mss);for(let si=0;si<splits.length;si++){const split=splits[si];if(split.type=="static"){let txnd=document.createTextNode(split.content);if(!parent)par._RealDOM.push(txnd);(tx??(tx=[])).push(txnd)}else{let txnd=document.createTextNode("");for(let ri=0;ri<split.rvs.length;ri++){const element=split.rvs[ri];(this._effects[element]??(this._effects[element]=[])).push({"type":"text","content":split.content,"jst":split.jst,"rvs":split.rvs,"isSplit":true,"nd":txnd,"tag":doc.tag})}if(!parent)par._RealDOM.push(txnd);(tx??(tx=[])).push(txnd)}}return tx}else{tx=document.createTextNode("");for(let mui=0;mui<doc.mss.length;mui++){const mus=doc.mss[mui];for(let ri=0;ri<mus.rvs.length;ri++){const element=mus.rvs[ri];(this._effects[element]??(this._effects[element]=[])).push({"type":"text","content":doc.content,"splits":this.splitTextWithMustaches(doc.content,doc.mss),"jst":mus.jst,"rvs":mus.rvs,"isSplit":false,"nd":tx,"tag":doc.tag})}}if(!parent)par._RealDOM.push(tx);return tx}}else{tx=document.createTextNode(doc.content);if(!parent)par._RealDOM.push(tx);return tx}break;case"sections":case"section":var _dd=md5(new Date().getTime()/1e3+"::"+Math.random());tx=document.createTextNode("");var typeN=null;if(doc.attrs.hasOwnProperty(":else"))typeN="else";else if(doc.attrs.hasOwnProperty(":else-if"))typeN="else-if";else if(doc.attrs.hasOwnProperty(":if"))typeN="if";else typeN="for";if(doc.type=="section"){var chain=[];if(typeN=="else-if"||typeN=="else"){try{let lastInChain=this._CXR.at(-1);if(lastInChain){_dd=lastInChain.key;chain.push(...lastInChain.chain,lastInChain)}}catch(e){}}el=par.createEl(doc.name,doc.attrs,[],doc.evs,doc);tx.node=el;this._CXR.push({"type":"section","name":typeN,"content":doc.cond,"doc":doc,"key":_dd,"chain":chain,"ref":tx});this.setEffects(doc,el)}else if(doc.type=="sections"){tx.key=_dd;tx.node=null;tx.nodes={};let docRaw=doc;this._LXR.push({"type":"sections","name":typeN,"cond":doc.attrs.hasOwnProperty(":for-if")?doc.attrs[":for-if"]:null,"limit":doc.attrs.hasOwnProperty(":for-limit")?doc.attrs[":for-limit"]:0,"offset":doc.attrs.hasOwnProperty(":for-offset")?doc.attrs[":for-offset"]:0,"content":doc.content,"forX":doc.forX,"doc":docRaw,"key":_dd,"atr":[],"ref":tx})}if(!parent)par._RealDOM.push(tx);return tx;break;case"tag":var _dd=md5(new Date().getTime()/1e3+"::"+Math.random());if(doc.name.toLowerCase()=="settings"){if(par.view.type=="main"){var defaultSettings={layout:"default",requireAuth:false};try{let settingsC=doc.children[0].content;let settings={};eval("settings = "+settingsC+";");if(settings){if(settings.layout==null)settings.layout="default";if(settings.requireAuth==null)settings.requireAuth=false;par.view.settings=settings}else{par.view.settings=defaultSettings}}catch(e){setError(e,"Error in your settings tag inside the '"+par.view.name.toLowerCase()+"' main view!");par.view.settings=defaultSettings}}}else if(doc.name.toLowerCase()=="script"||doc.name.toLowerCase()=="js"){let child=doc.children[0];let js=child.content;let jst=child.jst;let isScoped=false;if(doc.attrs.hasOwnProperty("scoped")){delete doc.attrs["scoped"];isScoped=true}el=par.createEl("script",doc.attrs,[],doc.evs,doc);el._sc=isScoped;el._dd=_dd;el._jst=jst;(par._jj[_dd]??(par._jj[_dd]=[])).push({"nd":el})}else if(doc.name.toLowerCase()=="style"){let css=doc.children[0].content;let isScoped=false;el=par.createEl("style",{},[],doc.evs,doc);if(doc.attrs.hasOwnProperty("scoped")){if(!parent){if(par.view._dd)_dd=par.view._dd;else{par.view._dd=_dd;if(par.view.type=="main")$("[body]")[0].setAttribute("vuid",_dd)}}else{if(parent._dd)_dd=parent._dd;else{parent._dd=_dd;parent.setAttribute("vuid",_dd)}}delete doc.attrs["scoped"];isScoped=true;el._sc=isScoped;el._dd=_dd;el._css=css;(par._cc[_dd]??(par._cc[_dd]=[])).push({"nd":el,"_css":css})}else{el._sc=isScoped;el._dd=_dd;el.textContent=css}for(const prop in doc.attrs){try{_el.setAttribute(prop,doc.attrs[prop])}catch(e){cl(e)}}}else if(doc.name.toLowerCase()=="icon"){let child=par.createEl("span",{"class":"iconify","data-icon":doc?.icon??"mdi:home"},[],{},null);el=par.createEl("span",doc.attrs,[child],doc.evs,doc)}else if(doc.name.toLowerCase()=="slot"){let slotName=doc.attrs&&doc.attrs.name;if(slotName){let tempWrapper=document.createElement("div");let childs=[];for(let i=0;i<doc.children.length;i++){const dc=doc.children[i];let chils=par.walk(dc,tempWrapper);if(chils){if(Array.isArray(chils)){if(chils.length)childs=[...childs,...chils]}else{childs.push(chils)}}}(par.view._slots??(par.view._slots={}))[slotName]=childs}}else if(doc.attrs&&doc.attrs.hasOwnProperty("tpl")&&!doc.attrs.hasOwnProperty(":for")){reportLumenError({stage:"tpl",error:new Error('tpl="'+doc.attrs["tpl"]+'" must be used together with :for on the same element \u2014 templates only render inside a repeated/list context.')})}else{el=par.createEl(doc.name,doc.attrs,[],doc.evs,doc);if(!doc.isV&&!el.isSub){let childs=[];for(let i=0;i<doc.children.length;i++){const dc=doc.children[i];let chils=par.walk(dc,el);if(chils){if(Array.isArray(chils)){if(chils.length)childs=[...childs,...chils]}else{childs.push(chils)}}}childs.length?el.append(...childs):null}}this.setEffects(doc,el);if(el){if(!parent)par._RealDOM.push(el)}return el;break;case"comment":break;default:break}}setEffects(doc2,el2){let rvs=[];if(Object.keys(doc2.ax).length){for(const attrName in doc2.ax){if(Object.hasOwnProperty.call(doc2.ax,attrName)){const attrMustaches=doc2.ax[attrName];for(let i=0;i<attrMustaches.length;i++){const mus=attrMustaches[i];for(let ri=0;ri<mus.rvs.length;ri++){const element=mus.rvs[ri];rvs.push(element);(this._effects[element]??(this._effects[element]=[])).push({"type":"attr","name":attrName,"content":doc2.attrs[attrName],"splits":this.splitTextWithMustaches(doc2.attrs[attrName],doc2.ax[attrName]),"jst":mus.jst,"rvs":mus.rvs,"nd":el2})}}}}}if(Object.keys(doc2.ex).length){for(const ky in doc2.ex){if(Object.hasOwnProperty.call(doc2.ex,ky)){const mss=doc2.ex[ky];for(let i=0;i<mss.length;i++){const mus=mss[i];for(let ri=0;ri<mus.rvs.length;ri++){const element=mus.rvs[ri];rvs.push(element);(this._effects[element]??(this._effects[element]=[])).push({"type":"event","name":ky,"content":doc2.evs[ky],"splits":this.splitTextWithMustaches(doc2.evs[ky],doc2.ex[ky]),"jst":mus.jst,"rvs":mus.rvs,"nd":el2})}}}}}return rvs.filter((value,index,self)=>{return self.indexOf(value)===index})}async createSection(cx,vx,isObj,forX){var keyed=cx.key+"_"+vx.index;var tx2=document.createTextNode("");var typeN2=null;if(cx.doc.attrs.hasOwnProperty(":else"))typeN2="else";else if(cx.doc.attrs.hasOwnProperty(":else-if"))typeN2="else-if";else if(cx.doc.attrs.hasOwnProperty(":if"))typeN2="if";else typeN2="for";let el2=this.createEl(cx.doc.name,cx.doc.attrs,[],cx.doc.evs,cx.doc);tx2.node=el2;tx2.key=cx.key;tx2.keyed=keyed;tx2.isObj=isObj;tx2.forX=forX;tx2.vx=vx;let scsc=await renderSection(tx2,cx.doc,this,cx.key);scsc._re=scsc;cx.ref.nodes[keyed]=tx2;return tx2}attrString(attrs){var buff=[];for(var key in attrs){buff.push(key+'="'+attrs[key]+'"')}if(!buff.length)return"";return" "+buff.join(" ")}_stringify(buff,doc2){var par2=this;switch(doc2.type){case"text":return buff+doc2.content;case"tag":buff+="<"+doc2.name+(doc2.attrs?par2.attrString(doc2.attrs):"")+(doc2.isV?"/>":">");if(doc2.isV)return buff;for(let i=0;i<doc2.children.length;i++){const dc=doc2.children[i];buff=buff+par2._stringify("",dc)}return buff+"</"+doc2.name+">";case"comment":return buff;default:return""}}stringify(doc2){var par2=this;return doc2.reduce(function(token,rootEl){return token+par2._stringify("",rootEl)},"")}}async function renderHST(hst,n,type="main",tx2,_pv=null,scopePath=["View"],ownVars,ownFns,ownViews){var reactiveVariables=hst.reactiveVars;hst=hst.hst;let _re=new _lm(new _v({"name":n,"type":type,"hst":hst,"vars":ownVars??tx2?.vx,"fns":ownFns,"views":ownViews,"rvs":reactiveVariables,"_pv":_pv}));_re.view.scopePath=scopePath;if(Object.keys(_re._cc).length){for(const ky in _re._cc){if(Object.hasOwnProperty.call(_re._cc,ky)){const csses=_re._cc[ky];for(let inde=0;inde<csses.length;inde++){let prom=new defer;const css=csses[inde];_csswrk.trigger("css-ready",{"csses":[css._css],"pre":"[vuid='"+ky+"']","key":ky});_vuid[ky]=prom;let _csses=await prom;css.nd.textContent=_csses[0]}}}}if(Object.keys(_re._jj).length){for(const ky in _re._jj){if(Object.hasOwnProperty.call(_re._jj,ky)){const jses=_re._jj[ky];for(let inde=0;inde<jses.length;inde++){const nd=jses[inde].nd;let code=getWatcher(nd._jst,_re.view,reactiveVariables,scopePath).code;code=`try { `+code+` } catch (e) { reportLumenError({ stage: 'script', error: e }); }`;code=code+`
14
- //# sourceURL=`+(_re.view?.name||"view")+`.view.generated.js`;nd.textContent=code}}}}return _re}async function fireRenderHook(cx,n,containerEl,extra){if(!containerEl)return;let attrKey="@"+n;if(!cx.doc||!cx.doc.evs||!cx.doc.evs.hasOwnProperty(attrKey))return;let attrVal=cx.doc.evs[attrKey];if(!attrVal)return;let ev=Object.assign({cType:n},extra||{});let result=evalEvAttr(attrVal,ev,$(containerEl),n);if(result&&typeof result.then==="function"){try{return await result}catch(e){return void 0}}return result}function autoInitPlugins(el2,attrs){if(!attrs)return;try{if(attrs.hasOwnProperty("sl")&&typeof $.fn.select2==="function"){initSl($(el2))}if(attrs.hasOwnProperty("color")&&typeof $.fn.colorpicker==="function"){$(el2).removeAttr("color").colorpicker({format:"rgba"})}if(typeof $.fn.datetimepicker==="function"){if(attrs.hasOwnProperty("time"))dtp($(el2),"time");if(attrs.hasOwnProperty("date"))dtp($(el2),"date");if(attrs.hasOwnProperty("datetime"))dtp($(el2),"datetime")}}catch(e){cl(e)}}function initSl(t){if(t.hasClass("select2-hidden-accessible"))return;try{var plchldr=t.attr("placeholder")?t.attr("placeholder"):"";var dir=$("body").hasClass("rtl")?"rtl":"ltr";var nr=t.attr("sl-nrmsg")?t.attr("sl-nrmsg"):"No results found";var minResultsForSearch=t.attr("sl-mins")?t.attr("sl-mins"):10;var allowNewTags=t.attr("sl-ntgs")?true:false;var dropdownParent=t.attr("sl-prt")?t.attr("sl-prt"):"body";if(dropdownParent=="self")dropdownParent=t.parent();else dropdownParent=$(dropdownParent);var query=t.attr("sl-query")?t.attr("sl-query"):null;var uniquer=Date.now();if(typeof window[query]==="function"){t.select2.amd.define("adapt_"+uniquer,["select2/data/array","select2/utils"],function(ArrayAdapter,Utils){function CustomDataAdapter($element,options){CustomDataAdapter.__super__.constructor.call(this,$element,options)}Utils.Extend(CustomDataAdapter,ArrayAdapter);CustomDataAdapter.prototype.query=function(params,callback){clearTimeout(_dbcrs[uniquer]);let _t=t;_dbcrs[uniquer]=setTimeout(function(){window[query](params,callback,_t)},!_dbcrs.hasOwnProperty(uniquer)?0:_dbcrsTime)};return CustomDataAdapter});t.select2({dropdownParent,minimumResultsForSearch:minResultsForSearch,placeholder:plchldr,dir,tags:allowNewTags,allowClear:true,language:{noResults:function(){return nr}},...t.select2.amd.require("adapt_"+uniquer)?{ajax:{},dataAdapter:t.select2.amd.require("adapt_"+uniquer)}:{}})}else{t.select2({dropdownParent,minimumResultsForSearch:minResultsForSearch,placeholder:plchldr,dir,tags:allowNewTags,allowClear:true,language:{noResults:function(){return nr}}})}if(t.attr("sl-nosrch"))t.on("select2:opening select2:closing",function(event){$(this).parent().find(".select2-search__field").prop("disabled",true)});if(t.attr("sl-class")){t.on("select2:opening",function(event){dropdownParent.addClass(t.attr("sl-class"))});t.on("select2:closing",function(event){dropdownParent.removeClass(t.attr("sl-class"))})}if(t.attr("sl-id")||t.attr("sl-text")){let text=t.attr("sl-text");let id=t.attr("sl-id");if(!text)text=id;if(!id)id=text;let newOption=new Option(text,id,true,true);t.append(newOption).trigger("select")}else{t.select2("val","")}if(t.attr("sl-value"))t.val(t.attr("sl-value")).trigger("change")}catch(e){cl(e)}}var _dbcrs={};var _dbcrsTime=250;function dtp(el2,t){el2.removeAttr(t);let opts={format:t=="date"?"yyyy-mm-dd":t=="time"?"hh:ii":"yyyy-mm-dd hh:ii",weekStart:el2.attr("date-week-start")??1,startView:t=="time"?1:el2.attr("startview")?el2.attr("startview"):2,minView:el2.attr("minview")?el2.attr("minview"):t=="time"?0:t=="datetime"?0:2,maxView:el2.attr("maxview")?el2.attr("maxview"):t=="time"?1:4,todayBtn:t=="time"?0:el2.attr("date-today")=="false"?0:1,todayHighlight:t=="time"?0:el2.attr("date-today")=="false"?0:1,language:el2.attr("date-lang")??"en",minuteStep:el2.attr("date-minute-step")??5,pickerPosition:el2.attr("date-position")??"top-right",autoclose:1,showMeridian:false};if(el2.attr("date-start"))opts["startDate"]=el2.attr("date-start");if(el2.attr("date-end"))opts["endDate"]=el2.attr("date-end");if(el2.attr("date-value"))opts["date"]=el2.attr("date-value");el2.datetimepicker(opts);if(t=="time"){el2.on("show",function(ev){$(".table-condensed > thead, .table-condensed > thead > tr > th, .table-condensed > thead > tr > th > i").attr("style","visibility: hidden; font-size:0px !important; overflow: hidden; height: 0px;")}).on("hide",function(ev){$(".table-condensed > thead, .table-condensed > thead > tr > th, .table-condensed > thead > tr > th > i").attr("style","visibility: visible;")})}if(el2.attr("date-link-start")){el2.on("change",function(e){let dp1=el2.data("datetimepicker");let dp2=$(el2.attr("date-link-start")).data("datetimepicker");dp2.setStartDate(dp1.getFormattedDate());if(dp2.getFormattedDate()<dp1.getFormattedDate()||dp2.getFormattedDate()=="")$(el2.attr("date-link-start")).val(dp1.getFormattedDate())})}else if(el2.attr("date-link-end")){el2.on("change",function(e){let dp1=$(el2.attr("date-link-end")).data("datetimepicker");let dp2=el2.data("datetimepicker");dp1.setEndDate(dp2.getFormattedDate())});opts["useCurrent"]=false}}async function renderSection(tx2,doc2,par2,k,sectionsData){if(tx2.node.isConnected){if(k){tx2._re.update(k)}return tx2._re}var hst=doc2.children;if(doc2.attrs&&doc2.attrs.hasOwnProperty("tpl")){let _payload=typeof _vcD!=="undefined"&&_vcD||(typeof _vcData!=="undefined"?_vcData:void 0);let _tplName=doc2.attrs["tpl"];let _tplKey=btoa("src/tpls/"+_tplName+".tpl");let _tplEntry=_payload&&_payload.tpls&&_payload.tpls[_tplKey];if(_tplEntry){hst=_tplEntry.hst}else{reportLumenError({stage:"tpl",error:new Error('tpl="'+_tplName+'" \u2014 no such file at src/tpls/'+_tplName+".tpl")})}}let _re=await renderHST({hst,mxes:[]},tx2.key,"section",tx2,par2,par2?.view?.scopePath||["View"],void 0,void 0,par2?.view?.views);tx2._re=_re;if(tx2.node){tx2.replaceWith(tx2.node);tx2.node.innerHTML="";tx2.node.append(..._re._RealDOM);_re.setEffects(doc2,tx2.node);_re.renderAll("section")}return _re}async function renderView(n,isSub,d,type="views",viewsArr,scopeBase=["View"]){let filePath="src/views/"+n+".view";if(type=="layouts")filePath="src/layouts/"+n+".layout";cl(arguments);let fileKey=btoa(filePath);if(!isSub){View.props=d??{};var _queryParams=window.location.href.split("?");var nn=_queryParams.shift();View.params=paraToObj(_queryParams)??{}}n=prepareNode(n);var _queryParams=n.split("?");n=_queryParams.shift();let _payload=_vcD||(typeof _vcData!=="undefined"?_vcData:void 0);if(_payload&&!_payload.__hstVersionChecked){_payload.__hstVersionChecked=true;if(_payload.hstFormatVersion!==void 0&&_payload.hstFormatVersion!==EXPECTED_HST_FORMAT_VERSION){reportLumenError({stage:"hst-version-mismatch",error:new Error("This project was compiled for HST format v"+_payload.hstFormatVersion+", but this LumenJS runtime expects v"+EXPECTED_HST_FORMAT_VERSION+". @lmjs/cli and @lmjs/core are out of sync \u2014 reinstall/upgrade both together.")});return}}if(_payload&&_payload[type].hasOwnProperty(fileKey)&&_csswrk.isStarted()){if(isSub)cl("Rendering",n,fileKey);var hst=_payload[type][fileKey];if(isSub){let searchArr=viewsArr||_vt.View.views;let els=[];for(let i=0;i<searchArr.length;i++){let _el2=searchArr[i];if(_el2.__isProxy)_el2=_el2.target;if(_el2.subPath==n)els.push({el:_el2,viewsIndex:i})}if(els.length){for(let i=0;i<els.length;i++){const{el:el2,viewsIndex}=els[i];el2.vars=el2.vars||{};el2.views=el2.views||[];el2.fns=el2.fns||{};let _re=await renderHST(hst,n,"sub",void 0,null,scopeBase.concat(["views",viewsIndex]),el2.vars,el2.fns,el2.views);el2._re=_re;el2.innerHTML="";el2.append(..._re._RealDOM);_re.renderAll()}}}else{if(type=="layouts"){let appSelector=appSettings.App??"[app]";var appContainer=$(appSelector);if(appContainer.length){let _rel=await renderHST(hst,n,"layout");appContainer.data("layout",n).html(_rel._RealDOM);_rel.renderAll();goToNode()}}else{let _re=await renderHST(hst,n,"main");let layout=_re.view.settings.layout;let filePathL="src/layouts/"+layout+".layout";let fileKeyL=btoa(filePathL);let hstL=_payload["layouts"][fileKeyL];let appSelector=appSettings.App??"[app]";var appContainer=$(appSelector);if(appContainer.length){let currentLayout=$(appSelector).data("layout");if(currentLayout!=layout){let _rel=await renderHST(hstL,layout,"layout");appContainer.data("layout",layout).html(_rel._RealDOM);_rel.renderAll()}else{}}else{$("body").prepend("<div "+appSelector+"></div>");let _rel=await renderHST(hstL,layout,"layout");appContainer=$(appSelector);appContainer.data("layout",layout).html(_rel._RealDOM);_rel.renderAll()}$("[body]").html(_re._RealDOM);if(_re.view._slots){for(const slotName in _re.view._slots){if(Object.prototype.hasOwnProperty.call(_re.view._slots,slotName)){$('[slot="'+slotName+'"]').html(_re.view._slots[slotName])}}}_re.renderAll()}}}else{setTimeout(()=>{renderView(n,isSub,d)},10)}}
13
+ var cl=console.log;class _v{static name;static type;static vars;static fns;static rvs;static _pv;static mx;static views;static hst;static settings;constructor(obj){this.name=obj.name??"home";this.type=obj.type??"main";this.hst=obj.hst??[];this.views=obj.views??[];this.vars=obj.vars??{};this.fns=obj.fns??{};this.rvs=obj.rvs??{};this._pv=obj._pv??null;this.mx=obj.mx??[];this.settings=obj.settings??{layout:"default",requireAuth:false}}}const consoleLogOriginal=console.log;console.log=function(){for(let i=0;i<arguments.length;i++){const arg=arguments[i];if(arg&&arg.hasOwnProperty("__isProxy")||arg?.target){arguments[i]=arguments[i].target}}consoleLogOriginal.apply(console,arguments)};var _lumenDevMode=true;var _lumenErrorLog=[];var EXPECTED_HST_FORMAT_VERSION=1;function _translateLumenError(message){if(!message)return message;return message.replace(/_vt\.View\.vars\[["'`]([^"'`\]]+)["'`]\]/g,"$1")}function reportLumenError(info){info=info||{};var rawMessage=info.message||info.error&&info.error.message||"Unknown error";var entry={time:new Date().toISOString(),stage:info.stage||"runtime",view:info.view||(typeof _vt!=="undefined"&&_vt.View?_vt.View.name:void 0),expr:info.expr,message:_translateLumenError(rawMessage),hint:info.hint};_lumenErrorLog.push(entry);if(_lumenDevMode){console.error("[LumenJS] "+entry.stage+' error in "'+(entry.view||"unknown")+'"'+(entry.expr?" \u2014 "+entry.expr:"")+": "+entry.message+(entry.hint?"\n "+entry.hint:""))}return entry}function _x(_x2){var currPath=[];function _dispatchVarsUpdate(key){let varsIdx=currPath.indexOf("vars");if(varsIdx===-1)return;let varName=varsIdx<currPath.length-1?currPath[varsIdx+1]:key;let rootPath=currPath.slice(0,varsIdx);if(rootPath[0]==="Global"){try{if(typeof window!=="undefined")window[varName]=_x2.Global.vars[varName]}catch(e){}if(_vt.View._re)_vt.View._re.update(varName);return}let owner=_x2;for(let i=0;i<rootPath.length&&owner;i++){owner=owner[rootPath[i]]}if(owner&&owner._re)owner._re.update(varName)}const handler={get(target,key){if(key=="__isProxy")return true;if(target===_x2)currPath=[];currPath.push(key);if(typeof target[key]==="object"&&target[key]!==null&&key!="_re"){return new Proxy(target[key],handler)}else{return target[key]??(key=="target"?target:void 0)??void 0}},set(target,key,value){target[key]=value;try{_dispatchVarsUpdate(key)}catch(e){cl(e)}currPath=[];return true},deleteProperty(target,key){if(!(key in target)){return false}delete target[key];try{_dispatchVarsUpdate(key)}catch(e){cl(e)}return true},ownKeys(target){return Reflect.ownKeys(target)},has(target,key){return key in target},defineProperty(target,key,descriptor){if(descriptor&&"value"in descriptor){target[key]=descriptor.value}return target},getOwnPropertyDescriptor(target,key){const value=target[key];return key in target?{value,enumerable:true,configurable:true}:void 0}};var x=new Proxy(_x2,handler);return x}let _vt=_x({"View":new _v({}),"Global":{"vars":{},"fns":{}},"Widgets":{}});function _lookupInWidgets(name){for(const wname in _vt.Widgets){if(_vt.Widgets[wname].vars.hasOwnProperty(name))return _vt.Widgets[wname].vars[name]}return void 0}function _mergedWidgetsVars(){let out={};let names=Object.keys(_vt.Widgets).reverse();for(const wname of names){out={...out,..._vt.Widgets[wname].vars}}return out}class _lm{_RealDOM=[];_effects={};_cc={};_jj={};_ready=false;view=void 0;sbscrbs=[];reactiveVariables=[];vrs={};_CXR=[];_LXR=[];constructor(view){this.view=view;this.view._re=this;this.reactiveVariables=view?.rvs??{};this.init();if(this.view.type=="main")_vt.View=this.view;if(this.view._pv){this.view._pv.subscribe(this.view)}return this}init(){var par2=this;this.view.hst.forEach(function(doc2){par2.walk(doc2,null)})}subscribe(view){this.sbscrbs.push(view)}scopedEval(context,expr,kk){let ctx=this.concatVarsAtLevel(context,this);if(kk){if(!ctx.hasOwnProperty(kk))return void 0;delete ctx[kk]}try{const evaluator=Function.apply(null,[...Object.keys(ctx),"expr","return eval(expr)"]);return evaluator.apply(null,[...Object.values(ctx),expr])}catch(e){if(e instanceof TypeError){return this.scopedEval(ctx,expr,e.message.split(" ")[0])}reportLumenError({stage:"expression",expr,error:e});return void 0}}getVals(effect){let val="";if(effect.type=="text"){if(!effect.isSplit){for(let i=0;i<effect.splits.length;i++){let split=effect.splits[i];if(split.type=="mustache"){val+=this.getVal(split.content)}else{val+=split.content}}}else{val=this.getVal(effect.content)}}else if(effect.type=="attr"||effect.type=="event"){for(let i=0;i<effect.splits.length;i++){let split=effect.splits[i];if(split.type=="mustache"){val+=this.getVal(split.content)}else{val+=split.content}}}return val}renderAll(){if(this._ready)return;this._ready=true;for(const rv in this._effects){if(Object.prototype.hasOwnProperty.call(this._effects,rv)){const effects=this._effects[rv];for(let ei=0;ei<effects.length;ei++){const effect=effects[ei];if(!effect.nd)continue;try{if(effect.type=="text"){effect.nd.textContent=this.render(effect)}else if(effect.type=="attr"){if(effect.name=="value"){effect.nd.value=this.render(effect)}else{effect.nd.setAttribute(effect.name,this.render(effect));if(effect.name=="view"){effect.nd.subPath=this.render(effect);renderView(this.render(effect),true,{})}}}else if(effect.type=="event"){effect.nd.events[effect.name]=this.render(effect)}}catch(e){cl("Eeeeee",e)}}}}this.updateCXRs();this.updateLXRs();this.updateVXRs();if(typeof appSettings!=="undefined"&&appSettings&&typeof appSettings.tick==="function"){try{appSettings.tick()}catch(e){cl(e)}}}chainConnected(cx){for(let i=cx.chain.length-1;i>=0;i--){const cxs=cx.chain[i];if(cxs.ref.isPreConnected){return true}}return false}async updateVXRs(k){let subsNames=[];for(let i=0;i<this.view.views.length;i++){const _view=this.view.views[i];if(!subsNames.includes(_view.subPath))subsNames.push(_view.subPath)}for(let i=0;i<subsNames.length;i++){const n=subsNames[i];renderView(n,true,{},"views",this.view.views,this.view.scopePath||["View"])}}async updateCXRs(k){for(let i=0;i<this._CXR.length;i++){const cx=this._CXR[i];if(cx.name=="if"){let isTrue=this.evalExp(cx.content,this.reactiveVariables);if(isTrue){await this.showSectionCX(cx,k)}else{await this.hideSectionCX(cx)}}else if(cx.name=="else-if"){if(!this.chainConnected(cx)){let isTrue=this.evalExp(cx.content,this.reactiveVariables);if(isTrue){await this.showSectionCX(cx,k)}else{await this.hideSectionCX(cx)}}else{await this.hideSectionCX(cx)}}else if(cx.name=="else"){if(!this.chainConnected(cx)){await this.showSectionCX(cx,k)}else{await this.hideSectionCX(cx)}}}}async showSectionCX(cx,k){let wasConnected=cx.ref.node.isConnected;cx.ref.isPreConnected=true;await renderSection(cx.ref,cx.doc,this,k);if(!wasConnected)await fireRenderHook(cx,"after-render",cx.ref.node,{visible:true})}async hideSectionCX(cx){if(cx.ref.node.isConnected)await fireRenderHook(cx,"before-render",cx.ref.node,{visible:false});cx.ref.isPreConnected=false;cx.ref.node.replaceWith(cx.ref)}render(effect){let x="";try{if(effect.type=="text"||effect.type=="attr"||effect.type=="event"){x=this.getVals(effect)}}catch(e){cl(e)}return x}update(k){if(!this._ready)return;if(this._effects.hasOwnProperty(k)){const effects=this._effects[k];for(let ei=0;ei<effects.length;ei++){const effect=effects[ei];if(!effect.nd)continue;try{if(effect.type=="text"){effect.nd.textContent=this.render(effect)}else if(effect.type=="attr"){if(effect.name=="value"){effect.nd.value=this.render(effect)}else{effect.nd.setAttribute(effect.name,this.render(effect));if(effect.name=="view"){effect.nd.subPath=this.render(effect);renderView(this.render(effect),true,{})}}}else if(effect.type=="event"){effect.nd.events[effect.name]=this.render(effect)}}catch(e){cl("Eeeeee",e)}}}this.updateCXRs(k);this.updateLXRs(k);for(let sbscsi=0;sbscsi<this.sbscrbs.length;sbscsi++){const sbscr=this.sbscrbs[sbscsi];sbscr._re.update(k)}if(typeof appSettings!=="undefined"&&appSettings&&typeof appSettings.tick==="function"){try{appSettings.tick()}catch(e){cl(e)}}}async updateLXRs(k){for(let i=0;i<this._LXR.length;i++){var cx=this._LXR[i];var forX=cx.forX;if(k&&k!=forX["js"])continue;var val=this.getVal(forX["js"],"");var tempVal=[];if(this.typeStr(val)=="number"){for(let i2=0;i2<val;i2++){tempVal.push(i2)}val=tempVal}let vals=[];let isObj=false;if(this.typeStr(val)=="object"){isObj=true;for(const oKey in val){if(Object.hasOwnProperty.call(val,oKey)){const item=val[oKey];let objj={key:oKey,value:item};vals.push(objj)}}}else vals=clone(val);if(this.typeStr(vals)=="array"&&vals.length>0){let forIf=cx.cond;let limit=vals.length;let offset=0;if(cx.limit)limit=(isNaN(cx.limit)?cx.limit:limit)>vals.length?vals.length:cx.limit*1;if(cx.offset)offset=(isNaN(cx.offset)?cx.offset:offset)<0?0:cx.offset*1;let marray=[];if(forIf){marray=vals.slice(offset*1,vals.length)}else{marray=vals.slice(offset*1,limit*1+offset*1)}let myLimit=0;let arrayToRender=[];let arrayToRenderVXs=[];for(var index=0;index<marray.length;index++){if(myLimit==limit*1)break;try{let vx={};vx["index"]=myLimit;if(forX["dx"]!="")vx[forX["dx"]]=myLimit;if(isObj){if(forX["as"]["v"]!=""){if(forX["as"]["k"])vx[forX["as"]["k"]]=marray[index]["key"];if(forX["as"]["v"])vx[forX["as"]["v"]]=marray[index]["value"]}else{if(forX["as"]["k"])vx[forX["as"]["k"]]=marray[index]}vx["key"]=marray[index]["key"];vx["value"]=marray[index]["value"]}else{if(forX["as"]["k"])vx[forX["as"]["k"]]=marray[index];else if(marray[index]&&typeof marray[index]==="object"){for(const k2 in marray[index]){if(Object.prototype.hasOwnProperty.call(marray[index],k2)){vx[k2]=marray[index][k2]}}}}if(forIf){let _prevVrs=this.vrs;this.vrs=vx;let isTrue;try{isTrue=this.evalExp(forIf,[])}finally{this.vrs=_prevVrs}if(!isTrue)continue}let miIndexx=offset*1+index*1;arrayToRender.push(marray[index]);arrayToRenderVXs.push(vx);myLimit++}catch(e){cl(e)}}let oldATR=cx.atr;cx.atr=clone(arrayToRender);const actions=this.compareArrays(oldATR,arrayToRender);if(actions.length)await fireRenderHook(cx,"before-render",cx.ref.parentElement,{items:arrayToRender,actions});for(let ai=0;ai<actions.length;ai++){const actn=actions[ai];if(actn.action=="add"){let vx=arrayToRenderVXs[actn.index];let cln=await this.createSection(cx,vx,isObj,forX);cx.ref.before(cln);cln.replaceWith(cln.node)}else if(actn.action=="remove"){var keyed=cx.key+"_"+actn.index;let tx2=cx.ref?.nodes[keyed];if(tx2){tx2.remove();tx2.node.remove();delete cx.tx?.nodes[keyed]}}else{var keyed=cx.key+"_"+actn.index;let tx2=cx.ref?.nodes[keyed];let vx=arrayToRenderVXs[actn.index];if(tx2){tx2._re.vrs=vx;if(tx2.isObj){if(tx2.forX.as["k"]!="")tx2._re.update(tx2.forX.as["k"]);else tx2._re.update(tx2.forX.js);if(tx2.forX.as["v"]!="")tx2._re.update(tx2.forX.as["v"]);for(let actnsi=0;actnsi<actn.updates.length;actnsi++){const actnu=actn.updates[actnsi];tx2._re.update(actnu.property)}}else{if(tx2.forX.as["k"]!="")tx2._re.update(tx2.forX.as["k"]);else tx2._re.update(tx2.forX.js)}}}}if(actions.length)await fireRenderHook(cx,"after-render",cx.ref.parentElement,{items:arrayToRender,actions})}else{cx.nodes=[]}}}compareLogic(array1,array2){if(array1.length===array2.length){return 1}else{if(array1.length>array2.length){return 2}else{return 3}}}compareArrays(array1,array2){const actions=[];const maxLength=Math.max(array1.length,array2.length);for(let i=0;i<maxLength;i++){const element1=array1[i];const element2=array2[i];if(!element2){actions.push({action:"remove",index:i})}else if(!element1){actions.push({action:"add",index:i,element:element2})}else if(!this.deepCompare(element1,element2)){actions.push({action:"update",index:i,updates:this.getUpdates(element1,element2)})}}return actions}findDeletedIndexes(array1,array2){const deletedIndexes=[];let par2=this;array1.forEach((item,index)=>{const foundIndex=array2.findIndex(el2=>par2.deepCompare(el2,item));if(foundIndex===-1){deletedIndexes.push(index)}});return deletedIndexes}findAddedIndexes(array1,array2){const addedIndexes=[];let par2=this;array2.forEach((item,index)=>{const foundIndex=array1.findIndex(el2=>par2.deepCompare(el2,item));if(foundIndex===-1){addedIndexes.push(index)}});return addedIndexes}deepCompare(obj1,obj2){return JSON.stringify(obj1)===JSON.stringify(obj2)}getUpdates(oldObj,newObj){const updates=[];for(const key in newObj){if(newObj.hasOwnProperty(key)&&newObj[key]!==oldObj[key]){updates.push({property:key,value:newObj[key]})}}return updates}getVal(mo,indexName){let vars={};try{for(let i=0;i<this.reactiveVariables.length;i++){let __name=this.reactiveVariables[i];if(_vt.View.vars.hasOwnProperty(__name)){vars[__name]=_vt.View.vars[__name]}else{let _wv=_lookupInWidgets(__name);vars[__name]=_wv!==void 0?_wv:_vt.Global.vars[__name]}}for(const ky in this.vrs){if(Object.prototype.hasOwnProperty.call(this.vrs,ky)){vars[ky]=this.vrs[ky]}}if(this.view&&this.view.vars){for(const ky in this.view.vars){if(Object.prototype.hasOwnProperty.call(this.view.vars,ky)){vars[ky]=this.view.vars[ky]}}}}catch(e){cl(e)}mo=mo.trim();if(mo.slice(0,2)=="{{"){mo=mo.slice(2,-2)}let value="";let _mo=mo;if(mo.indexOf("`")>-1){var matchesVal=_mo.match(/\.`[\s\S]*?`/g);if(matchesVal)for(var y=0;y<matchesVal.length;y++){_mo=_mo.split(matchesVal[y]).join("."+this.getVal(matchesVal[y].substr(1).slice(1,-1),indexName))}var matchesVal=_mo.match(/`[\s\S]*?`/g);if(matchesVal)for(var y=0;y<matchesVal.length;y++){_mo=_mo.split(matchesVal[y]).join("'"+this.getVal(matchesVal[y].slice(1,-1),indexName)+"'")}return this.getVal(_mo,indexName)}if(mo.indexOf(";")>-1){let zxx=mo.split(";");mo=$.trim(zxx[0])}if(mo.indexOf(" as ")>-1){mo=mo.split(" as ");return this.getVal(mo[0],indexName)}if(indexName){indexName=indexName.toString();if(mo.indexOf(indexName)>-1&&mo!=indexName&&vars.hasOwnProperty(indexName)&&mo!="index"){mo=mo.split(indexName).join(vars[indexName]);return this.getVal(mo,indexName)}}var Ondex=mo.match(/\bindex\b/g);if(Ondex&&mo!="index"&&vars.hasOwnProperty("index")){_mo=mo.replace(/\bindex\b/g,vars["index"]);return this.getVal(_mo,indexName)}value=this.lookup(mo,vars);return value??""}concatVarsAtLevel(levelVars,parent2){if(!parent2.view._pv){var concatenatedVars={...levelVars};if(parent2.view.vars){concatenatedVars={..._vt.Global.vars,..._mergedWidgetsVars(),...parent2.view.vars,...concatenatedVars}}return concatenatedVars}var concatenatedVars={...levelVars};if(parent2.view.vars){concatenatedVars={...parent2.view.vars,...concatenatedVars}}return this.concatVarsAtLevel(concatenatedVars,parent2.view._pv)}lookup(name,vaz){let vars=this.concatVarsAtLevel(vaz,this);try{var value;var names,index,lookupHit=false;if(this.hasProperty(vars,name)){value=vars[name]}else if(name.indexOf(".")>-1&&name.indexOf("[")==-1){var value=this.scopedEval(vars,name);if(!(value||value==0)){value=vars;names=name.split(".");index=0;while(value!=null&&index<names.length){if(index===names.length-1)lookupHit=this.hasProperty(value,names[index]);value=value[names[index++]]}}}else{var value=this.scopedEval(vars,name);if(!(value||value==0)){if(name.indexOf(".")==-1&&name.indexOf("[")>-1){let _name=name;var matchesVal=_name.match(/\[[\s\S]*?\]/g);for(var y=0;y<matchesVal.length;y++){if(matchesVal[y].indexOf("'")==-1&&matchesVal[y].indexOf('"')==-1)_name=_name.split(matchesVal[y]).join("['"+matchesVal[y].slice(1,-1)+"']")}var value=this.scopedEval(vars,_name)}}}if(this.isFunction(value))value=value.call(value)}catch(e){reportLumenError({stage:"lookup",expr:name,error:e});return""}return value}objectToString=Object.prototype.toString;isArray=Array.isArray||function isArrayPolyfill(object){return objectToString.call(object)==="[object Array]"};isFunction(object){return typeof object==="function"}typeStr(obj){return this.isArray(obj)?"array":typeof obj}hasProperty(obj,propName){return obj!=null&&typeof obj==="object"&&propName in obj}createEl(tag,attrs,children,events,doc2){const _el2=document.createElement(tag);Object.defineProperty(_el2,"_ownerRe",{value:this,enumerable:false,configurable:true,writable:true});_el2.isSub=false;if(attrs.hasOwnProperty("view")){_el2.isSub=true;_el2.subPath=attrs["view"];_el2.vars={};_el2.views=[];_el2.fns={};if(doc2&&doc2.evs&&doc2.evs.hasOwnProperty("@init")){let _initAttr=doc2.evs["@init"];if(_initAttr){let _initResult=evalEvAttr(_initAttr,{cType:"init"},$(_el2),"init",this.vrs);if(_initResult&&typeof _initResult==="object"&&typeof _initResult.then!=="function"){Object.assign(_el2.vars,_initResult)}}}this.view.views.push(_el2)}_el2.events={};for(const prop in attrs){if(prop=="view"||prop==":data"||prop==":if"||prop==":else-if"||prop==":else"||prop==":for"||prop==":for-limit"||prop==":for-offset"||prop==":for-if")continue;try{let val=doc2&&doc2.ax.hasOwnProperty(prop)?"":attrs[prop];if(prop=="value"){_el2.value=val}else _el2.setAttribute(prop,val)}catch(e){cl(e)}}for(const prop in events){try{_el2.events[prop]=events[prop]}catch(e){cl(e)}}if(children.length)_el2.append(...children);if(events&&events["@after-render"]&&!(attrs&&(attrs.hasOwnProperty(":for")||attrs.hasOwnProperty(":if")||attrs.hasOwnProperty(":else-if")||attrs.hasOwnProperty(":else")))){fireRenderHook({doc:doc2},"after-render",_el2,{})}autoInitPlugins(_el2,attrs);return _el2}evalExp(expr,vars){let rvars={};try{for(let i=0;i<vars.length;i++){let __name=vars[i];if(_vt.View.vars.hasOwnProperty(__name)){rvars[__name]=_vt.View.vars[__name]}else{let _wv=_lookupInWidgets(__name);rvars[__name]=_wv!==void 0?_wv:_vt.Global.vars[__name]}}for(const ky in this.vrs){if(Object.prototype.hasOwnProperty.call(this.vrs,ky)){rvars[ky]=this.vrs[ky]}}if(this.view&&this.view.vars){for(const ky in this.view.vars){if(Object.prototype.hasOwnProperty.call(this.view.vars,ky)){rvars[ky]=this.view.vars[ky]}}}}catch(e){cl(e)}try{var value=this.scopedEval(rvars,expr);if(value&&value!=0)return true}catch(e){reportLumenError({stage:"condition",expr,error:e});return false}return false}splitTextWithMustaches(text,mustaches){mustaches.sort((a,b)=>a.start-b.start);const elements=[];let currentIndex=0;for(const mustache of mustaches){if(currentIndex<mustache.start){elements.push({type:"static",content:text.substring(currentIndex,mustache.start)})}elements.push({type:"mustache",jst:mustache.jst,rvs:mustache.rvs,content:text.substring(mustache.start,mustache.end)});currentIndex=mustache.end}if(currentIndex<text.length){elements.push({type:"static",content:text.substring(currentIndex)})}return elements}walk(doc,parent){var par=this;var tx,el;switch(doc.type){case"text":if(doc.mss.length){let splitIt=true;if(doc.tag=="textarea"){splitIt=false}if(splitIt){let splits=this.splitTextWithMustaches(doc.content,doc.mss);for(let si=0;si<splits.length;si++){const split=splits[si];if(split.type=="static"){let txnd=document.createTextNode(split.content);if(!parent)par._RealDOM.push(txnd);(tx??(tx=[])).push(txnd)}else{let txnd=document.createTextNode("");for(let ri=0;ri<split.rvs.length;ri++){const element=split.rvs[ri];(this._effects[element]??(this._effects[element]=[])).push({"type":"text","content":split.content,"jst":split.jst,"rvs":split.rvs,"isSplit":true,"nd":txnd,"tag":doc.tag})}if(!parent)par._RealDOM.push(txnd);(tx??(tx=[])).push(txnd)}}return tx}else{tx=document.createTextNode("");for(let mui=0;mui<doc.mss.length;mui++){const mus=doc.mss[mui];for(let ri=0;ri<mus.rvs.length;ri++){const element=mus.rvs[ri];(this._effects[element]??(this._effects[element]=[])).push({"type":"text","content":doc.content,"splits":this.splitTextWithMustaches(doc.content,doc.mss),"jst":mus.jst,"rvs":mus.rvs,"isSplit":false,"nd":tx,"tag":doc.tag})}}if(!parent)par._RealDOM.push(tx);return tx}}else{tx=document.createTextNode(doc.content);if(!parent)par._RealDOM.push(tx);return tx}break;case"sections":case"section":var _dd=md5(new Date().getTime()/1e3+"::"+Math.random());tx=document.createTextNode("");var typeN=null;if(doc.attrs.hasOwnProperty(":else"))typeN="else";else if(doc.attrs.hasOwnProperty(":else-if"))typeN="else-if";else if(doc.attrs.hasOwnProperty(":if"))typeN="if";else typeN="for";if(doc.type=="section"){var chain=[];if(typeN=="else-if"||typeN=="else"){try{let lastInChain=this._CXR.at(-1);if(lastInChain){_dd=lastInChain.key;chain.push(...lastInChain.chain,lastInChain)}}catch(e){}}el=par.createEl(doc.name,doc.attrs,[],doc.evs,doc);tx.node=el;this._CXR.push({"type":"section","name":typeN,"content":doc.cond,"doc":doc,"key":_dd,"chain":chain,"ref":tx});this.setEffects(doc,el)}else if(doc.type=="sections"){tx.key=_dd;tx.node=null;tx.nodes={};let docRaw=doc;this._LXR.push({"type":"sections","name":typeN,"cond":doc.attrs.hasOwnProperty(":for-if")?doc.attrs[":for-if"]:null,"limit":doc.attrs.hasOwnProperty(":for-limit")?doc.attrs[":for-limit"]:0,"offset":doc.attrs.hasOwnProperty(":for-offset")?doc.attrs[":for-offset"]:0,"content":doc.content,"forX":doc.forX,"doc":docRaw,"key":_dd,"atr":[],"ref":tx})}if(!parent)par._RealDOM.push(tx);return tx;break;case"tag":var _dd=md5(new Date().getTime()/1e3+"::"+Math.random());if(doc.name.toLowerCase()=="settings"){if(par.view.type=="main"){var defaultSettings={layout:"default",requireAuth:false};try{let settingsC=doc.children[0].content;let settings={};eval("settings = "+settingsC+";");if(settings){if(settings.layout==null)settings.layout="default";if(settings.requireAuth==null)settings.requireAuth=false;par.view.settings=settings}else{par.view.settings=defaultSettings}}catch(e){setError(e,"Error in your settings tag inside the '"+par.view.name.toLowerCase()+"' main view!");par.view.settings=defaultSettings}}}else if(doc.name.toLowerCase()=="script"||doc.name.toLowerCase()=="js"){let child=doc.children[0];let js=child.content;let jst=child.jst;let isScoped=false;if(doc.attrs.hasOwnProperty("scoped")){delete doc.attrs["scoped"];isScoped=true}el=par.createEl("script",doc.attrs,[],doc.evs,doc);el._sc=isScoped;el._dd=_dd;el._jst=jst;(par._jj[_dd]??(par._jj[_dd]=[])).push({"nd":el})}else if(doc.name.toLowerCase()=="style"){let css=doc.children[0].content;let isScoped=false;el=par.createEl("style",{},[],doc.evs,doc);if(doc.attrs.hasOwnProperty("scoped")){if(!parent){if(par.view._dd)_dd=par.view._dd;else{par.view._dd=_dd;if(par.view.type=="main")$("[body]")[0].setAttribute("vuid",_dd)}}else{if(parent._dd)_dd=parent._dd;else{parent._dd=_dd;parent.setAttribute("vuid",_dd)}}delete doc.attrs["scoped"];isScoped=true;el._sc=isScoped;el._dd=_dd;el._css=css;(par._cc[_dd]??(par._cc[_dd]=[])).push({"nd":el,"_css":css})}else{el._sc=isScoped;el._dd=_dd;el.textContent=css}for(const prop in doc.attrs){try{_el.setAttribute(prop,doc.attrs[prop])}catch(e){cl(e)}}}else if(doc.name.toLowerCase()=="icon"){let child=par.createEl("span",{"class":"iconify","data-icon":doc?.icon??"mdi:home"},[],{},null);el=par.createEl("span",doc.attrs,[child],doc.evs,doc)}else if(doc.name.toLowerCase()=="slot"){let slotName=doc.attrs&&doc.attrs.name;if(slotName){let tempWrapper=document.createElement("div");let childs=[];for(let i=0;i<doc.children.length;i++){const dc=doc.children[i];let chils=par.walk(dc,tempWrapper);if(chils){if(Array.isArray(chils)){if(chils.length)childs=[...childs,...chils]}else{childs.push(chils)}}}(par.view._slots??(par.view._slots={}))[slotName]=childs}}else if(doc.attrs&&doc.attrs.hasOwnProperty("tpl")&&!doc.attrs.hasOwnProperty(":for")){reportLumenError({stage:"tpl",error:new Error('tpl="'+doc.attrs["tpl"]+'" must be used together with :for on the same element \u2014 templates only render inside a repeated/list context.')})}else{el=par.createEl(doc.name,doc.attrs,[],doc.evs,doc);if(!doc.isV&&!el.isSub){let childs=[];for(let i=0;i<doc.children.length;i++){const dc=doc.children[i];let chils=par.walk(dc,el);if(chils){if(Array.isArray(chils)){if(chils.length)childs=[...childs,...chils]}else{childs.push(chils)}}}childs.length?el.append(...childs):null}}this.setEffects(doc,el);if(el){if(!parent)par._RealDOM.push(el)}return el;break;case"comment":break;default:break}}setEffects(doc2,el2){let rvs=[];if(Object.keys(doc2.ax).length){for(const attrName in doc2.ax){if(Object.hasOwnProperty.call(doc2.ax,attrName)){const attrMustaches=doc2.ax[attrName];for(let i=0;i<attrMustaches.length;i++){const mus=attrMustaches[i];for(let ri=0;ri<mus.rvs.length;ri++){const element=mus.rvs[ri];rvs.push(element);(this._effects[element]??(this._effects[element]=[])).push({"type":"attr","name":attrName,"content":doc2.attrs[attrName],"splits":this.splitTextWithMustaches(doc2.attrs[attrName],doc2.ax[attrName]),"jst":mus.jst,"rvs":mus.rvs,"nd":el2})}}}}}if(Object.keys(doc2.ex).length){for(const ky in doc2.ex){if(Object.hasOwnProperty.call(doc2.ex,ky)){const mss=doc2.ex[ky];for(let i=0;i<mss.length;i++){const mus=mss[i];for(let ri=0;ri<mus.rvs.length;ri++){const element=mus.rvs[ri];rvs.push(element);(this._effects[element]??(this._effects[element]=[])).push({"type":"event","name":ky,"content":doc2.evs[ky],"splits":this.splitTextWithMustaches(doc2.evs[ky],doc2.ex[ky]),"jst":mus.jst,"rvs":mus.rvs,"nd":el2})}}}}}return rvs.filter((value,index,self)=>{return self.indexOf(value)===index})}async createSection(cx,vx,isObj,forX){var keyed=cx.key+"_"+vx.index;var tx2=document.createTextNode("");var typeN2=null;if(cx.doc.attrs.hasOwnProperty(":else"))typeN2="else";else if(cx.doc.attrs.hasOwnProperty(":else-if"))typeN2="else-if";else if(cx.doc.attrs.hasOwnProperty(":if"))typeN2="if";else typeN2="for";let el2=this.createEl(cx.doc.name,cx.doc.attrs,[],cx.doc.evs,cx.doc);tx2.node=el2;tx2.key=cx.key;tx2.keyed=keyed;tx2.isObj=isObj;tx2.forX=forX;tx2.vx=vx;let scsc=await renderSection(tx2,cx.doc,this,cx.key);scsc._re=scsc;cx.ref.nodes[keyed]=tx2;return tx2}attrString(attrs){var buff=[];for(var key in attrs){buff.push(key+'="'+attrs[key]+'"')}if(!buff.length)return"";return" "+buff.join(" ")}_stringify(buff,doc2){var par2=this;switch(doc2.type){case"text":return buff+doc2.content;case"tag":buff+="<"+doc2.name+(doc2.attrs?par2.attrString(doc2.attrs):"")+(doc2.isV?"/>":">");if(doc2.isV)return buff;for(let i=0;i<doc2.children.length;i++){const dc=doc2.children[i];buff=buff+par2._stringify("",dc)}return buff+"</"+doc2.name+">";case"comment":return buff;default:return""}}stringify(doc2){var par2=this;return doc2.reduce(function(token,rootEl){return token+par2._stringify("",rootEl)},"")}}async function renderHST(hst,n,type="main",tx2,_pv=null,scopePath=["View"],ownVars,ownFns,ownViews){var reactiveVariables=hst.reactiveVars;hst=hst.hst;let _re=new _lm(new _v({"name":n,"type":type,"hst":hst,"vars":ownVars??tx2?.vx,"fns":ownFns,"views":ownViews,"rvs":reactiveVariables,"_pv":_pv}));_re.view.scopePath=scopePath;if(Object.keys(_re._cc).length){for(const ky in _re._cc){if(Object.hasOwnProperty.call(_re._cc,ky)){const csses=_re._cc[ky];for(let inde=0;inde<csses.length;inde++){let prom=new defer;const css=csses[inde];_csswrk.trigger("css-ready",{"csses":[css._css],"pre":"[vuid='"+ky+"']","key":ky});_vuid[ky]=prom;let _csses=await prom;css.nd.textContent=_csses[0]}}}}if(Object.keys(_re._jj).length){for(const ky in _re._jj){if(Object.hasOwnProperty.call(_re._jj,ky)){const jses=_re._jj[ky];for(let inde=0;inde<jses.length;inde++){const nd=jses[inde].nd;let code=getWatcher(nd._jst,_re.view,reactiveVariables,scopePath).code;code=`try { `+code+` } catch (e) { reportLumenError({ stage: 'script', error: e }); }`;code=code+`
14
+ //# sourceURL=`+(_re.view?.name||"view")+`.view.generated.js`;nd.textContent=code}}}}return _re}async function fireRenderHook(cx,n,containerEl,extra){if(!containerEl)return;let attrKey="@"+n;if(!cx.doc||!cx.doc.evs||!cx.doc.evs.hasOwnProperty(attrKey))return;let attrVal=cx.doc.evs[attrKey];if(!attrVal)return;let ev=Object.assign({cType:n},extra||{});let result=evalEvAttr(attrVal,ev,$(containerEl),n);if(result&&typeof result.then==="function"){try{return await result}catch(e){return void 0}}return result}function autoInitPlugins(el2,attrs){if(!attrs)return;try{if(attrs.hasOwnProperty("sl")&&typeof $.fn.select2==="function"){initSl($(el2))}if(attrs.hasOwnProperty("color")&&typeof $.fn.colorpicker==="function"){$(el2).removeAttr("color").colorpicker({format:"rgba"})}if(typeof $.fn.datetimepicker==="function"){if(attrs.hasOwnProperty("time"))dtp($(el2),"time");if(attrs.hasOwnProperty("date"))dtp($(el2),"date");if(attrs.hasOwnProperty("datetime"))dtp($(el2),"datetime")}}catch(e){cl(e)}}function initSl(t){if(t.hasClass("select2-hidden-accessible"))return;try{var plchldr=t.attr("placeholder")?t.attr("placeholder"):"";var dir=$("body").hasClass("rtl")?"rtl":"ltr";var nr=t.attr("sl-nrmsg")?t.attr("sl-nrmsg"):"No results found";var minResultsForSearch=t.attr("sl-mins")?t.attr("sl-mins"):10;var allowNewTags=t.attr("sl-ntgs")?true:false;var dropdownParent=t.attr("sl-prt")?t.attr("sl-prt"):"body";if(dropdownParent=="self")dropdownParent=t.parent();else dropdownParent=$(dropdownParent);var query=t.attr("sl-query")?t.attr("sl-query"):null;var uniquer=Date.now();if(typeof window[query]==="function"){t.select2.amd.define("adapt_"+uniquer,["select2/data/array","select2/utils"],function(ArrayAdapter,Utils){function CustomDataAdapter($element,options){CustomDataAdapter.__super__.constructor.call(this,$element,options)}Utils.Extend(CustomDataAdapter,ArrayAdapter);CustomDataAdapter.prototype.query=function(params,callback){clearTimeout(_dbcrs[uniquer]);let _t=t;_dbcrs[uniquer]=setTimeout(function(){window[query](params,callback,_t)},!_dbcrs.hasOwnProperty(uniquer)?0:_dbcrsTime)};return CustomDataAdapter});t.select2({dropdownParent,minimumResultsForSearch:minResultsForSearch,placeholder:plchldr,dir,tags:allowNewTags,allowClear:true,language:{noResults:function(){return nr}},...t.select2.amd.require("adapt_"+uniquer)?{ajax:{},dataAdapter:t.select2.amd.require("adapt_"+uniquer)}:{}})}else{t.select2({dropdownParent,minimumResultsForSearch:minResultsForSearch,placeholder:plchldr,dir,tags:allowNewTags,allowClear:true,language:{noResults:function(){return nr}}})}if(t.attr("sl-nosrch"))t.on("select2:opening select2:closing",function(event){$(this).parent().find(".select2-search__field").prop("disabled",true)});if(t.attr("sl-class")){t.on("select2:opening",function(event){dropdownParent.addClass(t.attr("sl-class"))});t.on("select2:closing",function(event){dropdownParent.removeClass(t.attr("sl-class"))})}if(t.attr("sl-id")||t.attr("sl-text")){let text=t.attr("sl-text");let id=t.attr("sl-id");if(!text)text=id;if(!id)id=text;let newOption=new Option(text,id,true,true);t.append(newOption).trigger("select")}else{t.select2("val","")}if(t.attr("sl-value"))t.val(t.attr("sl-value")).trigger("change")}catch(e){cl(e)}}var _dbcrs={};var _dbcrsTime=250;function dtp(el2,t){el2.removeAttr(t);let opts={format:t=="date"?"yyyy-mm-dd":t=="time"?"hh:ii":"yyyy-mm-dd hh:ii",weekStart:el2.attr("date-week-start")??1,startView:t=="time"?1:el2.attr("startview")?el2.attr("startview"):2,minView:el2.attr("minview")?el2.attr("minview"):t=="time"?0:t=="datetime"?0:2,maxView:el2.attr("maxview")?el2.attr("maxview"):t=="time"?1:4,todayBtn:t=="time"?0:el2.attr("date-today")=="false"?0:1,todayHighlight:t=="time"?0:el2.attr("date-today")=="false"?0:1,language:el2.attr("date-lang")??"en",minuteStep:el2.attr("date-minute-step")??5,pickerPosition:el2.attr("date-position")??"top-right",autoclose:1,showMeridian:false};if(el2.attr("date-start"))opts["startDate"]=el2.attr("date-start");if(el2.attr("date-end"))opts["endDate"]=el2.attr("date-end");if(el2.attr("date-value"))opts["date"]=el2.attr("date-value");el2.datetimepicker(opts);if(t=="time"){el2.on("show",function(ev){$(".table-condensed > thead, .table-condensed > thead > tr > th, .table-condensed > thead > tr > th > i").attr("style","visibility: hidden; font-size:0px !important; overflow: hidden; height: 0px;")}).on("hide",function(ev){$(".table-condensed > thead, .table-condensed > thead > tr > th, .table-condensed > thead > tr > th > i").attr("style","visibility: visible;")})}if(el2.attr("date-link-start")){el2.on("change",function(e){let dp1=el2.data("datetimepicker");let dp2=$(el2.attr("date-link-start")).data("datetimepicker");dp2.setStartDate(dp1.getFormattedDate());if(dp2.getFormattedDate()<dp1.getFormattedDate()||dp2.getFormattedDate()=="")$(el2.attr("date-link-start")).val(dp1.getFormattedDate())})}else if(el2.attr("date-link-end")){el2.on("change",function(e){let dp1=$(el2.attr("date-link-end")).data("datetimepicker");let dp2=el2.data("datetimepicker");dp1.setEndDate(dp2.getFormattedDate())});opts["useCurrent"]=false}}async function renderSection(tx2,doc2,par2,k,sectionsData){if(tx2.node.isConnected){if(k){tx2._re.update(k)}return tx2._re}var hst=doc2.children;if(doc2.attrs&&doc2.attrs.hasOwnProperty("tpl")){let _payload=typeof _vcD!=="undefined"&&_vcD||(typeof _vcData!=="undefined"?_vcData:void 0);let _tplName=doc2.attrs["tpl"];let _tplKey=btoa("src/tpls/"+_tplName+".tpl");let _tplEntry=_payload&&_payload.tpls&&_payload.tpls[_tplKey];if(_tplEntry){hst=_tplEntry.hst}else{reportLumenError({stage:"tpl",error:new Error('tpl="'+_tplName+'" \u2014 no such file at src/tpls/'+_tplName+".tpl")})}}let _re=await renderHST({hst,mxes:[]},tx2.key,"section",tx2,par2,par2?.view?.scopePath||["View"],void 0,void 0,par2?.view?.views);tx2._re=_re;if(tx2.node){tx2.replaceWith(tx2.node);tx2.node.innerHTML="";tx2.node.append(..._re._RealDOM);_re.setEffects(doc2,tx2.node);_re.renderAll("section")}return _re}async function renderView(n,isSub,d,type="views",viewsArr,scopeBase=["View"]){let filePath="src/views/"+n+".view";if(type=="layouts")filePath="src/layouts/"+n+".layout";let fileKey=btoa(filePath);if(!isSub){View.props=d??{};var _queryParams=window.location.href.split("?");var nn=_queryParams.shift();View.params=paraToObj(_queryParams)??{}}n=prepareNode(n);var _queryParams=n.split("?");n=_queryParams.shift();let _payload=_vcD||(typeof _vcData!=="undefined"?_vcData:void 0);if(_payload&&!_payload.__hstVersionChecked){_payload.__hstVersionChecked=true;if(_payload.hstFormatVersion!==void 0&&_payload.hstFormatVersion!==EXPECTED_HST_FORMAT_VERSION){reportLumenError({stage:"hst-version-mismatch",error:new Error("This project was compiled for HST format v"+_payload.hstFormatVersion+", but this LumenJS runtime expects v"+EXPECTED_HST_FORMAT_VERSION+". @lmjs/cli and @lmjs/core are out of sync \u2014 reinstall/upgrade both together.")});return}}if(_payload&&_payload[type].hasOwnProperty(fileKey)&&_csswrk.isStarted()){if(isSub)cl("Rendering",n,fileKey);var hst=_payload[type][fileKey];if(isSub){let searchArr=viewsArr||_vt.View.views;let els=[];for(let i=0;i<searchArr.length;i++){let _el2=searchArr[i];if(_el2.__isProxy)_el2=_el2.target;if(_el2.subPath==n)els.push({el:_el2,viewsIndex:i})}if(els.length){for(let i=0;i<els.length;i++){const{el:el2,viewsIndex}=els[i];el2.vars=el2.vars||{};el2.views=el2.views||[];el2.fns=el2.fns||{};let _re=await renderHST(hst,n,"sub",void 0,null,scopeBase.concat(["views",viewsIndex]),el2.vars,el2.fns,el2.views);el2._re=_re;el2.innerHTML="";el2.append(..._re._RealDOM);_re.renderAll()}}}else{if(type=="layouts"){let appSelector=appSettings.App??"[app]";var appContainer=$(appSelector);if(appContainer.length){let _rel=await renderHST(hst,n,"layout");appContainer.data("layout",n).html(_rel._RealDOM);_rel.renderAll();goToNode()}}else{let _re=await renderHST(hst,n,"main");let layout=_re.view.settings.layout;let filePathL="src/layouts/"+layout+".layout";let fileKeyL=btoa(filePathL);let hstL=_payload["layouts"][fileKeyL];let appSelector=appSettings.App??"[app]";var appContainer=$(appSelector);let layoutJustSwapped=false;if(appContainer.length){let currentLayout=$(appSelector).data("layout");if(currentLayout!=layout){let _rel=await renderHST(hstL,layout,"layout");appContainer.data("layout",layout).html(_rel._RealDOM);_rel.renderAll();layoutJustSwapped=true}else{}}else{$("body").prepend("<div "+appSelector+"></div>");let _rel=await renderHST(hstL,layout,"layout");appContainer=$(appSelector);appContainer.data("layout",layout).html(_rel._RealDOM);_rel.renderAll();layoutJustSwapped=true}let declaredRegions=hstL&&hstL.regions||[];for(const regionName of declaredRegions){let settingsKey="has"+regionName[0].toUpperCase()+regionName.slice(1);let want=_re.view.settings.hasOwnProperty(settingsKey)?_re.view.settings[settingsKey]:true;let resolvedFile=want===false?null:want===true?regionName:want;let w=_vt.Widgets[regionName]||(_vt.Widgets[regionName]={vars:{},fns:{},views:[],_re:null,_resolvedFile:void 0});if(resolvedFile!==w._resolvedFile){if(resolvedFile===null){$("["+regionName+"]").html("");w._re=null}else{let wFilePath="src/views/widgets/"+resolvedFile+".view";let wHst=_payload["views"][btoa(wFilePath)];if(wHst){let _rew=await renderHST(wHst,resolvedFile,"widget",void 0,null,["Widgets",regionName],w.vars,w.fns,w.views);w._re=_rew;$("["+regionName+"]").html(_rew._RealDOM);_rew.renderAll()}}w._resolvedFile=resolvedFile}else if(layoutJustSwapped&&w._re){$("["+regionName+"]").html(w._re._RealDOM)}}$("[body]").html(_re._RealDOM);if(_re.view._slots){for(const slotName in _re.view._slots){if(Object.prototype.hasOwnProperty.call(_re.view._slots,slotName)){$('[slot="'+slotName+'"]').html(_re.view._slots[slotName])}}}_re.renderAll()}}}else{setTimeout(()=>{renderView(n,isSub,d)},10)}}
15
15
 
16
16
  !(function(a,b){"function"==typeof define&&define.amd?define([],b):"undefined"!=typeof module&&module.exports?module.exports=b():a.ReconnectingWebSocket=b()})(this,function(){function a(b,c,d){function l(a2,b2){var c2=document.createEvent("CustomEvent");return c2.initCustomEvent(a2,false,false,b2),c2}var e={debug:false,automaticOpen:true,reconnectInterval:1e3,maxReconnectInterval:3e4,reconnectDecay:1,timeoutInterval:3e3};d||(d={});for(var f in e)this[f]="undefined"!=typeof d[f]?d[f]:e[f];this.url=b,this.reconnectAttempts=0,this.readyState=WebSocket.CONNECTING,this.protocol=null;var h,g=this,i2=false,j=false,k=document.createElement("div");k.addEventListener("open",function(a2){g.onopen(a2)}),k.addEventListener("close",function(a2){g.onclose(a2)}),k.addEventListener("connecting",function(a2){g.onconnecting(a2)}),k.addEventListener("message",function(a2){g.onmessage(a2)}),k.addEventListener("error",function(a2){g.onerror(a2)}),this.addEventListener=k.addEventListener.bind(k),this.removeEventListener=k.removeEventListener.bind(k),this.dispatchEvent=k.dispatchEvent.bind(k),this.open=function(b2){try{h=new WebSocket(g.url,c||[]),b2||k.dispatchEvent(l("connecting")),(g.debug||a.debugAll)&&console.debug("ReconnectingWebSocket","attempt-connect",g.url);var d2=h,e2=setTimeout(function(){(g.debug||a.debugAll)&&console.debug("ReconnectingWebSocket","connection-timeout",g.url),j=true,j=false;if(d2.readyState==1)d2.close()},g.timeoutInterval);h.onopen=function(){clearTimeout(e2),(g.debug||a.debugAll)&&console.debug("ReconnectingWebSocket","onopen",g.url),g.protocol=h.protocol,g.readyState=WebSocket.OPEN,g.reconnectAttempts=0;var d3=l("open");d3.isReconnect=b2,b2=false,k.dispatchEvent(d3)},h.onclose=function(c2){if(clearTimeout(e3),h=null,i2)g.readyState=WebSocket.CLOSED,k.dispatchEvent(l("close"));else{g.readyState=WebSocket.CONNECTING;var d3=l("connecting");d3.code=c2.code,d3.reason=c2.reason,d3.wasClean=c2.wasClean,k.dispatchEvent(d3),b2||j||((g.debug||a.debugAll)&&console.debug("ReconnectingWebSocket","onclose",g.url),k.dispatchEvent(l("close")));var e3=g.reconnectInterval*Math.pow(g.reconnectDecay,g.reconnectAttempts);setTimeout(function(){g.reconnectAttempts++,g.open(true)},e3>g.maxReconnectInterval?g.maxReconnectInterval:e3)}},h.onmessage=function(b3){(g.debug||a.debugAll)&&console.debug("ReconnectingWebSocket","onmessage",g.url,b3.data);var c2=l("message");c2.data=b3.data,k.dispatchEvent(c2)},h.onerror=function(b3){(g.debug||a.debugAll)&&console.debug("ReconnectingWebSocket","onerror",g.url,b3),k.dispatchEvent(l("error"))}}catch(error){console.error("WebSocket connection error:",error)}},1==this.automaticOpen&&this.open(false),this.send=function(b2){if(h)return(g.debug||a.debugAll)&&console.debug("ReconnectingWebSocket","send",g.url,b2),h.send(b2);throw"INVALID_STATE_ERR : Pausing to reconnect websocket"},this.close=function(a2,b2){"undefined"==typeof a2&&(a2=1e3),i2=true,h&&h.close(a2,b2)},this.refresh=function(){h&&h.readyState==1&&h.close()}}return a.prototype.onopen=function(){},a.prototype.onclose=function(){},a.prototype.onconnecting=function(){},a.prototype.onmessage=function(){},a.prototype.onerror=function(){},a.debugAll=false,a.CONNECTING=WebSocket.CONNECTING,a.OPEN=WebSocket.OPEN,a.CLOSING=WebSocket.CLOSING,a.CLOSED=WebSocket.CLOSED,a});let _isTipped=false;var _debugMode=false;var _initialized=null;var _dbcrs={};var _dbcrsTime=200;var _tickTime=20;var _scW=0;var cl=console.log;if(!_vcData)var _vcData=void 0;if(!_beaTn)var _beaTn=void 0;var beas;var appSettings;var execEl="";var currentlyValidTags=new Array;var _upwrk=new WebWorker("_upw");var _csswrk=new WebWorker("_cssw");_csswrk.start();var _ups=[];(function(e,t2){typeof module!="undefined"&&module.exports?module.exports=t2():typeof define=="function"&&define.amd?define(t2):this[e]=t2()})("bea",function(){function p(e2,t3){for(var n3=0,i3=e2.length;n3<i3;++n3)if(!t3(e2[n3]))return r2;return 1}function d(e2,t3){p(e2,function(e3){return t3(e3),1})}function v(e2,t3,n3){function g(e3){return e3.call?e3():u[e3]}function y(){if(!--h2){u[o2]=1,s2&&s2();for(var e3 in f)p(e3.split("|"),g)&&!d(f[e3],g)&&(f[e3]=[])}}e2=e2[i2]?e2:[e2];var r3=t3&&t3.call,s2=r3?t3:n3,o2=r3?e2.join(""):t3,h2=e2.length;return setTimeout(function(){d(e2,function t4(e3,n4){if(e3===null)return y();/*!n &&
17
17
  !/^https?:\/\//.test(e) &&
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lmjs/core",
3
- "version": "2.0.2",
3
+ "version": "2.1.0",
4
4
  "description": "LumenJS reactive core runtime — the reactive engine, HTML/JS AST compiler, realtime socket client, and delegated event listeners powering LumenJS applications.",
5
5
  "files": [
6
6
  "dist/",
package/src/_re.js CHANGED
@@ -190,7 +190,17 @@ function _x(_x) {
190
190
  // so a stale tail from a prior _vt.Global read (which never hit
191
191
  // "View" to reset it) would otherwise get prepended to the next
192
192
  // chain and corrupt which key set()'s update(key) fires for.
193
- if (key == "View" || key == "Global") currPath = [];
193
+ // 2026-09-18: generalized from a hardcoded `key == "View" ||
194
+ // key == "Global"` name list (which needed editing every time a
195
+ // new permanent root, e.g. "Widgets", got added) to the one
196
+ // thing that's actually invariant: `target === _x` is only ever
197
+ // true for THIS proxy's own outermost target (the raw root
198
+ // object this whole closure was built from) — any nested proxy
199
+ // in the tree wraps some OTHER object as its target, never `_x`
200
+ // itself. So this fires on any fresh top-level access
201
+ // (`_vt.View`, `_vt.Global`, `_vt.Widgets`, ...) regardless of
202
+ // the key name, with nothing new to maintain per root added.
203
+ if (target === _x) currPath = [];
194
204
  currPath.push(key);
195
205
  if (typeof target[key] === 'object' && target[key] !== null && key != "_re") {
196
206
  // cl("salsaa", target, key)
@@ -287,11 +297,55 @@ function _x(_x) {
287
297
  // an uncaught exception there aborts every remaining statement in the
288
298
  // whole bundle file, breaking the entire app on every real production
289
299
  // site with this pattern. Found deploying lumenjs.com's own real build.
300
+ // "Widgets" (2026-09-18): a third permanent root, sibling of Global/View,
301
+ // generalizing V1's hardcoded hasNav/hasHeader/hasFooter widget-loading past
302
+ // its fixed 3-name list — see renderView()'s layout branch below for the
303
+ // resolve/mount/diff logic, and fcs.js's annotateLayoutRegions() for how a
304
+ // layout's own bare attributes (e.g. `<nav nav>`) become the region names
305
+ // used to key this object. Deliberately NOT an ancestor of View in the
306
+ // scope tree (widget regions and [body] are DOM SIBLINGS under the layout
307
+ // root, never one containing the other — unlike a subview's real, singular
308
+ // parent, there's no single unambiguous "the" widget a view could shadow
309
+ // into) — each entry gets its own real `._re` instead (see
310
+ // _dispatchVarsUpdate's generic owner-walk below, which already handles
311
+ // this with zero special-casing once an entry has `._re` set, same as any
312
+ // subview). Starts empty; populated lazily, one entry per declared region
313
+ // name, the first time a layout using that region is mounted.
290
314
  let _vt = _x({
291
315
  "View": new _v({}),
292
- "Global": { "vars": {}, "fns": {} }
316
+ "Global": { "vars": {}, "fns": {} },
317
+ "Widgets": {}
293
318
  });
294
319
 
320
+ // 2026-09-18: shared by getVal()/evalExp()/concatVarsAtLevel() below, so the
321
+ // "first-declared widget wins on a name collision" rule is defined exactly
322
+ // once. Object key iteration order for string keys is real insertion order,
323
+ // so this naturally checks widgets in the order they were first mounted —
324
+ // which, in practice, is document order (renderView()'s layout branch walks
325
+ // `hstL.regions`, itself built in document order by fcs.js's
326
+ // annotateLayoutRegions()).
327
+ function _lookupInWidgets(name) {
328
+ for (const wname in _vt.Widgets) {
329
+ if (_vt.Widgets[wname].vars.hasOwnProperty(name)) return _vt.Widgets[wname].vars[name];
330
+ }
331
+ return undefined;
332
+ }
333
+
334
+ // concatVarsAtLevel() below merges via object spread, not the loop-with-
335
+ // break shape _lookupInWidgets() uses — spread's "later wins" needs the
336
+ // widgets merged in REVERSE declaration order so the first-declared widget
337
+ // still wins a name collision, matching _lookupInWidgets()'s own semantics
338
+ // exactly (both must agree, since getVal()/evalExp() use one and
339
+ // concatVarsAtLevel()/lookup()/scopedEval() use the other for the same read).
340
+ function _mergedWidgetsVars() {
341
+ let out = {};
342
+ let names = Object.keys(_vt.Widgets).reverse();
343
+ for (const wname of names) {
344
+ out = { ...out, ..._vt.Widgets[wname].vars };
345
+ }
346
+ return out;
347
+ }
348
+
295
349
  class _lm {
296
350
  _RealDOM = [];
297
351
  _effects = {};
@@ -1073,10 +1127,17 @@ class _lm {
1073
1127
  // lookup()/scopedEval(); getVal() (what mustache text nodes
1074
1128
  // actually call) had its own separate, unmerged read here
1075
1129
  // and was silently rendering these as empty.
1130
+ // 2026-09-18: inserted a middle tier — _lookupInWidgets()
1131
+ // (all currently-mounted widgets' vars, first-declared
1132
+ // wins) — between View and Global, per this session's
1133
+ // agreed read-fallback order.
1076
1134
  let __name = this.reactiveVariables[i];
1077
- vars[__name] = _vt.View.vars.hasOwnProperty(__name)
1078
- ? _vt.View.vars[__name]
1079
- : _vt.Global.vars[__name];
1135
+ if (_vt.View.vars.hasOwnProperty(__name)) {
1136
+ vars[__name] = _vt.View.vars[__name];
1137
+ } else {
1138
+ let _wv = _lookupInWidgets(__name);
1139
+ vars[__name] = _wv !== undefined ? _wv : _vt.Global.vars[__name];
1140
+ }
1080
1141
  }
1081
1142
  for (const ky in this.vrs) {
1082
1143
  if (Object.prototype.hasOwnProperty.call(this.vrs, ky)) {
@@ -1207,8 +1268,10 @@ class _lm {
1207
1268
  // Global vars (index.js's top-level state, see _vt.Global
1208
1269
  // above) sit at the lowest priority here — a view or a
1209
1270
  // narrower scope declaring the same name shadows it, same
1210
- // as real JS scoping would.
1211
- concatenatedVars = { ..._vt.Global.vars, ...parent.view.vars, ...concatenatedVars };
1271
+ // as real JS scoping would. 2026-09-18: widgets' vars sit
1272
+ // one tier above Global, below the view's own — see
1273
+ // _mergedWidgetsVars()'s comment for the ordering rationale.
1274
+ concatenatedVars = { ..._vt.Global.vars, ..._mergedWidgetsVars(), ...parent.view.vars, ...concatenatedVars };
1212
1275
  }
1213
1276
  return concatenatedVars;
1214
1277
  }
@@ -1520,10 +1583,15 @@ class _lm {
1520
1583
  // value scopedEval() would otherwise have found in
1521
1584
  // _vt.Global.vars — breaking :if/:for conditions on any
1522
1585
  // index.js-declared var, not just mustache text (getVal()).
1586
+ // 2026-09-18: same middle tier as getVal() — see its
1587
+ // matching comment.
1523
1588
  let __name = vars[i];
1524
- rvars[__name] = _vt.View.vars.hasOwnProperty(__name)
1525
- ? _vt.View.vars[__name]
1526
- : _vt.Global.vars[__name];
1589
+ if (_vt.View.vars.hasOwnProperty(__name)) {
1590
+ rvars[__name] = _vt.View.vars[__name];
1591
+ } else {
1592
+ let _wv = _lookupInWidgets(__name);
1593
+ rvars[__name] = _wv !== undefined ? _wv : _vt.Global.vars[__name];
1594
+ }
1527
1595
  }
1528
1596
  // 2026-09-17, real bug found and fixed: getVal() (mustache
1529
1597
  // text, e.g. {{f.name}}) has always merged this.vrs in after
@@ -2544,7 +2612,6 @@ async function renderView(n, isSub, d, type = 'views', viewsArr, scopeBase = ["V
2544
2612
  let filePath = "src/views/" + n + ".view"
2545
2613
  if (type == 'layouts') filePath = "src/layouts/" + n + ".layout";
2546
2614
 
2547
- cl(arguments);
2548
2615
  let fileKey = btoa(filePath);
2549
2616
  if (!isSub) {
2550
2617
  View.props = d ?? {};
@@ -2657,12 +2724,21 @@ async function renderView(n, isSub, d, type = 'views', viewsArr, scopeBase = ["V
2657
2724
 
2658
2725
  let appSelector = appSettings.App ?? "[app]";
2659
2726
  var appContainer = $(appSelector);
2727
+ // 2026-09-18: whether THIS call just replaced the layout's
2728
+ // own DOM wholesale — needed below by the widget
2729
+ // resolve/mount/diff pass, since a widget whose resolution
2730
+ // hasn't changed still needs its already-rendered nodes
2731
+ // reattached to the fresh layout element (the old one they
2732
+ // were living in is gone), even though nothing about the
2733
+ // widget itself needs re-rendering.
2734
+ let layoutJustSwapped = false;
2660
2735
  if (appContainer.length) {
2661
2736
  let currentLayout = $(appSelector).data('layout');
2662
2737
  if (currentLayout != layout) {
2663
2738
  let _rel = await renderHST(hstL, layout, 'layout');
2664
2739
  appContainer.data('layout', layout).html(_rel._RealDOM);
2665
2740
  _rel.renderAll();
2741
+ layoutJustSwapped = true;
2666
2742
  } else {
2667
2743
  // cl("Same Layout");
2668
2744
  }
@@ -2672,6 +2748,59 @@ async function renderView(n, isSub, d, type = 'views', viewsArr, scopeBase = ["V
2672
2748
  appContainer = $(appSelector);
2673
2749
  appContainer.data('layout', layout).html(_rel._RealDOM);
2674
2750
  _rel.renderAll();
2751
+ layoutJustSwapped = true;
2752
+ }
2753
+
2754
+ // Persistent layout widgets (_vt.Widgets, 2026-09-18) — see
2755
+ // that object's own declaration comment for the design.
2756
+ // Runs on EVERY navigation, not gated on layoutJustSwapped:
2757
+ // a view's own settings (hasNav: false, hasNav: "nav2", ...)
2758
+ // can change what belongs in a region even when the layout
2759
+ // itself didn't change at all. hstL.regions is precomputed
2760
+ // build-time by fcs.js's annotateLayoutRegions() — the bare
2761
+ // (valueless) attribute names the CURRENTLY MOUNTED layout
2762
+ // itself declares (e.g. ["header","nav","footer"] for
2763
+ // `<header header>`/`<nav nav>`/`<footer footer>`).
2764
+ let declaredRegions = (hstL && hstL.regions) || [];
2765
+ for (const regionName of declaredRegions) {
2766
+ let settingsKey = "has" + regionName[0].toUpperCase() + regionName.slice(1);
2767
+ let want = _re.view.settings.hasOwnProperty(settingsKey) ? _re.view.settings[settingsKey] : true;
2768
+ let resolvedFile = want === false ? null : (want === true ? regionName : want);
2769
+
2770
+ let w = _vt.Widgets[regionName] || (_vt.Widgets[regionName] = { vars: {}, fns: {}, views: [], _re: null, _resolvedFile: undefined });
2771
+
2772
+ if (resolvedFile !== w._resolvedFile) {
2773
+ // Resolution genuinely changed since the last time
2774
+ // this region was resolved — mount fresh, or clear.
2775
+ if (resolvedFile === null) {
2776
+ $('[' + regionName + ']').html('');
2777
+ w._re = null;
2778
+ } else {
2779
+ let wFilePath = "src/views/widgets/" + resolvedFile + ".view";
2780
+ let wHst = _payload['views'][btoa(wFilePath)];
2781
+ if (wHst) {
2782
+ let _rew = await renderHST(wHst, resolvedFile, 'widget', undefined, null, ["Widgets", regionName], w.vars, w.fns, w.views);
2783
+ w._re = _rew;
2784
+ $('[' + regionName + ']').html(_rew._RealDOM);
2785
+ _rew.renderAll();
2786
+ }
2787
+ }
2788
+ w._resolvedFile = resolvedFile;
2789
+ } else if (layoutJustSwapped && w._re) {
2790
+ // Same widget as before, but the layout element it
2791
+ // lives in was just replaced wholesale — reattach
2792
+ // the EXISTING rendered nodes (.html() moves real
2793
+ // node references, same as [body]/[slot] below,
2794
+ // it doesn't clone) rather than re-rendering. The
2795
+ // widget's own state (w.vars/.fns/.views) never
2796
+ // lived on the old DOM to begin with, so nothing
2797
+ // was lost — only the attachment point needed
2798
+ // fixing up.
2799
+ $('[' + regionName + ']').html(w._re._RealDOM);
2800
+ }
2801
+ // else: nothing changed and the layout didn't just
2802
+ // swap — this region's DOM/state is left completely
2803
+ // untouched, on purpose (the whole point of this).
2675
2804
  }
2676
2805
 
2677
2806
  // return;