Comparing version 0.19.2 to 0.19.3
@@ -197,2 +197,7 @@ import {Store, Event, Fork} from 'effector' | ||
}): void | ||
export function route<T>(config: { | ||
source: Store<T> | ||
visible: Store<boolean> | ||
fn: (config: {store: Store<T>}) => void | ||
}): void | ||
@@ -199,0 +204,0 @@ export function node(fn: (node: DOMElement) => void): void |
@@ -1,2 +0,2 @@ | ||
function e(e,t){e.cursor[t].prev&&(e.cursor[t].prev.cursor[t].next=e.cursor[t].next),e.cursor[t].next&&(e.cursor[t].next.cursor[t].prev=e.cursor[t].prev),e.queue[t].last===e&&(e.queue[t].last=e.cursor[t].prev),e.queue[t].first===e&&(e.queue[t].first=e.cursor[t].next),e.cursor[t].prev=null,e.cursor[t].next=null}function t(e){var t,r;e.status='active',t=a(e),(r=e).cursor.prev&&(r.cursor.prev.cursor.next=r.cursor.next),r.cursor.next&&(r.cursor.next.cursor.prev=r.cursor.prev),t.last===r&&(t.last=r.cursor.prev),t.first===r&&(t.first=r.cursor.next),r.cursor.prev=null,r.cursor.next=null}function a(e){return e.group.activeChilds[e.priority]}function r(e,a){a.value.active=a.value.pending=e,'active'!==a.status&&t(a)}function l(r,l){if(l.value.active===r)return l.value.pending=r,void('pending'===l.status&&(t(l),a(l).first||e(l.group,l.priority)));var n,o,i,s;'active'===l.status&&(l.status='pending',a(l).first||((i=l.group).queue[s=l.priority].last?(i.cursor[s].prev=i.queue[s].last,i.queue[s].last.cursor[s].next=i,i.queue[s].last=i):i.queue[s].first=i.queue[s].last=i),o=l,(n=a(l)).last?(o.cursor.prev=n.last,n.last.cursor.next=o,n.last=o):n.first=n.last=o),l.value.pending=r,l.group.queue.rafID||(l.group.queue.rafID=X(l.group.queue.execQueue))}function n(a){H('execQueue');let r,l,n=K(),o=0;e:for(;a.props.first||a.tree.first||a.data.first;){if(K()-n>=10){o=1;break e}let i=!!a.props.first;for(i&&H('props');r=a.props.first;){for(;l=r.activeChilds.props.first;){if(K()-n>=10){o=1,J('props');break e}l.runOp(l.value.pending),l.value.active=l.value.pending,t(l)}e(r,'props')}i&&J('props');let s=!!a.tree.first;for(s&&H('tree');r=a.tree.first;){for(;l=r.activeChilds.tree.first;){if(K()-n>=10){o=1,J('tree');break e}l.runOp(l.value.pending),l.value.active=l.value.pending,t(l)}e(r,'tree')}s&&J('tree');let c=!!a.data.first;for(c&&H('data');r=a.data.first;){for(;l=r.activeChilds.data.first;){if(K()-n>=10){o=1,J('data');break e}l.runOp(l.value.pending),l.value.active=l.value.pending,t(l)}e(r,'data')}c&&J('data')}if(J('execQueue'),o)a.rafID=X(a.execQueue);else if(a.rafID=null,a.onDrain){let e=a.onDrain;a.onDrain=null,e()}}function o({value:e,runOp:t,group:a,priority:r}){return{value:{active:e,pending:e},runOp:t,status:'active',priority:r,group:a,cursor:{prev:null,next:null}}}function i({onComplete:e}){let t={props:{first:null,last:null},tree:{first:null,last:null},data:{first:null,last:null},rafID:null,execQueue(){},onDrain:e};return t.execQueue=n.bind(null,t),t}function s(e){return{ops:[],queue:e,activeChilds:{props:{first:null,last:null},tree:{first:null,last:null},data:{first:null,last:null}},cursor:{props:{prev:null,next:null},tree:{prev:null,next:null},data:{prev:null,next:null}}}}function c({value:e,group:t,onInit:a,onChange:r,onTerminate:n}){let i=o({value:e,group:t,runOp(e){s.status='A',r(e)},priority:'data'}),s={status:'IA',value:i.value,hooks:{onTerminate:n},ops:{init:o({value:0,group:t,runOp(e){s.status='A',a(s.value.active)},priority:'data'}),change:i,terminate:o({value:0,group:t,runOp(e){s.status='T',s.hooks.onTerminate(1)},priority:'data'})}};return l(1,s.ops.init),s}function u(e){switch(e.status){case'I':case'T':case'AT':return;case'A':e.status='AT',l(1,e.ops.terminate);break;case'AA':e.status='AT',l(1,e.ops.terminate),l(e.value.active,e.ops.change);break;case'IA':e.status='T',l(0,e.ops.init),e.hooks.onTerminate(0)}}function p(e,t){switch(t.status){case'I':case'T':return;case'A':t.value.active!==e&&(t.status='AA',l(e,t.ops.change));break;case'AA':t.value.active===e?(t.status='A',l(e,t.ops.change)):t.value.pending!==e&&(t.value.pending=e);break;case'IA':t.value.active=t.value.pending=e}}function f(e){switch(e=String(e)){case'__proto__':case'__defineGetter__':case'__defineSetter__':case'constructor':case'prototype':case'hasOwnProperty':case'toString':case'valueOf':case'setProperty':case'removeProperty':return'forbidden';default:return e.replace(/[^a-zA-Z0-9\-_]/g,'')}}function d(e,t){for(let a=0;a<t.length;a++){let{type:r,field:l,value:n}=t[a];Y[r](e,l,n)}}function h(e){return''!==e&&0!==e&&'0'!==e&&(0==e||null==e)}function g(e,t,a){h(a)?e.style.removeProperty("--"+t):e.style.setProperty("--"+t,""+a)}function v(e,t,a){h(a)?delete e.style[t]:e.style[t]=""+a}function m(e,t,a){h(a)?delete e.dataset[t]:e.dataset[t]=""+a}function k(e,t,a){if(h(a)){switch(t){case'value':delete e.value;break;case'checked':e.checked=0;break;case'spellcheck':if(0==a)return void e.setAttribute('spellcheck','false')}e.removeAttribute(t)}else{switch(t){case'value':e.value=""+a;break;case'checked':e.checked=""+a}e.setAttribute(t,""+a)}}function y(e,t){e.replaceData(0,(e.textContent||'').length,String(t))}function b({fn:e,state:t={},defer:a=0,name:r="",draft:l,isSvgRoot:n,namespace:o,env:i,isBlock:s=0}){let c=le,u=ae,p={id:++ee,name:r,plain:[],watch:[],nameMap:{},pages:[],closure:[],childTemplates:[],upward:effector.step.filter({fn(e,t,a){if(!a.page){if(!a.parent||!a.parent.page)return 1;a.page=a.parent.page}if(!a.page.active)return console.count('inactive page upward'),0;let r=[a.page.template],l=[a.page];{let e=a.page.parent;for(;e;)l.push(e),r.push(e.template),e=e.parent}return a.node.next.forEach(t=>{let n=t.meta.nativeTemplate;n?r.includes(n)?effector.launch({target:w(t,a.forkPage),params:e,defer:1,page:l[r.indexOf(n)],stack:a,forkPage:a.forkPage}):console.error('context drift',{stack:a,node:t}):effector.launch({target:w(t,a.forkPage),params:e,defer:1,page:null,stack:a,forkPage:a.forkPage})}),0}}),loader:effector.step.filter({fn(e,t,a){if(a.parent){let r=a.forkPage?a.forkPage.graphite.id:null;if(a.page){if(!a.page.active)return console.count('inactive page loader'),0;if(a.page.template===p)return 1;if(a.page.childSpawns[p.id])a.page.childSpawns[p.id].forEach(t=>{(!r||t.leaf.forkPage&&r===t.leaf.forkPage.graphite.id)&&effector.launch({params:e,target:w(a.node,a.forkPage),page:t,defer:1,forkPage:a.forkPage})});else if(t.targetTemplate){let r=[a.page];{let e=a.page.parent;for(;e;)r.push(e),e=e.parent}let l=r.findIndex(e=>t.targetTemplate===e.template);effector.launch(-1===l?{params:e,target:w(a.node,a.forkPage),page:null,defer:1,forkPage:a.forkPage}:{params:e,target:w(a.node,a.forkPage),page:r[l],defer:1,forkPage:a.forkPage})}else p.pages.forEach(t=>{(!r||t.leaf.forkPage&&r===t.leaf.forkPage.graphite.id)&&t.fullID.startsWith(a.page.fullID)&&effector.launch({params:e,target:w(a.node,a.forkPage),page:t,defer:1,forkPage:a.forkPage})})}else p.pages.forEach(t=>{(!r||t.leaf.forkPage&&r===t.leaf.forkPage.graphite.id)&&effector.launch({params:e,target:w(a.node,a.forkPage),page:t,defer:1,forkPage:a.forkPage})});return 0}return 1}}),parent:u};u&&u.childTemplates.push(p);let f=effector.createNode({meta:{template:p}});ae=p;let d=le={template:p,node:f,api:null,trigger:{mount:effector.createEvent()},draft:l,isSvgRoot:n,namespace:o,env:i,isBlock:s||!(!c||!c.isBlock)};return a?d.deferredInit=()=>{let a=le,r=ae;le=d,ae=p,d.deferredInit=null;try{effector.withRegion(f,()=>{let a=effector.restore(t);d.api=e(a,d.trigger),p.nameMap=a})}finally{le=a,ae=r}}:effector.withRegion(f,()=>{let a=effector.restore(t);d.api=e(a,d.trigger),p.nameMap=a}),le=c,ae=u,p.actor=d,d}function w(e,t){return t&&t.nodeMap[(e=e.graphite||e).id]||e}function x(e,t){let a=e;switch(t&&ne(t,e)&&(a=ne(t,e)),e.type){case'list':return[...a.current];case'shape':return{...a.current};default:return a.current}}function P(e,t,a){let r=t;for(;r&&!ne(r.spawn,e);)r=r.parentLeaf;return r?ne(r.spawn,e):a&&ne(a,e)?ne(a,e):e}function I(e,t,a){return P(e,t,a).current}function S(e,t){ne(t.spawn,e)||(t.spawn.reg[e.id]=P(e,t.parentLeaf,t.forkPage))}function C(e,{values:t={},parentLeaf:a,mountNode:r,svgRoot:l,leafData:n,opGroup:o,domSubtree:i,hydration:s,forkPage:c,env:u}){function p(e){if(e.before)for(let t=0;t<e.before.length;t++){let a=e.before[t];switch(a.type){case'map':{let t=a.from;S(t,k),g[e.id].current=a.fn(g[t.id].current);break}case'field':{let t=a.from;S(t,k),g[e.id].current[a.field]=g[t.id].current;break}case'closure':S(a.of,k)}}if(!e.after)return;let t=g[e.id].current;for(let a=0;a<e.after.length;a++){let r=e.after[a],l=r.to;switch(g[l.id]||(g[l.id]={id:l.id,current:I(l,k.parentLeaf,c)}),r.type){case'copy':g[l.id].current=t;break;case'map':g[l.id].current=r.fn(t)}}}function f(e,t,a){let r;t.stop=1;try{for(;t.i<e.length;)r=e[t.i],t.i++,r.fn(a[r.of.id]?a[r.of.id].current:I(r.of,k.parentLeaf,c))}catch(e){console.error(e),t.stop=0}}!u&&a&&(u=a.env);let d=a?a.spawn:null,h=e.template,g={},v={id:++te,fullID:'',reg:g,template:h,parent:d,childSpawns:{},active:1};h.pages.push(v);let m={},k={actor:e,spawn:v,api:m,draft:e.draft,ops:{group:o,domSubtree:i},svgRoot:l,data:n,parentLeaf:a,hydration:s,forkPage:c,env:u,mountNode:r},y=re;re=k,d&&(d.childSpawns[h.id]||(d.childSpawns[h.id]=[]),d.childSpawns[h.id].push(v)),v.fullID=d?`${d.fullID}_${v.id}`:""+v.id;for(let e=0;e<h.closure.length;e++){let t=h.closure[e],a=t,r=v.parent;e:for(;r;){if(ne(r,t)){a=ne(r,t);break e}r=r.parent}!r&&c&&ne(c,t)&&(a=ne(c,t)),g[t.id]=a}for(let e=0;e<h.plain.length;e++){let t=h.plain[e],a={id:t.id,current:x(t,c)};g[t.id]=a}for(let e in t){let a=h.nameMap[e].stateRef.id;g[a]={id:a,current:t[e]}}h.closure.forEach(p),h.plain.forEach(p);let b={i:0,stop:0};for(;!b.stop;)f(h.watch,b,g);if(d)for(let e in v.childSpawns)e in d.childSpawns||(d.childSpawns[e]=[]),d.childSpawns[e].push(...v.childSpawns[e]);if(m.mount=(t,a=1)=>(e=>{if(oe)return void oe.steps.push(e);let t;oe={parent:oe,steps:[e]};do{for(;t=oe.steps.shift();)oe={parent:oe,steps:[]},effector.launch(t)}while(oe=oe.parent)})({target:e.trigger.mount,params:t,defer:a,page:v,forkPage:c}),e.api)for(let t in e.api)m[t]=(a,r=1)=>effector.launch({target:e.api[t],params:a,defer:r,page:v,forkPage:c});return k.spawn.api=m,k.spawn.leaf=k,k.api.mount(k),re=y,k}function T(e){let t=function e(t){switch(t.type){case'using':return t;case'fragment':switch(t.parent.type){case'element':case'using':return t.parent}default:return e((e=>{switch(e.type){case'text':case'element':case'list':case'route':case'rec':case'recItem':case'block':case'blockItem':return e.parent;case'fragment':default:switch(e.parent.type){case'using':case'block':return e.parent;default:return e.parent.parent}}})(t))}}(e);return t?t.value:null}function R(e){if(!e.visible)return null;switch(e.type){case'text':case'element':return e;case'route':return R(e.child);case'LF':case'RF':case'FF':case'rec':case'recItem':case'block':case'blockItem':return(e=>{let t=e.child;for(let e=t.length-1;e>=0;e--){let a=R(t[e]);if(a)return a}return null})(e.child);case'list':{let t=e.lastChild;if(!t)return null;for(;t;){let e=R(t);if(e)return e;t=t.left}return null}default:return null}}function q(e){switch(e.type){case'fragment':switch(e.parent.type){case'element':case'using':return null;case'RF':{let t=e.parent.parent,a=t.parent;for(let e=t.index-1;e>=0;e--){let t=R(a.child[e]);if(t)return t}return q(a)}case'rec':case'recItem':case'block':case'blockItem':case'FF':{let t=e.parent,a=t.parent;for(let e=t.index-1;e>=0;e--){let t=R(a.child[e]);if(t)return t}return q(a)}case'LF':{let t=e.parent.left;for(;t;){let e=R(t);if(e)return e;t=t.left}return q(e.parent.parent)}default:return null}case'element':case'text':case'route':case'rec':case'recItem':case'block':case'blockItem':case'list':{let t=e.parent;for(let a=e.index-1;a>=0;a--){let e=t.child[a];if(!e)continue;let r=R(e);if(r)return r}return q(t)}default:return null}}function A(e){let t=q(e);return t?t.value:null}function D(e,{parentBlockFragment:t,leaf:a,node:r,svgRoot:l,values:n}){e.childTemplates.forEach(e=>{E({parentBlockFragment:t,leaf:a,node:r,svgRoot:l,values:n,actor:e})})}function E({parentBlockFragment:e,leaf:t,node:a=t.mountNode,actor:r,svgRoot:l,values:n}){let i,{draft:c}=r,{queue:u}=t.ops.group,p=s(u),f=t.ops.domSubtree,h=f;switch(c.type){case'route':{let t={type:'route',parent:e,child:{type:'RF',parent:null,child:{type:'fragment',parent:null,child:[]},visible:0},visible:1,index:c.inParentIndex};t.child.parent=t,t.child.child.parent=t.child,e.child[c.inParentIndex]=t,i={type:'route',block:t,ops:{},initialized:0};break}case'element':{let a;if(r.isBlock){let e,r,l=t;for(;l&&(!r||!e);){l.actor.env&&(e=l.actor.env);let{draft:t}=l;'element'===t.type&&('svg'===t.tag?r='svg':'foreignObject'===t.tag&&(r='html')),l=l.parentLeaf}r||(r='html'),e&&(a='svg'===r?e.document.createElementNS('http://www.w3.org/2000/svg',c.tag):e.document.createElement(c.tag),d(a,c.staticSeq))}else a=c.stencil.cloneNode();let l={type:'element',parent:e,child:{type:'fragment',parent:null,child:[]},value:a,visible:0,index:c.inParentIndex};l.child.parent=l,e.child[c.inParentIndex]=l,i={type:'element',block:l,ops:{visible:o({value:0,priority:'tree',runOp(e){e?(O(l),i.needToCallNode&&(i.needToCallNode=0,effector.launch({target:ie,params:{element:l.value,fns:c.node},page:g.spawn,forkPage:t.forkPage}))):(l.value.remove(),l.visible=0)},group:f})},needToCallNode:c.node.length>0},h=s(u);break}case'list':{let t={type:'list',parent:e,child:[],lastChild:null,visible:1,index:c.inParentIndex};e.child[c.inParentIndex]=t,i={type:'list',draft:c,block:t,records:[]};break}case'using':case'listItem':break;case'rec':{let t={type:'rec',parent:e,child:{type:'fragment',parent:null,child:[]},visible:1,index:c.inParentIndex};t.child.parent=t,e.child[c.inParentIndex]=t,i={type:'rec',block:t};break}case'recItem':{let t={type:'recItem',parent:e,child:{type:'fragment',parent:null,child:[]},visible:1,index:c.inParentIndex};t.child.parent=t,e.child[c.inParentIndex]=t,i={type:'rec item',block:t};break}case'block':{let t={type:'block',parent:e,child:{type:'fragment',parent:null,child:[]},visible:1,index:c.inParentIndex};t.child.parent=t,e.child[c.inParentIndex]=t,i={type:'block',block:t};break}case'blockItem':{let t={type:'blockItem',parent:e,child:{type:'fragment',parent:null,child:[]},visible:1,index:c.inParentIndex};t.child.parent=t,e.child[c.inParentIndex]=t,i={type:'block item',block:t};break}default:console.warn("unexpected draft type "+c.type)}let g=C(r,{values:n,parentLeaf:t,mountNode:a,svgRoot:l||t.svgRoot,leafData:i,opGroup:p,domSubtree:h,hydration:t.hydration,forkPage:t.forkPage})}function O(e){let t=A(e);t?t.after(e.value):T(e).prepend(e.value),e.visible=1}function F(e,t){if(Array.isArray(t))return t.map(t=>e.map(e=>e[t]));if('object'==typeof t&&null!==t){let a={};for(let r in t){let l=t[r];a[r]=e.map('function'==typeof l?e=>l(e):e=>e[l])}return a}return e.map(e=>e[t])}function N(e,t){let{spawn:a}=e;for(let e in a.childSpawns){let r=a.childSpawns[e];for(let e=0;e<r.length;e++)t(r[e].leaf)}}function M(e){e.spawn.active=0,N(e,V)}function B({spawn:e}){_(e,e.parent.childSpawns[e.template.id]),_(e,e.template.pages)}function V(e){let{spawn:t,data:a}=e;switch(a.type){case'element':_(t,t.parent.childSpawns[t.template.id]),function e(t){t.active=0,_(t,t.template.pages);for(let a in t.childSpawns)t.childSpawns[a].forEach(e)}(t),l(0,a.ops.visible);break;case'list':{let t=a.records;for(let e=0;e<t.length;e++){let a=t[e];a.instance&&V(a.instance),a.active=0}e.spawn.active=0,B(e);break}case'list item':{let t=a.block;_(t,t.parent.child);let r=t.left,l=t.right;r&&(r.right=l,l||t.parent.lastChild!==t||(t.parent.lastChild=r)),l&&(l.left=r),r||l||t.parent.lastChild!==t||(t.parent.lastChild=null),t.left=null,t.right=null,M(e),B(e);break}case'route':M(e),B(e);break;case'block':case'block item':case'rec':case'rec item':M(e)}}function _(e,t){if(!t)return;let a=t.indexOf(e);-1!==a&&t.splice(a,1)}function L(){if('undefined'!=typeof document)return{document};throw Error('your environment has no document')}function j(e){let t=le.draft;switch(t.type){case'list':return void(e.visible&&(t.itemVisible=e.visible));case'listItem':case'using':case'route':case'rec':case'recItem':case'block':case'blockItem':return}if(e.attr&&t.attr.push(e.attr),e.data&&t.data.push(e.data),'text'in e){let a=e.text,r=t.childCount;Array.isArray(a)?(t.text.push(...a.map((e,t)=>({index:t+r,value:e}))),t.childCount+=a.length):(t.text.push({index:r,value:a}),t.childCount+=1)}if(e.style){let a={};for(let t in e.style)a[f(t)]=e.style[t];t.styleProp.push(a)}if(e.styleVar&&t.styleVar.push(e.styleVar),e.visible&&(t.visible=e.visible),e.handler){let t=e.handler;'object'==typeof t.on?z(t.config||{},t.on):z(t)}e.ɔ&&j(e.ɔ)}function z(e,t){if(!le)return;let a=le.draft;if('element'!==a.type)throw Error(`"handler" extension can be used only with element nodes, got "${a.type}"`);void 0===t&&(t=e,e={});for(let e in t)if(!effector.is.unit(t[e]))throw Error(`handler for "${e}" should be event`);let{passive:r=0,capture:l=0,prevent:n=0,stop:o=0}=e;a.handler.push({options:{prevent:n,stop:o},domConfig:{passive:n?0:r,capture:l},map:t})}function G({source:e,visible:t,fn:a}){if(!le)throw Error('route() called outside from using() closure');let r=b({name:'route',isSvgRoot:0,namespace:le.namespace,env:le.env,draft:{type:'route',childTemplates:[],childCount:0,inParentIndex:-1},fn(r,{mount:l}){let n=e.map(e=>({value:e,visible:t(e)})),o=b({name:'route item',isSvgRoot:0,namespace:le.namespace,env:le.env,draft:{type:'route',childTemplates:[],childCount:0,inParentIndex:-1},state:{store:null},fn({store:e},{mount:t}){let r=effector.createEvent();e.on(r,(e,t)=>t),a({store:e});let l=effector.sample({source:t,clock:n,fn:(e,{visible:t,value:a})=>({leaf:e,visible:t,value:a}),greedy:1});t.watch(se.routeItem),l.watch(({leaf:e,visible:t,value:a})=>{e.data.block.child.visible=t,t&&effector.launch({target:r,params:a,defer:1,page:e.spawn,forkPage:e.forkPage}),Q(t,e)})}});W(o);let{onMount:i,onState:s}=Z({mount:l,state:n,onMount:({visible:e,value:t},a)=>({leaf:a,visible:e,value:t}),onState:(e,{visible:t,value:a})=>({leaf:e,visible:t,value:a})});effector.merge([i,s]).watch(({leaf:e,visible:t,value:a})=>{let r=e.data;r.block.child.visible=t,t&&!r.initialized&&(E({parentBlockFragment:r.block.child.child,leaf:e,actor:o,values:{store:a}}),r.initialized=1)})}});W(r)}function Q(e,t){let a=t=>{let r=t.data;switch(r.type){case'element':l(e,r.ops.visible);break;case'route':case'list':case'list item':N(t,a);break;default:console.log('unsupported type',r.type)}};N(t,a)}function U(e){let t='function'==typeof e?e:e.fn,a=b({name:'rec',state:{store:null},isSvgRoot:0,namespace:null,env:null,draft:{type:'rec',childTemplates:[],childCount:0,inParentIndex:0},defer:1,isBlock:1,fn({store:e},{mount:a}){t({store:e,state:e});let r=effector.createEvent();return e.on(r,(e,t)=>t),a.watch(se.rec),{itemUpdater:r}}});return({store:e,state:t=e})=>{a.deferredInit&&a.deferredInit();let{env:r,namespace:l}=le;W(b({name:'rec item',isSvgRoot:0,namespace:l,env:r,draft:{type:'recItem',childTemplates:[],childCount:0,inParentIndex:-1},fn(e,{mount:r}){let{onMount:l,onState:n}=Z({state:t,mount:r,onMount:(e,t)=>({state:e,leaf:t}),onState:(e,t)=>({state:t,leaf:e})});n.watch(({state:e,leaf:t})=>{N(t,t=>{t.api.itemUpdater(e)})}),l.watch(({leaf:e,state:t})=>{E({parentBlockFragment:e.data.block.child,leaf:e,actor:a,values:{store:t}})})}}))}}function $(e,t){'function'==typeof t&&(effector.is.unit(e)?e={source:e,fn:t}:e.fn=t);let{fn:a,key:r,source:l,fields:n=[]}=e,o=void 0!==r?'function'==typeof r?r:e=>e[r]:(e,t)=>t,i={type:'list',key:effector.is.store(e)?{type:'index'}:{type:'key',key:e.key},childTemplates:[],childCount:0,inParentIndex:-1};if(!le)throw Error('list() called outside from using() closure');let f=le.env,d=le.namespace;W(b({name:'list',draft:i,isSvgRoot:0,namespace:d,fn(e,{mount:t}){let r=b({name:'list item',state:{id:-1,store:null},draft:i,isSvgRoot:0,namespace:d,fn({id:e,store:t},{mount:r}){a({store:t,key:e,fields:F(t,n)});let l=effector.createEvent();if(t.on(l,(e,t)=>t),i.itemVisible){let{onMount:e,onState:t}=Z({mount:r,state:i.itemVisible,onMount:(e,t)=>({visible:e,leaf:t}),onState:(e,t)=>({visible:t,leaf:e})});e.watch(({visible:e,leaf:t})=>{let a=t.data.block;a.visible=e,a.childInitialized=e,e&&D(i,{parentBlockFragment:a.child,leaf:t})}),t.watch(({visible:e,leaf:t})=>{let a=t.data.block;a.visible=e,a.childInitialized?Q(e,t):e&&(a.childInitialized=1,D(i,{parentBlockFragment:a.child,leaf:t}))})}else r.watch(se.listItem);return{itemUpdater:l}},env:f}),h=effector.createStore([]),g=l.map(e=>e),v=effector.sample({source:l,clock:t,fn:(e,t)=>({updates:e,leaf:t,hydration:t.hydration}),greedy:1}),m=effector.sample({source:v,clock:g,fn:({leaf:e},t)=>({updates:t,leaf:e,hydration:0}),greedy:1});effector.sample({source:h,clock:[v,m],greedy:1,fn(e,{updates:t,leaf:a,hydration:n}){let f=a.data,d=f.block;H('list update ['+l.shortName+']');let h=Array(t.length).fill(0),g=t.map(o),v=[];for(let a=0;a<e.length;a++){let r=e[a],l=g.indexOf(r.key);-1!==l?(v.push(r),h[l]=1,p(t[l],r.asyncValue)):(r.active=0,r.instance&&V(r.instance),u(r.asyncValue))}for(let e=0;e<t.length;e++){if(h[e])continue;let l=t[e],o=g[e],u=s(a.ops.group.queue),p={type:'LF',parent:d,child:{type:'fragment',parent:null,child:[]},childInitialized:0,visible:0,left:null,right:null},f={type:'listItem',key:o,index:o,active:1,leafData:{type:'list item',block:p,listDraft:i},asyncValue:c({value:l,group:u,onTerminate(e){},onChange(e){f.instance&&f.instance.api.itemUpdater(e)},onInit(e){f.active&&(n||(f.instance=C(r,{values:{id:o,store:e},parentLeaf:a,mountNode:a.mountNode,svgRoot:a.svgRoot,leafData:f.leafData,opGroup:u,domSubtree:a.ops.domSubtree,hydration:n,forkPage:a.forkPage})))}})},m=v.length;v.push(f);let k=m>0?v[m-1].leafData:null;if(p.child.parent=p,d.child.push(p),k){let e=k.block;p.left=e;let t=e.right;t?(t.left=p,p.right=t):d.lastChild=p,e.right=p}else d.lastChild=p;n&&(f.instance=C(r,{values:{id:o,store:l},parentLeaf:a,mountNode:a.mountNode,svgRoot:a.svgRoot,leafData:f.leafData,opGroup:u,domSubtree:a.ops.domSubtree,hydration:n,forkPage:a.forkPage}))}return J('list update ['+l.shortName+']'),0===v.length&&(d.lastChild=null),f.records=v,v},target:h})},env:f}))}function W(e){if(!le)return;let{draft:t}=e;if('listItem'!==t.type&&'rec'!==t.type)switch(le.draft.type){case'element':case'using':case'route':case'list':case'rec':case'recItem':case'block':case'blockItem':t.inParentIndex=le.draft.childCount,le.draft.childCount+=1,le.draft.childTemplates.push(e);break;default:console.warn("unexpected currentActor type "+le.draft.type)}}function Z({mount:e,state:t,onMount:a,onState:r}){return{onMount:effector.sample({source:t,clock:e,fn:a,greedy:1}),onState:effector.sample({source:e,clock:t,fn:r,greedy:1})}}Object.defineProperty(exports,'__esModule',{value:1});var effector=require('effector');let H,J,K;'undefined'!=typeof performance&&performance.mark?(H=e=>{performance.mark('☄️ '+e+' start')},J=e=>{try{performance.measure('☄️ '+e,'☄️ '+e+' start')}catch(e){}performance.clearMarks('☄️ '+e+' start'),performance.clearMeasures('☄️ '+e)}):(H=()=>{},J=()=>{}),K='undefined'!=typeof performance&&performance.now?()=>performance.now():'undefined'!=typeof process&&process.hrtime?()=>{let e=process.hrtime();return(1e9*e[0]+e[1])/1e6}:()=>Date.now();let X='undefined'!=typeof requestAnimationFrame?requestAnimationFrame:e=>setTimeout(e,0);const Y={attr:k,data:m,style:v,styleVar:g};let ee=0,te=0,ae=null,re=null,le=null;const ne=(e,t)=>e.reg[t.id];let oe=null,ie=effector.createEvent();ie.watch(({fns:e,element:t})=>{e.forEach(e=>{e(t)})});const se={using(e){let t=e.data;D(t.draft,{parentBlockFragment:t.block.child,leaf:e})},routeItem(e){let t=e.draft,a=e.data;a.block.child.visible=1,D(t,{parentBlockFragment:a.block.child.child,leaf:e})},block(e){D(e.draft,{parentBlockFragment:e.data.block.child,leaf:e})},blockItem(e){E({parentBlockFragment:e.data.block.child,leaf:e,actor:e.draft.itemOf})},rec(e){D(e.draft,{parentBlockFragment:e.data.block.child,leaf:e})},listItem(e){let t=e.data,a=t.block;a.visible=1,a.childInitialized=1,D(t.listDraft,{parentBlockFragment:a.child,leaf:e})}};exports.block=({fn:e,env:t,namespace:a="html"})=>{let r=b({name:'block',isSvgRoot:0,namespace:a,env:t,draft:{type:'block',childTemplates:[],childCount:0,inParentIndex:0},isBlock:1,fn({},{mount:t}){e(),t.watch(se.block)}});return()=>{let e={type:'blockItem',childTemplates:[],childCount:0,inParentIndex:-1,itemOf:r},{env:t,namespace:a}=le;W(b({name:'block item',isSvgRoot:0,namespace:a,env:t,draft:e,fn(e,{mount:t}){t.watch(se.blockItem)}}))}},exports.h=(e,t)=>{function a(e){return e.data.block.value}function n(e,t,a){let r=e.data.block.child,l={type:'text',parent:r,visible:0,index:a,value:null};if(r.child[a]=l,e.hydration){let a=q(l);if(a)switch(a.type){case'text':l.value=e.env.document.createTextNode(t),a.value.after(l.value);break;case'element':l.value=a.value.nextSibling,y(l.value,t)}else{let e=T(l);l.value=e.firstChild,y(l.value,t)}l.visible=1}else l.value=e.env.document.createTextNode(t),O(l);return l}let i,s=0,c=0;if('function'==typeof t?(s=1,i=t):t&&(c=1,t.fn&&(s=1,i=t.fn),t.ɔ&&('function'==typeof t.ɔ?(s=1,i=t.ɔ):'function'==typeof t.ɔ.fn&&(s=1,i=t.ɔ.fn))),!le)throw Error('h() called outside from using() closure');let u,p=le.env,f=le.namespace,h=f,x='html';h=x='svg'===f?'svg':'html','svg'===e&&(x='svg',h='svg'),le.isBlock||(u='svg'===x?p.document.createElementNS('http://www.w3.org/2000/svg',e):p.document.createElement(e));let P=u,I={type:'element',tag:e,attr:[],data:[],text:[],styleProp:[],styleVar:[],handler:[],stencil:P,seq:[],staticSeq:[],childTemplates:[],childCount:0,inParentIndex:-1,opsAmount:1,node:[]};'foreignObject'===f?(I.attr.push({xmlns:'http://www.w3.org/1999/xhtml'}),h='html'):'svg'===e?(I.attr.push({xmlns:'http://www.w3.org/2000/svg'}),h='svg'):'foreignObject'===e&&(h='foreignObject');let S=b({name:'element',draft:I,isSvgRoot:'svg'===e,namespace:h,fn(e,{mount:u}){function p(e){return Z({mount:f,state:e,onMount:(e,t)=>({leaf:t,value:e}),onState:(e,t)=>({leaf:e,value:t})})}let f=effector.createEvent();s&&i(),c&&j(t);let h={attr:{},data:{},text:I.text,styleProp:{},styleVar:{},visible:I.visible||null,handler:I.handler};for(let e=0;e<I.attr.length;e++){let t=I.attr[e];for(let e in t)'xlink:href'===e?h.attr.href=t[e]:h.attr[e]=t[e]}for(let e=0;e<I.data.length;e++){let t=I.data[e];for(let e in t)h.data[e]=t[e]}for(let e=0;e<I.styleProp.length;e++){let t=I.styleProp[e];for(let e in t)e.startsWith('--')?h.styleVar[e.slice(2)]=t[e]:h.styleProp[e]=t[e]}for(let e=0;e<I.styleVar.length;e++){let t=I.styleVar[e];for(let e in t)h.styleVar[e]=t[e]}h.visible&&I.seq.push({type:'visible',value:h.visible});for(let e in h.attr){let t=h.attr[e];effector.is.unit(t)?I.seq.push({type:'attr',field:e,value:t}):I.staticSeq.push({type:'attr',field:e,value:t})}for(let e in h.data){let t=h.data[e];effector.is.unit(t)?I.seq.push({type:'data',field:e,value:t}):I.staticSeq.push({type:'data',field:e,value:t})}for(let e in h.styleProp){let t=h.styleProp[e];effector.is.unit(t)?I.seq.push({type:'style',field:e,value:t}):I.staticSeq.push({type:'style',field:e,value:t})}for(let e in h.styleVar){let t=h.styleVar[e];effector.is.unit(t)?I.seq.push({type:'styleVar',field:e,value:t}):I.staticSeq.push({type:'styleVar',field:e,value:t})}for(let e=0;e<h.text.length;e++){let t=h.text[e];if(null!==t.value)if(effector.is.unit(t.value)){I.seq.push({type:'dynamicText',value:t.value,childIndex:t.index});let e=t.value.stateRef,a=ae;a.plain.includes(e)||a.closure.includes(e)||a.closure.push(e)}else I.seq.push({type:'staticText',value:String(t.value),childIndex:t.index})}for(let e=0;e<h.handler.length;e++){let t=h.handler[e];for(let e in t.map)I.seq.push({type:'handler',for:e,handler:t.map[e],options:t.options,domConfig:t.domConfig})}if(h.visible){let{onMount:e,onState:t}=Z({mount:u,state:h.visible,onMount:(e,t)=>({leaf:t,value:e,hydration:t.hydration}),onState:(e,t)=>({leaf:e,value:t,hydration:0})});e.watch(({leaf:e,value:t,hydration:a})=>{let l=e.data,n=l.block;if(a&&(r(t,l.ops.visible),t)){let e,t=A(n);if(e=t?t.nextSibling:T(n).firstChild,'#text'===e.nodeName){let t=e;e=e.nextSibling,t.remove()}n.value=e,n.visible=1}D(I,{parentBlockFragment:n.child,leaf:e,node:n.value,svgRoot:S.isSvgRoot?n.value:null}),t&&l.needToCallNode&&(l.needToCallNode=0,effector.launch({target:ie,params:{element:l.block.value,fns:I.node},page:e.spawn,defer:1,forkPage:e.forkPage})),effector.launch({target:f,params:e,defer:1,page:e.spawn,forkPage:e.forkPage})}),effector.merge([t,e]).watch(({leaf:e,value:t,hydration:a})=>{a||l(t,e.data.ops.visible)})}P&&d(P,I.staticSeq);for(let e=0;e<I.seq.length;e++){let t=I.seq[e];switch(t.type){case'visible':break;case'attr':{let{field:e}=t,r='value'===e||'checked'===e||'min'===e||'max'===e,{onMount:n,onState:i}=p(t.value);if(r)effector.merge([i,n]).watch(({leaf:t,value:r})=>{k(a(t),e,r)});else{let t=I.opsAmount++;n.watch(({value:r,leaf:l})=>{let n=a(l),i=o({value:r,priority:'props',runOp(t){k(n,e,t)},group:l.ops.group});l.ops.group.ops[t]=i,k(n,e,r)}),i.watch(({value:e,leaf:a})=>{l(e,a.ops.group.ops[t])})}break}case'data':{let{field:e}=t,{onMount:r,onState:n}=p(t.value),i=I.opsAmount++;r.watch(({value:t,leaf:r})=>{let l=a(r),n=o({value:t,priority:'props',runOp(t){m(l,e,t)},group:r.ops.group});r.ops.group.ops[i]=n,m(l,e,t)}),n.watch(({value:e,leaf:t})=>{l(e,t.ops.group.ops[i])});break}case'style':{let e=I.opsAmount++,{field:r}=t,{onMount:n,onState:i}=p(t.value);n.watch(({value:t,leaf:l})=>{let n=a(l),i=o({value:t,priority:'props',runOp(e){v(n,r,e)},group:l.ops.group});l.ops.group.ops[e]=i,v(n,r,t)}),i.watch(({value:t,leaf:a})=>{l(t,a.ops.group.ops[e])});break}case'styleVar':{let{field:e}=t,{onMount:r,onState:n}=p(t.value),i=I.opsAmount++;r.watch(({value:t,leaf:r})=>{let l=a(r),n=o({value:t,priority:'props',runOp(t){g(l,e,t)},group:r.ops.group});r.ops.group.ops[i]=n,g(l,e,t)}),n.watch(({value:e,leaf:t})=>{l(e,t.ops.group.ops[i])});break}case'staticText':f.map(e=>e).watch(e=>{n(e,t.value,t.childIndex)});break;case'dynamicText':{let e=I.opsAmount++;effector.sample({source:t.value,clock:f,fn:(e,t)=>({value:String(e),leaf:t}),greedy:1}).watch(({value:a,leaf:r})=>{let l=o({value:a,priority:'props',runOp(e){y(i.value,e)},group:r.ops.group});r.ops.group.ops[e]=l;let i=n(r,a,t.childIndex)}),effector.sample({source:f,clock:t.value,fn:(e,t)=>({leaf:e,text:t}),greedy:1}).watch(({leaf:t,text:a})=>{l(a,t.ops.group.ops[e])});break}case'handler':{let e=t.handler.graphite.meta.nativeTemplate||null;f.watch(r=>{let l=null;if(e){let t=0,a=r.spawn;for(;!t&&a;)a.template===e?(t=1,l=a):a=a.parent}a(r).addEventListener(t.for,e=>{t.options.prevent&&e.preventDefault(),t.options.stop&&e.stopPropagation(),effector.launch({target:w(t.handler,r.forkPage),params:e,page:l,forkPage:r.forkPage})},t.domConfig)});break}}}u.watch(e=>{let t=e.data;if(!I.visible){let a=t.ops.visible,n=t.block;if(e.hydration){r(1,a);let e,t=A(n);if(e=t?t.nextSibling:T(n).firstChild,'#text'===e.nodeName){let t=e;e=e.nextSibling,t.remove()}n.value=e,n.visible=1}D(I,{parentBlockFragment:n.child,leaf:e,node:n.value,svgRoot:S.isSvgRoot?n.value:null}),effector.launch({target:f,params:e,defer:1,page:e.spawn,forkPage:e.forkPage}),e.hydration?t.needToCallNode&&(t.needToCallNode=0,effector.launch({target:ie,params:{element:t.block.value,fns:I.node},page:e.spawn,defer:1,forkPage:e.forkPage})):l(1,a)}})},env:p});W(S)},exports.handler=z,exports.list=$,exports.node=e=>{let t=le.draft;switch(t.type){case'list':case'listItem':case'using':case'route':case'rec':case'recItem':case'block':case'blockItem':return void console.error('node() hook supported only in h() nodes')}t.node.push(e)},exports.rec=U,exports.remap=F,exports.route=G,exports.spec=j,exports.text=(e,...t)=>{let a=[e[0]];for(let r=0;r<t.length;r++)a.push(t[r],e[r+1]);j({text:a})},exports.tree=({source:e,key:t,child:a,fn:r})=>{let l=U(({store:e})=>{$({source:e,key:t,fn({store:e}){let t=e.map(e=>e[a]||[]);r({store:e,child(){l({store:t})}})}})});l({store:e})},exports.using=(e,t)=>{let a,r,l,n,o,c;if('function'==typeof t)a=t,l=L(),n=0;else{if(!t)throw Error('using() second argument is missing');a=t.fn,l=t.env?t.env:L(),n=t.hydrate,r=t.onComplete,o=t.onRoot,c=t.scope}if(!e)throw Error('using() first argument is missing');let u=e.namespaceURI,p=e.tagName.toLowerCase(),f={type:'using',childTemplates:[],childCount:0,inParentIndex:-1},d=b({name:'using',draft:f,isSvgRoot:'svg'===p,namespace:'http://www.w3.org/2000/svg'===u?'svg':'foreignobject'===p?'foreignObject':'html',fn(e,{mount:t}){a(),t.watch(se.using)},env:l}),h={type:'using',child:{type:'fragment',parent:null,child:[]},value:e};h.child.parent=h,(e=>{if(e&&!e.nodeMap){let t={};for(let a=0;a<e.clones.length;a++){let r=e.clones[a];t[r.meta.forkOf.id]=r}e.nodeMap=t}})(c);let g=i({onComplete:r}),v=C(d,{parentLeaf:re||null,mountNode:e,svgRoot:d.isSvgRoot?e:re?re.svgRoot:null,leafData:{type:'using',draft:f,element:e,block:h},opGroup:s(g),domSubtree:s(g),hydration:n,forkPage:c,env:l});if(o&&o({template:d,leaf:v}),g.onDrain&&!g.rafID){let e=g.onDrain;g.onDrain=null,e()}},exports.variant=({source:e,cases:t,key:a})=>{if(!effector.is.unit(e))throw Error('variant({source}) should be unit');let r;r='function'==typeof a?a:null==a?e=>String(e):e=>String(e[a]);let l=0;for(let a in t)'__'!==a?G({source:e,visible:e=>r(e)===a,fn:t[a]}):l=1;if(l){let a=Object.keys(t);G({source:e,visible:e=>!a.includes(r(e)),fn:t.__})}}; | ||
function e(e,t){e.cursor[t].prev&&(e.cursor[t].prev.cursor[t].next=e.cursor[t].next),e.cursor[t].next&&(e.cursor[t].next.cursor[t].prev=e.cursor[t].prev),e.queue[t].last===e&&(e.queue[t].last=e.cursor[t].prev),e.queue[t].first===e&&(e.queue[t].first=e.cursor[t].next),e.cursor[t].prev=null,e.cursor[t].next=null}function t(e){var t,r;e.status='active',t=a(e),(r=e).cursor.prev&&(r.cursor.prev.cursor.next=r.cursor.next),r.cursor.next&&(r.cursor.next.cursor.prev=r.cursor.prev),t.last===r&&(t.last=r.cursor.prev),t.first===r&&(t.first=r.cursor.next),r.cursor.prev=null,r.cursor.next=null}function a(e){return e.group.activeChilds[e.priority]}function r(e,a){a.value.active=a.value.pending=e,'active'!==a.status&&t(a)}function n(r,n){if(n.value.active===r)return n.value.pending=r,void('pending'===n.status&&(t(n),a(n).first||e(n.group,n.priority)));var l,o,i,s;'active'===n.status&&(n.status='pending',a(n).first||((i=n.group).queue[s=n.priority].last?(i.cursor[s].prev=i.queue[s].last,i.queue[s].last.cursor[s].next=i,i.queue[s].last=i):i.queue[s].first=i.queue[s].last=i),o=n,(l=a(n)).last?(o.cursor.prev=l.last,l.last.cursor.next=o,l.last=o):l.first=l.last=o),n.value.pending=r,n.group.queue.rafID||(n.group.queue.rafID=ee(n.group.queue.execQueue))}function l(a){K('execQueue');let r,n,l=Y(),o=0;e:for(;a.props.first||a.tree.first||a.data.first;){if(Y()-l>=10){o=1;break e}let i=!!a.props.first;for(i&&K('props');r=a.props.first;){for(;n=r.activeChilds.props.first;){if(Y()-l>=10){o=1,X('props');break e}n.runOp(n.value.pending),n.value.active=n.value.pending,t(n)}e(r,'props')}i&&X('props');let s=!!a.tree.first;for(s&&K('tree');r=a.tree.first;){for(;n=r.activeChilds.tree.first;){if(Y()-l>=10){o=1,X('tree');break e}n.runOp(n.value.pending),n.value.active=n.value.pending,t(n)}e(r,'tree')}s&&X('tree');let c=!!a.data.first;for(c&&K('data');r=a.data.first;){for(;n=r.activeChilds.data.first;){if(Y()-l>=10){o=1,X('data');break e}n.runOp(n.value.pending),n.value.active=n.value.pending,t(n)}e(r,'data')}c&&X('data')}if(X('execQueue'),o)a.rafID=ee(a.execQueue);else if(a.rafID=null,a.onDrain){let e=a.onDrain;a.onDrain=null,e()}}function o({value:e,runOp:t,group:a,priority:r}){return{value:{active:e,pending:e},runOp:t,status:'active',priority:r,group:a,cursor:{prev:null,next:null}}}function i({onComplete:e}){let t={props:{first:null,last:null},tree:{first:null,last:null},data:{first:null,last:null},rafID:null,execQueue(){},onDrain:e};return t.execQueue=l.bind(null,t),t}function s(e){return{ops:[],queue:e,activeChilds:{props:{first:null,last:null},tree:{first:null,last:null},data:{first:null,last:null}},cursor:{props:{prev:null,next:null},tree:{prev:null,next:null},data:{prev:null,next:null}}}}function c({value:e,group:t,onInit:a,onChange:r,onTerminate:l}){let i=o({value:e,group:t,runOp(e){s.status='A',r(e)},priority:'data'}),s={status:'IA',value:i.value,hooks:{onTerminate:l},ops:{init:o({value:0,group:t,runOp(e){s.status='A',a(s.value.active)},priority:'data'}),change:i,terminate:o({value:0,group:t,runOp(e){s.status='T',s.hooks.onTerminate(1)},priority:'data'})}};return n(1,s.ops.init),s}function u(e){switch(e.status){case'I':case'T':case'AT':return;case'A':e.status='AT',n(1,e.ops.terminate);break;case'AA':e.status='AT',n(1,e.ops.terminate),n(e.value.active,e.ops.change);break;case'IA':e.status='T',n(0,e.ops.init),e.hooks.onTerminate(0)}}function p(e,t){switch(t.status){case'I':case'T':return;case'A':t.value.active!==e&&(t.status='AA',n(e,t.ops.change));break;case'AA':t.value.active===e?(t.status='A',n(e,t.ops.change)):t.value.pending!==e&&(t.value.pending=e);break;case'IA':t.value.active=t.value.pending=e}}function f(e){switch(e=String(e)){case'__proto__':case'__defineGetter__':case'__defineSetter__':case'constructor':case'prototype':case'hasOwnProperty':case'toString':case'valueOf':case'setProperty':case'removeProperty':return'forbidden';default:return e.replace(/[^a-zA-Z0-9\-_]/g,'')}}function d(e,t){for(let a=0;a<t.length;a++){let{type:r,field:n,value:l}=t[a];te[r](e,n,l)}}function h(e){return''!==e&&0!==e&&'0'!==e&&(0==e||null==e)}function g(e,t,a){h(a)?e.style.removeProperty("--"+t):e.style.setProperty("--"+t,""+a)}function v(e,t,a){h(a)?delete e.style[t]:e.style[t]=""+a}function m(e,t,a){h(a)?delete e.dataset[t]:e.dataset[t]=""+a}function k(e,t,a){if(h(a)){switch(t){case'value':delete e.value;break;case'checked':e.checked=0;break;case'spellcheck':if(0==a)return void e.setAttribute('spellcheck','false')}e.removeAttribute(t)}else{switch(t){case'value':e.value=""+a;break;case'checked':e.checked=""+a}e.setAttribute(t,""+a)}}function y(e,t){e.replaceData(0,(e.textContent||'').length,String(t))}function b({fn:e,state:t={},defer:a=0,name:r="",draft:n,isSvgRoot:l,namespace:o,env:i,isBlock:s=0}){let c=oe,u=ne,p={id:++ae,name:r,plain:[],watch:[],nameMap:{},pages:[],closure:[],childTemplates:[],upward:effector.step.filter({fn(e,t,a){if(!a.page){if(!a.parent||!a.parent.page)return 1;a.page=a.parent.page}if(!a.page.active)return console.count('inactive page upward'),0;let r=[a.page.template],n=[a.page];{let e=a.page.parent;for(;e;)n.push(e),r.push(e.template),e=e.parent}return a.node.next.forEach(t=>{let l=t.meta.nativeTemplate;l?r.includes(l)?effector.launch({target:x(t,a.forkPage),params:e,defer:1,page:n[r.indexOf(l)],stack:a,forkPage:a.forkPage}):console.error('context drift',{stack:a,node:t}):effector.launch({target:x(t,a.forkPage),params:e,defer:1,page:null,stack:a,forkPage:a.forkPage})}),0}}),loader:effector.step.filter({fn(e,t,a){if(a.parent){let r=a.forkPage?a.forkPage.graphite.id:null;if(a.page){if(!a.page.active)return console.count('inactive page loader'),0;if(a.page.template===p)return 1;if(a.page.childSpawns[p.id])a.page.childSpawns[p.id].forEach(t=>{(!r||t.leaf.forkPage&&r===t.leaf.forkPage.graphite.id)&&effector.launch({params:e,target:x(a.node,a.forkPage),page:t,defer:1,forkPage:a.forkPage})});else if(t.targetTemplate){let r=[a.page];{let e=a.page.parent;for(;e;)r.push(e),e=e.parent}let n=r.findIndex(e=>t.targetTemplate===e.template);effector.launch(-1===n?{params:e,target:x(a.node,a.forkPage),page:null,defer:1,forkPage:a.forkPage}:{params:e,target:x(a.node,a.forkPage),page:r[n],defer:1,forkPage:a.forkPage})}else p.pages.forEach(t=>{(!r||t.leaf.forkPage&&r===t.leaf.forkPage.graphite.id)&&t.fullID.startsWith(a.page.fullID)&&effector.launch({params:e,target:x(a.node,a.forkPage),page:t,defer:1,forkPage:a.forkPage})})}else p.pages.forEach(t=>{(!r||t.leaf.forkPage&&r===t.leaf.forkPage.graphite.id)&&effector.launch({params:e,target:x(a.node,a.forkPage),page:t,defer:1,forkPage:a.forkPage})});return 0}return 1}}),parent:u};u&&u.childTemplates.push(p);let f=effector.createNode({meta:{template:p}});ne=p;let d=oe={template:p,node:f,api:null,trigger:{mount:effector.createEvent()},draft:n,isSvgRoot:l,namespace:o,env:i,isBlock:s||!(!c||!c.isBlock)};return a?d.deferredInit=()=>{let a=oe,r=ne;oe=d,ne=p,d.deferredInit=null;try{effector.withRegion(f,()=>{let a=effector.restore(t);d.api=e(a,d.trigger),p.nameMap=a})}finally{oe=a,ne=r}}:effector.withRegion(f,()=>{let a=effector.restore(t);d.api=e(a,d.trigger),p.nameMap=a}),oe=c,ne=u,p.actor=d,d}function x(e,t){return t&&t.nodeMap[(e=e.graphite||e).id]||e}function w(e,t){let a=e;switch(t&&ie(t,e)&&(a=ie(t,e)),e.type){case'list':return[...a.current];case'shape':return{...a.current};default:return a.current}}function P(e,t,a){let r=t;for(;r&&!ie(r.spawn,e);)r=r.parentLeaf;return r?ie(r.spawn,e):a&&ie(a,e)?ie(a,e):e}function I(e,t,a){return P(e,t,a).current}function S(e,t){ie(t.spawn,e)||(t.spawn.reg[e.id]=P(e,t.parentLeaf,t.forkPage))}function C(e,{values:t={},parentLeaf:a,mountNode:r,svgRoot:n,leafData:l,opGroup:o,domSubtree:i,hydration:s,forkPage:c,env:u}){function p(e){if(e.before)for(let t=0;t<e.before.length;t++){let a=e.before[t];switch(a.type){case'map':{let t=a.from;S(t,k),g[e.id].current=a.fn(g[t.id].current);break}case'field':{let t=a.from;S(t,k),g[e.id].current[a.field]=g[t.id].current;break}case'closure':S(a.of,k)}}if(!e.after)return;let t=g[e.id].current;for(let a=0;a<e.after.length;a++){let r=e.after[a],n=r.to;switch(g[n.id]||(g[n.id]={id:n.id,current:I(n,k.parentLeaf,c)}),r.type){case'copy':g[n.id].current=t;break;case'map':g[n.id].current=r.fn(t)}}}function f(e,t,a){let r;t.stop=1;try{for(;t.i<e.length;)r=e[t.i],t.i++,r.fn(a[r.of.id]?a[r.of.id].current:I(r.of,k.parentLeaf,c))}catch(e){console.error(e),t.stop=0}}!u&&a&&(u=a.env);let d=a?a.spawn:null,h=e.template,g={},v={id:++re,fullID:'',reg:g,template:h,parent:d,childSpawns:{},active:1};h.pages.push(v);let m={},k={actor:e,spawn:v,api:m,draft:e.draft,ops:{group:o,domSubtree:i},svgRoot:n,data:l,parentLeaf:a,hydration:s,forkPage:c,env:u,mountNode:r},y=le;le=k,d&&(d.childSpawns[h.id]||(d.childSpawns[h.id]=[]),d.childSpawns[h.id].push(v)),v.fullID=d?`${d.fullID}_${v.id}`:""+v.id;for(let e=0;e<h.closure.length;e++){let t=h.closure[e],a=t,r=v.parent;e:for(;r;){if(ie(r,t)){a=ie(r,t);break e}r=r.parent}!r&&c&&ie(c,t)&&(a=ie(c,t)),g[t.id]=a}for(let e=0;e<h.plain.length;e++){let t=h.plain[e],a={id:t.id,current:w(t,c)};g[t.id]=a}for(let e in t){let a=h.nameMap[e].stateRef.id;g[a]={id:a,current:t[e]}}h.closure.forEach(p),h.plain.forEach(p);let b={i:0,stop:0};for(;!b.stop;)f(h.watch,b,g);if(d)for(let e in v.childSpawns)e in d.childSpawns||(d.childSpawns[e]=[]),d.childSpawns[e].push(...v.childSpawns[e]);if(m.mount=(t,a=1)=>(e=>{if(se)return void se.steps.push(e);let t;se={parent:se,steps:[e]};do{for(;t=se.steps.shift();)se={parent:se,steps:[]},effector.launch(t)}while(se=se.parent)})({target:e.trigger.mount,params:t,defer:a,page:v,forkPage:c}),e.api)for(let t in e.api)m[t]=(a,r=1)=>effector.launch({target:e.api[t],params:a,defer:r,page:v,forkPage:c});return k.spawn.api=m,k.spawn.leaf=k,k.api.mount(k),le=y,k}function T(e){let t=function e(t){switch(t.type){case'using':return t;case'fragment':switch(t.parent.type){case'element':case'using':return t.parent}default:return e((e=>{switch(e.type){case'text':case'element':case'list':case'route':case'rec':case'recItem':case'block':case'blockItem':return e.parent;case'fragment':default:switch(e.parent.type){case'using':case'block':return e.parent;default:return e.parent.parent}}})(t))}}(e);return t?t.value:null}function R(e){if(!e.visible)return null;switch(e.type){case'text':case'element':return e;case'route':return R(e.child);case'LF':case'RF':case'FF':case'rec':case'recItem':case'block':case'blockItem':return(e=>{let t=e.child;for(let e=t.length-1;e>=0;e--){let a=R(t[e]);if(a)return a}return null})(e.child);case'list':{let t=e.lastChild;if(!t)return null;for(;t;){let e=R(t);if(e)return e;t=t.left}return null}default:return null}}function q(e){switch(e.type){case'fragment':switch(e.parent.type){case'element':case'using':return null;case'RF':{let t=e.parent.parent,a=t.parent;for(let e=t.index-1;e>=0;e--){let t=R(a.child[e]);if(t)return t}return q(a)}case'rec':case'recItem':case'block':case'blockItem':case'FF':{let t=e.parent,a=t.parent;for(let e=t.index-1;e>=0;e--){let t=R(a.child[e]);if(t)return t}return q(a)}case'LF':{let t=e.parent.left;for(;t;){let e=R(t);if(e)return e;t=t.left}return q(e.parent.parent)}default:return null}case'element':case'text':case'route':case'rec':case'recItem':case'block':case'blockItem':case'list':{let t=e.parent;for(let a=e.index-1;a>=0;a--){let e=t.child[a];if(!e)continue;let r=R(e);if(r)return r}return q(t)}default:return null}}function A(e){let t=q(e);return t?t.value:null}function D(e,{parentBlockFragment:t,leaf:a,node:r,svgRoot:n,values:l}){e.childTemplates.forEach(e=>{O({parentBlockFragment:t,leaf:a,node:r,svgRoot:n,values:l,actor:e})})}function O({parentBlockFragment:e,leaf:t,node:a=t.mountNode,actor:r,svgRoot:n,values:l}){let i,{draft:c}=r,{queue:u}=t.ops.group,p=s(u),f=t.ops.domSubtree,h=f;switch(c.type){case'route':{let t={type:'route',parent:e,child:{type:'RF',parent:null,child:{type:'fragment',parent:null,child:[]},visible:0},visible:1,index:c.inParentIndex};t.child.parent=t,t.child.child.parent=t.child,e.child[c.inParentIndex]=t,i={type:'route',block:t,ops:{},initialized:0};break}case'element':{let a;if(r.isBlock){let e,r,n=t;for(;n&&(!r||!e);){n.actor.env&&(e=n.actor.env);let{draft:t}=n;'element'===t.type&&('svg'===t.tag?r='svg':'foreignObject'===t.tag&&(r='html')),n=n.parentLeaf}r||(r='html'),e&&(a='svg'===r?e.document.createElementNS('http://www.w3.org/2000/svg',c.tag):e.document.createElement(c.tag),d(a,c.staticSeq))}else a=c.stencil.cloneNode();let n={type:'element',parent:e,child:{type:'fragment',parent:null,child:[]},value:a,visible:0,index:c.inParentIndex};n.child.parent=n,e.child[c.inParentIndex]=n,i={type:'element',block:n,ops:{visible:o({value:0,priority:'tree',runOp(e){e?(F(n),i.needToCallNode&&(i.needToCallNode=0,effector.launch({target:ce,params:{element:n.value,fns:c.node},page:g.spawn,forkPage:t.forkPage}))):(n.value.remove(),n.visible=0)},group:f})},needToCallNode:c.node.length>0},h=s(u);break}case'list':{let t={type:'list',parent:e,child:[],lastChild:null,visible:1,index:c.inParentIndex};e.child[c.inParentIndex]=t,i={type:'list',draft:c,block:t,records:[]};break}case'using':case'listItem':break;case'rec':{let t={type:'rec',parent:e,child:{type:'fragment',parent:null,child:[]},visible:1,index:c.inParentIndex};t.child.parent=t,e.child[c.inParentIndex]=t,i={type:'rec',block:t};break}case'recItem':{let t={type:'recItem',parent:e,child:{type:'fragment',parent:null,child:[]},visible:1,index:c.inParentIndex};t.child.parent=t,e.child[c.inParentIndex]=t,i={type:'rec item',block:t};break}case'block':{let t={type:'block',parent:e,child:{type:'fragment',parent:null,child:[]},visible:1,index:c.inParentIndex};t.child.parent=t,e.child[c.inParentIndex]=t,i={type:'block',block:t};break}case'blockItem':{let t={type:'blockItem',parent:e,child:{type:'fragment',parent:null,child:[]},visible:1,index:c.inParentIndex};t.child.parent=t,e.child[c.inParentIndex]=t,i={type:'block item',block:t};break}default:console.warn("unexpected draft type "+c.type)}let g=C(r,{values:l,parentLeaf:t,mountNode:a,svgRoot:n||t.svgRoot,leafData:i,opGroup:p,domSubtree:h,hydration:t.hydration,forkPage:t.forkPage})}function F(e){let t=A(e);t?t.after(e.value):T(e).prepend(e.value),e.visible=1}function N(e,t){if(Array.isArray(t))return t.map(t=>e.map(e=>e[t]));if('object'==typeof t&&null!==t){let a={};for(let r in t){let n=t[r];a[r]=e.map('function'==typeof n?e=>n(e):e=>e[n])}return a}return e.map(e=>e[t])}function M(e,t){let{spawn:a}=e;for(let e in a.childSpawns){let r=a.childSpawns[e];for(let e=0;e<r.length;e++)t(r[e].leaf)}}function E(e){e.spawn.active=0,M(e,V)}function B({spawn:e}){_(e,e.parent.childSpawns[e.template.id]),_(e,e.template.pages)}function V(e){let{spawn:t,data:a}=e;switch(a.type){case'element':_(t,t.parent.childSpawns[t.template.id]),function e(t){t.active=0,_(t,t.template.pages);for(let a in t.childSpawns)t.childSpawns[a].forEach(e)}(t),n(0,a.ops.visible);break;case'list':{let t=a.records;for(let e=0;e<t.length;e++){let a=t[e];a.instance&&V(a.instance),a.active=0}e.spawn.active=0,B(e);break}case'list item':{let t=a.block;_(t,t.parent.child);let r=t.left,n=t.right;r&&(r.right=n,n||t.parent.lastChild!==t||(t.parent.lastChild=r)),n&&(n.left=r),r||n||t.parent.lastChild!==t||(t.parent.lastChild=null),t.left=null,t.right=null,E(e),B(e);break}case'route':E(e),B(e);break;case'block':case'block item':case'rec':case'rec item':E(e)}}function _(e,t){if(!t)return;let a=t.indexOf(e);-1!==a&&t.splice(a,1)}function L(e,t){if(!e)throw Error(t)}function j(e,t){if(!e)throw Error(t+"() called outside from using() closure")}function z(){if('undefined'!=typeof document)return{document};throw Error('your environment has no document')}function G(e){j(oe,'spec');let t=oe.draft;switch(t.type){case'list':return void(e.visible&&(t.itemVisible=e.visible));case'listItem':case'using':case'route':case'rec':case'recItem':case'block':case'blockItem':return}if(e.attr&&t.attr.push(e.attr),e.data&&t.data.push(e.data),'text'in e){let a=e.text,r=t.childCount;Array.isArray(a)?(t.text.push(...a.map((e,t)=>({index:t+r,value:e}))),t.childCount+=a.length):(t.text.push({index:r,value:a}),t.childCount+=1)}if(e.style){let a={};for(let t in e.style)a[f(t)]=e.style[t];t.styleProp.push(a)}if(e.styleVar&&t.styleVar.push(e.styleVar),e.visible&&(t.visible=e.visible),e.handler){let t=e.handler;'object'==typeof t.on?Q(t.config||{},t.on):Q(t)}e.ɔ&&G(e.ɔ)}function Q(e,t){if(!oe)return;let a=oe.draft;L('element'===a.type,`"handler" extension can be used only with element nodes, got "${a.type}"`),void 0===t&&(t=e,e={});for(let e in t)L(effector.is.unit(t[e]),`handler for "${e}" should be event`);let{passive:r=0,capture:n=0,prevent:l=0,stop:o=0}=e;a.handler.push({options:{prevent:l,stop:o},domConfig:{passive:l?0:r,capture:n},map:t})}function U({source:e,visible:t,fn:a}){j(oe,'route');let{env:r,namespace:n}=oe,l=b({name:'route',isSvgRoot:0,namespace:n,env:r,draft:{type:'route',childTemplates:[],childCount:0,inParentIndex:-1},fn(l,{mount:o}){let i;if(effector.is.store(t))i=effector.combine({value:e,visible:t});else{let a=t;i=e.map(e=>({value:e,visible:a(e)}))}let s=b({name:'route item',isSvgRoot:0,namespace:n,env:r,draft:{type:'route',childTemplates:[],childCount:0,inParentIndex:-1},state:{store:null},fn({store:e},{mount:t}){let r=effector.createEvent();e.on(r,(e,t)=>t),a({store:e});let n=effector.sample({source:t,clock:i,fn:(e,{visible:t,value:a})=>({leaf:e,visible:t,value:a}),greedy:1});t.watch(ue.routeItem),n.watch(({leaf:e,visible:t,value:a})=>{e.data.block.child.visible=t,t&&effector.launch({target:r,params:a,defer:1,page:e.spawn,forkPage:e.forkPage}),$(t,e)})}});H(s);let{onMount:c,onState:u}=J({mount:o,state:i,onMount:({visible:e,value:t},a)=>({leaf:a,visible:e,value:t}),onState:(e,{visible:t,value:a})=>({leaf:e,visible:t,value:a})});effector.merge([c,u]).watch(({leaf:e,visible:t,value:a})=>{let r=e.data;r.block.child.visible=t,t&&!r.initialized&&(O({parentBlockFragment:r.block.child.child,leaf:e,actor:s,values:{store:a}}),r.initialized=1)})}});H(l)}function $(e,t){let a=t=>{let r=t.data;switch(r.type){case'element':n(e,r.ops.visible);break;case'route':case'list':case'list item':M(t,a);break;default:console.log('unsupported type',r.type)}};M(t,a)}function W(e){let t='function'==typeof e?e:e.fn,a=b({name:'rec',state:{store:null},isSvgRoot:0,namespace:null,env:null,draft:{type:'rec',childTemplates:[],childCount:0,inParentIndex:0},defer:1,isBlock:1,fn({store:e},{mount:a}){t({store:e,state:e});let r=effector.createEvent();return e.on(r,(e,t)=>t),a.watch(ue.rec),{itemUpdater:r}}});return({store:e,state:t=e})=>{j(oe,'(rec instance)');let{env:r,namespace:n}=oe;a.deferredInit&&a.deferredInit(),H(b({name:'rec item',isSvgRoot:0,namespace:n,env:r,draft:{type:'recItem',childTemplates:[],childCount:0,inParentIndex:-1},fn(e,{mount:r}){let{onMount:n,onState:l}=J({state:t,mount:r,onMount:(e,t)=>({state:e,leaf:t}),onState:(e,t)=>({state:t,leaf:e})});l.watch(({state:e,leaf:t})=>{M(t,t=>{t.api.itemUpdater(e)})}),n.watch(({leaf:e,state:t})=>{O({parentBlockFragment:e.data.block.child,leaf:e,actor:a,values:{store:t}})})}}))}}function Z(e,t){j(oe,'list'),'function'==typeof t&&(effector.is.unit(e)?e={source:e,fn:t}:e.fn=t);let{fn:a,key:r,source:n,fields:l=[]}=e,o=void 0!==r?'function'==typeof r?r:e=>e[r]:(e,t)=>t,i={type:'list',key:effector.is.store(e)?{type:'index'}:{type:'key',key:e.key},childTemplates:[],childCount:0,inParentIndex:-1},{env:f,namespace:d}=oe;H(b({name:'list',draft:i,isSvgRoot:0,namespace:d,fn(e,{mount:t}){let r=b({name:'list item',state:{id:-1,store:null},draft:i,isSvgRoot:0,namespace:d,fn({id:e,store:t},{mount:r}){a({store:t,key:e,fields:N(t,l)});let n=effector.createEvent();if(t.on(n,(e,t)=>t),i.itemVisible){let{onMount:e,onState:t}=J({mount:r,state:i.itemVisible,onMount:(e,t)=>({visible:e,leaf:t}),onState:(e,t)=>({visible:t,leaf:e})});e.watch(({visible:e,leaf:t})=>{let a=t.data.block;a.visible=e,a.childInitialized=e,e&&D(i,{parentBlockFragment:a.child,leaf:t})}),t.watch(({visible:e,leaf:t})=>{let a=t.data.block;a.visible=e,a.childInitialized?$(e,t):e&&(a.childInitialized=1,D(i,{parentBlockFragment:a.child,leaf:t}))})}else r.watch(ue.listItem);return{itemUpdater:n}},env:f}),h=effector.createStore([]),g=n.map(e=>e),v=effector.sample({source:n,clock:t,fn:(e,t)=>({updates:e,leaf:t,hydration:t.hydration}),greedy:1}),m=effector.sample({source:v,clock:g,fn:({leaf:e},t)=>({updates:t,leaf:e,hydration:0}),greedy:1});effector.sample({source:h,clock:[v,m],greedy:1,fn(e,{updates:t,leaf:a,hydration:l}){let f=a.data,d=f.block;K('list update ['+n.shortName+']');let h=Array(t.length).fill(0),g=t.map(o),v=[];for(let a=0;a<e.length;a++){let r=e[a],n=g.indexOf(r.key);-1!==n?(v.push(r),h[n]=1,p(t[n],r.asyncValue)):(r.active=0,r.instance&&V(r.instance),u(r.asyncValue))}for(let e=0;e<t.length;e++){if(h[e])continue;let n=t[e],o=g[e],u=s(a.ops.group.queue),p={type:'LF',parent:d,child:{type:'fragment',parent:null,child:[]},childInitialized:0,visible:0,left:null,right:null},f={type:'listItem',key:o,index:o,active:1,leafData:{type:'list item',block:p,listDraft:i},asyncValue:c({value:n,group:u,onTerminate(e){},onChange(e){f.instance&&f.instance.api.itemUpdater(e)},onInit(e){f.active&&(l||(f.instance=C(r,{values:{id:o,store:e},parentLeaf:a,mountNode:a.mountNode,svgRoot:a.svgRoot,leafData:f.leafData,opGroup:u,domSubtree:a.ops.domSubtree,hydration:l,forkPage:a.forkPage})))}})},m=v.length;v.push(f);let k=m>0?v[m-1].leafData:null;if(p.child.parent=p,d.child.push(p),k){let e=k.block;p.left=e;let t=e.right;t?(t.left=p,p.right=t):d.lastChild=p,e.right=p}else d.lastChild=p;l&&(f.instance=C(r,{values:{id:o,store:n},parentLeaf:a,mountNode:a.mountNode,svgRoot:a.svgRoot,leafData:f.leafData,opGroup:u,domSubtree:a.ops.domSubtree,hydration:l,forkPage:a.forkPage}))}return X('list update ['+n.shortName+']'),0===v.length&&(d.lastChild=null),f.records=v,v},target:h})},env:f}))}function H(e){if(!oe)return;let{draft:t}=e;if('listItem'!==t.type&&'rec'!==t.type)switch(oe.draft.type){case'element':case'using':case'route':case'list':case'rec':case'recItem':case'block':case'blockItem':t.inParentIndex=oe.draft.childCount,oe.draft.childCount+=1,oe.draft.childTemplates.push(e);break;default:console.warn("unexpected currentActor type "+oe.draft.type)}}function J({mount:e,state:t,onMount:a,onState:r}){return{onMount:effector.sample({source:t,clock:e,fn:a,greedy:1}),onState:effector.sample({source:e,clock:t,fn:r,greedy:1})}}Object.defineProperty(exports,'__esModule',{value:1});var effector=require('effector');let K,X,Y;'undefined'!=typeof performance&&performance.mark?(K=e=>{performance.mark('☄️ '+e+' start')},X=e=>{try{performance.measure('☄️ '+e,'☄️ '+e+' start')}catch(e){}performance.clearMarks('☄️ '+e+' start'),performance.clearMeasures('☄️ '+e)}):(K=()=>{},X=()=>{}),Y='undefined'!=typeof performance&&performance.now?()=>performance.now():'undefined'!=typeof process&&process.hrtime?()=>{let e=process.hrtime();return(1e9*e[0]+e[1])/1e6}:()=>Date.now();let ee='undefined'!=typeof requestAnimationFrame?requestAnimationFrame:e=>setTimeout(e,0);const te={attr:k,data:m,style:v,styleVar:g};let ae=0,re=0,ne=null,le=null,oe=null;const ie=(e,t)=>e.reg[t.id];let se=null,ce=effector.createEvent();ce.watch(({fns:e,element:t})=>{e.forEach(e=>{e(t)})});const ue={using(e){let t=e.data;D(t.draft,{parentBlockFragment:t.block.child,leaf:e})},routeItem(e){let t=e.draft,a=e.data;a.block.child.visible=1,D(t,{parentBlockFragment:a.block.child.child,leaf:e})},block(e){D(e.draft,{parentBlockFragment:e.data.block.child,leaf:e})},blockItem(e){O({parentBlockFragment:e.data.block.child,leaf:e,actor:e.draft.itemOf})},rec(e){D(e.draft,{parentBlockFragment:e.data.block.child,leaf:e})},listItem(e){let t=e.data,a=t.block;a.visible=1,a.childInitialized=1,D(t.listDraft,{parentBlockFragment:a.child,leaf:e})}};exports.block=({fn:e,env:t,namespace:a="html"})=>{let r=b({name:'block',isSvgRoot:0,namespace:a,env:t,draft:{type:'block',childTemplates:[],childCount:0,inParentIndex:0},isBlock:1,fn({},{mount:t}){e(),t.watch(ue.block)}});return()=>{j(oe,'(block instance)');let e={type:'blockItem',childTemplates:[],childCount:0,inParentIndex:-1,itemOf:r},{env:t,namespace:a}=oe;H(b({name:'block item',isSvgRoot:0,namespace:a,env:t,draft:e,fn(e,{mount:t}){t.watch(ue.blockItem)}}))}},exports.h=(e,t)=>{function a(e){return e.data.block.value}function l(e,t,a){let r=e.data.block.child,n={type:'text',parent:r,visible:0,index:a,value:null};if(r.child[a]=n,e.hydration){let a=q(n);if(a)switch(a.type){case'text':n.value=e.env.document.createTextNode(t),a.value.after(n.value);break;case'element':n.value=a.value.nextSibling,y(n.value,t)}else{let e=T(n);n.value=e.firstChild,y(n.value,t)}n.visible=1}else n.value=e.env.document.createTextNode(t),F(n);return n}let i,s=0,c=0;'function'==typeof t?(s=1,i=t):t&&(c=1,t.fn&&(s=1,i=t.fn),t.ɔ&&('function'==typeof t.ɔ?(s=1,i=t.ɔ):'function'==typeof t.ɔ.fn&&(s=1,i=t.ɔ.fn))),j(oe,'h');let u,p=oe.env,f=oe.namespace,h=f,w='html';h=w='svg'===f?'svg':'html','svg'===e&&(w='svg',h='svg'),oe.isBlock||(u='svg'===w?p.document.createElementNS('http://www.w3.org/2000/svg',e):p.document.createElement(e));let P=u,I={type:'element',tag:e,attr:[],data:[],text:[],styleProp:[],styleVar:[],handler:[],stencil:P,seq:[],staticSeq:[],childTemplates:[],childCount:0,inParentIndex:-1,opsAmount:1,node:[]};'foreignObject'===f?(I.attr.push({xmlns:'http://www.w3.org/1999/xhtml'}),h='html'):'svg'===e?(I.attr.push({xmlns:'http://www.w3.org/2000/svg'}),h='svg'):'foreignObject'===e&&(h='foreignObject');let S=b({name:'element',draft:I,isSvgRoot:'svg'===e,namespace:h,fn(e,{mount:u}){function p(e){return J({mount:f,state:e,onMount:(e,t)=>({leaf:t,value:e}),onState:(e,t)=>({leaf:e,value:t})})}let f=effector.createEvent();s&&i(),c&&G(t);let h={attr:{},data:{},text:I.text,styleProp:{},styleVar:{},visible:I.visible||null,handler:I.handler};for(let e=0;e<I.attr.length;e++){let t=I.attr[e];for(let e in t)'xlink:href'===e?h.attr.href=t[e]:h.attr[e]=t[e]}for(let e=0;e<I.data.length;e++){let t=I.data[e];for(let e in t)h.data[e]=t[e]}for(let e=0;e<I.styleProp.length;e++){let t=I.styleProp[e];for(let e in t)e.startsWith('--')?h.styleVar[e.slice(2)]=t[e]:h.styleProp[e]=t[e]}for(let e=0;e<I.styleVar.length;e++){let t=I.styleVar[e];for(let e in t)h.styleVar[e]=t[e]}h.visible&&I.seq.push({type:'visible',value:h.visible});for(let e in h.attr){let t=h.attr[e];effector.is.unit(t)?I.seq.push({type:'attr',field:e,value:t}):I.staticSeq.push({type:'attr',field:e,value:t})}for(let e in h.data){let t=h.data[e];effector.is.unit(t)?I.seq.push({type:'data',field:e,value:t}):I.staticSeq.push({type:'data',field:e,value:t})}for(let e in h.styleProp){let t=h.styleProp[e];effector.is.unit(t)?I.seq.push({type:'style',field:e,value:t}):I.staticSeq.push({type:'style',field:e,value:t})}for(let e in h.styleVar){let t=h.styleVar[e];effector.is.unit(t)?I.seq.push({type:'styleVar',field:e,value:t}):I.staticSeq.push({type:'styleVar',field:e,value:t})}for(let e=0;e<h.text.length;e++){let t=h.text[e];if(null!==t.value)if(effector.is.unit(t.value)){I.seq.push({type:'dynamicText',value:t.value,childIndex:t.index});let e=t.value.stateRef,a=ne;a.plain.includes(e)||a.closure.includes(e)||a.closure.push(e)}else I.seq.push({type:'staticText',value:String(t.value),childIndex:t.index})}for(let e=0;e<h.handler.length;e++){let t=h.handler[e];for(let e in t.map)I.seq.push({type:'handler',for:e,handler:t.map[e],options:t.options,domConfig:t.domConfig})}if(h.visible){let{onMount:e,onState:t}=J({mount:u,state:h.visible,onMount:(e,t)=>({leaf:t,value:e,hydration:t.hydration}),onState:(e,t)=>({leaf:e,value:t,hydration:0})});e.watch(({leaf:e,value:t,hydration:a})=>{let n=e.data,l=n.block;if(a&&(r(t,n.ops.visible),t)){let e,t=A(l);if(e=t?t.nextSibling:T(l).firstChild,'#text'===e.nodeName){let t=e;e=e.nextSibling,t.remove()}l.value=e,l.visible=1}D(I,{parentBlockFragment:l.child,leaf:e,node:l.value,svgRoot:S.isSvgRoot?l.value:null}),t&&n.needToCallNode&&(n.needToCallNode=0,effector.launch({target:ce,params:{element:n.block.value,fns:I.node},page:e.spawn,defer:1,forkPage:e.forkPage})),effector.launch({target:f,params:e,defer:1,page:e.spawn,forkPage:e.forkPage})}),effector.merge([t,e]).watch(({leaf:e,value:t,hydration:a})=>{a||n(t,e.data.ops.visible)})}P&&d(P,I.staticSeq);for(let e=0;e<I.seq.length;e++){let t=I.seq[e];switch(t.type){case'visible':break;case'attr':{let{field:e}=t,r='value'===e||'checked'===e||'min'===e||'max'===e,{onMount:l,onState:i}=p(t.value);if(r)effector.merge([i,l]).watch(({leaf:t,value:r})=>{k(a(t),e,r)});else{let t=I.opsAmount++;l.watch(({value:r,leaf:n})=>{let l=a(n),i=o({value:r,priority:'props',runOp(t){k(l,e,t)},group:n.ops.group});n.ops.group.ops[t]=i,k(l,e,r)}),i.watch(({value:e,leaf:a})=>{n(e,a.ops.group.ops[t])})}break}case'data':{let{field:e}=t,{onMount:r,onState:l}=p(t.value),i=I.opsAmount++;r.watch(({value:t,leaf:r})=>{let n=a(r),l=o({value:t,priority:'props',runOp(t){m(n,e,t)},group:r.ops.group});r.ops.group.ops[i]=l,m(n,e,t)}),l.watch(({value:e,leaf:t})=>{n(e,t.ops.group.ops[i])});break}case'style':{let e=I.opsAmount++,{field:r}=t,{onMount:l,onState:i}=p(t.value);l.watch(({value:t,leaf:n})=>{let l=a(n),i=o({value:t,priority:'props',runOp(e){v(l,r,e)},group:n.ops.group});n.ops.group.ops[e]=i,v(l,r,t)}),i.watch(({value:t,leaf:a})=>{n(t,a.ops.group.ops[e])});break}case'styleVar':{let{field:e}=t,{onMount:r,onState:l}=p(t.value),i=I.opsAmount++;r.watch(({value:t,leaf:r})=>{let n=a(r),l=o({value:t,priority:'props',runOp(t){g(n,e,t)},group:r.ops.group});r.ops.group.ops[i]=l,g(n,e,t)}),l.watch(({value:e,leaf:t})=>{n(e,t.ops.group.ops[i])});break}case'staticText':f.watch(e=>{l(e,t.value,t.childIndex)});break;case'dynamicText':{let e=I.opsAmount++;effector.sample({source:t.value,clock:f,fn:(e,t)=>({value:String(e),leaf:t}),greedy:1}).watch(({value:a,leaf:r})=>{let n=o({value:a,priority:'props',runOp(e){y(i.value,e)},group:r.ops.group});r.ops.group.ops[e]=n;let i=l(r,a,t.childIndex)}),effector.sample({source:f,clock:t.value,fn:(e,t)=>({leaf:e,text:t}),greedy:1}).watch(({leaf:t,text:a})=>{n(a,t.ops.group.ops[e])});break}case'handler':{let e=t.handler.graphite.meta.nativeTemplate||null;f.watch(r=>{let n=null;if(e){let t=0,a=r.spawn;for(;!t&&a;)a.template===e?(t=1,n=a):a=a.parent}a(r).addEventListener(t.for,e=>{t.options.prevent&&e.preventDefault(),t.options.stop&&e.stopPropagation(),effector.launch({target:x(t.handler,r.forkPage),params:e,page:n,forkPage:r.forkPage})},t.domConfig)});break}}}u.watch(e=>{let t=e.data;if(!I.visible){let a=t.ops.visible,l=t.block;if(e.hydration){r(1,a);let e,t=A(l);if(e=t?t.nextSibling:T(l).firstChild,'#text'===e.nodeName){let t=e;e=e.nextSibling,t.remove()}l.value=e,l.visible=1}D(I,{parentBlockFragment:l.child,leaf:e,node:l.value,svgRoot:S.isSvgRoot?l.value:null}),effector.launch({target:f,params:e,defer:1,page:e.spawn,forkPage:e.forkPage}),e.hydration?t.needToCallNode&&(t.needToCallNode=0,effector.launch({target:ce,params:{element:t.block.value,fns:I.node},page:e.spawn,defer:1,forkPage:e.forkPage})):n(1,a)}})},env:p});H(S)},exports.handler=Q,exports.list=Z,exports.node=e=>{j(oe,'node');let t=oe.draft;switch(t.type){case'list':case'listItem':case'using':case'route':case'rec':case'recItem':case'block':case'blockItem':return void console.error('node() hook supported only in h() nodes')}t.node.push(e)},exports.rec=W,exports.remap=N,exports.route=U,exports.spec=G,exports.text=(e,...t)=>{let a=[e[0]];for(let r=0;r<t.length;r++)a.push(t[r],e[r+1]);G({text:a})},exports.tree=({source:e,key:t,child:a,fn:r})=>{let n=W(({store:e})=>{Z({source:e,key:t,fn({store:e}){let t=e.map(e=>e[a]||[]);r({store:e,child(){n({store:t})}})}})});n({store:e})},exports.using=(e,t)=>{let a,r,n,l,o,c;if('function'==typeof t)a=t,n=z(),l=0;else{if(!t)throw Error('using() second argument is missing');a=t.fn,n=t.env?t.env:z(),l=t.hydrate,r=t.onComplete,o=t.onRoot,c=t.scope}L(e,'using() first argument is missing');let u=e.namespaceURI,p=e.tagName.toLowerCase(),f={type:'using',childTemplates:[],childCount:0,inParentIndex:-1},d=b({name:'using',draft:f,isSvgRoot:'svg'===p,namespace:'http://www.w3.org/2000/svg'===u?'svg':'foreignobject'===p?'foreignObject':'html',fn(e,{mount:t}){a(),t.watch(ue.using)},env:n}),h={type:'using',child:{type:'fragment',parent:null,child:[]},value:e};h.child.parent=h,(e=>{if(e&&!e.nodeMap){let t={};for(let a=0;a<e.clones.length;a++){let r=e.clones[a];t[r.meta.forkOf.id]=r}e.nodeMap=t}})(c);let g=i({onComplete:r}),v=C(d,{parentLeaf:le||null,mountNode:e,svgRoot:d.isSvgRoot?e:le?le.svgRoot:null,leafData:{type:'using',draft:f,element:e,block:h},opGroup:s(g),domSubtree:s(g),hydration:l,forkPage:c,env:n});if(o&&o({template:d,leaf:v}),g.onDrain&&!g.rafID){let e=g.onDrain;g.onDrain=null,e()}},exports.variant=({source:e,cases:t,key:a})=>{let r;j(oe,'variant'),L(effector.is.unit(e),'variant({source}) should be unit'),r='function'==typeof a?a:null==a?e=>String(e):e=>String(e[a]);let n=0;for(let a in t)'__'!==a?U({source:e,visible:e=>r(e)===a,fn:t[a]}):n=1;if(n){let a=Object.keys(t);U({source:e,visible:e=>!a.includes(r(e)),fn:t.__})}}; | ||
//# sourceMappingURL=forest.cjs.js.map |
@@ -197,2 +197,7 @@ import {Store, Event, Fork} from 'effector' | ||
}): void | ||
export function route<T>(config: { | ||
source: Store<T> | ||
visible: Store<boolean> | ||
fn: (config: {store: Store<T>}) => void | ||
}): void | ||
@@ -199,0 +204,0 @@ export function node(fn: (node: DOMElement) => void): void |
@@ -197,2 +197,7 @@ import {Store, Event, Fork} from 'effector' | ||
}): void | ||
export function route<T>(config: { | ||
source: Store<T> | ||
visible: Store<boolean> | ||
fn: (config: {store: Store<T>}) => void | ||
}): void | ||
@@ -199,0 +204,0 @@ export function node(fn: (node: DOMElement) => void): void |
@@ -1,2 +0,2 @@ | ||
((e,t)=>{'object'==typeof exports&&'undefined'!=typeof module?t(exports,require('effector')):'function'==typeof define&&define.amd?define(['exports','effector'],t):t((e=e||self).forest={},e.effector)})(this,(e,effector)=>{function t(e,t){e.cursor[t].prev&&(e.cursor[t].prev.cursor[t].next=e.cursor[t].next),e.cursor[t].next&&(e.cursor[t].next.cursor[t].prev=e.cursor[t].prev),e.queue[t].last===e&&(e.queue[t].last=e.cursor[t].prev),e.queue[t].first===e&&(e.queue[t].first=e.cursor[t].next),e.cursor[t].prev=null,e.cursor[t].next=null}function a(e){e.status='active',((e,t)=>{t.cursor.prev&&(t.cursor.prev.cursor.next=t.cursor.next),t.cursor.next&&(t.cursor.next.cursor.prev=t.cursor.prev),e.last===t&&(e.last=t.cursor.prev),e.first===t&&(e.first=t.cursor.next),t.cursor.prev=null,t.cursor.next=null})(r(e),e)}function r(e){return e.group.activeChilds[e.priority]}function l(e,t){t.value.active=t.value.pending=e,'active'!==t.status&&a(t)}function n(e,l){if(l.value.active===e)return l.value.pending=e,void('pending'===l.status&&(a(l),r(l).first||t(l.group,l.priority)));'active'===l.status&&(l.status='pending',r(l).first||((e,t)=>{e.queue[t].last?(e.cursor[t].prev=e.queue[t].last,e.queue[t].last.cursor[t].next=e,e.queue[t].last=e):e.queue[t].first=e.queue[t].last=e})(l.group,l.priority),((e,t)=>{e.last?(t.cursor.prev=e.last,e.last.cursor.next=t,e.last=t):e.first=e.last=t})(r(l),l)),l.value.pending=e,l.group.queue.rafID||(l.group.queue.rafID=Y(l.group.queue.execQueue))}function o(e){J('execQueue');let r,l,n=X(),o=0;e:for(;e.props.first||e.tree.first||e.data.first;){if(X()-n>=10){o=1;break e}let i=!!e.props.first;for(i&&J('props');r=e.props.first;){for(;l=r.activeChilds.props.first;){if(X()-n>=10){o=1,K('props');break e}l.runOp(l.value.pending),l.value.active=l.value.pending,a(l)}t(r,'props')}i&&K('props');let s=!!e.tree.first;for(s&&J('tree');r=e.tree.first;){for(;l=r.activeChilds.tree.first;){if(X()-n>=10){o=1,K('tree');break e}l.runOp(l.value.pending),l.value.active=l.value.pending,a(l)}t(r,'tree')}s&&K('tree');let c=!!e.data.first;for(c&&J('data');r=e.data.first;){for(;l=r.activeChilds.data.first;){if(X()-n>=10){o=1,K('data');break e}l.runOp(l.value.pending),l.value.active=l.value.pending,a(l)}t(r,'data')}c&&K('data')}if(K('execQueue'),o)e.rafID=Y(e.execQueue);else if(e.rafID=null,e.onDrain){let t=e.onDrain;e.onDrain=null,t()}}function i({value:e,runOp:t,group:a,priority:r}){return{value:{active:e,pending:e},runOp:t,status:'active',priority:r,group:a,cursor:{prev:null,next:null}}}function s({onComplete:e}){let t={props:{first:null,last:null},tree:{first:null,last:null},data:{first:null,last:null},rafID:null,execQueue(){},onDrain:e};return t.execQueue=o.bind(null,t),t}function c(e){return{ops:[],queue:e,activeChilds:{props:{first:null,last:null},tree:{first:null,last:null},data:{first:null,last:null}},cursor:{props:{prev:null,next:null},tree:{prev:null,next:null},data:{prev:null,next:null}}}}function u({value:e,group:t,onInit:a,onChange:r,onTerminate:l}){let o=i({value:e,group:t,runOp(e){s.status='A',r(e)},priority:'data'}),s={status:'IA',value:o.value,hooks:{onTerminate:l},ops:{init:i({value:0,group:t,runOp(e){s.status='A',a(s.value.active)},priority:'data'}),change:o,terminate:i({value:0,group:t,runOp(e){s.status='T',s.hooks.onTerminate(1)},priority:'data'})}};return n(1,s.ops.init),s}function p(e){switch(e.status){case'I':case'T':case'AT':return;case'A':e.status='AT',n(1,e.ops.terminate);break;case'AA':e.status='AT',n(1,e.ops.terminate),n(e.value.active,e.ops.change);break;case'IA':e.status='T',n(0,e.ops.init),e.hooks.onTerminate(0)}}function f(e,t){switch(t.status){case'I':case'T':return;case'A':t.value.active!==e&&(t.status='AA',n(e,t.ops.change));break;case'AA':t.value.active===e?(t.status='A',n(e,t.ops.change)):t.value.pending!==e&&(t.value.pending=e);break;case'IA':t.value.active=t.value.pending=e}}function d(e){switch(e=String(e)){case'__proto__':case'__defineGetter__':case'__defineSetter__':case'constructor':case'prototype':case'hasOwnProperty':case'toString':case'valueOf':case'setProperty':case'removeProperty':return'forbidden';default:return e.replace(/[^a-zA-Z0-9\-_]/g,'')}}function h(e,t){for(let a=0;a<t.length;a++){let{type:r,field:l,value:n}=t[a];ee[r](e,l,n)}}function g(e){return''!==e&&0!==e&&'0'!==e&&(0==e||null==e)}function v(e,t,a){g(a)?e.style.removeProperty("--"+t):e.style.setProperty("--"+t,""+a)}function m(e,t,a){g(a)?delete e.style[t]:e.style[t]=""+a}function k(e,t,a){g(a)?delete e.dataset[t]:e.dataset[t]=""+a}function y(e,t,a){if(g(a)){switch(t){case'value':delete e.value;break;case'checked':e.checked=0;break;case'spellcheck':if(0==a)return void e.setAttribute('spellcheck','false')}e.removeAttribute(t)}else{switch(t){case'value':e.value=""+a;break;case'checked':e.checked=""+a}e.setAttribute(t,""+a)}}function b(e,t){e.replaceData(0,(e.textContent||'').length,String(t))}function w({fn:e,state:t={},defer:a=0,name:r="",draft:l,isSvgRoot:n,namespace:o,env:i,isBlock:s=0}){let c=ne,u=re,p={id:++te,name:r,plain:[],watch:[],nameMap:{},pages:[],closure:[],childTemplates:[],upward:effector.step.filter({fn(e,t,a){if(!a.page){if(!a.parent||!a.parent.page)return 1;a.page=a.parent.page}if(!a.page.active)return console.count('inactive page upward'),0;let r=[a.page.template],l=[a.page];{let e=a.page.parent;for(;e;)l.push(e),r.push(e.template),e=e.parent}return a.node.next.forEach(t=>{let n=t.meta.nativeTemplate;n?r.includes(n)?effector.launch({target:x(t,a.forkPage),params:e,defer:1,page:l[r.indexOf(n)],stack:a,forkPage:a.forkPage}):console.error('context drift',{stack:a,node:t}):effector.launch({target:x(t,a.forkPage),params:e,defer:1,page:null,stack:a,forkPage:a.forkPage})}),0}}),loader:effector.step.filter({fn(e,t,a){if(a.parent){let r=a.forkPage?a.forkPage.graphite.id:null;if(a.page){if(!a.page.active)return console.count('inactive page loader'),0;if(a.page.template===p)return 1;if(a.page.childSpawns[p.id])a.page.childSpawns[p.id].forEach(t=>{(!r||t.leaf.forkPage&&r===t.leaf.forkPage.graphite.id)&&effector.launch({params:e,target:x(a.node,a.forkPage),page:t,defer:1,forkPage:a.forkPage})});else if(t.targetTemplate){let r=[a.page];{let e=a.page.parent;for(;e;)r.push(e),e=e.parent}let l=r.findIndex(e=>t.targetTemplate===e.template);effector.launch(-1===l?{params:e,target:x(a.node,a.forkPage),page:null,defer:1,forkPage:a.forkPage}:{params:e,target:x(a.node,a.forkPage),page:r[l],defer:1,forkPage:a.forkPage})}else p.pages.forEach(t=>{(!r||t.leaf.forkPage&&r===t.leaf.forkPage.graphite.id)&&t.fullID.startsWith(a.page.fullID)&&effector.launch({params:e,target:x(a.node,a.forkPage),page:t,defer:1,forkPage:a.forkPage})})}else p.pages.forEach(t=>{(!r||t.leaf.forkPage&&r===t.leaf.forkPage.graphite.id)&&effector.launch({params:e,target:x(a.node,a.forkPage),page:t,defer:1,forkPage:a.forkPage})});return 0}return 1}}),parent:u};u&&u.childTemplates.push(p);let f=effector.createNode({meta:{template:p}});re=p;let d=ne={template:p,node:f,api:null,trigger:{mount:effector.createEvent()},draft:l,isSvgRoot:n,namespace:o,env:i,isBlock:s||!(!c||!c.isBlock)};return a?d.deferredInit=()=>{let a=ne,r=re;ne=d,re=p,d.deferredInit=null;try{effector.withRegion(f,()=>{let a=effector.restore(t);d.api=e(a,d.trigger),p.nameMap=a})}finally{ne=a,re=r}}:effector.withRegion(f,()=>{let a=effector.restore(t);d.api=e(a,d.trigger),p.nameMap=a}),ne=c,re=u,p.actor=d,d}function x(e,t){return t&&t.nodeMap[(e=e.graphite||e).id]||e}function P(e,t){let a=e;switch(t&&oe(t,e)&&(a=oe(t,e)),e.type){case'list':return[...a.current];case'shape':return{...a.current};default:return a.current}}function I(e,t,a){let r=t;for(;r&&!oe(r.spawn,e);)r=r.parentLeaf;return r?oe(r.spawn,e):a&&oe(a,e)?oe(a,e):e}function S(e,t,a){return I(e,t,a).current}function C(e,t){oe(t.spawn,e)||(t.spawn.reg[e.id]=I(e,t.parentLeaf,t.forkPage))}function T(e,{values:t={},parentLeaf:a,mountNode:r,svgRoot:l,leafData:n,opGroup:o,domSubtree:i,hydration:s,forkPage:c,env:u}){function p(e){if(e.before)for(let t=0;t<e.before.length;t++){let a=e.before[t];switch(a.type){case'map':{let t=a.from;C(t,k),g[e.id].current=a.fn(g[t.id].current);break}case'field':{let t=a.from;C(t,k),g[e.id].current[a.field]=g[t.id].current;break}case'closure':C(a.of,k)}}if(!e.after)return;let t=g[e.id].current;for(let a=0;a<e.after.length;a++){let r=e.after[a],l=r.to;switch(g[l.id]||(g[l.id]={id:l.id,current:S(l,k.parentLeaf,c)}),r.type){case'copy':g[l.id].current=t;break;case'map':g[l.id].current=r.fn(t)}}}function f(e,t,a){let r;t.stop=1;try{for(;t.i<e.length;)r=e[t.i],t.i++,r.fn(a[r.of.id]?a[r.of.id].current:S(r.of,k.parentLeaf,c))}catch(e){console.error(e),t.stop=0}}!u&&a&&(u=a.env);let d=a?a.spawn:null,h=e.template,g={},v={id:++ae,fullID:'',reg:g,template:h,parent:d,childSpawns:{},active:1};h.pages.push(v);let m={},k={actor:e,spawn:v,api:m,draft:e.draft,ops:{group:o,domSubtree:i},svgRoot:l,data:n,parentLeaf:a,hydration:s,forkPage:c,env:u,mountNode:r},y=le;le=k,d&&(d.childSpawns[h.id]||(d.childSpawns[h.id]=[]),d.childSpawns[h.id].push(v)),v.fullID=d?`${d.fullID}_${v.id}`:""+v.id;for(let e=0;e<h.closure.length;e++){let t=h.closure[e],a=t,r=v.parent;e:for(;r;){if(oe(r,t)){a=oe(r,t);break e}r=r.parent}!r&&c&&oe(c,t)&&(a=oe(c,t)),g[t.id]=a}for(let e=0;e<h.plain.length;e++){let t=h.plain[e],a={id:t.id,current:P(t,c)};g[t.id]=a}for(let e in t){let a=h.nameMap[e].stateRef.id;g[a]={id:a,current:t[e]}}h.closure.forEach(p),h.plain.forEach(p);let b={i:0,stop:0};for(;!b.stop;)f(h.watch,b,g);if(d)for(let e in v.childSpawns)e in d.childSpawns||(d.childSpawns[e]=[]),d.childSpawns[e].push(...v.childSpawns[e]);if(m.mount=(t,a=1)=>(e=>{if(ie)return void ie.steps.push(e);let t;ie={parent:ie,steps:[e]};do{for(;t=ie.steps.shift();)ie={parent:ie,steps:[]},effector.launch(t)}while(ie=ie.parent)})({target:e.trigger.mount,params:t,defer:a,page:v,forkPage:c}),e.api)for(let t in e.api)m[t]=(a,r=1)=>effector.launch({target:e.api[t],params:a,defer:r,page:v,forkPage:c});return k.spawn.api=m,k.spawn.leaf=k,k.api.mount(k),le=y,k}function R(e){let t=function e(t){switch(t.type){case'using':return t;case'fragment':switch(t.parent.type){case'element':case'using':return t.parent}default:return e((e=>{switch(e.type){case'text':case'element':case'list':case'route':case'rec':case'recItem':case'block':case'blockItem':return e.parent;case'fragment':default:switch(e.parent.type){case'using':case'block':return e.parent;default:return e.parent.parent}}})(t))}}(e);return t?t.value:null}function q(e){if(!e.visible)return null;switch(e.type){case'text':case'element':return e;case'route':return q(e.child);case'LF':case'RF':case'FF':case'rec':case'recItem':case'block':case'blockItem':return(e=>{let t=e.child;for(let e=t.length-1;e>=0;e--){let a=q(t[e]);if(a)return a}return null})(e.child);case'list':{let t=e.lastChild;if(!t)return null;for(;t;){let e=q(t);if(e)return e;t=t.left}return null}default:return null}}function A(e){switch(e.type){case'fragment':switch(e.parent.type){case'element':case'using':return null;case'RF':{let t=e.parent.parent,a=t.parent;for(let e=t.index-1;e>=0;e--){let t=q(a.child[e]);if(t)return t}return A(a)}case'rec':case'recItem':case'block':case'blockItem':case'FF':{let t=e.parent,a=t.parent;for(let e=t.index-1;e>=0;e--){let t=q(a.child[e]);if(t)return t}return A(a)}case'LF':{let t=e.parent.left;for(;t;){let e=q(t);if(e)return e;t=t.left}return A(e.parent.parent)}default:return null}case'element':case'text':case'route':case'rec':case'recItem':case'block':case'blockItem':case'list':{let t=e.parent;for(let a=e.index-1;a>=0;a--){let e=t.child[a];if(!e)continue;let r=q(e);if(r)return r}return A(t)}default:return null}}function D(e){let t=A(e);return t?t.value:null}function E(e,{parentBlockFragment:t,leaf:a,node:r,svgRoot:l,values:n}){e.childTemplates.forEach(e=>{O({parentBlockFragment:t,leaf:a,node:r,svgRoot:l,values:n,actor:e})})}function O({parentBlockFragment:e,leaf:t,node:a=t.mountNode,actor:r,svgRoot:l,values:n}){let o,{draft:s}=r,{queue:u}=t.ops.group,p=c(u),f=t.ops.domSubtree,d=f;switch(s.type){case'route':{let t={type:'route',parent:e,child:{type:'RF',parent:null,child:{type:'fragment',parent:null,child:[]},visible:0},visible:1,index:s.inParentIndex};t.child.parent=t,t.child.child.parent=t.child,e.child[s.inParentIndex]=t,o={type:'route',block:t,ops:{},initialized:0};break}case'element':{let a;if(r.isBlock){let e,r,l=t;for(;l&&(!r||!e);){l.actor.env&&(e=l.actor.env);let{draft:t}=l;'element'===t.type&&('svg'===t.tag?r='svg':'foreignObject'===t.tag&&(r='html')),l=l.parentLeaf}r||(r='html'),e&&(a='svg'===r?e.document.createElementNS('http://www.w3.org/2000/svg',s.tag):e.document.createElement(s.tag),h(a,s.staticSeq))}else a=s.stencil.cloneNode();let l={type:'element',parent:e,child:{type:'fragment',parent:null,child:[]},value:a,visible:0,index:s.inParentIndex};l.child.parent=l,e.child[s.inParentIndex]=l,o={type:'element',block:l,ops:{visible:i({value:0,priority:'tree',runOp(e){e?(F(l),o.needToCallNode&&(o.needToCallNode=0,effector.launch({target:se,params:{element:l.value,fns:s.node},page:g.spawn,forkPage:t.forkPage}))):(l.value.remove(),l.visible=0)},group:f})},needToCallNode:s.node.length>0},d=c(u);break}case'list':{let t={type:'list',parent:e,child:[],lastChild:null,visible:1,index:s.inParentIndex};e.child[s.inParentIndex]=t,o={type:'list',draft:s,block:t,records:[]};break}case'using':case'listItem':break;case'rec':{let t={type:'rec',parent:e,child:{type:'fragment',parent:null,child:[]},visible:1,index:s.inParentIndex};t.child.parent=t,e.child[s.inParentIndex]=t,o={type:'rec',block:t};break}case'recItem':{let t={type:'recItem',parent:e,child:{type:'fragment',parent:null,child:[]},visible:1,index:s.inParentIndex};t.child.parent=t,e.child[s.inParentIndex]=t,o={type:'rec item',block:t};break}case'block':{let t={type:'block',parent:e,child:{type:'fragment',parent:null,child:[]},visible:1,index:s.inParentIndex};t.child.parent=t,e.child[s.inParentIndex]=t,o={type:'block',block:t};break}case'blockItem':{let t={type:'blockItem',parent:e,child:{type:'fragment',parent:null,child:[]},visible:1,index:s.inParentIndex};t.child.parent=t,e.child[s.inParentIndex]=t,o={type:'block item',block:t};break}default:console.warn("unexpected draft type "+s.type)}let g=T(r,{values:n,parentLeaf:t,mountNode:a,svgRoot:l||t.svgRoot,leafData:o,opGroup:p,domSubtree:d,hydration:t.hydration,forkPage:t.forkPage})}function F(e){let t=D(e);t?t.after(e.value):R(e).prepend(e.value),e.visible=1}function N(e,t){if(Array.isArray(t))return t.map(t=>e.map(e=>e[t]));if('object'==typeof t&&null!==t){let a={};for(let r in t){let l=t[r];a[r]=e.map('function'==typeof l?e=>l(e):e=>e[l])}return a}return e.map(e=>e[t])}function M(e,t){let{spawn:a}=e;for(let e in a.childSpawns){let r=a.childSpawns[e];for(let e=0;e<r.length;e++)t(r[e].leaf)}}function B(e){e.spawn.active=0,M(e,_)}function V({spawn:e}){L(e,e.parent.childSpawns[e.template.id]),L(e,e.template.pages)}function _(e){let{spawn:t,data:a}=e;switch(a.type){case'element':L(t,t.parent.childSpawns[t.template.id]),function e(t){t.active=0,L(t,t.template.pages);for(let a in t.childSpawns)t.childSpawns[a].forEach(e)}(t),n(0,a.ops.visible);break;case'list':{let t=a.records;for(let e=0;e<t.length;e++){let a=t[e];a.instance&&_(a.instance),a.active=0}e.spawn.active=0,V(e);break}case'list item':{let t=a.block;L(t,t.parent.child);let r=t.left,l=t.right;r&&(r.right=l,l||t.parent.lastChild!==t||(t.parent.lastChild=r)),l&&(l.left=r),r||l||t.parent.lastChild!==t||(t.parent.lastChild=null),t.left=null,t.right=null,B(e),V(e);break}case'route':B(e),V(e);break;case'block':case'block item':case'rec':case'rec item':B(e)}}function L(e,t){if(!t)return;let a=t.indexOf(e);-1!==a&&t.splice(a,1)}function j(){if('undefined'!=typeof document)return{document};throw Error('your environment has no document')}function z(e){let t=ne.draft;switch(t.type){case'list':return void(e.visible&&(t.itemVisible=e.visible));case'listItem':case'using':case'route':case'rec':case'recItem':case'block':case'blockItem':return}if(e.attr&&t.attr.push(e.attr),e.data&&t.data.push(e.data),'text'in e){let a=e.text,r=t.childCount;Array.isArray(a)?(t.text.push(...a.map((e,t)=>({index:t+r,value:e}))),t.childCount+=a.length):(t.text.push({index:r,value:a}),t.childCount+=1)}if(e.style){let a={};for(let t in e.style)a[d(t)]=e.style[t];t.styleProp.push(a)}if(e.styleVar&&t.styleVar.push(e.styleVar),e.visible&&(t.visible=e.visible),e.handler){let t=e.handler;'object'==typeof t.on?G(t.config||{},t.on):G(t)}e.ɔ&&z(e.ɔ)}function G(e,t){if(!ne)return;let a=ne.draft;if('element'!==a.type)throw Error(`"handler" extension can be used only with element nodes, got "${a.type}"`);void 0===t&&(t=e,e={});for(let e in t)if(!effector.is.unit(t[e]))throw Error(`handler for "${e}" should be event`);let{passive:r=0,capture:l=0,prevent:n=0,stop:o=0}=e;a.handler.push({options:{prevent:n,stop:o},domConfig:{passive:n?0:r,capture:l},map:t})}function Q({source:e,visible:t,fn:a}){if(!ne)throw Error('route() called outside from using() closure');let r=w({name:'route',isSvgRoot:0,namespace:ne.namespace,env:ne.env,draft:{type:'route',childTemplates:[],childCount:0,inParentIndex:-1},fn(r,{mount:l}){let n=e.map(e=>({value:e,visible:t(e)})),o=w({name:'route item',isSvgRoot:0,namespace:ne.namespace,env:ne.env,draft:{type:'route',childTemplates:[],childCount:0,inParentIndex:-1},state:{store:null},fn({store:e},{mount:t}){let r=effector.createEvent();e.on(r,(e,t)=>t),a({store:e});let l=effector.sample({source:t,clock:n,fn:(e,{visible:t,value:a})=>({leaf:e,visible:t,value:a}),greedy:1});t.watch(ce.routeItem),l.watch(({leaf:e,visible:t,value:a})=>{e.data.block.child.visible=t,t&&effector.launch({target:r,params:a,defer:1,page:e.spawn,forkPage:e.forkPage}),U(t,e)})}});Z(o);let{onMount:i,onState:s}=H({mount:l,state:n,onMount:({visible:e,value:t},a)=>({leaf:a,visible:e,value:t}),onState:(e,{visible:t,value:a})=>({leaf:e,visible:t,value:a})});effector.merge([i,s]).watch(({leaf:e,visible:t,value:a})=>{let r=e.data;r.block.child.visible=t,t&&!r.initialized&&(O({parentBlockFragment:r.block.child.child,leaf:e,actor:o,values:{store:a}}),r.initialized=1)})}});Z(r)}function U(e,t){let a=t=>{let r=t.data;switch(r.type){case'element':n(e,r.ops.visible);break;case'route':case'list':case'list item':M(t,a);break;default:console.log('unsupported type',r.type)}};M(t,a)}function $(e){let t='function'==typeof e?e:e.fn,a=w({name:'rec',state:{store:null},isSvgRoot:0,namespace:null,env:null,draft:{type:'rec',childTemplates:[],childCount:0,inParentIndex:0},defer:1,isBlock:1,fn({store:e},{mount:a}){t({store:e,state:e});let r=effector.createEvent();return e.on(r,(e,t)=>t),a.watch(ce.rec),{itemUpdater:r}}});return({store:e,state:t=e})=>{a.deferredInit&&a.deferredInit();let{env:r,namespace:l}=ne;Z(w({name:'rec item',isSvgRoot:0,namespace:l,env:r,draft:{type:'recItem',childTemplates:[],childCount:0,inParentIndex:-1},fn(e,{mount:r}){let{onMount:l,onState:n}=H({state:t,mount:r,onMount:(e,t)=>({state:e,leaf:t}),onState:(e,t)=>({state:t,leaf:e})});n.watch(({state:e,leaf:t})=>{M(t,t=>{t.api.itemUpdater(e)})}),l.watch(({leaf:e,state:t})=>{O({parentBlockFragment:e.data.block.child,leaf:e,actor:a,values:{store:t}})})}}))}}function W(e,t){'function'==typeof t&&(effector.is.unit(e)?e={source:e,fn:t}:e.fn=t);let{fn:a,key:r,source:l,fields:n=[]}=e,o=void 0!==r?'function'==typeof r?r:e=>e[r]:(e,t)=>t,i={type:'list',key:effector.is.store(e)?{type:'index'}:{type:'key',key:e.key},childTemplates:[],childCount:0,inParentIndex:-1};if(!ne)throw Error('list() called outside from using() closure');let s=ne.env,d=ne.namespace;Z(w({name:'list',draft:i,isSvgRoot:0,namespace:d,fn(e,{mount:t}){let r=w({name:'list item',state:{id:-1,store:null},draft:i,isSvgRoot:0,namespace:d,fn({id:e,store:t},{mount:r}){a({store:t,key:e,fields:N(t,n)});let l=effector.createEvent();if(t.on(l,(e,t)=>t),i.itemVisible){let{onMount:e,onState:t}=H({mount:r,state:i.itemVisible,onMount:(e,t)=>({visible:e,leaf:t}),onState:(e,t)=>({visible:t,leaf:e})});e.watch(({visible:e,leaf:t})=>{let a=t.data.block;a.visible=e,a.childInitialized=e,e&&E(i,{parentBlockFragment:a.child,leaf:t})}),t.watch(({visible:e,leaf:t})=>{let a=t.data.block;a.visible=e,a.childInitialized?U(e,t):e&&(a.childInitialized=1,E(i,{parentBlockFragment:a.child,leaf:t}))})}else r.watch(ce.listItem);return{itemUpdater:l}},env:s}),h=effector.createStore([]),g=l.map(e=>e),v=effector.sample({source:l,clock:t,fn:(e,t)=>({updates:e,leaf:t,hydration:t.hydration}),greedy:1}),m=effector.sample({source:v,clock:g,fn:({leaf:e},t)=>({updates:t,leaf:e,hydration:0}),greedy:1});effector.sample({source:h,clock:[v,m],greedy:1,fn(e,{updates:t,leaf:a,hydration:n}){let s=a.data,d=s.block;J('list update ['+l.shortName+']');let h=Array(t.length).fill(0),g=t.map(o),v=[];for(let a=0;a<e.length;a++){let r=e[a],l=g.indexOf(r.key);-1!==l?(v.push(r),h[l]=1,f(t[l],r.asyncValue)):(r.active=0,r.instance&&_(r.instance),p(r.asyncValue))}for(let e=0;e<t.length;e++){if(h[e])continue;let l=t[e],o=g[e],s=c(a.ops.group.queue),p={type:'LF',parent:d,child:{type:'fragment',parent:null,child:[]},childInitialized:0,visible:0,left:null,right:null},f={type:'listItem',key:o,index:o,active:1,leafData:{type:'list item',block:p,listDraft:i},asyncValue:u({value:l,group:s,onTerminate(e){},onChange(e){f.instance&&f.instance.api.itemUpdater(e)},onInit(e){f.active&&(n||(f.instance=T(r,{values:{id:o,store:e},parentLeaf:a,mountNode:a.mountNode,svgRoot:a.svgRoot,leafData:f.leafData,opGroup:s,domSubtree:a.ops.domSubtree,hydration:n,forkPage:a.forkPage})))}})},m=v.length;v.push(f);let k=m>0?v[m-1].leafData:null;if(p.child.parent=p,d.child.push(p),k){let e=k.block;p.left=e;let t=e.right;t?(t.left=p,p.right=t):d.lastChild=p,e.right=p}else d.lastChild=p;n&&(f.instance=T(r,{values:{id:o,store:l},parentLeaf:a,mountNode:a.mountNode,svgRoot:a.svgRoot,leafData:f.leafData,opGroup:s,domSubtree:a.ops.domSubtree,hydration:n,forkPage:a.forkPage}))}return K('list update ['+l.shortName+']'),0===v.length&&(d.lastChild=null),s.records=v,v},target:h})},env:s}))}function Z(e){if(!ne)return;let{draft:t}=e;if('listItem'!==t.type&&'rec'!==t.type)switch(ne.draft.type){case'element':case'using':case'route':case'list':case'rec':case'recItem':case'block':case'blockItem':t.inParentIndex=ne.draft.childCount,ne.draft.childCount+=1,ne.draft.childTemplates.push(e);break;default:console.warn("unexpected currentActor type "+ne.draft.type)}}function H({mount:e,state:t,onMount:a,onState:r}){return{onMount:effector.sample({source:t,clock:e,fn:a,greedy:1}),onState:effector.sample({source:e,clock:t,fn:r,greedy:1})}}let J,K,X;'undefined'!=typeof performance&&performance.mark?(J=e=>{performance.mark('☄️ '+e+' start')},K=e=>{try{performance.measure('☄️ '+e,'☄️ '+e+' start')}catch(e){}performance.clearMarks('☄️ '+e+' start'),performance.clearMeasures('☄️ '+e)}):(J=()=>{},K=()=>{}),X='undefined'!=typeof performance&&performance.now?()=>performance.now():'undefined'!=typeof process&&process.hrtime?()=>{let e=process.hrtime();return(1e9*e[0]+e[1])/1e6}:()=>Date.now();let Y='undefined'!=typeof requestAnimationFrame?requestAnimationFrame:e=>setTimeout(e,0);const ee={attr:y,data:k,style:m,styleVar:v};let te=0,ae=0,re=null,le=null,ne=null;const oe=(e,t)=>e.reg[t.id];let ie=null,se=effector.createEvent();se.watch(({fns:e,element:t})=>{e.forEach(e=>{e(t)})});const ce={using(e){let t=e.data;E(t.draft,{parentBlockFragment:t.block.child,leaf:e})},routeItem(e){let t=e.draft,a=e.data;a.block.child.visible=1,E(t,{parentBlockFragment:a.block.child.child,leaf:e})},block(e){E(e.draft,{parentBlockFragment:e.data.block.child,leaf:e})},blockItem(e){O({parentBlockFragment:e.data.block.child,leaf:e,actor:e.draft.itemOf})},rec(e){E(e.draft,{parentBlockFragment:e.data.block.child,leaf:e})},listItem(e){let t=e.data,a=t.block;a.visible=1,a.childInitialized=1,E(t.listDraft,{parentBlockFragment:a.child,leaf:e})}};e.block=({fn:e,env:t,namespace:a="html"})=>{let r=w({name:'block',isSvgRoot:0,namespace:a,env:t,draft:{type:'block',childTemplates:[],childCount:0,inParentIndex:0},isBlock:1,fn({},{mount:t}){e(),t.watch(ce.block)}});return()=>{let e={type:'blockItem',childTemplates:[],childCount:0,inParentIndex:-1,itemOf:r},{env:t,namespace:a}=ne;Z(w({name:'block item',isSvgRoot:0,namespace:a,env:t,draft:e,fn(e,{mount:t}){t.watch(ce.blockItem)}}))}},e.h=(e,t)=>{function a(e){return e.data.block.value}function r(e,t,a){let r=e.data.block.child,l={type:'text',parent:r,visible:0,index:a,value:null};if(r.child[a]=l,e.hydration){let a=A(l);if(a)switch(a.type){case'text':l.value=e.env.document.createTextNode(t),a.value.after(l.value);break;case'element':l.value=a.value.nextSibling,b(l.value,t)}else{let e=R(l);l.value=e.firstChild,b(l.value,t)}l.visible=1}else l.value=e.env.document.createTextNode(t),F(l);return l}let o,s=0,c=0;if('function'==typeof t?(s=1,o=t):t&&(c=1,t.fn&&(s=1,o=t.fn),t.ɔ&&('function'==typeof t.ɔ?(s=1,o=t.ɔ):'function'==typeof t.ɔ.fn&&(s=1,o=t.ɔ.fn))),!ne)throw Error('h() called outside from using() closure');let u,p=ne.env,f=ne.namespace,d=f,g='html';d=g='svg'===f?'svg':'html','svg'===e&&(g='svg',d='svg'),ne.isBlock||(u='svg'===g?p.document.createElementNS('http://www.w3.org/2000/svg',e):p.document.createElement(e));let P=u,I={type:'element',tag:e,attr:[],data:[],text:[],styleProp:[],styleVar:[],handler:[],stencil:P,seq:[],staticSeq:[],childTemplates:[],childCount:0,inParentIndex:-1,opsAmount:1,node:[]};'foreignObject'===f?(I.attr.push({xmlns:'http://www.w3.org/1999/xhtml'}),d='html'):'svg'===e?(I.attr.push({xmlns:'http://www.w3.org/2000/svg'}),d='svg'):'foreignObject'===e&&(d='foreignObject');let S=w({name:'element',draft:I,isSvgRoot:'svg'===e,namespace:d,fn(e,{mount:u}){function p(e){return H({mount:f,state:e,onMount:(e,t)=>({leaf:t,value:e}),onState:(e,t)=>({leaf:e,value:t})})}let f=effector.createEvent();s&&o(),c&&z(t);let d={attr:{},data:{},text:I.text,styleProp:{},styleVar:{},visible:I.visible||null,handler:I.handler};for(let e=0;e<I.attr.length;e++){let t=I.attr[e];for(let e in t)'xlink:href'===e?d.attr.href=t[e]:d.attr[e]=t[e]}for(let e=0;e<I.data.length;e++){let t=I.data[e];for(let e in t)d.data[e]=t[e]}for(let e=0;e<I.styleProp.length;e++){let t=I.styleProp[e];for(let e in t)e.startsWith('--')?d.styleVar[e.slice(2)]=t[e]:d.styleProp[e]=t[e]}for(let e=0;e<I.styleVar.length;e++){let t=I.styleVar[e];for(let e in t)d.styleVar[e]=t[e]}d.visible&&I.seq.push({type:'visible',value:d.visible});for(let e in d.attr){let t=d.attr[e];effector.is.unit(t)?I.seq.push({type:'attr',field:e,value:t}):I.staticSeq.push({type:'attr',field:e,value:t})}for(let e in d.data){let t=d.data[e];effector.is.unit(t)?I.seq.push({type:'data',field:e,value:t}):I.staticSeq.push({type:'data',field:e,value:t})}for(let e in d.styleProp){let t=d.styleProp[e];effector.is.unit(t)?I.seq.push({type:'style',field:e,value:t}):I.staticSeq.push({type:'style',field:e,value:t})}for(let e in d.styleVar){let t=d.styleVar[e];effector.is.unit(t)?I.seq.push({type:'styleVar',field:e,value:t}):I.staticSeq.push({type:'styleVar',field:e,value:t})}for(let e=0;e<d.text.length;e++){let t=d.text[e];if(null!==t.value)if(effector.is.unit(t.value)){I.seq.push({type:'dynamicText',value:t.value,childIndex:t.index});let e=t.value.stateRef,a=re;a.plain.includes(e)||a.closure.includes(e)||a.closure.push(e)}else I.seq.push({type:'staticText',value:String(t.value),childIndex:t.index})}for(let e=0;e<d.handler.length;e++){let t=d.handler[e];for(let e in t.map)I.seq.push({type:'handler',for:e,handler:t.map[e],options:t.options,domConfig:t.domConfig})}if(d.visible){let{onMount:e,onState:t}=H({mount:u,state:d.visible,onMount:(e,t)=>({leaf:t,value:e,hydration:t.hydration}),onState:(e,t)=>({leaf:e,value:t,hydration:0})});e.watch(({leaf:e,value:t,hydration:a})=>{let r=e.data,n=r.block;if(a&&(l(t,r.ops.visible),t)){let e,t=D(n);if(e=t?t.nextSibling:R(n).firstChild,'#text'===e.nodeName){let t=e;e=e.nextSibling,t.remove()}n.value=e,n.visible=1}E(I,{parentBlockFragment:n.child,leaf:e,node:n.value,svgRoot:S.isSvgRoot?n.value:null}),t&&r.needToCallNode&&(r.needToCallNode=0,effector.launch({target:se,params:{element:r.block.value,fns:I.node},page:e.spawn,defer:1,forkPage:e.forkPage})),effector.launch({target:f,params:e,defer:1,page:e.spawn,forkPage:e.forkPage})}),effector.merge([t,e]).watch(({leaf:e,value:t,hydration:a})=>{a||n(t,e.data.ops.visible)})}P&&h(P,I.staticSeq);for(let e=0;e<I.seq.length;e++){let t=I.seq[e];switch(t.type){case'visible':break;case'attr':{let{field:e}=t,r='value'===e||'checked'===e||'min'===e||'max'===e,{onMount:l,onState:o}=p(t.value);if(r)effector.merge([o,l]).watch(({leaf:t,value:r})=>{y(a(t),e,r)});else{let t=I.opsAmount++;l.watch(({value:r,leaf:l})=>{let n=a(l),o=i({value:r,priority:'props',runOp(t){y(n,e,t)},group:l.ops.group});l.ops.group.ops[t]=o,y(n,e,r)}),o.watch(({value:e,leaf:a})=>{n(e,a.ops.group.ops[t])})}break}case'data':{let{field:e}=t,{onMount:r,onState:l}=p(t.value),o=I.opsAmount++;r.watch(({value:t,leaf:r})=>{let l=a(r),n=i({value:t,priority:'props',runOp(t){k(l,e,t)},group:r.ops.group});r.ops.group.ops[o]=n,k(l,e,t)}),l.watch(({value:e,leaf:t})=>{n(e,t.ops.group.ops[o])});break}case'style':{let e=I.opsAmount++,{field:r}=t,{onMount:l,onState:o}=p(t.value);l.watch(({value:t,leaf:l})=>{let n=a(l),o=i({value:t,priority:'props',runOp(e){m(n,r,e)},group:l.ops.group});l.ops.group.ops[e]=o,m(n,r,t)}),o.watch(({value:t,leaf:a})=>{n(t,a.ops.group.ops[e])});break}case'styleVar':{let{field:e}=t,{onMount:r,onState:l}=p(t.value),o=I.opsAmount++;r.watch(({value:t,leaf:r})=>{let l=a(r),n=i({value:t,priority:'props',runOp(t){v(l,e,t)},group:r.ops.group});r.ops.group.ops[o]=n,v(l,e,t)}),l.watch(({value:e,leaf:t})=>{n(e,t.ops.group.ops[o])});break}case'staticText':f.map(e=>e).watch(e=>{r(e,t.value,t.childIndex)});break;case'dynamicText':{let e=I.opsAmount++;effector.sample({source:t.value,clock:f,fn:(e,t)=>({value:String(e),leaf:t}),greedy:1}).watch(({value:a,leaf:l})=>{let n=i({value:a,priority:'props',runOp(e){b(o.value,e)},group:l.ops.group});l.ops.group.ops[e]=n;let o=r(l,a,t.childIndex)}),effector.sample({source:f,clock:t.value,fn:(e,t)=>({leaf:e,text:t}),greedy:1}).watch(({leaf:t,text:a})=>{n(a,t.ops.group.ops[e])});break}case'handler':{let e=t.handler.graphite.meta.nativeTemplate||null;f.watch(r=>{let l=null;if(e){let t=0,a=r.spawn;for(;!t&&a;)a.template===e?(t=1,l=a):a=a.parent}a(r).addEventListener(t.for,e=>{t.options.prevent&&e.preventDefault(),t.options.stop&&e.stopPropagation(),effector.launch({target:x(t.handler,r.forkPage),params:e,page:l,forkPage:r.forkPage})},t.domConfig)});break}}}u.watch(e=>{let t=e.data;if(!I.visible){let a=t.ops.visible,r=t.block;if(e.hydration){l(1,a);let e,t=D(r);if(e=t?t.nextSibling:R(r).firstChild,'#text'===e.nodeName){let t=e;e=e.nextSibling,t.remove()}r.value=e,r.visible=1}E(I,{parentBlockFragment:r.child,leaf:e,node:r.value,svgRoot:S.isSvgRoot?r.value:null}),effector.launch({target:f,params:e,defer:1,page:e.spawn,forkPage:e.forkPage}),e.hydration?t.needToCallNode&&(t.needToCallNode=0,effector.launch({target:se,params:{element:t.block.value,fns:I.node},page:e.spawn,defer:1,forkPage:e.forkPage})):n(1,a)}})},env:p});Z(S)},e.handler=G,e.list=W,e.node=e=>{let t=ne.draft;switch(t.type){case'list':case'listItem':case'using':case'route':case'rec':case'recItem':case'block':case'blockItem':return void console.error('node() hook supported only in h() nodes')}t.node.push(e)},e.rec=$,e.remap=N,e.route=Q,e.spec=z,e.text=(e,...t)=>{let a=[e[0]];for(let r=0;r<t.length;r++)a.push(t[r],e[r+1]);z({text:a})},e.tree=({source:e,key:t,child:a,fn:r})=>{let l=$(({store:e})=>{W({source:e,key:t,fn({store:e}){let t=e.map(e=>e[a]||[]);r({store:e,child(){l({store:t})}})}})});l({store:e})},e.using=(e,t)=>{let a,r,l,n,o,i;if('function'==typeof t)a=t,l=j(),n=0;else{if(!t)throw Error('using() second argument is missing');a=t.fn,l=t.env?t.env:j(),n=t.hydrate,r=t.onComplete,o=t.onRoot,i=t.scope}if(!e)throw Error('using() first argument is missing');let u=e.namespaceURI,p=e.tagName.toLowerCase(),f={type:'using',childTemplates:[],childCount:0,inParentIndex:-1},d=w({name:'using',draft:f,isSvgRoot:'svg'===p,namespace:'http://www.w3.org/2000/svg'===u?'svg':'foreignobject'===p?'foreignObject':'html',fn(e,{mount:t}){a(),t.watch(ce.using)},env:l}),h={type:'using',child:{type:'fragment',parent:null,child:[]},value:e};h.child.parent=h,(e=>{if(e&&!e.nodeMap){let t={};for(let a=0;a<e.clones.length;a++){let r=e.clones[a];t[r.meta.forkOf.id]=r}e.nodeMap=t}})(i);let g=s({onComplete:r}),v=T(d,{parentLeaf:le||null,mountNode:e,svgRoot:d.isSvgRoot?e:le?le.svgRoot:null,leafData:{type:'using',draft:f,element:e,block:h},opGroup:c(g),domSubtree:c(g),hydration:n,forkPage:i,env:l});if(o&&o({template:d,leaf:v}),g.onDrain&&!g.rafID){let e=g.onDrain;g.onDrain=null,e()}},e.variant=({source:e,cases:t,key:a})=>{if(!effector.is.unit(e))throw Error('variant({source}) should be unit');let r;r='function'==typeof a?a:null==a?e=>String(e):e=>String(e[a]);let l=0;for(let a in t)'__'!==a?Q({source:e,visible:e=>r(e)===a,fn:t[a]}):l=1;if(l){let a=Object.keys(t);Q({source:e,visible:e=>!a.includes(r(e)),fn:t.__})}},Object.defineProperty(e,'__esModule',{value:1})}); | ||
((e,t)=>{'object'==typeof exports&&'undefined'!=typeof module?t(exports,require('effector')):'function'==typeof define&&define.amd?define(['exports','effector'],t):t((e=e||self).forest={},e.effector)})(this,(e,effector)=>{function t(e,t){e.cursor[t].prev&&(e.cursor[t].prev.cursor[t].next=e.cursor[t].next),e.cursor[t].next&&(e.cursor[t].next.cursor[t].prev=e.cursor[t].prev),e.queue[t].last===e&&(e.queue[t].last=e.cursor[t].prev),e.queue[t].first===e&&(e.queue[t].first=e.cursor[t].next),e.cursor[t].prev=null,e.cursor[t].next=null}function a(e){e.status='active',((e,t)=>{t.cursor.prev&&(t.cursor.prev.cursor.next=t.cursor.next),t.cursor.next&&(t.cursor.next.cursor.prev=t.cursor.prev),e.last===t&&(e.last=t.cursor.prev),e.first===t&&(e.first=t.cursor.next),t.cursor.prev=null,t.cursor.next=null})(n(e),e)}function n(e){return e.group.activeChilds[e.priority]}function r(e,t){t.value.active=t.value.pending=e,'active'!==t.status&&a(t)}function l(e,r){if(r.value.active===e)return r.value.pending=e,void('pending'===r.status&&(a(r),n(r).first||t(r.group,r.priority)));'active'===r.status&&(r.status='pending',n(r).first||((e,t)=>{e.queue[t].last?(e.cursor[t].prev=e.queue[t].last,e.queue[t].last.cursor[t].next=e,e.queue[t].last=e):e.queue[t].first=e.queue[t].last=e})(r.group,r.priority),((e,t)=>{e.last?(t.cursor.prev=e.last,e.last.cursor.next=t,e.last=t):e.first=e.last=t})(n(r),r)),r.value.pending=e,r.group.queue.rafID||(r.group.queue.rafID=te(r.group.queue.execQueue))}function o(e){X('execQueue');let n,r,l=ee(),o=0;e:for(;e.props.first||e.tree.first||e.data.first;){if(ee()-l>=10){o=1;break e}let i=!!e.props.first;for(i&&X('props');n=e.props.first;){for(;r=n.activeChilds.props.first;){if(ee()-l>=10){o=1,Y('props');break e}r.runOp(r.value.pending),r.value.active=r.value.pending,a(r)}t(n,'props')}i&&Y('props');let s=!!e.tree.first;for(s&&X('tree');n=e.tree.first;){for(;r=n.activeChilds.tree.first;){if(ee()-l>=10){o=1,Y('tree');break e}r.runOp(r.value.pending),r.value.active=r.value.pending,a(r)}t(n,'tree')}s&&Y('tree');let c=!!e.data.first;for(c&&X('data');n=e.data.first;){for(;r=n.activeChilds.data.first;){if(ee()-l>=10){o=1,Y('data');break e}r.runOp(r.value.pending),r.value.active=r.value.pending,a(r)}t(n,'data')}c&&Y('data')}if(Y('execQueue'),o)e.rafID=te(e.execQueue);else if(e.rafID=null,e.onDrain){let t=e.onDrain;e.onDrain=null,t()}}function i({value:e,runOp:t,group:a,priority:n}){return{value:{active:e,pending:e},runOp:t,status:'active',priority:n,group:a,cursor:{prev:null,next:null}}}function s({onComplete:e}){let t={props:{first:null,last:null},tree:{first:null,last:null},data:{first:null,last:null},rafID:null,execQueue(){},onDrain:e};return t.execQueue=o.bind(null,t),t}function c(e){return{ops:[],queue:e,activeChilds:{props:{first:null,last:null},tree:{first:null,last:null},data:{first:null,last:null}},cursor:{props:{prev:null,next:null},tree:{prev:null,next:null},data:{prev:null,next:null}}}}function u({value:e,group:t,onInit:a,onChange:n,onTerminate:r}){let o=i({value:e,group:t,runOp(e){s.status='A',n(e)},priority:'data'}),s={status:'IA',value:o.value,hooks:{onTerminate:r},ops:{init:i({value:0,group:t,runOp(e){s.status='A',a(s.value.active)},priority:'data'}),change:o,terminate:i({value:0,group:t,runOp(e){s.status='T',s.hooks.onTerminate(1)},priority:'data'})}};return l(1,s.ops.init),s}function p(e){switch(e.status){case'I':case'T':case'AT':return;case'A':e.status='AT',l(1,e.ops.terminate);break;case'AA':e.status='AT',l(1,e.ops.terminate),l(e.value.active,e.ops.change);break;case'IA':e.status='T',l(0,e.ops.init),e.hooks.onTerminate(0)}}function f(e,t){switch(t.status){case'I':case'T':return;case'A':t.value.active!==e&&(t.status='AA',l(e,t.ops.change));break;case'AA':t.value.active===e?(t.status='A',l(e,t.ops.change)):t.value.pending!==e&&(t.value.pending=e);break;case'IA':t.value.active=t.value.pending=e}}function d(e){switch(e=String(e)){case'__proto__':case'__defineGetter__':case'__defineSetter__':case'constructor':case'prototype':case'hasOwnProperty':case'toString':case'valueOf':case'setProperty':case'removeProperty':return'forbidden';default:return e.replace(/[^a-zA-Z0-9\-_]/g,'')}}function h(e,t){for(let a=0;a<t.length;a++){let{type:n,field:r,value:l}=t[a];ae[n](e,r,l)}}function g(e){return''!==e&&0!==e&&'0'!==e&&(0==e||null==e)}function v(e,t,a){g(a)?e.style.removeProperty("--"+t):e.style.setProperty("--"+t,""+a)}function m(e,t,a){g(a)?delete e.style[t]:e.style[t]=""+a}function k(e,t,a){g(a)?delete e.dataset[t]:e.dataset[t]=""+a}function y(e,t,a){if(g(a)){switch(t){case'value':delete e.value;break;case'checked':e.checked=0;break;case'spellcheck':if(0==a)return void e.setAttribute('spellcheck','false')}e.removeAttribute(t)}else{switch(t){case'value':e.value=""+a;break;case'checked':e.checked=""+a}e.setAttribute(t,""+a)}}function b(e,t){e.replaceData(0,(e.textContent||'').length,String(t))}function w({fn:e,state:t={},defer:a=0,name:n="",draft:r,isSvgRoot:l,namespace:o,env:i,isBlock:s=0}){let c=ie,u=le,p={id:++ne,name:n,plain:[],watch:[],nameMap:{},pages:[],closure:[],childTemplates:[],upward:effector.step.filter({fn(e,t,a){if(!a.page){if(!a.parent||!a.parent.page)return 1;a.page=a.parent.page}if(!a.page.active)return console.count('inactive page upward'),0;let n=[a.page.template],r=[a.page];{let e=a.page.parent;for(;e;)r.push(e),n.push(e.template),e=e.parent}return a.node.next.forEach(t=>{let l=t.meta.nativeTemplate;l?n.includes(l)?effector.launch({target:x(t,a.forkPage),params:e,defer:1,page:r[n.indexOf(l)],stack:a,forkPage:a.forkPage}):console.error('context drift',{stack:a,node:t}):effector.launch({target:x(t,a.forkPage),params:e,defer:1,page:null,stack:a,forkPage:a.forkPage})}),0}}),loader:effector.step.filter({fn(e,t,a){if(a.parent){let n=a.forkPage?a.forkPage.graphite.id:null;if(a.page){if(!a.page.active)return console.count('inactive page loader'),0;if(a.page.template===p)return 1;if(a.page.childSpawns[p.id])a.page.childSpawns[p.id].forEach(t=>{(!n||t.leaf.forkPage&&n===t.leaf.forkPage.graphite.id)&&effector.launch({params:e,target:x(a.node,a.forkPage),page:t,defer:1,forkPage:a.forkPage})});else if(t.targetTemplate){let n=[a.page];{let e=a.page.parent;for(;e;)n.push(e),e=e.parent}let r=n.findIndex(e=>t.targetTemplate===e.template);effector.launch(-1===r?{params:e,target:x(a.node,a.forkPage),page:null,defer:1,forkPage:a.forkPage}:{params:e,target:x(a.node,a.forkPage),page:n[r],defer:1,forkPage:a.forkPage})}else p.pages.forEach(t=>{(!n||t.leaf.forkPage&&n===t.leaf.forkPage.graphite.id)&&t.fullID.startsWith(a.page.fullID)&&effector.launch({params:e,target:x(a.node,a.forkPage),page:t,defer:1,forkPage:a.forkPage})})}else p.pages.forEach(t=>{(!n||t.leaf.forkPage&&n===t.leaf.forkPage.graphite.id)&&effector.launch({params:e,target:x(a.node,a.forkPage),page:t,defer:1,forkPage:a.forkPage})});return 0}return 1}}),parent:u};u&&u.childTemplates.push(p);let f=effector.createNode({meta:{template:p}});le=p;let d=ie={template:p,node:f,api:null,trigger:{mount:effector.createEvent()},draft:r,isSvgRoot:l,namespace:o,env:i,isBlock:s||!(!c||!c.isBlock)};return a?d.deferredInit=()=>{let a=ie,n=le;ie=d,le=p,d.deferredInit=null;try{effector.withRegion(f,()=>{let a=effector.restore(t);d.api=e(a,d.trigger),p.nameMap=a})}finally{ie=a,le=n}}:effector.withRegion(f,()=>{let a=effector.restore(t);d.api=e(a,d.trigger),p.nameMap=a}),ie=c,le=u,p.actor=d,d}function x(e,t){return t&&t.nodeMap[(e=e.graphite||e).id]||e}function P(e,t){let a=e;switch(t&&se(t,e)&&(a=se(t,e)),e.type){case'list':return[...a.current];case'shape':return{...a.current};default:return a.current}}function I(e,t,a){let n=t;for(;n&&!se(n.spawn,e);)n=n.parentLeaf;return n?se(n.spawn,e):a&&se(a,e)?se(a,e):e}function S(e,t,a){return I(e,t,a).current}function C(e,t){se(t.spawn,e)||(t.spawn.reg[e.id]=I(e,t.parentLeaf,t.forkPage))}function T(e,{values:t={},parentLeaf:a,mountNode:n,svgRoot:r,leafData:l,opGroup:o,domSubtree:i,hydration:s,forkPage:c,env:u}){function p(e){if(e.before)for(let t=0;t<e.before.length;t++){let a=e.before[t];switch(a.type){case'map':{let t=a.from;C(t,k),g[e.id].current=a.fn(g[t.id].current);break}case'field':{let t=a.from;C(t,k),g[e.id].current[a.field]=g[t.id].current;break}case'closure':C(a.of,k)}}if(!e.after)return;let t=g[e.id].current;for(let a=0;a<e.after.length;a++){let n=e.after[a],r=n.to;switch(g[r.id]||(g[r.id]={id:r.id,current:S(r,k.parentLeaf,c)}),n.type){case'copy':g[r.id].current=t;break;case'map':g[r.id].current=n.fn(t)}}}function f(e,t,a){let n;t.stop=1;try{for(;t.i<e.length;)n=e[t.i],t.i++,n.fn(a[n.of.id]?a[n.of.id].current:S(n.of,k.parentLeaf,c))}catch(e){console.error(e),t.stop=0}}!u&&a&&(u=a.env);let d=a?a.spawn:null,h=e.template,g={},v={id:++re,fullID:'',reg:g,template:h,parent:d,childSpawns:{},active:1};h.pages.push(v);let m={},k={actor:e,spawn:v,api:m,draft:e.draft,ops:{group:o,domSubtree:i},svgRoot:r,data:l,parentLeaf:a,hydration:s,forkPage:c,env:u,mountNode:n},y=oe;oe=k,d&&(d.childSpawns[h.id]||(d.childSpawns[h.id]=[]),d.childSpawns[h.id].push(v)),v.fullID=d?`${d.fullID}_${v.id}`:""+v.id;for(let e=0;e<h.closure.length;e++){let t=h.closure[e],a=t,n=v.parent;e:for(;n;){if(se(n,t)){a=se(n,t);break e}n=n.parent}!n&&c&&se(c,t)&&(a=se(c,t)),g[t.id]=a}for(let e=0;e<h.plain.length;e++){let t=h.plain[e],a={id:t.id,current:P(t,c)};g[t.id]=a}for(let e in t){let a=h.nameMap[e].stateRef.id;g[a]={id:a,current:t[e]}}h.closure.forEach(p),h.plain.forEach(p);let b={i:0,stop:0};for(;!b.stop;)f(h.watch,b,g);if(d)for(let e in v.childSpawns)e in d.childSpawns||(d.childSpawns[e]=[]),d.childSpawns[e].push(...v.childSpawns[e]);if(m.mount=(t,a=1)=>(e=>{if(ce)return void ce.steps.push(e);let t;ce={parent:ce,steps:[e]};do{for(;t=ce.steps.shift();)ce={parent:ce,steps:[]},effector.launch(t)}while(ce=ce.parent)})({target:e.trigger.mount,params:t,defer:a,page:v,forkPage:c}),e.api)for(let t in e.api)m[t]=(a,n=1)=>effector.launch({target:e.api[t],params:a,defer:n,page:v,forkPage:c});return k.spawn.api=m,k.spawn.leaf=k,k.api.mount(k),oe=y,k}function R(e){let t=function e(t){switch(t.type){case'using':return t;case'fragment':switch(t.parent.type){case'element':case'using':return t.parent}default:return e((e=>{switch(e.type){case'text':case'element':case'list':case'route':case'rec':case'recItem':case'block':case'blockItem':return e.parent;case'fragment':default:switch(e.parent.type){case'using':case'block':return e.parent;default:return e.parent.parent}}})(t))}}(e);return t?t.value:null}function q(e){if(!e.visible)return null;switch(e.type){case'text':case'element':return e;case'route':return q(e.child);case'LF':case'RF':case'FF':case'rec':case'recItem':case'block':case'blockItem':return(e=>{let t=e.child;for(let e=t.length-1;e>=0;e--){let a=q(t[e]);if(a)return a}return null})(e.child);case'list':{let t=e.lastChild;if(!t)return null;for(;t;){let e=q(t);if(e)return e;t=t.left}return null}default:return null}}function A(e){switch(e.type){case'fragment':switch(e.parent.type){case'element':case'using':return null;case'RF':{let t=e.parent.parent,a=t.parent;for(let e=t.index-1;e>=0;e--){let t=q(a.child[e]);if(t)return t}return A(a)}case'rec':case'recItem':case'block':case'blockItem':case'FF':{let t=e.parent,a=t.parent;for(let e=t.index-1;e>=0;e--){let t=q(a.child[e]);if(t)return t}return A(a)}case'LF':{let t=e.parent.left;for(;t;){let e=q(t);if(e)return e;t=t.left}return A(e.parent.parent)}default:return null}case'element':case'text':case'route':case'rec':case'recItem':case'block':case'blockItem':case'list':{let t=e.parent;for(let a=e.index-1;a>=0;a--){let e=t.child[a];if(!e)continue;let n=q(e);if(n)return n}return A(t)}default:return null}}function D(e){let t=A(e);return t?t.value:null}function O(e,{parentBlockFragment:t,leaf:a,node:n,svgRoot:r,values:l}){e.childTemplates.forEach(e=>{F({parentBlockFragment:t,leaf:a,node:n,svgRoot:r,values:l,actor:e})})}function F({parentBlockFragment:e,leaf:t,node:a=t.mountNode,actor:n,svgRoot:r,values:l}){let o,{draft:s}=n,{queue:u}=t.ops.group,p=c(u),f=t.ops.domSubtree,d=f;switch(s.type){case'route':{let t={type:'route',parent:e,child:{type:'RF',parent:null,child:{type:'fragment',parent:null,child:[]},visible:0},visible:1,index:s.inParentIndex};t.child.parent=t,t.child.child.parent=t.child,e.child[s.inParentIndex]=t,o={type:'route',block:t,ops:{},initialized:0};break}case'element':{let a;if(n.isBlock){let e,n,r=t;for(;r&&(!n||!e);){r.actor.env&&(e=r.actor.env);let{draft:t}=r;'element'===t.type&&('svg'===t.tag?n='svg':'foreignObject'===t.tag&&(n='html')),r=r.parentLeaf}n||(n='html'),e&&(a='svg'===n?e.document.createElementNS('http://www.w3.org/2000/svg',s.tag):e.document.createElement(s.tag),h(a,s.staticSeq))}else a=s.stencil.cloneNode();let r={type:'element',parent:e,child:{type:'fragment',parent:null,child:[]},value:a,visible:0,index:s.inParentIndex};r.child.parent=r,e.child[s.inParentIndex]=r,o={type:'element',block:r,ops:{visible:i({value:0,priority:'tree',runOp(e){e?(N(r),o.needToCallNode&&(o.needToCallNode=0,effector.launch({target:ue,params:{element:r.value,fns:s.node},page:g.spawn,forkPage:t.forkPage}))):(r.value.remove(),r.visible=0)},group:f})},needToCallNode:s.node.length>0},d=c(u);break}case'list':{let t={type:'list',parent:e,child:[],lastChild:null,visible:1,index:s.inParentIndex};e.child[s.inParentIndex]=t,o={type:'list',draft:s,block:t,records:[]};break}case'using':case'listItem':break;case'rec':{let t={type:'rec',parent:e,child:{type:'fragment',parent:null,child:[]},visible:1,index:s.inParentIndex};t.child.parent=t,e.child[s.inParentIndex]=t,o={type:'rec',block:t};break}case'recItem':{let t={type:'recItem',parent:e,child:{type:'fragment',parent:null,child:[]},visible:1,index:s.inParentIndex};t.child.parent=t,e.child[s.inParentIndex]=t,o={type:'rec item',block:t};break}case'block':{let t={type:'block',parent:e,child:{type:'fragment',parent:null,child:[]},visible:1,index:s.inParentIndex};t.child.parent=t,e.child[s.inParentIndex]=t,o={type:'block',block:t};break}case'blockItem':{let t={type:'blockItem',parent:e,child:{type:'fragment',parent:null,child:[]},visible:1,index:s.inParentIndex};t.child.parent=t,e.child[s.inParentIndex]=t,o={type:'block item',block:t};break}default:console.warn("unexpected draft type "+s.type)}let g=T(n,{values:l,parentLeaf:t,mountNode:a,svgRoot:r||t.svgRoot,leafData:o,opGroup:p,domSubtree:d,hydration:t.hydration,forkPage:t.forkPage})}function N(e){let t=D(e);t?t.after(e.value):R(e).prepend(e.value),e.visible=1}function M(e,t){if(Array.isArray(t))return t.map(t=>e.map(e=>e[t]));if('object'==typeof t&&null!==t){let a={};for(let n in t){let r=t[n];a[n]=e.map('function'==typeof r?e=>r(e):e=>e[r])}return a}return e.map(e=>e[t])}function E(e,t){let{spawn:a}=e;for(let e in a.childSpawns){let n=a.childSpawns[e];for(let e=0;e<n.length;e++)t(n[e].leaf)}}function B(e){e.spawn.active=0,E(e,_)}function V({spawn:e}){L(e,e.parent.childSpawns[e.template.id]),L(e,e.template.pages)}function _(e){let{spawn:t,data:a}=e;switch(a.type){case'element':L(t,t.parent.childSpawns[t.template.id]),function e(t){t.active=0,L(t,t.template.pages);for(let a in t.childSpawns)t.childSpawns[a].forEach(e)}(t),l(0,a.ops.visible);break;case'list':{let t=a.records;for(let e=0;e<t.length;e++){let a=t[e];a.instance&&_(a.instance),a.active=0}e.spawn.active=0,V(e);break}case'list item':{let t=a.block;L(t,t.parent.child);let n=t.left,r=t.right;n&&(n.right=r,r||t.parent.lastChild!==t||(t.parent.lastChild=n)),r&&(r.left=n),n||r||t.parent.lastChild!==t||(t.parent.lastChild=null),t.left=null,t.right=null,B(e),V(e);break}case'route':B(e),V(e);break;case'block':case'block item':case'rec':case'rec item':B(e)}}function L(e,t){if(!t)return;let a=t.indexOf(e);-1!==a&&t.splice(a,1)}function j(e,t){if(!e)throw Error(t)}function z(e,t){if(!e)throw Error(t+"() called outside from using() closure")}function G(){if('undefined'!=typeof document)return{document};throw Error('your environment has no document')}function Q(e){z(ie,'spec');let t=ie.draft;switch(t.type){case'list':return void(e.visible&&(t.itemVisible=e.visible));case'listItem':case'using':case'route':case'rec':case'recItem':case'block':case'blockItem':return}if(e.attr&&t.attr.push(e.attr),e.data&&t.data.push(e.data),'text'in e){let a=e.text,n=t.childCount;Array.isArray(a)?(t.text.push(...a.map((e,t)=>({index:t+n,value:e}))),t.childCount+=a.length):(t.text.push({index:n,value:a}),t.childCount+=1)}if(e.style){let a={};for(let t in e.style)a[d(t)]=e.style[t];t.styleProp.push(a)}if(e.styleVar&&t.styleVar.push(e.styleVar),e.visible&&(t.visible=e.visible),e.handler){let t=e.handler;'object'==typeof t.on?U(t.config||{},t.on):U(t)}e.ɔ&&Q(e.ɔ)}function U(e,t){if(!ie)return;let a=ie.draft;j('element'===a.type,`"handler" extension can be used only with element nodes, got "${a.type}"`),void 0===t&&(t=e,e={});for(let e in t)j(effector.is.unit(t[e]),`handler for "${e}" should be event`);let{passive:n=0,capture:r=0,prevent:l=0,stop:o=0}=e;a.handler.push({options:{prevent:l,stop:o},domConfig:{passive:l?0:n,capture:r},map:t})}function $({source:e,visible:t,fn:a}){z(ie,'route');let{env:n,namespace:r}=ie,l=w({name:'route',isSvgRoot:0,namespace:r,env:n,draft:{type:'route',childTemplates:[],childCount:0,inParentIndex:-1},fn(l,{mount:o}){let i;if(effector.is.store(t))i=effector.combine({value:e,visible:t});else{let a=t;i=e.map(e=>({value:e,visible:a(e)}))}let s=w({name:'route item',isSvgRoot:0,namespace:r,env:n,draft:{type:'route',childTemplates:[],childCount:0,inParentIndex:-1},state:{store:null},fn({store:e},{mount:t}){let n=effector.createEvent();e.on(n,(e,t)=>t),a({store:e});let r=effector.sample({source:t,clock:i,fn:(e,{visible:t,value:a})=>({leaf:e,visible:t,value:a}),greedy:1});t.watch(pe.routeItem),r.watch(({leaf:e,visible:t,value:a})=>{e.data.block.child.visible=t,t&&effector.launch({target:n,params:a,defer:1,page:e.spawn,forkPage:e.forkPage}),W(t,e)})}});J(s);let{onMount:c,onState:u}=K({mount:o,state:i,onMount:({visible:e,value:t},a)=>({leaf:a,visible:e,value:t}),onState:(e,{visible:t,value:a})=>({leaf:e,visible:t,value:a})});effector.merge([c,u]).watch(({leaf:e,visible:t,value:a})=>{let n=e.data;n.block.child.visible=t,t&&!n.initialized&&(F({parentBlockFragment:n.block.child.child,leaf:e,actor:s,values:{store:a}}),n.initialized=1)})}});J(l)}function W(e,t){let a=t=>{let n=t.data;switch(n.type){case'element':l(e,n.ops.visible);break;case'route':case'list':case'list item':E(t,a);break;default:console.log('unsupported type',n.type)}};E(t,a)}function Z(e){let t='function'==typeof e?e:e.fn,a=w({name:'rec',state:{store:null},isSvgRoot:0,namespace:null,env:null,draft:{type:'rec',childTemplates:[],childCount:0,inParentIndex:0},defer:1,isBlock:1,fn({store:e},{mount:a}){t({store:e,state:e});let n=effector.createEvent();return e.on(n,(e,t)=>t),a.watch(pe.rec),{itemUpdater:n}}});return({store:e,state:t=e})=>{z(ie,'(rec instance)');let{env:n,namespace:r}=ie;a.deferredInit&&a.deferredInit(),J(w({name:'rec item',isSvgRoot:0,namespace:r,env:n,draft:{type:'recItem',childTemplates:[],childCount:0,inParentIndex:-1},fn(e,{mount:n}){let{onMount:r,onState:l}=K({state:t,mount:n,onMount:(e,t)=>({state:e,leaf:t}),onState:(e,t)=>({state:t,leaf:e})});l.watch(({state:e,leaf:t})=>{E(t,t=>{t.api.itemUpdater(e)})}),r.watch(({leaf:e,state:t})=>{F({parentBlockFragment:e.data.block.child,leaf:e,actor:a,values:{store:t}})})}}))}}function H(e,t){z(ie,'list'),'function'==typeof t&&(effector.is.unit(e)?e={source:e,fn:t}:e.fn=t);let{fn:a,key:n,source:r,fields:l=[]}=e,o=void 0!==n?'function'==typeof n?n:e=>e[n]:(e,t)=>t,i={type:'list',key:effector.is.store(e)?{type:'index'}:{type:'key',key:e.key},childTemplates:[],childCount:0,inParentIndex:-1},{env:s,namespace:d}=ie;J(w({name:'list',draft:i,isSvgRoot:0,namespace:d,fn(e,{mount:t}){let n=w({name:'list item',state:{id:-1,store:null},draft:i,isSvgRoot:0,namespace:d,fn({id:e,store:t},{mount:n}){a({store:t,key:e,fields:M(t,l)});let r=effector.createEvent();if(t.on(r,(e,t)=>t),i.itemVisible){let{onMount:e,onState:t}=K({mount:n,state:i.itemVisible,onMount:(e,t)=>({visible:e,leaf:t}),onState:(e,t)=>({visible:t,leaf:e})});e.watch(({visible:e,leaf:t})=>{let a=t.data.block;a.visible=e,a.childInitialized=e,e&&O(i,{parentBlockFragment:a.child,leaf:t})}),t.watch(({visible:e,leaf:t})=>{let a=t.data.block;a.visible=e,a.childInitialized?W(e,t):e&&(a.childInitialized=1,O(i,{parentBlockFragment:a.child,leaf:t}))})}else n.watch(pe.listItem);return{itemUpdater:r}},env:s}),h=effector.createStore([]),g=r.map(e=>e),v=effector.sample({source:r,clock:t,fn:(e,t)=>({updates:e,leaf:t,hydration:t.hydration}),greedy:1}),m=effector.sample({source:v,clock:g,fn:({leaf:e},t)=>({updates:t,leaf:e,hydration:0}),greedy:1});effector.sample({source:h,clock:[v,m],greedy:1,fn(e,{updates:t,leaf:a,hydration:l}){let s=a.data,d=s.block;X('list update ['+r.shortName+']');let h=Array(t.length).fill(0),g=t.map(o),v=[];for(let a=0;a<e.length;a++){let n=e[a],r=g.indexOf(n.key);-1!==r?(v.push(n),h[r]=1,f(t[r],n.asyncValue)):(n.active=0,n.instance&&_(n.instance),p(n.asyncValue))}for(let e=0;e<t.length;e++){if(h[e])continue;let r=t[e],o=g[e],s=c(a.ops.group.queue),p={type:'LF',parent:d,child:{type:'fragment',parent:null,child:[]},childInitialized:0,visible:0,left:null,right:null},f={type:'listItem',key:o,index:o,active:1,leafData:{type:'list item',block:p,listDraft:i},asyncValue:u({value:r,group:s,onTerminate(e){},onChange(e){f.instance&&f.instance.api.itemUpdater(e)},onInit(e){f.active&&(l||(f.instance=T(n,{values:{id:o,store:e},parentLeaf:a,mountNode:a.mountNode,svgRoot:a.svgRoot,leafData:f.leafData,opGroup:s,domSubtree:a.ops.domSubtree,hydration:l,forkPage:a.forkPage})))}})},m=v.length;v.push(f);let k=m>0?v[m-1].leafData:null;if(p.child.parent=p,d.child.push(p),k){let e=k.block;p.left=e;let t=e.right;t?(t.left=p,p.right=t):d.lastChild=p,e.right=p}else d.lastChild=p;l&&(f.instance=T(n,{values:{id:o,store:r},parentLeaf:a,mountNode:a.mountNode,svgRoot:a.svgRoot,leafData:f.leafData,opGroup:s,domSubtree:a.ops.domSubtree,hydration:l,forkPage:a.forkPage}))}return Y('list update ['+r.shortName+']'),0===v.length&&(d.lastChild=null),s.records=v,v},target:h})},env:s}))}function J(e){if(!ie)return;let{draft:t}=e;if('listItem'!==t.type&&'rec'!==t.type)switch(ie.draft.type){case'element':case'using':case'route':case'list':case'rec':case'recItem':case'block':case'blockItem':t.inParentIndex=ie.draft.childCount,ie.draft.childCount+=1,ie.draft.childTemplates.push(e);break;default:console.warn("unexpected currentActor type "+ie.draft.type)}}function K({mount:e,state:t,onMount:a,onState:n}){return{onMount:effector.sample({source:t,clock:e,fn:a,greedy:1}),onState:effector.sample({source:e,clock:t,fn:n,greedy:1})}}let X,Y,ee;'undefined'!=typeof performance&&performance.mark?(X=e=>{performance.mark('☄️ '+e+' start')},Y=e=>{try{performance.measure('☄️ '+e,'☄️ '+e+' start')}catch(e){}performance.clearMarks('☄️ '+e+' start'),performance.clearMeasures('☄️ '+e)}):(X=()=>{},Y=()=>{}),ee='undefined'!=typeof performance&&performance.now?()=>performance.now():'undefined'!=typeof process&&process.hrtime?()=>{let e=process.hrtime();return(1e9*e[0]+e[1])/1e6}:()=>Date.now();let te='undefined'!=typeof requestAnimationFrame?requestAnimationFrame:e=>setTimeout(e,0);const ae={attr:y,data:k,style:m,styleVar:v};let ne=0,re=0,le=null,oe=null,ie=null;const se=(e,t)=>e.reg[t.id];let ce=null,ue=effector.createEvent();ue.watch(({fns:e,element:t})=>{e.forEach(e=>{e(t)})});const pe={using(e){let t=e.data;O(t.draft,{parentBlockFragment:t.block.child,leaf:e})},routeItem(e){let t=e.draft,a=e.data;a.block.child.visible=1,O(t,{parentBlockFragment:a.block.child.child,leaf:e})},block(e){O(e.draft,{parentBlockFragment:e.data.block.child,leaf:e})},blockItem(e){F({parentBlockFragment:e.data.block.child,leaf:e,actor:e.draft.itemOf})},rec(e){O(e.draft,{parentBlockFragment:e.data.block.child,leaf:e})},listItem(e){let t=e.data,a=t.block;a.visible=1,a.childInitialized=1,O(t.listDraft,{parentBlockFragment:a.child,leaf:e})}};e.block=({fn:e,env:t,namespace:a="html"})=>{let n=w({name:'block',isSvgRoot:0,namespace:a,env:t,draft:{type:'block',childTemplates:[],childCount:0,inParentIndex:0},isBlock:1,fn({},{mount:t}){e(),t.watch(pe.block)}});return()=>{z(ie,'(block instance)');let e={type:'blockItem',childTemplates:[],childCount:0,inParentIndex:-1,itemOf:n},{env:t,namespace:a}=ie;J(w({name:'block item',isSvgRoot:0,namespace:a,env:t,draft:e,fn(e,{mount:t}){t.watch(pe.blockItem)}}))}},e.h=(e,t)=>{function a(e){return e.data.block.value}function n(e,t,a){let n=e.data.block.child,r={type:'text',parent:n,visible:0,index:a,value:null};if(n.child[a]=r,e.hydration){let a=A(r);if(a)switch(a.type){case'text':r.value=e.env.document.createTextNode(t),a.value.after(r.value);break;case'element':r.value=a.value.nextSibling,b(r.value,t)}else{let e=R(r);r.value=e.firstChild,b(r.value,t)}r.visible=1}else r.value=e.env.document.createTextNode(t),N(r);return r}let o,s=0,c=0;'function'==typeof t?(s=1,o=t):t&&(c=1,t.fn&&(s=1,o=t.fn),t.ɔ&&('function'==typeof t.ɔ?(s=1,o=t.ɔ):'function'==typeof t.ɔ.fn&&(s=1,o=t.ɔ.fn))),z(ie,'h');let u,p=ie.env,f=ie.namespace,d=f,g='html';d=g='svg'===f?'svg':'html','svg'===e&&(g='svg',d='svg'),ie.isBlock||(u='svg'===g?p.document.createElementNS('http://www.w3.org/2000/svg',e):p.document.createElement(e));let P=u,I={type:'element',tag:e,attr:[],data:[],text:[],styleProp:[],styleVar:[],handler:[],stencil:P,seq:[],staticSeq:[],childTemplates:[],childCount:0,inParentIndex:-1,opsAmount:1,node:[]};'foreignObject'===f?(I.attr.push({xmlns:'http://www.w3.org/1999/xhtml'}),d='html'):'svg'===e?(I.attr.push({xmlns:'http://www.w3.org/2000/svg'}),d='svg'):'foreignObject'===e&&(d='foreignObject');let S=w({name:'element',draft:I,isSvgRoot:'svg'===e,namespace:d,fn(e,{mount:u}){function p(e){return K({mount:f,state:e,onMount:(e,t)=>({leaf:t,value:e}),onState:(e,t)=>({leaf:e,value:t})})}let f=effector.createEvent();s&&o(),c&&Q(t);let d={attr:{},data:{},text:I.text,styleProp:{},styleVar:{},visible:I.visible||null,handler:I.handler};for(let e=0;e<I.attr.length;e++){let t=I.attr[e];for(let e in t)'xlink:href'===e?d.attr.href=t[e]:d.attr[e]=t[e]}for(let e=0;e<I.data.length;e++){let t=I.data[e];for(let e in t)d.data[e]=t[e]}for(let e=0;e<I.styleProp.length;e++){let t=I.styleProp[e];for(let e in t)e.startsWith('--')?d.styleVar[e.slice(2)]=t[e]:d.styleProp[e]=t[e]}for(let e=0;e<I.styleVar.length;e++){let t=I.styleVar[e];for(let e in t)d.styleVar[e]=t[e]}d.visible&&I.seq.push({type:'visible',value:d.visible});for(let e in d.attr){let t=d.attr[e];effector.is.unit(t)?I.seq.push({type:'attr',field:e,value:t}):I.staticSeq.push({type:'attr',field:e,value:t})}for(let e in d.data){let t=d.data[e];effector.is.unit(t)?I.seq.push({type:'data',field:e,value:t}):I.staticSeq.push({type:'data',field:e,value:t})}for(let e in d.styleProp){let t=d.styleProp[e];effector.is.unit(t)?I.seq.push({type:'style',field:e,value:t}):I.staticSeq.push({type:'style',field:e,value:t})}for(let e in d.styleVar){let t=d.styleVar[e];effector.is.unit(t)?I.seq.push({type:'styleVar',field:e,value:t}):I.staticSeq.push({type:'styleVar',field:e,value:t})}for(let e=0;e<d.text.length;e++){let t=d.text[e];if(null!==t.value)if(effector.is.unit(t.value)){I.seq.push({type:'dynamicText',value:t.value,childIndex:t.index});let e=t.value.stateRef,a=le;a.plain.includes(e)||a.closure.includes(e)||a.closure.push(e)}else I.seq.push({type:'staticText',value:String(t.value),childIndex:t.index})}for(let e=0;e<d.handler.length;e++){let t=d.handler[e];for(let e in t.map)I.seq.push({type:'handler',for:e,handler:t.map[e],options:t.options,domConfig:t.domConfig})}if(d.visible){let{onMount:e,onState:t}=K({mount:u,state:d.visible,onMount:(e,t)=>({leaf:t,value:e,hydration:t.hydration}),onState:(e,t)=>({leaf:e,value:t,hydration:0})});e.watch(({leaf:e,value:t,hydration:a})=>{let n=e.data,l=n.block;if(a&&(r(t,n.ops.visible),t)){let e,t=D(l);if(e=t?t.nextSibling:R(l).firstChild,'#text'===e.nodeName){let t=e;e=e.nextSibling,t.remove()}l.value=e,l.visible=1}O(I,{parentBlockFragment:l.child,leaf:e,node:l.value,svgRoot:S.isSvgRoot?l.value:null}),t&&n.needToCallNode&&(n.needToCallNode=0,effector.launch({target:ue,params:{element:n.block.value,fns:I.node},page:e.spawn,defer:1,forkPage:e.forkPage})),effector.launch({target:f,params:e,defer:1,page:e.spawn,forkPage:e.forkPage})}),effector.merge([t,e]).watch(({leaf:e,value:t,hydration:a})=>{a||l(t,e.data.ops.visible)})}P&&h(P,I.staticSeq);for(let e=0;e<I.seq.length;e++){let t=I.seq[e];switch(t.type){case'visible':break;case'attr':{let{field:e}=t,n='value'===e||'checked'===e||'min'===e||'max'===e,{onMount:r,onState:o}=p(t.value);if(n)effector.merge([o,r]).watch(({leaf:t,value:n})=>{y(a(t),e,n)});else{let t=I.opsAmount++;r.watch(({value:n,leaf:r})=>{let l=a(r),o=i({value:n,priority:'props',runOp(t){y(l,e,t)},group:r.ops.group});r.ops.group.ops[t]=o,y(l,e,n)}),o.watch(({value:e,leaf:a})=>{l(e,a.ops.group.ops[t])})}break}case'data':{let{field:e}=t,{onMount:n,onState:r}=p(t.value),o=I.opsAmount++;n.watch(({value:t,leaf:n})=>{let r=a(n),l=i({value:t,priority:'props',runOp(t){k(r,e,t)},group:n.ops.group});n.ops.group.ops[o]=l,k(r,e,t)}),r.watch(({value:e,leaf:t})=>{l(e,t.ops.group.ops[o])});break}case'style':{let e=I.opsAmount++,{field:n}=t,{onMount:r,onState:o}=p(t.value);r.watch(({value:t,leaf:r})=>{let l=a(r),o=i({value:t,priority:'props',runOp(e){m(l,n,e)},group:r.ops.group});r.ops.group.ops[e]=o,m(l,n,t)}),o.watch(({value:t,leaf:a})=>{l(t,a.ops.group.ops[e])});break}case'styleVar':{let{field:e}=t,{onMount:n,onState:r}=p(t.value),o=I.opsAmount++;n.watch(({value:t,leaf:n})=>{let r=a(n),l=i({value:t,priority:'props',runOp(t){v(r,e,t)},group:n.ops.group});n.ops.group.ops[o]=l,v(r,e,t)}),r.watch(({value:e,leaf:t})=>{l(e,t.ops.group.ops[o])});break}case'staticText':f.watch(e=>{n(e,t.value,t.childIndex)});break;case'dynamicText':{let e=I.opsAmount++;effector.sample({source:t.value,clock:f,fn:(e,t)=>({value:String(e),leaf:t}),greedy:1}).watch(({value:a,leaf:r})=>{let l=i({value:a,priority:'props',runOp(e){b(o.value,e)},group:r.ops.group});r.ops.group.ops[e]=l;let o=n(r,a,t.childIndex)}),effector.sample({source:f,clock:t.value,fn:(e,t)=>({leaf:e,text:t}),greedy:1}).watch(({leaf:t,text:a})=>{l(a,t.ops.group.ops[e])});break}case'handler':{let e=t.handler.graphite.meta.nativeTemplate||null;f.watch(n=>{let r=null;if(e){let t=0,a=n.spawn;for(;!t&&a;)a.template===e?(t=1,r=a):a=a.parent}a(n).addEventListener(t.for,e=>{t.options.prevent&&e.preventDefault(),t.options.stop&&e.stopPropagation(),effector.launch({target:x(t.handler,n.forkPage),params:e,page:r,forkPage:n.forkPage})},t.domConfig)});break}}}u.watch(e=>{let t=e.data;if(!I.visible){let a=t.ops.visible,n=t.block;if(e.hydration){r(1,a);let e,t=D(n);if(e=t?t.nextSibling:R(n).firstChild,'#text'===e.nodeName){let t=e;e=e.nextSibling,t.remove()}n.value=e,n.visible=1}O(I,{parentBlockFragment:n.child,leaf:e,node:n.value,svgRoot:S.isSvgRoot?n.value:null}),effector.launch({target:f,params:e,defer:1,page:e.spawn,forkPage:e.forkPage}),e.hydration?t.needToCallNode&&(t.needToCallNode=0,effector.launch({target:ue,params:{element:t.block.value,fns:I.node},page:e.spawn,defer:1,forkPage:e.forkPage})):l(1,a)}})},env:p});J(S)},e.handler=U,e.list=H,e.node=e=>{z(ie,'node');let t=ie.draft;switch(t.type){case'list':case'listItem':case'using':case'route':case'rec':case'recItem':case'block':case'blockItem':return void console.error('node() hook supported only in h() nodes')}t.node.push(e)},e.rec=Z,e.remap=M,e.route=$,e.spec=Q,e.text=(e,...t)=>{let a=[e[0]];for(let n=0;n<t.length;n++)a.push(t[n],e[n+1]);Q({text:a})},e.tree=({source:e,key:t,child:a,fn:n})=>{let r=Z(({store:e})=>{H({source:e,key:t,fn({store:e}){let t=e.map(e=>e[a]||[]);n({store:e,child(){r({store:t})}})}})});r({store:e})},e.using=(e,t)=>{let a,n,r,l,o,i;if('function'==typeof t)a=t,r=G(),l=0;else{if(!t)throw Error('using() second argument is missing');a=t.fn,r=t.env?t.env:G(),l=t.hydrate,n=t.onComplete,o=t.onRoot,i=t.scope}j(e,'using() first argument is missing');let u=e.namespaceURI,p=e.tagName.toLowerCase(),f={type:'using',childTemplates:[],childCount:0,inParentIndex:-1},d=w({name:'using',draft:f,isSvgRoot:'svg'===p,namespace:'http://www.w3.org/2000/svg'===u?'svg':'foreignobject'===p?'foreignObject':'html',fn(e,{mount:t}){a(),t.watch(pe.using)},env:r}),h={type:'using',child:{type:'fragment',parent:null,child:[]},value:e};h.child.parent=h,(e=>{if(e&&!e.nodeMap){let t={};for(let a=0;a<e.clones.length;a++){let n=e.clones[a];t[n.meta.forkOf.id]=n}e.nodeMap=t}})(i);let g=s({onComplete:n}),v=T(d,{parentLeaf:oe||null,mountNode:e,svgRoot:d.isSvgRoot?e:oe?oe.svgRoot:null,leafData:{type:'using',draft:f,element:e,block:h},opGroup:c(g),domSubtree:c(g),hydration:l,forkPage:i,env:r});if(o&&o({template:d,leaf:v}),g.onDrain&&!g.rafID){let e=g.onDrain;g.onDrain=null,e()}},e.variant=({source:e,cases:t,key:a})=>{let n;z(ie,'variant'),j(effector.is.unit(e),'variant({source}) should be unit'),n='function'==typeof a?a:null==a?e=>String(e):e=>String(e[a]);let r=0;for(let a in t)'__'!==a?$({source:e,visible:e=>n(e)===a,fn:t[a]}):r=1;if(r){let a=Object.keys(t);$({source:e,visible:e=>!a.includes(n(e)),fn:t.__})}},Object.defineProperty(e,'__esModule',{value:1})}); | ||
//# sourceMappingURL=forest.umd.js.map |
@@ -197,2 +197,7 @@ import {Store, Event, Fork} from 'effector' | ||
}): void | ||
export function route<T>(config: { | ||
source: Store<T> | ||
visible: Store<boolean> | ||
fn: (config: {store: Store<T>}) => void | ||
}): void | ||
@@ -199,0 +204,0 @@ export function node(fn: (node: DOMElement) => void): void |
{ | ||
"name": "forest", | ||
"version": "0.19.2", | ||
"version": "0.19.3", | ||
"description": "UI engine for web", | ||
@@ -24,3 +24,3 @@ "main": "forest.cjs.js", | ||
"peerDependencies": { | ||
"effector": "^21.2.2" | ||
"effector": "^21.5.0" | ||
}, | ||
@@ -51,4 +51,4 @@ "keywords": [ | ||
"scripts": {}, | ||
"repository": "https://github.com/zerobias/effector", | ||
"bugs": "https://github.com/zerobias/effector/issues", | ||
"repository": "https://github.com/effector/effector", | ||
"bugs": "https://github.com/effector/effector/issues", | ||
"homepage": "https://effector.now.sh", | ||
@@ -55,0 +55,0 @@ "engines": { |
256
README.md
# forest | ||
## UI engine for web | ||
**UI engine for web** | ||
### Usage | ||
## Usage | ||
@@ -79,1 +79,253 @@ ```js | ||
[Try it](https://share.effector.dev/e2FuOsag) | ||
## API | ||
### using | ||
Start an application from given root dom node. Can accept forked [Scope](https://effector.now.sh/docs/api/effector/scope). Set `hydrate: true` to reuse `root` html content (useful for ssr) | ||
```typescript | ||
function using(root: DOMElement, fn: () => void): void | ||
function using( | ||
root: DOMElement, | ||
config: { | ||
fn: () => void | ||
hydrate?: boolean | ||
scope?: Scope | ||
}, | ||
): void | ||
``` | ||
### h | ||
Declare single dom element. | ||
```typescript | ||
function h(tag: string, fn: () => void): void | ||
function h( | ||
tag: string, | ||
config: { | ||
attr?: PropertyMap | ||
style?: PropertyMap | ||
styleVar?: PropertyMap | ||
data?: PropertyMap | ||
text?: Property | Property[] | ||
visible?: Store<boolean> | ||
handler?: | ||
| {[domEvent: string]: Event<any>} | ||
| { | ||
config: { | ||
passive?: boolean | ||
capture?: boolean | ||
prevent?: boolean | ||
stop?: boolean | ||
} | ||
on: {[domEvent: string]: Event<any>} | ||
} | ||
fn?: () => void | ||
}, | ||
): void | ||
``` | ||
> See also: [PropertyMap](#PropertyMap), [Property](#Property) | ||
**Config fields**: | ||
- **attr**: add HTML attributes, e.g. `class` or input's `value`. `{value: createStore('initial')}` will become `"value"="initial"` | ||
- **style**: add inline styles. All `style` objects will be merged to single `style` html attribute. Object fields in camel case will be converted to dash-style, e.g. `{borderRadius: '3px'}` will become `"style"="border-radius: 3px"`. | ||
- **styleVar**: add css variables to inline styles. `{themeColor: createStore('red')}` will become `"style"="--themeColor: red"` | ||
- **data**: add [data attributes](https://developer.mozilla.org/en-US/docs/Learn/HTML/Howto/Use_data_attributes). Object fields in camel case will be converted to dash-style, e.g. `{buttonType: 'outline'}` will become `"data-button-type"="outline"` and might be queried in css in this way: | ||
```css | ||
[data-button-type='outline'] { | ||
} | ||
``` | ||
- **text**: add text to element as [property](#Property) or array of properties | ||
- **visible**: node will be presented in dom tree while store value is `true`. Useful for conditional rendering | ||
- **handler**: add event handlers to dom node. In cases when `preventDefault` or `stopPropagation` is needed, extended form with config object can be used | ||
```typescript | ||
const click = createEvent<MouseEvent>() | ||
h('button', { | ||
text: 'Click me', | ||
handler: {click}, | ||
}) | ||
h('a', { | ||
text: 'Click me', | ||
handler: { | ||
config: {prevent: true}, | ||
on: {click}, | ||
}, | ||
}) | ||
``` | ||
> **Handler config fields**: | ||
> | ||
> - **passive**: event handler will be defined as [passive](https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#Improving_scrolling_performance_with_passive_listeners) | ||
> - **capture**: event handler will be defined with [`capture: true`](https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Building_blocks/Events#Event_bubbling_and_capture) | ||
> - **prevent**: call [`preventDefault()`](https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault) on trigger | ||
> - **stop**: call [`stopPropagation()`](https://developer.mozilla.org/en-US/docs/Web/API/Event/stopPropagation) on trigger | ||
- **fn**: add childrens to given element by nesting api methods calls | ||
### spec | ||
Add new properties to dom element. Designed to call from [h](#h) callbacks and has the same fields as in `h(tag, config)`. Can be called as many times as needed | ||
```typescript | ||
function spec(config: { | ||
attr?: PropertyMap | ||
style?: PropertyMap | ||
styleVar?: PropertyMap | ||
data?: PropertyMap | ||
text?: Property | Property[] | ||
visible?: Store<boolean> | ||
handler?: | ||
| {[domEvent: string]: Event<any>} | ||
| { | ||
config: { | ||
passive?: boolean | ||
capture?: boolean | ||
prevent?: boolean | ||
stop?: boolean | ||
} | ||
on: {[domEvent: string]: Event<any>} | ||
} | ||
}): void | ||
``` | ||
### list | ||
Render array of items from store | ||
```typescript | ||
function list<T>(source: Store<T[]>, fn: (config: {store: Store<T>, key: Store<number>}) => void): void | ||
function list<T>(config: { | ||
source: Store<T[]>, | ||
key: string | ||
fields?: string[] | ||
fn: (config: {store: Store<T>, key: Store<any>, fields: Store<any>[]}) => void): void | ||
}): void | ||
``` | ||
**Config fields**: | ||
- **source**: store with array of items | ||
- **key**: field name which value will be used as key for given item | ||
- **fn**: function which will be used as a template for every list item. Receive item value and item key as stores and `fields` as array of stores if provided. All fields are strongly typed and inferred from config definition | ||
- **fields**: array of item field names which will be passed to `fn` as array of separate stores. Useful to avoid `store.map` and [`remap`](#remap) calls | ||
### variant | ||
Mount one of given cases by selecting a specific one by the current value of the `key` field of `source` store value. Type of `store` in `cases` functions will be inferred from a case type. Optional default case - `__` (like in [split](https://effector.now.sh/docs/api/effector/split)) | ||
```typescript | ||
function variant<T>(config: { | ||
source: Store<T> | ||
key: string | ||
cases: {[caseName: string]: ({store: Store<T>}) => void} | ||
}): void | ||
``` | ||
### route | ||
Generailzed route is a combination of state and visibility status. `fn` content will be mounted until `visible` called with `source` value will return `true`. In case of store in `visible` field, content will be mounted while that store contain `true`. [variant](#variant) is shorthand for creating several routes at once | ||
```typescript | ||
function route<T>(config: { | ||
source: Store<T> | ||
visible: ((value: T) => boolean) | Store<boolean> | ||
fn: (config: {store: Store<T>}) => void | ||
}): void | ||
``` | ||
### text | ||
Use template literals to add text to dom node. Accept any [properties](#Property) | ||
```typescript | ||
function text(words: TemplateStringsArray, ...values: Property[]): void | ||
``` | ||
**Example** | ||
```typescript | ||
const username = createStore('guest') | ||
h('h1', () => { | ||
text`Hello ${username}!` | ||
}) | ||
``` | ||
### rec | ||
Provide support for recursive templates. Can be called outside from [using](#using) calls | ||
```typescript | ||
function rec<T>(config: {store: Store<T>}): (config: {store: Store<T>}) => void | ||
``` | ||
### block | ||
Allow to define and validate template outside from [using](#using) calls. | ||
```typescript | ||
function block(config: {fn: () => void}): () => void | ||
``` | ||
### renderStatic | ||
Method from `forest/server` to render given application to string. Can accept forked [Scope](https://effector.now.sh/docs/api/effector/scope), in which case `fn` childs must be wrapped in [block](#block) to ensure that all units are created before [fork](https://effector.now.sh/docs/api/effector/fork) call | ||
```typescript | ||
function renderStatic(fn: () => void): Promise<string> | ||
function renderStatic(config: {scope?: Scope; fn: () => void}): Promise<string> | ||
``` | ||
### remap | ||
Helper for retrieving value fields from single store. Shorthand for several `store.map(val => val[fieldName])` calls. Infer types when used with either single key or whith `as const`: `const [id, name] = remap(user, ['id', 'name'] as const)` | ||
```typescript | ||
function remap<T>(store: Store<T>, keys: string[]): Store<any>[] | ||
function remap<T>(store: Store<T>, key: string): Store<any> | ||
``` | ||
## Type terms | ||
### PlainProperty | ||
Value types accepted by methods, which write values to dom properties. Strings are written as is, numbers are converted to strings, `null` and `false` mean no value (property deletion), `true` is used when the specific property value is not needed. | ||
```typescript | ||
type PlainProperty = string | number | null | boolean | ||
``` | ||
### Property | ||
In most cases [dom properties](#PlainProperty) can be wrapped in stores, thereby making result value dynamic | ||
```typescript | ||
type Property = PlainProperty | Store<PlainProperty> | ||
``` | ||
### PropertyMap | ||
Object with [dom properties](#Property), possibly reactive | ||
```typescript | ||
type PropertyMap = {[field: string]: Property} | ||
``` |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
620653
6990
1266
331