@rettangoli/ui 0.1.19 → 0.1.20

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.
@@ -935,7 +935,7 @@ var rettangoli=(()=>{var si=Object.defineProperty;var P=(e,t)=>{for(var r in t)s
935
935
  min-width: 200px;
936
936
  max-width: 400px;
937
937
  }
938
- `))}constructor(){super(),e.initializeStyleSheet(),this.shadow=this.attachShadow({mode:"open"}),this.shadow.adoptedStyleSheets=[e.styleSheet],this._dialogElement=document.createElement("dialog"),this.shadow.appendChild(this._dialogElement),this._dialogElement.addEventListener("click",t=>{t.stopPropagation();let r=t.composedPath();(r[0]===this._dialogElement||r[0].nodeName==="DIALOG"&&r[0]===this._dialogElement)&&this.dispatchEvent(new CustomEvent("close",{detail:{}}))}),this._dialogElement.addEventListener("contextmenu",t=>{let r=t.composedPath();(r[0]===this._dialogElement||r[0].nodeName==="DIALOG"&&r[0]===this._dialogElement)&&(t.preventDefault(),this.dispatchEvent(new CustomEvent("close",{detail:{}})))}),this._dialogElement.addEventListener("cancel",t=>{t.preventDefault(),this.dispatchEvent(new CustomEvent("close",{detail:{}}))}),this._popoverContainer=document.createElement("div"),this._popoverContainer.className="popover-container",this._dialogElement.appendChild(this._popoverContainer),this._slotElement=null,this._isOpen=!1}static get observedAttributes(){return["open","x","y","placement"]}connectedCallback(){this.hasAttribute("open")&&this._show()}disconnectedCallback(){this._isOpen&&this._dialogElement.open&&this._dialogElement.close()}attributeChangedCallback(t,r,s){t==="open"?s!==null&&!this._isOpen?this.isConnected&&this._show():s===null&&this._isOpen&&this._hide():(t==="x"||t==="y"||t==="placement")&&this._isOpen&&this._updatePosition()}_show(){this._isOpen||(this._slotElement||(this._slotElement=document.createElement("slot"),this._slotElement.setAttribute("name","content"),this._popoverContainer.appendChild(this._slotElement)),this._isOpen=!0,this._dialogElement.open||setTimeout(()=>{this._dialogElement&&!this._dialogElement.open&&(this.hasAttribute("no-overlay")?this._dialogElement.show():this._dialogElement.showModal())},0),requestAnimationFrame(()=>{this._updatePosition()}))}_hide(){this._isOpen&&(this._isOpen=!1,this._dialogElement.open&&this._dialogElement.close(),this._slotElement&&(this._popoverContainer.removeChild(this._slotElement),this._slotElement=null))}_updatePosition(){let t=parseFloat(this.getAttribute("x")||"0"),r=parseFloat(this.getAttribute("y")||"0"),s=this.getAttribute("placement")||"bottom-start";this.removeAttribute("positioned"),requestAnimationFrame(()=>{let i=this._popoverContainer.getBoundingClientRect(),{left:n,top:o}=this._calculatePosition(t,r,i.width,i.height,s);this._popoverContainer.style.left=`${n}px`,this._popoverContainer.style.top=`${o}px`,requestAnimationFrame(()=>{this.setAttribute("positioned","")})})}_calculatePosition(t,r,s,i,n){let l=t,p=r;switch(n){case"top":l=t-s/2,p=r-i-8;break;case"top-start":l=t,p=r-i-8;break;case"top-end":l=t-s,p=r-i-8;break;case"right":l=t+8,p=r-i/2;break;case"right-start":l=t+8,p=r;break;case"right-end":l=t+8,p=r-i;break;case"bottom":l=t-s/2,p=r+8;break;case"bottom-start":l=t,p=r+8;break;case"bottom-end":l=t-s,p=r+8;break;case"left":l=t-s-8,p=r-i/2;break;case"left-start":l=t-s-8,p=r;break;case"left-end":l=t-s-8,p=r-i;break}let a=8;return l=Math.max(a,Math.min(l,window.innerWidth-s-a)),p=Math.max(a,Math.min(p,window.innerHeight-i-a)),{left:l,top:p}}get popover(){return this._popoverContainer}},Tr=({render:e,html:t})=>dt;var ft={};P(ft,{handleClickItem:()=>fi});var fi=(e,t)=>{let{dispatchEvent:r}=e,i=t._event.currentTarget.dataset.id;r(new CustomEvent("item-click",{detail:{id:i}}))};var yt={};P(yt,{createInitialState:()=>yi,selectViewData:()=>vi});var yi=()=>Object.freeze({}),mi=["id","class","style","slot"],gi=e=>Object.entries(e).filter(([t])=>!mi.includes(t)).map(([t,r])=>`${t}=${r}`).join(" "),vi=({props:e,attrs:t})=>{let r=gi(t),s=e.items||[],i=e.separator||"breadcrumb-arrow",n=[];return s.forEach((o,l)=>{n.push(o),l<s.length-1&&n.push({isSeparator:!0})}),{containerAttrString:r,items:n,separator:i}};var Lr={elementName:"rtgl-breadcrumb",viewDataSchema:{type:"object",properties:{containerAttrString:{type:"string"},items:{type:"array",items:{type:"object",properties:{label:{type:"string"},id:{type:"string"}}}},separator:{type:"string"}}},propsSchema:{type:"object",properties:{items:{type:"array",items:{type:"object",properties:{label:{type:"string"},id:{type:"string"}}}},separator:{type:"string",default:"breadcrumb-arrow"}}},refs:{"item-*":{eventListeners:{click:{handler:"handleClickItem"}}}},events:{"item-click":{type:"object",properties:{item:{type:"object",properties:{label:{type:"string"},id:{type:"string"}}},index:{type:"number"}}}},template:{type:9,items:[{type:8,properties:[{key:"rtgl-view d=h av=c g=md p=sm ${containerAttrString}",value:{type:9,items:[{type:7,itemVar:"item",indexVar:null,iterable:{type:1,path:"items"},body:{type:9,items:[{type:8,properties:[{key:"$if item.isSeparator",value:{type:6,conditions:[{type:1,path:"item.isSeparator"},{type:1,path:"item.id"},null],bodies:[{type:9,items:[{type:8,properties:[{key:"rtgl-svg wh=16 svg=${separator} c=mu-fg",value:{type:0,value:null},parsedKey:{type:2,parts:["rtgl-svg wh=16 svg=",{type:1,path:"separator"}," c=mu-fg"]}}],fast:!0}],fast:!0},{type:9,items:[{type:8,properties:[{key:"rtgl-view#item-${item.id} data-id=${item.id} cur=p",value:{type:9,items:[{type:8,properties:[{key:"rtgl-text s=sm c=mu-fg",value:{type:1,path:"item.label"}}],fast:!0}],fast:!0},parsedKey:{type:2,parts:["rtgl-view#item-",{type:1,path:"item.id"}," data-id=",{type:1,path:"item.id"}," cur=p"]}}],fast:!0}],fast:!0},{type:9,items:[{type:8,properties:[{key:"rtgl-text s=sm c=mu-fg",value:{type:1,path:"item.label"}}],fast:!0}],fast:!0}],id:null}}],fast:!1}],fast:!1}}],fast:!1},parsedKey:{type:2,parts:["rtgl-view d=h av=c g=md p=sm ",{type:1,path:"containerAttrString"}]}}],fast:!1}],fast:!1}};var mt={};P(mt,{handleClickMenuItem:()=>wi,handleClosePopover:()=>bi});var bi=(e,t)=>{let{dispatchEvent:r}=e;r(new CustomEvent("close"))},wi=(e,t)=>{let{dispatchEvent:r,props:s}=e,i=t._event,n=parseInt(i.currentTarget.id.replace("option-","")),o=s.items[n];r(new CustomEvent("click-item",{detail:{index:n,item:o}}))};var gt={};P(gt,{createInitialState:()=>_i,selectViewData:()=>xi});var _i=()=>Object.freeze({}),xi=({props:e,attrs:t})=>({items:e.items||[],open:!!t.open,x:t.x,y:t.y,placement:t.placement});var Rr={elementName:"rtgl-dropdown-menu",viewDataSchema:{type:"object"},propsSchema:{type:"object",properties:{items:{type:"array",items:{type:"object",properties:{label:{type:"string"},type:{type:"string",enum:["label","item","separator"]}}}}}},attrsSchema:{type:"object",properties:{open:{type:"string"},x:{type:"string"},y:{type:"string"},placement:{type:"string"}}},refs:{popover:{eventListeners:{close:{handler:"handleClosePopover"}}},"option-*":{eventListeners:{click:{handler:"handleClickMenuItem"}}}},template:{type:9,items:[{type:8,properties:[{key:"rtgl-popover#popover ?open=${open} x=${x} y=${y} placement=${placement}",value:{type:9,items:[{type:8,properties:[{key:"rtgl-view wh=300 sv g=xs slot=content bgc=background br=md",value:{type:9,items:[{type:7,itemVar:"item",indexVar:"i",iterable:{type:1,path:"items"},body:{type:9,items:[{type:8,properties:[{key:"$if item.type == 'label'",value:{type:6,conditions:[{type:4,op:0,left:{type:1,path:"item.type"},right:{type:0,value:"label"}},{type:4,op:0,left:{type:1,path:"item.type"},right:{type:0,value:"item"}},{type:4,op:0,left:{type:1,path:"item.type"},right:{type:0,value:"separator"}}],bodies:[{type:9,items:[{type:8,properties:[{key:"rtgl-view w=f ph=lg pv=md",value:{type:9,items:[{type:8,properties:[{key:"rtgl-text s=sm c=mu-fg",value:{type:1,path:"item.label"}}],fast:!0}],fast:!0}}],fast:!0}],fast:!0},{type:9,items:[{type:8,properties:[{key:"rtgl-view#option-${i} w=f h-bgc=ac ph=lg pv=md cur=p br=md bgc=mu",value:{type:9,items:[{type:8,properties:[{key:"rtgl-text",value:{type:1,path:"item.label"}}],fast:!0}],fast:!0},parsedKey:{type:2,parts:["rtgl-view#option-",{type:1,path:"i"}," w=f h-bgc=ac ph=lg pv=md cur=p br=md bgc=mu"]}}],fast:!0}],fast:!0},{type:9,items:[{type:8,properties:[{key:"rtgl-view w=f h=1 ph=lg mv=md bgc=bo",value:{type:0,value:null}}],fast:!0}],fast:!0}],id:null}}],fast:!1}],fast:!1}}],fast:!1}}],fast:!1}],fast:!1},parsedKey:{type:2,parts:["rtgl-popover#popover ?open=",{type:1,path:"open"}," x=",{type:1,path:"x"}," y=",{type:1,path:"y"}," placement=",{type:1,path:"placement"}]}}],fast:!1}],fast:!1}};var vt={};P(vt,{handleActionClick:()=>$i,handleAfterMount:()=>Ei,handleBeforeMount:()=>Ai,handleColorPickerChange:()=>Oi,handleImageClick:()=>Li,handleInputChange:()=>Si,handleOnUpdate:()=>ki,handleSelectAddOption:()=>Ni,handleSelectChange:()=>Ci,handleSliderChange:()=>Ii,handleSliderInputChange:()=>Ti,handleTooltipMouseEnter:()=>Pi,handleTooltipMouseLeave:()=>Vi,handleWaveformClick:()=>Ri});var Nr=({form:e,defaultValues:t={},refs:r})=>{let{fields:s=[]}=e;s.forEach(i=>{let n=r[`field-${i.name}`]?.elm;if(n){if(["inputText","colorPicker","slider","slider-input","popover-input"].includes(i.inputType)){let o=t[i.name];o==null?n.removeAttribute("value"):n.setAttribute("value",o)}if(i.inputType==="inputText"&&i.placeholder&&n.getAttribute("placeholder")!==i.placeholder&&(i.placeholder===void 0||i.placeholder===null?n.removeAttribute("placeholder"):n.setAttribute("placeholder",i.placeholder)),i.inputType==="select"&&i.placeholder&&n.placeholder!==i.placeholder&&(n.placeholder=i.placeholder),i.inputType==="select"){i.placeholder!==n.getAttribute("placeholder")&&(i.placeholder!==void 0?n.setAttribute("placeholder",i.placeholder):n.removeAttribute("placeholder"),n.render());let o=t[i.name];o!==n.selectedValue&&(n.selectedValue=o,n.render())}}})},Ai=e=>{let{store:t,props:r}=e;t.setFormValues(r.defaultValues)},Ei=e=>{let{props:t,getRefIds:r,render:s}=e,{form:i={},defaultValues:n}=t,o=r();Nr({form:i,defaultValues:n,refs:o}),s()},ki=(e,t)=>{let{oldAttrs:r,newAttrs:s,newProps:i}=t,{store:n,render:o,getRefIds:l}=e,{form:p={},defaultValues:a}=i;if(r?.key!==s?.key){let c=l();Nr({form:p,defaultValues:a,refs:c}),n.setFormValues(a),o();return}o()},Ie=(e,t,r,s)=>{s(new CustomEvent("form-change",{detail:{name:e,fieldValue:t,formValues:r}}))},$i=(e,t)=>{let{store:r,dispatchEvent:s}=e,n=t._event.currentTarget.id.replace("action-","");s(new CustomEvent("action-click",{detail:{actionId:n,formValues:r.selectFormValues()}}))},Si=(e,t)=>{let{store:r,dispatchEvent:s,props:i}=e,n=t._event,o=n.currentTarget.id.replace("field-","");o&&n.detail.value!==void 0&&(r.setFormFieldValue({name:o,value:n.detail.value,props:i}),Ie(o,n.detail.value,r.selectFormValues(),s))},Ci=(e,t)=>{let{store:r,dispatchEvent:s,render:i,props:n}=e,o=t._event,l=o.currentTarget.id.replace("field-","");l&&(r.setFormFieldValue({name:l,value:o.detail.selectedValue,props:n}),Ie(l,o.detail.selectedValue,r.selectFormValues(),s),i())},Oi=(e,t)=>{let{store:r,dispatchEvent:s,props:i}=e,n=t._event,o=n.currentTarget.id.replace("field-","");o&&n.detail.value!==void 0&&(r.setFormFieldValue({name:o,value:n.detail.value,props:i}),Ie(o,n.detail.value,r.selectFormValues(),s))},Ii=(e,t)=>{let{store:r,dispatchEvent:s,props:i}=e,n=t._event,o=n.currentTarget.id.replace("field-","");o&&n.detail.value!==void 0&&(r.setFormFieldValue({name:o,value:n.detail.value,props:i}),Ie(o,n.detail.value,r.selectFormValues(),s))},Ti=(e,t)=>{let{store:r,dispatchEvent:s,props:i}=e,n=t._event,o=n.currentTarget.id.replace("field-","");o&&n.detail.value!==void 0&&(r.setFormFieldValue({name:o,value:n.detail.value,props:i}),Ie(o,n.detail.value,r.selectFormValues(),s))},Li=(e,t)=>{let r=t._event;r.type==="contextmenu"&&r.preventDefault();let{dispatchEvent:s}=e,i=r.currentTarget.id.replace("image-","");s(new CustomEvent("extra-event",{detail:{name:i,x:r.clientX,y:r.clientY,trigger:r.type}}))},Ri=(e,t)=>{let r=t._event;r.type==="contextmenu"&&r.preventDefault();let{dispatchEvent:s}=e,i=r.currentTarget.id.replace("waveform-","");s(new CustomEvent("extra-event",{detail:{name:i,x:r.clientX,y:r.clientY,trigger:r.type}}))},Ni=(e,t)=>{let{store:r,dispatchEvent:s}=e,n=t._event.currentTarget.id.replace("field-","");s(new CustomEvent("action-click",{detail:{actionId:"select-options-add",name:n,formValues:r.selectFormValues()}}))},Pi=(e,t)=>{let{store:r,render:s,props:i}=e,n=t._event,o=n.currentTarget.id.replace("tooltip-icon-",""),p=i.form.fields.find(a=>a.name===o);if(p&&p.tooltip){let a=n.currentTarget.getBoundingClientRect();r.showTooltip({x:a.left+a.width/2,y:a.top-8,content:p.tooltip.content}),s()}},Vi=e=>{let{store:t,render:r}=e;t.hideTooltip(),r()};var Et={};P(Et,{createInitialState:()=>yn,getFormFieldValue:()=>xn,hideTooltip:()=>$n,selectForm:()=>Ue,selectFormValues:()=>_n,selectState:()=>wn,selectViewData:()=>bn,setFormFieldValue:()=>En,setFormValues:()=>An,showTooltip:()=>kn});var v={LITERAL:0,VARIABLE:1,INTERPOLATION:2,FUNCTION:3,BINARY:4,UNARY:5,CONDITIONAL:6,LOOP:7,OBJECT:8,ARRAY:9,PARTIAL:10,PATH_REFERENCE:11},B={EQ:0,NEQ:1,GT:2,LT:3,GTE:4,LTE:5,AND:6,OR:7,IN:8,ADD:10,SUBTRACT:11},Te={NOT:0};var k=class extends Error{constructor(t){super(`Parse Error: ${t}`),this.name="JemplParseError"}},X=class extends Error{constructor(t){super(`Render Error: ${t}`),this.name="JemplRenderError"}};var bt=e=>{if(!e||e.trim()==="")throw new k("Missing condition expression after '$if'");if(e.includes("===")||e.includes("!==")){let r=e.includes("===")?"==":"!=";throw new k(`Invalid comparison operator '${e.includes("===")?"===":"!=="}' - did you mean '${r}'? (got: '${e}')`)}let t=["<",">","<=",">=","==","!="];for(let r of t)if(e.trim().endsWith(r))throw new k(`Incomplete comparison expression - missing right operand (got: '${e}')`)},Pr=e=>{if(e.trim().endsWith(" in"))throw new k(`Missing iterable expression after 'in' (got: '$for ${e}')`);if(!e.includes(" in "))throw new k(`Invalid loop syntax - missing 'in' keyword (got: '$for ${e}')`);let[t,r]=e.split(" in ");if(!r||r.trim()==="")throw new k(`Missing iterable expression after 'in' (got: '$for ${e}')`);let s=t.includes(",")?t.split(",").map(i=>i.trim()):[t.trim()];for(let i of s){if(!i)throw new k(`Invalid loop variable - variable name cannot be empty (got: '$for ${e}')`);if(!/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(i))throw new k(`Invalid loop syntax (got: '$for ${e}')`)}};var Vr=(e,t,r=!1)=>{if(t===null)return new X(`Cannot iterate over null value at '$for ${e}'`);if(t===void 0)return new X(`Cannot iterate over undefined value at '$for ${e}'`);let s=typeof t;return r?new X(`Cannot iterate over non-array value in loop '${e}' - got ${s} instead`):new X(`Cannot iterate over non-array value (got: ${s}) at '$for ${e}'`)},Dr=(e,t)=>{let r=t&&Object.keys(t).length>0?Object.keys(t).join(", "):"no custom functions provided";return new X(`Unknown function '${e}' (${r})`)};var Di=(e,t,r={})=>{let s={},i={};r&&typeof r=="object"&&(r.functions!==void 0||r.partials!==void 0?(s=r.functions||{},i=r.partials||{}):typeof r=="object"&&(s=r));let o=I(e,{functions:s,partials:i},t,{});return o===void 0?{}:o},I=(e,t,r,s)=>{let i=t.functions||t;if(e.var&&!e.type)return z(e.var,r,s);if(e.type===v.LITERAL)return e.value;if(e.type===v.VARIABLE)return z(e.path,r,s);if(e.type===v.INTERPOLATION)return Bi(e.parts,t,r,s);switch(e.type){case v.FUNCTION:return Br(e,t,r,s);case v.BINARY:return Wr(e,t,r,s);case v.UNARY:return Mr(e,t,r,s);case v.CONDITIONAL:return Mi(e,t,r,s);case v.LOOP:return Hi(e,t,r,s);case v.OBJECT:return qi(e,t,r,s);case v.ARRAY:return Yi(e,t,r,s);case v.PARTIAL:return Gi(e,t,r,s);case v.PATH_REFERENCE:return Xi(e,t,r,s);default:throw new Error(`Unknown node type: ${e.type}`)}},jr=new Map,ji=e=>{let t=[],r="",s=!1;for(let i=0;i<e.length;i++){let n=e[i];if(n==="[")r&&(t.push({type:"property",value:r}),r=""),s=!0;else if(n==="]"){if(s&&r){let o=r.trim();if(/^\d+$/.test(o))t.push({type:"index",value:parseInt(o,10)});else if(o.startsWith('"')&&o.endsWith('"')||o.startsWith("'")&&o.endsWith("'")){let l=o.slice(1,-1);t.push({type:"property",value:l})}else t.push({type:"property",value:o});r=""}s=!1}else r+=n}return r&&t.push({type:"property",value:r}),t},z=(e,t,r)=>{if(!e)return;if(e in r)return r[e];let s=jr.get(e);if(!s){let n=[],o="",l=0;for(let p=0;p<e.length;p++){let a=e[p];a==="["?(l++,o+=a):a==="]"?(l--,o+=a):a==="."&&l===0?o&&(n.push(o),o=""):o+=a}o&&n.push(o),s=[];for(let p of n){let a=ji(p.trim());s.push(...a)}jr.set(e,s)}let i=t;for(let n=0;n<s.length;n++){let o=s[n];if(o.type==="property"&&o.value in r){i=r[o.value];continue}if(i==null)return;(o.type==="property"||o.type==="index")&&(i=i[o.value])}return i},Bi=(e,t,r,s)=>{let i=[];for(let n of e)if(typeof n=="string")i.push(n);else{let o=I(n,t,r,s);i.push(o!=null?String(o):"")}return i.join("")},Br=(e,t,r,s)=>{let i=t.functions||t,n=i[e.name];if(!n)throw Dr(e.name,i);let o=e.args.map(l=>I(l,t,r,s));return n(...o)},xe=(e,t,r,s)=>{if(e.var&&!e.type)return z(e.var,r,s);switch(e.type){case v.VARIABLE:return z(e.path,r,s);case v.LITERAL:return e.value;case v.BINARY:return Wr(e,t,r,s);case v.UNARY:return Mr(e,t,r,s);case v.FUNCTION:return Br(e,t,r,s);default:return I(e,t,r,s)}},Wr=(e,t,r,s)=>{if(e.op===B.AND||e.op===B.OR){let o=xe(e.left,t,r,s),l=xe(e.right,t,r,s);switch(e.op){case B.AND:return o&&l;case B.OR:return o||l}}let i=I(e.left,t,r,s),n=I(e.right,t,r,s);switch(e.op){case B.EQ:return i==n;case B.NEQ:return i!=n;case B.GT:return i>n;case B.LT:return i<n;case B.GTE:return i>=n;case B.LTE:return i<=n;case B.IN:return Array.isArray(n)?n.includes(i):!1;case B.ADD:if(typeof i!="number"||typeof n!="number")throw new X(`Arithmetic operations require numbers. Got ${typeof i} + ${typeof n}`);return i+n;case B.SUBTRACT:if(typeof i!="number"||typeof n!="number")throw new X(`Arithmetic operations require numbers. Got ${typeof i} - ${typeof n}`);return i-n;default:throw new Error(`Unknown binary operator: ${e.op}`)}},Mr=(e,t,r,s)=>{let i=e.op===Te.NOT?xe(e.operand,t,r,s):I(e.operand,t,r,s);switch(e.op){case Te.NOT:return!i;default:throw new Error(`Unknown unary operator: ${e.op}`)}},Wi=(e,t,r,s)=>{if(e.conditions.length===2&&e.conditions[1]===null){let i=e.conditions[0];if(i.type===v.VARIABLE)if(z(i.path,r,s)){let o=e.bodies[0];if(o.type===v.OBJECT&&o.properties.length<=5){let l={};for(let p of o.properties){let a=p.parsedKey?I(p.parsedKey,t,r,s):p.key,c=p.value;if(c.type===v.LITERAL)l[a]=c.value;else if(c.type===v.VARIABLE)l[a]=z(c.path,r,s);else if(c.type===v.INTERPOLATION){let u=[];for(let h of c.parts)if(typeof h=="string")u.push(h);else if(h.type===v.VARIABLE){let f=z(h.path,r,s);u.push(f!=null?String(f):"")}else{let f=I(h,t,r,s);u.push(f!=null?String(f):"")}l[a]=u.join("")}else l[a]=I(c,t,r,s)}return l}}else{let o=e.bodies[1];if(o.type===v.OBJECT&&o.properties.length<=5){let l={};for(let p of o.properties){let a=p.parsedKey?I(p.parsedKey,t,r,s):p.key,c=p.value;if(c.type===v.LITERAL)l[a]=c.value;else if(c.type===v.VARIABLE)l[a]=z(c.path,r,s);else if(c.type===v.INTERPOLATION){let u=[];for(let h of c.parts)if(typeof h=="string")u.push(h);else if(h.type===v.VARIABLE){let f=z(h.path,r,s);u.push(f!=null?String(f):"")}else{let f=I(h,t,r,s);u.push(f!=null?String(f):"")}l[a]=u.join("")}else l[a]=I(c,t,r,s)}return l}}}return null},Mi=(e,t,r,s)=>{let i=Wi(e,t,r,s);if(i!==null)return i;for(let n=0;n<e.conditions.length;n++){let o=e.conditions[n];if(o===null||xe(o,t,r,s))return I(e.bodies[n],t,r,s)}return Fr},Fi=(e,t)=>{let r=e.body,s=e.itemVar;if(r.type===v.CONDITIONAL&&r.conditions.length===1&&r.conditions[0].type===v.VARIABLE){let i=r.conditions[0].path,n=r.bodies[0];if(i.startsWith(s+".")){let o=i.substring(s.length+1);if(n.type===v.OBJECT&&n.properties.length<=5){for(let p of n.properties)if(p.parsedKey)return null;let l=[];for(let p=0;p<t.length;p++){let a=t[p];if(a[o]){let c={};for(let u of n.properties){let h=u.key,f=u.value;if(f.type===v.LITERAL)c[h]=f.value;else if(f.type===v.VARIABLE){let d=f.path;if(d===s)c[h]=a;else if(d.startsWith(s+".")){let y=d.substring(s.length+1);c[h]=a[y]}else return null}else if(f.type===v.INTERPOLATION){let d=[],y=!0;for(let b of f.parts)if(typeof b=="string")d.push(b);else if(b.type===v.VARIABLE){let m=b.path;if(m===s)d.push(a!=null?String(a):"");else if(m.startsWith(s+".")){let w=m.substring(s.length+1),_=a[w];d.push(_!=null?String(_):"")}else{y=!1;break}}else{y=!1;break}if(!y)return null;c[h]=d.join("")}else return null}l.push(c)}}return l}}}return null},Ui=(e,t)=>{let r=e.body,s=e.itemVar,i=Fi(e,t);if(i!==null)return i;if(r.type===v.OBJECT&&r.properties.length<=5&&!r.whenCondition){for(let l of r.properties)if(l.parsedKey)return null;let n=[],o=!0;for(let l of r.properties){let p=l.key,a=l.value;if(a.type===v.LITERAL)n.push({key:p,type:"literal",value:a.value});else if(a.type===v.VARIABLE){let c=a.path;if(c===s)n.push({key:p,type:"item"});else if(c.startsWith(s+".")){let u=c.substring(s.length+1);if(!u.includes(".")&&!u.includes("["))n.push({key:p,type:"prop",prop:u});else{o=!1;break}}else{o=!1;break}}else if(a.type===v.INTERPOLATION&&a.parts.length===1){let c=a.parts[0];if(c.type===v.VARIABLE){let u=c.path;if(u===s)n.push({key:p,type:"item_string"});else if(u.startsWith(s+".")){let h=u.substring(s.length+1);if(!h.includes(".")&&!h.includes("["))n.push({key:p,type:"prop_string",prop:h});else{o=!1;break}}else{o=!1;break}}else{o=!1;break}}else{o=!1;break}}if(o){let l=new Array(t.length);if(n.length===3&&n[0].type==="prop"&&n[0].key==="id"&&n[1].type==="prop_string"&&n[1].key==="title"&&n[2].type==="prop"&&n[2].key==="completed")for(let p=0;p<t.length;p++){let a=t[p];l[p]={id:a.id,title:a.title!=null?String(a.title):"",completed:a.completed}}else for(let p=0;p<t.length;p++){let a=t[p],c={};for(let u of n)if(u.type==="literal")c[u.key]=u.value;else if(u.type==="item")c[u.key]=a;else if(u.type==="prop")c[u.key]=a[u.prop];else if(u.type==="item_string")c[u.key]=a!=null?String(a):"";else if(u.type==="prop_string"){let h=a[u.prop];c[u.key]=h!=null?String(h):""}l[p]=c}return l}}return null},Ki=(e,t,r,s,i)=>{let n=[],o=e.body;if(o.type===v.OBJECT&&o.fast!==!1){let l=e.itemVar,p=e.indexVar;for(let a=0;a<i.length;a++){let c=i[a],u={},h={...s,[l]:c,...p&&{[p]:a}};h.__paths__||(h.__paths__=s.__paths__||{});let f=e.iterable.path||"";if(s&&s.__paths__&&f){let d=f.split("."),y=d[0];y in s.__paths__&&(f=s.__paths__[y],d.length>1&&(f+="."+d.slice(1).join(".")))}h.__paths__={...h.__paths__,[l]:`${f}[${a}]`,...p&&{[p]:a}};for(let d of o.properties){let y=d.parsedKey?I(d.parsedKey,t,r,h):d.key,b=d.value;if(b.type===v.LITERAL)u[y]=b.value;else if(b.type===v.VARIABLE){let m=b.path;if(m===l)u[y]=c;else if(m===p)u[y]=a;else if(m.startsWith(l+".")){let w=m.substring(l.length+1);!w.includes(".")&&!w.includes("[")?u[y]=c[w]:u[y]=z(m,r,{...s,[l]:c,...p&&{[p]:a}})}else u[y]=z(m,r,{...s,[l]:c,...p&&{[p]:a}})}else if(b.type===v.INTERPOLATION){let m=[];for(let w of b.parts)if(typeof w=="string")m.push(w);else if(w.type===v.VARIABLE){let _=w.path,x;if(_===l)x=c;else if(_===p)x=a;else if(_.startsWith(l+".")){let E=_.substring(l.length+1);!E.includes(".")&&!E.includes("[")?x=c[E]:x=z(_,r,{...s,[l]:c,...p&&{[p]:a}})}else x=z(_,r,{...s,[l]:c,...p&&{[p]:a}});m.push(x!=null?String(x):"")}else{let _={...s,[l]:c,...p&&{[p]:a}},x=I(w,t,r,_);m.push(x!=null?String(x):"")}u[y]=m.join("")}else{let m={...s,[l]:c,...p&&{[p]:a}};u[y]=I(b,t,r,m)}}n.push(u)}return n}return null},zi=(e,t,r)=>{let s=e.body;if(s.type===v.OBJECT&&s.properties.length===1&&s.properties[0].key==="$if item.visible"){let n=s.properties[0].value;if(n.type===v.CONDITIONAL&&n.conditions.length===1&&n.conditions[0].type===v.VARIABLE&&n.conditions[0].path==="item.visible"){let o=n.bodies[0];if(o.type===v.OBJECT&&o.properties.length===2){let l=o.properties[0],p=o.properties[1];if(l.key==="id"&&l.value.type===v.VARIABLE&&l.value.path==="item.id"&&p.key==="$if item.highlighted"&&p.value.type===v.CONDITIONAL){let a=[];for(let c=0;c<t.length;c++){let u=t[c];if(u.visible){let h={id:u.id};u.highlighted?(h.highlight=!0,h.message=`This item is highlighted: ${u.name}`):(h.highlight=!1,h.message=u.name),a.push(h)}}return a}}}}return null},Hi=(e,t,r,s)=>{let i=I(e.iterable,t,r,s);if(!Array.isArray(i)){let a,c=!1;if(e.iterable.type===v.FUNCTION){c=!0;let h=e.iterable.args.map(f=>f.type===v.LITERAL?typeof f.value=="string"?`'${f.value}'`:String(f.value):f.type===v.VARIABLE?f.path:f.type===v.FUNCTION?`${f.name}(...)`:"?").join(", ");a=`${e.iterable.name}(${h})`}else a=e.iterable.path||"undefined";let u=`${e.itemVar}${e.indexVar?`, ${e.indexVar}`:""} in ${a}`;throw Vr(u,i,c)}if(!e.indexVar){let a=zi(e,i,e.itemVar);if(a!==null)return a}if(!e.indexVar){let a=Ui(e,i);if(a!==null)return a}let n=Ki(e,t,r,s,i);if(n!==null)return n;let o=[],l=e.iterable.path||"";if(s&&s.__paths__&&l){let a=l.split("."),c=a[0];c in s.__paths__&&(l=s.__paths__[c],a.length>1&&(l+="."+a.slice(1).join(".")))}let p=!1;e.body.type===v.ARRAY&&(e.body.items.length<=1?p=!1:p=e.body._shouldPreserveArray??=e.body.items.some(a=>a.type===v.OBJECT&&a.properties.some(c=>c.key.startsWith("$if ")||c.key.startsWith("$when "))));for(let a=0;a<i.length;a++){let c=e.indexVar?{...s,[e.itemVar]:i[a],[e.indexVar]:a}:{...s,[e.itemVar]:i[a]};c.__paths__||(c.__paths__=s.__paths__||{}),c.__paths__={...c.__paths__,[e.itemVar]:`${l}[${a}]`},e.indexVar&&(c.__paths__[e.indexVar]=a);let u=I(e.body,t,r,c);if(Array.isArray(u)&&u.length===1&&!p){let h=u[0];o.push(h===void 0?{}:h)}else o.push(u===void 0?{}:u)}return o},Ji=(e,t,r,s)=>{if(e.whenCondition)return null;if(e.properties.length===1){let i=e.properties[0],n=i.parsedKey?I(i.parsedKey,t,r,s):i.key,o=i.value;if(o.type===v.OBJECT&&o.properties.length<=10&&!o.whenCondition){let l={},p={},a=!0;for(let c of o.properties){let u=c.parsedKey?I(c.parsedKey,t,r,s):c.key,h=c.value;if(h.type===v.LITERAL)p[u]=h.value;else if(h.type===v.VARIABLE)p[u]=z(h.path,r,s);else if(h.type===v.INTERPOLATION){let f=[];for(let d of h.parts)if(typeof d=="string")f.push(d);else if(d.type===v.VARIABLE){let y=z(d.path,r,s);f.push(y!=null?String(y):"")}else{a=!1;break}if(!a)break;p[u]=f.join("")}else if(h.type===v.OBJECT&&h.properties.length<=5){let f={};for(let d of h.properties){let y=d.key,b=d.value;if(b.type===v.LITERAL)f[y]=b.value;else if(b.type===v.VARIABLE)f[y]=z(b.path,r,s);else if(b.type===v.INTERPOLATION){let m=[];for(let w of b.parts)if(typeof w=="string")m.push(w);else if(w.type===v.VARIABLE){let _=z(w.path,r,s);m.push(_!=null?String(_):"")}else{a=!1;break}if(!a)break;f[y]=m.join("")}else{a=!1;break}}if(!a)break;p[u]=f}else{a=!1;break}}if(a)return l[n]=p,l}}return null},qi=(e,t,r,s)=>{let i=t.functions||t;if(e.whenCondition&&!xe(e.whenCondition,i,r,s))return;let n=Ji(e,t,r,s);if(n!==null)return n;if(e.fast){let a={};for(let c of e.properties){let u=c.parsedKey?I(c.parsedKey,t,r,s):c.key,h=c.value;if(h.type===v.LITERAL)a[u]=h.value;else if(h.type===v.VARIABLE)a[u]=z(h.path,r,s);else if(h.type===v.INTERPOLATION){let f=[];for(let d of h.parts)if(typeof d=="string")f.push(d);else if(d.type===v.VARIABLE){let y=z(d.path,r,s);f.push(y!=null?String(y):"")}else{let y=I(d,t,r,s);f.push(y!=null?String(y):"")}a[u]=f.join("")}else a[u]=I(h,t,r,s)}return a}let o={},l=null,p=!1;for(let a of e.properties)if(!a.key.startsWith("$if ")&&!a.key.match(/^\$if\s+\w+.*:?$/)&&!a.key.startsWith("$elif")&&!a.key.startsWith("$else")&&!a.key.startsWith("$for ")){p=!0;break}for(let a of e.properties)if(a.key.startsWith("$if ")||a.key.match(/^\$if\s+\w+.*:?$/)){let c=I(a.value,t,r,s);if(!p&&c!==null&&c!==void 0)return Array.isArray(c)&&c.length===1?c[0]:c;typeof c=="object"&&c!==null&&!Array.isArray(c)&&Object.assign(o,c)}else if(a.key.startsWith("$for ")){if(e.properties.length===1)return I(a.value,t,r,s)}else{let c=a.value;if(c&&c.type===v.OBJECT&&c.properties){let u=c.properties.find(h=>h.key.startsWith("$for "));if(u){let h=I(u.value,t,r,s);h!==void 0&&(o[a.key]=h)}else{let h=I(a.value,t,r,s);h!==void 0&&(o[a.key]=h)}}else{let u=a.parsedKey?I(a.parsedKey,t,r,s):a.key,h=I(a.value,t,r,s);h!==void 0&&(o[u]=h)}}return o},Fr={},Yi=(e,t,r,s)=>{let i=[];for(let n of e.items)if(n.type===v.LOOP){let o=I(n,t,r,s);Array.isArray(o)&&n.flatten!==!1?i.push(...o):i.push(o)}else{let o=I(n,t,r,s);o!==Fr&&o!==void 0&&i.push(o)}return i},Gi=(e,t,r,s)=>{let{name:i,data:n,whenCondition:o}=e,l=t.partials||{},p=t.functions||t;if(o&&!xe(o,p,r,s))return;if(!l[i])throw new X(`Partial '${i}' is not defined`);let a=s._partialStack||[];if(a.includes(i))throw new X(`Circular partial reference detected: ${i}`);let c=l[i],u=r,h={...s,_partialStack:[...a,i]};if(s){u={...r};for(let f of Object.keys(s))f.startsWith("_")||(u[f]=s[f])}if(n){let f=I(n,t,r,s);u={...u,...f}}return I(c,t,u,h)},Xi=(e,t,r,s)=>{let{path:i}=e,n=i.split("."),o=n[0],l=n.slice(1);if(!s||!(o in s))throw new X(`Path reference '#{${i}}' refers to '${o}' which is not a loop variable in the current scope`);if(s.__paths__||(s.__paths__={}),!(o in s.__paths__))throw new X(`Path reference '#{${i}}' cannot be resolved - path tracking may not be initialized properly`);let p=s.__paths__[o];if(typeof p=="number"){if(l.length>0)throw new X(`Path reference '#{${i}}' - cannot access properties on index variable '${o}'`);return String(p)}return l.length>0&&(p+="."+l.join(".")),p},wt=Di;var Qi=/\$\{([^}]*)\}/g,Zi=/#\{([^}]*)\}/g,Kr=(e,t={})=>{let r=e.match(/^(\w+)\((.*)\)$/);if(!r)return{isFunction:!1};let[,s,i]=r,n=en(i,t);return{isFunction:!0,type:v.FUNCTION,name:s,args:n}},en=(e,t={})=>e.trim()?tn(e).map(s=>rn(s.trim(),t)):[],tn=e=>{let t=[],r="",s=0,i=!1,n="";for(let o=0;o<e.length;o++){let l=e[o],p=o>0?e[o-1]:"";!i&&(l==='"'||l==="'")?(i=!0,n=l,r+=l):i&&l===n&&p!=="\\"?(i=!1,n="",r+=l):!i&&l==="("?(s++,r+=l):!i&&l===")"?(s--,r+=l):!i&&l===","&&s===0?(t.push(r),r=""):r+=l}return r&&t.push(r),t},rn=(e,t={})=>{if(e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"))return{type:v.LITERAL,value:e.slice(1,-1)};if(/^-?\d+(\.\d+)?$/.test(e))return{type:v.LITERAL,value:parseFloat(e)};if(e==="true")return{type:v.LITERAL,value:!0};if(e==="false")return{type:v.LITERAL,value:!1};if(e==="null")return{type:v.LITERAL,value:null};let r=Kr(e,t);if(r.isFunction)return{type:r.type,name:r.name,args:r.args};let s=e.trim(),i=[{op:" + ",type:"ADD"},{op:" - ",type:"SUBTRACT"}],n=-1,o=null;for(let{op:l,type:p}of i){let a=0;for(;a<s.length;){let c=de(s.substring(a),l);if(c===-1)break;let u=a+c;u>n&&(n=u,o={op:l,type:p}),a=u+l.length}}if(n!==-1)try{return Y(s,t)}catch{return{type:v.VARIABLE,path:s}}return{type:v.VARIABLE,path:s}},zr=/^\w+\(.*\)$/,sn=/\s[+\-*/%]\s|\|\||&&|\?\?|.*\?.*:/,nn=e=>{if(!(!e||e.trim()===""||zr.test(e))&&sn.test(e))throw e.includes("?")&&e.includes(":")?new k(`Complex expressions not supported in variable replacements - consider calculating the value in your data instead. Offending expression: "${e}"`):e.includes("||")||e.includes("&&")||e.includes("??")?new k(`Logical operators not supported in variable replacements - consider calculating the value in your data instead (operators like ||, &&, ?? are not supported). Offending expression: "${e}"`):new k(`Arithmetic expressions not supported in variable replacements - consider calculating '${e}' in your data instead (expressions with +, -, *, /, % are not supported). Offending expression: "${e}"`)},Ur=e=>{let t=e.trim();if(zr.test(t))throw new k(`Functions are not supported in path references - path references can only refer to loop variables. Offending expression: "#{${e}}"`);if(t.includes("["))throw new k(`Array indices not supported in path references - use simple variable names or properties. Offending expression: "#{${e}}"`);if(/[+\-*/%]/.test(t))throw new k(`Arithmetic expressions not supported in path references - path references can only refer to loop variables. Offending expression: "#{${e}}"`);if(/\|\||&&/.test(t))throw new k(`Logical operators not supported in path references - path references can only refer to loop variables. Offending expression: "#{${e}}"`);if(t.includes("?")&&t.includes(":"))throw new k(`Complex expressions not supported in path references - path references can only refer to loop variables. Offending expression: "#{${e}}"`);return{type:v.PATH_REFERENCE,path:t}},Le=(e,t={})=>{let r=e.trim();nn(r);let s=Kr(r,t);if(s.isFunction)return{type:s.type,name:s.name,args:s.args};if(r.includes("[")&&!/[\s+\-*/%|&?:]/.test(r)){let i=0;for(let n of r)n==="["?i++:n==="]"&&i--;if(i!==0)throw new Error("Invalid array index syntax")}return{type:v.VARIABLE,path:r}},_t=(e,t={})=>{let r=e,s=[];(e.includes("\\${")||e.includes("\\#{"))&&(r=e.replace(/\\\\(\$\{[^}]*\})/g,"\\DOUBLE_ESC_VAR$1"),r=r.replace(/\\\\(#\{[^}]*\})/g,"\\DOUBLE_ESC_PATH$1"),r=r.replace(/\\(\$\{[^}]*\})/g,(a,c)=>{let u=`__ESCAPED_${s.length}__`;return s.push(c),u}),r=r.replace(/\\(#\{[^}]*\})/g,(a,c)=>{let u=`__ESCAPED_${s.length}__`;return s.push(c),u}),r=r.replace(/\\DOUBLE_ESC_VAR/g,"\\"),r=r.replace(/\\DOUBLE_ESC_PATH/g,"\\"));let i=[...r.matchAll(Qi)],n=[...r.matchAll(Zi)],o=[...i.map(a=>({match:a,type:"variable"})),...n.map(a=>({match:a,type:"pathref"}))].sort((a,c)=>a.match.index-c.match.index);if(o.length===0){let a=r;for(let c=0;c<s.length;c++)a=a.replace(`__ESCAPED_${c}__`,s[c]);return{type:v.LITERAL,value:a}}if(o.length===1&&o[0].match[0]===r&&s.length===0){let{match:a,type:c}=o[0];try{return c==="variable"?Le(a[1],t):Ur(a[1])}catch(u){if(u.message==="Invalid array index syntax")return{type:v.LITERAL,value:r};throw u}}let l=[],p=0;for(let{match:a,type:c}of o){let[u,h]=a,f=a.index;if(f>p){let d=r.substring(p,f);for(let y=0;y<s.length;y++)d=d.replace(`__ESCAPED_${y}__`,s[y]);d&&l.push(d)}try{let d;c==="variable"?d=Le(h.trim(),t):d=Ur(h.trim()),l.push(d)}catch(d){if(d.message==="Invalid array index syntax")l.push(u);else throw d}p=f+u.length}if(p<r.length){let a=r.substring(p);for(let c=0;c<s.length;c++)a=a.replace(`__ESCAPED_${c}__`,s[c]);a&&l.push(a)}return{type:v.INTERPOLATION,parts:l}};var ue=(e,t)=>typeof e=="string"?_t(e,t):typeof e=="object"&&e!==null?Array.isArray(e)?an(e,t):ln(e,t):{type:v.LITERAL,value:e},on=e=>{let{$each:t,...r}=e;if(typeof t!="string")throw new k("$each value must be a non-empty string");let s=t.trim();if(s==="")throw new k("$each value must be a non-empty string");if(Object.keys(r).length===0)throw new k("Empty $each body not allowed");if(r.$partial!==void 0)throw new k("Cannot use $partial with $each at the same level. Wrap $partial in a parent object if you need conditionals.");return{[`$for ${s}`]:r}},an=(e,t)=>{let r=[],s=!1;for(let i=0;i<e.length;i++){let n=e[i];if(typeof n=="object"&&n!==null&&!Array.isArray(n)){if(n.$each!==void 0)try{let p=on(n),a=Object.keys(p);if(a.length===1&&/^\$for(?::\w+)?\s/.test(a[0])){let c=Hr(a[0],p[a[0]],t,!0);r.push(c),s=!0;continue}}catch(p){throw p instanceof k?p:new k(p.message)}let l=Object.keys(n);if(l.length===1&&/^\$for(?::\w+)?\s/.test(l[0])){let p=Hr(l[0],n[l[0]],t);r.push(p),s=!0;continue}}let o=ue(n,t);r.push(o),(o.type===v.FUNCTION||o.type===v.CONDITIONAL||o.type===v.LOOP||o.type===v.PARTIAL||o.type===v.OBJECT&&!o.fast||o.type===v.ARRAY&&!o.fast)&&(s=!0)}return{type:v.ARRAY,items:r,fast:!s}},ln=(e,t)=>{let r=[],s=!1,i=null,n=Object.entries(e),o=0;if(e.$partial!==void 0){if(typeof e.$partial!="string")throw new k("$partial value must be a string");if(e.$partial.trim()==="")throw new k("$partial value cannot be an empty string");let p=["$if","$elif","$else","$for"],a=[];for(let[m]of n)for(let w of p)if(m===w||m.startsWith(w+" ")||m.startsWith(w+"#")){a.push(w);break}if(a.length>0)throw new k(`Cannot use $partial with ${a.join(", ")} at the same level. Wrap $partial in a parent object if you need conditionals.`);let{$partial:c,$when:u,...h}=e,f={},d=!1;for(let[m,w]of Object.entries(h)){let _=m;(m.startsWith("\\$")||m.startsWith("$$"))&&(_=m.slice(1)),f[_]=w,d=!0}let y=null;if(d&&(y=ue(f,t),y.type===v.OBJECT)){let m=!1;for(let w of y.properties)if(w.value.type===v.VARIABLE||w.value.type===v.INTERPOLATION||w.value.type===v.FUNCTION||w.value.type===v.CONDITIONAL||w.value.type===v.OBJECT&&!w.value.fast||w.value.type===v.ARRAY&&!w.value.fast){m=!0;break}m&&(y.fast=!1)}let b={type:v.PARTIAL,name:c,data:y};if(u!==void 0){let m;if(typeof u=="string"){if(u.trim()==="")throw new k("Empty condition expression after '$when'");m=Y(u,t)}else m={type:v.LITERAL,value:u};b.whenCondition=m}return b}for(let[p,a]of n)if(p==="$when"){if(i!==null)throw new k("Multiple '$when' directives on the same object are not allowed");if(a==null)throw new k("Missing condition expression after '$when'");let c=typeof a=="string"?a:JSON.stringify(a);if(c.trim()==="")throw new k("Empty condition expression after '$when'");i=Y(c,t),s=!0}else if(p.startsWith("$when#")||p.startsWith("$when "))throw new k("'$when' does not support ID syntax or inline conditions - use '$when' as a property");for(;o<n.length;){let[p,a]=n[o];if(p==="$when"){o++;continue}if(p==="$each")throw new k("$each can only be used inside arrays");if(p.startsWith("$if ")||p.match(/^\$if#\w+\s/)||p.match(/^\$if\s+\w+.*:$/)){let c=pn(n,o,t);r.push({key:p,value:c.node}),s=!0,o=c.nextIndex}else if(/^\$for(?::\w+)?\s/.test(p)){let c=p.match(/^\$for(?::(\w+))?\s/)?.[1]||"",u=c?`:${c}`:"";throw new k(`$for loops must be inside arrays - use '- $for${u} item in items:' instead of '$for${u} item in items:'. For cleaner object generation syntax, consider using $each.`)}else{if(p.startsWith("$elif ")||p.startsWith("$else"))throw new k(`'${p.split(" ")[0]}' without matching '$if'`);if(p==="$if"||p==="$if:")throw new k("Missing condition expression after '$if'");{let c=ue(a,t);(c.type===v.FUNCTION||c.type===v.CONDITIONAL||c.type===v.PARTIAL||c.type===v.OBJECT&&!c.fast||c.type===v.ARRAY&&!c.fast)&&(s=!0);let u=_t(p,t),h={key:p,value:c};(u.type!==v.LITERAL||u.value!==p)&&(h.parsedKey=u),r.push(h),o++}}}let l={type:v.OBJECT,properties:r,fast:!s};return i&&(l.whenCondition=i),l},pn=(e,t,r={})=>{let s=[],i=[],n=t,[o,l]=e[n],p=null,a;if(o.startsWith("$if#")){let u=o.match(/^\$if#(\w+)\s+(.+)$/);if(u)p=u[1],a=u[2];else throw new k(`Invalid conditional syntax: ${o}`)}else a=o.substring(4),a.endsWith(":")&&(a=a.slice(0,-1).trim());bt(a);let c=Y(a,r);for(s.push(c),i.push(ue(l,r)),n++;n<e.length;){let[u,h]=e[n],f=!1,d;if(p?u.startsWith(`$elif#${p} `)?(d=u.substring(`$elif#${p} `.length),d.endsWith(":")&&(d=d.slice(0,-1).trim()),f=!0):(u===`$else#${p}`||u===`$else#${p}:`)&&(f=!0,d=null):u.startsWith("$elif ")?(d=u.substring(6),d.endsWith(":")&&(d=d.slice(0,-1).trim()),f=!0):(u==="$else"||u==="$else:")&&(f=!0,d=null),f){if(d===null)s.push(null);else{bt(d);let y=Y(d,r);s.push(y)}if(i.push(ue(h,r)),n++,d===null)break}else break}return{node:{type:v.CONDITIONAL,conditions:s,bodies:i,id:p},nextIndex:n}},Y=(e,t={})=>{if(e=e.trim(),e.startsWith("(")&&e.endsWith(")")){let a=e.slice(1,-1),c=0,u=!0;for(let h=0;h<a.length;h++)if(a[h]==="("?c++:a[h]===")"&&c--,c<0){u=!1;break}if(u&&c===0)return Y(a,t)}let r=de(e,"||");if(r!==-1)return{type:v.BINARY,op:B.OR,left:Y(e.substring(0,r).trim(),t),right:Y(e.substring(r+2).trim(),t)};let s=de(e,"&&");if(s!==-1)return{type:v.BINARY,op:B.AND,left:Y(e.substring(0,s).trim(),t),right:Y(e.substring(s+2).trim(),t)};let i=[{op:">=",type:B.GTE},{op:"<=",type:B.LTE},{op:"==",type:B.EQ},{op:"!=",type:B.NEQ},{op:">",type:B.GT},{op:"<",type:B.LT},{op:" in ",type:B.IN}];for(let{op:a,type:c}of i){let u=de(e,a);if(u!==-1)return{type:v.BINARY,op:c,left:Y(e.substring(0,u).trim(),t),right:Y(e.substring(u+a.length).trim(),t)}}let n=-1,o=null,l=[{op:" + ",type:B.ADD},{op:" - ",type:B.SUBTRACT}];for(let{op:a,type:c}of l){let u=0;for(;u<e.length;){let h=de(e.substring(u),a);if(h===-1)break;let f=u+h;f>n&&(n=f,o={op:a,type:c}),u=f+a.length}}if(n!==-1&&o)return{type:v.BINARY,op:o.type,left:Y(e.substring(0,n).trim(),t),right:Y(e.substring(n+o.op.length).trim(),t)};let p=[" * "," / "," % "];for(let a of p)if(de(e,a)!==-1)throw new k(`Arithmetic operations are not allowed in conditionals: "${a}"`);return e.startsWith("!")?{type:v.UNARY,op:Te.NOT,operand:Y(e.substring(1).trim(),t)}:Jr(e,t)},de=(e,t)=>{let r=0,s=0;for(;s<=e.length-t.length;){if(e[s]==="(")r++;else if(e[s]===")")r--;else if(r===0&&e.substring(s,s+t.length)===t)return s;s++}return-1},cn=e=>{if(e=e.trim(),e==="true")return{type:v.LITERAL,value:!0};if(e==="false")return{type:v.LITERAL,value:!1};if(e==="null")return{type:v.LITERAL,value:null};if(e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"))return{type:v.LITERAL,value:e.slice(1,-1)};if(e==='""'||e==="''")return{type:v.LITERAL,value:""};if(e==="{}")return{type:v.LITERAL,value:{}};if(e==="[]")return{type:v.LITERAL,value:[]};let t=Number(e);return!isNaN(t)&&isFinite(t)?{type:v.LITERAL,value:t}:{type:v.VARIABLE,path:e}},Jr=(e,t)=>{let r=e.trim();if(r.match(/^(\w+)\((.*)\)$/))return Le(r,t);let i=cn(r);if(i.type===v.LITERAL)return i;if(/^[a-zA-Z_$][\w.$]*$/.test(r))return{type:v.VARIABLE,path:r};try{return Le(r,t)}catch(n){if(n.message&&n.message.includes("not supported"))return i;throw n}},un=(e,t=!1)=>{let r=t?"$each":"$for";try{Pr(e)}catch(s){if(s instanceof k&&t){let i=s.message.replace(/\$for/g,"$each");throw new k(i.replace("Parse Error: ",""))}throw s}},Hr=(e,t,r,s=!1)=>{let i=/^\$for(?::(\w+))?\s+(.+)$/,n=e.match(i);if(!n){let b=s?"$each":"$for";throw new k(`Invalid loop syntax (got: '${e.replace("$for",b)}')`)}let o=n[1],l=n[2].trim();un(l,s);let p=l.match(/^(.+?)\s+in\s+(.+)$/);if(!p){let b=s?"$each":"$for";throw new k(`Invalid loop syntax - missing 'in' keyword (got: '${b} ${l}')`)}let a=p[1].trim(),c=p[2].trim(),u,h=null;if(a.includes(",")){let b=a.split(",").map(m=>m.trim());if(b.length!==2)throw new k(`Invalid loop variables: ${a}. Expected format: "item" or "item, index"`);u=b[0],h=b[1]}else u=a;let f=["this","undefined","null","true","false"];if(f.includes(u))throw new k(`Reserved variable name: ${u}`);if(h&&f.includes(h))throw new k(`Reserved variable name: ${h}`);let d=Jr(c,r),y=ue(t,r);return{type:v.LOOP,itemVar:u,indexVar:h,iterable:d,body:y,flatten:o!=="nested"}};var hn=(e,t={})=>{let{functions:r={}}=t;return ue(e,r)},Fe=hn;var xt={};P(xt,{now:()=>dn});var dn=()=>Date.now();var fn=(e,t,r={})=>{let{functions:s={},partials:i={}}=r,n={...xt,...s},o=Fe(e,{functions:n}),l={};for(let[p,a]of Object.entries(i))l[p]=Fe(a,{functions:n});return wt(o,t,{functions:n,partials:l})},At=fn;function qr(e,t){return t.reduce((r,s)=>(s in e&&(r[s]=e[s]),r),{})}var yn=()=>Object.freeze({formValues:{},tooltipState:{open:!1,x:0,y:0,content:""}}),Yr=(e,t,r=void 0)=>{if(!t)return;let s=t.split(/[\[\].]/).filter(n=>n!==""),i=e;for(let n of s){if(i==null||!(n in i))return r;i=i[n]}return i},mn=(e,t,r)=>{let s=t.split(/[\[\].]/).filter(n=>n!=="");t.includes("[")&&t in e&&delete e[t];let i=e;for(let n=0;n<s.length-1;n++){let o=s[n];if(!(o in i)||typeof i[o]!="object"||i[o]===null){let l=s[n+1],p=/^\d+$/.test(l);i[o]=p?[]:{}}i=i[o]}return i[s[s.length-1]]=r,e},gn=["id","class","style","slot"],vn=e=>Object.entries(e).filter(([t])=>!gn.includes(t)).map(([t,r])=>`${t}=${r}`).join(" "),Ue=({props:e})=>{let{form:t={}}=e,{context:r}=e;return r?At(t,r):t},bn=({state:e,props:t,attrs:r})=>{let s=vn(r),i=Ue({state:e,props:t}),n=structuredClone(i.fields||[]);return n.forEach(o=>{let l=Yr(e.formValues,o.name);if(["read-only-text"].includes(o.inputType)&&(o.defaultValue=l),o.inputType==="image"){let p=o.src;o.imageSrc=p&&p.trim()?p:null,o.placeholderText=o.placeholder||"No Image"}if(o.inputType==="waveform"){let p=o.waveformData;o.waveformData=p||null,o.placeholderText=o.placeholder||"No Waveform"}}),{key:r?.key,containerAttrString:s,title:i?.title||"",description:i?.description||"",fields:n,actions:t?.form?.actions||{buttons:[]},formValues:e.formValues,tooltipState:e.tooltipState}},wn=({state:e})=>e,_n=({state:e,props:t})=>{let r=Ue({state:e,props:t});return qr(e.formValues,r.fields.map(s=>s.name))},xn=({state:e},t)=>Yr(e.formValues,t),An=(e,t)=>{e.formValues=t||{}},En=(e,{name:t,value:r,props:s})=>{mn(e.formValues,t,r);let i=Ue({state:e,props:s}),n=qr(e.formValues,i.fields.map(o=>o.name));e.formValues=n},kn=(e,{x:t,y:r,content:s})=>{e.tooltipState={open:!0,x:t,y:r,content:s}},$n=e=>{e.tooltipState={...e.tooltipState,open:!1}};var Gr={elementName:"rtgl-form",viewDataSchema:{type:"object"},propsSchema:{type:"object",properties:{defaultValues:{type:"object"},context:{type:"object"},form:{type:"object",properties:{title:{type:"string"},description:{type:"string"},fields:{type:"array",items:{anyOf:[{type:"object",properties:{name:{type:"string"},label:{type:"string"},description:{type:"string"},inputType:{const:"inputText"},placeholder:{type:"string"},tooltip:{type:"object",properties:{content:{type:"string"}}}},required:["name","label","inputType"],additionalProperties:!1},{type:"object",properties:{name:{type:"string"},label:{type:"string"},description:{type:"string"},inputType:{const:"select"},placeholder:{type:"string"},noClear:{type:"boolean"},addOption:{type:"object",properties:{label:{type:"string"}}},options:{type:"array",items:{type:"object",properties:{label:{type:"string"},value:{type:"any"}},required:["label","value"]}},tooltip:{type:"object",properties:{content:{type:"string"}}}},required:["name","label","inputType","options"],additionalProperties:!1},{type:"object",properties:{name:{type:"string"},label:{type:"string"},description:{type:"string"},inputType:{const:"colorPicker"},value:{type:"string"},tooltip:{type:"object",properties:{content:{type:"string"}}}},required:["name","label","inputType"],additionalProperties:!1},{type:"object",properties:{name:{type:"string"},label:{type:"string"},description:{type:"string"},inputType:{const:"slider"},min:{type:"number"},max:{type:"number"},step:{type:"number"},value:{type:"number"},tooltip:{type:"object",properties:{content:{type:"string"}}}},required:["name","label","inputType"],additionalProperties:!1},{type:"object",properties:{name:{type:"string"},label:{type:"string"},description:{type:"string"},inputType:{const:"slider-input"},min:{type:"number"},max:{type:"number"},step:{type:"number"},value:{type:"number"},tooltip:{type:"object",properties:{content:{type:"string"}}}},required:["name","label","inputType"],additionalProperties:!1},{type:"object",properties:{name:{type:"string"},label:{type:"string"},description:{type:"string"},inputType:{const:"image"},width:{type:"number"},height:{type:"number"},placeholder:{type:"string"},tooltip:{type:"object",properties:{content:{type:"string"}}}},required:["name","label","inputType"],additionalProperties:!1},{type:"object",properties:{name:{type:"string"},label:{type:"string"},description:{type:"string"},inputType:{const:"waveform"},width:{type:"number"},height:{type:"number"},placeholder:{type:"string"},defaultValue:{type:"object"},waveformData:{type:"object"},tooltip:{type:"object",properties:{content:{type:"string"}}}},required:["name","label","inputType"],additionalProperties:!1},{type:"object",properties:{name:{type:"string"},label:{type:"string"},description:{type:"string"},inputType:{const:"popover-input"},placeholder:{type:"string"},tooltip:{type:"object",properties:{content:{type:"string"}}}},required:["name","label","inputType"],additionalProperties:!1}]}},actions:{type:"object",properties:{buttons:{type:"array",items:{type:"object",properties:{id:{type:"string"},content:{type:"string"}},required:["id","content"]}}}}}}}},refs:{"action-*":{eventListeners:{click:{handler:"handleActionClick"}}},"tooltip-icon-*":{eventListeners:{mouseenter:{handler:"handleTooltipMouseEnter"},mouseleave:{handler:"handleTooltipMouseLeave"}}},"field-*":{eventListeners:{"input-change":{handler:"handleInputChange"},"select-change":{handler:"handleSelectChange"},"add-option-selected":{handler:"handleSelectAddOption"},"colorpicker-change":{handler:"handleColorPickerChange"},"slider-change":{handler:"handleSliderChange"},"slider-input-value-change":{handler:"handleSliderInputChange"}}},"image-*":{eventListeners:{click:{handler:"handleImageClick"},contextmenu:{handler:"handleImageClick"}}},"waveform-*":{eventListeners:{click:{handler:"handleWaveformClick"},contextmenu:{handler:"handleWaveformClick"}}}},events:{"form-change":{},"extra-event":{},"action-click":{}},template:{type:9,items:[{type:8,properties:[{key:"rtgl-view w=f p=md g=lg ${containerAttrString}",value:{type:9,items:[{type:8,properties:[{key:"rtgl-view g=sm w=f",value:{type:9,items:[{type:8,properties:[{key:"rtgl-text s=lg",value:{type:1,path:"title"}}],fast:!0},{type:8,properties:[{key:"rtgl-text c=mu-fg",value:{type:1,path:"description"}}],fast:!0}],fast:!0}}],fast:!0},{type:8,properties:[{key:"rtgl-view g=lg w=f",value:{type:9,items:[{type:7,itemVar:"field",indexVar:"i",iterable:{type:1,path:"fields"},body:{type:9,items:[{type:8,properties:[{key:"rtgl-view g=md w=f",value:{type:9,items:[{type:8,properties:[{key:"rtgl-view g=sm",value:{type:9,items:[{type:8,properties:[{key:"rtgl-view d=h g=md av=c",value:{type:9,items:[{type:8,properties:[{key:"rtgl-text",value:{type:1,path:"field.label"}}],fast:!0},{type:8,properties:[{key:"$if field.tooltip",value:{type:6,conditions:[{type:1,path:"field.tooltip"}],bodies:[{type:9,items:[{type:8,properties:[{key:'rtgl-svg#tooltip-icon-${field.name} svg="info" wh=16 c=mu-fg cur=help ml=xs',value:{type:0,value:null},parsedKey:{type:2,parts:["rtgl-svg#tooltip-icon-",{type:1,path:"field.name"},' svg="info" wh=16 c=mu-fg cur=help ml=xs']}}],fast:!0}],fast:!0}],id:null}}],fast:!1}],fast:!1}}],fast:!1},{type:8,properties:[{key:"rtgl-text s=sm c=mu-fg",value:{type:1,path:"field.description"}}],fast:!0}],fast:!1}}],fast:!1},{type:8,properties:[{key:'$if field.inputType == "read-only-text"',value:{type:6,conditions:[{type:4,op:0,left:{type:1,path:"field.inputType"},right:{type:0,value:"read-only-text"}}],bodies:[{type:9,items:[{type:8,properties:[{key:"rtgl-text s=sm",value:{type:1,path:"field.defaultValue"}}],fast:!0}],fast:!0}],id:null}}],fast:!1},{type:8,properties:[{key:'$if field.inputType == "inputText"',value:{type:6,conditions:[{type:4,op:0,left:{type:1,path:"field.inputType"},right:{type:0,value:"inputText"}}],bodies:[{type:9,items:[{type:8,properties:[{key:"rtgl-input#field-${field.name} w=f",value:{type:0,value:null},parsedKey:{type:2,parts:["rtgl-input#field-",{type:1,path:"field.name"}," w=f"]}}],fast:!0}],fast:!0}],id:null}}],fast:!1},{type:8,properties:[{key:'$if field.inputType == "popover-input"',value:{type:6,conditions:[{type:4,op:0,left:{type:1,path:"field.inputType"},right:{type:0,value:"popover-input"}}],bodies:[{type:9,items:[{type:8,properties:[{key:'rtgl-popover-input#field-${field.name} label="${field.label}"',value:{type:0,value:null},parsedKey:{type:2,parts:["rtgl-popover-input#field-",{type:1,path:"field.name"},' label="',{type:1,path:"field.label"},'"']}}],fast:!0}],fast:!0}],id:null}}],fast:!1},{type:8,properties:[{key:'$if field.inputType == "select"',value:{type:6,conditions:[{type:4,op:0,left:{type:1,path:"field.inputType"},right:{type:0,value:"select"}}],bodies:[{type:9,items:[{type:8,properties:[{key:"rtgl-select#field-${field.name} key=${key} w=f .options=fields[${i}].options ?no-clear=fields[${i}].noClear .addOption=fields[${i}].addOption",value:{type:0,value:null},parsedKey:{type:2,parts:["rtgl-select#field-",{type:1,path:"field.name"}," key=",{type:1,path:"key"}," w=f .options=fields[",{type:1,path:"i"},"].options ?no-clear=fields[",{type:1,path:"i"},"].noClear .addOption=fields[",{type:1,path:"i"},"].addOption"]}}],fast:!0}],fast:!0}],id:null}}],fast:!1},{type:8,properties:[{key:'$if field.inputType == "colorPicker"',value:{type:6,conditions:[{type:4,op:0,left:{type:1,path:"field.inputType"},right:{type:0,value:"colorPicker"}}],bodies:[{type:9,items:[{type:8,properties:[{key:"rtgl-color-picker#field-${field.name} key=${key}",value:{type:0,value:null},parsedKey:{type:2,parts:["rtgl-color-picker#field-",{type:1,path:"field.name"}," key=",{type:1,path:"key"}]}}],fast:!0}],fast:!0}],id:null}}],fast:!1},{type:8,properties:[{key:'$if field.inputType == "slider"',value:{type:6,conditions:[{type:4,op:0,left:{type:1,path:"field.inputType"},right:{type:0,value:"slider"}}],bodies:[{type:9,items:[{type:8,properties:[{key:"rtgl-slider#field-${field.name} key=${key} w=f min=${field.min} max=${field.max} step=${field.step}",value:{type:0,value:null},parsedKey:{type:2,parts:["rtgl-slider#field-",{type:1,path:"field.name"}," key=",{type:1,path:"key"}," w=f min=",{type:1,path:"field.min"}," max=",{type:1,path:"field.max"}," step=",{type:1,path:"field.step"}]}}],fast:!0}],fast:!0}],id:null}}],fast:!1},{type:8,properties:[{key:'$if field.inputType == "slider-input"',value:{type:6,conditions:[{type:4,op:0,left:{type:1,path:"field.inputType"},right:{type:0,value:"slider-input"}}],bodies:[{type:9,items:[{type:8,properties:[{key:"rtgl-slider-input#field-${field.name} w=f min=${field.min} max=${field.max} step=${field.step}",value:{type:0,value:null},parsedKey:{type:2,parts:["rtgl-slider-input#field-",{type:1,path:"field.name"}," w=f min=",{type:1,path:"field.min"}," max=",{type:1,path:"field.max"}," step=",{type:1,path:"field.step"}]}}],fast:!0}],fast:!0}],id:null}}],fast:!1},{type:8,properties:[{key:'$if field.inputType == "image" && field.imageSrc',value:{type:6,conditions:[{type:4,op:6,left:{type:4,op:0,left:{type:1,path:"field.inputType"},right:{type:0,value:"image"}},right:{type:1,path:"field.imageSrc"}}],bodies:[{type:9,items:[{type:8,properties:[{key:"rtgl-image#image-${field.name} src=${field.imageSrc} w=${field.width} h=${field.height} cur=p",value:{type:0,value:null},parsedKey:{type:2,parts:["rtgl-image#image-",{type:1,path:"field.name"}," src=",{type:1,path:"field.imageSrc"}," w=",{type:1,path:"field.width"}," h=",{type:1,path:"field.height"}," cur=p"]}}],fast:!0}],fast:!0}],id:null}}],fast:!1},{type:8,properties:[{key:'$if field.inputType == "image" && !field.imageSrc',value:{type:6,conditions:[{type:4,op:6,left:{type:4,op:0,left:{type:1,path:"field.inputType"},right:{type:0,value:"image"}},right:{type:5,op:0,operand:{type:1,path:"field.imageSrc"}}}],bodies:[{type:9,items:[{type:8,properties:[{key:"rtgl-view#field-${field.name} w=${field.width} h=${field.height} bc=ac bw=sm ah=c av=c cur=p p=md",value:{type:9,items:[{type:8,properties:[{key:"rtgl-text c=mu-fg ta=c",value:{type:1,path:"field.placeholderText"}}],fast:!0}],fast:!0},parsedKey:{type:2,parts:["rtgl-view#field-",{type:1,path:"field.name"}," w=",{type:1,path:"field.width"}," h=",{type:1,path:"field.height"}," bc=ac bw=sm ah=c av=c cur=p p=md"]}}],fast:!0}],fast:!0}],id:null}}],fast:!1},{type:8,properties:[{key:'$if field.inputType == "waveform" && field.waveformData',value:{type:6,conditions:[{type:4,op:6,left:{type:4,op:0,left:{type:1,path:"field.inputType"},right:{type:0,value:"waveform"}},right:{type:1,path:"field.waveformData"}}],bodies:[{type:9,items:[{type:8,properties:[{key:"rtgl-waveform#field-${field.name} .waveformData=fields[${i}].waveformData w=${field.width} h=${field.height} cur=p",value:{type:0,value:null},parsedKey:{type:2,parts:["rtgl-waveform#field-",{type:1,path:"field.name"}," .waveformData=fields[",{type:1,path:"i"},"].waveformData w=",{type:1,path:"field.width"}," h=",{type:1,path:"field.height"}," cur=p"]}}],fast:!0}],fast:!0}],id:null}}],fast:!1},{type:8,properties:[{key:'$if field.inputType == "waveform" && !field.waveformData',value:{type:6,conditions:[{type:4,op:6,left:{type:4,op:0,left:{type:1,path:"field.inputType"},right:{type:0,value:"waveform"}},right:{type:5,op:0,operand:{type:1,path:"field.waveformData"}}}],bodies:[{type:9,items:[{type:8,properties:[{key:"rtgl-view#field-${field.name} w=${field.width} h=${field.height} bc=ac bw=sm ah=c av=c cur=p p=md",value:{type:9,items:[{type:8,properties:[{key:"rtgl-text c=mu-fg ta=c",value:{type:1,path:"field.placeholder"}}],fast:!0}],fast:!0},parsedKey:{type:2,parts:["rtgl-view#field-",{type:1,path:"field.name"}," w=",{type:1,path:"field.width"}," h=",{type:1,path:"field.height"}," bc=ac bw=sm ah=c av=c cur=p p=md"]}}],fast:!0}],fast:!0}],id:null}}],fast:!1},{type:8,properties:[{key:'$if field.inputType == "slot"',value:{type:6,conditions:[{type:4,op:0,left:{type:1,path:"field.inputType"},right:{type:0,value:"slot"}}],bodies:[{type:9,items:[{type:8,properties:[{key:'slot#field-${field.slotName} name=${field.slot} style="display: contents;"',value:{type:0,value:null},parsedKey:{type:2,parts:["slot#field-",{type:1,path:"field.slotName"}," name=",{type:1,path:"field.slot"},' style="display: contents;"']}}],fast:!0}],fast:!0}],id:null}}],fast:!1}],fast:!1}}],fast:!1}],fast:!1}}],fast:!1}}],fast:!1},{type:8,properties:[{key:"rtgl-view g=sm w=f",value:{type:9,items:[{type:8,properties:[{key:"rtgl-view d=h ah=e g=sm w=f",value:{type:9,items:[{type:7,itemVar:"button",indexVar:"i",iterable:{type:1,path:"actions.buttons"},body:{type:9,items:[{type:8,properties:[{key:"rtgl-button#action-${button.id}",value:{type:1,path:"button.content"},parsedKey:{type:2,parts:["rtgl-button#action-",{type:1,path:"button.id"}]}}],fast:!0}],fast:!0}}],fast:!1}}],fast:!1}],fast:!1}}],fast:!1},{type:8,properties:[{key:'rtgl-tooltip ?open=${tooltipState.open} x=${tooltipState.x} y=${tooltipState.y} placement="top" content="${tooltipState.content}"',value:{type:0,value:null},parsedKey:{type:2,parts:["rtgl-tooltip ?open=",{type:1,path:"tooltipState.open"}," x=",{type:1,path:"tooltipState.x"}," y=",{type:1,path:"tooltipState.y"},' placement="top" content="',{type:1,path:"tooltipState.content"},'"']}}],fast:!0}],fast:!1},parsedKey:{type:2,parts:["rtgl-view w=f p=md g=lg ",{type:1,path:"containerAttrString"}]}}],fast:!1}],fast:!1}};var kt={};P(kt,{closeAll:()=>Pn,handleCancel:()=>On,handleConfirm:()=>Cn,handleDialogClose:()=>Sn,handleDropdownClose:()=>In,handleDropdownItemClick:()=>Tn,showAlert:()=>Ln,showConfirm:()=>Rn,showDropdownMenu:()=>Nn});var Sn=(e,t)=>{let{store:r,render:s}=e;r.closeAll(),s()},Cn=(e,t)=>{let{store:r,render:s,globalUI:i}=e;r.closeAll(),s(),i.emit("event",!0)},On=(e,t)=>{let{store:r,render:s,globalUI:i}=e;r.closeAll(),s(),i.emit("event",!1)},In=(e,t)=>{let{store:r,render:s,globalUI:i}=e;r.closeAll(),s(),i.emit("event",null)},Tn=(e,t)=>{let{store:r,render:s,globalUI:i}=e,n=t._event,{index:o,item:l}=n.detail;r.closeAll(),s(),i.emit("event",{index:o,item:l})},Ln=(e,t)=>{let{store:r,render:s}=e,i=t;r.selectIsOpen()&&(r.closeAll(),s()),r.setAlertConfig(i),s()},Rn=async(e,t)=>{let{store:r,render:s,globalUI:i}=e,n=t;return r.selectIsOpen()&&(r.closeAll(),s()),r.setConfirmConfig(n),s(),new Promise(o=>{i.once("event",l=>{o(l)})})},Nn=async(e,t)=>{let{store:r,render:s,globalUI:i}=e,n=t;return r.selectIsOpen()&&(r.closeAll(),s()),r.setDropdownConfig(n),s(),new Promise(o=>{i.once("event",l=>{o(l)})})},Pn=e=>{let{store:t,render:r}=e;t.selectIsOpen()&&(t.closeAll(),r())};var $t={};P($t,{closeAll:()=>Wn,createInitialState:()=>Vn,selectConfig:()=>Mn,selectDropdownConfig:()=>Fn,selectIsOpen:()=>Kn,selectUiType:()=>Un,selectViewData:()=>zn,setAlertConfig:()=>Dn,setConfirmConfig:()=>jn,setDropdownConfig:()=>Bn});var Vn=()=>Object.freeze({isOpen:!1,uiType:"dialog",config:{status:void 0,title:"",message:"",confirmText:"OK",cancelText:"Cancel",mode:"alert"},dropdownConfig:{items:[],x:0,y:0,placement:"bottom-start"}}),Dn=(e,t)=>{if(!t.message)throw new Error("message is required for showAlert");e.config={status:t.status||void 0,title:t.title||"",message:t.message,confirmText:t.confirmText||"OK",cancelText:"",mode:"alert"},e.uiType="dialog",e.isOpen=!0},jn=(e,t)=>{if(!t.message)throw new Error("message is required for showConfirm");e.config={status:t.status||void 0,title:t.title||"",message:t.message,confirmText:t.confirmText||"Yes",cancelText:t.cancelText||"Cancel",mode:"confirm"},e.uiType="dialog",e.isOpen=!0},Bn=(e,t)=>{if(!t.items||!Array.isArray(t.items))throw new Error("items array is required for showDropdown");e.dropdownConfig={items:t.items,x:t.x||0,y:t.y||0,placement:t.placement||"bottom-start"},e.uiType="dropdown",e.isOpen=!0},Wn=e=>{e.isOpen=!1,e.uiType="dialog"},Mn=({state:e})=>e.config,Fn=({state:e})=>e.dropdownConfig,Un=({state:e})=>e.uiType,Kn=({state:e})=>e.isOpen,zn=({state:e})=>({isOpen:e.isOpen,uiType:e.uiType,config:e.config,dropdownConfig:{items:e.dropdownConfig?.items||[],x:e.dropdownConfig?.x||0,y:e.dropdownConfig?.y||0,placement:e.dropdownConfig?.placement||"bottom-start"},isDialogOpen:e.isOpen&&e.uiType==="dialog",isDropdownOpen:e.isOpen&&e.uiType==="dropdown"});var Xr={elementName:"rtgl-global-ui",viewDataSchema:{type:"object",properties:{isOpen:{type:"boolean"},uiType:{type:"string"},config:{type:"object",properties:{status:{type:"string"},title:{type:"string"},message:{type:"string"},confirmText:{type:"string"},cancelText:{type:"string"},mode:{type:"string"}}},dropdownConfig:{type:"object",properties:{items:{type:"array"},x:{type:"number"},y:{type:"number"},placement:{type:"string"}}}}},refs:{dialog:{eventListeners:{close:{handler:"handleDialogClose"}}},"confirm-button":{eventListeners:{click:{handler:"handleConfirm"}}},"cancel-button":{eventListeners:{click:{handler:"handleCancel"}}},"dropdown-menu":{eventListeners:{close:{handler:"handleDropdownClose"},"click-item":{handler:"handleDropdownItemClick"}}}},template:{type:9,items:[{type:8,properties:[{key:"rtgl-dialog#dialog ?open=${isDialogOpen} s=sm",value:{type:9,items:[{type:8,properties:[{key:"rtgl-view slot=content g=lg p=lg",value:{type:9,items:[{type:8,properties:[{key:"rtgl-view d=h g=md",value:{type:9,items:[{type:8,properties:[{key:"rtgl-view d=h ah=c av=c g=md",value:{type:0,value:null}}],fast:!0},{type:8,properties:[{key:"rtgl-view g=md",value:{type:9,items:[{type:8,properties:[{key:"rtgl-view h=24 av=c",value:{type:9,items:[{type:8,properties:[{key:"rtgl-text fw=600",value:{type:1,path:"config.title"}}],fast:!0}],fast:!0}}],fast:!0},{type:8,properties:[{key:"rtgl-text",value:{type:1,path:"config.message"}}],fast:!0}],fast:!0}}],fast:!0}],fast:!0}}],fast:!0},{type:8,properties:[{key:"rtgl-view d=h g=md mt=lg w=f ah=e",value:{type:9,items:[{type:8,properties:[{key:"$if config.mode == 'confirm'",value:{type:6,conditions:[{type:4,op:0,left:{type:1,path:"config.mode"},right:{type:0,value:"confirm"}}],bodies:[{type:9,items:[{type:8,properties:[{key:"rtgl-button#cancel-button v=se",value:{type:1,path:"config.cancelText"}}],fast:!0}],fast:!0}],id:null}}],fast:!1},{type:8,properties:[{key:"rtgl-button#confirm-button v=pr",value:{type:1,path:"config.confirmText"}}],fast:!0}],fast:!1}}],fast:!1}],fast:!1}}],fast:!1}],fast:!1},parsedKey:{type:2,parts:["rtgl-dialog#dialog ?open=",{type:1,path:"isDialogOpen"}," s=sm"]}}],fast:!1},{type:8,properties:[{key:"rtgl-dropdown-menu#dropdown-menu ?open=${isDropdownOpen} x=${dropdownConfig.x} y=${dropdownConfig.y} placement=${dropdownConfig.placement} .items=dropdownConfig.items key=dropdown-${isDropdownOpen}",value:{type:0,value:null},parsedKey:{type:2,parts:["rtgl-dropdown-menu#dropdown-menu ?open=",{type:1,path:"isDropdownOpen"}," x=",{type:1,path:"dropdownConfig.x"}," y=",{type:1,path:"dropdownConfig.y"}," placement=",{type:1,path:"dropdownConfig.placement"}," .items=dropdownConfig.items key=dropdown-",{type:1,path:"isDropdownOpen"}]}}],fast:!0}],fast:!1}};var St={};P(St,{handleClickStart:()=>Hn});var Hn=(e,t)=>{let{dispatchEvent:r,store:s}=e,i=t._event;console.log("handle click start",s.selectPath()),r(new CustomEvent("clickStart",{detail:{path:s.selectPath()}}))};var Ct={};P(Ct,{createInitialState:()=>Jn,selectPath:()=>Xn,selectViewData:()=>Gn,setState:()=>Qn});var Jn=()=>Object.freeze({}),qn=["id","class","style","slot"],Yn=e=>Object.entries(e).filter(([t])=>!qn.includes(t)).map(([t,r])=>`${t}=${r}`).join(" "),Gn=({state:e,props:t,attrs:r})=>{console.log("attrs",{attrs:r,entries:Object.entries(r)});let s=r.start?JSON.parse(decodeURIComponent(r.start)):t.start;return{containerAttrString:Yn(r),start:s||{label:"",image:{src:"",width:32,height:32,alt:""}}}},Xn=({props:e})=>e.start.path,Qn=e=>{};var Qr={elementName:"rtgl-navbar",viewDataSchema:{type:"object",properties:{containerAttrString:{type:"string"},start:{type:"object",properties:{label:{type:"string"},href:{type:"string"},image:{type:"object",properties:{src:{type:"string"}}},hasImage:{type:"boolean"},hasHref:{type:"boolean"}}}}},propsSchema:{type:"object",properties:{start:{type:"object",properties:{label:{type:"string"},href:{type:"string"},image:{type:"object",properties:{src:{type:"string"}}}}}}},refs:{start:{eventListeners:{click:{handler:"handleClickStart"}}}},events:{clickStart:{type:"object",properties:{path:{type:"string"}}}},anchors:[[{"rtgl-text s=lg":"${start.label}"},{"$if start.image && start.image.src":[{"rtgl-image w=${start.image.width} h=${start.image.height} src=${start.image.src} alt=${start.image.alt}":null}]}]],template:{type:9,items:[{type:8,properties:[{key:"rtgl-view bgc=bg d=h h=48 av=c w=f ${containerAttrString}",value:{type:9,items:[{type:8,properties:[{key:"$if start.href",value:{type:6,conditions:[{type:1,path:"start.href"},{type:1,path:"start.path"},null],bodies:[{type:9,items:[{type:8,properties:[{key:"a href=${start.href}",value:{type:9,items:[{type:8,properties:[{key:"rtgl-view d=h av=c g=lg g=md",value:{type:9,items:[{type:9,items:[{type:8,properties:[{key:"rtgl-text s=lg",value:{type:1,path:"start.label"}}],fast:!0},{type:8,properties:[{key:"$if start.image && start.image.src",value:{type:6,conditions:[{type:4,op:6,left:{type:1,path:"start.image"},right:{type:1,path:"start.image.src"}}],bodies:[{type:9,items:[{type:8,properties:[{key:"rtgl-image w=${start.image.width} h=${start.image.height} src=${start.image.src} alt=${start.image.alt}",value:{type:0,value:null},parsedKey:{type:2,parts:["rtgl-image w=",{type:1,path:"start.image.width"}," h=",{type:1,path:"start.image.height"}," src=",{type:1,path:"start.image.src"}," alt=",{type:1,path:"start.image.alt"}]}}],fast:!0}],fast:!0}],id:null}}],fast:!1}],fast:!1}],fast:!1}}],fast:!1}],fast:!1},parsedKey:{type:2,parts:["a href=",{type:1,path:"start.href"}]}}],fast:!1}],fast:!1},{type:9,items:[{type:8,properties:[{key:"rtgl-view#start d=h av=c g=lg g=md cur=p",value:{type:9,items:[{type:9,items:[{type:8,properties:[{key:"rtgl-text s=lg",value:{type:1,path:"start.label"}}],fast:!0},{type:8,properties:[{key:"$if start.image && start.image.src",value:{type:6,conditions:[{type:4,op:6,left:{type:1,path:"start.image"},right:{type:1,path:"start.image.src"}}],bodies:[{type:9,items:[{type:8,properties:[{key:"rtgl-image w=${start.image.width} h=${start.image.height} src=${start.image.src} alt=${start.image.alt}",value:{type:0,value:null},parsedKey:{type:2,parts:["rtgl-image w=",{type:1,path:"start.image.width"}," h=",{type:1,path:"start.image.height"}," src=",{type:1,path:"start.image.src"}," alt=",{type:1,path:"start.image.alt"}]}}],fast:!0}],fast:!0}],id:null}}],fast:!1}],fast:!1}],fast:!1}}],fast:!1}],fast:!1},{type:9,items:[{type:8,properties:[{key:"rtgl-view d=h av=c g=lg g=md",value:{type:9,items:[{type:9,items:[{type:8,properties:[{key:"rtgl-text s=lg",value:{type:1,path:"start.label"}}],fast:!0},{type:8,properties:[{key:"$if start.image && start.image.src",value:{type:6,conditions:[{type:4,op:6,left:{type:1,path:"start.image"},right:{type:1,path:"start.image.src"}}],bodies:[{type:9,items:[{type:8,properties:[{key:"rtgl-image w=${start.image.width} h=${start.image.height} src=${start.image.src} alt=${start.image.alt}",value:{type:0,value:null},parsedKey:{type:2,parts:["rtgl-image w=",{type:1,path:"start.image.width"}," h=",{type:1,path:"start.image.height"}," src=",{type:1,path:"start.image.src"}," alt=",{type:1,path:"start.image.alt"}]}}],fast:!0}],fast:!0}],id:null}}],fast:!1}],fast:!1}],fast:!1}}],fast:!1}],fast:!1}],id:null}}],fast:!1},{type:8,properties:[{key:"rtgl-view flex=1",value:{type:0,value:null}}],fast:!0},{type:8,properties:[{key:"rtgl-view d=h av=c g=lg",value:{type:9,items:[{type:8,properties:[{key:"slot name=right",value:{type:0,value:null}}],fast:!0}],fast:!0}}],fast:!0}],fast:!1},parsedKey:{type:2,parts:["rtgl-view bgc=bg d=h h=48 av=c w=f ",{type:1,path:"containerAttrString"}]}}],fast:!1}],fast:!1}};var Ot={};P(Ot,{handleBeforeMount:()=>eo});var Zr=(e,t,r)=>{let{store:s,render:i}=r,n,o=-1/0;if(e.forEach(l=>{let p=l.getBoundingClientRect();p.top<=t&&p.top>o&&(o=p.top,n=l.id)}),!n){let l=1/0;e.forEach(p=>{let a=p.getBoundingClientRect();a.top>t&&a.top<l&&(l=a.top,n=p.id)})}n&&n!==s.selectCurrentId()&&(s.setCurrentId(n),i())},Zn=(e,t,r,s)=>{let{store:i,render:n}=s,o=e.querySelectorAll("h1[id], h2[id], h3[id], h4[id], rtgl-text[id]"),l=Array.from(o),p=l.map(c=>{let u=1,h=c.tagName.toLowerCase();return h==="h1"?u=1:h==="h2"?u=2:h==="h3"?u=3:h==="h4"?u=4:h==="rtgl-text"&&(u=parseInt(c.getAttribute("data-level")||"1",10)),{id:c.id,href:`#${c.id}`,title:c.textContent,level:u}});i.setItems(p),Zr(l,r,s),n();let a=Zr.bind(void 0,l,r,s);return t.addEventListener("scroll",a,{passive:!0}),()=>{t.removeEventListener("scroll",a)}},eo=e=>{let{attrs:t}=e;requestAnimationFrame(()=>{let r=document.getElementById(t["target-id"]),s=window;t["scroll-container-id"]&&(s=document.getElementById(t["scroll-container-id"])||window);let i=parseInt(t["offset-top"]||"100",10),n=Zn(r,s,i,e);return()=>{n()}})};var It={};P(It,{createInitialState:()=>to,selectCurrentId:()=>io,selectState:()=>so,selectViewData:()=>ro,setContentContainer:()=>ao,setCurrentId:()=>oo,setItems:()=>no});var to=()=>Object.freeze({items:[],currentId:null,contentContainer:null}),ro=({state:e})=>{let r=((s,i)=>{let n=new Set,o=s.findIndex(p=>p.id===i);if(o===-1)return n;let l=s[o].level;for(let p=o-1;p>=0;p--)if(s[p].level<l){let a=s[p].level;n.add(s[p].id);for(let c=p-1;c>=0;c--)s[c].level<a&&(n.add(s[c].id),a=s[c].level);break}return n})(e.items,e.currentId);return{items:e.items.map(s=>{let i={1:"0",2:"12px",3:"24px",4:"32px"},n=s.id===e.currentId,o=r.has(s.id),l=n||o;return{...s,c:l?"fg":"mu-fg",ml:i[s.level]||"",bc:l?"fg":"mu-fg"}}),currentId:e.currentId}},so=({state:e})=>e,io=({state:e})=>e.currentId,no=(e,t)=>{e.items=t},oo=(e,t)=>{e.currentId=t},ao=(e,t)=>{e.contentContainer=t};var es={elementName:"rtgl-page-outline",viewDataSchema:{type:"object",properties:{items:{type:"array",items:{type:"object",properties:{slug:{type:"string"},title:{type:"string"}}}},selectedSlug:{type:"string",nullable:!0}}},propsSchema:{type:"object",properties:{}},refs:{},events:{onItemClick:{type:"object"}},template:{type:9,items:[{type:8,properties:[{key:"rtgl-view h=f w=272 pr=md",value:{type:9,items:[{type:8,properties:[{key:"rtgl-view w=f mt=xl",value:{type:9,items:[{type:7,itemVar:"item",indexVar:"i",iterable:{type:1,path:"items"},body:{type:9,items:[{type:8,properties:[{key:'rtgl-view d=h bwl=xs bc="${item.bc}" pv=sm av=c href=${item.href} pl=md',value:{type:9,items:[{type:8,properties:[{key:"rtgl-view w=${item.ml}",value:{type:0,value:null},parsedKey:{type:2,parts:["rtgl-view w=",{type:1,path:"item.ml"}]}}],fast:!0},{type:8,properties:[{key:"rtgl-text s=sm c=${item.c} h-c=fg",value:{type:1,path:"item.title"},parsedKey:{type:2,parts:["rtgl-text s=sm c=",{type:1,path:"item.c"}," h-c=fg"]}}],fast:!0}],fast:!0},parsedKey:{type:2,parts:['rtgl-view d=h bwl=xs bc="',{type:1,path:"item.bc"},'" pv=sm av=c href=',{type:1,path:"item.href"}," pl=md"]}}],fast:!0}],fast:!0}}],fast:!1}}],fast:!1}],fast:!1}}],fast:!1}],fast:!1}};var Tt={};P(Tt,{handleBeforeMount:()=>lo,handleInputChange:()=>ho,handleInputKeydown:()=>yo,handleOnUpdate:()=>po,handlePopoverClose:()=>uo,handleSubmitClick:()=>fo,handleTextClick:()=>co});var lo=e=>{let{store:t,attrs:r}=e;r.value!==void 0&&t.setValue(r.value||"")},po=(e,t)=>{let{oldAttrs:r,newAttrs:s}=t,{store:i,render:n}=e;if(r?.value!==s?.value){let o=s?.value??"";i.setValue(o)}n()},co=(e,t)=>{let{store:r,render:s,getRefIds:i,attrs:n}=e,o=t._event,l=r.selectValue();r.setTempValue(l),r.openPopover({position:{x:o.currentTarget.getBoundingClientRect().left,y:o.currentTarget.getBoundingClientRect().bottom}});let{input:p}=i();p.elm.value=l,s(),n["auto-focus"]&&setTimeout(()=>{p.elm.focus()},50)},uo=(e,t)=>{let{store:r,render:s}=e;r.closePopover(),s()},ho=(e,t)=>{let{store:r,render:s,dispatchEvent:i}=e,o=t._event.detail.value;r.setTempValue(o),i(new CustomEvent("temp-input-change",{detail:{value:o},bubbles:!0})),s()},fo=e=>{let{store:t,render:r,dispatchEvent:s,getRefIds:i}=e,{input:n}=i(),o=n.elm.value;t.setValue(o),t.closePopover(),s(new CustomEvent("input-change",{detail:{value:o},bubbles:!0})),r()},yo=(e,t)=>{let{store:r,render:s,dispatchEvent:i,getRefIds:n}=e,o=t._event;if(o.key==="Enter"){let{input:l}=n(),p=l.elm.value;r.closePopover(),i(new CustomEvent("input-change",{detail:{value:p},bubbles:!0})),s()}else o.key==="Escape"&&(r.closePopover(),s())};var Lt={};P(Lt,{closePopover:()=>wo,createInitialState:()=>mo,openPopover:()=>bo,selectValue:()=>xo,selectViewData:()=>go,setTempValue:()=>vo,setValue:()=>_o});var mo=()=>Object.freeze({isOpen:!1,position:{x:0,y:0},value:"",tempValue:""}),go=({attrs:e,state:t})=>{let r=t.value||"-";return{isOpen:t.isOpen,position:t.position,value:r,tempValue:t.tempValue,placeholder:e.placeholder??"",label:e.label}},vo=(e,t)=>{e.tempValue=t},bo=(e,t)=>{let{position:r}=t;e.position=r,e.isOpen=!0,e.hasUnsavedChanges=!1},wo=e=>{e.isOpen=!1,e.tempValue=""},_o=(e,t)=>{e.value=t},xo=({state:e})=>e.value;var ts={elementName:"rtgl-popover-input",viewDataSchema:{type:"object"},attrsSchema:{type:"object",properties:{value:{type:"string"},placeholder:{type:"string"}}},refs:{"text-display":{eventListeners:{click:{handler:"handleTextClick"}}},popover:{eventListeners:{close:{handler:"handlePopoverClose"}}},input:{eventListeners:{"input-change":{handler:"handleInputChange"},keydown:{handler:"handleInputKeydown"}}},submit:{eventListeners:{click:{handler:"handleSubmitClick"}}}},events:{"input-change":{}},template:{type:9,items:[{type:8,properties:[{key:"rtgl-view#text-display w=f cur=p",value:{type:9,items:[{type:8,properties:[{key:"rtgl-text",value:{type:1,path:"value"}}],fast:!0}],fast:!0}}],fast:!0},{type:8,properties:[{key:"rtgl-popover#popover ?open=${isOpen} x=${position.x} y=${position.y}",value:{type:9,items:[{type:8,properties:[{key:"rtgl-view g=md w=240 slot=content bgc=background br=md",value:{type:9,items:[{type:8,properties:[{key:"rtgl-text",value:{type:1,path:"label"}}],fast:!0},{type:8,properties:[{key:"rtgl-input#input w=f placeholder=${placeholder}",value:{type:0,value:null},parsedKey:{type:2,parts:["rtgl-input#input w=f placeholder=",{type:1,path:"placeholder"}]}}],fast:!0},{type:8,properties:[{key:"rtgl-view w=f ah=e",value:{type:9,items:[{type:8,properties:[{key:"rtgl-button#submit",value:{type:0,value:"Submit"}}],fast:!0}],fast:!0}}],fast:!0}],fast:!0}}],fast:!0}],fast:!0},parsedKey:{type:2,parts:["rtgl-popover#popover ?open=",{type:1,path:"isOpen"}," x=",{type:1,path:"position.x"}," y=",{type:1,path:"position.y"}]}}],fast:!0}],fast:!0}};var Rt={};P(Rt,{handleAddOptionClick:()=>To,handleAddOptionMouseEnter:()=>Lo,handleAddOptionMouseLeave:()=>Ro,handleBeforeMount:()=>Ao,handleButtonClick:()=>ko,handleClearClick:()=>Io,handleClickOptionsPopoverOverlay:()=>$o,handleOnUpdate:()=>Eo,handleOptionClick:()=>So,handleOptionMouseEnter:()=>Co,handleOptionMouseLeave:()=>Oo});var Ao=e=>{let{store:t,props:r,render:s}=e;if(r.selectedValue!==null&&r.selectedValue!==void 0&&r.options){let i=r.options.find(n=>ce(n.value,r.selectedValue));i&&(t.updateSelectedValue({value:i?.value}),s())}},Eo=(e,t)=>{let{oldAttrs:r,newAttrs:s,oldProps:i,newProps:n}=t,{store:o,props:l,render:p}=e;if(r?.key!==s?.key&&s?.key){o.resetSelection();let a=n?.selectedValue||l?.selectedValue,c=n?.options||l?.options;if(a!=null&&c){let u=c.find(h=>ce(h.value,a));u&&o.updateSelectedValue({value:u.value})}p()}else i.selectedValue!==n.selectedValue&&(o.updateSelectedValue(n.selectedValue),p())},ko=(e,t)=>{let{store:r,render:s,getRefIds:i,props:n}=e;t._event.stopPropagation();let l=i()["select-button"].elm,p=l.firstElementChild,a=p?p.getBoundingClientRect():l.getBoundingClientRect(),c=r.selectSelectedValue(),u=c!==null?c:n.selectedValue,h=null;u!=null&&n.options&&(h=n.options.findIndex(f=>ce(f.value,u)),h===-1&&(h=null)),r.openOptionsPopover({position:{y:a.bottom+12,x:a.left-24},selectedIndex:h}),s()},$o=e=>{let{store:t,render:r}=e;t.closeOptionsPopover(),r()},So=(e,t)=>{let{render:r,dispatchEvent:s,props:i,store:n}=e,o=t._event;o.stopPropagation();let l=o.currentTarget.id.replace("option-",""),p=i.options[l];n.updateSelectedValue({value:p?.value}),i.onChange&&typeof i.onChange=="function"&&i.onChange(p.value),s(new CustomEvent("option-selected",{detail:{value:p.value,label:p.label},bubbles:!0})),s(new CustomEvent("select-change",{detail:{selectedValue:p.value},bubbles:!0})),r()},Co=(e,t)=>{let{store:r,render:s}=e,i=t._event,n=parseInt(i.currentTarget.id.replace("option-",""));r.setHoveredOption(n),s()},Oo=(e,t)=>{let{store:r,render:s}=e;r.clearHoveredOption(),s()},Io=(e,t)=>{let{store:r,render:s,dispatchEvent:i,props:n}=e;t._event.stopPropagation(),r.clearSelectedValue(),n.onChange&&typeof n.onChange=="function"&&n.onChange(void 0),i(new CustomEvent("option-selected",{detail:{value:void 0,label:void 0},bubbles:!0})),i(new CustomEvent("select-change",{detail:{selectedValue:void 0},bubbles:!0})),s()},To=(e,t)=>{let{store:r,render:s,dispatchEvent:i}=e,{_event:n}=t;n.stopPropagation(),r.closeOptionsPopover(),i(new CustomEvent("add-option-selected",{bubbles:!0})),s()},Lo=(e,t)=>{let{store:r,render:s}=e;r.setHoveredAddOption(!0),s()},Ro=(e,t)=>{let{store:r,render:s}=e;r.setHoveredAddOption(!1),s()};var Nt={};P(Nt,{clearHoveredOption:()=>zo,clearSelectedValue:()=>Ho,closeOptionsPopover:()=>Mo,createInitialState:()=>Vo,openOptionsPopover:()=>Wo,resetSelection:()=>Uo,selectSelectedValue:()=>Bo,selectState:()=>jo,selectViewData:()=>Do,setHoveredAddOption:()=>Jo,setHoveredOption:()=>Ko,updateSelectedValue:()=>Fo});var No=["id","class","style","slot","placeholder","selectedValue","selected-value","onChange","on-change","options"],Po=e=>Object.entries(e||{}).filter(([t])=>!No.includes(t)).map(([t,r])=>`${t}=${r}`).join(" "),Vo=()=>Object.freeze({isOpen:!1,position:{x:0,y:0},selectedValue:null,hoveredOptionId:null,hoveredAddOption:!1}),Do=({state:e,props:t,attrs:r})=>{let s=Po(r),i=e.selectedValue!==null?e.selectedValue:t.selectedValue,n=r.placeholder||"Select an option",o=!0;if(i!=null&&t.options){let p=t.options.find(a=>ce(a.value,i));p&&(n=p.label,o=!1)}let l=(t.options||[]).map((p,a)=>{let c=ce(p.value,i),u=e.hoveredOptionId===a;return{...p,isSelected:c,bgc:u?"ac":c?"mu":""}});return{containerAttrString:s,isOpen:e.isOpen,position:e.position,options:l,selectedValue:i,selectedLabel:n,selectedLabelColor:o?"mu-fg":"fg",hasValue:i!=null,showClear:!r["no-clear"]&&!t["no-clear"]&&i!=null,showAddOption:!!t.addOption,addOptionLabel:t.addOption?.label?`+ ${t.addOption.label}`:"+ Add",addOptionBgc:e.hoveredAddOption?"ac":""}},jo=({state:e})=>e,Bo=({state:e})=>e.selectedValue,Wo=(e,t)=>{let{position:r,selectedIndex:s}=t;e.position=r,e.isOpen=!0,s!=null&&(e.hoveredOptionId=s)},Mo=e=>{e.isOpen=!1},Fo=(e,t)=>{e.selectedValue=t.value,e.isOpen=!1},Uo=e=>{e.selectedValue=void 0},Ko=(e,t)=>{e.hoveredOptionId=t},zo=e=>{e.hoveredOptionId=null},Ho=e=>{e.selectedValue=void 0},Jo=(e,t)=>{e.hoveredAddOption=t};var rs={elementName:"rtgl-select",viewDataSchema:{type:"object"},attrsSchema:{type:"object",properties:{placeholder:{type:"string"}}},propsSchema:{type:"object",properties:{options:{type:"array",items:{type:"object",properties:{label:{type:"string"},value:{type:"any"}}}},selectedValue:{type:"any"},onChange:{type:"function"},"no-clear":{type:"boolean"},addOption:{type:"object",properties:{label:{type:"string"}}}}},refs:{"select-button":{eventListeners:{click:{handler:"handleButtonClick"}}},"clear-button":{eventListeners:{click:{handler:"handleClearClick"}}},popover:{eventListeners:{close:{handler:"handleClickOptionsPopoverOverlay"}}},"option-*":{eventListeners:{click:{handler:"handleOptionClick"},mouseenter:{handler:"handleOptionMouseEnter"},mouseleave:{handler:"handleOptionMouseLeave"}}},"option-add":{eventListeners:{click:{handler:"handleAddOptionClick"},mouseenter:{handler:"handleAddOptionMouseEnter"},mouseleave:{handler:"handleAddOptionMouseLeave"}}}},events:{},template:{type:9,items:[{type:8,properties:[{key:"rtgl-button#select-button v=ol ${containerAttrString}",value:{type:9,items:[{type:8,properties:[{key:"rtgl-view d=h av=c w=f",value:{type:9,items:[{type:8,properties:[{key:"rtgl-text c=${selectedLabelColor}",value:{type:1,path:"selectedLabel"},parsedKey:{type:2,parts:["rtgl-text c=",{type:1,path:"selectedLabelColor"}]}}],fast:!0},{type:8,properties:[{key:"rtgl-view mh=md flex=1",value:{type:0,value:null}}],fast:!0},{type:8,properties:[{key:"$if showClear",value:{type:6,conditions:[{type:1,path:"showClear"}],bodies:[{type:9,items:[{type:8,properties:[{key:"rtgl-svg#clear-button mr=md svg=x wh=16 c=mu-fg cur=p",value:{type:0,value:null}}],fast:!0}],fast:!0}],id:null}}],fast:!1},{type:8,properties:[{key:"rtgl-svg svg=chevronDown wh=16 c=mu-fg",value:{type:0,value:null}}],fast:!0}],fast:!1}}],fast:!1}],fast:!1},parsedKey:{type:2,parts:["rtgl-button#select-button v=ol ",{type:1,path:"containerAttrString"}]}}],fast:!1},{type:8,properties:[{key:"rtgl-popover#popover ?open=${isOpen} x=${position.x} y=${position.y} placement=right-start",value:{type:9,items:[{type:8,properties:[{key:"rtgl-view wh=300 g=xs slot=content bgc=background br=md sv=true",value:{type:9,items:[{type:7,itemVar:"option",indexVar:"i",iterable:{type:1,path:"options"},body:{type:9,items:[{type:8,properties:[{key:"rtgl-view#option-${i} w=f ph=lg pv=md cur=p br=md bgc=${option.bgc}",value:{type:9,items:[{type:8,properties:[{key:"rtgl-text",value:{type:1,path:"option.label"}}],fast:!0}],fast:!0},parsedKey:{type:2,parts:["rtgl-view#option-",{type:1,path:"i"}," w=f ph=lg pv=md cur=p br=md bgc=",{type:1,path:"option.bgc"}]}}],fast:!0}],fast:!0}},{type:8,properties:[{key:"$if showAddOption",value:{type:6,conditions:[{type:1,path:"showAddOption"}],bodies:[{type:9,items:[{type:8,properties:[{key:"rtgl-view w=f bw=xs bc=mu-bg bt=sm",value:{type:0,value:null}}],fast:!0},{type:8,properties:[{key:"rtgl-view#option-add w=f ph=lg pv=md cur=p br=md bgc=${addOptionBgc}",value:{type:9,items:[{type:8,properties:[{key:"rtgl-text c=ac",value:{type:1,path:"addOptionLabel"}}],fast:!0}],fast:!0},parsedKey:{type:2,parts:["rtgl-view#option-add w=f ph=lg pv=md cur=p br=md bgc=",{type:1,path:"addOptionBgc"}]}}],fast:!0}],fast:!0}],id:null}}],fast:!1}],fast:!1}}],fast:!1}],fast:!1},parsedKey:{type:2,parts:["rtgl-popover#popover ?open=",{type:1,path:"isOpen"}," x=",{type:1,path:"position.x"}," y=",{type:1,path:"position.y"}," placement=right-start"]}}],fast:!1}],fast:!1}};var Pt={};P(Pt,{handleHeaderClick:()=>qo,handleItemClick:()=>Yo});var qo=(e,t)=>{let{store:r,dispatchEvent:s}=e,i=t._event,n,o=r.selectHeader();i.currentTarget.id==="header-label"?n=o.labelPath:i.currentTarget.id==="header-image"?n=o.image.path:i.currentTarget.id==="header"&&(n=o.path),s(new CustomEvent("headerClick",{detail:{path:n},bubbles:!0,composed:!0}))},Yo=(e,t)=>{let{store:r,dispatchEvent:s}=e,n=t._event.currentTarget.id.replace("item-",""),o=r.selectItem(n);s(new CustomEvent("itemClick",{detail:{item:o},bubbles:!0,composed:!0}))};var Dt={};P(Dt,{createInitialState:()=>Go,selectActiveItem:()=>ta,selectHeader:()=>ea,selectItem:()=>ra,selectViewData:()=>Zo,setState:()=>sa});var Go=()=>Object.freeze({}),Xo=["id","class","style","slot"],Qo=e=>Object.entries(e).filter(([t])=>!Xo.includes(t)).map(([t,r])=>`${t}=${r}`).join(" ");function Vt(e,t=null){let r=[];for(let s of e){let i=s.id||s.href||s.path,n=t===i;if(r.push({id:i,title:s.title,href:s.href,type:s.type||"item",icon:s.icon,hrefAttr:s.href?`href=${s.href}`:"",isSelected:n,itemBgc:n?"ac":"bg",itemHoverBgc:n?"ac":"mu"}),s.items&&Array.isArray(s.items))for(let o of s.items){let l=o.id||o.href||o.path,p=t===l;r.push({id:l,title:o.title,href:o.href,type:o.type||"item",icon:o.icon,hrefAttr:o.href?`href=${o.href}`:"",isSelected:p,itemBgc:p?"ac":"bg",itemHoverBgc:p?"ac":"mu"})}}return r}var Zo=({state:e,props:t,attrs:r})=>{let s=r.header?JSON.parse(decodeURIComponent(r.header)):t.header,i=r.items?JSON.parse(decodeURIComponent(r.items)):t.items,n=r.selectedItemId||t.selectedItemId,o=Qo(r),l=r.mode||"full",p=s||{label:"",path:"",image:{src:"",alt:"",width:0,height:0}},a=i?Vt(i,n):[],c=l==="full"?272:64,u=l==="full"?"fs":"c",h=l==="full"?"fs":"c",f=l==="full"?"lg":"sm",d=l==="full"?"md":"sm",y=l==="shrunk-lg"?48:40,b=l==="shrunk-lg"?28:20,m=l==="shrunk-lg"?"md":"sm",w=l==="full",_=l==="full",x=l==="full"?"fs":"c",E=l==="full"?"":`ah=${h}`,$=l==="full"?"f":y;return{containerAttrString:o,mode:l,header:p,items:a,sidebarWidth:c,headerAlign:u,itemAlign:h,headerPadding:f,itemPadding:d,itemHeight:y,iconSize:b,firstLetterSize:m,showLabels:w,showGroupLabels:_,itemContentAlign:x,itemAlignAttr:E,itemWidth:$,headerWidth:$,selectedItemId:n,ah:l==="shrunk-lg"||l==="shrunk-md"?"c":""}},ea=({state:e,props:t,attrs:r})=>r.header?JSON.parse(decodeURIComponent(r.header)):t.header,ta=({state:e,props:t})=>(t.items?Vt(t.items):[]).find(s=>s.active),ra=({state:e,props:t,attrs:r},s)=>{let i=r.items?JSON.parse(decodeURIComponent(r.items)):t.items;return(i?Vt(i):[]).find(o=>o.id===s)},sa=e=>{};var ss={elementName:"rtgl-sidebar",viewDataSchema:{type:"object",properties:{containerAttrString:{type:"string"},mode:{type:"string",enum:["full","shrunk","shrunk-lg"],default:"full"},sidebarWidth:{type:"number"},headerAlign:{type:"string"},itemAlign:{type:"string"},headerPadding:{type:"string"},itemPadding:{type:"string"},itemHeight:{type:"number"},iconSize:{type:"number"},firstLetterSize:{type:"string"},showLabels:{type:"boolean"},showGroupLabels:{type:"boolean"},itemContentAlign:{type:"string"},itemAlignAttr:{type:"string"},itemWidth:{type:"string"},headerWidth:{type:"string"},selectedItemId:{type:"string"},header:{type:"object",properties:{label:{type:"string"},href:{type:"string"},image:{type:"object",properties:{src:{type:"string"},width:{type:"number"},height:{type:"number"},alt:{type:"string"}}}}},items:{type:"array",items:{type:"object",properties:{title:{type:"string"},slug:{type:"string"},type:{type:"string"},active:{type:"boolean"},icon:{type:"string"}}}}}},propsSchema:{type:"object",properties:{selectedItemId:{type:"string"},header:{type:"object",properties:{label:{type:"string"},href:{type:"string"},image:{type:"object",properties:{src:{type:"string"},width:{type:"number"},height:{type:"number"},alt:{type:"string"}}}}},items:{type:"array",items:{type:"object",properties:{title:{type:"string"},slug:{type:"string"},type:{type:"string"},items:{type:"array"}}}}}},refs:{"header-image":{eventListeners:{click:{handler:"handleHeaderClick"}}},"header-label":{eventListeners:{click:{handler:"handleHeaderClick"}}},header:{eventListeners:{click:{handler:"handleHeaderClick"}}},"item-*":{eventListeners:{click:{handler:"handleItemClick"}}}},events:{headerClick:{type:"object",properties:{path:{type:"string"}}}},anchors:[[{"$if header.image && header.image.src":[{"$if header.image.href":[{"a href=${header.image.href}":[{'rtgl-image w=${header.image.width} h=${header.image.height} src=${header.image.src} alt="${header.image.alt}"':null}]}],"$elif header.image.path":[{"rtgl-view#header-image cur=p":[{'rtgl-image w=${header.image.width} h=${header.image.height} src=${header.image.src} alt="${header.image.alt}"':null}]}],$else:[{'rtgl-image w=${header.image.width} h=${header.image.height} src=${header.image.src} alt="${header.image.alt}"':null}]}]},{"$if header.label && showLabels":[{"$if header.labelHref":[{"rtgl-text href=${header.labelHref} s=lg":"${header.label}"}],"$elif header.labelPath":[{"rtgl-view#header-label cur=p":[{"rtgl-text s=lg":"${header.label}"}]}],$else:[{"rtgl-text s=lg":"${header.label}"}]}]}]],template:{type:9,items:[{type:8,properties:[{key:"rtgl-view h=f w=${sidebarWidth} bwr=xs ah=${ah} ${containerAttrString}",value:{type:9,items:[{type:8,properties:[{key:"rtgl-view ph=${headerPadding} pv=lg",value:{type:9,items:[{type:8,properties:[{key:"$if header.href",value:{type:6,conditions:[{type:1,path:"header.href"},null],bodies:[{type:9,items:[{type:8,properties:[{key:"rtgl-view href=${header.href} d=h av=c ah=${headerAlign} g=lg w=${headerWidth}",value:{type:9,items:[{type:9,items:[{type:8,properties:[{key:"$if header.image && header.image.src",value:{type:6,conditions:[{type:4,op:6,left:{type:1,path:"header.image"},right:{type:1,path:"header.image.src"}}],bodies:[{type:9,items:[{type:8,properties:[{key:"$if header.image.href",value:{type:6,conditions:[{type:1,path:"header.image.href"},{type:1,path:"header.image.path"},null],bodies:[{type:9,items:[{type:8,properties:[{key:"a href=${header.image.href}",value:{type:9,items:[{type:8,properties:[{key:'rtgl-image w=${header.image.width} h=${header.image.height} src=${header.image.src} alt="${header.image.alt}"',value:{type:0,value:null},parsedKey:{type:2,parts:["rtgl-image w=",{type:1,path:"header.image.width"}," h=",{type:1,path:"header.image.height"}," src=",{type:1,path:"header.image.src"},' alt="',{type:1,path:"header.image.alt"},'"']}}],fast:!0}],fast:!0},parsedKey:{type:2,parts:["a href=",{type:1,path:"header.image.href"}]}}],fast:!0}],fast:!0},{type:9,items:[{type:8,properties:[{key:"rtgl-view#header-image cur=p",value:{type:9,items:[{type:8,properties:[{key:'rtgl-image w=${header.image.width} h=${header.image.height} src=${header.image.src} alt="${header.image.alt}"',value:{type:0,value:null},parsedKey:{type:2,parts:["rtgl-image w=",{type:1,path:"header.image.width"}," h=",{type:1,path:"header.image.height"}," src=",{type:1,path:"header.image.src"},' alt="',{type:1,path:"header.image.alt"},'"']}}],fast:!0}],fast:!0}}],fast:!0}],fast:!0},{type:9,items:[{type:8,properties:[{key:'rtgl-image w=${header.image.width} h=${header.image.height} src=${header.image.src} alt="${header.image.alt}"',value:{type:0,value:null},parsedKey:{type:2,parts:["rtgl-image w=",{type:1,path:"header.image.width"}," h=",{type:1,path:"header.image.height"}," src=",{type:1,path:"header.image.src"},' alt="',{type:1,path:"header.image.alt"},'"']}}],fast:!0}],fast:!0}],id:null}}],fast:!1}],fast:!1}],id:null}}],fast:!1},{type:8,properties:[{key:"$if header.label && showLabels",value:{type:6,conditions:[{type:4,op:6,left:{type:1,path:"header.label"},right:{type:1,path:"showLabels"}}],bodies:[{type:9,items:[{type:8,properties:[{key:"$if header.labelHref",value:{type:6,conditions:[{type:1,path:"header.labelHref"},{type:1,path:"header.labelPath"},null],bodies:[{type:9,items:[{type:8,properties:[{key:"rtgl-text href=${header.labelHref} s=lg",value:{type:1,path:"header.label"},parsedKey:{type:2,parts:["rtgl-text href=",{type:1,path:"header.labelHref"}," s=lg"]}}],fast:!0}],fast:!0},{type:9,items:[{type:8,properties:[{key:"rtgl-view#header-label cur=p",value:{type:9,items:[{type:8,properties:[{key:"rtgl-text s=lg",value:{type:1,path:"header.label"}}],fast:!0}],fast:!0}}],fast:!0}],fast:!0},{type:9,items:[{type:8,properties:[{key:"rtgl-text s=lg",value:{type:1,path:"header.label"}}],fast:!0}],fast:!0}],id:null}}],fast:!1}],fast:!1}],id:null}}],fast:!1}],fast:!1}],fast:!1},parsedKey:{type:2,parts:["rtgl-view href=",{type:1,path:"header.href"}," d=h av=c ah=",{type:1,path:"headerAlign"}," g=lg w=",{type:1,path:"headerWidth"}]}}],fast:!1}],fast:!1},{type:9,items:[{type:8,properties:[{key:"rtgl-view#header d=h av=c ah=${headerAlign} g=lg w=${headerWidth} cur=p",value:{type:9,items:[{type:9,items:[{type:8,properties:[{key:"$if header.image && header.image.src",value:{type:6,conditions:[{type:4,op:6,left:{type:1,path:"header.image"},right:{type:1,path:"header.image.src"}}],bodies:[{type:9,items:[{type:8,properties:[{key:"$if header.image.href",value:{type:6,conditions:[{type:1,path:"header.image.href"},{type:1,path:"header.image.path"},null],bodies:[{type:9,items:[{type:8,properties:[{key:"a href=${header.image.href}",value:{type:9,items:[{type:8,properties:[{key:'rtgl-image w=${header.image.width} h=${header.image.height} src=${header.image.src} alt="${header.image.alt}"',value:{type:0,value:null},parsedKey:{type:2,parts:["rtgl-image w=",{type:1,path:"header.image.width"}," h=",{type:1,path:"header.image.height"}," src=",{type:1,path:"header.image.src"},' alt="',{type:1,path:"header.image.alt"},'"']}}],fast:!0}],fast:!0},parsedKey:{type:2,parts:["a href=",{type:1,path:"header.image.href"}]}}],fast:!0}],fast:!0},{type:9,items:[{type:8,properties:[{key:"rtgl-view#header-image cur=p",value:{type:9,items:[{type:8,properties:[{key:'rtgl-image w=${header.image.width} h=${header.image.height} src=${header.image.src} alt="${header.image.alt}"',value:{type:0,value:null},parsedKey:{type:2,parts:["rtgl-image w=",{type:1,path:"header.image.width"}," h=",{type:1,path:"header.image.height"}," src=",{type:1,path:"header.image.src"},' alt="',{type:1,path:"header.image.alt"},'"']}}],fast:!0}],fast:!0}}],fast:!0}],fast:!0},{type:9,items:[{type:8,properties:[{key:'rtgl-image w=${header.image.width} h=${header.image.height} src=${header.image.src} alt="${header.image.alt}"',value:{type:0,value:null},parsedKey:{type:2,parts:["rtgl-image w=",{type:1,path:"header.image.width"}," h=",{type:1,path:"header.image.height"}," src=",{type:1,path:"header.image.src"},' alt="',{type:1,path:"header.image.alt"},'"']}}],fast:!0}],fast:!0}],id:null}}],fast:!1}],fast:!1}],id:null}}],fast:!1},{type:8,properties:[{key:"$if header.label && showLabels",value:{type:6,conditions:[{type:4,op:6,left:{type:1,path:"header.label"},right:{type:1,path:"showLabels"}}],bodies:[{type:9,items:[{type:8,properties:[{key:"$if header.labelHref",value:{type:6,conditions:[{type:1,path:"header.labelHref"},{type:1,path:"header.labelPath"},null],bodies:[{type:9,items:[{type:8,properties:[{key:"rtgl-text href=${header.labelHref} s=lg",value:{type:1,path:"header.label"},parsedKey:{type:2,parts:["rtgl-text href=",{type:1,path:"header.labelHref"}," s=lg"]}}],fast:!0}],fast:!0},{type:9,items:[{type:8,properties:[{key:"rtgl-view#header-label cur=p",value:{type:9,items:[{type:8,properties:[{key:"rtgl-text s=lg",value:{type:1,path:"header.label"}}],fast:!0}],fast:!0}}],fast:!0}],fast:!0},{type:9,items:[{type:8,properties:[{key:"rtgl-text s=lg",value:{type:1,path:"header.label"}}],fast:!0}],fast:!0}],id:null}}],fast:!1}],fast:!1}],id:null}}],fast:!1}],fast:!1}],fast:!1},parsedKey:{type:2,parts:["rtgl-view#header d=h av=c ah=",{type:1,path:"headerAlign"}," g=lg w=",{type:1,path:"headerWidth"}," cur=p"]}}],fast:!1}],fast:!1}],id:null}}],fast:!1}],fast:!1},parsedKey:{type:2,parts:["rtgl-view ph=",{type:1,path:"headerPadding"}," pv=lg"]}}],fast:!1},{type:8,properties:[{key:"rtgl-view w=f ph=${headerPadding} pb=lg g=xs ah=${ah}",value:{type:9,items:[{type:7,itemVar:"item",indexVar:"i",iterable:{type:1,path:"items"},body:{type:9,items:[{type:8,properties:[{key:'$if item.type == "groupLabel"',value:{type:6,conditions:[{type:4,op:0,left:{type:1,path:"item.type"},right:{type:0,value:"groupLabel"}},null],bodies:[{type:9,items:[{type:8,properties:[{key:"$if showGroupLabels",value:{type:6,conditions:[{type:1,path:"showGroupLabels"},null],bodies:[{type:9,items:[{type:8,properties:[{key:"rtgl-view mt=md h=32 av=c ph=md",value:{type:9,items:[{type:8,properties:[{key:"rtgl-text s=xs c=mu-fg",value:{type:1,path:"item.title"}}],fast:!0}],fast:!0}}],fast:!0}],fast:!0},{type:9,items:[{type:8,properties:[{key:"rtgl-view mt=md h=1 bgc=mu-bg",value:{type:0,value:null}}],fast:!0}],fast:!0}],id:null}}],fast:!1}],fast:!1},{type:9,items:[{type:8,properties:[{key:"rtgl-view#item-${item.id} ${item.hrefAttr} h=${itemHeight} av=c ${itemAlignAttr} ph=${itemPadding} w=${itemWidth} h-bgc=${item.itemHoverBgc} br=lg bgc=${item.itemBgc} cur=p",value:{type:9,items:[{type:8,properties:[{key:"$if item.icon",value:{type:6,conditions:[{type:1,path:"item.icon"},null],bodies:[{type:9,items:[{type:8,properties:[{key:"$if showLabels",value:{type:6,conditions:[{type:1,path:"showLabels"},null],bodies:[{type:9,items:[{type:8,properties:[{key:"rtgl-view d=h ah=${itemContentAlign} g=sm",value:{type:9,items:[{type:8,properties:[{key:"rtgl-svg wh=16 svg=${item.icon} c=fg",value:{type:0,value:null},parsedKey:{type:2,parts:["rtgl-svg wh=16 svg=",{type:1,path:"item.icon"}," c=fg"]}}],fast:!0},{type:8,properties:[{key:"rtgl-text s=sm",value:{type:1,path:"item.title"}}],fast:!0}],fast:!0},parsedKey:{type:2,parts:["rtgl-view d=h ah=",{type:1,path:"itemContentAlign"}," g=sm"]}}],fast:!0}],fast:!0},{type:9,items:[{type:8,properties:[{key:"rtgl-svg wh=${iconSize} svg=${item.icon} c=fg",value:{type:0,value:null},parsedKey:{type:2,parts:["rtgl-svg wh=",{type:1,path:"iconSize"}," svg=",{type:1,path:"item.icon"}," c=fg"]}}],fast:!0}],fast:!0}],id:null}}],fast:!1}],fast:!1},{type:9,items:[{type:8,properties:[{key:"$if showLabels",value:{type:6,conditions:[{type:1,path:"showLabels"},null],bodies:[{type:9,items:[{type:8,properties:[{key:"rtgl-text s=sm",value:{type:1,path:"item.title"}}],fast:!0}],fast:!0},{type:9,items:[{type:8,properties:[{key:"rtgl-view wh=${iconSize} br=f bgc=mu av=c ah=c",value:{type:9,items:[{type:8,properties:[{key:"rtgl-text s=${firstLetterSize} c=fg",value:{type:1,path:"item.title.charAt(0).toUpperCase()"},parsedKey:{type:2,parts:["rtgl-text s=",{type:1,path:"firstLetterSize"}," c=fg"]}}],fast:!0}],fast:!0},parsedKey:{type:2,parts:["rtgl-view wh=",{type:1,path:"iconSize"}," br=f bgc=mu av=c ah=c"]}}],fast:!0}],fast:!0}],id:null}}],fast:!1}],fast:!1}],id:null}}],fast:!1}],fast:!1},parsedKey:{type:2,parts:["rtgl-view#item-",{type:1,path:"item.id"}," ",{type:1,path:"item.hrefAttr"}," h=",{type:1,path:"itemHeight"}," av=c ",{type:1,path:"itemAlignAttr"}," ph=",{type:1,path:"itemPadding"}," w=",{type:1,path:"itemWidth"}," h-bgc=",{type:1,path:"item.itemHoverBgc"}," br=lg bgc=",{type:1,path:"item.itemBgc"}," cur=p"]}}],fast:!1}],fast:!1}],id:null}}],fast:!1}],fast:!1}}],fast:!1},parsedKey:{type:2,parts:["rtgl-view w=f ph=",{type:1,path:"headerPadding"}," pb=lg g=xs ah=",{type:1,path:"ah"}]}}],fast:!1}],fast:!1},parsedKey:{type:2,parts:["rtgl-view h=f w=",{type:1,path:"sidebarWidth"}," bwr=xs ah=",{type:1,path:"ah"}," ",{type:1,path:"containerAttrString"}]}}],fast:!1}],fast:!1}};var jt={};P(jt,{handleBeforeMount:()=>ia,handleOnUpdate:()=>na,handleValueChange:()=>oa});var ia=e=>{let{store:t,attrs:r}=e;t.setValue(r.value??0)},na=(e,t)=>{let{oldAttrs:r,newAttrs:s}=t,{store:i,render:n}=e;if(r?.value!==s?.value){let o=s?.value??0;i.setValue(o),n()}},oa=(e,t)=>{let{store:r,render:s,dispatchEvent:i}=e,n=t._event,o=Number(n.detail.value);r.setValue(o),s(),i(new CustomEvent("slider-input-value-change",{detail:{value:o},bubbles:!0}))};var Bt={};P(Bt,{createInitialState:()=>aa,selectViewData:()=>la,setValue:()=>pa});var aa=()=>Object.freeze({value:0}),la=({state:e,attrs:t})=>({key:t.key,value:e.value,w:t.w||"",min:t.min||0,max:t.max||100,step:t.step||1}),pa=(e,t)=>{e.value=t};var is={elementName:"rtgl-slider-input",viewDataSchema:{type:"object"},attrsSchema:{type:"object",properties:{value:{type:"string",default:"0"},w:{type:"string",default:""},min:{type:"string",default:"0"},max:{type:"string",default:"100"},step:{type:"string",default:"1"}}},refs:{input:{eventListeners:{"input-change":{handler:"handleValueChange"}}},slider:{eventListeners:{"slider-change":{handler:"handleValueChange"}}}},events:{"form-change":{}},template:{type:9,items:[{type:8,properties:[{key:"rtgl-view d=h av=c g=md w=${w}",value:{type:9,items:[{type:8,properties:[{key:"rtgl-slider#slider key=${key} w=f type=range min=${min} max=${max} step=${step} value=${value}",value:{type:0,value:null},parsedKey:{type:2,parts:["rtgl-slider#slider key=",{type:1,path:"key"}," w=f type=range min=",{type:1,path:"min"}," max=",{type:1,path:"max"}," step=",{type:1,path:"step"}," value=",{type:1,path:"value"}]}}],fast:!0},{type:8,properties:[{key:"rtgl-view w=84",value:{type:9,items:[{type:8,properties:[{key:"rtgl-input#input key=${key} w=f type=number min=${min} max=${max} step=${step} value=${value}",value:{type:0,value:null},parsedKey:{type:2,parts:["rtgl-input#input key=",{type:1,path:"key"}," w=f type=number min=",{type:1,path:"min"}," max=",{type:1,path:"max"}," step=",{type:1,path:"step"}," value=",{type:1,path:"value"}]}}],fast:!0}],fast:!0}}],fast:!0}],fast:!0},parsedKey:{type:2,parts:["rtgl-view d=h av=c g=md w=",{type:1,path:"w"}]}}],fast:!0}],fast:!0}};var Wt={};P(Wt,{handleBeforeMount:()=>ca,handleHeaderClick:()=>ha,handleRowClick:()=>ua});var ca=e=>{},ua=(e,t)=>{let{dispatchEvent:r,props:s}=e,i=t._event,n=parseInt(i.currentTarget.id.replace("row-","")),o=s.data?.rows?.[n];o&&r(new CustomEvent("row-click",{detail:{rowIndex:n,rowData:o}}))},ha=(e,t)=>{let{store:r,render:s,dispatchEvent:i}=e,o=t._event.currentTarget.id.replace("header-",""),l=r.selectSortInfo(),p="asc";l.column===o&&(l.direction==="asc"?p="desc":l.direction==="desc"&&(p=null)),p?r.setSortColumn({column:o,direction:p}):r.clearSort(),s(),i(new CustomEvent("header-click",{detail:{column:o,direction:p,sortInfo:p?{column:o,direction:p}:null}}))};var Mt={};P(Mt,{clearSort:()=>_a,createInitialState:()=>da,selectSortInfo:()=>ba,selectState:()=>va,selectViewData:()=>ga,setSortColumn:()=>wa});var da=()=>Object.freeze({sortColumn:null,sortDirection:null}),fa=["id","class","style","slot"],ya=e=>Object.entries(e).filter(([t])=>!fa.includes(t)).map(([t,r])=>`${t}=${r}`).join(" "),ma=(e,t)=>{let r=t.split("."),s=e;for(let i of r){if(s==null)return null;s=s[i]}return s},ga=({state:e,props:t,attrs:r})=>{let s=ya(r),i=t.data||{columns:[],rows:[]},n=i.rows.map((o,l)=>{let p=i.columns.map(a=>{let c=ma(o,a.key);return{key:a.key,value:c!=null?String(c):""}});return{index:l,cells:p}});return{containerAttrString:s,columns:i.columns||[],rows:n||[]}},va=({state:e})=>e,ba=({state:e})=>({column:e.sortColumn,direction:e.sortDirection}),wa=(e,{column:t,direction:r})=>{e.sortColumn=t,e.sortDirection=r},_a=e=>{e.sortColumn=null,e.sortDirection=null};var ns={elementName:"rtgl-table",viewDataSchema:{type:"object",properties:{columns:{type:"array"},rows:{type:"array"},containerAttrString:{type:"string"}}},propsSchema:{type:"object",properties:{data:{type:"object",properties:{columns:{type:"array",items:{type:"object",properties:{key:{type:"string"},label:{type:"string"}}}},rows:{type:"array",items:{type:"object"}}}},responsive:{type:"boolean",default:!0}}},refs:{"row-*":{eventListeners:{click:{handler:"handleRowClick"}}},"header-*":{eventListeners:{click:{handler:"handleHeaderClick"}}}},events:{},styles:{table:{width:"100%","border-collapse":"collapse","border-spacing":0},thead:{"border-bottom":"2px solid var(--border)"},th:{padding:"12px","text-align":"left","font-weight":500,color:"var(--foreground)","background-color":"var(--muted)",cursor:"pointer",position:"sticky",top:0,"z-index":1},"tbody tr":{"border-bottom":"1px solid var(--border)"},"tbody tr:last-child":{"border-bottom":"none"},td:{padding:"12px",color:"var(--foreground)"},".table-container":{width:"100%",height:"100%",overflow:"auto"},".empty-state":{"text-align":"center",padding:"24px",color:"var(--muted-foreground)"}},template:{type:9,items:[{type:8,properties:[{key:"rtgl-view.table-container ${containerAttrString}",value:{type:9,items:[{type:8,properties:[{key:"$if rows.length > 0",value:{type:6,conditions:[{type:4,op:2,left:{type:1,path:"rows.length"},right:{type:0,value:0}},null],bodies:[{type:9,items:[{type:8,properties:[{key:"table",value:{type:9,items:[{type:8,properties:[{key:"thead",value:{type:9,items:[{type:8,properties:[{key:"tr",value:{type:9,items:[{type:7,itemVar:"column",indexVar:"i",iterable:{type:1,path:"columns"},body:{type:9,items:[{type:8,properties:[{key:"th#header-${column.key}",value:{type:1,path:"column.label"},parsedKey:{type:2,parts:["th#header-",{type:1,path:"column.key"}]}}],fast:!0}],fast:!0}}],fast:!1}}],fast:!1}],fast:!1}}],fast:!1},{type:8,properties:[{key:"tbody",value:{type:9,items:[{type:7,itemVar:"row",indexVar:"rowIndex",iterable:{type:1,path:"rows"},body:{type:9,items:[{type:8,properties:[{key:"tr#row-${row.index}",value:{type:9,items:[{type:7,itemVar:"cell",indexVar:"cellIndex",iterable:{type:1,path:"row.cells"},body:{type:9,items:[{type:8,properties:[{key:"td",value:{type:1,path:"cell.value"}}],fast:!0}],fast:!0}}],fast:!1},parsedKey:{type:2,parts:["tr#row-",{type:1,path:"row.index"}]}}],fast:!1}],fast:!1}}],fast:!1}}],fast:!1}],fast:!1}}],fast:!1}],fast:!1},{type:9,items:[{type:8,properties:[{key:"rtgl-view.empty-state w=f p=xl",value:{type:9,items:[{type:8,properties:[{key:"rtgl-text c=mu-fg",value:{type:0,value:"No data available"}}],fast:!0}],fast:!0}}],fast:!0}],fast:!0}],id:null}}],fast:!1}],fast:!1},parsedKey:{type:2,parts:["rtgl-view.table-container ",{type:1,path:"containerAttrString"}]}}],fast:!1}],fast:!1}};var Ft={};P(Ft,{handleClickItem:()=>xa});var xa=(e,t)=>{let{dispatchEvent:r}=e,i=t._event.currentTarget.dataset.id;r(new CustomEvent("item-click",{detail:{id:i}}))};var Ut={};P(Ut,{createInitialState:()=>Aa,selectViewData:()=>$a});var Aa=()=>Object.freeze({}),Ea=["id","class","style","slot"],ka=e=>Object.entries(e).filter(([t])=>!Ea.includes(t)).map(([t,r])=>`${t}=${r}`).join(" "),$a=({state:e,props:t,attrs:r})=>{let s=ka(r),i=t.items||[],n=r["selected-tab"],o=i.map(l=>({...l,isSelected:l.id===n,bgColor:l.id===n?"ac":"",borderColor:l.id===n?"":"tr",textColor:l.id===n?"":"mu-fg"}));return{containerAttrString:s,items:o,selectedTab:n}};var os={elementName:"rtgl-tabs",viewDataSchema:{type:"object",properties:{containerAttrString:{type:"string"},items:{type:"array",items:{type:"object",properties:{label:{type:"string"},id:{type:"string"},isSelected:{type:"boolean"},bgColor:{type:"string"},textColor:{type:"string"},borderColor:{type:"string"}}}},selectedTab:{type:"string"}}},propsSchema:{type:"object",properties:{items:{type:"array",items:{type:"object",properties:{label:{type:"string"},id:{type:"string"}}}}}},attrsSchema:{type:"object",properties:{"selected-tab":{type:"string"}}},refs:{"tab-*":{eventListeners:{click:{handler:"handleClickItem"}}}},events:{"item-click":{type:"object",properties:{id:{type:"string"}}}},template:{type:9,items:[{type:8,properties:[{key:"rtgl-view d=h g=sm bgc=mu p=sm br=lg ${containerAttrString}",value:{type:9,items:[{type:7,itemVar:"item",indexVar:null,iterable:{type:1,path:"items"},body:{type:9,items:[{type:8,properties:[{key:"rtgl-view#tab-${item.id} data-id=${item.id} cur=p bgc=${item.bgColor} bw=xs bc=${item.borderColor} pv=md ph=lg br=lg",value:{type:9,items:[{type:8,properties:[{key:"rtgl-text s=sm c=${item.textColor}",value:{type:1,path:"item.label"},parsedKey:{type:2,parts:["rtgl-text s=sm c=",{type:1,path:"item.textColor"}]}}],fast:!0}],fast:!0},parsedKey:{type:2,parts:["rtgl-view#tab-",{type:1,path:"item.id"}," data-id=",{type:1,path:"item.id"}," cur=p bgc=",{type:1,path:"item.bgColor"}," bw=xs bc=",{type:1,path:"item.borderColor"}," pv=md ph=lg br=lg"]}}],fast:!0}],fast:!0}}],fast:!1},parsedKey:{type:2,parts:["rtgl-view d=h g=sm bgc=mu p=sm br=lg ",{type:1,path:"containerAttrString"}]}}],fast:!1}],fast:!1}};var as={};var Kt={};P(Kt,{createInitialState:()=>Sa,selectViewData:()=>Ca});var Sa=()=>Object.freeze({}),Ca=({attrs:e})=>({open:!!e.open,x:e.x||0,y:e.y||0,placement:e.placement||"top",content:e.content||""});var ls={elementName:"rtgl-tooltip",viewDataSchema:{type:"object"},attrsSchema:{type:"object",properties:{open:{type:"string"},x:{type:"string"},y:{type:"string"},placement:{type:"string"},content:{type:"string"}}},template:{type:9,items:[{type:8,properties:[{key:"rtgl-popover#popover ?open=${open} x=${x} y=${y} placement=${placement} no-overlay",value:{type:9,items:[{type:8,properties:[{key:"rtgl-view slot=content bgc=background bc=border br=md p=sm ah=c av=c",value:{type:9,items:[{type:8,properties:[{key:"rtgl-text ta=c s=sm c=foreground",value:{type:1,path:"content"}}],fast:!0}],fast:!0}}],fast:!0}],fast:!0},parsedKey:{type:2,parts:["rtgl-popover#popover ?open=",{type:1,path:"open"}," x=",{type:1,path:"x"}," y=",{type:1,path:"y"}," placement=",{type:1,path:"placement"}," no-overlay"]}}],fast:!0}],fast:!0}};var zt={};P(zt,{handleAfterMount:()=>Oa,handleOnUpdate:()=>Ia});var Oa=async e=>{let{props:t,store:r,render:s,getRefIds:i}=e,{waveformData:n}=t;r.setWaveformData(n),s();let o=i().canvas?.elm;o&&ps(n,o)},Ia=async(e,t)=>{let{store:r,render:s,getRefIds:i,props:n}=e,{waveformData:o}=n;if(!o){console.log("waveform handleOnUpdate: no waveformData provided");return}r.setWaveformData(o),s();let l=i().canvas?.elm;l&&ps(o,l)};async function ps(e,t){let r=t.getContext("2d"),s=t.getBoundingClientRect(),i=s.width,n=s.height;t.width=i,t.height=n;let o=t.width,l=t.height;if(r.clearRect(0,0,o,l),r.fillStyle="#1a1a1a",r.fillRect(0,0,o,l),!e||!e.amplitudes)return;let p=e.amplitudes,a=l/2,c=r.createLinearGradient(0,0,0,l);c.addColorStop(0,"#404040"),c.addColorStop(.5,"#A1A1A1"),c.addColorStop(1,"#404040");let u=Math.max(1,o/p.length),h=.2;for(let f=0;f<p.length;f++){let y=p[f]/255*(l*.85),b=f*u,m=a-y/2;r.fillStyle=c,r.fillRect(b,m,Math.max(1,u*(1-h)),y)}r.strokeStyle="rgba(255, 255, 255, 0.1)",r.lineWidth=1,r.beginPath(),r.moveTo(0,a),r.lineTo(o,a),r.stroke(),r.shadowBlur=10,r.shadowColor="#2196F3"}var Ht={};P(Ht,{createInitialState:()=>Ta,selectViewData:()=>Ra,setWaveformData:()=>La});var Ta=()=>Object.freeze({waveformData:null}),La=(e,t)=>{e.waveformData=t},Ra=({state:e,attrs:t,props:r})=>({isLoading:r.isLoading,w:t.w||"250",h:t.h||"150",cur:t.cur,waveformData:r.waveformData});var cs={elementName:"rtgl-waveform",attrsSchema:{type:"object",properties:{w:{type:"string",description:"Width of the waveform visualizer",default:"250"},h:{type:"string",description:"Height of the waveform visualizer",default:"150"},cur:{type:"string",description:"cursor"}}},propsSchema:{type:"object",properties:{waveformData:{type:"object",description:"File ID of the waveform data in object storage"},isLoading:{type:"boolean",description:"Whether the waveform data is currently being loaded"}}},refs:{canvas:{selector:"canvas"}},template:{type:9,items:[{type:8,properties:[{key:"rtgl-view w=f h=f pos=rel w=${w} h=${h} cur=${cur}",value:{type:9,items:[{type:8,properties:[{key:"$if isLoading",value:{type:6,conditions:[{type:1,path:"isLoading"},null],bodies:[{type:9,items:[{type:8,properties:[{key:"rtgl-view w=f h=f av=c ah=c",value:{type:9,items:[{type:8,properties:[{key:"rtgl-text c=mu-fg",value:{type:0,value:"..."}}],fast:!0}],fast:!0}}],fast:!0}],fast:!0},{type:9,items:[{type:8,properties:[{key:'canvas#canvas style="width:100%; height:100%;"',value:{type:0,value:null}}],fast:!0}],fast:!0}],id:null}}],fast:!1}],fast:!1},parsedKey:{type:2,parts:["rtgl-view w=f h=f pos=rel w=",{type:1,path:"w"}," h=",{type:1,path:"h"}," cur=",{type:1,path:"cur"}]}}],fast:!1}],fast:!1}};var ms=Symbol.for("immer-nothing"),us=Symbol.for("immer-draftable"),ee=Symbol.for("immer-state");function ne(e,...t){throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var Ae=Object.getPrototypeOf;function Ee(e){return!!e&&!!e[ee]}function ye(e){return e?gs(e)||Array.isArray(e)||!!e[us]||!!e.constructor?.[us]||qe(e)||Ye(e):!1}var Na=Object.prototype.constructor.toString();function gs(e){if(!e||typeof e!="object")return!1;let t=Ae(e);if(t===null)return!0;let r=Object.hasOwnProperty.call(t,"constructor")&&t.constructor;return r===Object?!0:typeof r=="function"&&Function.toString.call(r)===Na}function Ke(e,t){Je(e)===0?Reflect.ownKeys(e).forEach(r=>{t(r,e[r],e)}):e.forEach((r,s)=>t(s,r,e))}function Je(e){let t=e[ee];return t?t.type_:Array.isArray(e)?1:qe(e)?2:Ye(e)?3:0}function Yt(e,t){return Je(e)===2?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function vs(e,t,r){let s=Je(e);s===2?e.set(t,r):s===3?e.add(r):e[t]=r}function Pa(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}function qe(e){return e instanceof Map}function Ye(e){return e instanceof Set}function fe(e){return e.copy_||e.base_}function Gt(e,t){if(qe(e))return new Map(e);if(Ye(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);let r=gs(e);if(t===!0||t==="class_only"&&!r){let s=Object.getOwnPropertyDescriptors(e);delete s[ee];let i=Reflect.ownKeys(s);for(let n=0;n<i.length;n++){let o=i[n],l=s[o];l.writable===!1&&(l.writable=!0,l.configurable=!0),(l.get||l.set)&&(s[o]={configurable:!0,writable:!0,enumerable:l.enumerable,value:e[o]})}return Object.create(Ae(e),s)}else{let s=Ae(e);if(s!==null&&r)return{...e};let i=Object.create(s);return Object.assign(i,e)}}function tr(e,t=!1){return Ge(e)||Ee(e)||!ye(e)||(Je(e)>1&&(e.set=e.add=e.clear=e.delete=Va),Object.freeze(e),t&&Object.entries(e).forEach(([r,s])=>tr(s,!0))),e}function Va(){ne(2)}function Ge(e){return Object.isFrozen(e)}var Da={};function me(e){let t=Da[e];return t||ne(0,e),t}var Re;function bs(){return Re}function ja(e,t){return{drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function hs(e,t){t&&(me("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function Xt(e){Qt(e),e.drafts_.forEach(Ba),e.drafts_=null}function Qt(e){e===Re&&(Re=e.parent_)}function ds(e){return Re=ja(Re,e)}function Ba(e){let t=e[ee];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function fs(e,t){t.unfinalizedDrafts_=t.drafts_.length;let r=t.drafts_[0];return e!==void 0&&e!==r?(r[ee].modified_&&(Xt(t),ne(4)),ye(e)&&(e=ze(t,e),t.parent_||He(t,e)),t.patches_&&me("Patches").generateReplacementPatches_(r[ee].base_,e,t.patches_,t.inversePatches_)):e=ze(t,r,[]),Xt(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==ms?e:void 0}function ze(e,t,r){if(Ge(t))return t;let s=t[ee];if(!s)return Ke(t,(i,n)=>ys(e,s,t,i,n,r)),t;if(s.scope_!==e)return t;if(!s.modified_)return He(e,s.base_,!0),s.base_;if(!s.finalized_){s.finalized_=!0,s.scope_.unfinalizedDrafts_--;let i=s.copy_,n=i,o=!1;s.type_===3&&(n=new Set(i),i.clear(),o=!0),Ke(n,(l,p)=>ys(e,s,i,l,p,r,o)),He(e,i,!1),r&&e.patches_&&me("Patches").generatePatches_(s,r,e.patches_,e.inversePatches_)}return s.copy_}function ys(e,t,r,s,i,n,o){if(Ee(i)){let l=n&&t&&t.type_!==3&&!Yt(t.assigned_,s)?n.concat(s):void 0,p=ze(e,i,l);if(vs(r,s,p),Ee(p))e.canAutoFreeze_=!1;else return}else o&&r.add(i);if(ye(i)&&!Ge(i)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;ze(e,i),(!t||!t.scope_.parent_)&&typeof s!="symbol"&&Object.prototype.propertyIsEnumerable.call(r,s)&&He(e,i)}}function He(e,t,r=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&tr(t,r)}function Wa(e,t){let r=Array.isArray(e),s={type_:r?1:0,scope_:t?t.scope_:bs(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1},i=s,n=rr;r&&(i=[s],n=Ne);let{revoke:o,proxy:l}=Proxy.revocable(i,n);return s.draft_=l,s.revoke_=o,l}var rr={get(e,t){if(t===ee)return e;let r=fe(e);if(!Yt(r,t))return Ma(e,r,t);let s=r[t];return e.finalized_||!ye(s)?s:s===Jt(e.base_,t)?(qt(e),e.copy_[t]=er(s,e)):s},has(e,t){return t in fe(e)},ownKeys(e){return Reflect.ownKeys(fe(e))},set(e,t,r){let s=ws(fe(e),t);if(s?.set)return s.set.call(e.draft_,r),!0;if(!e.modified_){let i=Jt(fe(e),t),n=i?.[ee];if(n&&n.base_===r)return e.copy_[t]=r,e.assigned_[t]=!1,!0;if(Pa(r,i)&&(r!==void 0||Yt(e.base_,t)))return!0;qt(e),Zt(e)}return e.copy_[t]===r&&(r!==void 0||t in e.copy_)||Number.isNaN(r)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=r,e.assigned_[t]=!0),!0},deleteProperty(e,t){return Jt(e.base_,t)!==void 0||t in e.base_?(e.assigned_[t]=!1,qt(e),Zt(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){let r=fe(e),s=Reflect.getOwnPropertyDescriptor(r,t);return s&&{writable:!0,configurable:e.type_!==1||t!=="length",enumerable:s.enumerable,value:r[t]}},defineProperty(){ne(11)},getPrototypeOf(e){return Ae(e.base_)},setPrototypeOf(){ne(12)}},Ne={};Ke(rr,(e,t)=>{Ne[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}});Ne.deleteProperty=function(e,t){return Ne.set.call(this,e,t,void 0)};Ne.set=function(e,t,r){return rr.set.call(this,e[0],t,r,e[0])};function Jt(e,t){let r=e[ee];return(r?fe(r):e)[t]}function Ma(e,t,r){let s=ws(t,r);return s?"value"in s?s.value:s.get?.call(e.draft_):void 0}function ws(e,t){if(!(t in e))return;let r=Ae(e);for(;r;){let s=Object.getOwnPropertyDescriptor(r,t);if(s)return s;r=Ae(r)}}function Zt(e){e.modified_||(e.modified_=!0,e.parent_&&Zt(e.parent_))}function qt(e){e.copy_||(e.copy_=Gt(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var Fa=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.produce=(t,r,s)=>{if(typeof t=="function"&&typeof r!="function"){let n=r;r=t;let o=this;return function(p=n,...a){return o.produce(p,c=>r.call(this,c,...a))}}typeof r!="function"&&ne(6),s!==void 0&&typeof s!="function"&&ne(7);let i;if(ye(t)){let n=ds(this),o=er(t,void 0),l=!0;try{i=r(o),l=!1}finally{l?Xt(n):Qt(n)}return hs(n,s),fs(i,n)}else if(!t||typeof t!="object"){if(i=r(t),i===void 0&&(i=t),i===ms&&(i=void 0),this.autoFreeze_&&tr(i,!0),s){let n=[],o=[];me("Patches").generateReplacementPatches_(t,i,n,o),s(n,o)}return i}else ne(1,t)},this.produceWithPatches=(t,r)=>{if(typeof t=="function")return(o,...l)=>this.produceWithPatches(o,p=>t(p,...l));let s,i;return[this.produce(t,r,(o,l)=>{s=o,i=l}),s,i]},typeof e?.autoFreeze=="boolean"&&this.setAutoFreeze(e.autoFreeze),typeof e?.useStrictShallowCopy=="boolean"&&this.setUseStrictShallowCopy(e.useStrictShallowCopy)}createDraft(e){ye(e)||ne(8),Ee(e)&&(e=Ua(e));let t=ds(this),r=er(e,void 0);return r[ee].isManual_=!0,Qt(t),r}finishDraft(e,t){let r=e&&e[ee];(!r||!r.isManual_)&&ne(9);let{scope_:s}=r;return hs(s,t),fs(void 0,s)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}applyPatches(e,t){let r;for(r=t.length-1;r>=0;r--){let i=t[r];if(i.path.length===0&&i.op==="replace"){e=i.value;break}}r>-1&&(t=t.slice(r+1));let s=me("Patches").applyPatches_;return Ee(e)?s(e,t):this.produce(e,i=>s(i,t))}};function er(e,t){let r=qe(e)?me("MapSet").proxyMap_(e,t):Ye(e)?me("MapSet").proxySet_(e,t):Wa(e,t);return(t?t.scope_:bs()).drafts_.push(r),r}function Ua(e){return Ee(e)||ne(10,e),_s(e)}function _s(e){if(!ye(e)||Ge(e))return e;let t=e[ee],r;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,r=Gt(e,t.scope_.immer_.useStrictShallowCopy_)}else r=Gt(e,!0);return Ke(r,(s,i)=>{vs(r,s,_s(i))}),t&&(t.finalized_=!1),r}var te=new Fa,xs=te.produce,yu=te.produceWithPatches.bind(te),mu=te.setAutoFreeze.bind(te),gu=te.setUseStrictShallowCopy.bind(te),vu=te.applyPatches.bind(te),bu=te.createDraft.bind(te),wu=te.finishDraft.bind(te);var g={LITERAL:0,VARIABLE:1,INTERPOLATION:2,FUNCTION:3,BINARY:4,UNARY:5,CONDITIONAL:6,LOOP:7,OBJECT:8,ARRAY:9,PARTIAL:10,PATH_REFERENCE:11},W={EQ:0,NEQ:1,GT:2,LT:3,GTE:4,LTE:5,AND:6,OR:7,IN:8,ADD:10,SUBTRACT:11},Pe={NOT:0};var L=class extends Error{constructor(t){super(`Parse Error: ${t}`),this.name="JemplParseError"}},Q=class extends Error{constructor(t){super(`Render Error: ${t}`),this.name="JemplRenderError"}};var sr=e=>{if(!e||e.trim()==="")throw new L("Missing condition expression after '$if'");if(e.includes("===")||e.includes("!==")){let r=e.includes("===")?"==":"!=";throw new L(`Invalid comparison operator '${e.includes("===")?"===":"!=="}' - did you mean '${r}'? (got: '${e}')`)}let t=["<",">","<=",">=","==","!="];for(let r of t)if(e.trim().endsWith(r))throw new L(`Incomplete comparison expression - missing right operand (got: '${e}')`)},As=e=>{if(e.trim().endsWith(" in"))throw new L(`Missing iterable expression after 'in' (got: '$for ${e}')`);if(!e.includes(" in "))throw new L(`Invalid loop syntax - missing 'in' keyword (got: '$for ${e}')`);let[t,r]=e.split(" in ");if(!r||r.trim()==="")throw new L(`Missing iterable expression after 'in' (got: '$for ${e}')`);if(t.includes(",")){let s=t.split(",").map(i=>i.trim());for(let i of s)if(!i)throw new L(`Invalid loop variable - variable name cannot be empty (got: '$for ${e}')`)}else if(!t.trim())throw new L(`Invalid loop variable - variable name cannot be empty (got: '$for ${e}')`)};var Es=(e,t,r=!1)=>{if(t===null)return new Q(`Cannot iterate over null value at '$for ${e}'`);if(t===void 0)return new Q(`Cannot iterate over undefined value at '$for ${e}'`);let s=typeof t;return r?new Q(`Cannot iterate over non-array value in loop '${e}' - got ${s} instead`):new Q(`Cannot iterate over non-array value (got: ${s}) at '$for ${e}'`)},ks=(e,t)=>{let r=t&&Object.keys(t).length>0?Object.keys(t).join(", "):"no custom functions provided";return new Q(`Unknown function '${e}' (${r})`)};var Ka=(e,t,r={})=>{let s={},i={};r&&typeof r=="object"&&(r.functions!==void 0||r.partials!==void 0?(s=r.functions||{},i=r.partials||{}):typeof r=="object"&&(s=r));let o=T(e,{functions:s,partials:i},t,{});return o===void 0?{}:o},T=(e,t,r,s)=>{let i=t.functions||t;if(e.var&&!e.type)return H(e.var,r,s);if(e.type===g.LITERAL)return e.value;if(e.type===g.VARIABLE)return H(e.path,r,s);if(e.type===g.INTERPOLATION)return Ha(e.parts,t,r,s);switch(e.type){case g.FUNCTION:return Ss(e,t,r,s);case g.BINARY:return Cs(e,t,r,s);case g.UNARY:return Os(e,t,r,s);case g.CONDITIONAL:return qa(e,t,r,s);case g.LOOP:return Za(e,t,r,s);case g.OBJECT:return tl(e,t,r,s);case g.ARRAY:return rl(e,t,r,s);case g.PARTIAL:return sl(e,t,r,s);case g.PATH_REFERENCE:return il(e,t,r,s);default:throw new Error(`Unknown node type: ${e.type}`)}},$s=new Map,za=e=>{let t=[],r="",s=!1;for(let i=0;i<e.length;i++){let n=e[i];if(n==="[")r&&(t.push({type:"property",value:r}),r=""),s=!0;else if(n==="]"){if(s&&r){let o=r.trim();if(/^\d+$/.test(o))t.push({type:"index",value:parseInt(o,10)});else if(o.startsWith('"')&&o.endsWith('"')||o.startsWith("'")&&o.endsWith("'")){let l=o.slice(1,-1);t.push({type:"property",value:l})}else t.push({type:"property",value:o});r=""}s=!1}else r+=n}return r&&t.push({type:"property",value:r}),t},H=(e,t,r)=>{if(!e)return;if(e in r)return r[e];let s=$s.get(e);if(!s){let n=[],o="",l=0;for(let p=0;p<e.length;p++){let a=e[p];a==="["?(l++,o+=a):a==="]"?(l--,o+=a):a==="."&&l===0?o&&(n.push(o),o=""):o+=a}o&&n.push(o),s=[];for(let p of n){let a=za(p.trim());s.push(...a)}$s.set(e,s)}let i=t;for(let n=0;n<s.length;n++){let o=s[n];if(o.type==="property"&&o.value in r){i=r[o.value];continue}if(i==null)return;(o.type==="property"||o.type==="index")&&(i=i[o.value])}return i},Ha=(e,t,r,s)=>{let i=[];for(let n of e)if(typeof n=="string")i.push(n);else{let o=T(n,t,r,s);i.push(o!=null?String(o):"")}return i.join("")},Ss=(e,t,r,s)=>{let i=t.functions||t,n=i[e.name];if(!n)throw ks(e.name,i);let o=e.args.map(l=>T(l,t,r,s));return n(...o)},ke=(e,t,r,s)=>{if(e.var&&!e.type)return H(e.var,r,s);switch(e.type){case g.VARIABLE:return H(e.path,r,s);case g.LITERAL:return e.value;case g.BINARY:return Cs(e,t,r,s);case g.UNARY:return Os(e,t,r,s);case g.FUNCTION:return Ss(e,t,r,s);default:return T(e,t,r,s)}},Cs=(e,t,r,s)=>{if(e.op===W.AND||e.op===W.OR){let o=ke(e.left,t,r,s),l=ke(e.right,t,r,s);switch(e.op){case W.AND:return o&&l;case W.OR:return o||l}}let i=T(e.left,t,r,s),n=T(e.right,t,r,s);switch(e.op){case W.EQ:return i==n;case W.NEQ:return i!=n;case W.GT:return i>n;case W.LT:return i<n;case W.GTE:return i>=n;case W.LTE:return i<=n;case W.IN:return Array.isArray(n)?n.includes(i):!1;case W.ADD:if(typeof i!="number"||typeof n!="number")throw new Q(`Arithmetic operations require numbers. Got ${typeof i} + ${typeof n}`);return i+n;case W.SUBTRACT:if(typeof i!="number"||typeof n!="number")throw new Q(`Arithmetic operations require numbers. Got ${typeof i} - ${typeof n}`);return i-n;default:throw new Error(`Unknown binary operator: ${e.op}`)}},Os=(e,t,r,s)=>{let i=e.op===Pe.NOT?ke(e.operand,t,r,s):T(e.operand,t,r,s);switch(e.op){case Pe.NOT:return!i;default:throw new Error(`Unknown unary operator: ${e.op}`)}},Ja=(e,t,r,s)=>{if(e.conditions.length===2&&e.conditions[1]===null){let i=e.conditions[0];if(i.type===g.VARIABLE)if(H(i.path,r,s)){let o=e.bodies[0];if(o.type===g.OBJECT&&o.properties.length<=5){let l={};for(let p of o.properties){let a=p.parsedKey?T(p.parsedKey,t,r,s):p.key,c=p.value;if(c.type===g.LITERAL)l[a]=c.value;else if(c.type===g.VARIABLE)l[a]=H(c.path,r,s);else if(c.type===g.INTERPOLATION){let u=[];for(let h of c.parts)if(typeof h=="string")u.push(h);else if(h.type===g.VARIABLE){let f=H(h.path,r,s);u.push(f!=null?String(f):"")}else{let f=T(h,t,r,s);u.push(f!=null?String(f):"")}l[a]=u.join("")}else l[a]=T(c,t,r,s)}return l}}else{let o=e.bodies[1];if(o.type===g.OBJECT&&o.properties.length<=5){let l={};for(let p of o.properties){let a=p.parsedKey?T(p.parsedKey,t,r,s):p.key,c=p.value;if(c.type===g.LITERAL)l[a]=c.value;else if(c.type===g.VARIABLE)l[a]=H(c.path,r,s);else if(c.type===g.INTERPOLATION){let u=[];for(let h of c.parts)if(typeof h=="string")u.push(h);else if(h.type===g.VARIABLE){let f=H(h.path,r,s);u.push(f!=null?String(f):"")}else{let f=T(h,t,r,s);u.push(f!=null?String(f):"")}l[a]=u.join("")}else l[a]=T(c,t,r,s)}return l}}}return null},qa=(e,t,r,s)=>{let i=Ja(e,t,r,s);if(i!==null)return i;for(let n=0;n<e.conditions.length;n++){let o=e.conditions[n];if(o===null||ke(o,t,r,s))return T(e.bodies[n],t,r,s)}return Is},Ya=(e,t)=>{let r=e.body,s=e.itemVar;if(r.type===g.CONDITIONAL&&r.conditions.length===1&&r.conditions[0].type===g.VARIABLE){let i=r.conditions[0].path,n=r.bodies[0];if(i.startsWith(s+".")){let o=i.substring(s.length+1);if(n.type===g.OBJECT&&n.properties.length<=5){for(let p of n.properties)if(p.parsedKey)return null;let l=[];for(let p=0;p<t.length;p++){let a=t[p];if(a[o]){let c={};for(let u of n.properties){let h=u.key,f=u.value;if(f.type===g.LITERAL)c[h]=f.value;else if(f.type===g.VARIABLE){let d=f.path;if(d===s)c[h]=a;else if(d.startsWith(s+".")){let y=d.substring(s.length+1);c[h]=a[y]}else return null}else if(f.type===g.INTERPOLATION){let d=[],y=!0;for(let b of f.parts)if(typeof b=="string")d.push(b);else if(b.type===g.VARIABLE){let m=b.path;if(m===s)d.push(a!=null?String(a):"");else if(m.startsWith(s+".")){let w=m.substring(s.length+1),_=a[w];d.push(_!=null?String(_):"")}else{y=!1;break}}else{y=!1;break}if(!y)return null;c[h]=d.join("")}else return null}l.push(c)}}return l}}}return null},Ga=(e,t)=>{let r=e.body,s=e.itemVar,i=Ya(e,t);if(i!==null)return i;if(r.type===g.OBJECT&&r.properties.length<=5){for(let l of r.properties)if(l.parsedKey)return null;let n=[],o=!0;for(let l of r.properties){let p=l.key,a=l.value;if(a.type===g.LITERAL)n.push({key:p,type:"literal",value:a.value});else if(a.type===g.VARIABLE){let c=a.path;if(c===s)n.push({key:p,type:"item"});else if(c.startsWith(s+".")){let u=c.substring(s.length+1);if(!u.includes(".")&&!u.includes("["))n.push({key:p,type:"prop",prop:u});else{o=!1;break}}else{o=!1;break}}else if(a.type===g.INTERPOLATION&&a.parts.length===1){let c=a.parts[0];if(c.type===g.VARIABLE){let u=c.path;if(u===s)n.push({key:p,type:"item_string"});else if(u.startsWith(s+".")){let h=u.substring(s.length+1);if(!h.includes(".")&&!h.includes("["))n.push({key:p,type:"prop_string",prop:h});else{o=!1;break}}else{o=!1;break}}else{o=!1;break}}else{o=!1;break}}if(o){let l=new Array(t.length);if(n.length===3&&n[0].type==="prop"&&n[0].key==="id"&&n[1].type==="prop_string"&&n[1].key==="title"&&n[2].type==="prop"&&n[2].key==="completed")for(let p=0;p<t.length;p++){let a=t[p];l[p]={id:a.id,title:a.title!=null?String(a.title):"",completed:a.completed}}else for(let p=0;p<t.length;p++){let a=t[p],c={};for(let u of n)if(u.type==="literal")c[u.key]=u.value;else if(u.type==="item")c[u.key]=a;else if(u.type==="prop")c[u.key]=a[u.prop];else if(u.type==="item_string")c[u.key]=a!=null?String(a):"";else if(u.type==="prop_string"){let h=a[u.prop];c[u.key]=h!=null?String(h):""}l[p]=c}return l}}return null},Xa=(e,t,r,s,i)=>{let n=[],o=e.body;if(o.type===g.OBJECT&&o.fast!==!1){let l=e.itemVar,p=e.indexVar;for(let a=0;a<i.length;a++){let c=i[a],u={},h={...s,[l]:c,...p&&{[p]:a}};h.__paths__||(h.__paths__=s.__paths__||{});let f=e.iterable.path||"";if(s&&s.__paths__&&f){let d=f.split("."),y=d[0];y in s.__paths__&&(f=s.__paths__[y],d.length>1&&(f+="."+d.slice(1).join(".")))}h.__paths__={...h.__paths__,[l]:`${f}[${a}]`,...p&&{[p]:a}};for(let d of o.properties){let y=d.parsedKey?T(d.parsedKey,t,r,h):d.key,b=d.value;if(b.type===g.LITERAL)u[y]=b.value;else if(b.type===g.VARIABLE){let m=b.path;if(m===l)u[y]=c;else if(m===p)u[y]=a;else if(m.startsWith(l+".")){let w=m.substring(l.length+1);!w.includes(".")&&!w.includes("[")?u[y]=c[w]:u[y]=H(m,r,{...s,[l]:c,...p&&{[p]:a}})}else u[y]=H(m,r,{...s,[l]:c,...p&&{[p]:a}})}else if(b.type===g.INTERPOLATION){let m=[];for(let w of b.parts)if(typeof w=="string")m.push(w);else if(w.type===g.VARIABLE){let _=w.path,x;if(_===l)x=c;else if(_===p)x=a;else if(_.startsWith(l+".")){let E=_.substring(l.length+1);!E.includes(".")&&!E.includes("[")?x=c[E]:x=H(_,r,{...s,[l]:c,...p&&{[p]:a}})}else x=H(_,r,{...s,[l]:c,...p&&{[p]:a}});m.push(x!=null?String(x):"")}else{let _={...s,[l]:c,...p&&{[p]:a}},x=T(w,t,r,_);m.push(x!=null?String(x):"")}u[y]=m.join("")}else{let m={...s,[l]:c,...p&&{[p]:a}};u[y]=T(b,t,r,m)}}n.push(u)}return n}return null},Qa=(e,t,r)=>{let s=e.body;if(s.type===g.OBJECT&&s.properties.length===1&&s.properties[0].key==="$if item.visible"){let n=s.properties[0].value;if(n.type===g.CONDITIONAL&&n.conditions.length===1&&n.conditions[0].type===g.VARIABLE&&n.conditions[0].path==="item.visible"){let o=n.bodies[0];if(o.type===g.OBJECT&&o.properties.length===2){let l=o.properties[0],p=o.properties[1];if(l.key==="id"&&l.value.type===g.VARIABLE&&l.value.path==="item.id"&&p.key==="$if item.highlighted"&&p.value.type===g.CONDITIONAL){let a=[];for(let c=0;c<t.length;c++){let u=t[c];if(u.visible){let h={id:u.id};u.highlighted?(h.highlight=!0,h.message=`This item is highlighted: ${u.name}`):(h.highlight=!1,h.message=u.name),a.push(h)}}return a}}}}return null},Za=(e,t,r,s)=>{let i=T(e.iterable,t,r,s);if(!Array.isArray(i)){let a,c=!1;if(e.iterable.type===g.FUNCTION){c=!0;let h=e.iterable.args.map(f=>f.type===g.LITERAL?typeof f.value=="string"?`'${f.value}'`:String(f.value):f.type===g.VARIABLE?f.path:f.type===g.FUNCTION?`${f.name}(...)`:"?").join(", ");a=`${e.iterable.name}(${h})`}else a=e.iterable.path||"undefined";let u=`${e.itemVar}${e.indexVar?`, ${e.indexVar}`:""} in ${a}`;throw Es(u,i,c)}if(!e.indexVar){let a=Qa(e,i,e.itemVar);if(a!==null)return a}if(!e.indexVar){let a=Ga(e,i);if(a!==null)return a}let n=Xa(e,t,r,s,i);if(n!==null)return n;let o=[],l=e.iterable.path||"";if(s&&s.__paths__&&l){let a=l.split("."),c=a[0];c in s.__paths__&&(l=s.__paths__[c],a.length>1&&(l+="."+a.slice(1).join(".")))}let p=!1;e.body.type===g.ARRAY&&(e.body.items.length<=1?p=!1:p=e.body._shouldPreserveArray??=e.body.items.some(a=>a.type===g.OBJECT&&a.properties.some(c=>c.key.startsWith("$if ")||c.key.startsWith("$when "))));for(let a=0;a<i.length;a++){let c=e.indexVar?{...s,[e.itemVar]:i[a],[e.indexVar]:a}:{...s,[e.itemVar]:i[a]};c.__paths__||(c.__paths__=s.__paths__||{}),c.__paths__={...c.__paths__,[e.itemVar]:`${l}[${a}]`},e.indexVar&&(c.__paths__[e.indexVar]=a);let u=T(e.body,t,r,c);Array.isArray(u)&&u.length===1&&!p?o.push(u[0]):o.push(u)}return o},el=(e,t,r,s)=>{if(e.whenCondition)return null;if(e.properties.length===1){let i=e.properties[0],n=i.parsedKey?T(i.parsedKey,t,r,s):i.key,o=i.value;if(o.type===g.OBJECT&&o.properties.length<=10&&!o.whenCondition){let l={},p={},a=!0;for(let c of o.properties){let u=c.parsedKey?T(c.parsedKey,t,r,s):c.key,h=c.value;if(h.type===g.LITERAL)p[u]=h.value;else if(h.type===g.VARIABLE)p[u]=H(h.path,r,s);else if(h.type===g.INTERPOLATION){let f=[];for(let d of h.parts)if(typeof d=="string")f.push(d);else if(d.type===g.VARIABLE){let y=H(d.path,r,s);f.push(y!=null?String(y):"")}else{a=!1;break}if(!a)break;p[u]=f.join("")}else if(h.type===g.OBJECT&&h.properties.length<=5){let f={};for(let d of h.properties){let y=d.key,b=d.value;if(b.type===g.LITERAL)f[y]=b.value;else if(b.type===g.VARIABLE)f[y]=H(b.path,r,s);else if(b.type===g.INTERPOLATION){let m=[];for(let w of b.parts)if(typeof w=="string")m.push(w);else if(w.type===g.VARIABLE){let _=H(w.path,r,s);m.push(_!=null?String(_):"")}else{a=!1;break}if(!a)break;f[y]=m.join("")}else{a=!1;break}}if(!a)break;p[u]=f}else{a=!1;break}}if(a)return l[n]=p,l}}return null},tl=(e,t,r,s)=>{let i=t.functions||t;if(e.whenCondition&&!ke(e.whenCondition,i,r,s))return;let n=el(e,t,r,s);if(n!==null)return n;if(e.fast){let a={};for(let c of e.properties){let u=c.parsedKey?T(c.parsedKey,t,r,s):c.key,h=c.value;if(h.type===g.LITERAL)a[u]=h.value;else if(h.type===g.VARIABLE)a[u]=H(h.path,r,s);else if(h.type===g.INTERPOLATION){let f=[];for(let d of h.parts)if(typeof d=="string")f.push(d);else if(d.type===g.VARIABLE){let y=H(d.path,r,s);f.push(y!=null?String(y):"")}else{let y=T(d,t,r,s);f.push(y!=null?String(y):"")}a[u]=f.join("")}else a[u]=T(h,t,r,s)}return a}let o={},l=null,p=!1;for(let a of e.properties)if(!a.key.startsWith("$if ")&&!a.key.match(/^\$if\s+\w+.*:?$/)&&!a.key.startsWith("$elif")&&!a.key.startsWith("$else")&&!a.key.startsWith("$for ")){p=!0;break}for(let a of e.properties)if(a.key.startsWith("$if ")||a.key.match(/^\$if\s+\w+.*:?$/)){let c=T(a.value,t,r,s);if(!p&&c!==null&&c!==void 0)return Array.isArray(c)&&c.length===1?c[0]:c;typeof c=="object"&&c!==null&&!Array.isArray(c)&&Object.assign(o,c)}else if(a.key.startsWith("$for ")){if(e.properties.length===1)return T(a.value,t,r,s)}else{let c=a.value;if(c&&c.type===g.OBJECT&&c.properties){let u=c.properties.find(h=>h.key.startsWith("$for "));if(u){let h=T(u.value,t,r,s);h!==void 0&&(o[a.key]=h)}else{let h=T(a.value,t,r,s);h!==void 0&&(o[a.key]=h)}}else{let u=a.parsedKey?T(a.parsedKey,t,r,s):a.key,h=T(a.value,t,r,s);h!==void 0&&(o[u]=h)}}return o},Is={},rl=(e,t,r,s)=>{let i=[];for(let n of e.items)if(n.type===g.LOOP){let o=T(n,t,r,s);i.push(o)}else{let o=T(n,t,r,s);o!==Is&&o!==void 0&&i.push(o)}return i},sl=(e,t,r,s)=>{let{name:i,data:n,whenCondition:o}=e,l=t.partials||{},p=t.functions||t;if(o&&!ke(o,p,r,s))return;if(!l[i])throw new Q(`Partial '${i}' is not defined`);let a=s._partialStack||[];if(a.includes(i))throw new Q(`Circular partial reference detected: ${i}`);let c=l[i],u=r,h={...s,_partialStack:[...a,i]};if(s){u={...r};for(let f of Object.keys(s))f.startsWith("_")||(u[f]=s[f])}if(n){let f=T(n,t,r,s);u={...u,...f}}return T(c,t,u,h)},il=(e,t,r,s)=>{let{path:i}=e,n=i.split("."),o=n[0],l=n.slice(1);if(!s||!(o in s))throw new Q(`Path reference '#{${i}}' refers to '${o}' which is not a loop variable in the current scope`);if(s.__paths__||(s.__paths__={}),!(o in s.__paths__))throw new Q(`Path reference '#{${i}}' cannot be resolved - path tracking may not be initialized properly`);let p=s.__paths__[o];if(typeof p=="number"){if(l.length>0)throw new Q(`Path reference '#{${i}}' - cannot access properties on index variable '${o}'`);return String(p)}return l.length>0&&(p+="."+l.join(".")),p},Ve=Ka;var nl=/\$\{([^}]*)\}/g,ol=/#\{([^}]*)\}/g,Ls=(e,t={})=>{let r=e.match(/^(\w+)\((.*)\)$/);if(!r)return{isFunction:!1};let[,s,i]=r,n=al(i,t);return{isFunction:!0,type:g.FUNCTION,name:s,args:n}},al=(e,t={})=>e.trim()?ll(e).map(s=>pl(s.trim(),t)):[],ll=e=>{let t=[],r="",s=0,i=!1,n="";for(let o=0;o<e.length;o++){let l=e[o],p=o>0?e[o-1]:"";!i&&(l==='"'||l==="'")?(i=!0,n=l,r+=l):i&&l===n&&p!=="\\"?(i=!1,n="",r+=l):!i&&l==="("?(s++,r+=l):!i&&l===")"?(s--,r+=l):!i&&l===","&&s===0?(t.push(r),r=""):r+=l}return r&&t.push(r),t},pl=(e,t={})=>{if(e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"))return{type:g.LITERAL,value:e.slice(1,-1)};if(/^-?\d+(\.\d+)?$/.test(e))return{type:g.LITERAL,value:parseFloat(e)};if(e==="true")return{type:g.LITERAL,value:!0};if(e==="false")return{type:g.LITERAL,value:!1};if(e==="null")return{type:g.LITERAL,value:null};let r=Ls(e,t);if(r.isFunction)return{type:r.type,name:r.name,args:r.args};let s=e.trim(),i=[{op:" + ",type:"ADD"},{op:" - ",type:"SUBTRACT"}],n=-1,o=null;for(let{op:l,type:p}of i){let a=0;for(;a<s.length;){let c=ge(s.substring(a),l);if(c===-1)break;let u=a+c;u>n&&(n=u,o={op:l,type:p}),a=u+l.length}}if(n!==-1)try{return G(s,t)}catch{return{type:g.VARIABLE,path:s}}return{type:g.VARIABLE,path:s}},Rs=/^\w+\(.*\)$/,cl=/\s[+\-*/%]\s|\|\||&&|\?\?|.*\?.*:/,ul=e=>{if(!(!e||e.trim()===""||Rs.test(e))&&cl.test(e))throw e.includes("?")&&e.includes(":")?new L(`Complex expressions not supported in variable replacements - consider calculating the value in your data instead. Offending expression: "${e}"`):e.includes("||")||e.includes("&&")||e.includes("??")?new L(`Logical operators not supported in variable replacements - consider calculating the value in your data instead (operators like ||, &&, ?? are not supported). Offending expression: "${e}"`):new L(`Arithmetic expressions not supported in variable replacements - consider calculating '${e}' in your data instead (expressions with +, -, *, /, % are not supported). Offending expression: "${e}"`)},Ts=e=>{let t=e.trim();if(Rs.test(t))throw new L(`Functions are not supported in path references - path references can only refer to loop variables. Offending expression: "#{${e}}"`);if(t.includes("["))throw new L(`Array indices not supported in path references - use simple variable names or properties. Offending expression: "#{${e}}"`);if(/[+\-*/%]/.test(t))throw new L(`Arithmetic expressions not supported in path references - path references can only refer to loop variables. Offending expression: "#{${e}}"`);if(/\|\||&&/.test(t))throw new L(`Logical operators not supported in path references - path references can only refer to loop variables. Offending expression: "#{${e}}"`);if(t.includes("?")&&t.includes(":"))throw new L(`Complex expressions not supported in path references - path references can only refer to loop variables. Offending expression: "#{${e}}"`);return{type:g.PATH_REFERENCE,path:t}},De=(e,t={})=>{let r=e.trim();ul(r);let s=Ls(r,t);if(s.isFunction)return{type:s.type,name:s.name,args:s.args};if(r.includes("[")&&!/[\s+\-*/%|&?:]/.test(r)){let i=0;for(let n of r)n==="["?i++:n==="]"&&i--;if(i!==0)throw new Error("Invalid array index syntax")}return{type:g.VARIABLE,path:r}},ir=(e,t={})=>{let r=e,s=[];(e.includes("\\${")||e.includes("\\#{"))&&(r=e.replace(/\\\\(\$\{[^}]*\})/g,"\\DOUBLE_ESC_VAR$1"),r=r.replace(/\\\\(#\{[^}]*\})/g,"\\DOUBLE_ESC_PATH$1"),r=r.replace(/\\(\$\{[^}]*\})/g,(a,c)=>{let u=`__ESCAPED_${s.length}__`;return s.push(c),u}),r=r.replace(/\\(#\{[^}]*\})/g,(a,c)=>{let u=`__ESCAPED_${s.length}__`;return s.push(c),u}),r=r.replace(/\\DOUBLE_ESC_VAR/g,"\\"),r=r.replace(/\\DOUBLE_ESC_PATH/g,"\\"));let i=[...r.matchAll(nl)],n=[...r.matchAll(ol)],o=[...i.map(a=>({match:a,type:"variable"})),...n.map(a=>({match:a,type:"pathref"}))].sort((a,c)=>a.match.index-c.match.index);if(o.length===0){let a=r;for(let c=0;c<s.length;c++)a=a.replace(`__ESCAPED_${c}__`,s[c]);return{type:g.LITERAL,value:a}}if(o.length===1&&o[0].match[0]===r&&s.length===0){let{match:a,type:c}=o[0];try{return c==="variable"?De(a[1],t):Ts(a[1])}catch(u){if(u.message==="Invalid array index syntax")return{type:g.LITERAL,value:r};throw u}}let l=[],p=0;for(let{match:a,type:c}of o){let[u,h]=a,f=a.index;if(f>p){let d=r.substring(p,f);for(let y=0;y<s.length;y++)d=d.replace(`__ESCAPED_${y}__`,s[y]);d&&l.push(d)}try{let d;c==="variable"?d=De(h.trim(),t):d=Ts(h.trim()),l.push(d)}catch(d){if(d.message==="Invalid array index syntax")l.push(u);else throw d}p=f+u.length}if(p<r.length){let a=r.substring(p);for(let c=0;c<s.length;c++)a=a.replace(`__ESCAPED_${c}__`,s[c]);a&&l.push(a)}return{type:g.INTERPOLATION,parts:l}};var he=(e,t)=>typeof e=="string"?ir(e,t):typeof e=="object"&&e!==null?Array.isArray(e)?hl(e,t):dl(e,t):{type:g.LITERAL,value:e},hl=(e,t)=>{let r=[],s=!1;for(let i=0;i<e.length;i++){let n=e[i];if(typeof n=="object"&&n!==null&&!Array.isArray(n)){let l=Object.keys(n);if(l.length===1&&l[0].startsWith("$for ")){let p=Ps(l[0],n[l[0]],t);r.push(p),s=!0;continue}}let o=he(n,t);r.push(o),(o.type===g.FUNCTION||o.type===g.CONDITIONAL||o.type===g.LOOP||o.type===g.PARTIAL||o.type===g.OBJECT&&!o.fast||o.type===g.ARRAY&&!o.fast)&&(s=!0)}return{type:g.ARRAY,items:r,fast:!s}},dl=(e,t)=>{let r=[],s=!1,i=null,n=Object.entries(e),o=0;if(e.$partial!==void 0){if(typeof e.$partial!="string")throw new L("$partial value must be a string");if(e.$partial.trim()==="")throw new L("$partial value cannot be an empty string");let p=["$if","$elif","$else","$for"],a=[];for(let[m]of n)for(let w of p)if(m===w||m.startsWith(w+" ")||m.startsWith(w+"#")){a.push(w);break}if(a.length>0)throw new L(`Cannot use $partial with ${a.join(", ")} at the same level. Wrap $partial in a parent object if you need conditionals.`);let{$partial:c,$when:u,...h}=e,f={},d=!1;for(let[m,w]of Object.entries(h)){let _=m;(m.startsWith("\\$")||m.startsWith("$$"))&&(_=m.slice(1)),f[_]=w,d=!0}let y=null;if(d&&(y=he(f,t),y.type===g.OBJECT)){let m=!1;for(let w of y.properties)if(w.value.type===g.VARIABLE||w.value.type===g.INTERPOLATION||w.value.type===g.FUNCTION||w.value.type===g.CONDITIONAL||w.value.type===g.LOOP||w.value.type===g.OBJECT&&!w.value.fast||w.value.type===g.ARRAY&&!w.value.fast){m=!0;break}m&&(y.fast=!1)}let b={type:g.PARTIAL,name:c,data:y};if(u!==void 0){let m;if(typeof u=="string"){if(u.trim()==="")throw new L("Empty condition expression after '$when'");m=G(u,t)}else m={type:g.LITERAL,value:u};b.whenCondition=m}return b}for(let[p,a]of n)if(p==="$when"){if(i!==null)throw new L("Multiple '$when' directives on the same object are not allowed");if(a==null)throw new L("Missing condition expression after '$when'");let c=typeof a=="string"?a:JSON.stringify(a);if(c.trim()==="")throw new L("Empty condition expression after '$when'");i=G(c,t),s=!0}else if(p.startsWith("$when#")||p.startsWith("$when "))throw new L("'$when' does not support ID syntax or inline conditions - use '$when' as a property");for(;o<n.length;){let[p,a]=n[o];if(p==="$when"){o++;continue}if(p.startsWith("$if ")||p.match(/^\$if#\w+\s/)||p.match(/^\$if\s+\w+.*:$/)){let c=fl(n,o,t);r.push({key:p,value:c.node}),s=!0,o=c.nextIndex}else if(p.startsWith("$for ")){let c=Ps(p,a,t);r.push({key:p,value:c}),s=!0,o++}else{if(p.startsWith("$elif ")||p.startsWith("$else"))throw new L(`'${p.split(" ")[0]}' without matching '$if'`);if(p==="$if"||p==="$if:")throw new L("Missing condition expression after '$if'");{let c=he(a,t);(c.type===g.FUNCTION||c.type===g.CONDITIONAL||c.type===g.LOOP||c.type===g.PARTIAL||c.type===g.OBJECT&&!c.fast||c.type===g.ARRAY&&!c.fast)&&(s=!0);let u=ir(p,t),h={key:p,value:c};(u.type!==g.LITERAL||u.value!==p)&&(h.parsedKey=u),r.push(h),o++}}}let l={type:g.OBJECT,properties:r,fast:!s};return i&&(l.whenCondition=i),l},fl=(e,t,r={})=>{let s=[],i=[],n=t,[o,l]=e[n],p=null,a;if(o.startsWith("$if#")){let u=o.match(/^\$if#(\w+)\s+(.+)$/);if(u)p=u[1],a=u[2];else throw new L(`Invalid conditional syntax: ${o}`)}else a=o.substring(4),a.endsWith(":")&&(a=a.slice(0,-1).trim());sr(a);let c=G(a,r);for(s.push(c),i.push(he(l,r)),n++;n<e.length;){let[u,h]=e[n],f=!1,d;if(p?u.startsWith(`$elif#${p} `)?(d=u.substring(`$elif#${p} `.length),d.endsWith(":")&&(d=d.slice(0,-1).trim()),f=!0):(u===`$else#${p}`||u===`$else#${p}:`)&&(f=!0,d=null):u.startsWith("$elif ")?(d=u.substring(6),d.endsWith(":")&&(d=d.slice(0,-1).trim()),f=!0):(u==="$else"||u==="$else:")&&(f=!0,d=null),f){if(d===null)s.push(null);else{sr(d);let y=G(d,r);s.push(y)}if(i.push(he(h,r)),n++,d===null)break}else break}return{node:{type:g.CONDITIONAL,conditions:s,bodies:i,id:p},nextIndex:n}},G=(e,t={})=>{if(e=e.trim(),e.startsWith("(")&&e.endsWith(")")){let a=e.slice(1,-1),c=0,u=!0;for(let h=0;h<a.length;h++)if(a[h]==="("?c++:a[h]===")"&&c--,c<0){u=!1;break}if(u&&c===0)return G(a,t)}let r=ge(e,"||");if(r!==-1)return{type:g.BINARY,op:W.OR,left:G(e.substring(0,r).trim(),t),right:G(e.substring(r+2).trim(),t)};let s=ge(e,"&&");if(s!==-1)return{type:g.BINARY,op:W.AND,left:G(e.substring(0,s).trim(),t),right:G(e.substring(s+2).trim(),t)};let i=[{op:">=",type:W.GTE},{op:"<=",type:W.LTE},{op:"==",type:W.EQ},{op:"!=",type:W.NEQ},{op:">",type:W.GT},{op:"<",type:W.LT},{op:" in ",type:W.IN}];for(let{op:a,type:c}of i){let u=ge(e,a);if(u!==-1)return{type:g.BINARY,op:c,left:G(e.substring(0,u).trim(),t),right:G(e.substring(u+a.length).trim(),t)}}let n=-1,o=null,l=[{op:" + ",type:W.ADD},{op:" - ",type:W.SUBTRACT}];for(let{op:a,type:c}of l){let u=0;for(;u<e.length;){let h=ge(e.substring(u),a);if(h===-1)break;let f=u+h;f>n&&(n=f,o={op:a,type:c}),u=f+a.length}}if(n!==-1&&o)return{type:g.BINARY,op:o.type,left:G(e.substring(0,n).trim(),t),right:G(e.substring(n+o.op.length).trim(),t)};let p=[" * "," / "," % "];for(let a of p)if(ge(e,a)!==-1)throw new L(`Arithmetic operations are not allowed in conditionals: "${a}"`);return e.startsWith("!")?{type:g.UNARY,op:Pe.NOT,operand:G(e.substring(1).trim(),t)}:Ns(e,t)},ge=(e,t)=>{let r=0,s=0;for(;s<=e.length-t.length;){if(e[s]==="(")r++;else if(e[s]===")")r--;else if(r===0&&e.substring(s,s+t.length)===t)return s;s++}return-1},yl=e=>{if(e=e.trim(),e==="true")return{type:g.LITERAL,value:!0};if(e==="false")return{type:g.LITERAL,value:!1};if(e==="null")return{type:g.LITERAL,value:null};if(e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"))return{type:g.LITERAL,value:e.slice(1,-1)};if(e==='""'||e==="''")return{type:g.LITERAL,value:""};if(e==="{}")return{type:g.LITERAL,value:{}};if(e==="[]")return{type:g.LITERAL,value:[]};let t=Number(e);return!isNaN(t)&&isFinite(t)?{type:g.LITERAL,value:t}:{type:g.VARIABLE,path:e}},Ns=(e,t)=>{let r=e.trim();if(r.match(/^(\w+)\((.*)\)$/))return De(r,t);let i=yl(r);if(i.type===g.LITERAL)return i;if(/^[a-zA-Z_$][\w.$]*$/.test(r))return{type:g.VARIABLE,path:r};try{return De(r,t)}catch(n){if(n.message&&n.message.includes("not supported"))return i;throw n}},Ps=(e,t,r)=>{let s=e.substring(5).trim();As(s);let i=s.match(/^(.+?)\s+in\s+(.+)$/);if(!i)throw new L(`Invalid loop syntax - missing 'in' keyword (got: '$for ${s}')`);let n=i[1].trim(),o=i[2].trim(),l,p=null;if(n.includes(",")){let u=n.split(",").map(h=>h.trim());if(u.length!==2)throw new L(`Invalid loop variables: ${n}. Expected format: "item" or "item, index"`);l=u[0],p=u[1]}else l=n;let a=Ns(o,r),c=he(t,r);return{type:g.LOOP,itemVar:l,indexVar:p,iterable:a,body:c}};var ml=(e,t={})=>{let{functions:r={}}=t;return he(e,r)},Xe=ml;var nr={};P(nr,{now:()=>gl});var gl=()=>Date.now();var vl=(e,t,r={})=>{let{functions:s={},partials:i={}}=r,n={...nr,...s},o=Xe(e,{functions:n}),l={};for(let[p,a]of Object.entries(i))l[p]=Xe(a,{functions:n});return Ve(o,t,{functions:n,partials:l})},or=vl;var Qe=e=>Array.isArray(e)?e.reduce((t,r)=>{if(Array.isArray(r))t.push(...Qe(r));else{if(r&&typeof r=="object"){let s=Object.entries(r);if(s.length>0){let[i,n]=s[0];Array.isArray(n)&&(r={[i]:Qe(n)})}}t.push(r)}return t},[]):e;var Vs=(e,t)=>{if(!t)return e;let r=[],s="",i=!1,n=null;for(let o=0;o<t.length;o++){let l=t[o];if(!i&&l===".")s&&(r.push(s),s="");else if(!i&&l==="[")s&&(r.push(s),s=""),i=!0;else if(i&&l==="]"){if(s){if(s.startsWith('"')&&s.endsWith('"')||s.startsWith("'")&&s.endsWith("'"))r.push(s.slice(1,-1));else{let p=Number(s);r.push(isNaN(p)?s:p)}s=""}i=!1,n=null}else i&&(l==='"'||l==="'")&&(n?l===n&&(n=null):n=l),s+=l}return s&&r.push(s),r.reduce((o,l)=>o&&o[l],e)},Ds=({h:e,template:t,viewData:r,refs:s,handlers:i})=>{let n=Ve(t,r,{}),o=Qe(n),l=bl({h:e,items:o,refs:s,handlers:i,viewData:r});return e("div",{style:{display:"contents"}},l)},bl=({h:e,items:t,refs:r={},handlers:s={},viewData:i={}})=>{if(!Array.isArray(t))return console.error("Input to createVirtualDom must be an array."),[e("div",{},[])];function n(o,l=""){return o.map((p,a)=>{if(typeof p=="string"||typeof p=="number")return String(p);if(typeof p!="object"||p===null)return console.warn("Skipping invalid item in DOM structure:",p),null;let c=Object.entries(p);if(c.length===0)return null;let[u,h]=c[0];if(!isNaN(Number(u)))return Array.isArray(h)?n(h,`${l}.${u}`):typeof h=="object"&&h!==null&&Object.entries(h).length>0?n([h],`${l}.${u}`):String(h);c.length>1&&console.warn("Item has multiple keys, processing only the first:",u);let f,d,y=u.indexOf(" ");y===-1?(f=u,d=""):(f=u.substring(0,y),d=u.substring(y+1).trim());let b=f.split(/[.#]/)[0],m=b.includes("-"),w={},_={};if(d){let C=/(\S+?)=(?:\"([^\"]*)\"|\'([^\']*)\'|([^\s]+))/g,A,j=new Set;for(;(A=C.exec(d))!==null;)if(j.add(A[1]),A[1].startsWith(".")){let se=A[1].substring(1),Ce=A[4];_[se]=Vs(i,Ce)}else if(A[1].startsWith("?")){let se=A[1].substring(1),Ce=A[2]||A[3]||A[4],Be;Ce==="true"?Be=!0:Ce==="false"?Be=!1:Be=Vs(i,Ce),Be&&(w[se]="")}else w[A[1]]=A[2]||A[3]||A[4];let F=d,M=[],re,tt=/(\S+?)=(?:\"([^\"]*)\"|\'([^\']*)\'|([^\s]+))/g;for(;(re=tt.exec(d))!==null;)M.push(re[0]);M.forEach(se=>{F=F.replace(se," ")});let rt=/\b(\S+?)(?=\s|$)/g,K;for(;(K=rt.exec(F))!==null;){let se=K[1];!j.has(se)&&!se.startsWith(".")&&!se.includes("=")&&(w[se]="")}}let x=f.match(/#([^.#\s]+)/);x&&!Object.prototype.hasOwnProperty.call(w,"id")&&(w.id=x[1]);let E=null;w.id?E=w.id:m&&(E=b);let $=Object.create(null),O=null;if(m)O=b;else{let C=f.match(/\.([^.#]+)/g);C&&C.forEach(j=>{let F=j.substring(1);$[F]=!0});let A=f.match(/#([^.#\s]+)/);A&&(O=A[1])}let S;typeof h=="string"||typeof h=="number"?S=String(h):Array.isArray(h)?S=n(h,`${l}.${u}`):S=[],O&&!m&&(w.id=O);let N=Object.create(null);if(E&&r){let C=[];if(Object.keys(r).forEach(A=>{if(A.includes("*")){let j="^"+A.replace(/[.*+?^${}()|[\\\]\\]/g,"\\$&").replace(/\\\*/g,".*")+"$";try{new RegExp(j).test(E)&&C.push(A)}catch(F){console.warn(`[Parser] Invalid regex pattern created from refKey '${A}': ${j}`,F)}}else E===A&&C.push(A)}),C.length>0){C.sort((j,F)=>{let M=!j.includes("*"),re=!F.includes("*");return M&&!re?-1:!M&&re?1:F.length-j.length});let A=C[0];if(r[A]&&r[A].eventListeners){let j=r[A].eventListeners;Object.entries(j).forEach(([F,M])=>{if(M.handler&&M.action)throw new Error("Each listener can have hanlder or action but not both");if(M.action){N[F]=re=>{s.handleCallStoreAction({...M.payload,_event:re,_action:M.action})};return}M.handler&&s[M.handler]?N[F]=re=>{s[M.handler]({...M.payload,_event:re})}:M.handler&&console.warn(`[Parser] Handler '${M.handler}' for refKey '${A}' (matching elementId '${E}') is referenced but not found in available handlers.`)})}}}let D={};if(E)D.key=E;else if(f){let C=l?`${l}.${a}`:String(a);if(D.key=`${f}-${C}`,Object.keys(_).length>0){let A=JSON.stringify(_).substring(0,50);D.key+=`-${A}`}}Object.keys(w).length>0&&(D.attrs=w),Object.keys($).length>0&&(D.class=$),Object.keys(N).length>0&&(D.on=N),Object.keys(_).length>0&&(D.props=_),m&&(D.hook={update:(C,A)=>{let j=C.data?.props||{},F=A.data?.props||{},M=C.data?.attrs||{},re=A.data?.attrs||{},tt=JSON.stringify(j)!==JSON.stringify(F),rt=JSON.stringify(M)!==JSON.stringify(re);if(tt||rt){let K=A.elm;K&&K.render&&typeof K.render=="function"&&(K.setAttribute("isDirty","true"),requestAnimationFrame(()=>{if(K.render(),K.removeAttribute("isDirty"),K.handlers&&K.handlers.handleOnUpdate){let se={...K.deps,store:K.store,render:K.render.bind(K),handlers:K.handlers,dispatchEvent:K.dispatchEvent.bind(K),refIds:K.refIds||{},getRefIds:()=>K.refIds||{}};K.handlers.handleOnUpdate(se,{oldProps:j,newProps:F,oldAttrs:M,newAttrs:re})}}))}}});try{return e(b,D,S)}catch(C){return console.error("Error creating virtual node:",C,{tagName:b,snabbdomData:D,childrenOrText:S}),e("div",{},["Error creating element"])}}).filter(Boolean)}return n(t)};var wl=(e,t)=>{if(!t||typeof t!="object")return"";let r="",s=n=>Object.entries(n).map(([o,l])=>` ${o}: ${l};`).join(`
938
+ `))}constructor(){super(),e.initializeStyleSheet(),this.shadow=this.attachShadow({mode:"open"}),this.shadow.adoptedStyleSheets=[e.styleSheet],this._dialogElement=document.createElement("dialog"),this.shadow.appendChild(this._dialogElement),this._dialogElement.addEventListener("click",t=>{t.stopPropagation();let r=t.composedPath();(r[0]===this._dialogElement||r[0].nodeName==="DIALOG"&&r[0]===this._dialogElement)&&this.dispatchEvent(new CustomEvent("close",{detail:{}}))}),this._dialogElement.addEventListener("contextmenu",t=>{let r=t.composedPath();(r[0]===this._dialogElement||r[0].nodeName==="DIALOG"&&r[0]===this._dialogElement)&&(t.preventDefault(),this.dispatchEvent(new CustomEvent("close",{detail:{}})))}),this._dialogElement.addEventListener("cancel",t=>{t.preventDefault(),this.dispatchEvent(new CustomEvent("close",{detail:{}}))}),this._popoverContainer=document.createElement("div"),this._popoverContainer.className="popover-container",this._dialogElement.appendChild(this._popoverContainer),this._slotElement=null,this._isOpen=!1}static get observedAttributes(){return["open","x","y","placement"]}connectedCallback(){this.hasAttribute("open")&&this._show()}disconnectedCallback(){this._isOpen&&this._dialogElement.open&&this._dialogElement.close()}attributeChangedCallback(t,r,s){t==="open"?s!==null&&!this._isOpen?this.isConnected&&this._show():s===null&&this._isOpen&&this._hide():(t==="x"||t==="y"||t==="placement")&&this._isOpen&&this._updatePosition()}_show(){this._isOpen||(this._slotElement||(this._slotElement=document.createElement("slot"),this._slotElement.setAttribute("name","content"),this._popoverContainer.appendChild(this._slotElement)),this._isOpen=!0,this._dialogElement.open||setTimeout(()=>{this._dialogElement&&!this._dialogElement.open&&(this.hasAttribute("no-overlay")?this._dialogElement.show():this._dialogElement.showModal())},0),requestAnimationFrame(()=>{this._updatePosition()}))}_hide(){this._isOpen&&(this._isOpen=!1,this._dialogElement.open&&this._dialogElement.close(),this._slotElement&&(this._popoverContainer.removeChild(this._slotElement),this._slotElement=null))}_updatePosition(){let t=parseFloat(this.getAttribute("x")||"0"),r=parseFloat(this.getAttribute("y")||"0"),s=this.getAttribute("placement")||"bottom-start";this.removeAttribute("positioned"),requestAnimationFrame(()=>{let i=this._popoverContainer.getBoundingClientRect(),{left:n,top:o}=this._calculatePosition(t,r,i.width,i.height,s);this._popoverContainer.style.left=`${n}px`,this._popoverContainer.style.top=`${o}px`,requestAnimationFrame(()=>{this.setAttribute("positioned","")})})}_calculatePosition(t,r,s,i,n){let l=t,p=r;switch(n){case"top":l=t-s/2,p=r-i-8;break;case"top-start":l=t,p=r-i-8;break;case"top-end":l=t-s,p=r-i-8;break;case"right":l=t+8,p=r-i/2;break;case"right-start":l=t+8,p=r;break;case"right-end":l=t+8,p=r-i;break;case"bottom":l=t-s/2,p=r+8;break;case"bottom-start":l=t,p=r+8;break;case"bottom-end":l=t-s,p=r+8;break;case"left":l=t-s-8,p=r-i/2;break;case"left-start":l=t-s-8,p=r;break;case"left-end":l=t-s-8,p=r-i;break}let a=8;return l=Math.max(a,Math.min(l,window.innerWidth-s-a)),p=Math.max(a,Math.min(p,window.innerHeight-i-a)),{left:l,top:p}}get popover(){return this._popoverContainer}},Tr=({render:e,html:t})=>dt;var ft={};P(ft,{handleClickItem:()=>fi});var fi=(e,t)=>{let{dispatchEvent:r}=e,i=t._event.currentTarget.dataset.id;r(new CustomEvent("item-click",{detail:{id:i}}))};var yt={};P(yt,{createInitialState:()=>yi,selectViewData:()=>vi});var yi=()=>Object.freeze({}),mi=["id","class","style","slot"],gi=e=>Object.entries(e).filter(([t])=>!mi.includes(t)).map(([t,r])=>`${t}=${r}`).join(" "),vi=({props:e,attrs:t})=>{let r=gi(t),s=e.items||[],i=e.separator||"breadcrumb-arrow",n=[];return s.forEach((o,l)=>{n.push(o),l<s.length-1&&n.push({isSeparator:!0})}),{containerAttrString:r,items:n,separator:i}};var Lr={elementName:"rtgl-breadcrumb",viewDataSchema:{type:"object",properties:{containerAttrString:{type:"string"},items:{type:"array",items:{type:"object",properties:{label:{type:"string"},id:{type:"string"}}}},separator:{type:"string"}}},propsSchema:{type:"object",properties:{items:{type:"array",items:{type:"object",properties:{label:{type:"string"},id:{type:"string"}}}},separator:{type:"string",default:"breadcrumb-arrow"}}},refs:{"item-*":{eventListeners:{click:{handler:"handleClickItem"}}}},events:{"item-click":{type:"object",properties:{item:{type:"object",properties:{label:{type:"string"},id:{type:"string"}}},index:{type:"number"}}}},template:{type:9,items:[{type:8,properties:[{key:"rtgl-view d=h av=c g=md p=sm ${containerAttrString}",value:{type:9,items:[{type:7,itemVar:"item",indexVar:null,iterable:{type:1,path:"items"},body:{type:9,items:[{type:8,properties:[{key:"$if item.isSeparator",value:{type:6,conditions:[{type:1,path:"item.isSeparator"},{type:1,path:"item.id"},null],bodies:[{type:9,items:[{type:8,properties:[{key:"rtgl-svg wh=16 svg=${separator} c=mu-fg",value:{type:0,value:null},parsedKey:{type:2,parts:["rtgl-svg wh=16 svg=",{type:1,path:"separator"}," c=mu-fg"]}}],fast:!0}],fast:!0},{type:9,items:[{type:8,properties:[{key:"rtgl-view#item-${item.id} data-id=${item.id} cur=p",value:{type:9,items:[{type:8,properties:[{key:"rtgl-text s=sm c=mu-fg",value:{type:1,path:"item.label"}}],fast:!0}],fast:!0},parsedKey:{type:2,parts:["rtgl-view#item-",{type:1,path:"item.id"}," data-id=",{type:1,path:"item.id"}," cur=p"]}}],fast:!0}],fast:!0},{type:9,items:[{type:8,properties:[{key:"rtgl-text s=sm c=mu-fg",value:{type:1,path:"item.label"}}],fast:!0}],fast:!0}],id:null}}],fast:!1}],fast:!1}}],fast:!1},parsedKey:{type:2,parts:["rtgl-view d=h av=c g=md p=sm ",{type:1,path:"containerAttrString"}]}}],fast:!1}],fast:!1}};var mt={};P(mt,{handleClickMenuItem:()=>wi,handleClosePopover:()=>bi});var bi=(e,t)=>{let{dispatchEvent:r}=e;r(new CustomEvent("close"))},wi=(e,t)=>{let{dispatchEvent:r,props:s}=e,i=t._event,n=parseInt(i.currentTarget.id.replace("option-","")),o=s.items[n];r(new CustomEvent("click-item",{detail:{index:n,item:o}}))};var gt={};P(gt,{createInitialState:()=>_i,selectViewData:()=>xi});var _i=()=>Object.freeze({}),xi=({props:e,attrs:t})=>({items:e.items||[],open:!!t.open,x:t.x,y:t.y,placement:t.placement});var Rr={elementName:"rtgl-dropdown-menu",viewDataSchema:{type:"object"},propsSchema:{type:"object",properties:{items:{type:"array",items:{type:"object",properties:{label:{type:"string"},type:{type:"string",enum:["label","item","separator"]}}}}}},attrsSchema:{type:"object",properties:{open:{type:"string"},x:{type:"string"},y:{type:"string"},placement:{type:"string"}}},refs:{popover:{eventListeners:{close:{handler:"handleClosePopover"}}},"option-*":{eventListeners:{click:{handler:"handleClickMenuItem"}}}},template:{type:9,items:[{type:8,properties:[{key:"rtgl-popover#popover ?open=${open} x=${x} y=${y} placement=${placement}",value:{type:9,items:[{type:8,properties:[{key:"rtgl-view wh=300 sv g=xs slot=content bgc=background br=md",value:{type:9,items:[{type:7,itemVar:"item",indexVar:"i",iterable:{type:1,path:"items"},body:{type:9,items:[{type:8,properties:[{key:"$if item.type == 'label'",value:{type:6,conditions:[{type:4,op:0,left:{type:1,path:"item.type"},right:{type:0,value:"label"}},{type:4,op:0,left:{type:1,path:"item.type"},right:{type:0,value:"item"}},{type:4,op:0,left:{type:1,path:"item.type"},right:{type:0,value:"separator"}}],bodies:[{type:9,items:[{type:8,properties:[{key:"rtgl-view w=f ph=lg pv=md",value:{type:9,items:[{type:8,properties:[{key:"rtgl-text s=sm c=mu-fg",value:{type:1,path:"item.label"}}],fast:!0}],fast:!0}}],fast:!0}],fast:!0},{type:9,items:[{type:8,properties:[{key:"rtgl-view#option-${i} w=f h-bgc=ac ph=lg pv=md cur=p br=md bgc=mu",value:{type:9,items:[{type:8,properties:[{key:"rtgl-text",value:{type:1,path:"item.label"}}],fast:!0}],fast:!0},parsedKey:{type:2,parts:["rtgl-view#option-",{type:1,path:"i"}," w=f h-bgc=ac ph=lg pv=md cur=p br=md bgc=mu"]}}],fast:!0}],fast:!0},{type:9,items:[{type:8,properties:[{key:"rtgl-view w=f h=1 ph=lg mv=md bgc=bo",value:{type:0,value:null}}],fast:!0}],fast:!0}],id:null}}],fast:!1}],fast:!1}}],fast:!1}}],fast:!1}],fast:!1},parsedKey:{type:2,parts:["rtgl-popover#popover ?open=",{type:1,path:"open"}," x=",{type:1,path:"x"}," y=",{type:1,path:"y"}," placement=",{type:1,path:"placement"}]}}],fast:!1}],fast:!1}};var vt={};P(vt,{handleActionClick:()=>$i,handleAfterMount:()=>Ei,handleBeforeMount:()=>Ai,handleColorPickerChange:()=>Oi,handleImageClick:()=>Li,handleInputChange:()=>Si,handleOnUpdate:()=>ki,handleSelectAddOption:()=>Ni,handleSelectChange:()=>Ci,handleSliderChange:()=>Ii,handleSliderInputChange:()=>Ti,handleTooltipMouseEnter:()=>Pi,handleTooltipMouseLeave:()=>Vi,handleWaveformClick:()=>Ri});var Nr=({form:e,defaultValues:t={},refs:r})=>{let{fields:s=[]}=e;s.forEach(i=>{let n=r[`field-${i.name}`]?.elm;if(n){if(["inputText","colorPicker","slider","slider-input","popover-input"].includes(i.inputType)){let o=t[i.name];o==null?n.removeAttribute("value"):n.setAttribute("value",o)}if(i.inputType==="inputText"&&i.placeholder&&n.getAttribute("placeholder")!==i.placeholder&&(i.placeholder===void 0||i.placeholder===null?n.removeAttribute("placeholder"):n.setAttribute("placeholder",i.placeholder)),i.inputType==="select"&&i.placeholder&&n.placeholder!==i.placeholder&&(n.placeholder=i.placeholder),i.inputType==="select"){i.placeholder!==n.getAttribute("placeholder")&&(i.placeholder!==void 0?n.setAttribute("placeholder",i.placeholder):n.removeAttribute("placeholder"),n.render());let o=t[i.name];o!==n.selectedValue&&(n.selectedValue=o,n.render())}}})},Ai=e=>{let{store:t,props:r}=e;t.setFormValues(r.defaultValues)},Ei=e=>{let{props:t,getRefIds:r,render:s}=e,{form:i={},defaultValues:n}=t,o=r();Nr({form:i,defaultValues:n,refs:o}),s()},ki=(e,t)=>{let{oldAttrs:r,newAttrs:s,newProps:i}=t,{store:n,render:o,getRefIds:l}=e,{form:p={},defaultValues:a}=i;if(r?.key!==s?.key){let c=l();Nr({form:p,defaultValues:a,refs:c}),n.setFormValues(a),o();return}o()},Ie=(e,t,r,s)=>{s(new CustomEvent("form-change",{detail:{name:e,fieldValue:t,formValues:r}}))},$i=(e,t)=>{let{store:r,dispatchEvent:s}=e,n=t._event.currentTarget.id.replace("action-","");s(new CustomEvent("action-click",{detail:{actionId:n,formValues:r.selectFormValues()}}))},Si=(e,t)=>{let{store:r,dispatchEvent:s,props:i}=e,n=t._event,o=n.currentTarget.id.replace("field-","");o&&n.detail.value!==void 0&&(r.setFormFieldValue({name:o,value:n.detail.value,props:i}),Ie(o,n.detail.value,r.selectFormValues(),s))},Ci=(e,t)=>{let{store:r,dispatchEvent:s,render:i,props:n}=e,o=t._event,l=o.currentTarget.id.replace("field-","");l&&(r.setFormFieldValue({name:l,value:o.detail.selectedValue,props:n}),Ie(l,o.detail.selectedValue,r.selectFormValues(),s),i())},Oi=(e,t)=>{let{store:r,dispatchEvent:s,props:i}=e,n=t._event,o=n.currentTarget.id.replace("field-","");o&&n.detail.value!==void 0&&(r.setFormFieldValue({name:o,value:n.detail.value,props:i}),Ie(o,n.detail.value,r.selectFormValues(),s))},Ii=(e,t)=>{let{store:r,dispatchEvent:s,props:i}=e,n=t._event,o=n.currentTarget.id.replace("field-","");o&&n.detail.value!==void 0&&(r.setFormFieldValue({name:o,value:n.detail.value,props:i}),Ie(o,n.detail.value,r.selectFormValues(),s))},Ti=(e,t)=>{let{store:r,dispatchEvent:s,props:i}=e,n=t._event,o=n.currentTarget.id.replace("field-","");o&&n.detail.value!==void 0&&(r.setFormFieldValue({name:o,value:n.detail.value,props:i}),Ie(o,n.detail.value,r.selectFormValues(),s))},Li=(e,t)=>{let r=t._event;r.type==="contextmenu"&&r.preventDefault();let{dispatchEvent:s}=e,i=r.currentTarget.id.replace("image-","");s(new CustomEvent("extra-event",{detail:{name:i,x:r.clientX,y:r.clientY,trigger:r.type}}))},Ri=(e,t)=>{let r=t._event;r.type==="contextmenu"&&r.preventDefault();let{dispatchEvent:s}=e,i=r.currentTarget.id.replace("waveform-","");s(new CustomEvent("extra-event",{detail:{name:i,x:r.clientX,y:r.clientY,trigger:r.type}}))},Ni=(e,t)=>{let{store:r,dispatchEvent:s}=e,n=t._event.currentTarget.id.replace("field-","");s(new CustomEvent("action-click",{detail:{actionId:"select-options-add",name:n,formValues:r.selectFormValues()}}))},Pi=(e,t)=>{let{store:r,render:s,props:i}=e,n=t._event,o=n.currentTarget.id.replace("tooltip-icon-",""),p=i.form.fields.find(a=>a.name===o);if(p&&p.tooltip){let a=n.currentTarget.getBoundingClientRect();r.showTooltip({x:a.left+a.width/2,y:a.top-8,content:p.tooltip.content}),s()}},Vi=e=>{let{store:t,render:r}=e;t.hideTooltip(),r()};var Et={};P(Et,{createInitialState:()=>yn,getFormFieldValue:()=>xn,hideTooltip:()=>$n,selectForm:()=>Ue,selectFormValues:()=>_n,selectState:()=>wn,selectViewData:()=>bn,setFormFieldValue:()=>En,setFormValues:()=>An,showTooltip:()=>kn});var v={LITERAL:0,VARIABLE:1,INTERPOLATION:2,FUNCTION:3,BINARY:4,UNARY:5,CONDITIONAL:6,LOOP:7,OBJECT:8,ARRAY:9,PARTIAL:10,PATH_REFERENCE:11},B={EQ:0,NEQ:1,GT:2,LT:3,GTE:4,LTE:5,AND:6,OR:7,IN:8,ADD:10,SUBTRACT:11},Te={NOT:0};var k=class extends Error{constructor(t){super(`Parse Error: ${t}`),this.name="JemplParseError"}},X=class extends Error{constructor(t){super(`Render Error: ${t}`),this.name="JemplRenderError"}};var bt=e=>{if(!e||e.trim()==="")throw new k("Missing condition expression after '$if'");if(e.includes("===")||e.includes("!==")){let r=e.includes("===")?"==":"!=";throw new k(`Invalid comparison operator '${e.includes("===")?"===":"!=="}' - did you mean '${r}'? (got: '${e}')`)}let t=["<",">","<=",">=","==","!="];for(let r of t)if(e.trim().endsWith(r))throw new k(`Incomplete comparison expression - missing right operand (got: '${e}')`)},Pr=e=>{if(e.trim().endsWith(" in"))throw new k(`Missing iterable expression after 'in' (got: '$for ${e}')`);if(!e.includes(" in "))throw new k(`Invalid loop syntax - missing 'in' keyword (got: '$for ${e}')`);let[t,r]=e.split(" in ");if(!r||r.trim()==="")throw new k(`Missing iterable expression after 'in' (got: '$for ${e}')`);let s=t.includes(",")?t.split(",").map(i=>i.trim()):[t.trim()];for(let i of s){if(!i)throw new k(`Invalid loop variable - variable name cannot be empty (got: '$for ${e}')`);if(!/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(i))throw new k(`Invalid loop syntax (got: '$for ${e}')`)}};var Vr=(e,t,r=!1)=>{if(t===null)return new X(`Cannot iterate over null value at '$for ${e}'`);if(t===void 0)return new X(`Cannot iterate over undefined value at '$for ${e}'`);let s=typeof t;return r?new X(`Cannot iterate over non-array value in loop '${e}' - got ${s} instead`):new X(`Cannot iterate over non-array value (got: ${s}) at '$for ${e}'`)},Dr=(e,t)=>{let r=t&&Object.keys(t).length>0?Object.keys(t).join(", "):"no custom functions provided";return new X(`Unknown function '${e}' (${r})`)};var Di=(e,t,r={})=>{let s={},i={};r&&typeof r=="object"&&(r.functions!==void 0||r.partials!==void 0?(s=r.functions||{},i=r.partials||{}):typeof r=="object"&&(s=r));let o=I(e,{functions:s,partials:i},t,{});return o===void 0?{}:o},I=(e,t,r,s)=>{let i=t.functions||t;if(e.var&&!e.type)return z(e.var,r,s);if(e.type===v.LITERAL)return e.value;if(e.type===v.VARIABLE)return z(e.path,r,s);if(e.type===v.INTERPOLATION)return Bi(e.parts,t,r,s);switch(e.type){case v.FUNCTION:return Br(e,t,r,s);case v.BINARY:return Wr(e,t,r,s);case v.UNARY:return Mr(e,t,r,s);case v.CONDITIONAL:return Mi(e,t,r,s);case v.LOOP:return Hi(e,t,r,s);case v.OBJECT:return qi(e,t,r,s);case v.ARRAY:return Yi(e,t,r,s);case v.PARTIAL:return Gi(e,t,r,s);case v.PATH_REFERENCE:return Xi(e,t,r,s);default:throw new Error(`Unknown node type: ${e.type}`)}},jr=new Map,ji=e=>{let t=[],r="",s=!1;for(let i=0;i<e.length;i++){let n=e[i];if(n==="[")r&&(t.push({type:"property",value:r}),r=""),s=!0;else if(n==="]"){if(s&&r){let o=r.trim();if(/^\d+$/.test(o))t.push({type:"index",value:parseInt(o,10)});else if(o.startsWith('"')&&o.endsWith('"')||o.startsWith("'")&&o.endsWith("'")){let l=o.slice(1,-1);t.push({type:"property",value:l})}else t.push({type:"property",value:o});r=""}s=!1}else r+=n}return r&&t.push({type:"property",value:r}),t},z=(e,t,r)=>{if(!e)return;if(e in r)return r[e];let s=jr.get(e);if(!s){let n=[],o="",l=0;for(let p=0;p<e.length;p++){let a=e[p];a==="["?(l++,o+=a):a==="]"?(l--,o+=a):a==="."&&l===0?o&&(n.push(o),o=""):o+=a}o&&n.push(o),s=[];for(let p of n){let a=ji(p.trim());s.push(...a)}jr.set(e,s)}let i=t;for(let n=0;n<s.length;n++){let o=s[n];if(o.type==="property"&&o.value in r){i=r[o.value];continue}if(i==null)return;(o.type==="property"||o.type==="index")&&(i=i[o.value])}return i},Bi=(e,t,r,s)=>{let i=[];for(let n of e)if(typeof n=="string")i.push(n);else{let o=I(n,t,r,s);i.push(o!=null?String(o):"")}return i.join("")},Br=(e,t,r,s)=>{let i=t.functions||t,n=i[e.name];if(!n)throw Dr(e.name,i);let o=e.args.map(l=>I(l,t,r,s));return n(...o)},xe=(e,t,r,s)=>{if(e.var&&!e.type)return z(e.var,r,s);switch(e.type){case v.VARIABLE:return z(e.path,r,s);case v.LITERAL:return e.value;case v.BINARY:return Wr(e,t,r,s);case v.UNARY:return Mr(e,t,r,s);case v.FUNCTION:return Br(e,t,r,s);default:return I(e,t,r,s)}},Wr=(e,t,r,s)=>{if(e.op===B.AND||e.op===B.OR){let o=xe(e.left,t,r,s),l=xe(e.right,t,r,s);switch(e.op){case B.AND:return o&&l;case B.OR:return o||l}}let i=I(e.left,t,r,s),n=I(e.right,t,r,s);switch(e.op){case B.EQ:return i==n;case B.NEQ:return i!=n;case B.GT:return i>n;case B.LT:return i<n;case B.GTE:return i>=n;case B.LTE:return i<=n;case B.IN:return Array.isArray(n)?n.includes(i):!1;case B.ADD:if(typeof i!="number"||typeof n!="number")throw new X(`Arithmetic operations require numbers. Got ${typeof i} + ${typeof n}`);return i+n;case B.SUBTRACT:if(typeof i!="number"||typeof n!="number")throw new X(`Arithmetic operations require numbers. Got ${typeof i} - ${typeof n}`);return i-n;default:throw new Error(`Unknown binary operator: ${e.op}`)}},Mr=(e,t,r,s)=>{let i=e.op===Te.NOT?xe(e.operand,t,r,s):I(e.operand,t,r,s);switch(e.op){case Te.NOT:return!i;default:throw new Error(`Unknown unary operator: ${e.op}`)}},Wi=(e,t,r,s)=>{if(e.conditions.length===2&&e.conditions[1]===null){let i=e.conditions[0];if(i.type===v.VARIABLE)if(z(i.path,r,s)){let o=e.bodies[0];if(o.type===v.OBJECT&&o.properties.length<=5){let l={};for(let p of o.properties){let a=p.parsedKey?I(p.parsedKey,t,r,s):p.key,c=p.value;if(c.type===v.LITERAL)l[a]=c.value;else if(c.type===v.VARIABLE)l[a]=z(c.path,r,s);else if(c.type===v.INTERPOLATION){let u=[];for(let h of c.parts)if(typeof h=="string")u.push(h);else if(h.type===v.VARIABLE){let f=z(h.path,r,s);u.push(f!=null?String(f):"")}else{let f=I(h,t,r,s);u.push(f!=null?String(f):"")}l[a]=u.join("")}else l[a]=I(c,t,r,s)}return l}}else{let o=e.bodies[1];if(o.type===v.OBJECT&&o.properties.length<=5){let l={};for(let p of o.properties){let a=p.parsedKey?I(p.parsedKey,t,r,s):p.key,c=p.value;if(c.type===v.LITERAL)l[a]=c.value;else if(c.type===v.VARIABLE)l[a]=z(c.path,r,s);else if(c.type===v.INTERPOLATION){let u=[];for(let h of c.parts)if(typeof h=="string")u.push(h);else if(h.type===v.VARIABLE){let f=z(h.path,r,s);u.push(f!=null?String(f):"")}else{let f=I(h,t,r,s);u.push(f!=null?String(f):"")}l[a]=u.join("")}else l[a]=I(c,t,r,s)}return l}}}return null},Mi=(e,t,r,s)=>{let i=Wi(e,t,r,s);if(i!==null)return i;for(let n=0;n<e.conditions.length;n++){let o=e.conditions[n];if(o===null||xe(o,t,r,s))return I(e.bodies[n],t,r,s)}return Fr},Fi=(e,t)=>{let r=e.body,s=e.itemVar;if(r.type===v.CONDITIONAL&&r.conditions.length===1&&r.conditions[0].type===v.VARIABLE){let i=r.conditions[0].path,n=r.bodies[0];if(i.startsWith(s+".")){let o=i.substring(s.length+1);if(n.type===v.OBJECT&&n.properties.length<=5){for(let p of n.properties)if(p.parsedKey)return null;let l=[];for(let p=0;p<t.length;p++){let a=t[p];if(a[o]){let c={};for(let u of n.properties){let h=u.key,f=u.value;if(f.type===v.LITERAL)c[h]=f.value;else if(f.type===v.VARIABLE){let d=f.path;if(d===s)c[h]=a;else if(d.startsWith(s+".")){let y=d.substring(s.length+1);c[h]=a[y]}else return null}else if(f.type===v.INTERPOLATION){let d=[],y=!0;for(let b of f.parts)if(typeof b=="string")d.push(b);else if(b.type===v.VARIABLE){let m=b.path;if(m===s)d.push(a!=null?String(a):"");else if(m.startsWith(s+".")){let w=m.substring(s.length+1),_=a[w];d.push(_!=null?String(_):"")}else{y=!1;break}}else{y=!1;break}if(!y)return null;c[h]=d.join("")}else return null}l.push(c)}}return l}}}return null},Ui=(e,t)=>{let r=e.body,s=e.itemVar,i=Fi(e,t);if(i!==null)return i;if(r.type===v.OBJECT&&r.properties.length<=5&&!r.whenCondition){for(let l of r.properties)if(l.parsedKey)return null;let n=[],o=!0;for(let l of r.properties){let p=l.key,a=l.value;if(a.type===v.LITERAL)n.push({key:p,type:"literal",value:a.value});else if(a.type===v.VARIABLE){let c=a.path;if(c===s)n.push({key:p,type:"item"});else if(c.startsWith(s+".")){let u=c.substring(s.length+1);if(!u.includes(".")&&!u.includes("["))n.push({key:p,type:"prop",prop:u});else{o=!1;break}}else{o=!1;break}}else if(a.type===v.INTERPOLATION&&a.parts.length===1){let c=a.parts[0];if(c.type===v.VARIABLE){let u=c.path;if(u===s)n.push({key:p,type:"item_string"});else if(u.startsWith(s+".")){let h=u.substring(s.length+1);if(!h.includes(".")&&!h.includes("["))n.push({key:p,type:"prop_string",prop:h});else{o=!1;break}}else{o=!1;break}}else{o=!1;break}}else{o=!1;break}}if(o){let l=new Array(t.length);if(n.length===3&&n[0].type==="prop"&&n[0].key==="id"&&n[1].type==="prop_string"&&n[1].key==="title"&&n[2].type==="prop"&&n[2].key==="completed")for(let p=0;p<t.length;p++){let a=t[p];l[p]={id:a.id,title:a.title!=null?String(a.title):"",completed:a.completed}}else for(let p=0;p<t.length;p++){let a=t[p],c={};for(let u of n)if(u.type==="literal")c[u.key]=u.value;else if(u.type==="item")c[u.key]=a;else if(u.type==="prop")c[u.key]=a[u.prop];else if(u.type==="item_string")c[u.key]=a!=null?String(a):"";else if(u.type==="prop_string"){let h=a[u.prop];c[u.key]=h!=null?String(h):""}l[p]=c}return l}}return null},Ki=(e,t,r,s,i)=>{let n=[],o=e.body;if(o.type===v.OBJECT&&o.fast!==!1){let l=e.itemVar,p=e.indexVar;for(let a=0;a<i.length;a++){let c=i[a],u={},h={...s,[l]:c,...p&&{[p]:a}};h.__paths__||(h.__paths__=s.__paths__||{});let f=e.iterable.path||"";if(s&&s.__paths__&&f){let d=f.split("."),y=d[0];y in s.__paths__&&(f=s.__paths__[y],d.length>1&&(f+="."+d.slice(1).join(".")))}h.__paths__={...h.__paths__,[l]:`${f}[${a}]`,...p&&{[p]:a}};for(let d of o.properties){let y=d.parsedKey?I(d.parsedKey,t,r,h):d.key,b=d.value;if(b.type===v.LITERAL)u[y]=b.value;else if(b.type===v.VARIABLE){let m=b.path;if(m===l)u[y]=c;else if(m===p)u[y]=a;else if(m.startsWith(l+".")){let w=m.substring(l.length+1);!w.includes(".")&&!w.includes("[")?u[y]=c[w]:u[y]=z(m,r,{...s,[l]:c,...p&&{[p]:a}})}else u[y]=z(m,r,{...s,[l]:c,...p&&{[p]:a}})}else if(b.type===v.INTERPOLATION){let m=[];for(let w of b.parts)if(typeof w=="string")m.push(w);else if(w.type===v.VARIABLE){let _=w.path,x;if(_===l)x=c;else if(_===p)x=a;else if(_.startsWith(l+".")){let E=_.substring(l.length+1);!E.includes(".")&&!E.includes("[")?x=c[E]:x=z(_,r,{...s,[l]:c,...p&&{[p]:a}})}else x=z(_,r,{...s,[l]:c,...p&&{[p]:a}});m.push(x!=null?String(x):"")}else{let _={...s,[l]:c,...p&&{[p]:a}},x=I(w,t,r,_);m.push(x!=null?String(x):"")}u[y]=m.join("")}else{let m={...s,[l]:c,...p&&{[p]:a}};u[y]=I(b,t,r,m)}}n.push(u)}return n}return null},zi=(e,t,r)=>{let s=e.body;if(s.type===v.OBJECT&&s.properties.length===1&&s.properties[0].key==="$if item.visible"){let n=s.properties[0].value;if(n.type===v.CONDITIONAL&&n.conditions.length===1&&n.conditions[0].type===v.VARIABLE&&n.conditions[0].path==="item.visible"){let o=n.bodies[0];if(o.type===v.OBJECT&&o.properties.length===2){let l=o.properties[0],p=o.properties[1];if(l.key==="id"&&l.value.type===v.VARIABLE&&l.value.path==="item.id"&&p.key==="$if item.highlighted"&&p.value.type===v.CONDITIONAL){let a=[];for(let c=0;c<t.length;c++){let u=t[c];if(u.visible){let h={id:u.id};u.highlighted?(h.highlight=!0,h.message=`This item is highlighted: ${u.name}`):(h.highlight=!1,h.message=u.name),a.push(h)}}return a}}}}return null},Hi=(e,t,r,s)=>{let i=I(e.iterable,t,r,s);if(!Array.isArray(i)){let a,c=!1;if(e.iterable.type===v.FUNCTION){c=!0;let h=e.iterable.args.map(f=>f.type===v.LITERAL?typeof f.value=="string"?`'${f.value}'`:String(f.value):f.type===v.VARIABLE?f.path:f.type===v.FUNCTION?`${f.name}(...)`:"?").join(", ");a=`${e.iterable.name}(${h})`}else a=e.iterable.path||"undefined";let u=`${e.itemVar}${e.indexVar?`, ${e.indexVar}`:""} in ${a}`;throw Vr(u,i,c)}if(!e.indexVar){let a=zi(e,i,e.itemVar);if(a!==null)return a}if(!e.indexVar){let a=Ui(e,i);if(a!==null)return a}let n=Ki(e,t,r,s,i);if(n!==null)return n;let o=[],l=e.iterable.path||"";if(s&&s.__paths__&&l){let a=l.split("."),c=a[0];c in s.__paths__&&(l=s.__paths__[c],a.length>1&&(l+="."+a.slice(1).join(".")))}let p=!1;e.body.type===v.ARRAY&&(e.body.items.length<=1?p=!1:p=e.body._shouldPreserveArray??=e.body.items.some(a=>a.type===v.OBJECT&&a.properties.some(c=>c.key.startsWith("$if ")||c.key.startsWith("$when "))));for(let a=0;a<i.length;a++){let c=e.indexVar?{...s,[e.itemVar]:i[a],[e.indexVar]:a}:{...s,[e.itemVar]:i[a]};c.__paths__||(c.__paths__=s.__paths__||{}),c.__paths__={...c.__paths__,[e.itemVar]:`${l}[${a}]`},e.indexVar&&(c.__paths__[e.indexVar]=a);let u=I(e.body,t,r,c);if(Array.isArray(u)&&u.length===1&&!p){let h=u[0];o.push(h===void 0?{}:h)}else o.push(u===void 0?{}:u)}return o},Ji=(e,t,r,s)=>{if(e.whenCondition)return null;if(e.properties.length===1){let i=e.properties[0],n=i.parsedKey?I(i.parsedKey,t,r,s):i.key,o=i.value;if(o.type===v.OBJECT&&o.properties.length<=10&&!o.whenCondition){let l={},p={},a=!0;for(let c of o.properties){let u=c.parsedKey?I(c.parsedKey,t,r,s):c.key,h=c.value;if(h.type===v.LITERAL)p[u]=h.value;else if(h.type===v.VARIABLE)p[u]=z(h.path,r,s);else if(h.type===v.INTERPOLATION){let f=[];for(let d of h.parts)if(typeof d=="string")f.push(d);else if(d.type===v.VARIABLE){let y=z(d.path,r,s);f.push(y!=null?String(y):"")}else{a=!1;break}if(!a)break;p[u]=f.join("")}else if(h.type===v.OBJECT&&h.properties.length<=5){let f={};for(let d of h.properties){let y=d.key,b=d.value;if(b.type===v.LITERAL)f[y]=b.value;else if(b.type===v.VARIABLE)f[y]=z(b.path,r,s);else if(b.type===v.INTERPOLATION){let m=[];for(let w of b.parts)if(typeof w=="string")m.push(w);else if(w.type===v.VARIABLE){let _=z(w.path,r,s);m.push(_!=null?String(_):"")}else{a=!1;break}if(!a)break;f[y]=m.join("")}else{a=!1;break}}if(!a)break;p[u]=f}else{a=!1;break}}if(a)return l[n]=p,l}}return null},qi=(e,t,r,s)=>{let i=t.functions||t;if(e.whenCondition&&!xe(e.whenCondition,i,r,s))return;let n=Ji(e,t,r,s);if(n!==null)return n;if(e.fast){let a={};for(let c of e.properties){let u=c.parsedKey?I(c.parsedKey,t,r,s):c.key,h=c.value;if(h.type===v.LITERAL)a[u]=h.value;else if(h.type===v.VARIABLE)a[u]=z(h.path,r,s);else if(h.type===v.INTERPOLATION){let f=[];for(let d of h.parts)if(typeof d=="string")f.push(d);else if(d.type===v.VARIABLE){let y=z(d.path,r,s);f.push(y!=null?String(y):"")}else{let y=I(d,t,r,s);f.push(y!=null?String(y):"")}a[u]=f.join("")}else a[u]=I(h,t,r,s)}return a}let o={},l=null,p=!1;for(let a of e.properties)if(!a.key.startsWith("$if ")&&!a.key.match(/^\$if\s+\w+.*:?$/)&&!a.key.startsWith("$elif")&&!a.key.startsWith("$else")&&!a.key.startsWith("$for ")){p=!0;break}for(let a of e.properties)if(a.key.startsWith("$if ")||a.key.match(/^\$if\s+\w+.*:?$/)){let c=I(a.value,t,r,s);if(!p&&c!==null&&c!==void 0)return Array.isArray(c)&&c.length===1?c[0]:c;typeof c=="object"&&c!==null&&!Array.isArray(c)&&Object.assign(o,c)}else if(a.key.startsWith("$for ")){if(e.properties.length===1)return I(a.value,t,r,s)}else{let c=a.value;if(c&&c.type===v.OBJECT&&c.properties){let u=c.properties.find(h=>h.key.startsWith("$for "));if(u){let h=I(u.value,t,r,s);h!==void 0&&(o[a.key]=h)}else{let h=I(a.value,t,r,s);h!==void 0&&(o[a.key]=h)}}else{let u=a.parsedKey?I(a.parsedKey,t,r,s):a.key,h=I(a.value,t,r,s);h!==void 0&&(o[u]=h)}}return o},Fr={},Yi=(e,t,r,s)=>{let i=[];for(let n of e.items)if(n.type===v.LOOP){let o=I(n,t,r,s);Array.isArray(o)&&n.flatten!==!1?i.push(...o):i.push(o)}else{let o=I(n,t,r,s);o!==Fr&&o!==void 0&&i.push(o)}return i},Gi=(e,t,r,s)=>{let{name:i,data:n,whenCondition:o}=e,l=t.partials||{},p=t.functions||t;if(o&&!xe(o,p,r,s))return;if(!l[i])throw new X(`Partial '${i}' is not defined`);let a=s._partialStack||[];if(a.includes(i))throw new X(`Circular partial reference detected: ${i}`);let c=l[i],u=r,h={...s,_partialStack:[...a,i]};if(s){u={...r};for(let f of Object.keys(s))f.startsWith("_")||(u[f]=s[f])}if(n){let f=I(n,t,r,s);u={...u,...f}}return I(c,t,u,h)},Xi=(e,t,r,s)=>{let{path:i}=e,n=i.split("."),o=n[0],l=n.slice(1);if(!s||!(o in s))throw new X(`Path reference '#{${i}}' refers to '${o}' which is not a loop variable in the current scope`);if(s.__paths__||(s.__paths__={}),!(o in s.__paths__))throw new X(`Path reference '#{${i}}' cannot be resolved - path tracking may not be initialized properly`);let p=s.__paths__[o];if(typeof p=="number"){if(l.length>0)throw new X(`Path reference '#{${i}}' - cannot access properties on index variable '${o}'`);return String(p)}return l.length>0&&(p+="."+l.join(".")),p},wt=Di;var Qi=/\$\{([^}]*)\}/g,Zi=/#\{([^}]*)\}/g,Kr=(e,t={})=>{let r=e.match(/^(\w+)\((.*)\)$/);if(!r)return{isFunction:!1};let[,s,i]=r,n=en(i,t);return{isFunction:!0,type:v.FUNCTION,name:s,args:n}},en=(e,t={})=>e.trim()?tn(e).map(s=>rn(s.trim(),t)):[],tn=e=>{let t=[],r="",s=0,i=!1,n="";for(let o=0;o<e.length;o++){let l=e[o],p=o>0?e[o-1]:"";!i&&(l==='"'||l==="'")?(i=!0,n=l,r+=l):i&&l===n&&p!=="\\"?(i=!1,n="",r+=l):!i&&l==="("?(s++,r+=l):!i&&l===")"?(s--,r+=l):!i&&l===","&&s===0?(t.push(r),r=""):r+=l}return r&&t.push(r),t},rn=(e,t={})=>{if(e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"))return{type:v.LITERAL,value:e.slice(1,-1)};if(/^-?\d+(\.\d+)?$/.test(e))return{type:v.LITERAL,value:parseFloat(e)};if(e==="true")return{type:v.LITERAL,value:!0};if(e==="false")return{type:v.LITERAL,value:!1};if(e==="null")return{type:v.LITERAL,value:null};let r=Kr(e,t);if(r.isFunction)return{type:r.type,name:r.name,args:r.args};let s=e.trim(),i=[{op:" + ",type:"ADD"},{op:" - ",type:"SUBTRACT"}],n=-1,o=null;for(let{op:l,type:p}of i){let a=0;for(;a<s.length;){let c=de(s.substring(a),l);if(c===-1)break;let u=a+c;u>n&&(n=u,o={op:l,type:p}),a=u+l.length}}if(n!==-1)try{return Y(s,t)}catch{return{type:v.VARIABLE,path:s}}return{type:v.VARIABLE,path:s}},zr=/^\w+\(.*\)$/,sn=/\s[+\-*/%]\s|\|\||&&|\?\?|.*\?.*:/,nn=e=>{if(!(!e||e.trim()===""||zr.test(e))&&sn.test(e))throw e.includes("?")&&e.includes(":")?new k(`Complex expressions not supported in variable replacements - consider calculating the value in your data instead. Offending expression: "${e}"`):e.includes("||")||e.includes("&&")||e.includes("??")?new k(`Logical operators not supported in variable replacements - consider calculating the value in your data instead (operators like ||, &&, ?? are not supported). Offending expression: "${e}"`):new k(`Arithmetic expressions not supported in variable replacements - consider calculating '${e}' in your data instead (expressions with +, -, *, /, % are not supported). Offending expression: "${e}"`)},Ur=e=>{let t=e.trim();if(zr.test(t))throw new k(`Functions are not supported in path references - path references can only refer to loop variables. Offending expression: "#{${e}}"`);if(t.includes("["))throw new k(`Array indices not supported in path references - use simple variable names or properties. Offending expression: "#{${e}}"`);if(/[+\-*/%]/.test(t))throw new k(`Arithmetic expressions not supported in path references - path references can only refer to loop variables. Offending expression: "#{${e}}"`);if(/\|\||&&/.test(t))throw new k(`Logical operators not supported in path references - path references can only refer to loop variables. Offending expression: "#{${e}}"`);if(t.includes("?")&&t.includes(":"))throw new k(`Complex expressions not supported in path references - path references can only refer to loop variables. Offending expression: "#{${e}}"`);return{type:v.PATH_REFERENCE,path:t}},Le=(e,t={})=>{let r=e.trim();nn(r);let s=Kr(r,t);if(s.isFunction)return{type:s.type,name:s.name,args:s.args};if(r.includes("[")&&!/[\s+\-*/%|&?:]/.test(r)){let i=0;for(let n of r)n==="["?i++:n==="]"&&i--;if(i!==0)throw new Error("Invalid array index syntax")}return{type:v.VARIABLE,path:r}},_t=(e,t={})=>{let r=e,s=[];(e.includes("\\${")||e.includes("\\#{"))&&(r=e.replace(/\\\\(\$\{[^}]*\})/g,"\\DOUBLE_ESC_VAR$1"),r=r.replace(/\\\\(#\{[^}]*\})/g,"\\DOUBLE_ESC_PATH$1"),r=r.replace(/\\(\$\{[^}]*\})/g,(a,c)=>{let u=`__ESCAPED_${s.length}__`;return s.push(c),u}),r=r.replace(/\\(#\{[^}]*\})/g,(a,c)=>{let u=`__ESCAPED_${s.length}__`;return s.push(c),u}),r=r.replace(/\\DOUBLE_ESC_VAR/g,"\\"),r=r.replace(/\\DOUBLE_ESC_PATH/g,"\\"));let i=[...r.matchAll(Qi)],n=[...r.matchAll(Zi)],o=[...i.map(a=>({match:a,type:"variable"})),...n.map(a=>({match:a,type:"pathref"}))].sort((a,c)=>a.match.index-c.match.index);if(o.length===0){let a=r;for(let c=0;c<s.length;c++)a=a.replace(`__ESCAPED_${c}__`,s[c]);return{type:v.LITERAL,value:a}}if(o.length===1&&o[0].match[0]===r&&s.length===0){let{match:a,type:c}=o[0];try{return c==="variable"?Le(a[1],t):Ur(a[1])}catch(u){if(u.message==="Invalid array index syntax")return{type:v.LITERAL,value:r};throw u}}let l=[],p=0;for(let{match:a,type:c}of o){let[u,h]=a,f=a.index;if(f>p){let d=r.substring(p,f);for(let y=0;y<s.length;y++)d=d.replace(`__ESCAPED_${y}__`,s[y]);d&&l.push(d)}try{let d;c==="variable"?d=Le(h.trim(),t):d=Ur(h.trim()),l.push(d)}catch(d){if(d.message==="Invalid array index syntax")l.push(u);else throw d}p=f+u.length}if(p<r.length){let a=r.substring(p);for(let c=0;c<s.length;c++)a=a.replace(`__ESCAPED_${c}__`,s[c]);a&&l.push(a)}return{type:v.INTERPOLATION,parts:l}};var ue=(e,t)=>typeof e=="string"?_t(e,t):typeof e=="object"&&e!==null?Array.isArray(e)?an(e,t):ln(e,t):{type:v.LITERAL,value:e},on=e=>{let{$each:t,...r}=e;if(typeof t!="string")throw new k("$each value must be a non-empty string");let s=t.trim();if(s==="")throw new k("$each value must be a non-empty string");if(Object.keys(r).length===0)throw new k("Empty $each body not allowed");if(r.$partial!==void 0)throw new k("Cannot use $partial with $each at the same level. Wrap $partial in a parent object if you need conditionals.");return{[`$for ${s}`]:r}},an=(e,t)=>{let r=[],s=!1;for(let i=0;i<e.length;i++){let n=e[i];if(typeof n=="object"&&n!==null&&!Array.isArray(n)){if(n.$each!==void 0)try{let p=on(n),a=Object.keys(p);if(a.length===1&&/^\$for(?::\w+)?\s/.test(a[0])){let c=Hr(a[0],p[a[0]],t,!0);r.push(c),s=!0;continue}}catch(p){throw p instanceof k?p:new k(p.message)}let l=Object.keys(n);if(l.length===1&&/^\$for(?::\w+)?\s/.test(l[0])){let p=Hr(l[0],n[l[0]],t);r.push(p),s=!0;continue}}let o=ue(n,t);r.push(o),(o.type===v.FUNCTION||o.type===v.CONDITIONAL||o.type===v.LOOP||o.type===v.PARTIAL||o.type===v.OBJECT&&!o.fast||o.type===v.ARRAY&&!o.fast)&&(s=!0)}return{type:v.ARRAY,items:r,fast:!s}},ln=(e,t)=>{let r=[],s=!1,i=null,n=Object.entries(e),o=0;if(e.$partial!==void 0){if(typeof e.$partial!="string")throw new k("$partial value must be a string");if(e.$partial.trim()==="")throw new k("$partial value cannot be an empty string");let p=["$if","$elif","$else","$for"],a=[];for(let[m]of n)for(let w of p)if(m===w||m.startsWith(w+" ")||m.startsWith(w+"#")){a.push(w);break}if(a.length>0)throw new k(`Cannot use $partial with ${a.join(", ")} at the same level. Wrap $partial in a parent object if you need conditionals.`);let{$partial:c,$when:u,...h}=e,f={},d=!1;for(let[m,w]of Object.entries(h)){let _=m;(m.startsWith("\\$")||m.startsWith("$$"))&&(_=m.slice(1)),f[_]=w,d=!0}let y=null;if(d&&(y=ue(f,t),y.type===v.OBJECT)){let m=!1;for(let w of y.properties)if(w.value.type===v.VARIABLE||w.value.type===v.INTERPOLATION||w.value.type===v.FUNCTION||w.value.type===v.CONDITIONAL||w.value.type===v.OBJECT&&!w.value.fast||w.value.type===v.ARRAY&&!w.value.fast){m=!0;break}m&&(y.fast=!1)}let b={type:v.PARTIAL,name:c,data:y};if(u!==void 0){let m;if(typeof u=="string"){if(u.trim()==="")throw new k("Empty condition expression after '$when'");m=Y(u,t)}else m={type:v.LITERAL,value:u};b.whenCondition=m}return b}for(let[p,a]of n)if(p==="$when"){if(i!==null)throw new k("Multiple '$when' directives on the same object are not allowed");if(a==null)throw new k("Missing condition expression after '$when'");let c=typeof a=="string"?a:JSON.stringify(a);if(c.trim()==="")throw new k("Empty condition expression after '$when'");i=Y(c,t),s=!0}else if(p.startsWith("$when#")||p.startsWith("$when "))throw new k("'$when' does not support ID syntax or inline conditions - use '$when' as a property");for(;o<n.length;){let[p,a]=n[o];if(p==="$when"){o++;continue}if(p==="$each")throw new k("$each can only be used inside arrays");if(p.startsWith("$if ")||p.match(/^\$if#\w+\s/)||p.match(/^\$if\s+\w+.*:$/)){let c=pn(n,o,t);r.push({key:p,value:c.node}),s=!0,o=c.nextIndex}else if(/^\$for(?::\w+)?\s/.test(p)){let c=p.match(/^\$for(?::(\w+))?\s/)?.[1]||"",u=c?`:${c}`:"";throw new k(`$for loops must be inside arrays - use '- $for${u} item in items:' instead of '$for${u} item in items:'. For cleaner object generation syntax, consider using $each.`)}else{if(p.startsWith("$elif ")||p.startsWith("$else"))throw new k(`'${p.split(" ")[0]}' without matching '$if'`);if(p==="$if"||p==="$if:")throw new k("Missing condition expression after '$if'");{let c=ue(a,t);(c.type===v.FUNCTION||c.type===v.CONDITIONAL||c.type===v.PARTIAL||c.type===v.OBJECT&&!c.fast||c.type===v.ARRAY&&!c.fast)&&(s=!0);let u=_t(p,t),h={key:p,value:c};(u.type!==v.LITERAL||u.value!==p)&&(h.parsedKey=u),r.push(h),o++}}}let l={type:v.OBJECT,properties:r,fast:!s};return i&&(l.whenCondition=i),l},pn=(e,t,r={})=>{let s=[],i=[],n=t,[o,l]=e[n],p=null,a;if(o.startsWith("$if#")){let u=o.match(/^\$if#(\w+)\s+(.+)$/);if(u)p=u[1],a=u[2];else throw new k(`Invalid conditional syntax: ${o}`)}else a=o.substring(4),a.endsWith(":")&&(a=a.slice(0,-1).trim());bt(a);let c=Y(a,r);for(s.push(c),i.push(ue(l,r)),n++;n<e.length;){let[u,h]=e[n],f=!1,d;if(p?u.startsWith(`$elif#${p} `)?(d=u.substring(`$elif#${p} `.length),d.endsWith(":")&&(d=d.slice(0,-1).trim()),f=!0):(u===`$else#${p}`||u===`$else#${p}:`)&&(f=!0,d=null):u.startsWith("$elif ")?(d=u.substring(6),d.endsWith(":")&&(d=d.slice(0,-1).trim()),f=!0):(u==="$else"||u==="$else:")&&(f=!0,d=null),f){if(d===null)s.push(null);else{bt(d);let y=Y(d,r);s.push(y)}if(i.push(ue(h,r)),n++,d===null)break}else break}return{node:{type:v.CONDITIONAL,conditions:s,bodies:i,id:p},nextIndex:n}},Y=(e,t={})=>{if(e=e.trim(),e.startsWith("(")&&e.endsWith(")")){let a=e.slice(1,-1),c=0,u=!0;for(let h=0;h<a.length;h++)if(a[h]==="("?c++:a[h]===")"&&c--,c<0){u=!1;break}if(u&&c===0)return Y(a,t)}let r=de(e,"||");if(r!==-1)return{type:v.BINARY,op:B.OR,left:Y(e.substring(0,r).trim(),t),right:Y(e.substring(r+2).trim(),t)};let s=de(e,"&&");if(s!==-1)return{type:v.BINARY,op:B.AND,left:Y(e.substring(0,s).trim(),t),right:Y(e.substring(s+2).trim(),t)};let i=[{op:">=",type:B.GTE},{op:"<=",type:B.LTE},{op:"==",type:B.EQ},{op:"!=",type:B.NEQ},{op:">",type:B.GT},{op:"<",type:B.LT},{op:" in ",type:B.IN}];for(let{op:a,type:c}of i){let u=de(e,a);if(u!==-1)return{type:v.BINARY,op:c,left:Y(e.substring(0,u).trim(),t),right:Y(e.substring(u+a.length).trim(),t)}}let n=-1,o=null,l=[{op:" + ",type:B.ADD},{op:" - ",type:B.SUBTRACT}];for(let{op:a,type:c}of l){let u=0;for(;u<e.length;){let h=de(e.substring(u),a);if(h===-1)break;let f=u+h;f>n&&(n=f,o={op:a,type:c}),u=f+a.length}}if(n!==-1&&o)return{type:v.BINARY,op:o.type,left:Y(e.substring(0,n).trim(),t),right:Y(e.substring(n+o.op.length).trim(),t)};let p=[" * "," / "," % "];for(let a of p)if(de(e,a)!==-1)throw new k(`Arithmetic operations are not allowed in conditionals: "${a}"`);return e.startsWith("!")?{type:v.UNARY,op:Te.NOT,operand:Y(e.substring(1).trim(),t)}:Jr(e,t)},de=(e,t)=>{let r=0,s=0;for(;s<=e.length-t.length;){if(e[s]==="(")r++;else if(e[s]===")")r--;else if(r===0&&e.substring(s,s+t.length)===t)return s;s++}return-1},cn=e=>{if(e=e.trim(),e==="true")return{type:v.LITERAL,value:!0};if(e==="false")return{type:v.LITERAL,value:!1};if(e==="null")return{type:v.LITERAL,value:null};if(e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"))return{type:v.LITERAL,value:e.slice(1,-1)};if(e==='""'||e==="''")return{type:v.LITERAL,value:""};if(e==="{}")return{type:v.LITERAL,value:{}};if(e==="[]")return{type:v.LITERAL,value:[]};let t=Number(e);return!isNaN(t)&&isFinite(t)?{type:v.LITERAL,value:t}:{type:v.VARIABLE,path:e}},Jr=(e,t)=>{let r=e.trim();if(r.match(/^(\w+)\((.*)\)$/))return Le(r,t);let i=cn(r);if(i.type===v.LITERAL)return i;if(/^[a-zA-Z_$][\w.$]*$/.test(r))return{type:v.VARIABLE,path:r};try{return Le(r,t)}catch(n){if(n.message&&n.message.includes("not supported"))return i;throw n}},un=(e,t=!1)=>{let r=t?"$each":"$for";try{Pr(e)}catch(s){if(s instanceof k&&t){let i=s.message.replace(/\$for/g,"$each");throw new k(i.replace("Parse Error: ",""))}throw s}},Hr=(e,t,r,s=!1)=>{let i=/^\$for(?::(\w+))?\s+(.+)$/,n=e.match(i);if(!n){let b=s?"$each":"$for";throw new k(`Invalid loop syntax (got: '${e.replace("$for",b)}')`)}let o=n[1],l=n[2].trim();un(l,s);let p=l.match(/^(.+?)\s+in\s+(.+)$/);if(!p){let b=s?"$each":"$for";throw new k(`Invalid loop syntax - missing 'in' keyword (got: '${b} ${l}')`)}let a=p[1].trim(),c=p[2].trim(),u,h=null;if(a.includes(",")){let b=a.split(",").map(m=>m.trim());if(b.length!==2)throw new k(`Invalid loop variables: ${a}. Expected format: "item" or "item, index"`);u=b[0],h=b[1]}else u=a;let f=["this","undefined","null","true","false"];if(f.includes(u))throw new k(`Reserved variable name: ${u}`);if(h&&f.includes(h))throw new k(`Reserved variable name: ${h}`);let d=Jr(c,r),y=ue(t,r);return{type:v.LOOP,itemVar:u,indexVar:h,iterable:d,body:y,flatten:o!=="nested"}};var hn=(e,t={})=>{let{functions:r={}}=t;return ue(e,r)},Fe=hn;var xt={};P(xt,{now:()=>dn});var dn=()=>Date.now();var fn=(e,t,r={})=>{let{functions:s={},partials:i={}}=r,n={...xt,...s},o=Fe(e,{functions:n}),l={};for(let[p,a]of Object.entries(i))l[p]=Fe(a,{functions:n});return wt(o,t,{functions:n,partials:l})},At=fn;function qr(e,t){return t.reduce((r,s)=>(s in e&&(r[s]=e[s]),r),{})}var yn=()=>Object.freeze({formValues:{},tooltipState:{open:!1,x:0,y:0,content:""}}),Yr=(e,t,r=void 0)=>{if(!t)return;let s=t.split(/[\[\].]/).filter(n=>n!==""),i=e;for(let n of s){if(i==null||!(n in i))return r;i=i[n]}return i},mn=(e,t,r)=>{let s=t.split(/[\[\].]/).filter(n=>n!=="");t.includes("[")&&t in e&&delete e[t];let i=e;for(let n=0;n<s.length-1;n++){let o=s[n];if(!(o in i)||typeof i[o]!="object"||i[o]===null){let l=s[n+1],p=/^\d+$/.test(l);i[o]=p?[]:{}}i=i[o]}return i[s[s.length-1]]=r,e},gn=["id","class","style","slot"],vn=e=>Object.entries(e).filter(([t])=>!gn.includes(t)).map(([t,r])=>`${t}=${r}`).join(" "),Ue=({props:e})=>{let{form:t={}}=e,{context:r}=e;return r?At(t,r):t},bn=({state:e,props:t,attrs:r})=>{let s=vn(r),i=Ue({state:e,props:t}),n=structuredClone(i.fields||[]);return n.forEach(o=>{let l=Yr(e.formValues,o.name);if(["read-only-text"].includes(o.inputType)&&(o.defaultValue=l),o.inputType==="image"){let p=o.src;o.imageSrc=p&&p.trim()?p:null,o.placeholderText=o.placeholder||"No Image"}if(o.inputType==="waveform"){let p=o.waveformData;o.waveformData=p||null,o.placeholderText=o.placeholder||"No Waveform"}}),{key:r?.key,containerAttrString:s,title:i?.title||"",description:i?.description||"",fields:n,actions:t?.form?.actions||{buttons:[]},formValues:e.formValues,tooltipState:e.tooltipState}},wn=({state:e})=>e,_n=({state:e,props:t})=>{let r=Ue({state:e,props:t});return qr(e.formValues,r.fields.map(s=>s.name))},xn=({state:e},t)=>Yr(e.formValues,t),An=(e,t)=>{e.formValues=t||{}},En=(e,{name:t,value:r,props:s})=>{mn(e.formValues,t,r);let i=Ue({state:e,props:s}),n=qr(e.formValues,i.fields.map(o=>o.name));e.formValues=n},kn=(e,{x:t,y:r,content:s})=>{e.tooltipState={open:!0,x:t,y:r,content:s}},$n=e=>{e.tooltipState={...e.tooltipState,open:!1}};var Gr={elementName:"rtgl-form",viewDataSchema:{type:"object"},propsSchema:{type:"object",properties:{defaultValues:{type:"object"},context:{type:"object"},form:{type:"object",properties:{title:{type:"string"},description:{type:"string"},fields:{type:"array",items:{anyOf:[{type:"object",properties:{name:{type:"string"},label:{type:"string"},description:{type:"string"},inputType:{const:"inputText"},placeholder:{type:"string"},tooltip:{type:"object",properties:{content:{type:"string"}}}},required:["name","label","inputType"],additionalProperties:!1},{type:"object",properties:{name:{type:"string"},label:{type:"string"},description:{type:"string"},inputType:{const:"select"},placeholder:{type:"string"},noClear:{type:"boolean"},addOption:{type:"object",properties:{label:{type:"string"}}},options:{type:"array",items:{type:"object",properties:{label:{type:"string"},value:{type:"any"}},required:["label","value"]}},tooltip:{type:"object",properties:{content:{type:"string"}}}},required:["name","label","inputType","options"],additionalProperties:!1},{type:"object",properties:{name:{type:"string"},label:{type:"string"},description:{type:"string"},inputType:{const:"colorPicker"},value:{type:"string"},tooltip:{type:"object",properties:{content:{type:"string"}}}},required:["name","label","inputType"],additionalProperties:!1},{type:"object",properties:{name:{type:"string"},label:{type:"string"},description:{type:"string"},inputType:{const:"slider"},min:{type:"number"},max:{type:"number"},step:{type:"number"},value:{type:"number"},tooltip:{type:"object",properties:{content:{type:"string"}}}},required:["name","label","inputType"],additionalProperties:!1},{type:"object",properties:{name:{type:"string"},label:{type:"string"},description:{type:"string"},inputType:{const:"slider-input"},min:{type:"number"},max:{type:"number"},step:{type:"number"},value:{type:"number"},tooltip:{type:"object",properties:{content:{type:"string"}}}},required:["name","label","inputType"],additionalProperties:!1},{type:"object",properties:{name:{type:"string"},label:{type:"string"},description:{type:"string"},inputType:{const:"image"},width:{type:"number"},height:{type:"number"},placeholder:{type:"string"},tooltip:{type:"object",properties:{content:{type:"string"}}}},required:["name","label","inputType"],additionalProperties:!1},{type:"object",properties:{name:{type:"string"},label:{type:"string"},description:{type:"string"},inputType:{const:"waveform"},width:{type:"number"},height:{type:"number"},placeholder:{type:"string"},defaultValue:{type:"object"},waveformData:{type:"object"},tooltip:{type:"object",properties:{content:{type:"string"}}}},required:["name","label","inputType"],additionalProperties:!1},{type:"object",properties:{name:{type:"string"},label:{type:"string"},description:{type:"string"},inputType:{const:"popover-input"},placeholder:{type:"string"},tooltip:{type:"object",properties:{content:{type:"string"}}}},required:["name","label","inputType"],additionalProperties:!1}]}},actions:{type:"object",properties:{buttons:{type:"array",items:{type:"object",properties:{id:{type:"string"},content:{type:"string"}},required:["id","content"]}}}}}}}},refs:{"action-*":{eventListeners:{click:{handler:"handleActionClick"}}},"tooltip-icon-*":{eventListeners:{mouseenter:{handler:"handleTooltipMouseEnter"},mouseleave:{handler:"handleTooltipMouseLeave"}}},"field-*":{eventListeners:{"input-change":{handler:"handleInputChange"},"select-change":{handler:"handleSelectChange"},"add-option-selected":{handler:"handleSelectAddOption"},"colorpicker-change":{handler:"handleColorPickerChange"},"slider-change":{handler:"handleSliderChange"},"slider-input-value-change":{handler:"handleSliderInputChange"}}},"image-*":{eventListeners:{click:{handler:"handleImageClick"},contextmenu:{handler:"handleImageClick"}}},"waveform-*":{eventListeners:{click:{handler:"handleWaveformClick"},contextmenu:{handler:"handleWaveformClick"}}}},events:{"form-change":{},"extra-event":{},"action-click":{}},template:{type:9,items:[{type:8,properties:[{key:"rtgl-view w=f p=md g=lg ${containerAttrString}",value:{type:9,items:[{type:8,properties:[{key:"rtgl-view g=sm w=f",value:{type:9,items:[{type:8,properties:[{key:"rtgl-text s=lg",value:{type:1,path:"title"}}],fast:!0},{type:8,properties:[{key:"rtgl-text c=mu-fg",value:{type:1,path:"description"}}],fast:!0}],fast:!0}}],fast:!0},{type:8,properties:[{key:"rtgl-view g=lg w=f",value:{type:9,items:[{type:7,itemVar:"field",indexVar:"i",iterable:{type:1,path:"fields"},body:{type:9,items:[{type:8,properties:[{key:"rtgl-view g=md w=f",value:{type:9,items:[{type:8,properties:[{key:"rtgl-view g=sm",value:{type:9,items:[{type:8,properties:[{key:"rtgl-view d=h g=md av=c",value:{type:9,items:[{type:8,properties:[{key:"rtgl-text",value:{type:1,path:"field.label"}}],fast:!0},{type:8,properties:[{key:"$if field.tooltip",value:{type:6,conditions:[{type:1,path:"field.tooltip"}],bodies:[{type:9,items:[{type:8,properties:[{key:'rtgl-svg#tooltip-icon-${field.name} svg="info" wh=16 c=mu-fg cur=help ml=xs',value:{type:0,value:null},parsedKey:{type:2,parts:["rtgl-svg#tooltip-icon-",{type:1,path:"field.name"},' svg="info" wh=16 c=mu-fg cur=help ml=xs']}}],fast:!0}],fast:!0}],id:null}}],fast:!1}],fast:!1}}],fast:!1},{type:8,properties:[{key:"rtgl-text s=sm c=mu-fg",value:{type:1,path:"field.description"}}],fast:!0}],fast:!1}}],fast:!1},{type:8,properties:[{key:'$if field.inputType == "read-only-text"',value:{type:6,conditions:[{type:4,op:0,left:{type:1,path:"field.inputType"},right:{type:0,value:"read-only-text"}}],bodies:[{type:9,items:[{type:8,properties:[{key:"rtgl-text s=sm",value:{type:1,path:"field.defaultValue"}}],fast:!0}],fast:!0}],id:null}}],fast:!1},{type:8,properties:[{key:'$if field.inputType == "inputText"',value:{type:6,conditions:[{type:4,op:0,left:{type:1,path:"field.inputType"},right:{type:0,value:"inputText"}}],bodies:[{type:9,items:[{type:8,properties:[{key:"rtgl-input#field-${field.name} w=f",value:{type:0,value:null},parsedKey:{type:2,parts:["rtgl-input#field-",{type:1,path:"field.name"}," w=f"]}}],fast:!0}],fast:!0}],id:null}}],fast:!1},{type:8,properties:[{key:'$if field.inputType == "popover-input"',value:{type:6,conditions:[{type:4,op:0,left:{type:1,path:"field.inputType"},right:{type:0,value:"popover-input"}}],bodies:[{type:9,items:[{type:8,properties:[{key:'rtgl-popover-input#field-${field.name} label="${field.label}"',value:{type:0,value:null},parsedKey:{type:2,parts:["rtgl-popover-input#field-",{type:1,path:"field.name"},' label="',{type:1,path:"field.label"},'"']}}],fast:!0}],fast:!0}],id:null}}],fast:!1},{type:8,properties:[{key:'$if field.inputType == "select"',value:{type:6,conditions:[{type:4,op:0,left:{type:1,path:"field.inputType"},right:{type:0,value:"select"}}],bodies:[{type:9,items:[{type:8,properties:[{key:"rtgl-select#field-${field.name} key=${key} w=f .options=fields[${i}].options ?no-clear=fields[${i}].noClear .addOption=fields[${i}].addOption",value:{type:0,value:null},parsedKey:{type:2,parts:["rtgl-select#field-",{type:1,path:"field.name"}," key=",{type:1,path:"key"}," w=f .options=fields[",{type:1,path:"i"},"].options ?no-clear=fields[",{type:1,path:"i"},"].noClear .addOption=fields[",{type:1,path:"i"},"].addOption"]}}],fast:!0}],fast:!0}],id:null}}],fast:!1},{type:8,properties:[{key:'$if field.inputType == "colorPicker"',value:{type:6,conditions:[{type:4,op:0,left:{type:1,path:"field.inputType"},right:{type:0,value:"colorPicker"}}],bodies:[{type:9,items:[{type:8,properties:[{key:"rtgl-color-picker#field-${field.name} key=${key}",value:{type:0,value:null},parsedKey:{type:2,parts:["rtgl-color-picker#field-",{type:1,path:"field.name"}," key=",{type:1,path:"key"}]}}],fast:!0}],fast:!0}],id:null}}],fast:!1},{type:8,properties:[{key:'$if field.inputType == "slider"',value:{type:6,conditions:[{type:4,op:0,left:{type:1,path:"field.inputType"},right:{type:0,value:"slider"}}],bodies:[{type:9,items:[{type:8,properties:[{key:"rtgl-slider#field-${field.name} key=${key} w=f min=${field.min} max=${field.max} step=${field.step}",value:{type:0,value:null},parsedKey:{type:2,parts:["rtgl-slider#field-",{type:1,path:"field.name"}," key=",{type:1,path:"key"}," w=f min=",{type:1,path:"field.min"}," max=",{type:1,path:"field.max"}," step=",{type:1,path:"field.step"}]}}],fast:!0}],fast:!0}],id:null}}],fast:!1},{type:8,properties:[{key:'$if field.inputType == "slider-input"',value:{type:6,conditions:[{type:4,op:0,left:{type:1,path:"field.inputType"},right:{type:0,value:"slider-input"}}],bodies:[{type:9,items:[{type:8,properties:[{key:"rtgl-slider-input#field-${field.name} w=f min=${field.min} max=${field.max} step=${field.step}",value:{type:0,value:null},parsedKey:{type:2,parts:["rtgl-slider-input#field-",{type:1,path:"field.name"}," w=f min=",{type:1,path:"field.min"}," max=",{type:1,path:"field.max"}," step=",{type:1,path:"field.step"}]}}],fast:!0}],fast:!0}],id:null}}],fast:!1},{type:8,properties:[{key:'$if field.inputType == "image" && field.imageSrc',value:{type:6,conditions:[{type:4,op:6,left:{type:4,op:0,left:{type:1,path:"field.inputType"},right:{type:0,value:"image"}},right:{type:1,path:"field.imageSrc"}}],bodies:[{type:9,items:[{type:8,properties:[{key:"rtgl-image#image-${field.name} src=${field.imageSrc} w=${field.width} h=${field.height} cur=p",value:{type:0,value:null},parsedKey:{type:2,parts:["rtgl-image#image-",{type:1,path:"field.name"}," src=",{type:1,path:"field.imageSrc"}," w=",{type:1,path:"field.width"}," h=",{type:1,path:"field.height"}," cur=p"]}}],fast:!0}],fast:!0}],id:null}}],fast:!1},{type:8,properties:[{key:'$if field.inputType == "image" && !field.imageSrc',value:{type:6,conditions:[{type:4,op:6,left:{type:4,op:0,left:{type:1,path:"field.inputType"},right:{type:0,value:"image"}},right:{type:5,op:0,operand:{type:1,path:"field.imageSrc"}}}],bodies:[{type:9,items:[{type:8,properties:[{key:"rtgl-view#field-${field.name} w=${field.width} h=${field.height} bc=ac bw=sm ah=c av=c cur=p p=md",value:{type:9,items:[{type:8,properties:[{key:"rtgl-text c=mu-fg ta=c",value:{type:1,path:"field.placeholderText"}}],fast:!0}],fast:!0},parsedKey:{type:2,parts:["rtgl-view#field-",{type:1,path:"field.name"}," w=",{type:1,path:"field.width"}," h=",{type:1,path:"field.height"}," bc=ac bw=sm ah=c av=c cur=p p=md"]}}],fast:!0}],fast:!0}],id:null}}],fast:!1},{type:8,properties:[{key:'$if field.inputType == "waveform" && field.waveformData',value:{type:6,conditions:[{type:4,op:6,left:{type:4,op:0,left:{type:1,path:"field.inputType"},right:{type:0,value:"waveform"}},right:{type:1,path:"field.waveformData"}}],bodies:[{type:9,items:[{type:8,properties:[{key:"rtgl-waveform#field-${field.name} .waveformData=fields[${i}].waveformData w=${field.width} h=${field.height} cur=p",value:{type:0,value:null},parsedKey:{type:2,parts:["rtgl-waveform#field-",{type:1,path:"field.name"}," .waveformData=fields[",{type:1,path:"i"},"].waveformData w=",{type:1,path:"field.width"}," h=",{type:1,path:"field.height"}," cur=p"]}}],fast:!0}],fast:!0}],id:null}}],fast:!1},{type:8,properties:[{key:'$if field.inputType == "waveform" && !field.waveformData',value:{type:6,conditions:[{type:4,op:6,left:{type:4,op:0,left:{type:1,path:"field.inputType"},right:{type:0,value:"waveform"}},right:{type:5,op:0,operand:{type:1,path:"field.waveformData"}}}],bodies:[{type:9,items:[{type:8,properties:[{key:"rtgl-view#field-${field.name} w=${field.width} h=${field.height} bc=ac bw=sm ah=c av=c cur=p p=md",value:{type:9,items:[{type:8,properties:[{key:"rtgl-text c=mu-fg ta=c",value:{type:1,path:"field.placeholder"}}],fast:!0}],fast:!0},parsedKey:{type:2,parts:["rtgl-view#field-",{type:1,path:"field.name"}," w=",{type:1,path:"field.width"}," h=",{type:1,path:"field.height"}," bc=ac bw=sm ah=c av=c cur=p p=md"]}}],fast:!0}],fast:!0}],id:null}}],fast:!1},{type:8,properties:[{key:'$if field.inputType == "slot"',value:{type:6,conditions:[{type:4,op:0,left:{type:1,path:"field.inputType"},right:{type:0,value:"slot"}}],bodies:[{type:9,items:[{type:8,properties:[{key:'slot#field-${field.slotName} name=${field.slot} style="display: contents;"',value:{type:0,value:null},parsedKey:{type:2,parts:["slot#field-",{type:1,path:"field.slotName"}," name=",{type:1,path:"field.slot"},' style="display: contents;"']}}],fast:!0}],fast:!0}],id:null}}],fast:!1}],fast:!1}}],fast:!1}],fast:!1}}],fast:!1}}],fast:!1},{type:8,properties:[{key:"rtgl-view g=sm w=f",value:{type:9,items:[{type:8,properties:[{key:"rtgl-view d=h ah=e g=sm w=f",value:{type:9,items:[{type:7,itemVar:"button",indexVar:"i",iterable:{type:1,path:"actions.buttons"},body:{type:9,items:[{type:8,properties:[{key:"rtgl-button#action-${button.id}",value:{type:1,path:"button.content"},parsedKey:{type:2,parts:["rtgl-button#action-",{type:1,path:"button.id"}]}}],fast:!0}],fast:!0}}],fast:!1}}],fast:!1}],fast:!1}}],fast:!1},{type:8,properties:[{key:'rtgl-tooltip ?open=${tooltipState.open} x=${tooltipState.x} y=${tooltipState.y} placement="top" content="${tooltipState.content}"',value:{type:0,value:null},parsedKey:{type:2,parts:["rtgl-tooltip ?open=",{type:1,path:"tooltipState.open"}," x=",{type:1,path:"tooltipState.x"}," y=",{type:1,path:"tooltipState.y"},' placement="top" content="',{type:1,path:"tooltipState.content"},'"']}}],fast:!0}],fast:!1},parsedKey:{type:2,parts:["rtgl-view w=f p=md g=lg ",{type:1,path:"containerAttrString"}]}}],fast:!1}],fast:!1}};var kt={};P(kt,{closeAll:()=>Pn,handleCancel:()=>On,handleConfirm:()=>Cn,handleDialogClose:()=>Sn,handleDropdownClose:()=>In,handleDropdownItemClick:()=>Tn,showAlert:()=>Ln,showConfirm:()=>Rn,showDropdownMenu:()=>Nn});var Sn=(e,t)=>{let{store:r,render:s}=e;r.closeAll(),s()},Cn=(e,t)=>{let{store:r,render:s,globalUI:i}=e;r.closeAll(),s(),i.emit("event",!0)},On=(e,t)=>{let{store:r,render:s,globalUI:i}=e;r.closeAll(),s(),i.emit("event",!1)},In=(e,t)=>{let{store:r,render:s,globalUI:i}=e;r.closeAll(),s(),i.emit("event",null)},Tn=(e,t)=>{let{store:r,render:s,globalUI:i}=e,n=t._event,{index:o,item:l}=n.detail;r.closeAll(),s(),i.emit("event",{index:o,item:l})},Ln=(e,t)=>{let{store:r,render:s}=e,i=t;r.selectIsOpen()&&(r.closeAll(),s()),r.setAlertConfig(i),s()},Rn=async(e,t)=>{let{store:r,render:s,globalUI:i}=e,n=t;return r.selectIsOpen()&&(r.closeAll(),s()),r.setConfirmConfig(n),s(),new Promise(o=>{i.once("event",l=>{o(l)})})},Nn=async(e,t)=>{let{store:r,render:s,globalUI:i}=e,n=t;return r.selectIsOpen()&&(r.closeAll(),s()),r.setDropdownConfig(n),s(),new Promise(o=>{i.once("event",l=>{o(l)})})},Pn=e=>{let{store:t,render:r}=e;t.selectIsOpen()&&(t.closeAll(),r())};var $t={};P($t,{closeAll:()=>Wn,createInitialState:()=>Vn,selectConfig:()=>Mn,selectDropdownConfig:()=>Fn,selectIsOpen:()=>Kn,selectUiType:()=>Un,selectViewData:()=>zn,setAlertConfig:()=>Dn,setConfirmConfig:()=>jn,setDropdownConfig:()=>Bn});var Vn=()=>Object.freeze({isOpen:!1,uiType:"dialog",config:{status:void 0,title:"",message:"",confirmText:"OK",cancelText:"Cancel",mode:"alert"},dropdownConfig:{items:[],x:0,y:0,placement:"bottom-start"}}),Dn=(e,t)=>{if(!t.message)throw new Error("message is required for showAlert");e.config={status:t.status||void 0,title:t.title||"",message:t.message,confirmText:t.confirmText||"OK",cancelText:"",mode:"alert"},e.uiType="dialog",e.isOpen=!0},jn=(e,t)=>{if(!t.message)throw new Error("message is required for showConfirm");e.config={status:t.status||void 0,title:t.title||"",message:t.message,confirmText:t.confirmText||"Yes",cancelText:t.cancelText||"Cancel",mode:"confirm"},e.uiType="dialog",e.isOpen=!0},Bn=(e,t)=>{if(!t.items||!Array.isArray(t.items))throw new Error("items array is required for showDropdown");e.dropdownConfig={items:t.items,x:t.x||0,y:t.y||0,placement:t.placement||"bottom-start"},e.uiType="dropdown",e.isOpen=!0},Wn=e=>{e.isOpen=!1,e.uiType="dialog"},Mn=({state:e})=>e.config,Fn=({state:e})=>e.dropdownConfig,Un=({state:e})=>e.uiType,Kn=({state:e})=>e.isOpen,zn=({state:e})=>({isOpen:e.isOpen,uiType:e.uiType,config:e.config,dropdownConfig:{items:e.dropdownConfig?.items||[],x:e.dropdownConfig?.x||0,y:e.dropdownConfig?.y||0,placement:e.dropdownConfig?.placement||"bottom-start"},isDialogOpen:e.isOpen&&e.uiType==="dialog",isDropdownOpen:e.isOpen&&e.uiType==="dropdown"});var Xr={elementName:"rtgl-global-ui",viewDataSchema:{type:"object",properties:{isOpen:{type:"boolean"},uiType:{type:"string"},config:{type:"object",properties:{status:{type:"string"},title:{type:"string"},message:{type:"string"},confirmText:{type:"string"},cancelText:{type:"string"},mode:{type:"string"}}},dropdownConfig:{type:"object",properties:{items:{type:"array"},x:{type:"number"},y:{type:"number"},placement:{type:"string"}}}}},refs:{dialog:{eventListeners:{close:{handler:"handleDialogClose"}}},"confirm-button":{eventListeners:{click:{handler:"handleConfirm"}}},"cancel-button":{eventListeners:{click:{handler:"handleCancel"}}},"dropdown-menu":{eventListeners:{close:{handler:"handleDropdownClose"},"click-item":{handler:"handleDropdownItemClick"}}}},template:{type:9,items:[{type:8,properties:[{key:"rtgl-dialog#dialog ?open=${isDialogOpen} s=sm",value:{type:9,items:[{type:8,properties:[{key:"rtgl-view slot=content g=lg p=lg",value:{type:9,items:[{type:8,properties:[{key:"rtgl-view d=h g=md",value:{type:9,items:[{type:8,properties:[{key:"rtgl-view d=h ah=c av=c g=md",value:{type:0,value:null}}],fast:!0},{type:8,properties:[{key:"rtgl-view g=md",value:{type:9,items:[{type:8,properties:[{key:"rtgl-view h=24 av=c",value:{type:9,items:[{type:8,properties:[{key:"rtgl-text fw=600",value:{type:1,path:"config.title"}}],fast:!0}],fast:!0}}],fast:!0},{type:8,properties:[{key:"rtgl-text",value:{type:1,path:"config.message"}}],fast:!0}],fast:!0}}],fast:!0}],fast:!0}}],fast:!0},{type:8,properties:[{key:"rtgl-view d=h g=md mt=lg w=f ah=e",value:{type:9,items:[{type:8,properties:[{key:"$if config.mode == 'confirm'",value:{type:6,conditions:[{type:4,op:0,left:{type:1,path:"config.mode"},right:{type:0,value:"confirm"}}],bodies:[{type:9,items:[{type:8,properties:[{key:"rtgl-button#cancel-button v=se",value:{type:1,path:"config.cancelText"}}],fast:!0}],fast:!0}],id:null}}],fast:!1},{type:8,properties:[{key:"rtgl-button#confirm-button v=pr",value:{type:1,path:"config.confirmText"}}],fast:!0}],fast:!1}}],fast:!1}],fast:!1}}],fast:!1}],fast:!1},parsedKey:{type:2,parts:["rtgl-dialog#dialog ?open=",{type:1,path:"isDialogOpen"}," s=sm"]}}],fast:!1},{type:8,properties:[{key:"rtgl-dropdown-menu#dropdown-menu ?open=${isDropdownOpen} x=${dropdownConfig.x} y=${dropdownConfig.y} placement=${dropdownConfig.placement} .items=dropdownConfig.items key=dropdown-${isDropdownOpen}",value:{type:0,value:null},parsedKey:{type:2,parts:["rtgl-dropdown-menu#dropdown-menu ?open=",{type:1,path:"isDropdownOpen"}," x=",{type:1,path:"dropdownConfig.x"}," y=",{type:1,path:"dropdownConfig.y"}," placement=",{type:1,path:"dropdownConfig.placement"}," .items=dropdownConfig.items key=dropdown-",{type:1,path:"isDropdownOpen"}]}}],fast:!0}],fast:!1}};var St={};P(St,{handleClickStart:()=>Hn});var Hn=(e,t)=>{let{dispatchEvent:r,store:s}=e,i=t._event;console.log("handle click start",s.selectPath()),r(new CustomEvent("clickStart",{detail:{path:s.selectPath()}}))};var Ct={};P(Ct,{createInitialState:()=>Jn,selectPath:()=>Xn,selectViewData:()=>Gn,setState:()=>Qn});var Jn=()=>Object.freeze({}),qn=["id","class","style","slot"],Yn=e=>Object.entries(e).filter(([t])=>!qn.includes(t)).map(([t,r])=>`${t}=${r}`).join(" "),Gn=({state:e,props:t,attrs:r})=>{console.log("attrs",{attrs:r,entries:Object.entries(r)});let s=r.start?JSON.parse(decodeURIComponent(r.start)):t.start;return{containerAttrString:Yn(r),start:s||{label:"",image:{src:"",width:32,height:32,alt:""}}}},Xn=({props:e})=>e.start.path,Qn=e=>{};var Qr={elementName:"rtgl-navbar",viewDataSchema:{type:"object",properties:{containerAttrString:{type:"string"},start:{type:"object",properties:{label:{type:"string"},href:{type:"string"},image:{type:"object",properties:{src:{type:"string"}}},hasImage:{type:"boolean"},hasHref:{type:"boolean"}}}}},propsSchema:{type:"object",properties:{start:{type:"object",properties:{label:{type:"string"},href:{type:"string"},image:{type:"object",properties:{src:{type:"string"}}}}}}},refs:{start:{eventListeners:{click:{handler:"handleClickStart"}}}},events:{clickStart:{type:"object",properties:{path:{type:"string"}}}},anchors:[[{"rtgl-text s=lg":"${start.label}"},{"$if start.image && start.image.src":[{"rtgl-image w=${start.image.width} h=${start.image.height} src=${start.image.src} alt=${start.image.alt}":null}]}]],template:{type:9,items:[{type:8,properties:[{key:"rtgl-view bgc=bg d=h h=48 av=c w=f ${containerAttrString}",value:{type:9,items:[{type:8,properties:[{key:"$if start.href",value:{type:6,conditions:[{type:1,path:"start.href"},{type:1,path:"start.path"},null],bodies:[{type:9,items:[{type:8,properties:[{key:"a href=${start.href}",value:{type:9,items:[{type:8,properties:[{key:"rtgl-view d=h av=c g=lg g=md",value:{type:9,items:[{type:9,items:[{type:8,properties:[{key:"rtgl-text s=lg",value:{type:1,path:"start.label"}}],fast:!0},{type:8,properties:[{key:"$if start.image && start.image.src",value:{type:6,conditions:[{type:4,op:6,left:{type:1,path:"start.image"},right:{type:1,path:"start.image.src"}}],bodies:[{type:9,items:[{type:8,properties:[{key:"rtgl-image w=${start.image.width} h=${start.image.height} src=${start.image.src} alt=${start.image.alt}",value:{type:0,value:null},parsedKey:{type:2,parts:["rtgl-image w=",{type:1,path:"start.image.width"}," h=",{type:1,path:"start.image.height"}," src=",{type:1,path:"start.image.src"}," alt=",{type:1,path:"start.image.alt"}]}}],fast:!0}],fast:!0}],id:null}}],fast:!1}],fast:!1}],fast:!1}}],fast:!1}],fast:!1},parsedKey:{type:2,parts:["a href=",{type:1,path:"start.href"}]}}],fast:!1}],fast:!1},{type:9,items:[{type:8,properties:[{key:"rtgl-view#start d=h av=c g=lg g=md cur=p",value:{type:9,items:[{type:9,items:[{type:8,properties:[{key:"rtgl-text s=lg",value:{type:1,path:"start.label"}}],fast:!0},{type:8,properties:[{key:"$if start.image && start.image.src",value:{type:6,conditions:[{type:4,op:6,left:{type:1,path:"start.image"},right:{type:1,path:"start.image.src"}}],bodies:[{type:9,items:[{type:8,properties:[{key:"rtgl-image w=${start.image.width} h=${start.image.height} src=${start.image.src} alt=${start.image.alt}",value:{type:0,value:null},parsedKey:{type:2,parts:["rtgl-image w=",{type:1,path:"start.image.width"}," h=",{type:1,path:"start.image.height"}," src=",{type:1,path:"start.image.src"}," alt=",{type:1,path:"start.image.alt"}]}}],fast:!0}],fast:!0}],id:null}}],fast:!1}],fast:!1}],fast:!1}}],fast:!1}],fast:!1},{type:9,items:[{type:8,properties:[{key:"rtgl-view d=h av=c g=lg g=md",value:{type:9,items:[{type:9,items:[{type:8,properties:[{key:"rtgl-text s=lg",value:{type:1,path:"start.label"}}],fast:!0},{type:8,properties:[{key:"$if start.image && start.image.src",value:{type:6,conditions:[{type:4,op:6,left:{type:1,path:"start.image"},right:{type:1,path:"start.image.src"}}],bodies:[{type:9,items:[{type:8,properties:[{key:"rtgl-image w=${start.image.width} h=${start.image.height} src=${start.image.src} alt=${start.image.alt}",value:{type:0,value:null},parsedKey:{type:2,parts:["rtgl-image w=",{type:1,path:"start.image.width"}," h=",{type:1,path:"start.image.height"}," src=",{type:1,path:"start.image.src"}," alt=",{type:1,path:"start.image.alt"}]}}],fast:!0}],fast:!0}],id:null}}],fast:!1}],fast:!1}],fast:!1}}],fast:!1}],fast:!1}],id:null}}],fast:!1},{type:8,properties:[{key:"rtgl-view flex=1",value:{type:0,value:null}}],fast:!0},{type:8,properties:[{key:"rtgl-view d=h av=c g=lg",value:{type:9,items:[{type:8,properties:[{key:"slot name=right",value:{type:0,value:null}}],fast:!0}],fast:!0}}],fast:!0}],fast:!1},parsedKey:{type:2,parts:["rtgl-view bgc=bg d=h h=48 av=c w=f ",{type:1,path:"containerAttrString"}]}}],fast:!1}],fast:!1}};var Ot={};P(Ot,{handleBeforeMount:()=>eo});var Zr=(e,t,r)=>{let{store:s,render:i}=r,n,o=-1/0;if(e.forEach(l=>{let p=l.getBoundingClientRect();p.top<=t&&p.top>o&&(o=p.top,n=l.id)}),!n){let l=1/0;e.forEach(p=>{let a=p.getBoundingClientRect();a.top>t&&a.top<l&&(l=a.top,n=p.id)})}n&&n!==s.selectCurrentId()&&(s.setCurrentId(n),i())},Zn=(e,t,r,s)=>{let{store:i,render:n}=s,o=e.querySelectorAll("h1[id], h2[id], h3[id], h4[id], rtgl-text[id]"),l=Array.from(o),p=l.map(c=>{let u=1,h=c.tagName.toLowerCase();return h==="h1"?u=1:h==="h2"?u=2:h==="h3"?u=3:h==="h4"?u=4:h==="rtgl-text"&&(u=parseInt(c.getAttribute("data-level")||"1",10)),{id:c.id,href:`#${c.id}`,title:c.textContent,level:u}});i.setItems(p),Zr(l,r,s),n();let a=Zr.bind(void 0,l,r,s);return t.addEventListener("scroll",a,{passive:!0}),()=>{t.removeEventListener("scroll",a)}},eo=e=>{let{attrs:t}=e;requestAnimationFrame(()=>{let r=document.getElementById(t["target-id"]),s=window;t["scroll-container-id"]&&(s=document.getElementById(t["scroll-container-id"])||window);let i=parseInt(t["offset-top"]||"100",10),n=Zn(r,s,i,e);return()=>{n()}})};var It={};P(It,{createInitialState:()=>to,selectCurrentId:()=>io,selectState:()=>so,selectViewData:()=>ro,setContentContainer:()=>ao,setCurrentId:()=>oo,setItems:()=>no});var to=()=>Object.freeze({items:[],currentId:null,contentContainer:null}),ro=({state:e})=>{let r=((s,i)=>{let n=new Set,o=s.findIndex(p=>p.id===i);if(o===-1)return n;let l=s[o].level;for(let p=o-1;p>=0;p--)if(s[p].level<l){let a=s[p].level;n.add(s[p].id);for(let c=p-1;c>=0;c--)s[c].level<a&&(n.add(s[c].id),a=s[c].level);break}return n})(e.items,e.currentId);return{items:e.items.map(s=>{let i={1:"0",2:"12px",3:"24px",4:"32px"},n=s.id===e.currentId,o=r.has(s.id),l=n||o;return{...s,c:l?"fg":"mu-fg",ml:i[s.level]||"",bc:l?"fg":"mu-fg"}}),currentId:e.currentId}},so=({state:e})=>e,io=({state:e})=>e.currentId,no=(e,t)=>{e.items=t},oo=(e,t)=>{e.currentId=t},ao=(e,t)=>{e.contentContainer=t};var es={elementName:"rtgl-page-outline",viewDataSchema:{type:"object",properties:{items:{type:"array",items:{type:"object",properties:{slug:{type:"string"},title:{type:"string"}}}},selectedSlug:{type:"string",nullable:!0}}},propsSchema:{type:"object",properties:{}},refs:{},events:{onItemClick:{type:"object"}},template:{type:9,items:[{type:8,properties:[{key:"rtgl-view h=f w=272 pr=md",value:{type:9,items:[{type:8,properties:[{key:"rtgl-view w=f mt=xl",value:{type:9,items:[{type:7,itemVar:"item",indexVar:"i",iterable:{type:1,path:"items"},body:{type:9,items:[{type:8,properties:[{key:'rtgl-view d=h bwl=xs bc="${item.bc}" pv=sm av=c href=${item.href} pl=md',value:{type:9,items:[{type:8,properties:[{key:"rtgl-view w=${item.ml}",value:{type:0,value:null},parsedKey:{type:2,parts:["rtgl-view w=",{type:1,path:"item.ml"}]}}],fast:!0},{type:8,properties:[{key:"rtgl-text s=sm c=${item.c} h-c=fg",value:{type:1,path:"item.title"},parsedKey:{type:2,parts:["rtgl-text s=sm c=",{type:1,path:"item.c"}," h-c=fg"]}}],fast:!0}],fast:!0},parsedKey:{type:2,parts:['rtgl-view d=h bwl=xs bc="',{type:1,path:"item.bc"},'" pv=sm av=c href=',{type:1,path:"item.href"}," pl=md"]}}],fast:!0}],fast:!0}}],fast:!1}}],fast:!1}],fast:!1}}],fast:!1}],fast:!1}};var Tt={};P(Tt,{handleBeforeMount:()=>lo,handleInputChange:()=>ho,handleInputKeydown:()=>yo,handleOnUpdate:()=>po,handlePopoverClose:()=>uo,handleSubmitClick:()=>fo,handleTextClick:()=>co});var lo=e=>{let{store:t,attrs:r}=e;r.value!==void 0&&t.setValue(r.value||"")},po=(e,t)=>{let{oldAttrs:r,newAttrs:s}=t,{store:i,render:n}=e;if(r?.value!==s?.value){let o=s?.value??"";i.setValue(o)}n()},co=(e,t)=>{let{store:r,render:s,getRefIds:i,attrs:n}=e,o=t._event,l=r.selectValue();r.setTempValue(l),r.openPopover({position:{x:o.currentTarget.getBoundingClientRect().left,y:o.currentTarget.getBoundingClientRect().bottom}});let{input:p}=i();p.elm.value=l,s(),n["auto-focus"]&&setTimeout(()=>{p.elm.focus()},50)},uo=(e,t)=>{let{store:r,render:s}=e;r.closePopover(),s()},ho=(e,t)=>{let{store:r,render:s,dispatchEvent:i}=e,o=t._event.detail.value;r.setTempValue(o),i(new CustomEvent("temp-input-change",{detail:{value:o},bubbles:!0})),s()},fo=e=>{let{store:t,render:r,dispatchEvent:s,getRefIds:i}=e,{input:n}=i(),o=n.elm.value;t.setValue(o),t.closePopover(),s(new CustomEvent("input-change",{detail:{value:o},bubbles:!0})),r()},yo=(e,t)=>{let{store:r,render:s,dispatchEvent:i,getRefIds:n}=e,o=t._event;if(o.key==="Enter"){let{input:l}=n(),p=l.elm.value;r.closePopover(),i(new CustomEvent("input-change",{detail:{value:p},bubbles:!0})),s()}else o.key==="Escape"&&(r.closePopover(),s())};var Lt={};P(Lt,{closePopover:()=>wo,createInitialState:()=>mo,openPopover:()=>bo,selectValue:()=>xo,selectViewData:()=>go,setTempValue:()=>vo,setValue:()=>_o});var mo=()=>Object.freeze({isOpen:!1,position:{x:0,y:0},value:"",tempValue:""}),go=({attrs:e,state:t})=>{let r=t.value||"-";return{isOpen:t.isOpen,position:t.position,value:r,tempValue:t.tempValue,placeholder:e.placeholder??"",label:e.label}},vo=(e,t)=>{e.tempValue=t},bo=(e,t)=>{let{position:r}=t;e.position=r,e.isOpen=!0,e.hasUnsavedChanges=!1},wo=e=>{e.isOpen=!1,e.tempValue=""},_o=(e,t)=>{e.value=t},xo=({state:e})=>e.value;var ts={elementName:"rtgl-popover-input",viewDataSchema:{type:"object"},attrsSchema:{type:"object",properties:{value:{type:"string"},placeholder:{type:"string"}}},refs:{"text-display":{eventListeners:{click:{handler:"handleTextClick"}}},popover:{eventListeners:{close:{handler:"handlePopoverClose"}}},input:{eventListeners:{"input-change":{handler:"handleInputChange"},keydown:{handler:"handleInputKeydown"}}},submit:{eventListeners:{click:{handler:"handleSubmitClick"}}}},events:{"input-change":{}},template:{type:9,items:[{type:8,properties:[{key:"rtgl-view#text-display w=f cur=p",value:{type:9,items:[{type:8,properties:[{key:"rtgl-text",value:{type:1,path:"value"}}],fast:!0}],fast:!0}}],fast:!0},{type:8,properties:[{key:"rtgl-popover#popover ?open=${isOpen} x=${position.x} y=${position.y}",value:{type:9,items:[{type:8,properties:[{key:"rtgl-view g=md w=240 slot=content bgc=background br=md",value:{type:9,items:[{type:8,properties:[{key:"rtgl-text",value:{type:1,path:"label"}}],fast:!0},{type:8,properties:[{key:"rtgl-input#input w=f placeholder=${placeholder}",value:{type:0,value:null},parsedKey:{type:2,parts:["rtgl-input#input w=f placeholder=",{type:1,path:"placeholder"}]}}],fast:!0},{type:8,properties:[{key:"rtgl-view w=f ah=e",value:{type:9,items:[{type:8,properties:[{key:"rtgl-button#submit",value:{type:0,value:"Submit"}}],fast:!0}],fast:!0}}],fast:!0}],fast:!0}}],fast:!0}],fast:!0},parsedKey:{type:2,parts:["rtgl-popover#popover ?open=",{type:1,path:"isOpen"}," x=",{type:1,path:"position.x"}," y=",{type:1,path:"position.y"}]}}],fast:!0}],fast:!0}};var Rt={};P(Rt,{handleAddOptionClick:()=>To,handleAddOptionMouseEnter:()=>Lo,handleAddOptionMouseLeave:()=>Ro,handleBeforeMount:()=>Ao,handleButtonClick:()=>ko,handleClearClick:()=>Io,handleClickOptionsPopoverOverlay:()=>$o,handleOnUpdate:()=>Eo,handleOptionClick:()=>So,handleOptionMouseEnter:()=>Co,handleOptionMouseLeave:()=>Oo});var Ao=e=>{let{store:t,props:r,render:s}=e;if(r.selectedValue!==null&&r.selectedValue!==void 0&&r.options){let i=r.options.find(n=>ce(n.value,r.selectedValue));i&&(t.updateSelectedValue({value:i?.value}),s())}},Eo=(e,t)=>{let{oldAttrs:r,newAttrs:s,oldProps:i,newProps:n}=t,{store:o,render:l}=e;if(r?.key!==s?.key&&s?.key){o.resetSelection();let p=n?.selectedValue,a=n?.options||[];if(p!=null&&a){let c=a.find(u=>ce(u.value,p));c&&o.updateSelectedValue({value:c.value})}l()}else i.selectedValue!==n.selectedValue&&(o.updateSelectedValue({value:n.selectedValue}),l())},ko=(e,t)=>{let{store:r,render:s,getRefIds:i,props:n}=e;t._event.stopPropagation();let l=i()["select-button"].elm,p=l.firstElementChild,a=p?p.getBoundingClientRect():l.getBoundingClientRect(),c=r.selectSelectedValue(),u=c!==null?c:n.selectedValue,h=null;u!=null&&n.options&&(h=n.options.findIndex(f=>ce(f.value,u)),h===-1&&(h=null)),r.openOptionsPopover({position:{y:a.bottom+12,x:a.left-24},selectedIndex:h}),s()},$o=e=>{let{store:t,render:r}=e;t.closeOptionsPopover(),r()},So=(e,t)=>{let{render:r,dispatchEvent:s,props:i,store:n}=e,o=t._event;o.stopPropagation();let l=o.currentTarget.id.replace("option-",""),p=i.options[l];n.updateSelectedValue({value:p?.value}),i.onChange&&typeof i.onChange=="function"&&i.onChange(p.value),s(new CustomEvent("option-selected",{detail:{value:p.value,label:p.label},bubbles:!0})),s(new CustomEvent("select-change",{detail:{selectedValue:p.value},bubbles:!0})),r()},Co=(e,t)=>{let{store:r,render:s}=e,i=t._event,n=parseInt(i.currentTarget.id.replace("option-",""));r.setHoveredOption(n),s()},Oo=(e,t)=>{let{store:r,render:s}=e;r.clearHoveredOption(),s()},Io=(e,t)=>{let{store:r,render:s,dispatchEvent:i,props:n}=e;t._event.stopPropagation(),r.clearSelectedValue(),n.onChange&&typeof n.onChange=="function"&&n.onChange(void 0),i(new CustomEvent("option-selected",{detail:{value:void 0,label:void 0},bubbles:!0})),i(new CustomEvent("select-change",{detail:{selectedValue:void 0},bubbles:!0})),s()},To=(e,t)=>{let{store:r,render:s,dispatchEvent:i}=e,{_event:n}=t;n.stopPropagation(),r.closeOptionsPopover(),i(new CustomEvent("add-option-selected",{bubbles:!0})),s()},Lo=(e,t)=>{let{store:r,render:s}=e;r.setHoveredAddOption(!0),s()},Ro=(e,t)=>{let{store:r,render:s}=e;r.setHoveredAddOption(!1),s()};var Nt={};P(Nt,{clearHoveredOption:()=>zo,clearSelectedValue:()=>Ho,closeOptionsPopover:()=>Mo,createInitialState:()=>Vo,openOptionsPopover:()=>Wo,resetSelection:()=>Uo,selectSelectedValue:()=>Bo,selectState:()=>jo,selectViewData:()=>Do,setHoveredAddOption:()=>Jo,setHoveredOption:()=>Ko,updateSelectedValue:()=>Fo});var No=["id","class","style","slot","placeholder","selectedValue","selected-value","onChange","on-change","options"],Po=e=>Object.entries(e||{}).filter(([t])=>!No.includes(t)).map(([t,r])=>`${t}=${r}`).join(" "),Vo=()=>Object.freeze({isOpen:!1,position:{x:0,y:0},selectedValue:null,hoveredOptionId:null,hoveredAddOption:!1}),Do=({state:e,props:t,attrs:r})=>{let s=Po(r),i=e.selectedValue!==null?e.selectedValue:t.selectedValue,n=r.placeholder||"Select an option",o=!0,l=t.options||[],p=l.find(c=>ce(c.value,i));p&&(n=p.label,o=!1);let a=l.map((c,u)=>{let h=ce(c.value,i),f=e.hoveredOptionId===u;return{...c,isSelected:h,bgc:f?"ac":h?"mu":""}});return{containerAttrString:s,isOpen:e.isOpen,position:e.position,options:a,selectedValue:i,selectedLabel:n,selectedLabelColor:o?"mu-fg":"fg",hasValue:i!=null,showClear:!r["no-clear"]&&!t["no-clear"]&&i!=null,showAddOption:!!t.addOption,addOptionLabel:t.addOption?.label?`+ ${t.addOption.label}`:"+ Add",addOptionBgc:e.hoveredAddOption?"ac":""}},jo=({state:e})=>e,Bo=({state:e})=>e.selectedValue,Wo=(e,t)=>{let{position:r,selectedIndex:s}=t;e.position=r,e.isOpen=!0,s!=null&&(e.hoveredOptionId=s)},Mo=e=>{e.isOpen=!1},Fo=(e,t)=>{e.selectedValue=t.value,e.isOpen=!1},Uo=e=>{e.selectedValue=void 0},Ko=(e,t)=>{e.hoveredOptionId=t},zo=e=>{e.hoveredOptionId=null},Ho=e=>{e.selectedValue=void 0},Jo=(e,t)=>{e.hoveredAddOption=t};var rs={elementName:"rtgl-select",viewDataSchema:{type:"object"},attrsSchema:{type:"object",properties:{placeholder:{type:"string"}}},propsSchema:{type:"object",properties:{options:{type:"array",items:{type:"object",properties:{label:{type:"string"},value:{type:"any"}}}},selectedValue:{type:"any"},onChange:{type:"function"},"no-clear":{type:"boolean"},addOption:{type:"object",properties:{label:{type:"string"}}}}},refs:{"select-button":{eventListeners:{click:{handler:"handleButtonClick"}}},"clear-button":{eventListeners:{click:{handler:"handleClearClick"}}},popover:{eventListeners:{close:{handler:"handleClickOptionsPopoverOverlay"}}},"option-*":{eventListeners:{click:{handler:"handleOptionClick"},mouseenter:{handler:"handleOptionMouseEnter"},mouseleave:{handler:"handleOptionMouseLeave"}}},"option-add":{eventListeners:{click:{handler:"handleAddOptionClick"},mouseenter:{handler:"handleAddOptionMouseEnter"},mouseleave:{handler:"handleAddOptionMouseLeave"}}}},events:{},template:{type:9,items:[{type:8,properties:[{key:"rtgl-button#select-button v=ol ${containerAttrString}",value:{type:9,items:[{type:8,properties:[{key:"rtgl-view d=h av=c w=f",value:{type:9,items:[{type:8,properties:[{key:"rtgl-text c=${selectedLabelColor}",value:{type:1,path:"selectedLabel"},parsedKey:{type:2,parts:["rtgl-text c=",{type:1,path:"selectedLabelColor"}]}}],fast:!0},{type:8,properties:[{key:"rtgl-view mh=md flex=1",value:{type:0,value:null}}],fast:!0},{type:8,properties:[{key:"$if showClear",value:{type:6,conditions:[{type:1,path:"showClear"}],bodies:[{type:9,items:[{type:8,properties:[{key:"rtgl-svg#clear-button mr=md svg=x wh=16 c=mu-fg cur=p",value:{type:0,value:null}}],fast:!0}],fast:!0}],id:null}}],fast:!1},{type:8,properties:[{key:"rtgl-svg svg=chevronDown wh=16 c=mu-fg",value:{type:0,value:null}}],fast:!0}],fast:!1}}],fast:!1}],fast:!1},parsedKey:{type:2,parts:["rtgl-button#select-button v=ol ",{type:1,path:"containerAttrString"}]}}],fast:!1},{type:8,properties:[{key:"rtgl-popover#popover ?open=${isOpen} x=${position.x} y=${position.y} placement=right-start",value:{type:9,items:[{type:8,properties:[{key:"rtgl-view wh=300 g=xs slot=content bgc=background br=md sv=true",value:{type:9,items:[{type:7,itemVar:"option",indexVar:"i",iterable:{type:1,path:"options"},body:{type:9,items:[{type:8,properties:[{key:"rtgl-view#option-${i} w=f ph=lg pv=md cur=p br=md bgc=${option.bgc}",value:{type:9,items:[{type:8,properties:[{key:"rtgl-text",value:{type:1,path:"option.label"}}],fast:!0}],fast:!0},parsedKey:{type:2,parts:["rtgl-view#option-",{type:1,path:"i"}," w=f ph=lg pv=md cur=p br=md bgc=",{type:1,path:"option.bgc"}]}}],fast:!0}],fast:!0}},{type:8,properties:[{key:"$if showAddOption",value:{type:6,conditions:[{type:1,path:"showAddOption"}],bodies:[{type:9,items:[{type:8,properties:[{key:"rtgl-view w=f bw=xs bc=mu-bg bt=sm",value:{type:0,value:null}}],fast:!0},{type:8,properties:[{key:"rtgl-view#option-add w=f ph=lg pv=md cur=p br=md bgc=${addOptionBgc}",value:{type:9,items:[{type:8,properties:[{key:"rtgl-text c=ac",value:{type:1,path:"addOptionLabel"}}],fast:!0}],fast:!0},parsedKey:{type:2,parts:["rtgl-view#option-add w=f ph=lg pv=md cur=p br=md bgc=",{type:1,path:"addOptionBgc"}]}}],fast:!0}],fast:!0}],id:null}}],fast:!1}],fast:!1}}],fast:!1}],fast:!1},parsedKey:{type:2,parts:["rtgl-popover#popover ?open=",{type:1,path:"isOpen"}," x=",{type:1,path:"position.x"}," y=",{type:1,path:"position.y"}," placement=right-start"]}}],fast:!1}],fast:!1}};var Pt={};P(Pt,{handleHeaderClick:()=>qo,handleItemClick:()=>Yo});var qo=(e,t)=>{let{store:r,dispatchEvent:s}=e,i=t._event,n,o=r.selectHeader();i.currentTarget.id==="header-label"?n=o.labelPath:i.currentTarget.id==="header-image"?n=o.image.path:i.currentTarget.id==="header"&&(n=o.path),s(new CustomEvent("headerClick",{detail:{path:n},bubbles:!0,composed:!0}))},Yo=(e,t)=>{let{store:r,dispatchEvent:s}=e,n=t._event.currentTarget.id.replace("item-",""),o=r.selectItem(n);s(new CustomEvent("itemClick",{detail:{item:o},bubbles:!0,composed:!0}))};var Dt={};P(Dt,{createInitialState:()=>Go,selectActiveItem:()=>ta,selectHeader:()=>ea,selectItem:()=>ra,selectViewData:()=>Zo,setState:()=>sa});var Go=()=>Object.freeze({}),Xo=["id","class","style","slot"],Qo=e=>Object.entries(e).filter(([t])=>!Xo.includes(t)).map(([t,r])=>`${t}=${r}`).join(" ");function Vt(e,t=null){let r=[];for(let s of e){let i=s.id||s.href||s.path,n=t===i;if(r.push({id:i,title:s.title,href:s.href,type:s.type||"item",icon:s.icon,hrefAttr:s.href?`href=${s.href}`:"",isSelected:n,itemBgc:n?"ac":"bg",itemHoverBgc:n?"ac":"mu"}),s.items&&Array.isArray(s.items))for(let o of s.items){let l=o.id||o.href||o.path,p=t===l;r.push({id:l,title:o.title,href:o.href,type:o.type||"item",icon:o.icon,hrefAttr:o.href?`href=${o.href}`:"",isSelected:p,itemBgc:p?"ac":"bg",itemHoverBgc:p?"ac":"mu"})}}return r}var Zo=({state:e,props:t,attrs:r})=>{let s=r.header?JSON.parse(decodeURIComponent(r.header)):t.header,i=r.items?JSON.parse(decodeURIComponent(r.items)):t.items,n=r.selectedItemId||t.selectedItemId,o=Qo(r),l=r.mode||"full",p=s||{label:"",path:"",image:{src:"",alt:"",width:0,height:0}},a=i?Vt(i,n):[],c=l==="full"?272:64,u=l==="full"?"fs":"c",h=l==="full"?"fs":"c",f=l==="full"?"lg":"sm",d=l==="full"?"md":"sm",y=l==="shrunk-lg"?48:40,b=l==="shrunk-lg"?28:20,m=l==="shrunk-lg"?"md":"sm",w=l==="full",_=l==="full",x=l==="full"?"fs":"c",E=l==="full"?"":`ah=${h}`,$=l==="full"?"f":y;return{containerAttrString:o,mode:l,header:p,items:a,sidebarWidth:c,headerAlign:u,itemAlign:h,headerPadding:f,itemPadding:d,itemHeight:y,iconSize:b,firstLetterSize:m,showLabels:w,showGroupLabels:_,itemContentAlign:x,itemAlignAttr:E,itemWidth:$,headerWidth:$,selectedItemId:n,ah:l==="shrunk-lg"||l==="shrunk-md"?"c":""}},ea=({state:e,props:t,attrs:r})=>r.header?JSON.parse(decodeURIComponent(r.header)):t.header,ta=({state:e,props:t})=>(t.items?Vt(t.items):[]).find(s=>s.active),ra=({state:e,props:t,attrs:r},s)=>{let i=r.items?JSON.parse(decodeURIComponent(r.items)):t.items;return(i?Vt(i):[]).find(o=>o.id===s)},sa=e=>{};var ss={elementName:"rtgl-sidebar",viewDataSchema:{type:"object",properties:{containerAttrString:{type:"string"},mode:{type:"string",enum:["full","shrunk","shrunk-lg"],default:"full"},sidebarWidth:{type:"number"},headerAlign:{type:"string"},itemAlign:{type:"string"},headerPadding:{type:"string"},itemPadding:{type:"string"},itemHeight:{type:"number"},iconSize:{type:"number"},firstLetterSize:{type:"string"},showLabels:{type:"boolean"},showGroupLabels:{type:"boolean"},itemContentAlign:{type:"string"},itemAlignAttr:{type:"string"},itemWidth:{type:"string"},headerWidth:{type:"string"},selectedItemId:{type:"string"},header:{type:"object",properties:{label:{type:"string"},href:{type:"string"},image:{type:"object",properties:{src:{type:"string"},width:{type:"number"},height:{type:"number"},alt:{type:"string"}}}}},items:{type:"array",items:{type:"object",properties:{title:{type:"string"},slug:{type:"string"},type:{type:"string"},active:{type:"boolean"},icon:{type:"string"}}}}}},propsSchema:{type:"object",properties:{selectedItemId:{type:"string"},header:{type:"object",properties:{label:{type:"string"},href:{type:"string"},image:{type:"object",properties:{src:{type:"string"},width:{type:"number"},height:{type:"number"},alt:{type:"string"}}}}},items:{type:"array",items:{type:"object",properties:{title:{type:"string"},slug:{type:"string"},type:{type:"string"},items:{type:"array"}}}}}},refs:{"header-image":{eventListeners:{click:{handler:"handleHeaderClick"}}},"header-label":{eventListeners:{click:{handler:"handleHeaderClick"}}},header:{eventListeners:{click:{handler:"handleHeaderClick"}}},"item-*":{eventListeners:{click:{handler:"handleItemClick"}}}},events:{headerClick:{type:"object",properties:{path:{type:"string"}}}},anchors:[[{"$if header.image && header.image.src":[{"$if header.image.href":[{"a href=${header.image.href}":[{'rtgl-image w=${header.image.width} h=${header.image.height} src=${header.image.src} alt="${header.image.alt}"':null}]}],"$elif header.image.path":[{"rtgl-view#header-image cur=p":[{'rtgl-image w=${header.image.width} h=${header.image.height} src=${header.image.src} alt="${header.image.alt}"':null}]}],$else:[{'rtgl-image w=${header.image.width} h=${header.image.height} src=${header.image.src} alt="${header.image.alt}"':null}]}]},{"$if header.label && showLabels":[{"$if header.labelHref":[{"rtgl-text href=${header.labelHref} s=lg":"${header.label}"}],"$elif header.labelPath":[{"rtgl-view#header-label cur=p":[{"rtgl-text s=lg":"${header.label}"}]}],$else:[{"rtgl-text s=lg":"${header.label}"}]}]}]],template:{type:9,items:[{type:8,properties:[{key:"rtgl-view h=f w=${sidebarWidth} bwr=xs ah=${ah} ${containerAttrString}",value:{type:9,items:[{type:8,properties:[{key:"rtgl-view ph=${headerPadding} pv=lg",value:{type:9,items:[{type:8,properties:[{key:"$if header.href",value:{type:6,conditions:[{type:1,path:"header.href"},null],bodies:[{type:9,items:[{type:8,properties:[{key:"rtgl-view href=${header.href} d=h av=c ah=${headerAlign} g=lg w=${headerWidth}",value:{type:9,items:[{type:9,items:[{type:8,properties:[{key:"$if header.image && header.image.src",value:{type:6,conditions:[{type:4,op:6,left:{type:1,path:"header.image"},right:{type:1,path:"header.image.src"}}],bodies:[{type:9,items:[{type:8,properties:[{key:"$if header.image.href",value:{type:6,conditions:[{type:1,path:"header.image.href"},{type:1,path:"header.image.path"},null],bodies:[{type:9,items:[{type:8,properties:[{key:"a href=${header.image.href}",value:{type:9,items:[{type:8,properties:[{key:'rtgl-image w=${header.image.width} h=${header.image.height} src=${header.image.src} alt="${header.image.alt}"',value:{type:0,value:null},parsedKey:{type:2,parts:["rtgl-image w=",{type:1,path:"header.image.width"}," h=",{type:1,path:"header.image.height"}," src=",{type:1,path:"header.image.src"},' alt="',{type:1,path:"header.image.alt"},'"']}}],fast:!0}],fast:!0},parsedKey:{type:2,parts:["a href=",{type:1,path:"header.image.href"}]}}],fast:!0}],fast:!0},{type:9,items:[{type:8,properties:[{key:"rtgl-view#header-image cur=p",value:{type:9,items:[{type:8,properties:[{key:'rtgl-image w=${header.image.width} h=${header.image.height} src=${header.image.src} alt="${header.image.alt}"',value:{type:0,value:null},parsedKey:{type:2,parts:["rtgl-image w=",{type:1,path:"header.image.width"}," h=",{type:1,path:"header.image.height"}," src=",{type:1,path:"header.image.src"},' alt="',{type:1,path:"header.image.alt"},'"']}}],fast:!0}],fast:!0}}],fast:!0}],fast:!0},{type:9,items:[{type:8,properties:[{key:'rtgl-image w=${header.image.width} h=${header.image.height} src=${header.image.src} alt="${header.image.alt}"',value:{type:0,value:null},parsedKey:{type:2,parts:["rtgl-image w=",{type:1,path:"header.image.width"}," h=",{type:1,path:"header.image.height"}," src=",{type:1,path:"header.image.src"},' alt="',{type:1,path:"header.image.alt"},'"']}}],fast:!0}],fast:!0}],id:null}}],fast:!1}],fast:!1}],id:null}}],fast:!1},{type:8,properties:[{key:"$if header.label && showLabels",value:{type:6,conditions:[{type:4,op:6,left:{type:1,path:"header.label"},right:{type:1,path:"showLabels"}}],bodies:[{type:9,items:[{type:8,properties:[{key:"$if header.labelHref",value:{type:6,conditions:[{type:1,path:"header.labelHref"},{type:1,path:"header.labelPath"},null],bodies:[{type:9,items:[{type:8,properties:[{key:"rtgl-text href=${header.labelHref} s=lg",value:{type:1,path:"header.label"},parsedKey:{type:2,parts:["rtgl-text href=",{type:1,path:"header.labelHref"}," s=lg"]}}],fast:!0}],fast:!0},{type:9,items:[{type:8,properties:[{key:"rtgl-view#header-label cur=p",value:{type:9,items:[{type:8,properties:[{key:"rtgl-text s=lg",value:{type:1,path:"header.label"}}],fast:!0}],fast:!0}}],fast:!0}],fast:!0},{type:9,items:[{type:8,properties:[{key:"rtgl-text s=lg",value:{type:1,path:"header.label"}}],fast:!0}],fast:!0}],id:null}}],fast:!1}],fast:!1}],id:null}}],fast:!1}],fast:!1}],fast:!1},parsedKey:{type:2,parts:["rtgl-view href=",{type:1,path:"header.href"}," d=h av=c ah=",{type:1,path:"headerAlign"}," g=lg w=",{type:1,path:"headerWidth"}]}}],fast:!1}],fast:!1},{type:9,items:[{type:8,properties:[{key:"rtgl-view#header d=h av=c ah=${headerAlign} g=lg w=${headerWidth} cur=p",value:{type:9,items:[{type:9,items:[{type:8,properties:[{key:"$if header.image && header.image.src",value:{type:6,conditions:[{type:4,op:6,left:{type:1,path:"header.image"},right:{type:1,path:"header.image.src"}}],bodies:[{type:9,items:[{type:8,properties:[{key:"$if header.image.href",value:{type:6,conditions:[{type:1,path:"header.image.href"},{type:1,path:"header.image.path"},null],bodies:[{type:9,items:[{type:8,properties:[{key:"a href=${header.image.href}",value:{type:9,items:[{type:8,properties:[{key:'rtgl-image w=${header.image.width} h=${header.image.height} src=${header.image.src} alt="${header.image.alt}"',value:{type:0,value:null},parsedKey:{type:2,parts:["rtgl-image w=",{type:1,path:"header.image.width"}," h=",{type:1,path:"header.image.height"}," src=",{type:1,path:"header.image.src"},' alt="',{type:1,path:"header.image.alt"},'"']}}],fast:!0}],fast:!0},parsedKey:{type:2,parts:["a href=",{type:1,path:"header.image.href"}]}}],fast:!0}],fast:!0},{type:9,items:[{type:8,properties:[{key:"rtgl-view#header-image cur=p",value:{type:9,items:[{type:8,properties:[{key:'rtgl-image w=${header.image.width} h=${header.image.height} src=${header.image.src} alt="${header.image.alt}"',value:{type:0,value:null},parsedKey:{type:2,parts:["rtgl-image w=",{type:1,path:"header.image.width"}," h=",{type:1,path:"header.image.height"}," src=",{type:1,path:"header.image.src"},' alt="',{type:1,path:"header.image.alt"},'"']}}],fast:!0}],fast:!0}}],fast:!0}],fast:!0},{type:9,items:[{type:8,properties:[{key:'rtgl-image w=${header.image.width} h=${header.image.height} src=${header.image.src} alt="${header.image.alt}"',value:{type:0,value:null},parsedKey:{type:2,parts:["rtgl-image w=",{type:1,path:"header.image.width"}," h=",{type:1,path:"header.image.height"}," src=",{type:1,path:"header.image.src"},' alt="',{type:1,path:"header.image.alt"},'"']}}],fast:!0}],fast:!0}],id:null}}],fast:!1}],fast:!1}],id:null}}],fast:!1},{type:8,properties:[{key:"$if header.label && showLabels",value:{type:6,conditions:[{type:4,op:6,left:{type:1,path:"header.label"},right:{type:1,path:"showLabels"}}],bodies:[{type:9,items:[{type:8,properties:[{key:"$if header.labelHref",value:{type:6,conditions:[{type:1,path:"header.labelHref"},{type:1,path:"header.labelPath"},null],bodies:[{type:9,items:[{type:8,properties:[{key:"rtgl-text href=${header.labelHref} s=lg",value:{type:1,path:"header.label"},parsedKey:{type:2,parts:["rtgl-text href=",{type:1,path:"header.labelHref"}," s=lg"]}}],fast:!0}],fast:!0},{type:9,items:[{type:8,properties:[{key:"rtgl-view#header-label cur=p",value:{type:9,items:[{type:8,properties:[{key:"rtgl-text s=lg",value:{type:1,path:"header.label"}}],fast:!0}],fast:!0}}],fast:!0}],fast:!0},{type:9,items:[{type:8,properties:[{key:"rtgl-text s=lg",value:{type:1,path:"header.label"}}],fast:!0}],fast:!0}],id:null}}],fast:!1}],fast:!1}],id:null}}],fast:!1}],fast:!1}],fast:!1},parsedKey:{type:2,parts:["rtgl-view#header d=h av=c ah=",{type:1,path:"headerAlign"}," g=lg w=",{type:1,path:"headerWidth"}," cur=p"]}}],fast:!1}],fast:!1}],id:null}}],fast:!1}],fast:!1},parsedKey:{type:2,parts:["rtgl-view ph=",{type:1,path:"headerPadding"}," pv=lg"]}}],fast:!1},{type:8,properties:[{key:"rtgl-view w=f ph=${headerPadding} pb=lg g=xs ah=${ah}",value:{type:9,items:[{type:7,itemVar:"item",indexVar:"i",iterable:{type:1,path:"items"},body:{type:9,items:[{type:8,properties:[{key:'$if item.type == "groupLabel"',value:{type:6,conditions:[{type:4,op:0,left:{type:1,path:"item.type"},right:{type:0,value:"groupLabel"}},null],bodies:[{type:9,items:[{type:8,properties:[{key:"$if showGroupLabels",value:{type:6,conditions:[{type:1,path:"showGroupLabels"},null],bodies:[{type:9,items:[{type:8,properties:[{key:"rtgl-view mt=md h=32 av=c ph=md",value:{type:9,items:[{type:8,properties:[{key:"rtgl-text s=xs c=mu-fg",value:{type:1,path:"item.title"}}],fast:!0}],fast:!0}}],fast:!0}],fast:!0},{type:9,items:[{type:8,properties:[{key:"rtgl-view mt=md h=1 bgc=mu-bg",value:{type:0,value:null}}],fast:!0}],fast:!0}],id:null}}],fast:!1}],fast:!1},{type:9,items:[{type:8,properties:[{key:"rtgl-view#item-${item.id} ${item.hrefAttr} h=${itemHeight} av=c ${itemAlignAttr} ph=${itemPadding} w=${itemWidth} h-bgc=${item.itemHoverBgc} br=lg bgc=${item.itemBgc} cur=p",value:{type:9,items:[{type:8,properties:[{key:"$if item.icon",value:{type:6,conditions:[{type:1,path:"item.icon"},null],bodies:[{type:9,items:[{type:8,properties:[{key:"$if showLabels",value:{type:6,conditions:[{type:1,path:"showLabels"},null],bodies:[{type:9,items:[{type:8,properties:[{key:"rtgl-view d=h ah=${itemContentAlign} g=sm",value:{type:9,items:[{type:8,properties:[{key:"rtgl-svg wh=16 svg=${item.icon} c=fg",value:{type:0,value:null},parsedKey:{type:2,parts:["rtgl-svg wh=16 svg=",{type:1,path:"item.icon"}," c=fg"]}}],fast:!0},{type:8,properties:[{key:"rtgl-text s=sm",value:{type:1,path:"item.title"}}],fast:!0}],fast:!0},parsedKey:{type:2,parts:["rtgl-view d=h ah=",{type:1,path:"itemContentAlign"}," g=sm"]}}],fast:!0}],fast:!0},{type:9,items:[{type:8,properties:[{key:"rtgl-svg wh=${iconSize} svg=${item.icon} c=fg",value:{type:0,value:null},parsedKey:{type:2,parts:["rtgl-svg wh=",{type:1,path:"iconSize"}," svg=",{type:1,path:"item.icon"}," c=fg"]}}],fast:!0}],fast:!0}],id:null}}],fast:!1}],fast:!1},{type:9,items:[{type:8,properties:[{key:"$if showLabels",value:{type:6,conditions:[{type:1,path:"showLabels"},null],bodies:[{type:9,items:[{type:8,properties:[{key:"rtgl-text s=sm",value:{type:1,path:"item.title"}}],fast:!0}],fast:!0},{type:9,items:[{type:8,properties:[{key:"rtgl-view wh=${iconSize} br=f bgc=mu av=c ah=c",value:{type:9,items:[{type:8,properties:[{key:"rtgl-text s=${firstLetterSize} c=fg",value:{type:1,path:"item.title.charAt(0).toUpperCase()"},parsedKey:{type:2,parts:["rtgl-text s=",{type:1,path:"firstLetterSize"}," c=fg"]}}],fast:!0}],fast:!0},parsedKey:{type:2,parts:["rtgl-view wh=",{type:1,path:"iconSize"}," br=f bgc=mu av=c ah=c"]}}],fast:!0}],fast:!0}],id:null}}],fast:!1}],fast:!1}],id:null}}],fast:!1}],fast:!1},parsedKey:{type:2,parts:["rtgl-view#item-",{type:1,path:"item.id"}," ",{type:1,path:"item.hrefAttr"}," h=",{type:1,path:"itemHeight"}," av=c ",{type:1,path:"itemAlignAttr"}," ph=",{type:1,path:"itemPadding"}," w=",{type:1,path:"itemWidth"}," h-bgc=",{type:1,path:"item.itemHoverBgc"}," br=lg bgc=",{type:1,path:"item.itemBgc"}," cur=p"]}}],fast:!1}],fast:!1}],id:null}}],fast:!1}],fast:!1}}],fast:!1},parsedKey:{type:2,parts:["rtgl-view w=f ph=",{type:1,path:"headerPadding"}," pb=lg g=xs ah=",{type:1,path:"ah"}]}}],fast:!1}],fast:!1},parsedKey:{type:2,parts:["rtgl-view h=f w=",{type:1,path:"sidebarWidth"}," bwr=xs ah=",{type:1,path:"ah"}," ",{type:1,path:"containerAttrString"}]}}],fast:!1}],fast:!1}};var jt={};P(jt,{handleBeforeMount:()=>ia,handleOnUpdate:()=>na,handleValueChange:()=>oa});var ia=e=>{let{store:t,attrs:r}=e;t.setValue(r.value??0)},na=(e,t)=>{let{oldAttrs:r,newAttrs:s}=t,{store:i,render:n}=e;if(r?.value!==s?.value){let o=s?.value??0;i.setValue(o),n()}},oa=(e,t)=>{let{store:r,render:s,dispatchEvent:i}=e,n=t._event,o=Number(n.detail.value);r.setValue(o),s(),i(new CustomEvent("slider-input-value-change",{detail:{value:o},bubbles:!0}))};var Bt={};P(Bt,{createInitialState:()=>aa,selectViewData:()=>la,setValue:()=>pa});var aa=()=>Object.freeze({value:0}),la=({state:e,attrs:t})=>({key:t.key,value:e.value,w:t.w||"",min:t.min||0,max:t.max||100,step:t.step||1}),pa=(e,t)=>{e.value=t};var is={elementName:"rtgl-slider-input",viewDataSchema:{type:"object"},attrsSchema:{type:"object",properties:{value:{type:"string",default:"0"},w:{type:"string",default:""},min:{type:"string",default:"0"},max:{type:"string",default:"100"},step:{type:"string",default:"1"}}},refs:{input:{eventListeners:{"input-change":{handler:"handleValueChange"}}},slider:{eventListeners:{"slider-change":{handler:"handleValueChange"}}}},events:{"form-change":{}},template:{type:9,items:[{type:8,properties:[{key:"rtgl-view d=h av=c g=md w=${w}",value:{type:9,items:[{type:8,properties:[{key:"rtgl-slider#slider key=${key} w=f type=range min=${min} max=${max} step=${step} value=${value}",value:{type:0,value:null},parsedKey:{type:2,parts:["rtgl-slider#slider key=",{type:1,path:"key"}," w=f type=range min=",{type:1,path:"min"}," max=",{type:1,path:"max"}," step=",{type:1,path:"step"}," value=",{type:1,path:"value"}]}}],fast:!0},{type:8,properties:[{key:"rtgl-view w=84",value:{type:9,items:[{type:8,properties:[{key:"rtgl-input#input key=${key} w=f type=number min=${min} max=${max} step=${step} value=${value}",value:{type:0,value:null},parsedKey:{type:2,parts:["rtgl-input#input key=",{type:1,path:"key"}," w=f type=number min=",{type:1,path:"min"}," max=",{type:1,path:"max"}," step=",{type:1,path:"step"}," value=",{type:1,path:"value"}]}}],fast:!0}],fast:!0}}],fast:!0}],fast:!0},parsedKey:{type:2,parts:["rtgl-view d=h av=c g=md w=",{type:1,path:"w"}]}}],fast:!0}],fast:!0}};var Wt={};P(Wt,{handleBeforeMount:()=>ca,handleHeaderClick:()=>ha,handleRowClick:()=>ua});var ca=e=>{},ua=(e,t)=>{let{dispatchEvent:r,props:s}=e,i=t._event,n=parseInt(i.currentTarget.id.replace("row-","")),o=s.data?.rows?.[n];o&&r(new CustomEvent("row-click",{detail:{rowIndex:n,rowData:o}}))},ha=(e,t)=>{let{store:r,render:s,dispatchEvent:i}=e,o=t._event.currentTarget.id.replace("header-",""),l=r.selectSortInfo(),p="asc";l.column===o&&(l.direction==="asc"?p="desc":l.direction==="desc"&&(p=null)),p?r.setSortColumn({column:o,direction:p}):r.clearSort(),s(),i(new CustomEvent("header-click",{detail:{column:o,direction:p,sortInfo:p?{column:o,direction:p}:null}}))};var Mt={};P(Mt,{clearSort:()=>_a,createInitialState:()=>da,selectSortInfo:()=>ba,selectState:()=>va,selectViewData:()=>ga,setSortColumn:()=>wa});var da=()=>Object.freeze({sortColumn:null,sortDirection:null}),fa=["id","class","style","slot"],ya=e=>Object.entries(e).filter(([t])=>!fa.includes(t)).map(([t,r])=>`${t}=${r}`).join(" "),ma=(e,t)=>{let r=t.split("."),s=e;for(let i of r){if(s==null)return null;s=s[i]}return s},ga=({state:e,props:t,attrs:r})=>{let s=ya(r),i=t.data||{columns:[],rows:[]},n=i.rows.map((o,l)=>{let p=i.columns.map(a=>{let c=ma(o,a.key);return{key:a.key,value:c!=null?String(c):""}});return{index:l,cells:p}});return{containerAttrString:s,columns:i.columns||[],rows:n||[]}},va=({state:e})=>e,ba=({state:e})=>({column:e.sortColumn,direction:e.sortDirection}),wa=(e,{column:t,direction:r})=>{e.sortColumn=t,e.sortDirection=r},_a=e=>{e.sortColumn=null,e.sortDirection=null};var ns={elementName:"rtgl-table",viewDataSchema:{type:"object",properties:{columns:{type:"array"},rows:{type:"array"},containerAttrString:{type:"string"}}},propsSchema:{type:"object",properties:{data:{type:"object",properties:{columns:{type:"array",items:{type:"object",properties:{key:{type:"string"},label:{type:"string"}}}},rows:{type:"array",items:{type:"object"}}}},responsive:{type:"boolean",default:!0}}},refs:{"row-*":{eventListeners:{click:{handler:"handleRowClick"}}},"header-*":{eventListeners:{click:{handler:"handleHeaderClick"}}}},events:{},styles:{table:{width:"100%","border-collapse":"collapse","border-spacing":0},thead:{"border-bottom":"2px solid var(--border)"},th:{padding:"12px","text-align":"left","font-weight":500,color:"var(--foreground)","background-color":"var(--muted)",cursor:"pointer",position:"sticky",top:0,"z-index":1},"tbody tr":{"border-bottom":"1px solid var(--border)"},"tbody tr:last-child":{"border-bottom":"none"},td:{padding:"12px",color:"var(--foreground)"},".table-container":{width:"100%",height:"100%",overflow:"auto"},".empty-state":{"text-align":"center",padding:"24px",color:"var(--muted-foreground)"}},template:{type:9,items:[{type:8,properties:[{key:"rtgl-view.table-container ${containerAttrString}",value:{type:9,items:[{type:8,properties:[{key:"$if rows.length > 0",value:{type:6,conditions:[{type:4,op:2,left:{type:1,path:"rows.length"},right:{type:0,value:0}},null],bodies:[{type:9,items:[{type:8,properties:[{key:"table",value:{type:9,items:[{type:8,properties:[{key:"thead",value:{type:9,items:[{type:8,properties:[{key:"tr",value:{type:9,items:[{type:7,itemVar:"column",indexVar:"i",iterable:{type:1,path:"columns"},body:{type:9,items:[{type:8,properties:[{key:"th#header-${column.key}",value:{type:1,path:"column.label"},parsedKey:{type:2,parts:["th#header-",{type:1,path:"column.key"}]}}],fast:!0}],fast:!0}}],fast:!1}}],fast:!1}],fast:!1}}],fast:!1},{type:8,properties:[{key:"tbody",value:{type:9,items:[{type:7,itemVar:"row",indexVar:"rowIndex",iterable:{type:1,path:"rows"},body:{type:9,items:[{type:8,properties:[{key:"tr#row-${row.index}",value:{type:9,items:[{type:7,itemVar:"cell",indexVar:"cellIndex",iterable:{type:1,path:"row.cells"},body:{type:9,items:[{type:8,properties:[{key:"td",value:{type:1,path:"cell.value"}}],fast:!0}],fast:!0}}],fast:!1},parsedKey:{type:2,parts:["tr#row-",{type:1,path:"row.index"}]}}],fast:!1}],fast:!1}}],fast:!1}}],fast:!1}],fast:!1}}],fast:!1}],fast:!1},{type:9,items:[{type:8,properties:[{key:"rtgl-view.empty-state w=f p=xl",value:{type:9,items:[{type:8,properties:[{key:"rtgl-text c=mu-fg",value:{type:0,value:"No data available"}}],fast:!0}],fast:!0}}],fast:!0}],fast:!0}],id:null}}],fast:!1}],fast:!1},parsedKey:{type:2,parts:["rtgl-view.table-container ",{type:1,path:"containerAttrString"}]}}],fast:!1}],fast:!1}};var Ft={};P(Ft,{handleClickItem:()=>xa});var xa=(e,t)=>{let{dispatchEvent:r}=e,i=t._event.currentTarget.dataset.id;r(new CustomEvent("item-click",{detail:{id:i}}))};var Ut={};P(Ut,{createInitialState:()=>Aa,selectViewData:()=>$a});var Aa=()=>Object.freeze({}),Ea=["id","class","style","slot"],ka=e=>Object.entries(e).filter(([t])=>!Ea.includes(t)).map(([t,r])=>`${t}=${r}`).join(" "),$a=({state:e,props:t,attrs:r})=>{let s=ka(r),i=t.items||[],n=r["selected-tab"],o=i.map(l=>({...l,isSelected:l.id===n,bgColor:l.id===n?"ac":"",borderColor:l.id===n?"":"tr",textColor:l.id===n?"":"mu-fg"}));return{containerAttrString:s,items:o,selectedTab:n}};var os={elementName:"rtgl-tabs",viewDataSchema:{type:"object",properties:{containerAttrString:{type:"string"},items:{type:"array",items:{type:"object",properties:{label:{type:"string"},id:{type:"string"},isSelected:{type:"boolean"},bgColor:{type:"string"},textColor:{type:"string"},borderColor:{type:"string"}}}},selectedTab:{type:"string"}}},propsSchema:{type:"object",properties:{items:{type:"array",items:{type:"object",properties:{label:{type:"string"},id:{type:"string"}}}}}},attrsSchema:{type:"object",properties:{"selected-tab":{type:"string"}}},refs:{"tab-*":{eventListeners:{click:{handler:"handleClickItem"}}}},events:{"item-click":{type:"object",properties:{id:{type:"string"}}}},template:{type:9,items:[{type:8,properties:[{key:"rtgl-view d=h g=sm bgc=mu p=sm br=lg ${containerAttrString}",value:{type:9,items:[{type:7,itemVar:"item",indexVar:null,iterable:{type:1,path:"items"},body:{type:9,items:[{type:8,properties:[{key:"rtgl-view#tab-${item.id} data-id=${item.id} cur=p bgc=${item.bgColor} bw=xs bc=${item.borderColor} pv=md ph=lg br=lg",value:{type:9,items:[{type:8,properties:[{key:"rtgl-text s=sm c=${item.textColor}",value:{type:1,path:"item.label"},parsedKey:{type:2,parts:["rtgl-text s=sm c=",{type:1,path:"item.textColor"}]}}],fast:!0}],fast:!0},parsedKey:{type:2,parts:["rtgl-view#tab-",{type:1,path:"item.id"}," data-id=",{type:1,path:"item.id"}," cur=p bgc=",{type:1,path:"item.bgColor"}," bw=xs bc=",{type:1,path:"item.borderColor"}," pv=md ph=lg br=lg"]}}],fast:!0}],fast:!0}}],fast:!1},parsedKey:{type:2,parts:["rtgl-view d=h g=sm bgc=mu p=sm br=lg ",{type:1,path:"containerAttrString"}]}}],fast:!1}],fast:!1}};var as={};var Kt={};P(Kt,{createInitialState:()=>Sa,selectViewData:()=>Ca});var Sa=()=>Object.freeze({}),Ca=({attrs:e})=>({open:!!e.open,x:e.x||0,y:e.y||0,placement:e.placement||"top",content:e.content||""});var ls={elementName:"rtgl-tooltip",viewDataSchema:{type:"object"},attrsSchema:{type:"object",properties:{open:{type:"string"},x:{type:"string"},y:{type:"string"},placement:{type:"string"},content:{type:"string"}}},template:{type:9,items:[{type:8,properties:[{key:"rtgl-popover#popover ?open=${open} x=${x} y=${y} placement=${placement} no-overlay",value:{type:9,items:[{type:8,properties:[{key:"rtgl-view slot=content bgc=background bc=border br=md p=sm ah=c av=c",value:{type:9,items:[{type:8,properties:[{key:"rtgl-text ta=c s=sm c=foreground",value:{type:1,path:"content"}}],fast:!0}],fast:!0}}],fast:!0}],fast:!0},parsedKey:{type:2,parts:["rtgl-popover#popover ?open=",{type:1,path:"open"}," x=",{type:1,path:"x"}," y=",{type:1,path:"y"}," placement=",{type:1,path:"placement"}," no-overlay"]}}],fast:!0}],fast:!0}};var zt={};P(zt,{handleAfterMount:()=>Oa,handleOnUpdate:()=>Ia});var Oa=async e=>{let{props:t,store:r,render:s,getRefIds:i}=e,{waveformData:n}=t;r.setWaveformData(n),s();let o=i().canvas?.elm;o&&ps(n,o)},Ia=async(e,t)=>{let{store:r,render:s,getRefIds:i,props:n}=e,{waveformData:o}=n;if(!o){console.log("waveform handleOnUpdate: no waveformData provided");return}r.setWaveformData(o),s();let l=i().canvas?.elm;l&&ps(o,l)};async function ps(e,t){let r=t.getContext("2d"),s=t.getBoundingClientRect(),i=s.width,n=s.height;t.width=i,t.height=n;let o=t.width,l=t.height;if(r.clearRect(0,0,o,l),r.fillStyle="#1a1a1a",r.fillRect(0,0,o,l),!e||!e.amplitudes)return;let p=e.amplitudes,a=l/2,c=r.createLinearGradient(0,0,0,l);c.addColorStop(0,"#404040"),c.addColorStop(.5,"#A1A1A1"),c.addColorStop(1,"#404040");let u=Math.max(1,o/p.length),h=.2;for(let f=0;f<p.length;f++){let y=p[f]/255*(l*.85),b=f*u,m=a-y/2;r.fillStyle=c,r.fillRect(b,m,Math.max(1,u*(1-h)),y)}r.strokeStyle="rgba(255, 255, 255, 0.1)",r.lineWidth=1,r.beginPath(),r.moveTo(0,a),r.lineTo(o,a),r.stroke(),r.shadowBlur=10,r.shadowColor="#2196F3"}var Ht={};P(Ht,{createInitialState:()=>Ta,selectViewData:()=>Ra,setWaveformData:()=>La});var Ta=()=>Object.freeze({waveformData:null}),La=(e,t)=>{e.waveformData=t},Ra=({state:e,attrs:t,props:r})=>({isLoading:r.isLoading,w:t.w||"250",h:t.h||"150",cur:t.cur,waveformData:r.waveformData});var cs={elementName:"rtgl-waveform",attrsSchema:{type:"object",properties:{w:{type:"string",description:"Width of the waveform visualizer",default:"250"},h:{type:"string",description:"Height of the waveform visualizer",default:"150"},cur:{type:"string",description:"cursor"}}},propsSchema:{type:"object",properties:{waveformData:{type:"object",description:"File ID of the waveform data in object storage"},isLoading:{type:"boolean",description:"Whether the waveform data is currently being loaded"}}},refs:{canvas:{selector:"canvas"}},template:{type:9,items:[{type:8,properties:[{key:"rtgl-view w=f h=f pos=rel w=${w} h=${h} cur=${cur}",value:{type:9,items:[{type:8,properties:[{key:"$if isLoading",value:{type:6,conditions:[{type:1,path:"isLoading"},null],bodies:[{type:9,items:[{type:8,properties:[{key:"rtgl-view w=f h=f av=c ah=c",value:{type:9,items:[{type:8,properties:[{key:"rtgl-text c=mu-fg",value:{type:0,value:"..."}}],fast:!0}],fast:!0}}],fast:!0}],fast:!0},{type:9,items:[{type:8,properties:[{key:'canvas#canvas style="width:100%; height:100%;"',value:{type:0,value:null}}],fast:!0}],fast:!0}],id:null}}],fast:!1}],fast:!1},parsedKey:{type:2,parts:["rtgl-view w=f h=f pos=rel w=",{type:1,path:"w"}," h=",{type:1,path:"h"}," cur=",{type:1,path:"cur"}]}}],fast:!1}],fast:!1}};var ms=Symbol.for("immer-nothing"),us=Symbol.for("immer-draftable"),ee=Symbol.for("immer-state");function ne(e,...t){throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var Ae=Object.getPrototypeOf;function Ee(e){return!!e&&!!e[ee]}function ye(e){return e?gs(e)||Array.isArray(e)||!!e[us]||!!e.constructor?.[us]||qe(e)||Ye(e):!1}var Na=Object.prototype.constructor.toString();function gs(e){if(!e||typeof e!="object")return!1;let t=Ae(e);if(t===null)return!0;let r=Object.hasOwnProperty.call(t,"constructor")&&t.constructor;return r===Object?!0:typeof r=="function"&&Function.toString.call(r)===Na}function Ke(e,t){Je(e)===0?Reflect.ownKeys(e).forEach(r=>{t(r,e[r],e)}):e.forEach((r,s)=>t(s,r,e))}function Je(e){let t=e[ee];return t?t.type_:Array.isArray(e)?1:qe(e)?2:Ye(e)?3:0}function Yt(e,t){return Je(e)===2?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function vs(e,t,r){let s=Je(e);s===2?e.set(t,r):s===3?e.add(r):e[t]=r}function Pa(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}function qe(e){return e instanceof Map}function Ye(e){return e instanceof Set}function fe(e){return e.copy_||e.base_}function Gt(e,t){if(qe(e))return new Map(e);if(Ye(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);let r=gs(e);if(t===!0||t==="class_only"&&!r){let s=Object.getOwnPropertyDescriptors(e);delete s[ee];let i=Reflect.ownKeys(s);for(let n=0;n<i.length;n++){let o=i[n],l=s[o];l.writable===!1&&(l.writable=!0,l.configurable=!0),(l.get||l.set)&&(s[o]={configurable:!0,writable:!0,enumerable:l.enumerable,value:e[o]})}return Object.create(Ae(e),s)}else{let s=Ae(e);if(s!==null&&r)return{...e};let i=Object.create(s);return Object.assign(i,e)}}function tr(e,t=!1){return Ge(e)||Ee(e)||!ye(e)||(Je(e)>1&&(e.set=e.add=e.clear=e.delete=Va),Object.freeze(e),t&&Object.entries(e).forEach(([r,s])=>tr(s,!0))),e}function Va(){ne(2)}function Ge(e){return Object.isFrozen(e)}var Da={};function me(e){let t=Da[e];return t||ne(0,e),t}var Re;function bs(){return Re}function ja(e,t){return{drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function hs(e,t){t&&(me("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function Xt(e){Qt(e),e.drafts_.forEach(Ba),e.drafts_=null}function Qt(e){e===Re&&(Re=e.parent_)}function ds(e){return Re=ja(Re,e)}function Ba(e){let t=e[ee];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function fs(e,t){t.unfinalizedDrafts_=t.drafts_.length;let r=t.drafts_[0];return e!==void 0&&e!==r?(r[ee].modified_&&(Xt(t),ne(4)),ye(e)&&(e=ze(t,e),t.parent_||He(t,e)),t.patches_&&me("Patches").generateReplacementPatches_(r[ee].base_,e,t.patches_,t.inversePatches_)):e=ze(t,r,[]),Xt(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==ms?e:void 0}function ze(e,t,r){if(Ge(t))return t;let s=t[ee];if(!s)return Ke(t,(i,n)=>ys(e,s,t,i,n,r)),t;if(s.scope_!==e)return t;if(!s.modified_)return He(e,s.base_,!0),s.base_;if(!s.finalized_){s.finalized_=!0,s.scope_.unfinalizedDrafts_--;let i=s.copy_,n=i,o=!1;s.type_===3&&(n=new Set(i),i.clear(),o=!0),Ke(n,(l,p)=>ys(e,s,i,l,p,r,o)),He(e,i,!1),r&&e.patches_&&me("Patches").generatePatches_(s,r,e.patches_,e.inversePatches_)}return s.copy_}function ys(e,t,r,s,i,n,o){if(Ee(i)){let l=n&&t&&t.type_!==3&&!Yt(t.assigned_,s)?n.concat(s):void 0,p=ze(e,i,l);if(vs(r,s,p),Ee(p))e.canAutoFreeze_=!1;else return}else o&&r.add(i);if(ye(i)&&!Ge(i)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;ze(e,i),(!t||!t.scope_.parent_)&&typeof s!="symbol"&&Object.prototype.propertyIsEnumerable.call(r,s)&&He(e,i)}}function He(e,t,r=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&tr(t,r)}function Wa(e,t){let r=Array.isArray(e),s={type_:r?1:0,scope_:t?t.scope_:bs(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1},i=s,n=rr;r&&(i=[s],n=Ne);let{revoke:o,proxy:l}=Proxy.revocable(i,n);return s.draft_=l,s.revoke_=o,l}var rr={get(e,t){if(t===ee)return e;let r=fe(e);if(!Yt(r,t))return Ma(e,r,t);let s=r[t];return e.finalized_||!ye(s)?s:s===Jt(e.base_,t)?(qt(e),e.copy_[t]=er(s,e)):s},has(e,t){return t in fe(e)},ownKeys(e){return Reflect.ownKeys(fe(e))},set(e,t,r){let s=ws(fe(e),t);if(s?.set)return s.set.call(e.draft_,r),!0;if(!e.modified_){let i=Jt(fe(e),t),n=i?.[ee];if(n&&n.base_===r)return e.copy_[t]=r,e.assigned_[t]=!1,!0;if(Pa(r,i)&&(r!==void 0||Yt(e.base_,t)))return!0;qt(e),Zt(e)}return e.copy_[t]===r&&(r!==void 0||t in e.copy_)||Number.isNaN(r)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=r,e.assigned_[t]=!0),!0},deleteProperty(e,t){return Jt(e.base_,t)!==void 0||t in e.base_?(e.assigned_[t]=!1,qt(e),Zt(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){let r=fe(e),s=Reflect.getOwnPropertyDescriptor(r,t);return s&&{writable:!0,configurable:e.type_!==1||t!=="length",enumerable:s.enumerable,value:r[t]}},defineProperty(){ne(11)},getPrototypeOf(e){return Ae(e.base_)},setPrototypeOf(){ne(12)}},Ne={};Ke(rr,(e,t)=>{Ne[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}});Ne.deleteProperty=function(e,t){return Ne.set.call(this,e,t,void 0)};Ne.set=function(e,t,r){return rr.set.call(this,e[0],t,r,e[0])};function Jt(e,t){let r=e[ee];return(r?fe(r):e)[t]}function Ma(e,t,r){let s=ws(t,r);return s?"value"in s?s.value:s.get?.call(e.draft_):void 0}function ws(e,t){if(!(t in e))return;let r=Ae(e);for(;r;){let s=Object.getOwnPropertyDescriptor(r,t);if(s)return s;r=Ae(r)}}function Zt(e){e.modified_||(e.modified_=!0,e.parent_&&Zt(e.parent_))}function qt(e){e.copy_||(e.copy_=Gt(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var Fa=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.produce=(t,r,s)=>{if(typeof t=="function"&&typeof r!="function"){let n=r;r=t;let o=this;return function(p=n,...a){return o.produce(p,c=>r.call(this,c,...a))}}typeof r!="function"&&ne(6),s!==void 0&&typeof s!="function"&&ne(7);let i;if(ye(t)){let n=ds(this),o=er(t,void 0),l=!0;try{i=r(o),l=!1}finally{l?Xt(n):Qt(n)}return hs(n,s),fs(i,n)}else if(!t||typeof t!="object"){if(i=r(t),i===void 0&&(i=t),i===ms&&(i=void 0),this.autoFreeze_&&tr(i,!0),s){let n=[],o=[];me("Patches").generateReplacementPatches_(t,i,n,o),s(n,o)}return i}else ne(1,t)},this.produceWithPatches=(t,r)=>{if(typeof t=="function")return(o,...l)=>this.produceWithPatches(o,p=>t(p,...l));let s,i;return[this.produce(t,r,(o,l)=>{s=o,i=l}),s,i]},typeof e?.autoFreeze=="boolean"&&this.setAutoFreeze(e.autoFreeze),typeof e?.useStrictShallowCopy=="boolean"&&this.setUseStrictShallowCopy(e.useStrictShallowCopy)}createDraft(e){ye(e)||ne(8),Ee(e)&&(e=Ua(e));let t=ds(this),r=er(e,void 0);return r[ee].isManual_=!0,Qt(t),r}finishDraft(e,t){let r=e&&e[ee];(!r||!r.isManual_)&&ne(9);let{scope_:s}=r;return hs(s,t),fs(void 0,s)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}applyPatches(e,t){let r;for(r=t.length-1;r>=0;r--){let i=t[r];if(i.path.length===0&&i.op==="replace"){e=i.value;break}}r>-1&&(t=t.slice(r+1));let s=me("Patches").applyPatches_;return Ee(e)?s(e,t):this.produce(e,i=>s(i,t))}};function er(e,t){let r=qe(e)?me("MapSet").proxyMap_(e,t):Ye(e)?me("MapSet").proxySet_(e,t):Wa(e,t);return(t?t.scope_:bs()).drafts_.push(r),r}function Ua(e){return Ee(e)||ne(10,e),_s(e)}function _s(e){if(!ye(e)||Ge(e))return e;let t=e[ee],r;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,r=Gt(e,t.scope_.immer_.useStrictShallowCopy_)}else r=Gt(e,!0);return Ke(r,(s,i)=>{vs(r,s,_s(i))}),t&&(t.finalized_=!1),r}var te=new Fa,xs=te.produce,yu=te.produceWithPatches.bind(te),mu=te.setAutoFreeze.bind(te),gu=te.setUseStrictShallowCopy.bind(te),vu=te.applyPatches.bind(te),bu=te.createDraft.bind(te),wu=te.finishDraft.bind(te);var g={LITERAL:0,VARIABLE:1,INTERPOLATION:2,FUNCTION:3,BINARY:4,UNARY:5,CONDITIONAL:6,LOOP:7,OBJECT:8,ARRAY:9,PARTIAL:10,PATH_REFERENCE:11},W={EQ:0,NEQ:1,GT:2,LT:3,GTE:4,LTE:5,AND:6,OR:7,IN:8,ADD:10,SUBTRACT:11},Pe={NOT:0};var L=class extends Error{constructor(t){super(`Parse Error: ${t}`),this.name="JemplParseError"}},Q=class extends Error{constructor(t){super(`Render Error: ${t}`),this.name="JemplRenderError"}};var sr=e=>{if(!e||e.trim()==="")throw new L("Missing condition expression after '$if'");if(e.includes("===")||e.includes("!==")){let r=e.includes("===")?"==":"!=";throw new L(`Invalid comparison operator '${e.includes("===")?"===":"!=="}' - did you mean '${r}'? (got: '${e}')`)}let t=["<",">","<=",">=","==","!="];for(let r of t)if(e.trim().endsWith(r))throw new L(`Incomplete comparison expression - missing right operand (got: '${e}')`)},As=e=>{if(e.trim().endsWith(" in"))throw new L(`Missing iterable expression after 'in' (got: '$for ${e}')`);if(!e.includes(" in "))throw new L(`Invalid loop syntax - missing 'in' keyword (got: '$for ${e}')`);let[t,r]=e.split(" in ");if(!r||r.trim()==="")throw new L(`Missing iterable expression after 'in' (got: '$for ${e}')`);if(t.includes(",")){let s=t.split(",").map(i=>i.trim());for(let i of s)if(!i)throw new L(`Invalid loop variable - variable name cannot be empty (got: '$for ${e}')`)}else if(!t.trim())throw new L(`Invalid loop variable - variable name cannot be empty (got: '$for ${e}')`)};var Es=(e,t,r=!1)=>{if(t===null)return new Q(`Cannot iterate over null value at '$for ${e}'`);if(t===void 0)return new Q(`Cannot iterate over undefined value at '$for ${e}'`);let s=typeof t;return r?new Q(`Cannot iterate over non-array value in loop '${e}' - got ${s} instead`):new Q(`Cannot iterate over non-array value (got: ${s}) at '$for ${e}'`)},ks=(e,t)=>{let r=t&&Object.keys(t).length>0?Object.keys(t).join(", "):"no custom functions provided";return new Q(`Unknown function '${e}' (${r})`)};var Ka=(e,t,r={})=>{let s={},i={};r&&typeof r=="object"&&(r.functions!==void 0||r.partials!==void 0?(s=r.functions||{},i=r.partials||{}):typeof r=="object"&&(s=r));let o=T(e,{functions:s,partials:i},t,{});return o===void 0?{}:o},T=(e,t,r,s)=>{let i=t.functions||t;if(e.var&&!e.type)return H(e.var,r,s);if(e.type===g.LITERAL)return e.value;if(e.type===g.VARIABLE)return H(e.path,r,s);if(e.type===g.INTERPOLATION)return Ha(e.parts,t,r,s);switch(e.type){case g.FUNCTION:return Ss(e,t,r,s);case g.BINARY:return Cs(e,t,r,s);case g.UNARY:return Os(e,t,r,s);case g.CONDITIONAL:return qa(e,t,r,s);case g.LOOP:return Za(e,t,r,s);case g.OBJECT:return tl(e,t,r,s);case g.ARRAY:return rl(e,t,r,s);case g.PARTIAL:return sl(e,t,r,s);case g.PATH_REFERENCE:return il(e,t,r,s);default:throw new Error(`Unknown node type: ${e.type}`)}},$s=new Map,za=e=>{let t=[],r="",s=!1;for(let i=0;i<e.length;i++){let n=e[i];if(n==="[")r&&(t.push({type:"property",value:r}),r=""),s=!0;else if(n==="]"){if(s&&r){let o=r.trim();if(/^\d+$/.test(o))t.push({type:"index",value:parseInt(o,10)});else if(o.startsWith('"')&&o.endsWith('"')||o.startsWith("'")&&o.endsWith("'")){let l=o.slice(1,-1);t.push({type:"property",value:l})}else t.push({type:"property",value:o});r=""}s=!1}else r+=n}return r&&t.push({type:"property",value:r}),t},H=(e,t,r)=>{if(!e)return;if(e in r)return r[e];let s=$s.get(e);if(!s){let n=[],o="",l=0;for(let p=0;p<e.length;p++){let a=e[p];a==="["?(l++,o+=a):a==="]"?(l--,o+=a):a==="."&&l===0?o&&(n.push(o),o=""):o+=a}o&&n.push(o),s=[];for(let p of n){let a=za(p.trim());s.push(...a)}$s.set(e,s)}let i=t;for(let n=0;n<s.length;n++){let o=s[n];if(o.type==="property"&&o.value in r){i=r[o.value];continue}if(i==null)return;(o.type==="property"||o.type==="index")&&(i=i[o.value])}return i},Ha=(e,t,r,s)=>{let i=[];for(let n of e)if(typeof n=="string")i.push(n);else{let o=T(n,t,r,s);i.push(o!=null?String(o):"")}return i.join("")},Ss=(e,t,r,s)=>{let i=t.functions||t,n=i[e.name];if(!n)throw ks(e.name,i);let o=e.args.map(l=>T(l,t,r,s));return n(...o)},ke=(e,t,r,s)=>{if(e.var&&!e.type)return H(e.var,r,s);switch(e.type){case g.VARIABLE:return H(e.path,r,s);case g.LITERAL:return e.value;case g.BINARY:return Cs(e,t,r,s);case g.UNARY:return Os(e,t,r,s);case g.FUNCTION:return Ss(e,t,r,s);default:return T(e,t,r,s)}},Cs=(e,t,r,s)=>{if(e.op===W.AND||e.op===W.OR){let o=ke(e.left,t,r,s),l=ke(e.right,t,r,s);switch(e.op){case W.AND:return o&&l;case W.OR:return o||l}}let i=T(e.left,t,r,s),n=T(e.right,t,r,s);switch(e.op){case W.EQ:return i==n;case W.NEQ:return i!=n;case W.GT:return i>n;case W.LT:return i<n;case W.GTE:return i>=n;case W.LTE:return i<=n;case W.IN:return Array.isArray(n)?n.includes(i):!1;case W.ADD:if(typeof i!="number"||typeof n!="number")throw new Q(`Arithmetic operations require numbers. Got ${typeof i} + ${typeof n}`);return i+n;case W.SUBTRACT:if(typeof i!="number"||typeof n!="number")throw new Q(`Arithmetic operations require numbers. Got ${typeof i} - ${typeof n}`);return i-n;default:throw new Error(`Unknown binary operator: ${e.op}`)}},Os=(e,t,r,s)=>{let i=e.op===Pe.NOT?ke(e.operand,t,r,s):T(e.operand,t,r,s);switch(e.op){case Pe.NOT:return!i;default:throw new Error(`Unknown unary operator: ${e.op}`)}},Ja=(e,t,r,s)=>{if(e.conditions.length===2&&e.conditions[1]===null){let i=e.conditions[0];if(i.type===g.VARIABLE)if(H(i.path,r,s)){let o=e.bodies[0];if(o.type===g.OBJECT&&o.properties.length<=5){let l={};for(let p of o.properties){let a=p.parsedKey?T(p.parsedKey,t,r,s):p.key,c=p.value;if(c.type===g.LITERAL)l[a]=c.value;else if(c.type===g.VARIABLE)l[a]=H(c.path,r,s);else if(c.type===g.INTERPOLATION){let u=[];for(let h of c.parts)if(typeof h=="string")u.push(h);else if(h.type===g.VARIABLE){let f=H(h.path,r,s);u.push(f!=null?String(f):"")}else{let f=T(h,t,r,s);u.push(f!=null?String(f):"")}l[a]=u.join("")}else l[a]=T(c,t,r,s)}return l}}else{let o=e.bodies[1];if(o.type===g.OBJECT&&o.properties.length<=5){let l={};for(let p of o.properties){let a=p.parsedKey?T(p.parsedKey,t,r,s):p.key,c=p.value;if(c.type===g.LITERAL)l[a]=c.value;else if(c.type===g.VARIABLE)l[a]=H(c.path,r,s);else if(c.type===g.INTERPOLATION){let u=[];for(let h of c.parts)if(typeof h=="string")u.push(h);else if(h.type===g.VARIABLE){let f=H(h.path,r,s);u.push(f!=null?String(f):"")}else{let f=T(h,t,r,s);u.push(f!=null?String(f):"")}l[a]=u.join("")}else l[a]=T(c,t,r,s)}return l}}}return null},qa=(e,t,r,s)=>{let i=Ja(e,t,r,s);if(i!==null)return i;for(let n=0;n<e.conditions.length;n++){let o=e.conditions[n];if(o===null||ke(o,t,r,s))return T(e.bodies[n],t,r,s)}return Is},Ya=(e,t)=>{let r=e.body,s=e.itemVar;if(r.type===g.CONDITIONAL&&r.conditions.length===1&&r.conditions[0].type===g.VARIABLE){let i=r.conditions[0].path,n=r.bodies[0];if(i.startsWith(s+".")){let o=i.substring(s.length+1);if(n.type===g.OBJECT&&n.properties.length<=5){for(let p of n.properties)if(p.parsedKey)return null;let l=[];for(let p=0;p<t.length;p++){let a=t[p];if(a[o]){let c={};for(let u of n.properties){let h=u.key,f=u.value;if(f.type===g.LITERAL)c[h]=f.value;else if(f.type===g.VARIABLE){let d=f.path;if(d===s)c[h]=a;else if(d.startsWith(s+".")){let y=d.substring(s.length+1);c[h]=a[y]}else return null}else if(f.type===g.INTERPOLATION){let d=[],y=!0;for(let b of f.parts)if(typeof b=="string")d.push(b);else if(b.type===g.VARIABLE){let m=b.path;if(m===s)d.push(a!=null?String(a):"");else if(m.startsWith(s+".")){let w=m.substring(s.length+1),_=a[w];d.push(_!=null?String(_):"")}else{y=!1;break}}else{y=!1;break}if(!y)return null;c[h]=d.join("")}else return null}l.push(c)}}return l}}}return null},Ga=(e,t)=>{let r=e.body,s=e.itemVar,i=Ya(e,t);if(i!==null)return i;if(r.type===g.OBJECT&&r.properties.length<=5){for(let l of r.properties)if(l.parsedKey)return null;let n=[],o=!0;for(let l of r.properties){let p=l.key,a=l.value;if(a.type===g.LITERAL)n.push({key:p,type:"literal",value:a.value});else if(a.type===g.VARIABLE){let c=a.path;if(c===s)n.push({key:p,type:"item"});else if(c.startsWith(s+".")){let u=c.substring(s.length+1);if(!u.includes(".")&&!u.includes("["))n.push({key:p,type:"prop",prop:u});else{o=!1;break}}else{o=!1;break}}else if(a.type===g.INTERPOLATION&&a.parts.length===1){let c=a.parts[0];if(c.type===g.VARIABLE){let u=c.path;if(u===s)n.push({key:p,type:"item_string"});else if(u.startsWith(s+".")){let h=u.substring(s.length+1);if(!h.includes(".")&&!h.includes("["))n.push({key:p,type:"prop_string",prop:h});else{o=!1;break}}else{o=!1;break}}else{o=!1;break}}else{o=!1;break}}if(o){let l=new Array(t.length);if(n.length===3&&n[0].type==="prop"&&n[0].key==="id"&&n[1].type==="prop_string"&&n[1].key==="title"&&n[2].type==="prop"&&n[2].key==="completed")for(let p=0;p<t.length;p++){let a=t[p];l[p]={id:a.id,title:a.title!=null?String(a.title):"",completed:a.completed}}else for(let p=0;p<t.length;p++){let a=t[p],c={};for(let u of n)if(u.type==="literal")c[u.key]=u.value;else if(u.type==="item")c[u.key]=a;else if(u.type==="prop")c[u.key]=a[u.prop];else if(u.type==="item_string")c[u.key]=a!=null?String(a):"";else if(u.type==="prop_string"){let h=a[u.prop];c[u.key]=h!=null?String(h):""}l[p]=c}return l}}return null},Xa=(e,t,r,s,i)=>{let n=[],o=e.body;if(o.type===g.OBJECT&&o.fast!==!1){let l=e.itemVar,p=e.indexVar;for(let a=0;a<i.length;a++){let c=i[a],u={},h={...s,[l]:c,...p&&{[p]:a}};h.__paths__||(h.__paths__=s.__paths__||{});let f=e.iterable.path||"";if(s&&s.__paths__&&f){let d=f.split("."),y=d[0];y in s.__paths__&&(f=s.__paths__[y],d.length>1&&(f+="."+d.slice(1).join(".")))}h.__paths__={...h.__paths__,[l]:`${f}[${a}]`,...p&&{[p]:a}};for(let d of o.properties){let y=d.parsedKey?T(d.parsedKey,t,r,h):d.key,b=d.value;if(b.type===g.LITERAL)u[y]=b.value;else if(b.type===g.VARIABLE){let m=b.path;if(m===l)u[y]=c;else if(m===p)u[y]=a;else if(m.startsWith(l+".")){let w=m.substring(l.length+1);!w.includes(".")&&!w.includes("[")?u[y]=c[w]:u[y]=H(m,r,{...s,[l]:c,...p&&{[p]:a}})}else u[y]=H(m,r,{...s,[l]:c,...p&&{[p]:a}})}else if(b.type===g.INTERPOLATION){let m=[];for(let w of b.parts)if(typeof w=="string")m.push(w);else if(w.type===g.VARIABLE){let _=w.path,x;if(_===l)x=c;else if(_===p)x=a;else if(_.startsWith(l+".")){let E=_.substring(l.length+1);!E.includes(".")&&!E.includes("[")?x=c[E]:x=H(_,r,{...s,[l]:c,...p&&{[p]:a}})}else x=H(_,r,{...s,[l]:c,...p&&{[p]:a}});m.push(x!=null?String(x):"")}else{let _={...s,[l]:c,...p&&{[p]:a}},x=T(w,t,r,_);m.push(x!=null?String(x):"")}u[y]=m.join("")}else{let m={...s,[l]:c,...p&&{[p]:a}};u[y]=T(b,t,r,m)}}n.push(u)}return n}return null},Qa=(e,t,r)=>{let s=e.body;if(s.type===g.OBJECT&&s.properties.length===1&&s.properties[0].key==="$if item.visible"){let n=s.properties[0].value;if(n.type===g.CONDITIONAL&&n.conditions.length===1&&n.conditions[0].type===g.VARIABLE&&n.conditions[0].path==="item.visible"){let o=n.bodies[0];if(o.type===g.OBJECT&&o.properties.length===2){let l=o.properties[0],p=o.properties[1];if(l.key==="id"&&l.value.type===g.VARIABLE&&l.value.path==="item.id"&&p.key==="$if item.highlighted"&&p.value.type===g.CONDITIONAL){let a=[];for(let c=0;c<t.length;c++){let u=t[c];if(u.visible){let h={id:u.id};u.highlighted?(h.highlight=!0,h.message=`This item is highlighted: ${u.name}`):(h.highlight=!1,h.message=u.name),a.push(h)}}return a}}}}return null},Za=(e,t,r,s)=>{let i=T(e.iterable,t,r,s);if(!Array.isArray(i)){let a,c=!1;if(e.iterable.type===g.FUNCTION){c=!0;let h=e.iterable.args.map(f=>f.type===g.LITERAL?typeof f.value=="string"?`'${f.value}'`:String(f.value):f.type===g.VARIABLE?f.path:f.type===g.FUNCTION?`${f.name}(...)`:"?").join(", ");a=`${e.iterable.name}(${h})`}else a=e.iterable.path||"undefined";let u=`${e.itemVar}${e.indexVar?`, ${e.indexVar}`:""} in ${a}`;throw Es(u,i,c)}if(!e.indexVar){let a=Qa(e,i,e.itemVar);if(a!==null)return a}if(!e.indexVar){let a=Ga(e,i);if(a!==null)return a}let n=Xa(e,t,r,s,i);if(n!==null)return n;let o=[],l=e.iterable.path||"";if(s&&s.__paths__&&l){let a=l.split("."),c=a[0];c in s.__paths__&&(l=s.__paths__[c],a.length>1&&(l+="."+a.slice(1).join(".")))}let p=!1;e.body.type===g.ARRAY&&(e.body.items.length<=1?p=!1:p=e.body._shouldPreserveArray??=e.body.items.some(a=>a.type===g.OBJECT&&a.properties.some(c=>c.key.startsWith("$if ")||c.key.startsWith("$when "))));for(let a=0;a<i.length;a++){let c=e.indexVar?{...s,[e.itemVar]:i[a],[e.indexVar]:a}:{...s,[e.itemVar]:i[a]};c.__paths__||(c.__paths__=s.__paths__||{}),c.__paths__={...c.__paths__,[e.itemVar]:`${l}[${a}]`},e.indexVar&&(c.__paths__[e.indexVar]=a);let u=T(e.body,t,r,c);Array.isArray(u)&&u.length===1&&!p?o.push(u[0]):o.push(u)}return o},el=(e,t,r,s)=>{if(e.whenCondition)return null;if(e.properties.length===1){let i=e.properties[0],n=i.parsedKey?T(i.parsedKey,t,r,s):i.key,o=i.value;if(o.type===g.OBJECT&&o.properties.length<=10&&!o.whenCondition){let l={},p={},a=!0;for(let c of o.properties){let u=c.parsedKey?T(c.parsedKey,t,r,s):c.key,h=c.value;if(h.type===g.LITERAL)p[u]=h.value;else if(h.type===g.VARIABLE)p[u]=H(h.path,r,s);else if(h.type===g.INTERPOLATION){let f=[];for(let d of h.parts)if(typeof d=="string")f.push(d);else if(d.type===g.VARIABLE){let y=H(d.path,r,s);f.push(y!=null?String(y):"")}else{a=!1;break}if(!a)break;p[u]=f.join("")}else if(h.type===g.OBJECT&&h.properties.length<=5){let f={};for(let d of h.properties){let y=d.key,b=d.value;if(b.type===g.LITERAL)f[y]=b.value;else if(b.type===g.VARIABLE)f[y]=H(b.path,r,s);else if(b.type===g.INTERPOLATION){let m=[];for(let w of b.parts)if(typeof w=="string")m.push(w);else if(w.type===g.VARIABLE){let _=H(w.path,r,s);m.push(_!=null?String(_):"")}else{a=!1;break}if(!a)break;f[y]=m.join("")}else{a=!1;break}}if(!a)break;p[u]=f}else{a=!1;break}}if(a)return l[n]=p,l}}return null},tl=(e,t,r,s)=>{let i=t.functions||t;if(e.whenCondition&&!ke(e.whenCondition,i,r,s))return;let n=el(e,t,r,s);if(n!==null)return n;if(e.fast){let a={};for(let c of e.properties){let u=c.parsedKey?T(c.parsedKey,t,r,s):c.key,h=c.value;if(h.type===g.LITERAL)a[u]=h.value;else if(h.type===g.VARIABLE)a[u]=H(h.path,r,s);else if(h.type===g.INTERPOLATION){let f=[];for(let d of h.parts)if(typeof d=="string")f.push(d);else if(d.type===g.VARIABLE){let y=H(d.path,r,s);f.push(y!=null?String(y):"")}else{let y=T(d,t,r,s);f.push(y!=null?String(y):"")}a[u]=f.join("")}else a[u]=T(h,t,r,s)}return a}let o={},l=null,p=!1;for(let a of e.properties)if(!a.key.startsWith("$if ")&&!a.key.match(/^\$if\s+\w+.*:?$/)&&!a.key.startsWith("$elif")&&!a.key.startsWith("$else")&&!a.key.startsWith("$for ")){p=!0;break}for(let a of e.properties)if(a.key.startsWith("$if ")||a.key.match(/^\$if\s+\w+.*:?$/)){let c=T(a.value,t,r,s);if(!p&&c!==null&&c!==void 0)return Array.isArray(c)&&c.length===1?c[0]:c;typeof c=="object"&&c!==null&&!Array.isArray(c)&&Object.assign(o,c)}else if(a.key.startsWith("$for ")){if(e.properties.length===1)return T(a.value,t,r,s)}else{let c=a.value;if(c&&c.type===g.OBJECT&&c.properties){let u=c.properties.find(h=>h.key.startsWith("$for "));if(u){let h=T(u.value,t,r,s);h!==void 0&&(o[a.key]=h)}else{let h=T(a.value,t,r,s);h!==void 0&&(o[a.key]=h)}}else{let u=a.parsedKey?T(a.parsedKey,t,r,s):a.key,h=T(a.value,t,r,s);h!==void 0&&(o[u]=h)}}return o},Is={},rl=(e,t,r,s)=>{let i=[];for(let n of e.items)if(n.type===g.LOOP){let o=T(n,t,r,s);i.push(o)}else{let o=T(n,t,r,s);o!==Is&&o!==void 0&&i.push(o)}return i},sl=(e,t,r,s)=>{let{name:i,data:n,whenCondition:o}=e,l=t.partials||{},p=t.functions||t;if(o&&!ke(o,p,r,s))return;if(!l[i])throw new Q(`Partial '${i}' is not defined`);let a=s._partialStack||[];if(a.includes(i))throw new Q(`Circular partial reference detected: ${i}`);let c=l[i],u=r,h={...s,_partialStack:[...a,i]};if(s){u={...r};for(let f of Object.keys(s))f.startsWith("_")||(u[f]=s[f])}if(n){let f=T(n,t,r,s);u={...u,...f}}return T(c,t,u,h)},il=(e,t,r,s)=>{let{path:i}=e,n=i.split("."),o=n[0],l=n.slice(1);if(!s||!(o in s))throw new Q(`Path reference '#{${i}}' refers to '${o}' which is not a loop variable in the current scope`);if(s.__paths__||(s.__paths__={}),!(o in s.__paths__))throw new Q(`Path reference '#{${i}}' cannot be resolved - path tracking may not be initialized properly`);let p=s.__paths__[o];if(typeof p=="number"){if(l.length>0)throw new Q(`Path reference '#{${i}}' - cannot access properties on index variable '${o}'`);return String(p)}return l.length>0&&(p+="."+l.join(".")),p},Ve=Ka;var nl=/\$\{([^}]*)\}/g,ol=/#\{([^}]*)\}/g,Ls=(e,t={})=>{let r=e.match(/^(\w+)\((.*)\)$/);if(!r)return{isFunction:!1};let[,s,i]=r,n=al(i,t);return{isFunction:!0,type:g.FUNCTION,name:s,args:n}},al=(e,t={})=>e.trim()?ll(e).map(s=>pl(s.trim(),t)):[],ll=e=>{let t=[],r="",s=0,i=!1,n="";for(let o=0;o<e.length;o++){let l=e[o],p=o>0?e[o-1]:"";!i&&(l==='"'||l==="'")?(i=!0,n=l,r+=l):i&&l===n&&p!=="\\"?(i=!1,n="",r+=l):!i&&l==="("?(s++,r+=l):!i&&l===")"?(s--,r+=l):!i&&l===","&&s===0?(t.push(r),r=""):r+=l}return r&&t.push(r),t},pl=(e,t={})=>{if(e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"))return{type:g.LITERAL,value:e.slice(1,-1)};if(/^-?\d+(\.\d+)?$/.test(e))return{type:g.LITERAL,value:parseFloat(e)};if(e==="true")return{type:g.LITERAL,value:!0};if(e==="false")return{type:g.LITERAL,value:!1};if(e==="null")return{type:g.LITERAL,value:null};let r=Ls(e,t);if(r.isFunction)return{type:r.type,name:r.name,args:r.args};let s=e.trim(),i=[{op:" + ",type:"ADD"},{op:" - ",type:"SUBTRACT"}],n=-1,o=null;for(let{op:l,type:p}of i){let a=0;for(;a<s.length;){let c=ge(s.substring(a),l);if(c===-1)break;let u=a+c;u>n&&(n=u,o={op:l,type:p}),a=u+l.length}}if(n!==-1)try{return G(s,t)}catch{return{type:g.VARIABLE,path:s}}return{type:g.VARIABLE,path:s}},Rs=/^\w+\(.*\)$/,cl=/\s[+\-*/%]\s|\|\||&&|\?\?|.*\?.*:/,ul=e=>{if(!(!e||e.trim()===""||Rs.test(e))&&cl.test(e))throw e.includes("?")&&e.includes(":")?new L(`Complex expressions not supported in variable replacements - consider calculating the value in your data instead. Offending expression: "${e}"`):e.includes("||")||e.includes("&&")||e.includes("??")?new L(`Logical operators not supported in variable replacements - consider calculating the value in your data instead (operators like ||, &&, ?? are not supported). Offending expression: "${e}"`):new L(`Arithmetic expressions not supported in variable replacements - consider calculating '${e}' in your data instead (expressions with +, -, *, /, % are not supported). Offending expression: "${e}"`)},Ts=e=>{let t=e.trim();if(Rs.test(t))throw new L(`Functions are not supported in path references - path references can only refer to loop variables. Offending expression: "#{${e}}"`);if(t.includes("["))throw new L(`Array indices not supported in path references - use simple variable names or properties. Offending expression: "#{${e}}"`);if(/[+\-*/%]/.test(t))throw new L(`Arithmetic expressions not supported in path references - path references can only refer to loop variables. Offending expression: "#{${e}}"`);if(/\|\||&&/.test(t))throw new L(`Logical operators not supported in path references - path references can only refer to loop variables. Offending expression: "#{${e}}"`);if(t.includes("?")&&t.includes(":"))throw new L(`Complex expressions not supported in path references - path references can only refer to loop variables. Offending expression: "#{${e}}"`);return{type:g.PATH_REFERENCE,path:t}},De=(e,t={})=>{let r=e.trim();ul(r);let s=Ls(r,t);if(s.isFunction)return{type:s.type,name:s.name,args:s.args};if(r.includes("[")&&!/[\s+\-*/%|&?:]/.test(r)){let i=0;for(let n of r)n==="["?i++:n==="]"&&i--;if(i!==0)throw new Error("Invalid array index syntax")}return{type:g.VARIABLE,path:r}},ir=(e,t={})=>{let r=e,s=[];(e.includes("\\${")||e.includes("\\#{"))&&(r=e.replace(/\\\\(\$\{[^}]*\})/g,"\\DOUBLE_ESC_VAR$1"),r=r.replace(/\\\\(#\{[^}]*\})/g,"\\DOUBLE_ESC_PATH$1"),r=r.replace(/\\(\$\{[^}]*\})/g,(a,c)=>{let u=`__ESCAPED_${s.length}__`;return s.push(c),u}),r=r.replace(/\\(#\{[^}]*\})/g,(a,c)=>{let u=`__ESCAPED_${s.length}__`;return s.push(c),u}),r=r.replace(/\\DOUBLE_ESC_VAR/g,"\\"),r=r.replace(/\\DOUBLE_ESC_PATH/g,"\\"));let i=[...r.matchAll(nl)],n=[...r.matchAll(ol)],o=[...i.map(a=>({match:a,type:"variable"})),...n.map(a=>({match:a,type:"pathref"}))].sort((a,c)=>a.match.index-c.match.index);if(o.length===0){let a=r;for(let c=0;c<s.length;c++)a=a.replace(`__ESCAPED_${c}__`,s[c]);return{type:g.LITERAL,value:a}}if(o.length===1&&o[0].match[0]===r&&s.length===0){let{match:a,type:c}=o[0];try{return c==="variable"?De(a[1],t):Ts(a[1])}catch(u){if(u.message==="Invalid array index syntax")return{type:g.LITERAL,value:r};throw u}}let l=[],p=0;for(let{match:a,type:c}of o){let[u,h]=a,f=a.index;if(f>p){let d=r.substring(p,f);for(let y=0;y<s.length;y++)d=d.replace(`__ESCAPED_${y}__`,s[y]);d&&l.push(d)}try{let d;c==="variable"?d=De(h.trim(),t):d=Ts(h.trim()),l.push(d)}catch(d){if(d.message==="Invalid array index syntax")l.push(u);else throw d}p=f+u.length}if(p<r.length){let a=r.substring(p);for(let c=0;c<s.length;c++)a=a.replace(`__ESCAPED_${c}__`,s[c]);a&&l.push(a)}return{type:g.INTERPOLATION,parts:l}};var he=(e,t)=>typeof e=="string"?ir(e,t):typeof e=="object"&&e!==null?Array.isArray(e)?hl(e,t):dl(e,t):{type:g.LITERAL,value:e},hl=(e,t)=>{let r=[],s=!1;for(let i=0;i<e.length;i++){let n=e[i];if(typeof n=="object"&&n!==null&&!Array.isArray(n)){let l=Object.keys(n);if(l.length===1&&l[0].startsWith("$for ")){let p=Ps(l[0],n[l[0]],t);r.push(p),s=!0;continue}}let o=he(n,t);r.push(o),(o.type===g.FUNCTION||o.type===g.CONDITIONAL||o.type===g.LOOP||o.type===g.PARTIAL||o.type===g.OBJECT&&!o.fast||o.type===g.ARRAY&&!o.fast)&&(s=!0)}return{type:g.ARRAY,items:r,fast:!s}},dl=(e,t)=>{let r=[],s=!1,i=null,n=Object.entries(e),o=0;if(e.$partial!==void 0){if(typeof e.$partial!="string")throw new L("$partial value must be a string");if(e.$partial.trim()==="")throw new L("$partial value cannot be an empty string");let p=["$if","$elif","$else","$for"],a=[];for(let[m]of n)for(let w of p)if(m===w||m.startsWith(w+" ")||m.startsWith(w+"#")){a.push(w);break}if(a.length>0)throw new L(`Cannot use $partial with ${a.join(", ")} at the same level. Wrap $partial in a parent object if you need conditionals.`);let{$partial:c,$when:u,...h}=e,f={},d=!1;for(let[m,w]of Object.entries(h)){let _=m;(m.startsWith("\\$")||m.startsWith("$$"))&&(_=m.slice(1)),f[_]=w,d=!0}let y=null;if(d&&(y=he(f,t),y.type===g.OBJECT)){let m=!1;for(let w of y.properties)if(w.value.type===g.VARIABLE||w.value.type===g.INTERPOLATION||w.value.type===g.FUNCTION||w.value.type===g.CONDITIONAL||w.value.type===g.LOOP||w.value.type===g.OBJECT&&!w.value.fast||w.value.type===g.ARRAY&&!w.value.fast){m=!0;break}m&&(y.fast=!1)}let b={type:g.PARTIAL,name:c,data:y};if(u!==void 0){let m;if(typeof u=="string"){if(u.trim()==="")throw new L("Empty condition expression after '$when'");m=G(u,t)}else m={type:g.LITERAL,value:u};b.whenCondition=m}return b}for(let[p,a]of n)if(p==="$when"){if(i!==null)throw new L("Multiple '$when' directives on the same object are not allowed");if(a==null)throw new L("Missing condition expression after '$when'");let c=typeof a=="string"?a:JSON.stringify(a);if(c.trim()==="")throw new L("Empty condition expression after '$when'");i=G(c,t),s=!0}else if(p.startsWith("$when#")||p.startsWith("$when "))throw new L("'$when' does not support ID syntax or inline conditions - use '$when' as a property");for(;o<n.length;){let[p,a]=n[o];if(p==="$when"){o++;continue}if(p.startsWith("$if ")||p.match(/^\$if#\w+\s/)||p.match(/^\$if\s+\w+.*:$/)){let c=fl(n,o,t);r.push({key:p,value:c.node}),s=!0,o=c.nextIndex}else if(p.startsWith("$for ")){let c=Ps(p,a,t);r.push({key:p,value:c}),s=!0,o++}else{if(p.startsWith("$elif ")||p.startsWith("$else"))throw new L(`'${p.split(" ")[0]}' without matching '$if'`);if(p==="$if"||p==="$if:")throw new L("Missing condition expression after '$if'");{let c=he(a,t);(c.type===g.FUNCTION||c.type===g.CONDITIONAL||c.type===g.LOOP||c.type===g.PARTIAL||c.type===g.OBJECT&&!c.fast||c.type===g.ARRAY&&!c.fast)&&(s=!0);let u=ir(p,t),h={key:p,value:c};(u.type!==g.LITERAL||u.value!==p)&&(h.parsedKey=u),r.push(h),o++}}}let l={type:g.OBJECT,properties:r,fast:!s};return i&&(l.whenCondition=i),l},fl=(e,t,r={})=>{let s=[],i=[],n=t,[o,l]=e[n],p=null,a;if(o.startsWith("$if#")){let u=o.match(/^\$if#(\w+)\s+(.+)$/);if(u)p=u[1],a=u[2];else throw new L(`Invalid conditional syntax: ${o}`)}else a=o.substring(4),a.endsWith(":")&&(a=a.slice(0,-1).trim());sr(a);let c=G(a,r);for(s.push(c),i.push(he(l,r)),n++;n<e.length;){let[u,h]=e[n],f=!1,d;if(p?u.startsWith(`$elif#${p} `)?(d=u.substring(`$elif#${p} `.length),d.endsWith(":")&&(d=d.slice(0,-1).trim()),f=!0):(u===`$else#${p}`||u===`$else#${p}:`)&&(f=!0,d=null):u.startsWith("$elif ")?(d=u.substring(6),d.endsWith(":")&&(d=d.slice(0,-1).trim()),f=!0):(u==="$else"||u==="$else:")&&(f=!0,d=null),f){if(d===null)s.push(null);else{sr(d);let y=G(d,r);s.push(y)}if(i.push(he(h,r)),n++,d===null)break}else break}return{node:{type:g.CONDITIONAL,conditions:s,bodies:i,id:p},nextIndex:n}},G=(e,t={})=>{if(e=e.trim(),e.startsWith("(")&&e.endsWith(")")){let a=e.slice(1,-1),c=0,u=!0;for(let h=0;h<a.length;h++)if(a[h]==="("?c++:a[h]===")"&&c--,c<0){u=!1;break}if(u&&c===0)return G(a,t)}let r=ge(e,"||");if(r!==-1)return{type:g.BINARY,op:W.OR,left:G(e.substring(0,r).trim(),t),right:G(e.substring(r+2).trim(),t)};let s=ge(e,"&&");if(s!==-1)return{type:g.BINARY,op:W.AND,left:G(e.substring(0,s).trim(),t),right:G(e.substring(s+2).trim(),t)};let i=[{op:">=",type:W.GTE},{op:"<=",type:W.LTE},{op:"==",type:W.EQ},{op:"!=",type:W.NEQ},{op:">",type:W.GT},{op:"<",type:W.LT},{op:" in ",type:W.IN}];for(let{op:a,type:c}of i){let u=ge(e,a);if(u!==-1)return{type:g.BINARY,op:c,left:G(e.substring(0,u).trim(),t),right:G(e.substring(u+a.length).trim(),t)}}let n=-1,o=null,l=[{op:" + ",type:W.ADD},{op:" - ",type:W.SUBTRACT}];for(let{op:a,type:c}of l){let u=0;for(;u<e.length;){let h=ge(e.substring(u),a);if(h===-1)break;let f=u+h;f>n&&(n=f,o={op:a,type:c}),u=f+a.length}}if(n!==-1&&o)return{type:g.BINARY,op:o.type,left:G(e.substring(0,n).trim(),t),right:G(e.substring(n+o.op.length).trim(),t)};let p=[" * "," / "," % "];for(let a of p)if(ge(e,a)!==-1)throw new L(`Arithmetic operations are not allowed in conditionals: "${a}"`);return e.startsWith("!")?{type:g.UNARY,op:Pe.NOT,operand:G(e.substring(1).trim(),t)}:Ns(e,t)},ge=(e,t)=>{let r=0,s=0;for(;s<=e.length-t.length;){if(e[s]==="(")r++;else if(e[s]===")")r--;else if(r===0&&e.substring(s,s+t.length)===t)return s;s++}return-1},yl=e=>{if(e=e.trim(),e==="true")return{type:g.LITERAL,value:!0};if(e==="false")return{type:g.LITERAL,value:!1};if(e==="null")return{type:g.LITERAL,value:null};if(e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"))return{type:g.LITERAL,value:e.slice(1,-1)};if(e==='""'||e==="''")return{type:g.LITERAL,value:""};if(e==="{}")return{type:g.LITERAL,value:{}};if(e==="[]")return{type:g.LITERAL,value:[]};let t=Number(e);return!isNaN(t)&&isFinite(t)?{type:g.LITERAL,value:t}:{type:g.VARIABLE,path:e}},Ns=(e,t)=>{let r=e.trim();if(r.match(/^(\w+)\((.*)\)$/))return De(r,t);let i=yl(r);if(i.type===g.LITERAL)return i;if(/^[a-zA-Z_$][\w.$]*$/.test(r))return{type:g.VARIABLE,path:r};try{return De(r,t)}catch(n){if(n.message&&n.message.includes("not supported"))return i;throw n}},Ps=(e,t,r)=>{let s=e.substring(5).trim();As(s);let i=s.match(/^(.+?)\s+in\s+(.+)$/);if(!i)throw new L(`Invalid loop syntax - missing 'in' keyword (got: '$for ${s}')`);let n=i[1].trim(),o=i[2].trim(),l,p=null;if(n.includes(",")){let u=n.split(",").map(h=>h.trim());if(u.length!==2)throw new L(`Invalid loop variables: ${n}. Expected format: "item" or "item, index"`);l=u[0],p=u[1]}else l=n;let a=Ns(o,r),c=he(t,r);return{type:g.LOOP,itemVar:l,indexVar:p,iterable:a,body:c}};var ml=(e,t={})=>{let{functions:r={}}=t;return he(e,r)},Xe=ml;var nr={};P(nr,{now:()=>gl});var gl=()=>Date.now();var vl=(e,t,r={})=>{let{functions:s={},partials:i={}}=r,n={...nr,...s},o=Xe(e,{functions:n}),l={};for(let[p,a]of Object.entries(i))l[p]=Xe(a,{functions:n});return Ve(o,t,{functions:n,partials:l})},or=vl;var Qe=e=>Array.isArray(e)?e.reduce((t,r)=>{if(Array.isArray(r))t.push(...Qe(r));else{if(r&&typeof r=="object"){let s=Object.entries(r);if(s.length>0){let[i,n]=s[0];Array.isArray(n)&&(r={[i]:Qe(n)})}}t.push(r)}return t},[]):e;var Vs=(e,t)=>{if(!t)return e;let r=[],s="",i=!1,n=null;for(let o=0;o<t.length;o++){let l=t[o];if(!i&&l===".")s&&(r.push(s),s="");else if(!i&&l==="[")s&&(r.push(s),s=""),i=!0;else if(i&&l==="]"){if(s){if(s.startsWith('"')&&s.endsWith('"')||s.startsWith("'")&&s.endsWith("'"))r.push(s.slice(1,-1));else{let p=Number(s);r.push(isNaN(p)?s:p)}s=""}i=!1,n=null}else i&&(l==='"'||l==="'")&&(n?l===n&&(n=null):n=l),s+=l}return s&&r.push(s),r.reduce((o,l)=>o&&o[l],e)},Ds=({h:e,template:t,viewData:r,refs:s,handlers:i})=>{let n=Ve(t,r,{}),o=Qe(n),l=bl({h:e,items:o,refs:s,handlers:i,viewData:r});return e("div",{style:{display:"contents"}},l)},bl=({h:e,items:t,refs:r={},handlers:s={},viewData:i={}})=>{if(!Array.isArray(t))return console.error("Input to createVirtualDom must be an array."),[e("div",{},[])];function n(o,l=""){return o.map((p,a)=>{if(typeof p=="string"||typeof p=="number")return String(p);if(typeof p!="object"||p===null)return console.warn("Skipping invalid item in DOM structure:",p),null;let c=Object.entries(p);if(c.length===0)return null;let[u,h]=c[0];if(!isNaN(Number(u)))return Array.isArray(h)?n(h,`${l}.${u}`):typeof h=="object"&&h!==null&&Object.entries(h).length>0?n([h],`${l}.${u}`):String(h);c.length>1&&console.warn("Item has multiple keys, processing only the first:",u);let f,d,y=u.indexOf(" ");y===-1?(f=u,d=""):(f=u.substring(0,y),d=u.substring(y+1).trim());let b=f.split(/[.#]/)[0],m=b.includes("-"),w={},_={};if(d){let C=/(\S+?)=(?:\"([^\"]*)\"|\'([^\']*)\'|([^\s]+))/g,A,j=new Set;for(;(A=C.exec(d))!==null;)if(j.add(A[1]),A[1].startsWith(".")){let se=A[1].substring(1),Ce=A[4];_[se]=Vs(i,Ce)}else if(A[1].startsWith("?")){let se=A[1].substring(1),Ce=A[2]||A[3]||A[4],Be;Ce==="true"?Be=!0:Ce==="false"?Be=!1:Be=Vs(i,Ce),Be&&(w[se]="")}else w[A[1]]=A[2]||A[3]||A[4];let F=d,M=[],re,tt=/(\S+?)=(?:\"([^\"]*)\"|\'([^\']*)\'|([^\s]+))/g;for(;(re=tt.exec(d))!==null;)M.push(re[0]);M.forEach(se=>{F=F.replace(se," ")});let rt=/\b(\S+?)(?=\s|$)/g,K;for(;(K=rt.exec(F))!==null;){let se=K[1];!j.has(se)&&!se.startsWith(".")&&!se.includes("=")&&(w[se]="")}}let x=f.match(/#([^.#\s]+)/);x&&!Object.prototype.hasOwnProperty.call(w,"id")&&(w.id=x[1]);let E=null;w.id?E=w.id:m&&(E=b);let $=Object.create(null),O=null;if(m)O=b;else{let C=f.match(/\.([^.#]+)/g);C&&C.forEach(j=>{let F=j.substring(1);$[F]=!0});let A=f.match(/#([^.#\s]+)/);A&&(O=A[1])}let S;typeof h=="string"||typeof h=="number"?S=String(h):Array.isArray(h)?S=n(h,`${l}.${u}`):S=[],O&&!m&&(w.id=O);let N=Object.create(null);if(E&&r){let C=[];if(Object.keys(r).forEach(A=>{if(A.includes("*")){let j="^"+A.replace(/[.*+?^${}()|[\\\]\\]/g,"\\$&").replace(/\\\*/g,".*")+"$";try{new RegExp(j).test(E)&&C.push(A)}catch(F){console.warn(`[Parser] Invalid regex pattern created from refKey '${A}': ${j}`,F)}}else E===A&&C.push(A)}),C.length>0){C.sort((j,F)=>{let M=!j.includes("*"),re=!F.includes("*");return M&&!re?-1:!M&&re?1:F.length-j.length});let A=C[0];if(r[A]&&r[A].eventListeners){let j=r[A].eventListeners;Object.entries(j).forEach(([F,M])=>{if(M.handler&&M.action)throw new Error("Each listener can have hanlder or action but not both");if(M.action){N[F]=re=>{s.handleCallStoreAction({...M.payload,_event:re,_action:M.action})};return}M.handler&&s[M.handler]?N[F]=re=>{s[M.handler]({...M.payload,_event:re})}:M.handler&&console.warn(`[Parser] Handler '${M.handler}' for refKey '${A}' (matching elementId '${E}') is referenced but not found in available handlers.`)})}}}let D={};if(E)D.key=E;else if(f){let C=l?`${l}.${a}`:String(a);if(D.key=`${f}-${C}`,Object.keys(_).length>0){let A=JSON.stringify(_).substring(0,50);D.key+=`-${A}`}}Object.keys(w).length>0&&(D.attrs=w),Object.keys($).length>0&&(D.class=$),Object.keys(N).length>0&&(D.on=N),Object.keys(_).length>0&&(D.props=_),m&&(D.hook={update:(C,A)=>{let j=C.data?.props||{},F=A.data?.props||{},M=C.data?.attrs||{},re=A.data?.attrs||{},tt=JSON.stringify(j)!==JSON.stringify(F),rt=JSON.stringify(M)!==JSON.stringify(re);if(tt||rt){let K=A.elm;K&&K.render&&typeof K.render=="function"&&(K.setAttribute("isDirty","true"),requestAnimationFrame(()=>{if(K.render(),K.removeAttribute("isDirty"),K.handlers&&K.handlers.handleOnUpdate){let se={...K.deps,store:K.store,render:K.render.bind(K),handlers:K.handlers,dispatchEvent:K.dispatchEvent.bind(K),refIds:K.refIds||{},getRefIds:()=>K.refIds||{}};K.handlers.handleOnUpdate(se,{oldProps:j,newProps:F,oldAttrs:M,newAttrs:re})}}))}}});try{return e(b,D,S)}catch(C){return console.error("Error creating virtual node:",C,{tagName:b,snabbdomData:D,childrenOrText:S}),e("div",{},["Error creating element"])}}).filter(Boolean)}return n(t)};var wl=(e,t)=>{if(!t||typeof t!="object")return"";let r="",s=n=>Object.entries(n).map(([o,l])=>` ${o}: ${l};`).join(`
939
939
  `),i=(n,o)=>{if(typeof o!="object"||o===null)return"";if(n.startsWith("@")){let l=Object.entries(o).map(([p,a])=>{let c=s(a);return` ${p} {
940
940
  ${c.split(`
941
941
  `).map(u=>u?` ${u}`:"").join(`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rettangoli/ui",
3
- "version": "0.1.19",
3
+ "version": "0.1.20",
4
4
  "description": "A UI component library for building web interfaces.",
5
5
  "main": "dist/rettangoli-esm.min.js",
6
6
  "type": "module",
@@ -16,7 +16,7 @@ export const handleBeforeMount = (deps) => {
16
16
 
17
17
  export const handleOnUpdate = (deps, payload) => {
18
18
  const { oldAttrs, newAttrs, oldProps, newProps } = payload;
19
- const { store, props, render } = deps;
19
+ const { store, render } = deps;
20
20
 
21
21
  // Check if key changed
22
22
  if (oldAttrs?.key !== newAttrs?.key && newAttrs?.key) {
@@ -24,8 +24,8 @@ export const handleOnUpdate = (deps, payload) => {
24
24
  store.resetSelection();
25
25
 
26
26
  // Re-apply the prop value if available
27
- const selectedValue = newProps?.selectedValue || props?.selectedValue;
28
- const options = newProps?.options || props?.options;
27
+ const selectedValue = newProps?.selectedValue;
28
+ const options = newProps?.options || [];
29
29
 
30
30
  if (selectedValue !== null && selectedValue !== undefined && options) {
31
31
  const selectedOption = options.find(opt => deepEqual(opt.value, selectedValue));
@@ -37,7 +37,7 @@ export const handleOnUpdate = (deps, payload) => {
37
37
  }
38
38
  render();
39
39
  } else if (oldProps.selectedValue !== newProps.selectedValue) {
40
- store.updateSelectedValue(newProps.selectedValue);
40
+ store.updateSelectedValue({ value: newProps.selectedValue });
41
41
  render();
42
42
  }
43
43
  }
@@ -44,16 +44,16 @@ export const selectViewData = ({ state, props, attrs }) => {
44
44
  // Calculate display label from value
45
45
  let displayLabel = attrs.placeholder || 'Select an option';
46
46
  let isPlaceholderLabel = true;
47
- if (currentValue !== null && currentValue !== undefined && props.options) {
48
- const selectedOption = props.options.find(opt => deepEqual(opt.value, currentValue));
49
- if (selectedOption) {
50
- displayLabel = selectedOption.label;
51
- isPlaceholderLabel = false;
52
- }
47
+
48
+ const options = props.options || [];
49
+ const selectedOption = options.find(opt => deepEqual(opt.value, currentValue));
50
+ if (selectedOption) {
51
+ displayLabel = selectedOption.label;
52
+ isPlaceholderLabel = false;
53
53
  }
54
54
 
55
55
  // Map options to include isSelected flag and computed background color
56
- const optionsWithSelection = (props.options || []).map((option, index) => {
56
+ const optionsWithSelection = options.map((option, index) => {
57
57
  const isSelected = deepEqual(option.value, currentValue);
58
58
  const isHovered = state.hoveredOptionId === index;
59
59
  return {