@odoo/owl 2.0.0-alpha.2 → 2.0.0-beta-5

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.
@@ -1 +1 @@
1
- !function(t){"use strict";function e(t){t=t.slice();const e=[];let n;for(;(n=t[0])&&"string"==typeof n;)e.push(t.shift());return{modifiers:e,data:t}}const n={shouldNormalizeDom:!0,mainEventHandler:(t,n,o)=>("function"==typeof t?t(n):Array.isArray(t)&&(t=e(t).data)[0](t[1],n),!1)};class o{constructor(t,e){this.key=t,this.child=e}mount(t,e){this.parentEl=t,this.child.mount(t,e)}moveBefore(t,e){this.child.moveBefore(t?t.child:null,e)}patch(t,e){if(this===t)return;let n=this.child,o=t.child;this.key===t.key?n.patch(o,e):(o.mount(this.parentEl,n.firstNode()),e&&n.beforeRemove(),n.remove(),this.child=o,this.key=t.key)}beforeRemove(){this.child.beforeRemove()}remove(){this.child.remove()}firstNode(){return this.child.firstNode()}toString(){return this.child.toString()}}function r(t,e){return new o(t,e)}const{setAttribute:i,removeAttribute:s}=Element.prototype,l=DOMTokenList.prototype,a=l.add,c=l.remove,h=Array.isArray,{split:u,trim:d}=String.prototype,f=/\s+/;function p(t,e){switch(e){case!1:case void 0:s.call(this,t);break;case!0:i.call(this,t,"");break;default:i.call(this,t,e)}}function m(t){return function(e){p.call(this,t,e)}}function g(t){if(h(t))p.call(this,t[0],t[1]);else for(let e in t)p.call(this,e,t[e])}function b(t,e){if(h(t)){const n=t[0],o=t[1];if(n===e[0]){if(o===e[1])return;p.call(this,n,o)}else s.call(this,e[0]),p.call(this,n,o)}else{for(let n in e)n in t||s.call(this,n);for(let n in t){const o=t[n];o!==e[n]&&p.call(this,n,o)}}}function v(t){const e={};switch(typeof t){case"string":const n=d.call(t);if(!n)return{};let o=u.call(n,f);for(let t=0,n=o.length;t<n;t++)e[o[t]]=!0;return e;case"object":for(let n in t){const o=t[n];if(o){const t=u.call(n,f);for(let n of t)e[n]=o}}return e;case"undefined":return{};case"number":return{[t]:!0};default:return{[t]:!0}}}function y(t){t=""===t?{}:v(t);const e=this.classList;for(let n in t)a.call(e,n)}function w(t,e){e=""===e?{}:v(e),t=""===t?{}:v(t);const n=this.classList;for(let o in e)o in t||c.call(n,o);for(let o in t)o in e||a.call(n,o)}function x(t){return function(e){this[t]=e}}function k(t,e){switch(t){case"input":return"checked"===e||"indeterminate"===e||"value"===e||"readonly"===e||"disabled"===e;case"option":return"selected"===e||"disabled"===e;case"textarea":return"value"===e||"readonly"===e||"disabled"===e;case"select":return"value"===e||"disabled"===e;case"button":case"optgroup":return"disabled"===e}return!1}function $(t){const e=t.split(".")[0],o=t.includes(".capture");return t.includes(".synthetic")?function(t,e=!1){let o="__event__synthetic_"+t;e&&(o+="_capture");!function(t,e,o=!1){if(A[e])return;document.addEventListener(t,(t=>function(t,e){let o=e.target;for(;null!==o;){const r=o[t];if(r)for(const t of Object.values(r)){if(n.mainEventHandler(t,e,o))return}o=o.parentNode}}(e,t)),{capture:o}),A[e]=!0}(t,o,e);const r=E++;function i(t){const e=this[o]||{};e[r]=t,this[o]=e}return{setup:i,update:i}}(e,o):function(t,e=!1){let o=`__event__${t}_${N++}`;e&&(o+="_capture");function r(t){const e=t.currentTarget;if(!e||!document.contains(e))return;const r=e[o];r&&n.mainEventHandler(r,t,e)}function i(n){this[o]=n,this.addEventListener(t,r,{capture:e})}function s(t){this[o]=t}return{setup:i,update:s}}(e,o)}let N=1;let E=1;const A={};const T=Node.prototype,_=T.insertBefore,L=(C=T,S="textContent",Object.getOwnPropertyDescriptor(C,S)).set;var C,S;const D=T.removeChild;class B{constructor(t){this.children=t}mount(t,e){const n=this.children,o=n.length,r=new Array(o);for(let i=0;i<o;i++){let o=n[i];if(o)o.mount(t,e);else{const n=document.createTextNode("");r[i]=n,_.call(t,n,e)}}this.anchors=r,this.parentEl=t}moveBefore(t,e){if(t){const n=t.children[0];e=(n?n.firstNode():t.anchors[0])||null}const n=this.children,o=this.parentEl,r=this.anchors;for(let t=0,i=n.length;t<i;t++){let i=n[t];if(i)i.moveBefore(null,e);else{const n=r[t];_.call(o,n,e)}}}patch(t,e){if(this===t)return;const n=this.children,o=t.children,r=this.anchors,i=this.parentEl;for(let t=0,s=n.length;t<s;t++){const s=n[t],l=o[t];if(s)if(l)s.patch(l,e);else{const o=s.firstNode(),l=document.createTextNode("");r[t]=l,_.call(i,l,o),e&&s.beforeRemove(),s.remove(),n[t]=void 0}else if(l){n[t]=l;const e=r[t];l.mount(i,e),D.call(i,e)}}}beforeRemove(){const t=this.children;for(let e=0,n=t.length;e<n;e++){const n=t[e];n&&n.beforeRemove()}}remove(){const t=this.parentEl;if(this.isOnlyChild)L.call(t,"");else{const e=this.children,n=this.anchors;for(let o=0,r=e.length;o<r;o++){const r=e[o];r?r.remove():D.call(t,n[o])}}}firstNode(){const t=this.children[0];return t?t.firstNode():this.anchors[0]}toString(){return this.children.map((t=>t?t.toString():"")).join("")}}function O(t){return new B(t)}const I=Node.prototype,R=CharacterData.prototype,P=I.insertBefore,j=((t,e)=>Object.getOwnPropertyDescriptor(t,e))(R,"data").set,M=I.removeChild;class F{constructor(t){this.text=t}mountNode(t,e,n){this.parentEl=e,P.call(e,t,n),this.el=t}moveBefore(t,e){const n=t?t.el:e;P.call(this.parentEl,this.el,n)}beforeRemove(){}remove(){M.call(this.parentEl,this.el)}firstNode(){return this.el}toString(){return this.text}}class V extends F{mount(t,e){this.mountNode(document.createTextNode(H(this.text)),t,e)}patch(t){const e=t.text;this.text!==e&&(j.call(this.el,H(e)),this.text=e)}}class W extends F{mount(t,e){this.mountNode(document.createComment(H(this.text)),t,e)}patch(){}}function z(t){return new V(t)}function K(t){return new W(t)}function H(t){switch(typeof t){case"string":return t;case"number":return String(t);case"boolean":return t?"true":"false";default:return t||""}}const U=(t,e)=>Object.getOwnPropertyDescriptor(t,e),q=Node.prototype,G=Element.prototype,X=U(CharacterData.prototype,"data").set,Y=U(q,"firstChild").get,Z=U(q,"nextSibling").get,Q=()=>{},J={};function tt(t){if(t in J)return J[t];const e=(new DOMParser).parseFromString(`<t>${t}</t>`,"text/xml").firstChild.firstChild;n.shouldNormalizeDom&&et(e);const o=nt(e),r=it(o),i=function(t,e){let n=function(t,e){const{refN:n,collectors:o,children:r}=e,i=o.length;e.locations.sort(((t,e)=>t.idx-e.idx));const s=e.locations.map((t=>({refIdx:t.refIdx,setData:t.setData,updateData:t.updateData}))),l=s.length,a=r.length,c=r,h=n>0,u=q.cloneNode,d=q.insertBefore,f=G.remove;class p{constructor(t){this.data=t}beforeRemove(){}remove(){f.call(this.el)}firstNode(){return this.el}moveBefore(t,e){const n=t?t.el:e;d.call(this.parentEl,this.el,n)}toString(){const t=document.createElement("div");return this.mount(t,null),t.innerHTML}mount(e,n){const o=u.call(t,!0);d.call(e,o,n),this.el=o,this.parentEl=e}patch(t,e){}}h&&(p.prototype.mount=function(e,r){const h=u.call(t,!0),f=new Array(n);this.refs=f,f[0]=h;for(let t=0;t<i;t++){const e=o[t];f[e.idx]=e.getVal.call(f[e.prevIdx])}if(l){const t=this.data;for(let e=0;e<l;e++){const n=s[e];n.setData.call(f[n.refIdx],t[e])}}if(d.call(e,h,r),a){const t=this.children;for(let e=0;e<a;e++){const n=t[e];if(n){const t=c[e],o=t.afterRefIdx?f[t.afterRefIdx]:null;n.isOnlyChild=t.isOnlyChild,n.mount(f[t.parentRefIdx],o)}}}this.el=h,this.parentEl=e},p.prototype.patch=function(t,e){if(this===t)return;const n=this.refs;if(l){const e=this.data,o=t.data;for(let t=0;t<l;t++){const r=e[t],i=o[t];if(r!==i){const e=s[t];e.updateData.call(n[e.refIdx],i,r)}}this.data=o}if(a){let o=this.children;const r=t.children;for(let t=0;t<a;t++){const i=o[t],s=r[t];if(i)s?i.patch(s,e):(e&&i.beforeRemove(),i.remove(),o[t]=void 0);else if(s){const e=c[t],r=e.afterRefIdx?n[e.afterRefIdx]:null;s.mount(n[e.parentRefIdx],r),o[t]=s}}}});return p}(t,e);if(e.cbRefs.length){const t=e.cbRefs,o=e.refList;let r=t.length;n=class extends n{mount(t,e){o.push(new Array(r)),super.mount(t,e);for(let t of o.pop())t()}remove(){super.remove();for(let e of t){(0,this.data[e])(null)}}}}if(e.children.length)return n=class extends n{constructor(t,e){super(t),this.children=e}},n.prototype.beforeRemove=B.prototype.beforeRemove,(t,e=[])=>new n(t,e);return t=>new n(t)}(o.el,r);return J[t]=i,i}function et(t){if(t.nodeType!==Node.TEXT_NODE||/\S/.test(t.textContent)){if(t.nodeType!==Node.ELEMENT_NODE||"pre"!==t.tagName)for(let e=t.childNodes.length-1;e>=0;--e)et(t.childNodes.item(e))}else t.remove()}function nt(t,e=null,n=null){switch(t.nodeType){case Node.ELEMENT_NODE:{let o=n&&n.currentNS;const r=t.tagName;let i=void 0;const s=[];if(r.startsWith("block-text-")){const t=parseInt(r.slice(11),10);s.push({type:"text",idx:t}),i=document.createTextNode("")}if(r.startsWith("block-child-")){n.isRef||ot(n);const t=parseInt(r.slice(12),10);s.push({type:"child",idx:t}),i=document.createTextNode("")}const l=t.attributes,a=l.getNamedItem("block-ns");if(a&&(l.removeNamedItem("block-ns"),o=a.value),i||(i=o?document.createElementNS(o,r):document.createElement(r)),i instanceof Element)for(let t=0;t<l.length;t++){const e=l[t].name,n=l[t].value;if(e.startsWith("block-handler-")){const t=parseInt(e.slice(14),10);s.push({type:"handler",idx:t,event:n})}else if(e.startsWith("block-attribute-")){const t=parseInt(e.slice(16),10);s.push({type:"attribute",idx:t,name:n,tag:r})}else"block-attributes"===e?s.push({type:"attributes",idx:parseInt(n,10)}):"block-ref"===e?s.push({type:"ref",idx:parseInt(n,10)}):i.setAttribute(l[t].name,n)}const c={parent:e,firstChild:null,nextSibling:null,el:i,info:s,refN:0,currentNS:o};if(t.firstChild){const e=t.childNodes[0];if(1===t.childNodes.length&&e.nodeType===Node.ELEMENT_NODE&&e.tagName.startsWith("block-child-")){const t=e.tagName,n=parseInt(t.slice(12),10);s.push({idx:n,type:"child",isOnlyChild:!0})}else{c.firstChild=nt(t.firstChild,c,c),i.appendChild(c.firstChild.el);let e=t.firstChild,n=c.firstChild;for(;e=e.nextSibling;)n.nextSibling=nt(e,n,c),i.appendChild(n.nextSibling.el),n=n.nextSibling}}return c.info.length&&ot(c),c}case Node.TEXT_NODE:case Node.COMMENT_NODE:return{parent:e,firstChild:null,nextSibling:null,el:t.nodeType===Node.TEXT_NODE?document.createTextNode(t.textContent):document.createComment(t.textContent),info:[],refN:0,currentNS:null}}throw new Error("boom")}function ot(t){t.isRef=!0;do{t.refN++}while(t=t.parent)}function rt(t){let e=t.parent;for(;e&&e.nextSibling===t;)t=e,e=e.parent;return e}function it(t,e,n){if(!e){e={collectors:[],locations:[],children:new Array(t.info.filter((t=>"child"===t.type)).length),cbRefs:[],refN:t.refN,refList:[]},n=0}if(t.refN){const o=n,r=t.isRef,i=t.firstChild?t.firstChild.refN:0,s=t.nextSibling?t.nextSibling.refN:0;if(r){for(let e of t.info)e.refIdx=o;t.refIdx=o,function(t,e){for(let n of e.info)switch(n.type){case"text":t.locations.push({idx:n.idx,refIdx:n.refIdx,setData:st,updateData:st});break;case"child":n.isOnlyChild?t.children[n.idx]={parentRefIdx:n.refIdx,isOnlyChild:!0}:t.children[n.idx]={parentRefIdx:rt(e).refIdx,afterRefIdx:n.refIdx};break;case"attribute":{const e=n.refIdx;let o,r;if(k(n.tag,n.name)){const t=x(n.name);r=t,o=t}else"class"===n.name?(r=y,o=w):(r=m(n.name),o=r);t.locations.push({idx:n.idx,refIdx:e,setData:r,updateData:o});break}case"attributes":t.locations.push({idx:n.idx,refIdx:n.refIdx,setData:g,updateData:b});break;case"handler":{const{setup:e,update:o}=$(n.event);t.locations.push({idx:n.idx,refIdx:n.refIdx,setData:e,updateData:o});break}case"ref":const o=t.cbRefs.push(n.idx)-1;t.locations.push({idx:n.idx,refIdx:n.refIdx,setData:lt(o,t.refList),updateData:Q})}}(e,t),n++}if(s){const r=n+i;e.collectors.push({idx:r,prevIdx:o,getVal:Z}),it(t.nextSibling,e,r)}i&&(e.collectors.push({idx:n,prevIdx:o,getVal:Y}),it(t.firstChild,e,n))}return e}function st(t){X.call(this,H(t))}function lt(t,e){return function(n){e[e.length-1][t]=()=>n(this)}}const at=Node.prototype,ct=at.insertBefore,ht=at.appendChild,ut=at.removeChild,dt=((t,e)=>Object.getOwnPropertyDescriptor(t,e))(at,"textContent").set;class ft{constructor(t){this.children=t}mount(t,e){const n=this.children,o=document.createTextNode("");this.anchor=o,ct.call(t,o,e);const r=n.length;if(r){const e=n[0].mount;for(let i=0;i<r;i++)e.call(n[i],t,o)}this.parentEl=t}moveBefore(t,e){if(t){const n=t.children[0];e=(n?n.firstNode():t.anchor)||null}const n=this.children;for(let t=0,o=n.length;t<o;t++)n[t].moveBefore(null,e);this.parentEl.insertBefore(this.anchor,e)}patch(t,e){if(this===t)return;const n=this.children,o=t.children;if(0===o.length&&0===n.length)return;this.children=o;const r=o[0]||n[0],{mount:i,patch:s,remove:l,beforeRemove:a,moveBefore:c,firstNode:h}=r,u=this.anchor,d=this.isOnlyChild,f=this.parentEl;if(0===o.length&&d){if(e)for(let t=0,e=n.length;t<e;t++)a.call(n[t]);return dt.call(f,""),void ht.call(f,u)}let p=0,m=0,g=n[0],b=o[0],v=n.length-1,y=o.length-1,w=n[v],x=o[y],k=void 0;for(;p<=v&&m<=y;){if(null===g){g=n[++p];continue}if(null===w){w=n[--v];continue}let t=g.key,r=b.key;if(t===r){s.call(g,b,e),o[m]=g,g=n[++p],b=o[++m];continue}let l=w.key,a=x.key;if(l===a){s.call(w,x,e),o[y]=w,w=n[--v],x=o[--y];continue}if(t===a){s.call(g,x,e),o[y]=g;const t=o[y+1];c.call(g,t,u),g=n[++p],x=o[--y];continue}if(l===r){s.call(w,b,e),o[m]=w;const t=n[p];c.call(w,t,u),w=n[--v],b=o[++m];continue}k=k||mt(n,p,v);let d=k[r];if(void 0===d)i.call(b,f,h.call(g)||null);else{const t=n[d];c.call(t,g,null),s.call(t,b,e),o[m]=t,n[d]=null}b=o[++m]}if(p<=v||m<=y)if(p>v){const t=o[y+1],e=t?h.call(t)||null:u;for(let t=m;t<=y;t++)i.call(o[t],f,e)}else for(let t=p;t<=v;t++){let o=n[t];o&&(e&&a.call(o),l.call(o))}}beforeRemove(){const t=this.children,e=t.length;if(e){const n=t[0].beforeRemove;for(let o=0;o<e;o++)n.call(t[o])}}remove(){const{parentEl:t,anchor:e}=this;if(this.isOnlyChild)dt.call(t,"");else{const n=this.children,o=n.length;if(o){const t=n[0].remove;for(let e=0;e<o;e++)t.call(n[e])}ut.call(t,e)}}firstNode(){const t=this.children[0];return t?t.firstNode():void 0}toString(){return this.children.map((t=>t.toString())).join("")}}function pt(t){return new ft(t)}function mt(t,e,n){let o={};for(let r=e;r<=n;r++)o[t[r].key]=r;return o}const gt=Node.prototype,bt=gt.insertBefore,vt=gt.removeChild;class yt{constructor(t){this.content=[],this.html=t}mount(t,e){this.parentEl=t;const n=document.createElement("template");n.innerHTML=this.html,this.content=[...n.content.childNodes];for(let n of this.content)bt.call(t,n,e);if(!this.content.length){const n=document.createTextNode("");this.content.push(n),bt.call(t,n,e)}}moveBefore(t,e){const n=t?t.content[0]:e,o=this.parentEl;for(let t of this.content)bt.call(o,t,n)}patch(t){if(this===t)return;const e=t.html;if(this.html!==e){const n=this.parentEl,o=this.content[0],r=document.createElement("template");r.innerHTML=e;const i=[...r.content.childNodes];for(let t of i)bt.call(n,t,o);if(!i.length){const t=document.createTextNode("");i.push(t),bt.call(n,t,o)}this.remove(),this.content=i,this.html=t.html}}beforeRemove(){}remove(){const t=this.parentEl;for(let e of this.content)vt.call(t,e)}firstNode(){return this.content[0]}toString(){return this.html}}function wt(t){return new yt(t)}function xt(t,e,n=null){t.mount(e,n)}function kt(t,e){const n=e.defaultProps;if(n)for(let e in n)void 0===t[e]&&(t[e]=n[e])}function $t(t,e){if(!0===e)return!0;if("function"==typeof e)return"object"==typeof t?t instanceof e:typeof t===e.name.toLowerCase();if(e instanceof Array){let n=!1;for(let o=0,r=e.length;o<r;o++)n=n||$t(t,e[o]);return n}if(e.optional&&void 0===t)return!0;let n=!e.type||$t(t,e.type);if(e.validate&&(n=n&&e.validate(t)),e.type===Array&&e.element)for(let o=0,r=t.length;o<r;o++)n=n&&$t(t[o],e.element);if(e.type===Object&&e.shape){const o=e.shape;for(let e in o)n=n&&$t(t[e],o[e]);if(n)for(let e in t)if(!(e in o))throw new Error(`unknown prop '${e}'`)}return n}class Nt extends EventTarget{trigger(t,e){this.dispatchEvent(new CustomEvent(t,{detail:e}))}}class Et extends String{}function At(t){const e=t.__owl__.component,n=Object.create(e);for(let e in t)n[e]=t[e];return n}const Tt=Symbol("isBoundary");class _t{constructor(t,e,n){this.fn=t,this.ctx=At(e),this.node=n}evaluate(){return this.fn(this.ctx,this.node)}toString(){return this.evaluate().toString()}}let Lt=new WeakMap;const Ct={withDefault:function(t,e){return null==t||!1===t?e:t},zero:Symbol("zero"),isBoundary:Tt,callSlot:function(t,e,n,o,i,s,l){n=n+"__slot_"+o;const a=t.props&&t.props.slots||{},{__render:c,__ctx:h,__scope:u}=a[o]||{},d=Object.create(h||{});u&&(d[u]=s||{});const f=c?c.call(h.__owl__.component,d,e,n):null;if(l){let s=void 0,a=void 0;return f?s=i?r(o,f):f:a=l.call(t.__owl__.component,t,e,n),O([s,a])}return f||z("")},capture:At,withKey:function(t,e){return t.key=e,t},prepareList:function(t){let e,n;if(Array.isArray(t))e=t,n=t;else{if(!t)throw new Error("Invalid loop expression");n=Object.keys(t),e=Object.values(t)}const o=n.length;return[e,n,o,new Array(o)]},setContextValue:function(t,e,n){const o=t;for(;!t.hasOwnProperty(e)&&!t.hasOwnProperty(Tt);){const e=t.__proto__;if(!e){t=o;break}t=e}t[e]=n},multiRefSetter:function(t,e){let n=0;return o=>{if(o&&(n++,n>1))throw new Error("Cannot have 2 elements with same ref name at the same time");(0===n||o)&&(t[e]=o)}},shallowEqual:function(t,e){for(let n=0,o=t.length;n<o;n++)if(t[n]!==e[n])return!1;return!0},toNumber:function(t){const e=parseFloat(t);return isNaN(e)?t:e},validateProps:function(t,e,n){const o="string"!=typeof t?t:n.constructor.components[t];if(!o)return;kt(e,o);const r=o.defaultProps||{};let i=(s=o.props)instanceof Array?Object.fromEntries(s.map((t=>t.endsWith("?")?[t.slice(0,-1),!1]:[t,!0]))):s||{"*":!0};var s;const l="*"in i;for(let t in i){if("*"===t)continue;const n=i[t];let s,l=!!n;if("object"==typeof n&&"optional"in n&&(l=!n.optional),l&&t in r)throw new Error(`A default value cannot be defined for a mandatory prop (name: '${t}', component: ${o.name})`);if(void 0!==e[t]){try{s=$t(e[t],n)}catch(e){throw e.message=`Invalid prop '${t}' in component ${o.name} (${e.message})`,e}if(!s)throw new Error(`Invalid Prop '${t}' in component '${o.name}'`)}else if(l)throw new Error(`Missing props '${t}' (component '${o.name}')`)}if(!l)for(let t in e)if(!(t in i))throw new Error(`Unknown prop '${t}' given to component '${o.name}'`)},LazyValue:_t,safeOutput:function(t){if(!t)return t;let e,n;return t instanceof Et?(e="string_safe",n=wt(t)):t instanceof _t?(e="lazy_value",n=t.evaluate()):t instanceof String||"string"==typeof t?(e="string_unsafe",n=z(t)):(e="block_safe",n=t),r(e,n)},bind:function(t,e){let n=t.__owl__.component,o=Lt.get(n);o||(o=new WeakMap,Lt.set(n,o));let r=o.get(e);return r||(r=e.bind(n),o.set(e,r)),r}},St=new WeakMap,Dt=new WeakMap;function Bt(t,e,n=!1){if(!t)return!1;const o=t.fiber;o&&St.set(o,e);const r=Dt.get(t);if(r){let t=!1;for(let n=r.length-1;n>=0;n--)try{r[n](e),t=!0;break}catch(t){e=t}if(t)return n&&o&&o.node.fiber&&o.root.counter--,!0}return Bt(t.parent,e)}function Ot(t){const e=t.error,n="node"in t?t.node:t.fiber.node,o="fiber"in t?t.fiber:n.fiber;let r=o;do{r.node.fiber=r,r=r.parent}while(r);St.set(o.root,e);if(!Bt(n,e,!0)){console.warn("[Owl] Unhandled error. Destroying the root component");try{n.app.destroy()}catch(t){console.error(t)}}}function It(t,e){let n=t.fiber;if(n){Rt(e.root,n.children),n.root=null}return new Pt(t,e)}function Rt(t,e){let n=0;for(let o of e)o.node.fiber=null,o.root=t,o.bdom||n++,n+=Rt(t,o.children);return n}class Pt{constructor(t,e){if(this.bdom=null,this.children=[],this.appliedToDom=!1,this.node=t,this.parent=e,e){const t=e.root;t.counter++,this.root=t,e.children.push(this)}else this.root=this}}class jt extends Pt{constructor(){super(...arguments),this.counter=1,this.willPatch=[],this.patched=[],this.mounted=[],this.locked=!1}complete(){const t=this.node;this.locked=!0;let e=void 0;try{for(e of this.willPatch){let t=e.node;if(t.fiber===e){const e=t.component;for(let n of t.willPatch)n.call(e)}}e=void 0,t.patch(),this.locked=!1;let n=this.mounted;for(;e=n.pop();)if(e=e,e.appliedToDom)for(let t of e.node.mounted)t();let o=this.patched;for(;e=o.pop();)if(e=e,e.appliedToDom)for(let t of e.node.patched)t()}catch(t){this.locked=!1,Ot({fiber:e||this,error:t})}}}class Mt extends jt{constructor(t,e,n={}){super(t,null),this.target=e,this.position=n.position||"last-child"}complete(){let t=this;try{const e=this.node;if(e.app.constructor.validateTarget(this.target),e.bdom)e.updateDom();else if(e.bdom=this.bdom,"last-child"===this.position||0===this.target.childNodes.length)xt(e.bdom,this.target);else{const t=this.target.childNodes[0];xt(e.bdom,this.target,t)}e.fiber=null,e.status=1,this.appliedToDom=!0;let n=this.mounted;for(;t=n.pop();)if(t.appliedToDom)for(let e of t.node.mounted)e()}catch(e){Ot({fiber:t,error:e})}}}let Ft=null;function Vt(){if(!Ft)throw new Error("No active component (a hook function should only be called in 'setup')");return Ft}class Wt{constructor(t,e,n,o){this.fiber=null,this.bdom=null,this.status=0,this.children=Object.create(null),this.refs={},this.willStart=[],this.willUpdateProps=[],this.willUnmount=[],this.mounted=[],this.willPatch=[],this.patched=[],this.willDestroy=[],Ft=this,this.app=n,this.parent=o||null,this.level=o?o.level+1:0,kt(e,t);const r=o&&o.childEnv||n.env;this.childEnv=r,this.component=new t(e,r,this),this.renderFn=n.getTemplate(t.template).bind(this.component,this.component,this),this.component.setup(),Ft=null}mountComponent(t,e){const n=new Mt(this,t,e);this.app.scheduler.addFiber(n),this.initiateRender(n)}async initiateRender(t){this.fiber=t,this.mounted.length&&t.root.mounted.push(t);const e=this.component;try{await Promise.all(this.willStart.map((t=>t.call(e))))}catch(t){return void Ot({node:this,error:t})}0===this.status&&this.fiber===t&&this._render(t)}async render(){let t=this.fiber;if(t&&t.root.locked&&(await Promise.resolve(),t=this.fiber),t&&!t.bdom&&!St.has(t))return;if(!this.bdom&&!t)return;const e=function(t){let e=t.fiber;if(e){let t=e.root;return t.counter-=Rt(t,e.children),e.children=[],t.counter++,e.bdom=null,St.has(e)&&(St.delete(e),St.delete(t),e.appliedToDom=!1),e}const n=new jt(t,null);return t.willPatch.length&&n.willPatch.push(n),t.patched.length&&n.patched.push(n),n}(this);this.fiber=e,this.app.scheduler.addFiber(e),await Promise.resolve(),2!==this.status&&(this.fiber!==e||!t&&e.parent||this._render(e))}_render(t){try{t.bdom=this.renderFn(),t.root.counter--}catch(t){Ot({node:this,error:t})}}destroy(){let t=1===this.status;this._destroy(),t&&this.bdom.remove()}_destroy(){const t=this.component;if(1===this.status)for(let e of this.willUnmount)e.call(t);for(let t of Object.values(this.children))t._destroy();for(let e of this.willDestroy)e.call(t);this.status=2}async updateAndRender(t,e){const n=It(this,e);this.fiber=n;const o=this.component;kt(t,o.constructor);const r=Promise.all(this.willUpdateProps.map((e=>e.call(o,t))));if(await r,n!==this.fiber)return;o.props=t,this._render(n);const i=e.root;this.willPatch.length&&i.willPatch.push(n),this.patched.length&&i.patched.push(n)}updateDom(){if(this.fiber)if(this.bdom===this.fiber.bdom)for(let t in this.children){this.children[t].updateDom()}else this.bdom.patch(this.fiber.bdom,!1),this.fiber.appliedToDom=!0,this.fiber=null}firstNode(){const t=this.bdom;return t?t.firstNode():void 0}mount(t,e){const n=this.fiber.bdom;this.bdom=n,n.mount(t,e),this.status=1,this.fiber.appliedToDom=!0,this.fiber=null}moveBefore(t,e){this.bdom.moveBefore(t?t.bdom:null,e)}patch(){const t=Object.keys(this.children).length>0;this.bdom.patch(this.fiber.bdom,t),t&&this.cleanOutdatedChildren(),this.fiber.appliedToDom=!0,this.fiber=null}beforeRemove(){this._destroy()}remove(){this.bdom.remove()}cleanOutdatedChildren(){const t=this.children;for(const e in t){const n=t[e],o=n.status;1!==o&&(delete t[e],2!==o&&n.destroy())}}}function zt(t){const e=Vt();e.mounted.push(t.bind(e.component))}function Kt(t){const e=Vt();e.patched.push(t.bind(e.component))}function Ht(t){const e=Vt();e.willUnmount.unshift(t.bind(e.component))}function Ut(t){const e=Vt();e.willDestroy.push(t.bind(e.component))}const qt="true,false,NaN,null,undefined,debugger,console,window,in,instanceof,new,function,return,this,eval,void,Math,RegExp,Array,Object,Date".split(","),Gt=Object.assign(Object.create(null),{and:"&&",or:"||",gt:">",gte:">=",lt:"<",lte:"<="}),Xt=Object.assign(Object.create(null),{"{":"LEFT_BRACE","}":"RIGHT_BRACE","[":"LEFT_BRACKET","]":"RIGHT_BRACKET",":":"COLON",",":"COMMA","(":"LEFT_PAREN",")":"RIGHT_PAREN"}),Yt="...,.,===,==,+,!==,!=,!,||,&&,>=,>,<=,<,?,-,*,/,%,typeof ,=>,=,;,in ".split(",");const Zt=[function(t){let e=t[0],n=e;if("'"!==e&&'"'!==e&&"`"!==e)return!1;let o,r=1;for(;t[r]&&t[r]!==n;){if(o=t[r],e+=o,"\\"===o){if(r++,o=t[r],!o)throw new Error("Invalid expression");e+=o}r++}if(t[r]!==n)throw new Error("Invalid expression");return e+=n,"`"===n?{type:"TEMPLATE_STRING",value:e,replace:t=>e.replace(/\$\{(.*?)\}/g,((e,n)=>"${"+t(n)+"}"))}:{type:"VALUE",value:e}},function(t){let e=t[0];if(e&&e.match(/[0-9]/)){let n=1;for(;t[n]&&t[n].match(/[0-9]|\./);)e+=t[n],n++;return{type:"VALUE",value:e}}return!1},function(t){for(let e of Yt)if(t.startsWith(e))return{type:"OPERATOR",value:e};return!1},function(t){let e=t[0];if(e&&e.match(/[a-zA-Z_\$]/)){let n=1;for(;t[n]&&t[n].match(/\w/);)e+=t[n],n++;return e in Gt?{type:"OPERATOR",value:Gt[e],size:e.length}:{type:"SYMBOL",value:e}}return!1},function(t){const e=t[0];return!(!e||!(e in Xt))&&{type:Xt[e],value:e}}];const Qt=t=>t&&("LEFT_BRACE"===t.type||"COMMA"===t.type),Jt=t=>t&&("RIGHT_BRACE"===t.type||"COMMA"===t.type);function te(t){const e=new Set,n=function(t){const e=[];let n=!0;for(;n;)if(t=t.trim()){for(let o of Zt)if(n=o(t),n){e.push(n),t=t.slice(n.size||n.value.length);break}}else n=!1;if(t.length)throw new Error(`Tokenizer error: could not tokenize "${t}"`);return e}(t);let o=0,r=[];for(;o<n.length;){let t=n[o],i=n[o-1],s=n[o+1],l=r[r.length-1];switch(t.type){case"LEFT_BRACE":case"LEFT_BRACKET":r.push(t.type);break;case"RIGHT_BRACE":case"RIGHT_BRACKET":r.pop()}let a="SYMBOL"===t.type&&!qt.includes(t.value);if("SYMBOL"!==t.type||qt.includes(t.value)||i&&("LEFT_BRACE"===l&&Qt(i)&&Jt(s)&&(n.splice(o+1,0,{type:"COLON",value:":"},{...t}),s=n[o+1]),"OPERATOR"===i.type&&"."===i.value?a=!1:"LEFT_BRACE"!==i.type&&"COMMA"!==i.type||s&&"COLON"===s.type&&(a=!1)),"TEMPLATE_STRING"===t.type&&(t.value=t.replace((t=>ee(t)))),s&&"OPERATOR"===s.type&&"=>"===s.value)if("RIGHT_PAREN"===t.type){let t=o-1;for(;t>0&&"LEFT_PAREN"!==n[t].type;)"SYMBOL"===n[t].type&&n[t].originalValue&&(n[t].value=n[t].originalValue,e.add(n[t].value)),t--}else e.add(t.value);a&&(t.varName=t.value,e.has(t.value)||(t.originalValue=t.value,t.value=`ctx['${t.value}']`)),o++}for(const t of n)"SYMBOL"===t.type&&t.varName&&e.has(t.value)&&(t.originalValue=t.value,t.value="_"+t.value,t.isLocal=!0);return n}function ee(t){return te(t).map((t=>t.value)).join("")}const ne=/\{\{.*?\}\}/g,oe=/\{\{.*?\}\}/g;function re(t){let e=t.match(ne);return e&&e[0].length===t.length?`(${ee(t.slice(2,-2))})`:"`"+t.replace(oe,(t=>"${"+ee(t.slice(2,-2))+"}"))+"`"}const ie=document.implementation.createDocument(null,null,null),se=new Set(["stop","capture","prevent","self","synthetic"]);class le{constructor(t,e){this.dynamicTagName=null,this.isRoot=!1,this.hasDynamicChildren=!1,this.children=[],this.data=[],this.childNumber=0,this.parentVar="",this.id=le.nextBlockId++,this.varName="b"+this.id,this.blockName="block"+this.id,this.target=t,this.type=e}static generateId(t){return this.nextDataIds[t]=(this.nextDataIds[t]||0)+1,t+this.nextDataIds[t]}insertData(t,e="d"){const n=le.generateId(e);return this.target.addLine(`let ${n} = ${t};`),this.data.push(n)-1}insert(t){this.currentDom?this.currentDom.appendChild(t):this.dom=t}generateExpr(t){if("block"===this.type){const t=this.children.length;let e=this.data.length?`[${this.data.join(", ")}]`:t?"[]":"";return t&&(e+=", ["+this.children.map((t=>t.varName)).join(", ")+"]"),this.dynamicTagName?`toggler(${this.dynamicTagName}, ${this.blockName}(${this.dynamicTagName})(${e}))`:`${this.blockName}(${e})`}return"list"===this.type?`list(c_block${this.id})`:t}asXmlString(){const t=ie.createElement("t");return t.appendChild(this.dom),t.innerHTML}}function ae(t,e){return Object.assign({block:null,index:0,forceNewBlock:!0,translate:t.translate,tKeyExpr:null,nameSpace:t.nameSpace,tModelSelectedExpr:t.tModelSelectedExpr},e)}le.nextBlockId=1,le.nextDataIds={};class ce{constructor(t){this.indentLevel=0,this.loopLevel=0,this.code=[],this.hasRoot=!1,this.hasCache=!1,this.hasRef=!1,this.refInfo={},this.shouldProtectScope=!1,this.name=t}addLine(t,e){const n=new Array(this.indentLevel+2).join(" ");void 0===e?this.code.push(n+t):this.code.splice(e,0,n+t)}generateCode(){let t=[];if(t.push(`function ${this.name}(ctx, node, key = "") {`),this.hasRef){t.push(" const refs = ctx.__owl__.refs;");for(let e in this.refInfo){const[n,o]=this.refInfo[e];t.push(` const ${n} = ${o};`)}}this.shouldProtectScope&&(t.push(" ctx = Object.create(ctx);"),t.push(" ctx[isBoundary] = 1")),this.hasCache&&(t.push(" let cache = ctx.cache || {};"),t.push(" let nextCache = ctx.cache = {};"));for(let e of this.code)t.push(e);return this.hasRoot||t.push("return text('');"),t.push("}"),t.join("\n ")}}const he=["label","title","placeholder","alt"],ue=/^(\s*)([\s\S]+?)(\s*)$/;class de{constructor(t,e){if(this.blocks=[],this.ids={},this.nextBlockId=1,this.isDebug=!1,this.targets=[],this.target=new ce("template"),this.translatableAttributes=he,this.staticCalls=[],this.helpers=new Set,this.translateFn=e.translateFn||(t=>t),e.translatableAttributes){const t=new Set(he);for(let n of e.translatableAttributes)n.startsWith("-")?t.delete(n.slice(1)):t.add(n);this.translatableAttributes=[...t]}this.hasSafeContext=e.hasSafeContext||!1,this.dev=e.dev||!1,this.ast=t,this.templateName=e.name}generateCode(){const t=this.ast;this.isDebug=12===t.type,le.nextBlockId=1,le.nextDataIds={},this.compileAST(t,{block:null,index:0,forceNewBlock:!1,isLast:!0,translate:!0,tKeyExpr:null});let e=[" let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;"];this.helpers.size&&e.push(`let { ${[...this.helpers].join(", ")} } = helpers;`),this.templateName&&e.push(`// Template name: "${this.templateName}"`);for(let{id:t,template:n}of this.staticCalls)e.push(`const ${t} = getTemplate(${n});`);if(this.blocks.length){e.push("");for(let t of this.blocks)if(t.dom){let n=t.asXmlString();t.dynamicTagName?(n=n.replace(/^<\w+/,`<\${tag || '${t.dom.nodeName}'}`),n=n.replace(/\w+>$/,`\${tag || '${t.dom.nodeName}'}>`),e.push(`let ${t.blockName} = tag => createBlock(\`${n}\`);`)):e.push(`let ${t.blockName} = createBlock(\`${n}\`);`)}}if(this.targets.length)for(let t of this.targets)e.push(""),e=e.concat(t.generateCode());e.push(""),e=e.concat("return "+this.target.generateCode());const n=e.join("\n ");if(this.isDebug){const t="[Owl Debug]\n"+n;console.log(t)}return n}compileInNewTarget(t,e,n){const o=this.generateId(t),r=this.target,i=new ce(o);this.targets.push(i),this.target=i;const s=ae(n);return this.compileAST(e,s),this.target=r,o}addLine(t){this.target.addLine(t)}generateId(t=""){return this.ids[t]=(this.ids[t]||0)+1,t+this.ids[t]}insertAnchor(t){const e="block-child-"+t.children.length,n=ie.createElement(e);t.insert(n)}createBlock(t,e,n){const o=this.target.hasRoot,r=new le(this.target,e);return o||n.preventRoot||(this.target.hasRoot=!0,r.isRoot=!0),t&&(t.children.push(r),"list"===t.type&&(r.parentVar="c_block"+t.id)),r}insertBlock(t,e,n){let o=e.generateExpr(t);const r=n.tKeyExpr;if(e.parentVar){let t="key"+this.target.loopLevel;return r&&(t=`${r} + ${t}`),this.helpers.add("withKey"),void this.addLine(`${e.parentVar}[${n.index}] = withKey(${o}, ${t});`)}r&&(o=`toggler(${r}, ${o})`),e.isRoot&&!n.preventRoot?this.addLine(`return ${o};`):this.addLine(`let ${e.varName} = ${o};`)}captureExpression(t,e=!1){if(!e&&!t.includes("=>"))return ee(t);const n=te(t),o=new Map;return n.map((t=>{if(t.varName&&!t.isLocal){if(!o.has(t.varName)){const e=this.generateId("v");o.set(t.varName,e),this.addLine(`const ${e} = ${t.value};`)}t.value=o.get(t.varName)}return t.value})).join("")}compileAST(t,e){switch(t.type){case 1:this.compileComment(t,e);break;case 0:this.compileText(t,e);break;case 2:this.compileTDomNode(t,e);break;case 4:this.compileTEsc(t,e);break;case 8:this.compileTOut(t,e);break;case 5:this.compileTIf(t,e);break;case 9:this.compileTForeach(t,e);break;case 10:this.compileTKey(t,e);break;case 3:this.compileMulti(t,e);break;case 7:this.compileTCall(t,e);break;case 15:this.compileTCallBlock(t,e);break;case 6:this.compileTSet(t,e);break;case 11:this.compileComponent(t,e);break;case 12:this.compileDebug(t,e);break;case 13:this.compileLog(t,e);break;case 14:this.compileTSlot(t,e);break;case 16:this.compileTTranslation(t,e);break;case 17:this.compileTPortal(t,e)}}compileDebug(t,e){this.addLine("debugger;"),t.content&&this.compileAST(t.content,e)}compileLog(t,e){this.addLine(`console.log(${ee(t.expr)});`),t.content&&this.compileAST(t.content,e)}compileComment(t,e){let{block:n,forceNewBlock:o}=e;if(!n||o)n=this.createBlock(n,"comment",e),this.insertBlock(`comment(\`${t.value}\`)`,n,{...e,forceNewBlock:o&&!n});else{const e=ie.createComment(t.value);n.insert(e)}}compileText(t,e){let{block:n,forceNewBlock:o}=e,r=t.value;if(r&&!1!==e.translate){const t=ue.exec(r);r=t[1]+this.translateFn(t[2])+t[3]}if(!n||o)n=this.createBlock(n,"text",e),this.insertBlock(`text(\`${r}\`)`,n,{...e,forceNewBlock:o&&!n});else{const e=0===t.type?ie.createTextNode:ie.createComment;n.insert(e.call(ie,r))}}generateHandlerCode(t,e){const n=t.split(".").slice(1).map((t=>{if(!se.has(t))throw new Error(`Unknown event modifier: '${t}'`);return`"${t}"`}));let o="";return n.length&&(o=n.join(",")+", "),`[${o}${this.captureExpression(e)}, ctx]`}compileTDomNode(t,e){let{block:n,forceNewBlock:o}=e;const r=!n||o||null!==t.dynamicTag||t.ns;let i=this.target.code.length;if(r&&((t.dynamicTag||e.tKeyExpr||t.ns)&&e.block&&this.insertAnchor(e.block),n=this.createBlock(n,"block",e),this.blocks.push(n),t.dynamicTag)){const e=this.generateId("tag");this.addLine(`let ${e} = ${ee(t.dynamicTag)};`),n.dynamicTagName=e}const s={},l=t.ns||e.nameSpace;l&&r&&(s["block-ns"]=l);for(let o in t.attrs){let r,i;if(o.startsWith("t-attf")){r=re(t.attrs[o]);const e=n.insertData(r,"attr");i=o.slice(7),s["block-attribute-"+e]=i}else if(o.startsWith("t-att")){r=ee(t.attrs[o]);const e=n.insertData(r,"attr");"t-att"===o?s["block-attributes"]=String(e):(i=o.slice(6),s["block-attribute-"+e]=i)}else this.translatableAttributes.includes(o)?s[o]=this.translateFn(t.attrs[o]):(r=`"${t.attrs[o]}"`,i=o,s[o]=t.attrs[o]);if("value"===i&&e.tModelSelectedExpr){s["block-attribute-"+n.insertData(`${e.tModelSelectedExpr} === ${r}`,"attr")]="selected"}}for(let e in t.on){const o=this.generateHandlerCode(e,t.on[e]);s["block-handler-"+n.insertData(o,"hdlr")]=e}if(t.ref){this.target.hasRef=!0;if(ne.test(t.ref)){const e=t.ref.replace(ne,(t=>"${"+this.captureExpression(t.slice(2,-2),!0)+"}")),o=n.insertData(`(el) => refs[\`${e}\`] = el`,"ref");s["block-ref"]=String(o)}else{let e=t.ref;if(e in this.target.refInfo){this.helpers.add("multiRefSetter");const t=this.target.refInfo[e],o=n.data.push(t[0])-1;s["block-ref"]=String(o),t[1]=`multiRefSetter(refs, \`${e}\`)`}else{let t=this.generateId("ref");this.target.refInfo[e]=[t,`(el) => refs[\`${e}\`] = el`];const o=n.data.push(t)-1;s["block-ref"]=String(o)}}}let a;if(t.model){const{hasDynamicChildren:e,baseExpr:o,expr:r,eventType:i,shouldNumberize:l,shouldTrim:c,targetAttr:h,specialInitTargetAttr:u}=t.model,d=ee(o),f=this.generateId("bExpr");this.addLine(`const ${f} = ${d};`);const p=ee(r),m=this.generateId("expr");this.addLine(`const ${m} = ${p};`);const g=`${f}[${m}]`;let b;if(u)b=n.insertData(`${g} === '${s[h]}'`,"attr"),s["block-attribute-"+b]=u;else if(e){a=""+this.generateId("bValue"),this.addLine(`let ${a} = ${g}`)}else b=n.insertData(""+g,"attr"),s["block-attribute-"+b]=h;this.helpers.add("toNumber");let v="ev.target."+h;v=c?v+".trim()":v,v=l?`toNumber(${v})`:v;const y=`[(ev) => { ${g} = ${v}; }]`;b=n.insertData(y,"hdlr"),s["block-handler-"+b]=i}const c=ie.createElement(t.tag);for(const[t,e]of Object.entries(s))"class"===t&&""===e||c.setAttribute(t,e);if(n.insert(c),t.content.length){const o=n.currentDom;n.currentDom=c;const r=t.content;for(let o=0;o<r.length;o++){const i=t.content[o],s=ae(e,{block:n,index:n.childNumber,forceNewBlock:!1,isLast:e.isLast&&o===r.length-1,tKeyExpr:e.tKeyExpr,nameSpace:l,tModelSelectedExpr:a});this.compileAST(i,s)}n.currentDom=o}if(r&&(this.insertBlock(n.blockName+"(ddd)",n,e),n.children.length&&n.hasDynamicChildren)){const t=this.target.code,e=n.children.slice();let o=e.shift();for(let n=i;n<t.length&&(!t[n].trimStart().startsWith(`let ${o.varName} `)||(t[n]=t[n].replace("let "+o.varName,o.varName),o=e.shift(),o));n++);this.target.addLine(`let ${n.children.map((t=>t.varName))};`,i)}}compileTEsc(t,e){let n,{block:o,forceNewBlock:r}=e;if("0"===t.expr?(this.helpers.add("zero"),n="ctx[zero]"):(n=ee(t.expr),t.defaultValue&&(this.helpers.add("withDefault"),n=`withDefault(${n}, \`${t.defaultValue}\`)`)),!o||r)o=this.createBlock(o,"text",e),this.insertBlock(`text(${n})`,o,{...e,forceNewBlock:r&&!o});else{const t=o.insertData(n,"txt"),e=ie.createElement("block-text-"+t);o.insert(e)}}compileTOut(t,e){let{block:n}=e;n&&this.insertAnchor(n),n=this.createBlock(n,"html",e),this.helpers.add("0"===t.expr?"zero":"safeOutput");let o="0"===t.expr?"ctx[zero]":`safeOutput(${ee(t.expr)})`;if(t.body){const n=le.nextBlockId,r=ae(e);this.compileAST({type:3,content:t.body},r),this.helpers.add("withDefault"),o=`withDefault(${o}, b${n})`}this.insertBlock(""+o,n,e)}compileTIf(t,e,n){let{block:o,forceNewBlock:r,index:i}=e,s=i;const l=this.target.code.length,a=!o||"multi"!==o.type&&r;o&&(o.hasDynamicChildren=!0),(!o||"multi"!==o.type&&r)&&(o=this.createBlock(o,"multi",e)),this.addLine(`if (${ee(t.condition)}) {`),this.target.indentLevel++,this.insertAnchor(o);const c=ae(e,{block:o,index:s});if(this.compileAST(t.content,c),this.target.indentLevel--,t.tElif)for(let n of t.tElif){this.addLine(`} else if (${ee(n.condition)}) {`),this.target.indentLevel++,this.insertAnchor(o);const t=ae(e,{block:o,index:s});this.compileAST(n.content,t),this.target.indentLevel--}if(t.tElse){this.addLine("} else {"),this.target.indentLevel++,this.insertAnchor(o);const n=ae(e,{block:o,index:s});this.compileAST(t.tElse,n),this.target.indentLevel--}if(this.addLine("}"),a){if(o.children.length){const t=this.target.code,e=o.children.slice();let n=e.shift();for(let o=l;o<t.length&&(!t[o].trimStart().startsWith(`let ${n.varName} `)||(t[o]=t[o].replace("let "+n.varName,n.varName),n=e.shift(),n));o++);this.target.addLine(`let ${o.children.map((t=>t.varName))};`,l)}const t=o.children.map((t=>t.varName)).join(", ");this.insertBlock(`multi([${t}])`,o,e)}}compileTForeach(t,e){let{block:n}=e;n&&this.insertAnchor(n),n=this.createBlock(n,"list",e),this.target.loopLevel++;const o="i"+this.target.loopLevel;this.addLine("ctx = Object.create(ctx);");const r="v_block"+n.id,i="k_block"+n.id,s="l_block"+n.id,l="c_block"+n.id;let a;this.helpers.add("prepareList"),this.addLine(`const [${i}, ${r}, ${s}, ${l}] = prepareList(${ee(t.collection)});`),this.dev&&this.addLine(`const keys${n.id} = new Set();`),this.addLine(`for (let ${o} = 0; ${o} < ${s}; ${o}++) {`),this.target.indentLevel++,this.addLine(`ctx[\`${t.elem}\`] = ${r}[${o}];`),t.hasNoFirst||this.addLine(`ctx[\`${t.elem}_first\`] = ${o} === 0;`),t.hasNoLast||this.addLine(`ctx[\`${t.elem}_last\`] = ${o} === ${r}.length - 1;`),t.hasNoIndex||this.addLine(`ctx[\`${t.elem}_index\`] = ${o};`),t.hasNoValue||this.addLine(`ctx[\`${t.elem}_value\`] = ${i}[${o}];`),this.addLine(`let key${this.target.loopLevel} = ${t.key?ee(t.key):o};`),this.dev&&(this.addLine(`if (keys${n.id}.has(key${this.target.loopLevel})) { throw new Error(\`Got duplicate key in t-foreach: \${key${this.target.loopLevel}}\`)}`),this.addLine(`keys${n.id}.add(key${this.target.loopLevel});`)),t.memo&&(this.target.hasCache=!0,a=this.generateId(),this.addLine(`let memo${a} = ${ee(t.memo)}`),this.addLine(`let vnode${a} = cache[key${this.target.loopLevel}];`),this.addLine(`if (vnode${a}) {`),this.target.indentLevel++,this.addLine(`if (shallowEqual(vnode${a}.memo, memo${a})) {`),this.target.indentLevel++,this.addLine(`${l}[${o}] = vnode${a};`),this.addLine(`nextCache[key${this.target.loopLevel}] = vnode${a};`),this.addLine("continue;"),this.target.indentLevel--,this.addLine("}"),this.target.indentLevel--,this.addLine("}"));const c=ae(e,{block:n,index:o});this.compileAST(t.body,c),t.memo&&this.addLine(`nextCache[key${this.target.loopLevel}] = Object.assign(${l}[${o}], {memo: memo${a}});`),this.target.indentLevel--,this.target.loopLevel--,this.addLine("}"),e.isLast||this.addLine("ctx = ctx.__proto__;"),this.insertBlock("l",n,e)}compileTKey(t,e){const n=this.generateId("tKey_");this.addLine(`const ${n} = ${ee(t.expr)};`),e=ae(e,{tKeyExpr:n,block:e.block,index:e.index}),this.compileAST(t.content,e)}compileMulti(t,e){let{block:n,forceNewBlock:o}=e;const r=!n||o;let i=this.target.code.length;if(r){if(t.content.filter((t=>6!==t.type)).length<=1){for(let n of t.content)this.compileAST(n,e);return}n=this.createBlock(n,"multi",e)}let s=0;for(let o=0,r=t.content.length;o<r;o++){const i=t.content[o],l=6===i.type,a=ae(e,{block:n,index:s,forceNewBlock:!l,preventRoot:e.preventRoot,isLast:e.isLast&&o===r-1});this.compileAST(i,a),l||s++}if(r){if(n.hasDynamicChildren&&n.children.length){const t=this.target.code,e=n.children.slice();let o=e.shift();for(let n=i;n<t.length&&(!t[n].trimStart().startsWith(`let ${o.varName} `)||(t[n]=t[n].replace("let "+o.varName,o.varName),o=e.shift(),o));n++);this.target.addLine(`let ${n.children.map((t=>t.varName))};`,i)}const t=n.children.map((t=>t.varName)).join(", ");this.insertBlock(`multi([${t}])`,n,e)}}compileTCall(t,e){let{block:n,forceNewBlock:o}=e;if(t.body){this.addLine("ctx = Object.create(ctx);"),this.addLine("ctx[isBoundary] = 1;"),this.helpers.add("isBoundary");const n=le.nextBlockId,o=ae(e,{preventRoot:!0});this.compileAST({type:3,content:t.body},o),n!==le.nextBlockId&&(this.helpers.add("zero"),this.addLine(`ctx[zero] = b${n};`))}const r=ne.test(t.name),i=r?re(t.name):"`"+t.name+"`";n&&(o||this.insertAnchor(n));const s=`key + \`${this.generateComponentKey()}\``;if(r){const t=this.generateId("template");this.addLine(`const ${t} = ${i};`),n=this.createBlock(n,"multi",e),this.helpers.add("call"),this.insertBlock(`call(this, ${t}, ctx, node, ${s})`,n,{...e,forceNewBlock:!n})}else{const t=this.generateId("callTemplate_");this.helpers.add("getTemplate"),this.staticCalls.push({id:t,template:i}),n=this.createBlock(n,"multi",e),this.insertBlock(`${t}.call(this, ctx, node, ${s})`,n,{...e,forceNewBlock:!n})}t.body&&!e.isLast&&this.addLine("ctx = ctx.__proto__;")}compileTCallBlock(t,e){let{block:n,forceNewBlock:o}=e;n&&(o||this.insertAnchor(n)),n=this.createBlock(n,"multi",e),this.insertBlock(ee(t.name),n,{...e,forceNewBlock:!n})}compileTSet(t,e){this.target.shouldProtectScope=!0,this.helpers.add("isBoundary").add("withDefault");const n=t.value?ee(t.value||""):"null";if(t.body){this.helpers.add("LazyValue");const o={type:3,content:t.body};let r=`new LazyValue(${this.compileInNewTarget("value",o,e)}, ctx, node)`;r=t.value?r?`withDefault(${n}, ${r})`:n:r,this.addLine(`ctx[\`${t.name}\`] = ${r};`)}else{let e;e=t.defaultValue?t.value?`withDefault(${n}, \`${t.defaultValue}\`)`:`\`${t.defaultValue}\``:n,this.helpers.add("setContextValue"),this.addLine(`setContextValue(ctx, "${t.name}", ${e});`)}}generateComponentKey(){const t=[this.generateId("__")];for(let e=0;e<this.target.loopLevel;e++)t.push(`\${key${e+1}}`);return t.join("__")}formatProp(t,e){if(e=this.captureExpression(e),t.includes(".")){let[n,o]=t.split(".");if("bind"!==o)throw new Error("Invalid prop suffix");this.helpers.add("bind"),t=n,e=`bind(ctx, ${e||void 0})`}return`${t=/^[a-z_]+$/i.test(t)?t:`'${t}'`}: ${e||void 0}`}formatPropObject(t){const e=[];for(const[n,o]of Object.entries(t))e.push(this.formatProp(n,o));return e.join(", ")}compileComponent(t,e){let{block:n}=e;const o="slots"in t.props,r=[],i=this.formatPropObject(t.props);i&&r.push(i);let s="";if(!!Object.keys(t.slots).length){let n="ctx";!this.target.loopLevel&&this.hasSafeContext||(n=this.generateId("ctx"),this.helpers.add("capture"),this.addLine(`const ${n} = capture(ctx);`));let o=[];for(let r in t.slots){const i=t.slots[r].content,s=[`__render: ${this.compileInNewTarget("slot",i,e)}, __ctx: ${n}`],l=t.slots[r].scope;l&&s.push(`__scope: "${l}"`),t.slots[r].attrs&&s.push(this.formatPropObject(t.slots[r].attrs));const a=`{${s.join(", ")}}`;o.push(`'${r}': ${a}`)}s=`{${o.join(", ")}}`}!s||t.dynamicProps||o||r.push("slots: "+s);const l=`{${r.join(",")}}`;let a,c=l;t.dynamicProps&&(c=r.length?`Object.assign({}, ${ee(t.dynamicProps)}, ${l})`:`Object.assign({}, ${ee(t.dynamicProps)})`),(s&&(t.dynamicProps||o)||this.dev)&&(a=this.generateId("props"),this.addLine(`const ${a} = ${c};`),c=a),s&&(t.dynamicProps||o)&&this.addLine(`${a}.slots = Object.assign(${s}, ${a}.slots)`);const h=this.generateComponentKey();let u;t.isDynamic?(u=this.generateId("Comp"),this.addLine(`let ${u} = ${ee(t.name)};`)):u=`\`${t.name}\``,this.dev&&this.addLine(`helpers.validateProps(${u}, ${a}, ctx);`),n&&(!1===e.forceNewBlock||e.tKeyExpr)&&this.insertAnchor(n);let d=`key + \`${h}\``;e.tKeyExpr&&(d=`${e.tKeyExpr} + ${d}`);let f=`component(${`${u}, ${c}, ${d}, node, ctx`})`;t.isDynamic&&(f=`toggler(${u}, ${f})`),n=this.createBlock(n,"multi",e),this.insertBlock(f,n,e)}compileTSlot(t,e){this.helpers.add("callSlot");let n,o,{block:r}=e,i=!1;t.name.match(ne)?(i=!0,o=re(t.name)):o="'"+t.name+"'";const s=t.attrs?`{${this.formatPropObject(t.attrs)}}`:null;if(t.defaultContent){n=`callSlot(ctx, node, key, ${o}, ${i}, ${s}, ${this.compileInNewTarget("defaultContent",t.defaultContent,e)})`}else if(i){let t=this.generateId("slot");this.addLine(`const ${t} = ${o};`),n=`toggler(${t}, callSlot(ctx, node, key, ${t}), ${i}, ${s})`}else n=`callSlot(ctx, node, key, ${o}, ${i}, ${s})`;r&&this.insertAnchor(r),r=this.createBlock(r,"multi",e),this.insertBlock(n,r,{...e,forceNewBlock:!1})}compileTTranslation(t,e){t.content&&this.compileAST(t.content,Object.assign({},e,{translate:!1}))}compileTPortal(t,e){this.helpers.add("Portal");let{block:n}=e;const o=this.compileInNewTarget("slot",t.content,e),r=this.generateComponentKey();let i="ctx";!this.target.loopLevel&&this.hasSafeContext||(i=this.generateId("ctx"),this.helpers.add("capture"),this.addLine(`const ${i} = capture(ctx);`));const s=`component(Portal, {target: ${t.target},slots: {'default': {__render: ${o}, __ctx: ${i}}}}, key + \`${r}\`, node, ctx)`;n&&this.insertAnchor(n),n=this.createBlock(n,"multi",e),this.insertBlock(s,n,{...e,forceNewBlock:!1})}}const fe=new WeakMap;function pe(t){if("string"==typeof t){return me(function(t){const e=(new DOMParser).parseFromString(t,"text/xml");if(e.getElementsByTagName("parsererror").length){let n="Invalid XML in template.";const o=e.getElementsByTagName("parsererror")[0].textContent;if(o){n+="\nThe parser has produced the following error message:\n"+o;const e=/\d+/g,r=e.exec(o);if(r){const i=Number(r[0]),s=t.split("\n")[i-1],l=e.exec(o);if(s&&l){const t=Number(l[0])-1;s[t]&&(n+=`\nThe error might be located at xml line ${i} column ${t}\n${s}\n${"-".repeat(t-1)}^`)}}}throw new Error(n)}return e}(`<t>${t}</t>`).firstChild)}let e=fe.get(t);return e||(e=me(t.cloneNode(!0)),fe.set(t,e)),e}function me(t){var e;(function(t){let e=t.querySelectorAll("[t-elif], [t-else]");for(let t=0,n=e.length;t<n;t++){let n=e[t],o=n.previousElementSibling,r=t=>o.getAttribute(t),i=t=>+!!n.getAttribute(t);if(!o||!r("t-if")&&!r("t-elif"))throw new Error("t-elif and t-else directives must be preceded by a t-if or t-elif directive");{if(r("t-foreach"))throw new Error("t-if cannot stay at the same level as t-foreach when using t-elif or t-else");if(["t-if","t-elif","t-else"].map(i).reduce((function(t,e){return t+e}))>1)throw new Error("Only one conditional branching directive is allowed per node");let t;for(;(t=n.previousSibling)!==o;){if(t.nodeValue.trim().length&&8!==t.nodeType)throw new Error("text is not allowed between branching directives");t.remove()}}}})(e=t),function(t){const e=[...t.querySelectorAll("[t-esc]")].filter((t=>t.tagName[0]===t.tagName[0].toUpperCase()||t.hasAttribute("t-component")));for(const t of e){if(t.childNodes.length)throw new Error("Cannot have t-esc on a component that already has content");const e=t.getAttribute("t-esc");t.removeAttribute("t-esc");const n=t.ownerDocument.createElement("t");null!=e&&n.setAttribute("t-esc",e),t.appendChild(n)}}(e);return ge(t,{inPreTag:!1,inSVG:!1})||{type:0,value:""}}function ge(t,e){return t instanceof Element?function(t,e){if(t.hasAttribute("t-debug"))return t.removeAttribute("t-debug"),{type:12,content:ge(t,e)};if(t.hasAttribute("t-log")){const n=t.getAttribute("t-log");return t.removeAttribute("t-log"),{type:13,expr:n,content:ge(t,e)}}return null}(t,e)||function(t,e){if(!t.hasAttribute("t-foreach"))return null;const n=t.outerHTML,o=t.getAttribute("t-foreach");t.removeAttribute("t-foreach");const r=t.getAttribute("t-as")||"";t.removeAttribute("t-as");const i=t.getAttribute("t-key");if(!i)throw new Error(`"Directive t-foreach should always be used with a t-key!" (expression: t-foreach="${o}" t-as="${r}")`);t.removeAttribute("t-key");const s=t.getAttribute("t-memo")||"";t.removeAttribute("t-memo");const l=ge(t,e);if(!l)return null;const a=!n.includes("t-call"),c=a&&!n.includes(r+"_first"),h=a&&!n.includes(r+"_last"),u=a&&!n.includes(r+"_index"),d=a&&!n.includes(r+"_value");return{type:9,collection:o,elem:r,body:l,memo:s,key:i,hasNoFirst:c,hasNoLast:h,hasNoIndex:u,hasNoValue:d}}(t,e)||function(t,e){if(!t.hasAttribute("t-if"))return null;const n=t.getAttribute("t-if");t.removeAttribute("t-if");const o=ge(t,e)||{type:0,value:""};let r=t.nextElementSibling;const i=[];for(;r&&r.hasAttribute("t-elif");){const t=r.getAttribute("t-elif");r.removeAttribute("t-elif");const n=ge(r,e),o=r.nextElementSibling;r.remove(),r=o,n&&i.push({condition:t,content:n})}let s=null;r&&r.hasAttribute("t-else")&&(r.removeAttribute("t-else"),s=ge(r,e),r.remove());return{type:5,condition:n,content:o,tElif:i.length?i:null,tElse:s}}(t,e)||function(t,e){if(!t.hasAttribute("t-portal"))return null;const n=t.getAttribute("t-portal");t.removeAttribute("t-portal");const o=ge(t,e);if(!o)return{type:0,value:""};return{type:17,target:n,content:o}}(t,e)||function(t,e){if(!t.hasAttribute("t-call"))return null;const n=t.getAttribute("t-call");if(t.removeAttribute("t-call"),"t"!==t.tagName){const o=ge(t,e),r={type:7,name:n,body:null};if(o&&2===o.type)return o.content=[r],o;if(o&&11===o.type)return{...o,slots:{default:{content:r}}}}const o=$e(t,e);return{type:7,name:n,body:o.length?o:null}}(t,e)||function(t,e){if(!t.hasAttribute("t-call-block"))return null;return{type:15,name:t.getAttribute("t-call-block")}}(t)||function(t,e){if(!t.hasAttribute("t-esc"))return null;const n=t.getAttribute("t-esc");t.removeAttribute("t-esc");const o={type:4,expr:n,defaultValue:t.textContent||""};let r=t.getAttribute("t-ref");t.removeAttribute("t-ref");const i=ge(t,e);if(!i)return o;if(2===i.type)return{...i,ref:r,content:[o]};if(11===i.type)throw new Error("t-esc is not supported on Component nodes");return o}(t,e)||function(t,e){if(!t.hasAttribute("t-key"))return null;const n=t.getAttribute("t-key");t.removeAttribute("t-key");const o=ge(t,e);if(!o)return null;return{type:10,expr:n,content:o}}(t,e)||function(t,e){if("off"!==t.getAttribute("t-translation"))return null;return t.removeAttribute("t-translation"),{type:16,content:ge(t,e)}}(t,e)||function(t,e){if(!t.hasAttribute("t-slot"))return null;const n=t.getAttribute("t-slot");t.removeAttribute("t-slot");const o={};for(let e of t.getAttributeNames()){const n=t.getAttribute(e);o[e]=n}return{type:14,name:n,attrs:o,defaultContent:Ne(t,e)}}(t,e)||function(t,e){if(!t.hasAttribute("t-out")&&!t.hasAttribute("t-raw"))return null;t.hasAttribute("t-raw")&&console.warn('t-raw has been deprecated in favor of t-out. If the value to render is not wrapped by the "markup" function, it will be escaped');const n=t.getAttribute("t-out")||t.getAttribute("t-raw");t.removeAttribute("t-out"),t.removeAttribute("t-raw");const o={type:8,expr:n,body:null},r=t.getAttribute("t-ref");t.removeAttribute("t-ref");const i=ge(t,e);if(!i)return o;if(2===i.type)return o.body=i.content.length?i.content:null,{...i,ref:r,content:[o]};return o}(t,e)||function(t,e){let n=t.tagName;const o=n[0];let r=t.hasAttribute("t-component");if(r&&"t"!==n)throw new Error(`Directive 't-component' can only be used on <t> nodes (used on a <${n}>)`);if(o!==o.toUpperCase()&&!r)return null;r&&(n=t.getAttribute("t-component"),t.removeAttribute("t-component"));const i=t.getAttribute("t-props");t.removeAttribute("t-props");const s=t.getAttribute("t-slot-scope");t.removeAttribute("t-slot-scope");const l={};for(let e of t.getAttributeNames()){const n=t.getAttribute(e);if(e.startsWith("t-")){const t=ke.get(e.split("-").slice(0,2).join("-"));throw new Error(t||"unsupported directive on Component: "+e)}l[e]=n}const a={};if(t.hasChildNodes()){const n=t.cloneNode(!0),o=Array.from(n.querySelectorAll("[t-set-slot]"));for(let t of o){if("t"!==t.tagName)throw new Error(`Directive 't-set-slot' can only be used on <t> nodes (used on a <${t.tagName}>)`);const o=t.getAttribute("t-set-slot");let r=t.parentElement,i=!1;for(;r!==n;){if(r.hasAttribute("t-component")||r.tagName[0]===r.tagName[0].toUpperCase()){i=!0;break}r=r.parentElement}if(i)continue;t.removeAttribute("t-set-slot"),t.remove();const s=ge(t,e);if(s){const e={content:s},n={};for(let o of t.getAttributeNames()){const r=t.getAttribute(o);"t-slot-scope"!==o?n[o]=r:e.scope=r}Object.keys(n).length&&(e.attrs=n),a[o]=e}}const r=Ne(n,e);r&&(a.default={content:r},s&&(a.default.scope=s))}return{type:11,name:n,isDynamic:r,dynamicProps:i,props:l,slots:a}}(t,e)||function(t,e){const{tagName:n}=t,o=t.getAttribute("t-tag");if(t.removeAttribute("t-tag"),"t"===n&&!o)return null;e=Object.assign({},e),"pre"===n&&(e.inPreTag=!0);const r=xe.has(n)&&!e.inSVG;e.inSVG=e.inSVG||r;const i=r?"http://www.w3.org/2000/svg":null,s=t.getAttribute("t-ref");t.removeAttribute("t-ref");const l=t.getAttributeNames(),a={},c={};let h=null;for(let o of l){const r=t.getAttribute(o);if(o.startsWith("t-on")){if("t-on"===o)throw new Error("Missing event name with t-on directive");c[o.slice(5)]=r}else if(o.startsWith("t-model")){if(!["input","select","textarea"].includes(n))throw new Error("The t-model directive only works with <input>, <textarea> and <select>");let i,s;if(ye.test(r)){const t=r.lastIndexOf(".");i=r.slice(0,t),s=`'${r.slice(t+1)}'`}else{if(!we.test(r))throw new Error(`Invalid t-model expression: "${r}" (it should be assignable)`);{const t=r.lastIndexOf("[");i=r.slice(0,t),s=r.slice(t+1,-1)}}const l=t.getAttribute("type"),a="input"===n,c="select"===n,u="textarea"===n,d=a&&"checkbox"===l,f=a&&"radio"===l,p=a&&!d&&!f,m=o.includes(".lazy"),g=o.includes(".number");h={baseExpr:i,expr:s,targetAttr:d?"checked":"value",specialInitTargetAttr:f?"checked":null,eventType:f?"click":c||m?"change":"input",shouldTrim:o.includes(".trim")&&(p||u),shouldNumberize:g&&(p||u)},c&&((e=Object.assign({},e)).tModelInfo=h)}else if("t-name"!==o){if(o.startsWith("t-")&&!o.startsWith("t-att"))throw new Error(`Unknown QWeb directive: '${o}'`);const t=e.tModelInfo;t&&["t-att-value","t-attf-value"].includes(o)&&(t.hasDynamicChildren=!0),a[o]=r}}const u=$e(t,e);return{type:2,tag:n,dynamicTag:o,attrs:a,on:c,ref:s,content:u,model:h,ns:i}}(t,e)||function(t,e){if(!t.hasAttribute("t-set"))return null;const n=t.getAttribute("t-set"),o=t.getAttribute("t-value")||null,r=t.innerHTML===t.textContent&&t.textContent||null;let i=null;t.textContent!==t.innerHTML&&(i=$e(t,e));return{type:6,name:n,value:o,defaultValue:r,body:i}}(t,e)||function(t,e){if("t"!==t.tagName)return null;return Ne(t,e)}(t,e):function(t,e){if(t.nodeType===Node.TEXT_NODE){let n=t.textContent||"";if(!e.inPreTag){if(be.test(n)&&!n.trim())return null;n=n.replace(ve," ")}return{type:0,value:n}}if(t.nodeType===Node.COMMENT_NODE)return{type:1,value:t.textContent||""};return null}(t,e)}const be=/[\r\n]/,ve=/\s+/g;const ye=/\.[\w_]+\s*$/,we=/\[[^\[]+\]\s*$/,xe=new Set(["svg","g","path"]);const ke=new Map([["t-on","t-on is no longer supported on components. Consider passing a callback in props."],["t-ref","t-ref is no longer supported on components. Consider exposing only the public part of the component's API through a callback prop."],["t-att","t-att makes no sense on component: props are already treated as expressions"],["t-attf","t-attf is not supported on components: use template strings for string interpolation in props"]]);function $e(t,e){const n=[];for(let o of t.childNodes){const t=ge(o,e);t&&(3===t.type?n.push(...t.content):n.push(t))}return n}function Ne(t,e){const n=$e(t,e);switch(n.length){case 0:return null;case 1:return n[0];default:return{type:3,content:n}}}const Ee={text:z,createBlock:tt,list:pt,multi:O,html:wt,toggler:r,component:function(t,e,n,o,r){let i=o.children[n],s="string"!=typeof t;i&&(i.status<1?(i.destroy(),i=void 0):2===i.status&&(i=void 0)),s&&i&&i.component.constructor!==t&&(i=void 0);const l=o.fiber;if(i)i.updateAndRender(e,l);else{let a;if(s)a=t;else if(a=r.constructor.components[t],!a)throw new Error(`Cannot find the definition of component "${t}"`);i=new Wt(a,e,o.app,o),o.children[n]=i;const c=It(i,l);i.initiateRender(c)}return i},comment:K},Ae={};function Te(...t){const e="__template__"+Te.nextId++,n=String.raw(...t);return Ae[e]=n,e}Te.nextId=1;class _e{constructor(t,e,n){this.props=t,this.env=e,this.__owl__=n}setup(){}render(){this.__owl__.render()}}_e.template="";const Le=z("").constructor;class Ce extends Le{constructor(t,e){super(""),this.target=null,this.selector=t,this.realBDom=e}mount(t,e){if(super.mount(t,e),this.target=document.querySelector(this.selector),!this.target){let t=this.el;for(;t&&t.parentElement instanceof HTMLElement;)t=t.parentElement;if(this.target=t&&t.querySelector(this.selector),!this.target)throw new Error("invalid portal target")}this.realBDom.mount(this.target,null)}beforeRemove(){this.realBDom.beforeRemove()}remove(){this.realBDom&&(super.remove(),this.realBDom.remove(),this.realBDom=null)}patch(t){super.patch(t),this.realBDom?this.realBDom.patch(t.realBDom,!0):(this.realBDom=t.realBDom,this.realBDom.mount(this.target,null))}}class Se extends _e{setup(){const t=this.__owl__,e=t.renderFn;t.renderFn=()=>new Ce(this.props.target,e()),Ht((()=>{t.bdom&&t.bdom.remove()}))}}Se.template=Te`<t t-slot="default"/>`,Se.props={target:{type:String},slots:!0};class De{constructor(){this.tasks=new Set,this.isRunning=!1,this.requestAnimationFrame=De.requestAnimationFrame}start(){this.isRunning=!0,this.scheduleTasks()}stop(){this.isRunning=!1}addFiber(t){this.tasks.add(t.root),this.isRunning||this.start()}flush(){this.tasks.forEach((t=>{if(t.root!==t)return void this.tasks.delete(t);const e=St.has(t);e&&0!==t.counter?this.tasks.delete(t):2!==t.node.status?0===t.counter&&(e||t.complete(),this.tasks.delete(t)):this.tasks.delete(t)})),0===this.tasks.size&&this.stop()}scheduleTasks(){this.requestAnimationFrame((()=>{this.flush(),this.isRunning&&this.scheduleTasks()}))}}De.requestAnimationFrame=window.requestAnimationFrame.bind(window);class Be extends class{constructor(t={}){this.rawTemplates=Object.create(Ae),this.templates={},this.utils=Object.assign({},Ct,{call:(t,e,n,o,i)=>r(e,this.getTemplate(e).call(t,n,o,i)),getTemplate:t=>this.getTemplate(t)}),this.dev=t.dev||!1,this.translateFn=t.translateFn,this.translatableAttributes=t.translatableAttributes,t.templates&&this.addTemplates(t.templates)}addTemplate(t,e,n={}){if(t in this.rawTemplates&&!n.allowDuplicate)throw new Error(`Template ${t} already defined`);this.rawTemplates[t]=e}addTemplates(t,e={}){if(t){t=t instanceof Document?t:function(t){const e=(new DOMParser).parseFromString(t,"text/xml");if(e.getElementsByTagName("parsererror").length){let n="Invalid XML in template.";const o=e.getElementsByTagName("parsererror")[0].textContent;if(o){n+="\nThe parser has produced the following error message:\n"+o;const e=/\d+/g,r=e.exec(o);if(r){const i=Number(r[0]),s=t.split("\n")[i-1],l=e.exec(o);if(s&&l){const t=Number(l[0])-1;s[t]&&(n+=`\nThe error might be located at xml line ${i} column ${t}\n${s}\n${"-".repeat(t-1)}^`)}}}throw new Error(n)}return e}(t);for(const n of t.querySelectorAll("[t-name]")){const t=n.getAttribute("t-name");this.addTemplate(t,n,e)}}}getTemplate(t){if(!(t in this.templates)){const e=this.rawTemplates[t];if(void 0===e)throw new Error(`Missing template: "${t}"`);const n=this._compileTemplate(t,e),o=this.templates;this.templates[t]=function(e,n){return o[t].call(this,e,n)};const r=n(Ee,this.utils);this.templates[t]=r}return this.templates[t]}_compileTemplate(t,e){return function(t,e={}){const n=pe(t),o=t instanceof Node?!(t instanceof Element)||null===t.querySelector("[t-set], [t-call]"):!t.includes("t-set")&&!t.includes("t-call"),r=new de(n,{...e,hasSafeContext:o}).generateCode();return new Function("bdom, helpers",r)}(e,{name:t,dev:this.dev,translateFn:this.translateFn,translatableAttributes:this.translatableAttributes})}}{constructor(t,e={}){super(e),this.scheduler=new De,this.root=null,this.Root=t,e.test&&(this.dev=!0),this.dev&&!e.test&&console.info("Owl is running in 'dev' mode.\n\nThis is not suitable for production use.\nSee https://github.com/odoo/owl/blob/master/doc/reference/config.md#mode for more information.");const n=Object.getOwnPropertyDescriptors(e.env||{});this.env=Object.freeze(Object.defineProperties({},n)),this.props=e.props||{}}mount(t,e){Be.validateTarget(t);const n=this.makeNode(this.Root,this.props),o=this.mountNode(n,t,e);return this.root=n,o}makeNode(t,e){return new Wt(t,e,this)}mountNode(t,e,n){const o=new Promise(((e,n)=>{let o=!1;t.mounted.push((()=>{e(t.component),o=!0}));let r=Dt.get(t);r||(r=[],Dt.set(t,r)),r.unshift((t=>{throw o?console.error(t):n(t),t}))}));return t.mountComponent(e,n),o}destroy(){this.root&&this.root.destroy()}}Be.validateTarget=function(t){if(!(t instanceof HTMLElement))throw new Error("Cannot mount component: the target is not a valid DOM element");if(!document.body.contains(t))throw new Error("Cannot mount a component on a detached dom node")};class Oe extends _e{constructor(t,e,n){super(t,e,n);let o=!1;const r=n.patch;n.patch=()=>{o&&(r.call(n),o=!1)};let i=t;const s=n.updateAndRender;n.updateAndRender=function(t,e){return!function(t,e){for(let n in t)if("slots"!==n&&t[n]!==e[n])return!1;return!0}(i,t)&&(i=t,s.call(n,t,e),o=!0),Promise.resolve()}}}Oe.template=Te`<t t-slot="default"/>`;const Ie=Symbol("Target"),Re=Symbol("Skip"),Pe=Symbol("Key changes"),je=Object.prototype.toString;function Me(t){if("object"!=typeof t)return!1;const e=je.call(t).slice(8,-1);return"Object"===e||"Array"===e}const Fe=new WeakMap;function Ve(t,e,n){Fe.get(t)||Fe.set(t,new Map);const o=Fe.get(t);o.get(e)||o.set(e,new Set),o.get(e).add(n),ze.has(n)||ze.set(n,new Set),ze.get(n).add(t)}function We(t,e){const n=Fe.get(t);if(!n)return;const o=n.get(e);if(o)for(const t of[...o])Ke(t),t()}const ze=new WeakMap;function Ke(t){const e=ze.get(t);if(e){for(const n of e){const e=Fe.get(n);if(e)for(const n of e.values())n.delete(t)}e.clear()}}const He=new WeakMap;function Ue(t,e=(()=>{})){if(!Me(t))throw new Error("Cannot make the given value reactive");if(Re in t)return t;const n=t[Ie];if(n)return Ue(n,e);He.has(t)||He.set(t,new Map);const o=He.get(t);if(!o.has(e)){const n=new Proxy(t,{get(t,n,o){if(n===Ie)return t;Ve(t,n,e);const r=Reflect.get(t,n,o);return Me(r)?Ue(r,e):r},set(t,e,n,o){const r=!Object.hasOwnProperty.call(t,e),i=Reflect.get(t,e,o),s=Reflect.set(t,e,n,o);return r&&We(t,Pe),(i!==n||Array.isArray(t)&&"length"===e)&&We(t,e),s},deleteProperty(t,e){const n=Reflect.deleteProperty(t,e);return We(t,Pe),We(t,e),n},ownKeys:t=>(Ve(t,Pe,e),Reflect.ownKeys(t)),has:(t,n)=>(Ve(t,Pe,e),Reflect.has(t,n))});o.set(e,n)}return o.get(e)}const qe=new WeakMap;function Ge(t,e){const n=Object.create(t),o=Object.getOwnPropertyDescriptors(e);return Object.freeze(Object.defineProperties(n,o))}function Xe(t){const e=Vt();e.childEnv=Ge(e.childEnv,t)}const Ye=()=>{};n.shouldNormalizeDom=!1,n.mainEventHandler=(t,n,o)=>{const{data:r,modifiers:i}=e(t);t=r;let s=!1;if(i.length){let t=!1;const e=n.target===o;for(const o of i)switch(o){case"self":if(t=!0,e)continue;return s;case"prevent":(t&&e||!t)&&n.preventDefault();continue;case"stop":(t&&e||!t)&&n.stopPropagation(),s=!0;continue}}if(Object.hasOwnProperty.call(t,0)){const e=t[0];if("function"!=typeof e)throw new Error(`Invalid handler (expected a function, received: '${e}')`);let o=t[1]?t[1].__owl__:null;o&&1!==o.status||e.call(o?o.component:null,n)}return s},Ct.Portal=Se;const Ze={config:n,mount:xt,patch:function(t,e,n=!1){t.patch(e,n)},remove:function(t,e=!1){e&&t.beforeRemove(),t.remove()},list:pt,multi:O,text:z,toggler:r,createBlock:tt,html:wt,comment:K},Qe={};t.App=Be,t.Component=_e,t.EventBus=Nt,t.Memo=Oe,t.__info__=Qe,t.blockDom=Ze,t.loadFile=async function(t){const e=await fetch(t);if(!e.ok)throw new Error("Error while fetching xml templates");return await e.text()},t.markRaw=function(t){return t[Re]=!0,t},t.markup=function(t){return new Et(t)},t.mount=async function(t,e,n={}){return new Be(t,n).mount(e,n)},t.onError=function(t){const e=Vt();let n=Dt.get(e);n||(n=[],Dt.set(e,n)),n.push(t.bind(e.component))},t.onMounted=zt,t.onPatched=Kt,t.onRendered=function(t){const e=Vt(),n=e.renderFn;e.renderFn=()=>{const o=n();return t.call(e.component),o}},t.onWillDestroy=Ut,t.onWillPatch=function(t){const e=Vt();e.willPatch.unshift(t.bind(e.component))},t.onWillRender=function(t){const e=Vt(),n=e.renderFn;e.renderFn=()=>(t.call(e.component),n())},t.onWillStart=function(t){const e=Vt();e.willStart.push(t.bind(e.component))},t.onWillUnmount=Ht,t.onWillUpdateProps=function(t){const e=Vt();e.willUpdateProps.push(t.bind(e.component))},t.reactive=Ue,t.status=function(t){switch(t.__owl__.status){case 0:return"new";case 1:return"mounted";case 2:return"destroyed"}},t.toRaw=function(t){return t[Ie]},t.useChildSubEnv=Xe,t.useComponent=function(){return Ft.component},t.useEffect=function(t,e=(()=>[NaN])){let n,o;zt((()=>{o=e(),n=t(...o)||Ye})),Kt((()=>{const r=e();r.some(((t,e)=>t!==o[e]))&&(o=r,n(),n=t(...o)||Ye)})),Ht((()=>n()))},t.useEnv=function(){return Vt().component.env},t.useExternalListener=function(t,e,n,o){const r=Vt(),i=n.bind(r.component);zt((()=>t.addEventListener(e,i,o))),Ht((()=>t.removeEventListener(e,i,o)))},t.useRef=function(t){const e=Vt().refs;return{get el(){return e[t]||null}}},t.useState=function(t){const e=Vt();qe.has(e)||(qe.set(e,function(t){let e=!1;return async()=>{await Promise.resolve(),e||(e=!0,t(),await Promise.resolve(),e=!1)}}((()=>e.render()))),Ut((()=>Ke(n))));const n=qe.get(e);return Ue(t,n)},t.useSubEnv=function(t){const e=Vt();e.component.env=Ge(e.component.env,t),Xe(t)},t.whenReady=function(t){return new Promise((function(t){"loading"!==document.readyState?t(!0):document.addEventListener("DOMContentLoaded",t,!1)})).then(t||function(){})},t.xml=Te,Object.defineProperty(t,"__esModule",{value:!0}),Qe.version="2.0.0-alpha.2",Qe.date="2022-02-14T12:42:47.468Z",Qe.hash="4a922ed",Qe.url="https://github.com/odoo/owl"}(this.owl=this.owl||{});
1
+ !function(t){"use strict";function e(t){t=t.slice();const e=[];let n;for(;(n=t[0])&&"string"==typeof n;)e.push(t.shift());return{modifiers:e,data:t}}const n={shouldNormalizeDom:!0,mainEventHandler:(t,n,o)=>("function"==typeof t?t(n):Array.isArray(t)&&(t=e(t).data)[0](t[1],n),!1)};class o{constructor(t,e){this.key=t,this.child=e}mount(t,e){this.parentEl=t,this.child.mount(t,e)}moveBefore(t,e){this.child.moveBefore(t?t.child:null,e)}patch(t,e){if(this===t)return;let n=this.child,o=t.child;this.key===t.key?n.patch(o,e):(o.mount(this.parentEl,n.firstNode()),e&&n.beforeRemove(),n.remove(),this.child=o,this.key=t.key)}beforeRemove(){this.child.beforeRemove()}remove(){this.child.remove()}firstNode(){return this.child.firstNode()}toString(){return this.child.toString()}}function r(t,e){return new o(t,e)}const{setAttribute:i,removeAttribute:s}=Element.prototype,l=DOMTokenList.prototype,a=l.add,c=l.remove,h=Array.isArray,{split:u,trim:d}=String.prototype,f=/\s+/;function p(t,e){switch(e){case!1:case void 0:s.call(this,t);break;case!0:i.call(this,t,"");break;default:i.call(this,t,e)}}function m(t){return function(e){p.call(this,t,e)}}function g(t){if(h(t))p.call(this,t[0],t[1]);else for(let e in t)p.call(this,e,t[e])}function b(t,e){if(h(t)){const n=t[0],o=t[1];if(n===e[0]){if(o===e[1])return;p.call(this,n,o)}else s.call(this,e[0]),p.call(this,n,o)}else{for(let n in e)n in t||s.call(this,n);for(let n in t){const o=t[n];o!==e[n]&&p.call(this,n,o)}}}function v(t){const e={};switch(typeof t){case"string":const n=d.call(t);if(!n)return{};let o=u.call(n,f);for(let t=0,n=o.length;t<n;t++)e[o[t]]=!0;return e;case"object":for(let n in t){const o=t[n];if(o){const t=u.call(n,f);for(let n of t)e[n]=o}}return e;case"undefined":return{};case"number":return{[t]:!0};default:return{[t]:!0}}}function y(t){t=""===t?{}:v(t);const e=this.classList;for(let n in t)a.call(e,n)}function w(t,e){e=""===e?{}:v(e),t=""===t?{}:v(t);const n=this.classList;for(let o in e)o in t||c.call(n,o);for(let o in t)o in e||a.call(n,o)}function x(t){return function(e){this[t]=0===e?0:e||""}}function k(t,e){switch(t){case"input":return"checked"===e||"indeterminate"===e||"value"===e||"readonly"===e||"disabled"===e;case"option":return"selected"===e||"disabled"===e;case"textarea":return"value"===e||"readonly"===e||"disabled"===e;case"select":return"value"===e||"disabled"===e;case"button":case"optgroup":return"disabled"===e}return!1}function $(t){const e=t.split(".")[0],o=t.includes(".capture");return t.includes(".synthetic")?function(t,e=!1){let o="__event__synthetic_"+t;e&&(o+="_capture");!function(t,e,o=!1){if(A[e])return;document.addEventListener(t,(t=>function(t,e){let o=e.target;for(;null!==o;){const r=o[t];if(r)for(const t of Object.values(r)){if(n.mainEventHandler(t,e,o))return}o=o.parentNode}}(e,t)),{capture:o}),A[e]=!0}(t,o,e);const r=E++;function i(t){const e=this[o]||{};e[r]=t,this[o]=e}function s(){delete this[o]}return{setup:i,update:i,remove:s}}(e,o):function(t,e=!1){let o=`__event__${t}_${N++}`;e&&(o+="_capture");function r(t){const e=t.currentTarget;if(!e||!document.contains(e))return;const r=e[o];r&&n.mainEventHandler(r,t,e)}function i(n){this[o]=n,this.addEventListener(t,r,{capture:e})}function s(){delete this[o],this.removeEventListener(t,r,{capture:e})}function l(t){this[o]=t}return{setup:i,update:l,remove:s}}(e,o)}let N=1;let E=1;const A={};const T=Node.prototype,_=T.insertBefore,S=(C=T,L="textContent",Object.getOwnPropertyDescriptor(C,L)).set;var C,L;const D=T.removeChild;class O{constructor(t){this.children=t}mount(t,e){const n=this.children,o=n.length,r=new Array(o);for(let i=0;i<o;i++){let o=n[i];if(o)o.mount(t,e);else{const n=document.createTextNode("");r[i]=n,_.call(t,n,e)}}this.anchors=r,this.parentEl=t}moveBefore(t,e){if(t){const n=t.children[0];e=(n?n.firstNode():t.anchors[0])||null}const n=this.children,o=this.parentEl,r=this.anchors;for(let t=0,i=n.length;t<i;t++){let i=n[t];if(i)i.moveBefore(null,e);else{const n=r[t];_.call(o,n,e)}}}patch(t,e){if(this===t)return;const n=this.children,o=t.children,r=this.anchors,i=this.parentEl;for(let t=0,s=n.length;t<s;t++){const s=n[t],l=o[t];if(s)if(l)s.patch(l,e);else{const o=s.firstNode(),l=document.createTextNode("");r[t]=l,_.call(i,l,o),e&&s.beforeRemove(),s.remove(),n[t]=void 0}else if(l){n[t]=l;const e=r[t];l.mount(i,e),D.call(i,e)}}}beforeRemove(){const t=this.children;for(let e=0,n=t.length;e<n;e++){const n=t[e];n&&n.beforeRemove()}}remove(){const t=this.parentEl;if(this.isOnlyChild)S.call(t,"");else{const e=this.children,n=this.anchors;for(let o=0,r=e.length;o<r;o++){const r=e[o];r?r.remove():D.call(t,n[o])}}}firstNode(){const t=this.children[0];return t?t.firstNode():this.anchors[0]}toString(){return this.children.map((t=>t?t.toString():"")).join("")}}function B(t){return new O(t)}const R=Node.prototype,I=CharacterData.prototype,P=R.insertBefore,M=((t,e)=>Object.getOwnPropertyDescriptor(t,e))(I,"data").set,j=R.removeChild;class W{constructor(t){this.text=t}mountNode(t,e,n){this.parentEl=e,P.call(e,t,n),this.el=t}moveBefore(t,e){const n=t?t.el:e;P.call(this.parentEl,this.el,n)}beforeRemove(){}remove(){j.call(this.parentEl,this.el)}firstNode(){return this.el}toString(){return this.text}}class F extends W{mount(t,e){this.mountNode(document.createTextNode(H(this.text)),t,e)}patch(t){const e=t.text;this.text!==e&&(M.call(this.el,H(e)),this.text=e)}}class V extends W{mount(t,e){this.mountNode(document.createComment(H(this.text)),t,e)}patch(){}}function z(t){return new F(t)}function K(t){return new V(t)}function H(t){switch(typeof t){case"string":return t;case"number":return String(t);case"boolean":return t?"true":"false";default:return t||""}}const U=(t,e)=>Object.getOwnPropertyDescriptor(t,e),q=Node.prototype,G=Element.prototype,X=U(CharacterData.prototype,"data").set,Y=U(q,"firstChild").get,Z=U(q,"nextSibling").get,J=()=>{},Q={};function tt(t){if(t in Q)return Q[t];const e=(new DOMParser).parseFromString(`<t>${t}</t>`,"text/xml").firstChild.firstChild;n.shouldNormalizeDom&&et(e);const o=nt(e),r=it(o),i=function(t,e){let n=function(t,e){const{refN:n,collectors:o,children:r}=e,i=o.length;e.locations.sort(((t,e)=>t.idx-e.idx));const s=e.locations.map((t=>({refIdx:t.refIdx,setData:t.setData,updateData:t.updateData}))),l=s.length,a=r.length,c=r,h=n>0,u=q.cloneNode,d=q.insertBefore,f=G.remove;class p{constructor(t){this.data=t}beforeRemove(){}remove(){f.call(this.el)}firstNode(){return this.el}moveBefore(t,e){const n=t?t.el:e;d.call(this.parentEl,this.el,n)}toString(){const t=document.createElement("div");return this.mount(t,null),t.innerHTML}mount(e,n){const o=u.call(t,!0);d.call(e,o,n),this.el=o,this.parentEl=e}patch(t,e){}}h&&(p.prototype.mount=function(e,r){const h=u.call(t,!0),f=new Array(n);this.refs=f,f[0]=h;for(let t=0;t<i;t++){const e=o[t];f[e.idx]=e.getVal.call(f[e.prevIdx])}if(l){const t=this.data;for(let e=0;e<l;e++){const n=s[e];n.setData.call(f[n.refIdx],t[e])}}if(d.call(e,h,r),a){const t=this.children;for(let e=0;e<a;e++){const n=t[e];if(n){const t=c[e],o=t.afterRefIdx?f[t.afterRefIdx]:null;n.isOnlyChild=t.isOnlyChild,n.mount(f[t.parentRefIdx],o)}}}this.el=h,this.parentEl=e},p.prototype.patch=function(t,e){if(this===t)return;const n=this.refs;if(l){const e=this.data,o=t.data;for(let t=0;t<l;t++){const r=e[t],i=o[t];if(r!==i){const e=s[t];e.updateData.call(n[e.refIdx],i,r)}}this.data=o}if(a){let o=this.children;const r=t.children;for(let t=0;t<a;t++){const i=o[t],s=r[t];if(i)s?i.patch(s,e):(e&&i.beforeRemove(),i.remove(),o[t]=void 0);else if(s){const e=c[t],r=e.afterRefIdx?n[e.afterRefIdx]:null;s.mount(n[e.parentRefIdx],r),o[t]=s}}}});return p}(t,e);if(e.cbRefs.length){const t=e.cbRefs,o=e.refList;let r=t.length;n=class extends n{mount(t,e){o.push(new Array(r)),super.mount(t,e);for(let t of o.pop())t()}remove(){super.remove();for(let e of t){(0,this.data[e])(null)}}}}if(e.children.length)return n=class extends n{constructor(t,e){super(t),this.children=e}},n.prototype.beforeRemove=O.prototype.beforeRemove,(t,e=[])=>new n(t,e);return t=>new n(t)}(o.el,r);return Q[t]=i,i}function et(t){if(t.nodeType!==Node.TEXT_NODE||/\S/.test(t.textContent)){if(t.nodeType!==Node.ELEMENT_NODE||"pre"!==t.tagName)for(let e=t.childNodes.length-1;e>=0;--e)et(t.childNodes.item(e))}else t.remove()}function nt(t,e=null,n=null){switch(t.nodeType){case Node.ELEMENT_NODE:{let o=n&&n.currentNS;const r=t.tagName;let i=void 0;const s=[];if(r.startsWith("block-text-")){const t=parseInt(r.slice(11),10);s.push({type:"text",idx:t}),i=document.createTextNode("")}if(r.startsWith("block-child-")){n.isRef||ot(n);const t=parseInt(r.slice(12),10);s.push({type:"child",idx:t}),i=document.createTextNode("")}const l=t.attributes,a=l.getNamedItem("block-ns");if(a&&(l.removeNamedItem("block-ns"),o=a.value),i||(i=o?document.createElementNS(o,r):document.createElement(r)),i instanceof Element)for(let t=0;t<l.length;t++){const e=l[t].name,n=l[t].value;if(e.startsWith("block-handler-")){const t=parseInt(e.slice(14),10);s.push({type:"handler",idx:t,event:n})}else if(e.startsWith("block-attribute-")){const t=parseInt(e.slice(16),10);s.push({type:"attribute",idx:t,name:n,tag:r})}else"block-attributes"===e?s.push({type:"attributes",idx:parseInt(n,10)}):"block-ref"===e?s.push({type:"ref",idx:parseInt(n,10)}):i.setAttribute(l[t].name,n)}const c={parent:e,firstChild:null,nextSibling:null,el:i,info:s,refN:0,currentNS:o};if(t.firstChild){const e=t.childNodes[0];if(1===t.childNodes.length&&e.nodeType===Node.ELEMENT_NODE&&e.tagName.startsWith("block-child-")){const t=e.tagName,n=parseInt(t.slice(12),10);s.push({idx:n,type:"child",isOnlyChild:!0})}else{c.firstChild=nt(t.firstChild,c,c),i.appendChild(c.firstChild.el);let e=t.firstChild,n=c.firstChild;for(;e=e.nextSibling;)n.nextSibling=nt(e,n,c),i.appendChild(n.nextSibling.el),n=n.nextSibling}}return c.info.length&&ot(c),c}case Node.TEXT_NODE:case Node.COMMENT_NODE:return{parent:e,firstChild:null,nextSibling:null,el:t.nodeType===Node.TEXT_NODE?document.createTextNode(t.textContent):document.createComment(t.textContent),info:[],refN:0,currentNS:null}}throw new Error("boom")}function ot(t){t.isRef=!0;do{t.refN++}while(t=t.parent)}function rt(t){let e=t.parent;for(;e&&e.nextSibling===t;)t=e,e=e.parent;return e}function it(t,e,n){if(!e){e={collectors:[],locations:[],children:new Array(t.info.filter((t=>"child"===t.type)).length),cbRefs:[],refN:t.refN,refList:[]},n=0}if(t.refN){const o=n,r=t.isRef,i=t.firstChild?t.firstChild.refN:0,s=t.nextSibling?t.nextSibling.refN:0;if(r){for(let e of t.info)e.refIdx=o;t.refIdx=o,function(t,e){for(let n of e.info)switch(n.type){case"text":t.locations.push({idx:n.idx,refIdx:n.refIdx,setData:st,updateData:st});break;case"child":n.isOnlyChild?t.children[n.idx]={parentRefIdx:n.refIdx,isOnlyChild:!0}:t.children[n.idx]={parentRefIdx:rt(e).refIdx,afterRefIdx:n.refIdx};break;case"attribute":{const e=n.refIdx;let o,r;if(k(n.tag,n.name)){const t=x(n.name);r=t,o=t}else"class"===n.name?(r=y,o=w):(r=m(n.name),o=r);t.locations.push({idx:n.idx,refIdx:e,setData:r,updateData:o});break}case"attributes":t.locations.push({idx:n.idx,refIdx:n.refIdx,setData:g,updateData:b});break;case"handler":{const{setup:e,update:o}=$(n.event);t.locations.push({idx:n.idx,refIdx:n.refIdx,setData:e,updateData:o});break}case"ref":const o=t.cbRefs.push(n.idx)-1;t.locations.push({idx:n.idx,refIdx:n.refIdx,setData:lt(o,t.refList),updateData:J})}}(e,t),n++}if(s){const r=n+i;e.collectors.push({idx:r,prevIdx:o,getVal:Z}),it(t.nextSibling,e,r)}i&&(e.collectors.push({idx:n,prevIdx:o,getVal:Y}),it(t.firstChild,e,n))}return e}function st(t){X.call(this,H(t))}function lt(t,e){return function(n){e[e.length-1][t]=()=>n(this)}}const at=Node.prototype,ct=at.insertBefore,ht=at.appendChild,ut=at.removeChild,dt=((t,e)=>Object.getOwnPropertyDescriptor(t,e))(at,"textContent").set;class ft{constructor(t){this.children=t}mount(t,e){const n=this.children,o=document.createTextNode("");this.anchor=o,ct.call(t,o,e);const r=n.length;if(r){const e=n[0].mount;for(let i=0;i<r;i++)e.call(n[i],t,o)}this.parentEl=t}moveBefore(t,e){if(t){const n=t.children[0];e=(n?n.firstNode():t.anchor)||null}const n=this.children;for(let t=0,o=n.length;t<o;t++)n[t].moveBefore(null,e);this.parentEl.insertBefore(this.anchor,e)}patch(t,e){if(this===t)return;const n=this.children,o=t.children;if(0===o.length&&0===n.length)return;this.children=o;const r=o[0]||n[0],{mount:i,patch:s,remove:l,beforeRemove:a,moveBefore:c,firstNode:h}=r,u=this.anchor,d=this.isOnlyChild,f=this.parentEl;if(0===o.length&&d){if(e)for(let t=0,e=n.length;t<e;t++)a.call(n[t]);return dt.call(f,""),void ht.call(f,u)}let p=0,m=0,g=n[0],b=o[0],v=n.length-1,y=o.length-1,w=n[v],x=o[y],k=void 0;for(;p<=v&&m<=y;){if(null===g){g=n[++p];continue}if(null===w){w=n[--v];continue}let t=g.key,r=b.key;if(t===r){s.call(g,b,e),o[m]=g,g=n[++p],b=o[++m];continue}let l=w.key,a=x.key;if(l===a){s.call(w,x,e),o[y]=w,w=n[--v],x=o[--y];continue}if(t===a){s.call(g,x,e),o[y]=g;const t=o[y+1];c.call(g,t,u),g=n[++p],x=o[--y];continue}if(l===r){s.call(w,b,e),o[m]=w;const t=n[p];c.call(w,t,u),w=n[--v],b=o[++m];continue}k=k||mt(n,p,v);let d=k[r];if(void 0===d)i.call(b,f,h.call(g)||null);else{const t=n[d];c.call(t,g,null),s.call(t,b,e),o[m]=t,n[d]=null}b=o[++m]}if(p<=v||m<=y)if(p>v){const t=o[y+1],e=t?h.call(t)||null:u;for(let t=m;t<=y;t++)i.call(o[t],f,e)}else for(let t=p;t<=v;t++){let o=n[t];o&&(e&&a.call(o),l.call(o))}}beforeRemove(){const t=this.children,e=t.length;if(e){const n=t[0].beforeRemove;for(let o=0;o<e;o++)n.call(t[o])}}remove(){const{parentEl:t,anchor:e}=this;if(this.isOnlyChild)dt.call(t,"");else{const n=this.children,o=n.length;if(o){const t=n[0].remove;for(let e=0;e<o;e++)t.call(n[e])}ut.call(t,e)}}firstNode(){const t=this.children[0];return t?t.firstNode():void 0}toString(){return this.children.map((t=>t.toString())).join("")}}function pt(t){return new ft(t)}function mt(t,e,n){let o={};for(let r=e;r<=n;r++)o[t[r].key]=r;return o}const gt=Node.prototype,bt=gt.insertBefore,vt=gt.removeChild;class yt{constructor(t){this.content=[],this.html=t}mount(t,e){this.parentEl=t;const n=document.createElement("template");n.innerHTML=this.html,this.content=[...n.content.childNodes];for(let n of this.content)bt.call(t,n,e);if(!this.content.length){const n=document.createTextNode("");this.content.push(n),bt.call(t,n,e)}}moveBefore(t,e){const n=t?t.content[0]:e,o=this.parentEl;for(let t of this.content)bt.call(o,t,n)}patch(t){if(this===t)return;const e=t.html;if(this.html!==e){const n=this.parentEl,o=this.content[0],r=document.createElement("template");r.innerHTML=e;const i=[...r.content.childNodes];for(let t of i)bt.call(n,t,o);if(!i.length){const t=document.createTextNode("");i.push(t),bt.call(n,t,o)}this.remove(),this.content=i,this.html=t.html}}beforeRemove(){}remove(){const t=this.parentEl;for(let e of this.content)vt.call(t,e)}firstNode(){return this.content[0]}toString(){return this.html}}function wt(t){return new yt(t)}function xt(t,e,n=null){t.mount(e,n)}const kt=Symbol("Target"),$t=Symbol("Skip"),Nt=Symbol("Key changes"),Et=Object.prototype.toString,At=Object.prototype.hasOwnProperty,Tt=new Set(["Object","Array","Set","Map","WeakMap"]),_t=new Set(["Set","Map","WeakMap"]);function St(t){return Et.call(t).slice(8,-1)}function Ct(t){return"object"==typeof t&&Tt.has(St(t))}function Lt(t,e){return Ct(t)?Wt(t,e):t}function Dt(t){return t[$t]=!0,t}function Ot(t){return t[kt]||t}const Bt=new WeakMap;function Rt(t,e,n){Bt.get(t)||Bt.set(t,new Map);const o=Bt.get(t);o.get(e)||o.set(e,new Set),o.get(e).add(n),Pt.has(n)||Pt.set(n,new Set),Pt.get(n).add(t)}function It(t,e){const n=Bt.get(t);if(!n)return;const o=n.get(e);if(o)for(const t of[...o])Mt(t),t()}const Pt=new WeakMap;function Mt(t){const e=Pt.get(t);if(e){for(const n of e){const e=Bt.get(n);if(e)for(const n of e.values())n.delete(t)}e.clear()}}const jt=new WeakMap;function Wt(t,e=(()=>{})){if(!Ct(t))throw new Error("Cannot make the given value reactive");if($t in t)return t;const n=t[kt];if(n)return Wt(n,e);jt.has(t)||jt.set(t,new Map);const o=jt.get(t);if(!o.has(e)){const n=St(t),r=_t.has(n)?function(t,e,n){const o=qt[n](t,e);return Object.assign(Ft(e),{get:(t,n)=>n===kt?t:At.call(o,n)?o[n]:(Rt(t,n,e),Lt(t[n],e))})}(t,e,n):Ft(e),i=new Proxy(t,r);o.set(e,i)}return o.get(e)}function Ft(t){return{get(e,n,o){if(n===kt)return e;const r=Object.getOwnPropertyDescriptor(e,n);return!r||r.writable||r.configurable?(Rt(e,n,t),Lt(Reflect.get(e,n,o),t)):Reflect.get(e,n,o)},set(t,e,n,o){const r=!At.call(t,e),i=Reflect.get(t,e,o),s=Reflect.set(t,e,n,o);return r&&It(t,Nt),(i!==n||Array.isArray(t)&&"length"===e)&&It(t,e),s},deleteProperty(t,e){const n=Reflect.deleteProperty(t,e);return It(t,Nt),It(t,e),n},ownKeys:e=>(Rt(e,Nt,t),Reflect.ownKeys(e)),has:(e,n)=>(Rt(e,Nt,t),Reflect.has(e,n))}}function Vt(t,e,n){return o=>(o=Ot(o),Rt(e,o,n),Lt(e[t](o),n))}function zt(t,e,n){return function*(){Rt(e,Nt,n);const o=e.keys();for(const r of e[t]()){const t=o.next().value;Rt(e,t,n),yield Lt(r,n)}}}function Kt(t,e){return function(n,o){Rt(t,Nt,e),t.forEach((function(r,i,s){Rt(t,i,e),n.call(o,Lt(r,e),Lt(i,e),Lt(s,e))}),o)}}function Ht(t,e,n){return(o,r)=>{o=Ot(o);const i=n.has(o),s=n[e](o),l=n[t](o,r);return i!==n.has(o)&&It(n,Nt),s!==r&&It(n,o),l}}function Ut(t){return()=>{const e=[...t.keys()];t.clear(),It(t,Nt);for(const n of e)It(t,n)}}const qt={Set:(t,e)=>({has:Vt("has",t,e),add:Ht("add","has",t),delete:Ht("delete","has",t),keys:zt("keys",t,e),values:zt("values",t,e),entries:zt("entries",t,e),[Symbol.iterator]:zt(Symbol.iterator,t,e),forEach:Kt(t,e),clear:Ut(t),get size(){return Rt(t,Nt,e),t.size}}),Map:(t,e)=>({has:Vt("has",t,e),get:Vt("get",t,e),set:Ht("set","get",t),delete:Ht("delete","has",t),keys:zt("keys",t,e),values:zt("values",t,e),entries:zt("entries",t,e),[Symbol.iterator]:zt(Symbol.iterator,t,e),forEach:Kt(t,e),clear:Ut(t),get size(){return Rt(t,Nt,e),t.size}}),WeakMap:(t,e)=>({has:Vt("has",t,e),get:Vt("get",t,e),set:Ht("set","get",t),delete:Ht("delete","has",t)})};class Gt extends EventTarget{trigger(t,e){this.dispatchEvent(new CustomEvent(t,{detail:e}))}}class Xt extends String{}const Yt={};function Zt(...t){const e="__template__"+Zt.nextId++,n=String.raw(...t);return Yt[e]=n,e}Zt.nextId=1;const Jt=new WeakMap,Qt=new WeakMap;function te(t,e){if(!t)return!1;const n=t.fiber;n&&Jt.set(n,e);const o=Qt.get(t);if(o){let t=!1;for(let n=o.length-1;n>=0;n--)try{o[n](e),t=!0;break}catch(t){e=t}if(t)return!0}return te(t.parent,e)}function ee(t){const e=t.error,n="node"in t?t.node:t.fiber.node,o="fiber"in t?t.fiber:n.fiber;let r=o;do{r.node.fiber=r,r=r.parent}while(r);Jt.set(o.root,e);if(!te(n,e)){console.warn("[Owl] Unhandled error. Destroying the root component");try{n.app.destroy()}catch(t){console.error(t)}}}function ne(t){let e=0;for(let n of t){let t=n.node;0===t.status&&t.destroy(),t.fiber=null,n.bdom?t.forceNextRender=!0:e++,e+=ne(n.children)}return e}class oe{constructor(t,e){if(this.bdom=null,this.children=[],this.appliedToDom=!1,this.deep=!1,this.childrenMap={},this.node=t,this.parent=e,e){this.deep=e.deep;const t=e.root;t.setCounter(t.counter+1),this.root=t,e.children.push(this)}else this.root=this}render(){let t=this.root.node,e=t.app.scheduler,n=t.parent;for(;n;){if(n.fiber){let o=n.fiber.root;if(0!==o.counter||!(t.parentKey in n.fiber.childrenMap))return void e.delayedRenders.push(this);n=o.node}t=n,n=n.parent}this._render()}_render(){const t=this.node,e=this.root;if(e){try{this.bdom=!0,this.bdom=t.renderFn()}catch(e){ee({node:t,error:e})}e.setCounter(e.counter-1)}}}class re extends oe{constructor(){super(...arguments),this.counter=1,this.willPatch=[],this.patched=[],this.mounted=[],this.locked=!1}complete(){const t=this.node;this.locked=!0;let e=void 0;try{for(e of this.willPatch){let t=e.node;if(t.fiber===e){const e=t.component;for(let n of t.willPatch)n.call(e)}}e=void 0,t._patch(),this.locked=!1;let n=this.mounted;for(;e=n.pop();)if(e=e,e.appliedToDom)for(let t of e.node.mounted)t();let o=this.patched;for(;e=o.pop();)if(e=e,e.appliedToDom)for(let t of e.node.patched)t()}catch(t){this.locked=!1,ee({fiber:e||this,error:t})}}setCounter(t){this.counter=t,0===t&&this.node.app.scheduler.flush()}}class ie extends re{constructor(t,e,n={}){super(t,null),this.target=e,this.position=n.position||"last-child"}complete(){let t=this;try{const e=this.node;if(e.children=this.childrenMap,e.app.constructor.validateTarget(this.target),e.bdom)e.updateDom();else if(e.bdom=this.bdom,"last-child"===this.position||0===this.target.childNodes.length)xt(e.bdom,this.target);else{const t=this.target.childNodes[0];xt(e.bdom,this.target,t)}e.fiber=null,e.status=1,this.appliedToDom=!0;let n=this.mounted;for(;t=n.pop();)if(t.appliedToDom)for(let e of t.node.mounted)e()}catch(e){ee({fiber:t,error:e})}}}function se(t,e){const n=e.defaultProps;if(n)for(let e in n)void 0===t[e]&&(t[e]=n[e])}function le(t,e){if(!0===e)return!0;if("function"==typeof e)return"object"==typeof t?t instanceof e:typeof t===e.name.toLowerCase();if(e instanceof Array){let n=!1;for(let o=0,r=e.length;o<r;o++)n=n||le(t,e[o]);return n}if(e.optional&&void 0===t)return!0;let n=!e.type||le(t,e.type);if(e.validate&&(n=n&&e.validate(t)),e.type===Array&&e.element)for(let o=0,r=t.length;o<r;o++)n=n&&le(t[o],e.element);if(e.type===Object&&e.shape){const o=e.shape;for(let e in o)n=n&&le(t[e],o[e]);if(n)for(let e in t)if(!(e in o))throw new Error(`unknown prop '${e}'`)}return n}let ae=null;function ce(){if(!ae)throw new Error("No active component (a hook function should only be called in 'setup')");return ae}const he=new WeakMap;function ue(t){const e=ce();let n=he.get(e);return n||(n=function(t){let e=!1;return async()=>{await Promise.resolve(),e||(e=!0,Promise.resolve().then((()=>e=!1)),t())}}(e.render.bind(e)),he.set(e,n),e.willDestroy.push(Mt.bind(null,n))),Wt(t,n)}class de{constructor(t,e,n,o,r){this.fiber=null,this.bdom=null,this.status=0,this.forceNextRender=!1,this.children=Object.create(null),this.refs={},this.willStart=[],this.willUpdateProps=[],this.willUnmount=[],this.mounted=[],this.willPatch=[],this.patched=[],this.willDestroy=[],ae=this,this.app=n,this.parent=o,this.parentKey=r,this.level=o?o.level+1:0,se(e,t);const i=o&&o.childEnv||n.env;this.childEnv=i,e=ue(e),this.component=new t(e,i,this),this.renderFn=n.getTemplate(t.template).bind(this.component,this.component,this),this.component.setup(),ae=null}mountComponent(t,e){const n=new ie(this,t,e);this.app.scheduler.addFiber(n),this.initiateRender(n)}async initiateRender(t){this.fiber=t,this.mounted.length&&t.root.mounted.push(t);const e=this.component;try{await Promise.all(this.willStart.map((t=>t.call(e))))}catch(t){return void ee({node:this,error:t})}0===this.status&&this.fiber===t&&t.render()}async render(t=!1){let e=this.fiber;if(e&&(e.root.locked||!0===e.bdom)&&(await Promise.resolve(),e=this.fiber),e){if(!e.bdom&&!Jt.has(e))return void(t&&(e.deep=t));t=t||e.deep}else if(!this.bdom)return;const n=function(t){let e=t.fiber;if(e){let t=e.root;return t.locked=!0,t.setCounter(t.counter+1-ne(e.children)),t.locked=!1,e.children=[],e.childrenMap={},e.bdom=null,Jt.has(e)&&(Jt.delete(e),Jt.delete(t),e.appliedToDom=!1),e}const n=new re(t,null);return t.willPatch.length&&n.willPatch.push(n),t.patched.length&&n.patched.push(n),n}(this);n.deep=t,this.fiber=n,this.app.scheduler.addFiber(n),await Promise.resolve(),2!==this.status&&(this.fiber!==n||!e&&n.parent||n.render())}destroy(){let t=1===this.status;this._destroy(),t&&this.bdom.remove()}_destroy(){const t=this.component;if(1===this.status)for(let e of this.willUnmount)e.call(t);for(let t of Object.values(this.children))t._destroy();if(this.willDestroy.length)try{for(let e of this.willDestroy)e.call(t)}catch(t){ee({error:t,node:this})}this.status=2}async updateAndRender(t,e){const n=function(t,e){let n=t.fiber;return n&&(ne(n.children),n.root=null),new oe(t,e)}(this,e);this.fiber=n;const o=this.component;se(t,o.constructor),ae=this,t=ue(t),ae=null;const r=Promise.all(this.willUpdateProps.map((e=>e.call(o,t))));if(await r,n!==this.fiber)return;o.props=t,n.render();const i=e.root;this.willPatch.length&&i.willPatch.push(n),this.patched.length&&i.patched.push(n)}updateDom(){if(this.fiber)if(this.bdom===this.fiber.bdom)for(let t in this.children){this.children[t].updateDom()}else this.bdom.patch(this.fiber.bdom,!1),this.fiber.appliedToDom=!0,this.fiber=null}firstNode(){const t=this.bdom;return t?t.firstNode():void 0}mount(t,e){const n=this.fiber.bdom;this.bdom=n,n.mount(t,e),this.status=1,this.fiber.appliedToDom=!0,this.children=this.fiber.childrenMap,this.fiber=null}moveBefore(t,e){this.bdom.moveBefore(t?t.bdom:null,e)}patch(){this.fiber&&this.fiber.parent&&this._patch()}_patch(){const t=Object.keys(this.children).length>0;this.children=this.fiber.childrenMap,this.bdom.patch(this.fiber.bdom,t),this.fiber.appliedToDom=!0,this.fiber=null}beforeRemove(){this._destroy()}remove(){this.bdom.remove()}get name(){return this.component.constructor.name}get subscriptions(){const t=he.get(this);return t?(e=t,[...Pt.get(e)||[]].map((t=>{const e=Bt.get(t);return{target:t,keys:e?[...e.keys()]:[]}}))):[];var e}}class fe{constructor(){this.tasks=new Set,this.frame=0,this.delayedRenders=[],this.requestAnimationFrame=fe.requestAnimationFrame}addFiber(t){this.tasks.add(t.root)}flush(){if(this.delayedRenders.length){let t=this.delayedRenders;this.delayedRenders=[];for(let e of t)e.root&&2!==e.node.status&&e.render()}0===this.frame&&(this.frame=this.requestAnimationFrame((()=>{this.frame=0,this.tasks.forEach((t=>this.processFiber(t)));for(let t of this.tasks)2===t.node.status&&this.tasks.delete(t)})))}processFiber(t){if(t.root!==t)return void this.tasks.delete(t);const e=Jt.has(t);e&&0!==t.counter?this.tasks.delete(t):2!==t.node.status?0===t.counter&&(e||t.complete(),this.tasks.delete(t)):this.tasks.delete(t)}}fe.requestAnimationFrame=window.requestAnimationFrame.bind(window);const pe="true,false,NaN,null,undefined,debugger,console,window,in,instanceof,new,function,return,this,eval,void,Math,RegExp,Array,Object,Date".split(","),me=Object.assign(Object.create(null),{and:"&&",or:"||",gt:">",gte:">=",lt:"<",lte:"<="}),ge=Object.assign(Object.create(null),{"{":"LEFT_BRACE","}":"RIGHT_BRACE","[":"LEFT_BRACKET","]":"RIGHT_BRACKET",":":"COLON",",":"COMMA","(":"LEFT_PAREN",")":"RIGHT_PAREN"}),be="...,.,===,==,+,!==,!=,!,||,&&,>=,>,<=,<,?,-,*,/,%,typeof ,=>,=,;,in ".split(",");const ve=[function(t){let e=t[0],n=e;if("'"!==e&&'"'!==e&&"`"!==e)return!1;let o,r=1;for(;t[r]&&t[r]!==n;){if(o=t[r],e+=o,"\\"===o){if(r++,o=t[r],!o)throw new Error("Invalid expression");e+=o}r++}if(t[r]!==n)throw new Error("Invalid expression");return e+=n,"`"===n?{type:"TEMPLATE_STRING",value:e,replace:t=>e.replace(/\$\{(.*?)\}/g,((e,n)=>"${"+t(n)+"}"))}:{type:"VALUE",value:e}},function(t){let e=t[0];if(e&&e.match(/[0-9]/)){let n=1;for(;t[n]&&t[n].match(/[0-9]|\./);)e+=t[n],n++;return{type:"VALUE",value:e}}return!1},function(t){for(let e of be)if(t.startsWith(e))return{type:"OPERATOR",value:e};return!1},function(t){let e=t[0];if(e&&e.match(/[a-zA-Z_\$]/)){let n=1;for(;t[n]&&t[n].match(/\w/);)e+=t[n],n++;return e in me?{type:"OPERATOR",value:me[e],size:e.length}:{type:"SYMBOL",value:e}}return!1},function(t){const e=t[0];return!(!e||!(e in ge))&&{type:ge[e],value:e}}];const ye=t=>t&&("LEFT_BRACE"===t.type||"COMMA"===t.type),we=t=>t&&("RIGHT_BRACE"===t.type||"COMMA"===t.type);function xe(t){const e=new Set,n=function(t){const e=[];let n,o=!0,r=t;try{for(;o;)if(r=r.trim(),r){for(let t of ve)if(o=t(r),o){e.push(o),r=r.slice(o.size||o.value.length);break}}else o=!1}catch(t){n=t}if(r.length||n)throw new Error(`Tokenizer error: could not tokenize \`${t}\``);return e}(t);let o=0,r=[];for(;o<n.length;){let t=n[o],i=n[o-1],s=n[o+1],l=r[r.length-1];switch(t.type){case"LEFT_BRACE":case"LEFT_BRACKET":r.push(t.type);break;case"RIGHT_BRACE":case"RIGHT_BRACKET":r.pop()}let a="SYMBOL"===t.type&&!pe.includes(t.value);if("SYMBOL"!==t.type||pe.includes(t.value)||i&&("LEFT_BRACE"===l&&ye(i)&&we(s)&&(n.splice(o+1,0,{type:"COLON",value:":"},{...t}),s=n[o+1]),"OPERATOR"===i.type&&"."===i.value?a=!1:"LEFT_BRACE"!==i.type&&"COMMA"!==i.type||s&&"COLON"===s.type&&(a=!1)),"TEMPLATE_STRING"===t.type&&(t.value=t.replace((t=>ke(t)))),s&&"OPERATOR"===s.type&&"=>"===s.value)if("RIGHT_PAREN"===t.type){let t=o-1;for(;t>0&&"LEFT_PAREN"!==n[t].type;)"SYMBOL"===n[t].type&&n[t].originalValue&&(n[t].value=n[t].originalValue,e.add(n[t].value)),t--}else e.add(t.value);a&&(t.varName=t.value,e.has(t.value)||(t.originalValue=t.value,t.value=`ctx['${t.value}']`)),o++}for(const t of n)"SYMBOL"===t.type&&t.varName&&e.has(t.value)&&(t.originalValue=t.value,t.value="_"+t.value,t.isLocal=!0);return n}function ke(t){return xe(t).map((t=>t.value)).join("")}const $e=/\{\{.*?\}\}/g,Ne=/\{\{.*?\}\}/g;function Ee(t){let e=t.match($e);return e&&e[0].length===t.length?`(${ke(t.slice(2,-2))})`:"`"+t.replace(Ne,(t=>"${"+ke(t.slice(2,-2))+"}"))+"`"}const Ae=document.implementation.createDocument(null,null,null),Te=new Set(["stop","capture","prevent","self","synthetic"]);class _e{constructor(t,e){this.dynamicTagName=null,this.isRoot=!1,this.hasDynamicChildren=!1,this.children=[],this.data=[],this.childNumber=0,this.parentVar="",this.id=_e.nextBlockId++,this.varName="b"+this.id,this.blockName="block"+this.id,this.target=t,this.type=e}static generateId(t){return this.nextDataIds[t]=(this.nextDataIds[t]||0)+1,t+this.nextDataIds[t]}insertData(t,e="d"){const n=_e.generateId(e);return this.target.addLine(`let ${n} = ${t};`),this.data.push(n)-1}insert(t){this.currentDom?this.currentDom.appendChild(t):this.dom=t}generateExpr(t){if("block"===this.type){const t=this.children.length;let e=this.data.length?`[${this.data.join(", ")}]`:t?"[]":"";return t&&(e+=", ["+this.children.map((t=>t.varName)).join(", ")+"]"),this.dynamicTagName?`toggler(${this.dynamicTagName}, ${this.blockName}(${this.dynamicTagName})(${e}))`:`${this.blockName}(${e})`}return"list"===this.type?`list(c_block${this.id})`:t}asXmlString(){const t=Ae.createElement("t");return t.appendChild(this.dom),t.innerHTML}}function Se(t,e){return Object.assign({block:null,index:0,forceNewBlock:!0,translate:t.translate,tKeyExpr:null,nameSpace:t.nameSpace,tModelSelectedExpr:t.tModelSelectedExpr},e)}_e.nextBlockId=1,_e.nextDataIds={};class Ce{constructor(t,e){this.indentLevel=0,this.loopLevel=0,this.code=[],this.hasRoot=!1,this.hasCache=!1,this.hasRef=!1,this.refInfo={},this.shouldProtectScope=!1,this.name=t,this.on=e||null}addLine(t,e){const n=new Array(this.indentLevel+2).join(" ");void 0===e?this.code.push(n+t):this.code.splice(e,0,n+t)}generateCode(){let t=[];if(t.push(`function ${this.name}(ctx, node, key = "") {`),this.hasRef){t.push(" const refs = ctx.__owl__.refs;");for(let e in this.refInfo){const[n,o]=this.refInfo[e];t.push(` const ${n} = ${o};`)}}this.shouldProtectScope&&(t.push(" ctx = Object.create(ctx);"),t.push(" ctx[isBoundary] = 1")),this.hasCache&&(t.push(" let cache = ctx.cache || {};"),t.push(" let nextCache = ctx.cache = {};"));for(let e of this.code)t.push(e);return this.hasRoot||t.push("return text('');"),t.push("}"),t.join("\n ")}}const Le=["label","title","placeholder","alt"],De=/^(\s*)([\s\S]+?)(\s*)$/;class Oe{constructor(t,e){if(this.blocks=[],this.ids={},this.nextBlockId=1,this.isDebug=!1,this.targets=[],this.target=new Ce("template"),this.translatableAttributes=Le,this.staticDefs=[],this.helpers=new Set,this.translateFn=e.translateFn||(t=>t),e.translatableAttributes){const t=new Set(Le);for(let n of e.translatableAttributes)n.startsWith("-")?t.delete(n.slice(1)):t.add(n);this.translatableAttributes=[...t]}this.hasSafeContext=e.hasSafeContext||!1,this.dev=e.dev||!1,this.ast=t,this.templateName=e.name}generateCode(){const t=this.ast;this.isDebug=12===t.type,_e.nextBlockId=1,_e.nextDataIds={},this.compileAST(t,{block:null,index:0,forceNewBlock:!1,isLast:!0,translate:!0,tKeyExpr:null});let e=[" let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;"];this.helpers.size&&e.push(`let { ${[...this.helpers].join(", ")} } = helpers;`),this.templateName&&e.push(`// Template name: "${this.templateName}"`);for(let{id:t,expr:n}of this.staticDefs)e.push(`const ${t} = ${n};`);if(this.blocks.length){e.push("");for(let t of this.blocks)if(t.dom){let n=t.asXmlString();t.dynamicTagName?(n=n.replace(/^<\w+/,`<\${tag || '${t.dom.nodeName}'}`),n=n.replace(/\w+>$/,`\${tag || '${t.dom.nodeName}'}>`),e.push(`let ${t.blockName} = tag => createBlock(\`${n}\`);`)):e.push(`let ${t.blockName} = createBlock(\`${n}\`);`)}}if(this.targets.length)for(let t of this.targets)e.push(""),e=e.concat(t.generateCode());e.push(""),e=e.concat("return "+this.target.generateCode());const n=e.join("\n ");if(this.isDebug){const t="[Owl Debug]\n"+n;console.log(t)}return n}compileInNewTarget(t,e,n,o){const r=this.generateId(t),i=this.target,s=new Ce(r,o);return this.targets.push(s),this.target=s,this.compileAST(e,Se(n)),this.target=i,r}addLine(t,e){this.target.addLine(t,e)}define(t,e){this.addLine(`const ${t} = ${e};`)}generateId(t=""){return this.ids[t]=(this.ids[t]||0)+1,t+this.ids[t]}insertAnchor(t){const e="block-child-"+t.children.length,n=Ae.createElement(e);t.insert(n)}createBlock(t,e,n){const o=this.target.hasRoot,r=new _e(this.target,e);return o||n.preventRoot||(this.target.hasRoot=!0,r.isRoot=!0),t&&(t.children.push(r),"list"===t.type&&(r.parentVar="c_block"+t.id)),r}insertBlock(t,e,n){let o=e.generateExpr(t);const r=n.tKeyExpr;if(e.parentVar){let t="key"+this.target.loopLevel;return r&&(t=`${r} + ${t}`),this.helpers.add("withKey"),void this.addLine(`${e.parentVar}[${n.index}] = withKey(${o}, ${t});`)}r&&(o=`toggler(${r}, ${o})`),e.isRoot&&!n.preventRoot?(this.target.on&&(o=this.wrapWithEventCatcher(o,this.target.on)),this.addLine(`return ${o};`)):this.define(e.varName,o)}captureExpression(t,e=!1){if(!e&&!t.includes("=>"))return ke(t);const n=xe(t),o=new Map;return n.map((t=>{if(t.varName&&!t.isLocal){if(!o.has(t.varName)){const e=this.generateId("v");o.set(t.varName,e),this.define(e,t.value)}t.value=o.get(t.varName)}return t.value})).join("")}compileAST(t,e){switch(t.type){case 1:this.compileComment(t,e);break;case 0:this.compileText(t,e);break;case 2:this.compileTDomNode(t,e);break;case 4:this.compileTEsc(t,e);break;case 8:this.compileTOut(t,e);break;case 5:this.compileTIf(t,e);break;case 9:this.compileTForeach(t,e);break;case 10:this.compileTKey(t,e);break;case 3:this.compileMulti(t,e);break;case 7:this.compileTCall(t,e);break;case 15:this.compileTCallBlock(t,e);break;case 6:this.compileTSet(t,e);break;case 11:this.compileComponent(t,e);break;case 12:this.compileDebug(t,e);break;case 13:this.compileLog(t,e);break;case 14:this.compileTSlot(t,e);break;case 16:this.compileTTranslation(t,e);break;case 17:this.compileTPortal(t,e)}}compileDebug(t,e){this.addLine("debugger;"),t.content&&this.compileAST(t.content,e)}compileLog(t,e){this.addLine(`console.log(${ke(t.expr)});`),t.content&&this.compileAST(t.content,e)}compileComment(t,e){let{block:n,forceNewBlock:o}=e;if(!n||o)n=this.createBlock(n,"comment",e),this.insertBlock(`comment(\`${t.value}\`)`,n,{...e,forceNewBlock:o&&!n});else{const e=Ae.createComment(t.value);n.insert(e)}}compileText(t,e){let{block:n,forceNewBlock:o}=e,r=t.value;if(r&&!1!==e.translate){const t=De.exec(r);r=t[1]+this.translateFn(t[2])+t[3]}if(!n||o)n=this.createBlock(n,"text",e),this.insertBlock(`text(\`${r}\`)`,n,{...e,forceNewBlock:o&&!n});else{const e=0===t.type?Ae.createTextNode:Ae.createComment;n.insert(e.call(Ae,r))}}generateHandlerCode(t,e){const n=t.split(".").slice(1).map((t=>{if(!Te.has(t))throw new Error(`Unknown event modifier: '${t}'`);return`"${t}"`}));let o="";return n.length&&(o=n.join(",")+", "),`[${o}${this.captureExpression(e)}, ctx]`}compileTDomNode(t,e){let{block:n,forceNewBlock:o}=e;const r=!n||o||null!==t.dynamicTag||t.ns;let i=this.target.code.length;if(r&&((t.dynamicTag||e.tKeyExpr||t.ns)&&e.block&&this.insertAnchor(e.block),n=this.createBlock(n,"block",e),this.blocks.push(n),t.dynamicTag)){const e=this.generateId("tag");this.define(e,ke(t.dynamicTag)),n.dynamicTagName=e}const s={},l=t.ns||e.nameSpace;l&&r&&(s["block-ns"]=l);for(let o in t.attrs){let r,i;if(o.startsWith("t-attf")){r=Ee(t.attrs[o]);const e=n.insertData(r,"attr");i=o.slice(7),s["block-attribute-"+e]=i}else if(o.startsWith("t-att")){r=ke(t.attrs[o]);const e=n.insertData(r,"attr");"t-att"===o?s["block-attributes"]=String(e):(i=o.slice(6),s["block-attribute-"+e]=i)}else this.translatableAttributes.includes(o)?s[o]=this.translateFn(t.attrs[o]):(r=`"${t.attrs[o]}"`,i=o,s[o]=t.attrs[o]);if("value"===i&&e.tModelSelectedExpr){s["block-attribute-"+n.insertData(`${e.tModelSelectedExpr} === ${r}`,"attr")]="selected"}}for(let e in t.on){const o=this.generateHandlerCode(e,t.on[e]);s["block-handler-"+n.insertData(o,"hdlr")]=e}if(t.ref){this.target.hasRef=!0;if($e.test(t.ref)){const e=t.ref.replace($e,(t=>"${"+this.captureExpression(t.slice(2,-2),!0)+"}")),o=n.insertData(`(el) => refs[\`${e}\`] = el`,"ref");s["block-ref"]=String(o)}else{let e=t.ref;if(e in this.target.refInfo){this.helpers.add("multiRefSetter");const t=this.target.refInfo[e],o=n.data.push(t[0])-1;s["block-ref"]=String(o),t[1]=`multiRefSetter(refs, \`${e}\`)`}else{let t=this.generateId("ref");this.target.refInfo[e]=[t,`(el) => refs[\`${e}\`] = el`];const o=n.data.push(t)-1;s["block-ref"]=String(o)}}}let a;if(t.model){const{hasDynamicChildren:e,baseExpr:o,expr:r,eventType:i,shouldNumberize:l,shouldTrim:c,targetAttr:h,specialInitTargetAttr:u}=t.model,d=ke(o),f=this.generateId("bExpr");this.define(f,d);const p=ke(r),m=this.generateId("expr");this.define(m,p);const g=`${f}[${m}]`;let b;if(u)b=n.insertData(`${g} === '${s[h]}'`,"attr"),s["block-attribute-"+b]=u;else if(e){a=""+this.generateId("bValue"),this.define(a,g)}else b=n.insertData(""+g,"attr"),s["block-attribute-"+b]=h;this.helpers.add("toNumber");let v="ev.target."+h;v=c?v+".trim()":v,v=l?`toNumber(${v})`:v;const y=`[(ev) => { ${g} = ${v}; }]`;b=n.insertData(y,"hdlr"),s["block-handler-"+b]=i}const c=Ae.createElement(t.tag);for(const[t,e]of Object.entries(s))"class"===t&&""===e||c.setAttribute(t,e);if(n.insert(c),t.content.length){const o=n.currentDom;n.currentDom=c;const r=t.content;for(let o=0;o<r.length;o++){const i=t.content[o],s=Se(e,{block:n,index:n.childNumber,forceNewBlock:!1,isLast:e.isLast&&o===r.length-1,tKeyExpr:e.tKeyExpr,nameSpace:l,tModelSelectedExpr:a});this.compileAST(i,s)}n.currentDom=o}if(r&&(this.insertBlock(n.blockName+"(ddd)",n,e),n.children.length&&n.hasDynamicChildren)){const t=this.target.code,e=n.children.slice();let o=e.shift();for(let n=i;n<t.length&&(!t[n].trimStart().startsWith(`const ${o.varName} `)||(t[n]=t[n].replace("const "+o.varName,o.varName),o=e.shift(),o));n++);this.addLine(`let ${n.children.map((t=>t.varName))};`,i)}}compileTEsc(t,e){let n,{block:o,forceNewBlock:r}=e;if("0"===t.expr?(this.helpers.add("zero"),n="ctx[zero]"):(n=ke(t.expr),t.defaultValue&&(this.helpers.add("withDefault"),n=`withDefault(${n}, \`${t.defaultValue}\`)`)),!o||r)o=this.createBlock(o,"text",e),this.insertBlock(`text(${n})`,o,{...e,forceNewBlock:r&&!o});else{const t=o.insertData(n,"txt"),e=Ae.createElement("block-text-"+t);o.insert(e)}}compileTOut(t,e){let{block:n}=e;n&&this.insertAnchor(n),n=this.createBlock(n,"html",e),this.helpers.add("0"===t.expr?"zero":"safeOutput");let o="0"===t.expr?"ctx[zero]":`safeOutput(${ke(t.expr)})`;if(t.body){const n=_e.nextBlockId,r=Se(e);this.compileAST({type:3,content:t.body},r),this.helpers.add("withDefault"),o=`withDefault(${o}, b${n})`}this.insertBlock(""+o,n,e)}compileTIf(t,e,n){let{block:o,forceNewBlock:r,index:i}=e,s=i;const l=this.target.code.length,a=!o||"multi"!==o.type&&r;o&&(o.hasDynamicChildren=!0),(!o||"multi"!==o.type&&r)&&(o=this.createBlock(o,"multi",e)),this.addLine(`if (${ke(t.condition)}) {`),this.target.indentLevel++,this.insertAnchor(o);const c=Se(e,{block:o,index:s});if(this.compileAST(t.content,c),this.target.indentLevel--,t.tElif)for(let n of t.tElif){this.addLine(`} else if (${ke(n.condition)}) {`),this.target.indentLevel++,this.insertAnchor(o);const t=Se(e,{block:o,index:s});this.compileAST(n.content,t),this.target.indentLevel--}if(t.tElse){this.addLine("} else {"),this.target.indentLevel++,this.insertAnchor(o);const n=Se(e,{block:o,index:s});this.compileAST(t.tElse,n),this.target.indentLevel--}if(this.addLine("}"),a){if(o.children.length){const t=this.target.code,e=o.children.slice();let n=e.shift();for(let o=l;o<t.length&&(!t[o].trimStart().startsWith(`const ${n.varName} `)||(t[o]=t[o].replace("const "+n.varName,n.varName),n=e.shift(),n));o++);this.addLine(`let ${o.children.map((t=>t.varName))};`,l)}const t=o.children.map((t=>t.varName)).join(", ");this.insertBlock(`multi([${t}])`,o,e)}}compileTForeach(t,e){let{block:n}=e;n&&this.insertAnchor(n),n=this.createBlock(n,"list",e),this.target.loopLevel++;const o="i"+this.target.loopLevel;this.addLine("ctx = Object.create(ctx);");const r="v_block"+n.id,i="k_block"+n.id,s="l_block"+n.id,l="c_block"+n.id;let a;this.helpers.add("prepareList"),this.define(`[${i}, ${r}, ${s}, ${l}]`,`prepareList(${ke(t.collection)});`),this.dev&&this.define("keys"+n.id,"new Set()"),this.addLine(`for (let ${o} = 0; ${o} < ${s}; ${o}++) {`),this.target.indentLevel++,this.addLine(`ctx[\`${t.elem}\`] = ${r}[${o}];`),t.hasNoFirst||this.addLine(`ctx[\`${t.elem}_first\`] = ${o} === 0;`),t.hasNoLast||this.addLine(`ctx[\`${t.elem}_last\`] = ${o} === ${r}.length - 1;`),t.hasNoIndex||this.addLine(`ctx[\`${t.elem}_index\`] = ${o};`),t.hasNoValue||this.addLine(`ctx[\`${t.elem}_value\`] = ${i}[${o}];`),this.define("key"+this.target.loopLevel,t.key?ke(t.key):o),this.dev&&(this.addLine(`if (keys${n.id}.has(key${this.target.loopLevel})) { throw new Error(\`Got duplicate key in t-foreach: \${key${this.target.loopLevel}}\`)}`),this.addLine(`keys${n.id}.add(key${this.target.loopLevel});`)),t.memo&&(this.target.hasCache=!0,a=this.generateId(),this.define("memo"+a,ke(t.memo)),this.define("vnode"+a,`cache[key${this.target.loopLevel}];`),this.addLine(`if (vnode${a}) {`),this.target.indentLevel++,this.addLine(`if (shallowEqual(vnode${a}.memo, memo${a})) {`),this.target.indentLevel++,this.addLine(`${l}[${o}] = vnode${a};`),this.addLine(`nextCache[key${this.target.loopLevel}] = vnode${a};`),this.addLine("continue;"),this.target.indentLevel--,this.addLine("}"),this.target.indentLevel--,this.addLine("}"));const c=Se(e,{block:n,index:o});this.compileAST(t.body,c),t.memo&&this.addLine(`nextCache[key${this.target.loopLevel}] = Object.assign(${l}[${o}], {memo: memo${a}});`),this.target.indentLevel--,this.target.loopLevel--,this.addLine("}"),e.isLast||this.addLine("ctx = ctx.__proto__;"),this.insertBlock("l",n,e)}compileTKey(t,e){const n=this.generateId("tKey_");this.define(n,ke(t.expr)),e=Se(e,{tKeyExpr:n,block:e.block,index:e.index}),this.compileAST(t.content,e)}compileMulti(t,e){let{block:n,forceNewBlock:o}=e;const r=!n||o;let i=this.target.code.length;if(r){if(t.content.filter((t=>6!==t.type)).length<=1){for(let n of t.content)this.compileAST(n,e);return}n=this.createBlock(n,"multi",e)}let s=0;for(let o=0,r=t.content.length;o<r;o++){const i=t.content[o],l=6===i.type,a=Se(e,{block:n,index:s,forceNewBlock:!l,preventRoot:e.preventRoot,isLast:e.isLast&&o===r-1});this.compileAST(i,a),l||s++}if(r){if(n.hasDynamicChildren&&n.children.length){const t=this.target.code,e=n.children.slice();let o=e.shift();for(let n=i;n<t.length&&(!t[n].trimStart().startsWith(`const ${o.varName} `)||(t[n]=t[n].replace("const "+o.varName,o.varName),o=e.shift(),o));n++);this.addLine(`let ${n.children.map((t=>t.varName))};`,i)}const t=n.children.map((t=>t.varName)).join(", ");this.insertBlock(`multi([${t}])`,n,e)}}compileTCall(t,e){let{block:n,forceNewBlock:o}=e;if(t.body){this.addLine("ctx = Object.create(ctx);"),this.addLine("ctx[isBoundary] = 1;"),this.helpers.add("isBoundary");const n=_e.nextBlockId,o=Se(e,{preventRoot:!0});this.compileAST({type:3,content:t.body},o),n!==_e.nextBlockId&&(this.helpers.add("zero"),this.addLine(`ctx[zero] = b${n};`))}const r=$e.test(t.name),i=r?Ee(t.name):"`"+t.name+"`";n&&(o||this.insertAnchor(n));const s=`key + \`${this.generateComponentKey()}\``;if(r){const t=this.generateId("template");this.define(t,i),n=this.createBlock(n,"multi",e),this.helpers.add("call"),this.insertBlock(`call(this, ${t}, ctx, node, ${s})`,n,{...e,forceNewBlock:!n})}else{const t=this.generateId("callTemplate_");this.helpers.add("getTemplate"),this.staticDefs.push({id:t,expr:`getTemplate(${i})`}),n=this.createBlock(n,"multi",e),this.insertBlock(`${t}.call(this, ctx, node, ${s})`,n,{...e,forceNewBlock:!n})}t.body&&!e.isLast&&this.addLine("ctx = ctx.__proto__;")}compileTCallBlock(t,e){let{block:n,forceNewBlock:o}=e;n&&(o||this.insertAnchor(n)),n=this.createBlock(n,"multi",e),this.insertBlock(ke(t.name),n,{...e,forceNewBlock:!n})}compileTSet(t,e){this.target.shouldProtectScope=!0,this.helpers.add("isBoundary").add("withDefault");const n=t.value?ke(t.value||""):"null";if(t.body){this.helpers.add("LazyValue");const o={type:3,content:t.body};let r=`new LazyValue(${this.compileInNewTarget("value",o,e)}, ctx, node)`;r=t.value?r?`withDefault(${n}, ${r})`:n:r,this.addLine(`ctx[\`${t.name}\`] = ${r};`)}else{let e;e=t.defaultValue?t.value?`withDefault(${n}, \`${t.defaultValue}\`)`:`\`${t.defaultValue}\``:n,this.helpers.add("setContextValue"),this.addLine(`setContextValue(ctx, "${t.name}", ${e});`)}}generateComponentKey(){const t=[this.generateId("__")];for(let e=0;e<this.target.loopLevel;e++)t.push(`\${key${e+1}}`);return t.join("__")}formatProp(t,e){if(e=this.captureExpression(e),t.includes(".")){let[n,o]=t.split(".");if("bind"!==o)throw new Error("Invalid prop suffix");this.helpers.add("bind"),t=n,e=`bind(ctx, ${e||void 0})`}return`${t=/^[a-z_]+$/i.test(t)?t:`'${t}'`}: ${e||void 0}`}formatPropObject(t){const e=[];for(const[n,o]of Object.entries(t))e.push(this.formatProp(n,o));return e.join(", ")}compileComponent(t,e){let{block:n}=e;const o="slots"in(t.props||{}),r=[],i=this.formatPropObject(t.props||{});i&&r.push(i);let s="";if(t.slots){let n="ctx";!this.target.loopLevel&&this.hasSafeContext||(n=this.generateId("ctx"),this.helpers.add("capture"),this.define(n,"capture(ctx)"));let o=[];for(let r in t.slots){const i=t.slots[r],s=[];if(i.content){const t=this.compileInNewTarget("slot",i.content,e,i.on);s.push(`__render: ${t}, __ctx: ${n}`)}const l=t.slots[r].scope;l&&s.push(`__scope: "${l}"`),t.slots[r].attrs&&s.push(this.formatPropObject(t.slots[r].attrs));const a=`{${s.join(", ")}}`;o.push(`'${r}': ${a}`)}s=`{${o.join(", ")}}`}!s||t.dynamicProps||o||(this.helpers.add("markRaw"),r.push(`slots: markRaw(${s})`));const l=`{${r.join(",")}}`;let a,c=l;t.dynamicProps&&(c=`Object.assign({}, ${ke(t.dynamicProps)}${r.length?", "+l:""})`),(s&&(t.dynamicProps||o)||this.dev)&&(a=this.generateId("props"),this.define(a,c),c=a),s&&(t.dynamicProps||o)&&(this.helpers.add("markRaw"),this.addLine(`${a}.slots = markRaw(Object.assign(${s}, ${a}.slots))`));const h=this.generateComponentKey();let u;t.isDynamic?(u=this.generateId("Comp"),this.define(u,ke(t.name))):u=`\`${t.name}\``,this.dev&&this.addLine(`helpers.validateProps(${u}, ${a}, ctx);`),n&&(!1===e.forceNewBlock||e.tKeyExpr)&&this.insertAnchor(n);let d=`key + \`${h}\``;e.tKeyExpr&&(d=`${e.tKeyExpr} + ${d}`);let f=`component(${`${u}, ${c}, ${d}, node, ctx`})`;t.isDynamic&&(f=`toggler(${u}, ${f})`),t.on&&(f=this.wrapWithEventCatcher(f,t.on)),n=this.createBlock(n,"multi",e),this.insertBlock(f,n,e)}wrapWithEventCatcher(t,e){this.helpers.add("createCatcher");let n=this.generateId("catcher"),o={},r=[];for(let t in e){let n=this.generateId("hdlr"),i=r.push(n)-1;o[t]=i;const s=this.generateHandlerCode(t,e[t]);this.define(n,s)}return this.staticDefs.push({id:n,expr:`createCatcher(${JSON.stringify(o)})`}),`${n}(${t}, [${r.join(",")}])`}compileTSlot(t,e){this.helpers.add("callSlot");let n,o,{block:r}=e,i=!1;t.name.match($e)?(i=!0,o=Ee(t.name)):o="'"+t.name+"'";const s=t.attrs?`{${this.formatPropObject(t.attrs)}}`:null;if(t.defaultContent){n=`callSlot(ctx, node, key, ${o}, ${i}, ${s}, ${this.compileInNewTarget("defaultContent",t.defaultContent,e)})`}else if(i){let t=this.generateId("slot");this.define(t,o),n=`toggler(${t}, callSlot(ctx, node, key, ${t}, ${i}, ${s}))`}else n=`callSlot(ctx, node, key, ${o}, ${i}, ${s})`;t.on&&(n=this.wrapWithEventCatcher(n,t.on)),r&&this.insertAnchor(r),r=this.createBlock(r,"multi",e),this.insertBlock(n,r,{...e,forceNewBlock:!1})}compileTTranslation(t,e){t.content&&this.compileAST(t.content,Object.assign({},e,{translate:!1}))}compileTPortal(t,e){this.helpers.add("Portal");let{block:n}=e;const o=this.compileInNewTarget("slot",t.content,e),r=this.generateComponentKey();let i="ctx";!this.target.loopLevel&&this.hasSafeContext||(i=this.generateId("ctx"),this.helpers.add("capture"),this.define(i,"capture(ctx);"));const s=`component(Portal, {target: ${t.target},slots: {'default': {__render: ${o}, __ctx: ${i}}}}, key + \`${r}\`, node, ctx)`;n&&this.insertAnchor(n),n=this.createBlock(n,"multi",e),this.insertBlock(s,n,{...e,forceNewBlock:!1})}}const Be=new WeakMap;function Re(t){if("string"==typeof t){return Ie(function(t){const e=(new DOMParser).parseFromString(t,"text/xml");if(e.getElementsByTagName("parsererror").length){let n="Invalid XML in template.";const o=e.getElementsByTagName("parsererror")[0].textContent;if(o){n+="\nThe parser has produced the following error message:\n"+o;const e=/\d+/g,r=e.exec(o);if(r){const i=Number(r[0]),s=t.split("\n")[i-1],l=e.exec(o);if(s&&l){const t=Number(l[0])-1;s[t]&&(n+=`\nThe error might be located at xml line ${i} column ${t}\n${s}\n${"-".repeat(t-1)}^`)}}}throw new Error(n)}return e}(`<t>${t}</t>`).firstChild)}let e=Be.get(t);return e||(e=Ie(t.cloneNode(!0)),Be.set(t,e)),e}function Ie(t){var e;(function(t){let e=t.querySelectorAll("[t-elif], [t-else]");for(let t=0,n=e.length;t<n;t++){let n=e[t],o=n.previousElementSibling,r=t=>o.getAttribute(t),i=t=>+!!n.getAttribute(t);if(!o||!r("t-if")&&!r("t-elif"))throw new Error("t-elif and t-else directives must be preceded by a t-if or t-elif directive");{if(r("t-foreach"))throw new Error("t-if cannot stay at the same level as t-foreach when using t-elif or t-else");if(["t-if","t-elif","t-else"].map(i).reduce((function(t,e){return t+e}))>1)throw new Error("Only one conditional branching directive is allowed per node");let t;for(;(t=n.previousSibling)!==o;){if(t.nodeValue.trim().length&&8!==t.nodeType)throw new Error("text is not allowed between branching directives");t.remove()}}}})(e=t),function(t){const e=[...t.querySelectorAll("[t-esc]")].filter((t=>t.tagName[0]===t.tagName[0].toUpperCase()||t.hasAttribute("t-component")));for(const t of e){if(t.childNodes.length)throw new Error("Cannot have t-esc on a component that already has content");const e=t.getAttribute("t-esc");t.removeAttribute("t-esc");const n=t.ownerDocument.createElement("t");null!=e&&n.setAttribute("t-esc",e),t.appendChild(n)}}(e);return Pe(t,{inPreTag:!1,inSVG:!1})||{type:0,value:""}}function Pe(t,e){return t instanceof Element?function(t,e){if(t.hasAttribute("t-debug"))return t.removeAttribute("t-debug"),{type:12,content:Pe(t,e)};if(t.hasAttribute("t-log")){const n=t.getAttribute("t-log");return t.removeAttribute("t-log"),{type:13,expr:n,content:Pe(t,e)}}return null}(t,e)||function(t,e){if(!t.hasAttribute("t-foreach"))return null;const n=t.outerHTML,o=t.getAttribute("t-foreach");t.removeAttribute("t-foreach");const r=t.getAttribute("t-as")||"";t.removeAttribute("t-as");const i=t.getAttribute("t-key");if(!i)throw new Error(`"Directive t-foreach should always be used with a t-key!" (expression: t-foreach="${o}" t-as="${r}")`);t.removeAttribute("t-key");const s=t.getAttribute("t-memo")||"";t.removeAttribute("t-memo");const l=Pe(t,e);if(!l)return null;const a=!n.includes("t-call"),c=a&&!n.includes(r+"_first"),h=a&&!n.includes(r+"_last"),u=a&&!n.includes(r+"_index"),d=a&&!n.includes(r+"_value");return{type:9,collection:o,elem:r,body:l,memo:s,key:i,hasNoFirst:c,hasNoLast:h,hasNoIndex:u,hasNoValue:d}}(t,e)||function(t,e){if(!t.hasAttribute("t-if"))return null;const n=t.getAttribute("t-if");t.removeAttribute("t-if");const o=Pe(t,e)||{type:0,value:""};let r=t.nextElementSibling;const i=[];for(;r&&r.hasAttribute("t-elif");){const t=r.getAttribute("t-elif");r.removeAttribute("t-elif");const n=Pe(r,e),o=r.nextElementSibling;r.remove(),r=o,n&&i.push({condition:t,content:n})}let s=null;r&&r.hasAttribute("t-else")&&(r.removeAttribute("t-else"),s=Pe(r,e),r.remove());return{type:5,condition:n,content:o,tElif:i.length?i:null,tElse:s}}(t,e)||function(t,e){if(!t.hasAttribute("t-portal"))return null;const n=t.getAttribute("t-portal");t.removeAttribute("t-portal");const o=Pe(t,e);if(!o)return{type:0,value:""};return{type:17,target:n,content:o}}(t,e)||function(t,e){if(!t.hasAttribute("t-call"))return null;const n=t.getAttribute("t-call");if(t.removeAttribute("t-call"),"t"!==t.tagName){const o=Pe(t,e),r={type:7,name:n,body:null};if(o&&2===o.type)return o.content=[r],o;if(o&&11===o.type)return{...o,slots:{default:{content:r,scope:null,on:null,attrs:null}}}}const o=Ke(t,e);return{type:7,name:n,body:o.length?o:null}}(t,e)||function(t,e){if(!t.hasAttribute("t-call-block"))return null;return{type:15,name:t.getAttribute("t-call-block")}}(t)||function(t,e){if(!t.hasAttribute("t-esc"))return null;const n=t.getAttribute("t-esc");t.removeAttribute("t-esc");const o={type:4,expr:n,defaultValue:t.textContent||""};let r=t.getAttribute("t-ref");t.removeAttribute("t-ref");const i=Pe(t,e);if(!i)return o;if(2===i.type)return{...i,ref:r,content:[o]};if(11===i.type)throw new Error("t-esc is not supported on Component nodes");return o}(t,e)||function(t,e){if(!t.hasAttribute("t-key"))return null;const n=t.getAttribute("t-key");t.removeAttribute("t-key");const o=Pe(t,e);if(!o)return null;return{type:10,expr:n,content:o}}(t,e)||function(t,e){if("off"!==t.getAttribute("t-translation"))return null;return t.removeAttribute("t-translation"),{type:16,content:Pe(t,e)}}(t,e)||function(t,e){if(!t.hasAttribute("t-slot"))return null;const n=t.getAttribute("t-slot");t.removeAttribute("t-slot");let o=null,r=null;for(let e of t.getAttributeNames()){const n=t.getAttribute(e);e.startsWith("t-on-")?(r=r||{},r[e.slice(5)]=n):(o=o||{},o[e]=n)}return{type:14,name:n,attrs:o,on:r,defaultContent:He(t,e)}}(t,e)||function(t,e){if(!t.hasAttribute("t-out")&&!t.hasAttribute("t-raw"))return null;t.hasAttribute("t-raw")&&console.warn('t-raw has been deprecated in favor of t-out. If the value to render is not wrapped by the "markup" function, it will be escaped');const n=t.getAttribute("t-out")||t.getAttribute("t-raw");t.removeAttribute("t-out"),t.removeAttribute("t-raw");const o={type:8,expr:n,body:null},r=t.getAttribute("t-ref");t.removeAttribute("t-ref");const i=Pe(t,e);if(!i)return o;if(2===i.type)return o.body=i.content.length?i.content:null,{...i,ref:r,content:[o]};return o}(t,e)||function(t,e){let n=t.tagName;const o=n[0];let r=t.hasAttribute("t-component");if(r&&"t"!==n)throw new Error(`Directive 't-component' can only be used on <t> nodes (used on a <${n}>)`);if(o!==o.toUpperCase()&&!r)return null;r&&(n=t.getAttribute("t-component"),t.removeAttribute("t-component"));const i=t.getAttribute("t-props");t.removeAttribute("t-props");const s=t.getAttribute("t-slot-scope");t.removeAttribute("t-slot-scope");let l=null,a=null;for(let e of t.getAttributeNames()){const n=t.getAttribute(e);if(e.startsWith("t-")){if(!e.startsWith("t-on-")){const t=ze.get(e.split("-").slice(0,2).join("-"));throw new Error(t||"unsupported directive on Component: "+e)}l=l||{},l[e.slice(5)]=n}else a=a||{},a[e]=n}let c=null;if(t.hasChildNodes()){const n=t.cloneNode(!0),o=Array.from(n.querySelectorAll("[t-set-slot]"));for(let t of o){if("t"!==t.tagName)throw new Error(`Directive 't-set-slot' can only be used on <t> nodes (used on a <${t.tagName}>)`);const o=t.getAttribute("t-set-slot");let r=t.parentElement,i=!1;for(;r!==n;){if(r.hasAttribute("t-component")||r.tagName[0]===r.tagName[0].toUpperCase()){i=!0;break}r=r.parentElement}if(i)continue;t.removeAttribute("t-set-slot"),t.remove();const s=Pe(t,e);let l=null,a=null,h=null;for(let e of t.getAttributeNames()){const n=t.getAttribute(e);"t-slot-scope"!==e?e.startsWith("t-on-")?(l=l||{},l[e.slice(5)]=n):(a=a||{},a[e]=n):h=n}c=c||{},c[o]={content:s,on:l,attrs:a,scope:h}}const r=He(n,e);r&&(c=c||{},c.default={content:r,on:l,attrs:null,scope:s})}return{type:11,name:n,isDynamic:r,dynamicProps:i,props:a,slots:c,on:l}}(t,e)||function(t,e){const{tagName:n}=t,o=t.getAttribute("t-tag");if(t.removeAttribute("t-tag"),"t"===n&&!o)return null;if(n.startsWith("block-"))throw new Error(`Invalid tag name: '${n}'`);e=Object.assign({},e),"pre"===n&&(e.inPreTag=!0);const r=Ve.has(n)&&!e.inSVG;e.inSVG=e.inSVG||r;const i=r?"http://www.w3.org/2000/svg":null,s=t.getAttribute("t-ref");t.removeAttribute("t-ref");const l=t.getAttributeNames();let a=null,c=null,h=null;for(let o of l){const r=t.getAttribute(o);if(o.startsWith("t-on")){if("t-on"===o)throw new Error("Missing event name with t-on directive");c=c||{},c[o.slice(5)]=r}else if(o.startsWith("t-model")){if(!["input","select","textarea"].includes(n))throw new Error("The t-model directive only works with <input>, <textarea> and <select>");let i,s;if(We.test(r)){const t=r.lastIndexOf(".");i=r.slice(0,t),s=`'${r.slice(t+1)}'`}else{if(!Fe.test(r))throw new Error(`Invalid t-model expression: "${r}" (it should be assignable)`);{const t=r.lastIndexOf("[");i=r.slice(0,t),s=r.slice(t+1,-1)}}const l=t.getAttribute("type"),a="input"===n,c="select"===n,u="textarea"===n,d=a&&"checkbox"===l,f=a&&"radio"===l,p=a&&!d&&!f,m=o.includes(".lazy"),g=o.includes(".number");h={baseExpr:i,expr:s,targetAttr:d?"checked":"value",specialInitTargetAttr:f?"checked":null,eventType:f?"click":c||m?"change":"input",hasDynamicChildren:!1,shouldTrim:o.includes(".trim")&&(p||u),shouldNumberize:g&&(p||u)},c&&((e=Object.assign({},e)).tModelInfo=h)}else{if(o.startsWith("block-"))throw new Error(`Invalid attribute: '${o}'`);if("t-name"!==o){if(o.startsWith("t-")&&!o.startsWith("t-att"))throw new Error(`Unknown QWeb directive: '${o}'`);const t=e.tModelInfo;t&&["t-att-value","t-attf-value"].includes(o)&&(t.hasDynamicChildren=!0),a=a||{},a[o]=r}}}const u=Ke(t,e);return{type:2,tag:n,dynamicTag:o,attrs:a,on:c,ref:s,content:u,model:h,ns:i}}(t,e)||function(t,e){if(!t.hasAttribute("t-set"))return null;const n=t.getAttribute("t-set"),o=t.getAttribute("t-value")||null,r=t.innerHTML===t.textContent&&t.textContent||null;let i=null;t.textContent!==t.innerHTML&&(i=Ke(t,e));return{type:6,name:n,value:o,defaultValue:r,body:i}}(t,e)||function(t,e){if("t"!==t.tagName)return null;return He(t,e)}(t,e):function(t,e){if(t.nodeType===Node.TEXT_NODE){let n=t.textContent||"";if(!e.inPreTag){if(Me.test(n)&&!n.trim())return null;n=n.replace(je," ")}return{type:0,value:n}}if(t.nodeType===Node.COMMENT_NODE)return{type:1,value:t.textContent||""};return null}(t,e)}const Me=/[\r\n]/,je=/\s+/g;const We=/\.[\w_]+\s*$/,Fe=/\[[^\[]+\]\s*$/,Ve=new Set(["svg","g","path"]);const ze=new Map([["t-ref","t-ref is no longer supported on components. Consider exposing only the public part of the component's API through a callback prop."],["t-att","t-att makes no sense on component: props are already treated as expressions"],["t-attf","t-attf is not supported on components: use template strings for string interpolation in props"]]);function Ke(t,e){const n=[];for(let o of t.childNodes){const t=Pe(o,e);t&&(3===t.type?n.push(...t.content):n.push(t))}return n}function He(t,e){const n=Ke(t,e);switch(n.length){case 0:return null;case 1:return n[0];default:return{type:3,content:n}}}const Ue=Symbol("timeout");function qe(t,e){const n=new Error(`The following error occurred in ${e}: `),o=new Error(e+"'s promise hasn't resolved after 3 seconds"),r=ce();return(...i)=>{try{const s=t(...i);if(s instanceof Promise){if("onWillStart"===e||"onWillUpdateProps"===e){const t=r.fiber;Promise.race([s,new Promise((t=>setTimeout((()=>t(Ue)),3e3)))]).then((e=>{e===Ue&&r.fiber===t&&console.warn(o)}))}return s.catch((t=>{throw n.cause=t,t instanceof Error&&(n.message+=`"${t.message}"`),n}))}return s}catch(t){throw t instanceof Error&&(n.message+=`"${t.message}"`),n}}}function Ge(t){const e=ce(),n=e.app.dev?qe:t=>t;e.mounted.push(n(t.bind(e.component),"onMounted"))}function Xe(t){const e=ce(),n=e.app.dev?qe:t=>t;e.patched.push(n(t.bind(e.component),"onPatched"))}function Ye(t){const e=ce(),n=e.app.dev?qe:t=>t;e.willUnmount.unshift(n(t.bind(e.component),"onWillUnmount"))}class Ze{constructor(t,e,n){this.props=t,this.env=e,this.__owl__=n}setup(){}render(t=!1){this.__owl__.render(t)}}Ze.template="";const Je=z("").constructor;class Qe extends Je{constructor(t,e){super(""),this.target=null,this.selector=t,this.realBDom=e}mount(t,e){if(super.mount(t,e),this.target=document.querySelector(this.selector),!this.target){let t=this.el;for(;t&&t.parentElement instanceof HTMLElement;)t=t.parentElement;if(this.target=t&&t.querySelector(this.selector),!this.target)throw new Error("invalid portal target")}this.realBDom.mount(this.target,null)}beforeRemove(){this.realBDom.beforeRemove()}remove(){this.realBDom&&(super.remove(),this.realBDom.remove(),this.realBDom=null)}patch(t){super.patch(t),this.realBDom?this.realBDom.patch(t.realBDom,!0):(this.realBDom=t.realBDom,this.realBDom.mount(this.target,null))}}class tn extends Ze{setup(){const t=this.__owl__,e=t.renderFn;t.renderFn=()=>new Qe(this.props.target,e()),Ye((()=>{t.bdom&&t.bdom.remove()}))}}function en(t){const e=t.__owl__.component,n=Object.create(e);for(let e in t)n[e]=t[e];return n}tn.template=Zt`<t t-slot="default"/>`,tn.props={target:{type:String},slots:!0};const nn=Symbol("isBoundary");class on{constructor(t,e,n){this.fn=t,this.ctx=en(e),this.node=n}evaluate(){return this.fn(this.ctx,this.node)}toString(){return this.evaluate().toString()}}let rn=new WeakMap;const sn={withDefault:function(t,e){return null==t||!1===t?e:t},zero:Symbol("zero"),isBoundary:nn,callSlot:function(t,e,n,o,i,s,l){n=n+"__slot_"+o;const a=t.props[kt].slots||{},{__render:c,__ctx:h,__scope:u}=a[o]||{},d=Object.create(h||{});u&&(d[u]=s);const f=c?c.call(h.__owl__.component,d,e,n):null;if(l){let s=void 0,a=void 0;return f?s=i?r(o,f):f:a=l.call(t.__owl__.component,t,e,n),B([s,a])}return f||z("")},capture:en,withKey:function(t,e){return t.key=e,t},prepareList:function(t){let e,n;if(Array.isArray(t))e=t,n=t;else{if(!t)throw new Error("Invalid loop expression");n=Object.keys(t),e=Object.values(t)}const o=n.length;return[e,n,o,new Array(o)]},setContextValue:function(t,e,n){const o=t;for(;!t.hasOwnProperty(e)&&!t.hasOwnProperty(nn);){const e=t.__proto__;if(!e){t=o;break}t=e}t[e]=n},multiRefSetter:function(t,e){let n=0;return o=>{if(o&&(n++,n>1))throw new Error("Cannot have 2 elements with same ref name at the same time");(0===n||o)&&(t[e]=o)}},shallowEqual:function(t,e){for(let n=0,o=t.length;n<o;n++)if(t[n]!==e[n])return!1;return!0},toNumber:function(t){const e=parseFloat(t);return isNaN(e)?t:e},validateProps:function(t,e,n){const o="string"!=typeof t?t:n.constructor.components[t];if(!o)return;se(e,o);const r=o.defaultProps||{};let i=(s=o.props)instanceof Array?Object.fromEntries(s.map((t=>t.endsWith("?")?[t.slice(0,-1),!1]:[t,!0]))):s||{"*":!0};var s;const l="*"in i;for(let t in i){if("*"===t)continue;const n=i[t];let s,l=!!n;if("object"==typeof n&&"optional"in n&&(l=!n.optional),l&&t in r)throw new Error(`A default value cannot be defined for a mandatory prop (name: '${t}', component: ${o.name})`);if(void 0!==e[t]){try{s=le(e[t],n)}catch(e){throw e.message=`Invalid prop '${t}' in component ${o.name} (${e.message})`,e}if(!s)throw new Error(`Invalid Prop '${t}' in component '${o.name}'`)}else if(l)throw new Error(`Missing props '${t}' (component '${o.name}')`)}if(!l)for(let t in e)if(!(t in i))throw new Error(`Unknown prop '${t}' given to component '${o.name}'`)},LazyValue:on,safeOutput:function(t){if(!t)return t;let e,n;return t instanceof Xt?(e="string_safe",n=wt(t)):t instanceof on?(e="lazy_value",n=t.evaluate()):t instanceof String||"string"==typeof t?(e="string_unsafe",n=z(t)):(e="block_safe",n=t),r(e,n)},bind:function(t,e){let n=t.__owl__.component,o=rn.get(n);o||(o=new WeakMap,rn.set(n,o));let r=o.get(e);return r||(r=e.bind(n),o.set(e,r)),r},createCatcher:function(t){let e=[],n=[];for(let o in t){let r=t[o],{setup:i,remove:s}=$(o);e[r]=i,n[r]=s}let o=e.length;class r{constructor(t,e){this.afterNode=null,this.child=t,this.handlers=e}mount(t,n){this.parentEl=t,this.afterNode=n,this.child.mount(t,n);for(let n=0;n<o;n++){let o=this.handlers[n][0];const r=this;this.handlers[n][0]=function(t){const e=t.target;let n=r.child.firstNode();const i=r.afterNode;for(;n!==i;){if(n.contains(e))return o.call(this,t);n=n.nextSibling}},e[n].call(t,this.handlers[n])}}moveBefore(t,e){this.afterNode=null,this.child.moveBefore(t?t.child:null,e)}patch(t,e){this!==t&&(this.handlers=t.handlers,this.child.patch(t.child,e))}beforeRemove(){this.child.beforeRemove()}remove(){for(let t=0;t<o;t++)n[t].call(this.parentEl);this.child.remove()}firstNode(){return this.child.firstNode()}toString(){return this.child.toString()}}return function(t,e){return new r(t,e)}}},ln={text:z,createBlock:tt,list:pt,multi:B,html:wt,toggler:r,component:function(t,e,n,o,r){let i=o.children[n],s="string"!=typeof t;i&&2===i.status&&(i=void 0),s&&i&&i.component.constructor!==t&&(i=void 0);const l=o.fiber;if(i){let t=i.forceNextRender;if(t)i.forceNextRender=!1;else{const n=i.component.props[kt];t=l.deep||function(t,e){for(let n in t)if(t[n]!==e[n])return!0;return Object.keys(t).length!==Object.keys(e).length}(n,e)}t&&i.updateAndRender(e,l)}else{let a;if(s)a=t;else if(a=r.constructor.components[t],!a)throw new Error(`Cannot find the definition of component "${t}"`);i=new de(a,e,o.app,o,n),o.children[n]=i,i.initiateRender(new oe(i,l))}return l.childrenMap[n]=i,i},comment:K};let an=!1;class cn extends class{constructor(t={}){var e;this.rawTemplates=Object.create(Yt),this.templates={},this.dev=t.dev||!1,this.translateFn=t.translateFn,this.translatableAttributes=t.translatableAttributes,t.templates&&this.addTemplates(t.templates),this.helpers=(e=this.getTemplate.bind(this),Object.assign({},sn,{Portal:tn,markRaw:Dt,getTemplate:e,call:(t,n,o,i,s)=>r(n,e(n).call(t,o,i,s))}))}addTemplate(t,e,n={}){if(t in this.rawTemplates&&!n.allowDuplicate)throw new Error(`Template ${t} already defined`);this.rawTemplates[t]=e}addTemplates(t,e={}){if(t){t=t instanceof Document?t:function(t){const e=(new DOMParser).parseFromString(t,"text/xml");if(e.getElementsByTagName("parsererror").length){let n="Invalid XML in template.";const o=e.getElementsByTagName("parsererror")[0].textContent;if(o){n+="\nThe parser has produced the following error message:\n"+o;const e=/\d+/g,r=e.exec(o);if(r){const i=Number(r[0]),s=t.split("\n")[i-1],l=e.exec(o);if(s&&l){const t=Number(l[0])-1;s[t]&&(n+=`\nThe error might be located at xml line ${i} column ${t}\n${s}\n${"-".repeat(t-1)}^`)}}}throw new Error(n)}return e}(t);for(const n of t.querySelectorAll("[t-name]")){const t=n.getAttribute("t-name");this.addTemplate(t,n,e)}}}getTemplate(t){if(!(t in this.templates)){const e=this.rawTemplates[t];if(void 0===e){let e="";try{e=` (for component "${ce().component.constructor.name}")`}catch{}throw new Error(`Missing template: "${t}"${e}`)}const n=this._compileTemplate(t,e),o=this.templates;this.templates[t]=function(e,n){return o[t].call(this,e,n)};const r=n(ln,this.helpers);this.templates[t]=r}return this.templates[t]}_compileTemplate(t,e){return function(t,e={}){const n=Re(t),o=t instanceof Node?!(t instanceof Element)||null===t.querySelector("[t-set], [t-call]"):!t.includes("t-set")&&!t.includes("t-call"),r=new Oe(n,{...e,hasSafeContext:o}).generateCode();return new Function("bdom, helpers",r)}(e,{name:t,dev:this.dev,translateFn:this.translateFn,translatableAttributes:this.translatableAttributes})}}{constructor(t,e={}){super(e),this.scheduler=new fe,this.root=null,this.Root=t,e.test&&(this.dev=!0),!this.dev||e.test||an||(console.info(`Owl is running in 'dev' mode.\n\nThis is not suitable for production use.\nSee https://github.com/odoo/owl/blob/${window.owl?window.owl.__info__.hash:"master"}/doc/reference/app.md#configuration for more information.`),an=!0);const n=e.env||{},o=Object.getOwnPropertyDescriptors(n);this.env=Object.freeze(Object.create(Object.getPrototypeOf(n),o)),this.props=e.props||{}}mount(t,e){cn.validateTarget(t);const n=this.makeNode(this.Root,this.props),o=this.mountNode(n,t,e);return this.root=n,o}makeNode(t,e){return new de(t,e,this,null,null)}mountNode(t,e,n){const o=new Promise(((e,n)=>{let o=!1;t.mounted.push((()=>{e(t.component),o=!0}));let r=Qt.get(t);r||(r=[],Qt.set(t,r)),r.unshift((t=>{throw o?console.error(t):n(t),t}))}));return t.mountComponent(e,n),o}destroy(){this.root&&(this.scheduler.flush(),this.root.destroy())}}function hn(t,e){const n=Object.create(t),o=Object.getOwnPropertyDescriptors(e);return Object.freeze(Object.defineProperties(n,o))}function un(t){const e=ce();e.childEnv=hn(e.childEnv,t)}cn.validateTarget=function(t){if(!(t instanceof HTMLElement))throw new Error("Cannot mount component: the target is not a valid DOM element");if(!document.body.contains(t))throw new Error("Cannot mount a component on a detached dom node")},n.shouldNormalizeDom=!1,n.mainEventHandler=(t,n,o)=>{const{data:r,modifiers:i}=e(t);t=r;let s=!1;if(i.length){let t=!1;const e=n.target===o;for(const o of i)switch(o){case"self":if(t=!0,e)continue;return s;case"prevent":(t&&e||!t)&&n.preventDefault();continue;case"stop":(t&&e||!t)&&n.stopPropagation(),s=!0;continue}}if(Object.hasOwnProperty.call(t,0)){const e=t[0];if("function"!=typeof e)throw new Error(`Invalid handler (expected a function, received: '${e}')`);let o=t[1]?t[1].__owl__:null;o&&1!==o.status||e.call(o?o.component:null,n)}return s};const dn={config:n,mount:xt,patch:function(t,e,n=!1){t.patch(e,n)},remove:function(t,e=!1){e&&t.beforeRemove(),t.remove()},list:pt,multi:B,text:z,toggler:r,createBlock:tt,html:wt,comment:K},fn={};t.App=cn,t.Component=Ze,t.EventBus=Gt,t.__info__=fn,t.blockDom=dn,t.loadFile=async function(t){const e=await fetch(t);if(!e.ok)throw new Error("Error while fetching xml templates");return await e.text()},t.markRaw=Dt,t.markup=function(t){return new Xt(t)},t.mount=async function(t,e,n={}){return new cn(t,n).mount(e,n)},t.onError=function(t){const e=ce();let n=Qt.get(e);n||(n=[],Qt.set(e,n)),n.push(t.bind(e.component))},t.onMounted=Ge,t.onPatched=Xe,t.onRendered=function(t){const e=ce(),n=e.renderFn,o=e.app.dev?qe:t=>t;t=o(t.bind(e.component),"onRendered"),e.renderFn=()=>{const e=n();return t(),e}},t.onWillDestroy=function(t){const e=ce(),n=e.app.dev?qe:t=>t;e.willDestroy.push(n(t.bind(e.component),"onWillDestroy"))},t.onWillPatch=function(t){const e=ce(),n=e.app.dev?qe:t=>t;e.willPatch.unshift(n(t.bind(e.component),"onWillPatch"))},t.onWillRender=function(t){const e=ce(),n=e.renderFn,o=e.app.dev?qe:t=>t;t=o(t.bind(e.component),"onWillRender"),e.renderFn=()=>(t(),n())},t.onWillStart=function(t){const e=ce(),n=e.app.dev?qe:t=>t;e.willStart.push(n(t.bind(e.component),"onWillStart"))},t.onWillUnmount=Ye,t.onWillUpdateProps=function(t){const e=ce(),n=e.app.dev?qe:t=>t;e.willUpdateProps.push(n(t.bind(e.component),"onWillUpdateProps"))},t.reactive=Wt,t.status=function(t){switch(t.__owl__.status){case 0:return"new";case 1:return"mounted";case 2:return"destroyed"}},t.toRaw=Ot,t.useChildSubEnv=un,t.useComponent=function(){return ae.component},t.useEffect=function(t,e=(()=>[NaN])){let n,o;Ge((()=>{o=e(),n=t(...o)})),Xe((()=>{const r=e();r.some(((t,e)=>t!==o[e]))&&(o=r,n&&n(),n=t(...o))})),Ye((()=>n&&n()))},t.useEnv=function(){return ce().component.env},t.useExternalListener=function(t,e,n,o){const r=ce(),i=n.bind(r.component);Ge((()=>t.addEventListener(e,i,o))),Ye((()=>t.removeEventListener(e,i,o)))},t.useRef=function(t){const e=ce().refs;return{get el(){return e[t]||null}}},t.useState=ue,t.useSubEnv=function(t){const e=ce();e.component.env=hn(e.component.env,t),un(t)},t.whenReady=function(t){return new Promise((function(t){"loading"!==document.readyState?t(!0):document.addEventListener("DOMContentLoaded",t,!1)})).then(t||function(){})},t.xml=Zt,Object.defineProperty(t,"__esModule",{value:!0}),fn.version="2.0.0-beta-5",fn.date="2022-04-07T13:36:37.300Z",fn.hash="1179e84",fn.url="https://github.com/odoo/owl"}(this.owl=this.owl||{});
@@ -12,8 +12,8 @@ export interface AppConfig<P, E> extends TemplateSetConfig {
12
12
  env?: E;
13
13
  test?: boolean;
14
14
  }
15
- export declare const DEV_MSG = "Owl is running in 'dev' mode.\n\nThis is not suitable for production use.\nSee https://github.com/odoo/owl/blob/master/doc/reference/config.md#mode for more information.";
16
- export declare class App<T extends abstract new (...args: any) => any = any, P = any, E = any> extends TemplateSet {
15
+ export declare const DEV_MSG: () => string;
16
+ export declare class App<T extends abstract new (...args: any) => any = any, P extends object = any, E = any> extends TemplateSet {
17
17
  static validateTarget: typeof validateTarget;
18
18
  Root: ComponentConstructor<P, E>;
19
19
  props: P;
@@ -26,4 +26,4 @@ export declare class App<T extends abstract new (...args: any) => any = any, P =
26
26
  mountNode(node: ComponentNode, target: HTMLElement, options?: MountOptions): any;
27
27
  destroy(): void;
28
28
  }
29
- export declare function mount<T extends abstract new (...args: any) => any = any, P = any, E = any>(C: T & ComponentConstructor<P, E>, target: HTMLElement, config?: AppConfig<P, E> & MountOptions): Promise<Component<P, E> & InstanceType<T>>;
29
+ export declare function mount<T extends abstract new (...args: any) => any = any, P extends object = any, E = any>(C: T & ComponentConstructor<P, E>, target: HTMLElement, config?: AppConfig<P, E> & MountOptions): Promise<Component<P, E> & InstanceType<T>>;
@@ -1,4 +1,4 @@
1
- import { BDom, toggler } from "../blockdom";
1
+ import { BDom, toggler, createCatcher } from "../blockdom";
2
2
  import { validateProps } from "../component/props_validation";
3
3
  /**
4
4
  * This file contains utility functions that will be injected in each template,
@@ -29,7 +29,7 @@ declare type RefMap = {
29
29
  };
30
30
  declare type RefSetter = (el: HTMLElement | null) => void;
31
31
  declare function multiRefSetter(refs: RefMap, name: string): RefSetter;
32
- export declare const UTILS: {
32
+ export declare const helpers: {
33
33
  withDefault: typeof withDefault;
34
34
  zero: symbol;
35
35
  isBoundary: symbol;
@@ -45,5 +45,6 @@ export declare const UTILS: {
45
45
  LazyValue: typeof LazyValue;
46
46
  safeOutput: typeof safeOutput;
47
47
  bind: typeof bind;
48
+ createCatcher: typeof createCatcher;
48
49
  };
49
50
  export {};
@@ -1,8 +1,5 @@
1
1
  import { Template } from "../compiler";
2
- import { UTILS } from "./template_helpers";
3
- export declare const globalTemplates: {
4
- [key: string]: string | Element;
5
- };
2
+ import { globalTemplates } from "../utils";
6
3
  export interface TemplateSetConfig {
7
4
  dev?: boolean;
8
5
  translatableAttributes?: string[];
@@ -17,7 +14,7 @@ export declare class TemplateSet {
17
14
  };
18
15
  translateFn?: (s: string) => string;
19
16
  translatableAttributes?: string[];
20
- utils: typeof UTILS;
17
+ helpers: any;
21
18
  constructor(config?: TemplateSetConfig);
22
19
  addTemplate(name: string, template: string | Element, options?: {
23
20
  allowDuplicate?: boolean;
@@ -28,7 +25,3 @@ export declare class TemplateSet {
28
25
  getTemplate(name: string): Template;
29
26
  _compileTemplate(name: string, template: string | Element): import("../compiler").TemplateFunction;
30
27
  }
31
- export declare function xml(...args: Parameters<typeof String.raw>): string;
32
- export declare namespace xml {
33
- var nextId: number;
34
- }
@@ -0,0 +1,7 @@
1
+ import type { VNode } from "./index";
2
+ declare type EventsSpec = {
3
+ [name: string]: number;
4
+ };
5
+ declare type Catcher = (child: VNode, handlers: any[]) => VNode;
6
+ export declare function createCatcher(eventsSpec: EventsSpec): Catcher;
7
+ export {};
@@ -2,6 +2,7 @@ declare type EventHandlerSetter = (this: HTMLElement, data: any) => void;
2
2
  interface EventHandlerCreator {
3
3
  setup: EventHandlerSetter;
4
4
  update: EventHandlerSetter;
5
+ remove: (this: HTMLElement) => void;
5
6
  }
6
7
  export declare function createEventHandler(rawEvent: string): EventHandlerCreator;
7
8
  export {};
@@ -5,6 +5,7 @@ export { list } from "./list";
5
5
  export { multi } from "./multi";
6
6
  export { text, comment } from "./text";
7
7
  export { html } from "./html";
8
+ export { createCatcher } from "./event_catcher";
8
9
  export interface VNode<T = any> {
9
10
  mount(parent: HTMLElement, afterNode: Node | null): void;
10
11
  moveBefore(other: T | null, afterNode: Node | null): void;
@@ -1,4 +1,4 @@
1
- import { AST, ASTComment, ASTComponent, ASTDebug, ASTDomNode, ASTLog, ASTMulti, ASTSlot, ASTTCall, ASTTCallBlock, ASTTEsc, ASTText, ASTTForEach, ASTTif, ASTTKey, ASTTOut, ASTTSet, ASTTranslation, ASTTPortal } from "./parser";
1
+ import { AST, ASTComment, ASTComponent, ASTDebug, ASTDomNode, ASTLog, ASTMulti, ASTSlot, ASTTCall, ASTTCallBlock, ASTTEsc, ASTText, ASTTForEach, ASTTif, ASTTKey, ASTTOut, ASTTSet, ASTTranslation, ASTTPortal, EventHandlers } from "./parser";
2
2
  declare type BlockType = "block" | "text" | "multi" | "list" | "html" | "comment";
3
3
  export interface Config {
4
4
  translateFn?: (s: string) => string;
@@ -58,7 +58,8 @@ declare class CodeTarget {
58
58
  [name: string]: [string, string];
59
59
  };
60
60
  shouldProtectScope: boolean;
61
- constructor(name: string);
61
+ on: EventHandlers | null;
62
+ constructor(name: string, on?: EventHandlers | null);
62
63
  addLine(line: string, idx?: number): void;
63
64
  generateCode(): string;
64
65
  }
@@ -77,15 +78,16 @@ export declare class CodeGenerator {
77
78
  translateFn: (s: string) => string;
78
79
  translatableAttributes: string[];
79
80
  ast: AST;
80
- staticCalls: {
81
+ staticDefs: {
81
82
  id: string;
82
- template: string;
83
+ expr: string;
83
84
  }[];
84
85
  helpers: Set<string>;
85
86
  constructor(ast: AST, options: CodeGenOptions);
86
87
  generateCode(): string;
87
- compileInNewTarget(prefix: string, ast: AST, ctx: Context): string;
88
- addLine(line: string): void;
88
+ compileInNewTarget(prefix: string, ast: AST, ctx: Context, on?: EventHandlers | null): string;
89
+ addLine(line: string, idx?: number): void;
90
+ define(varName: string, expr: string): void;
89
91
  generateId(prefix?: string): string;
90
92
  insertAnchor(block: BlockDescription): void;
91
93
  createBlock(parentBlock: BlockDescription | null, type: BlockType, ctx: Context): BlockDescription;
@@ -137,6 +139,7 @@ export declare class CodeGenerator {
137
139
  [prop: string]: any;
138
140
  }): string;
139
141
  compileComponent(ast: ASTComponent, ctx: Context): void;
142
+ wrapWithEventCatcher(expr: string, on: EventHandlers): string;
140
143
  compileTSlot(ast: ASTSlot, ctx: Context): void;
141
144
  compileTTranslation(ast: ASTTranslation, ctx: Context): void;
142
145
  compileTPortal(ast: ASTTPortal, ctx: Context): void;
@@ -1,3 +1,9 @@
1
+ export declare type EventHandlers = {
2
+ [eventName: string]: string;
3
+ };
4
+ export declare type Attrs = {
5
+ [attrs: string]: string;
6
+ };
1
7
  export declare const enum ASTType {
2
8
  Text = 0,
3
9
  Comment = 1,
@@ -27,28 +33,24 @@ export interface ASTComment {
27
33
  value: string;
28
34
  }
29
35
  interface TModelInfo {
30
- hasDynamicChildren?: boolean;
31
36
  baseExpr: string;
32
37
  expr: string;
33
38
  targetAttr: string;
34
- specialInitTargetAttr: string | null;
35
39
  eventType: "change" | "click" | "input";
36
40
  shouldTrim: boolean;
37
41
  shouldNumberize: boolean;
42
+ hasDynamicChildren: boolean;
43
+ specialInitTargetAttr: string | null;
38
44
  }
39
45
  export interface ASTDomNode {
40
46
  type: ASTType.DomNode;
41
47
  tag: string;
42
- dynamicTag: string | null;
43
- attrs: {
44
- [key: string]: string;
45
- };
46
48
  content: AST[];
49
+ attrs: Attrs | null;
47
50
  ref: string | null;
48
- on: {
49
- [key: string]: string;
50
- };
51
- model?: TModelInfo | null;
51
+ on: EventHandlers | null;
52
+ model: TModelInfo | null;
53
+ dynamicTag: string | null;
52
54
  ns: string | null;
53
55
  }
54
56
  export interface ASTMulti {
@@ -86,13 +88,13 @@ export interface ASTTForEach {
86
88
  type: ASTType.TForEach;
87
89
  collection: string;
88
90
  elem: string;
89
- key: string | null;
90
91
  body: AST;
91
92
  memo: string;
92
93
  hasNoFirst: boolean;
93
94
  hasNoLast: boolean;
94
95
  hasNoIndex: boolean;
95
96
  hasNoValue: boolean;
97
+ key: string | null;
96
98
  }
97
99
  export interface ASTTKey {
98
100
  type: ASTType.TKey;
@@ -104,30 +106,30 @@ export interface ASTTCall {
104
106
  name: string;
105
107
  body: AST[] | null;
106
108
  }
109
+ interface SlotDefinition {
110
+ content: AST | null;
111
+ scope: string | null;
112
+ on: EventHandlers | null;
113
+ attrs: Attrs | null;
114
+ }
107
115
  export interface ASTComponent {
108
116
  type: ASTType.TComponent;
109
117
  name: string;
110
118
  isDynamic: boolean;
111
119
  dynamicProps: string | null;
120
+ on: EventHandlers | null;
112
121
  props: {
113
122
  [name: string]: string;
114
- };
123
+ } | null;
115
124
  slots: {
116
- [name: string]: {
117
- content: AST;
118
- attrs?: {
119
- [key: string]: string;
120
- };
121
- scope?: string;
122
- };
123
- };
125
+ [name: string]: SlotDefinition;
126
+ } | null;
124
127
  }
125
128
  export interface ASTSlot {
126
129
  type: ASTType.TSlot;
127
130
  name: string;
128
- attrs: {
129
- [key: string]: string;
130
- };
131
+ attrs: Attrs | null;
132
+ on: EventHandlers | null;
131
133
  defaultContent: AST | null;
132
134
  }
133
135
  export interface ASTTCallBlock {
@@ -17,6 +17,6 @@ export declare class Component<Props = any, Env = any> {
17
17
  __owl__: ComponentNode;
18
18
  constructor(props: Props, env: Env, node: ComponentNode);
19
19
  setup(): void;
20
- render(): void;
20
+ render(deep?: boolean): void;
21
21
  }
22
22
  export {};