Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

forest

Package Overview
Dependencies
Maintainers
3
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

forest - npm Package Compare versions

Comparing version 0.16.7 to 0.16.8

2

forest.umd.js

@@ -1,2 +0,2 @@

((e,t)=>{'object'==typeof exports&&'undefined'!=typeof module?t(exports):'function'==typeof define&&define.amd?define(['exports'],t):t((e=e||self).forest={})})(this,e=>{function t(e,t="combine"){let a=t+'(',r='',n=0;for(let t in e){let l=e[t];if(null!=l&&(a+=r,a+=Y(l)?l.compositeName.fullName:l.toString()),n+=1,25===n)break;r=', '}return a+=')',a}function a({node:e=[],from:t,source:a,parent:r=t||a,to:n,target:l,child:o=n||l,scope:i={},meta:s={},family:u={type:'regular'}}={}){let p=je(r),c=je(u.links),d=je(u.owners),f=[],h={};for(let t=0;t<e.length;t++){let a=e[t];a&&(f.push(a),Be(a,h))}let m={seq:f,next:je(o),meta:s,scope:i,family:{type:u.type||'crosslink',links:c,owners:d},reg:h};for(let e=0;e<c.length;e++)se(c[e]).push(m);for(let e=0;e<d.length;e++)ue(d[e]).push(m);for(let e=0;e<p.length;e++)p[e].next.push(m);return m}function r(e,t){dt={parent:dt,value:e,template:ie(e).meta.template||dt&&dt.template};try{return t()}finally{dt=me(dt)}}function n(e,t){let r=(e,...t)=>r.create(e,t,t);r.graphite=a({meta:yt('event',r,t,e)}),r.create=e=>(tt(r,e),e),r.watch=xe(mt,r),r.map=e=>{let t,a;le(e)&&(t=e,a=e.name,e=e.fn);let l=n(ve(r,a),t);return bt(r,l,'map',e),l},r.filter=e=>oe(e)?(console.error('.filter(fn) is deprecated, use .filterMap instead'),l(r,e)):kt(r,'filter',e.fn,[Pe({fn:ze})]),r.filterMap=xe(l,r),r.prepend=e=>{let t=n('* → '+r.shortName,{parent:me(r)}),a=ft();return a&&ie(t).seq.push(a.upward),bt(t,r,'prepend',e),((e,t)=>{me(e)&&me(e).hooks.event(t)})(r,t),t};let o=ft();return o&&(ie(r).meta.nativeTemplate=o),ct(r)}function l(e,t){return kt(e,'filterMap',t,[qe({fn:ze}),Fe()])}function o(e,t){function r(e,t){p.off(e),he(p).set(e,pt(wt(e,p,'on',1,t)))}let l=Me(e),i=Me(e),s=(()=>n({named:'updates'}))(),u=ft();l.after=[{type:'copy',to:i}],u&&u.plain.push(l);let p={subscribers:new Map,updates:s,defaultState:e,stateRef:l,getState(){let e=et();return Oe(e&&e.reg[l.id]?e.reg[l.id]:l)},setState(e){tt({target:p,params:e,defer:1})},reset(...e){for(let t of e)p.on(t,()=>p.defaultState);return p},on(e,t){if(Array.isArray(e))for(let a of e)r(a,t);else r(e,t);return p},off(e){let t=he(p).get(e);return t&&(t(),he(p).delete(e)),p},map(e,t){let a,r,n;le(e)&&(a=e,r=e.name,t=e.firstState,e=e.fn);let i=p.getState(),s=ft();s?n=null:void 0!==i&&(n=e(i,t));let u=o(n,{name:ve(p,r),config:a,strict:0}),c=wt(p,u,'map',0,e);return pe(u).before=[{type:'map',fn:e,from:l}],s&&(s.plain.includes(l)||c.seq.includes(s.loader)||c.seq.unshift(s.loader)),u},watch(e,t){if(!t||!Y(e)){oe(e)||ne('watch requires function handler');let t=ft();return t?t.watch.push({of:l,fn:e}):e(p.getState()),mt(p,e)}return oe(t)||ne('second argument should be a function'),e.watch(e=>t(p.getState(),e))}};return p.graphite=a({scope:{state:l},node:[Fe(),De({store:l}),Ae({store:i}),De({store:i})],child:s,meta:yt('store',p,t)}),vt&&void 0===e&&ne("current state can't be undefined, use null instead"),u&&(ie(p).meta.nativeTemplate=u),Le(p,[s]),ct(p)}function i(...e){let t,r,l;rt(e[0],(t,a)=>{l=t,e=a});let i,[s,u,p,c=0]=e;void 0===u&&'source'in s&&('clock'in s&&null==s.clock&&ne('config.clock should be defined'),u=s.clock,p=s.fn,c=s.greedy,t=s.target,r=s.name,i=s.sid,s=s.source),void 0===u&&(u=s),r=l||r||s.shortName,s=Tt(s),u=Tt(u),'boolean'==typeof p&&(c=p,p=null);let d=ft(),f=!!t;t||(ee(s)&&ee(u)?t=o(p?p(Oe(pe(s)),Oe(pe(u))):Oe(pe(s)),{name:r,sid:i}):(t=n(r),d&&ie(t).seq.push(d.loader)));let h=f&&Y(t)&&ie(t).meta.nativeTemplate;if(ee(s))Le(s,[ht(u,t,{scope:{fn:p,targetTemplate:h},node:[d&&d.loader,!c&&Te({priority:'sampler'}),Ce({store:pe(s),to:p?'a':'stack'}),p&&qe({fn:Ve}),d&&f&&d.upward],meta:{op:'sample',sample:'store'}})]);else{let e=Me(0),r=Me(),n=Me();d&&d.plain.push(e,r,n),ct(a({parent:s,node:[De({store:r}),Ce({from:'value',store:1,target:e})],family:{owners:[s,t,u],links:t},meta:{op:'sample',sample:'source'}})),Le(s,[ht(u,t,{scope:{fn:p,targetTemplate:h},node:[d&&d.loader,De({store:n}),Ce({store:e}),Pe({fn:e=>e}),!c&&Te({priority:'sampler'}),Ce({store:r}),Ce({store:n,to:'a'}),p&&qe({fn:Ee}),d&&f&&d.upward],meta:{op:'sample',sample:'clock'}})])}return t}function s(e){let r=n(t(e,'merge'));return(e=>{let t;rt(e,(a,r)=>{t=a,e=r});let{from:r,to:n,meta:l={op:'forward'}}=e;r&&n||ne('from and to fields should be defined'),t&&(l.config=t),pt(ct(a({parent:r,child:n,meta:l,family:{}})))})({from:e,to:r,meta:{op:'merge'}}),r}function u(e,t,a){if(ee(e))return e;if(Y(e)){let r,n=me(e);return te(e)&&(r=o(t,{parent:n,name:e.shortName,ɔ:a}).on(e,(e,t)=>t)),ae(e)&&(r=o(t,{parent:n,name:e.shortName,ɔ:a}).on(e.done,(e,{result:t})=>t)),n&&n.hooks.store(r),r}let r={};return xt(e,(e,t)=>{r[t]=ee(e)?e:o(e,{name:t})}),r}function p(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 c(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})(d(e),e)}function d(e){return e.group.activeChilds[e.priority]}function f(e,t){t.value.active=t.value.pending=e,'active'!==t.status&&c(t)}function h(e,t){if(t.value.active===e)return t.value.pending=e,void('pending'===t.status&&(c(t),d(t).first||p(t.group,t.priority)));'active'===t.status&&(t.status='pending',d(t).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})(t.group,t.priority),((e,t)=>{e.last?(t.cursor.prev=e.last,e.last.cursor.next=t,e.last=t):e.first=e.last=t})(d(t),t)),t.value.pending=e,t.group.queue.rafID||(t.group.queue.rafID=Ct(t.group.queue.execQueue))}function m(e){St('execQueue');let t,a,r=Rt(),n=0;e:for(;e.props.first||e.tree.first||e.data.first;){if(Rt()-r>=10){n=1;break e}let l=!!e.props.first;for(l&&St('props');t=e.props.first;){for(;a=t.activeChilds.props.first;){if(Rt()-r>=10){n=1,It('props');break e}a.runOp(a.value.pending),a.value.active=a.value.pending,c(a)}p(t,'props')}l&&It('props');let o=!!e.tree.first;for(o&&St('tree');t=e.tree.first;){for(;a=t.activeChilds.tree.first;){if(Rt()-r>=10){n=1,It('tree');break e}a.runOp(a.value.pending),a.value.active=a.value.pending,c(a)}p(t,'tree')}o&&It('tree');let i=!!e.data.first;for(i&&St('data');t=e.data.first;){for(;a=t.activeChilds.data.first;){if(Rt()-r>=10){n=1,It('data');break e}a.runOp(a.value.pending),a.value.active=a.value.pending,c(a)}p(t,'data')}i&&It('data')}if(It('execQueue'),n)e.rafID=Ct(e.execQueue);else if(e.rafID=null,e.onDrain){let t=e.onDrain;e.onDrain=null,t()}}function g({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 v({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=m.bind(null,t),t}function y(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 b({value:e,group:t,onInit:a,onChange:r,onTerminate:n}){let l=g({value:e,group:t,runOp(e){o.status='A',r(e)},priority:'data'}),o={status:'IA',value:l.value,hooks:{onTerminate:n},ops:{init:g({value:0,group:t,runOp(e){o.status='A',a(o.value.active)},priority:'data'}),change:l,terminate:g({value:0,group:t,runOp(e){o.status='T',o.hooks.onTerminate(1)},priority:'data'})}};return h(1,o.ops.init),o}function k(e){switch(e.status){case'I':case'T':case'AT':return;case'A':e.status='AT',h(1,e.ops.terminate);break;case'AA':e.status='AT',h(1,e.ops.terminate),h(e.value.active,e.ops.change);break;case'IA':e.status='T',h(0,e.ops.init),e.hooks.onTerminate(0)}}function w(e,t){switch(t.status){case'I':case'T':return;case'A':t.value.active!==e&&(t.status='AA',h(e,t.ops.change));break;case'AA':t.value.active===e?(t.status='A',h(e,t.ops.change)):t.value.pending!==e&&(t.value.pending=e);break;case'IA':t.value.active=t.value.pending=e}}function x(e){return''!==e&&0!==e&&'0'!==e&&(0==e||null==e)}function S(e,t,a){x(a)?e.style.removeProperty("--"+t):e.style.setProperty("--"+t,""+a)}function I(e,t,a){x(a)?delete e.style[t]:e.style[t]=""+a}function R(e,t,a){x(a)?delete e.dataset[t]:e.dataset[t]=""+a}function T(e,t,a){if(x(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 C(e,t){e.replaceData(0,(e.textContent||'').length,String(t))}function F({fn:e,state:t={},defer:l=0,name:o="",draft:i,isSvgRoot:s,namespace:p,env:c}){let d=Nt,f=qt,h={id:++Ft,name:o,plain:[],watch:[],nameMap:{},pages:[],closure:[],childTemplates:[],upward:Pe({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 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)?tt({target:t,params:e,defer:1,page:n[r.indexOf(l)],stack:a}):console.error('context drift',{stack:a,node:t}):tt({target:t,params:e,defer:1,page:null,stack:a})}),0}}),loader:Pe({fn(e,t,a){if(a.parent){if(a.page){if(!a.page.active)return 0;if(a.page.template===h)return 1;if(a.page.childSpawns[h.id])a.page.childSpawns[h.id].forEach(t=>{tt({params:e,target:a.node,page:t,defer:1})});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);tt(-1===n?{params:e,target:a.node,page:null,defer:1}:{params:e,target:a.node,page:r[n],defer:1})}else h.pages.forEach(t=>{t.fullID.startsWith(a.page.fullID)&&tt({params:e,target:a.node,page:t,defer:1})})}else h.pages.forEach(t=>{tt({params:e,target:a.node,page:t,defer:1})});return 0}return 1}}),parent:f};f&&f.childTemplates.push(h);let m=a({meta:{template:h}});qt=h;let g=Nt={template:h,node:m,api:null,trigger:{mount:n(),unmount:n()},draft:i,isSvgRoot:s,namespace:p,env:c};return l?g.deferredInit=()=>{let a=Nt,n=qt;Nt=g,qt=h,g.deferredInit=null;try{r(m,()=>{let a=u(t);g.api=e(a,g.trigger),h.nameMap=a})}finally{Nt=a,qt=n}}:r(m,()=>{let a=u(t);g.api=e(a,g.trigger),h.nameMap=a}),Nt=d,qt=f,h.actor=g,g}function A(e){switch(e.type){case'list':return[...e.current];case'shape':return{...e.current};default:return e.current}}function q(e,t){let a=t;for(;a&&!a.spawn.reg[e.id];)a=a.parentLeaf;return a?a.spawn.reg[e.id].current:e.current}function P(e,{values:t={},parentLeaf:a,mountNode:r,svgRoot:n,leafData:l,opGroup:o,domSubtree:i,hydration:s}){function u(e){if(e.before)for(let t of e.before)switch(t.type){case'map':{let a=t.from;f[a.id]||(f[a.id]=a),f[e.id].current=t.fn(f[a.id].current);break}case'field':{let a=t.from;f[a.id]||(f[a.id]=a),f[e.id].current[t.field]=f[a.id].current;break}case'closure':f[t.of.id]||(f[t.of.id]=t.of)}if(!e.after)return;let t=f[e.id].current;for(let a of e.after){let e=a.to;switch(f[e.id]||(f[e.id]={id:e.id,current:e.current}),a.type){case'copy':f[e.id].current=t;break;case'map':f[e.id].current=a.fn(t)}}}function p(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:q(r.of,g.parentLeaf))}catch(e){console.error(e),t.stop=0}}let c=a?a.spawn:null,d=e.template,f={},h={id:++At,fullID:'',reg:f,template:d,parent:c,childSpawns:{},active:1};d.pages.push(h);let m={},g={spawn:h,api:m,draft:e.draft,ops:{group:o,domSubtree:i},svgRoot:n,data:l,parentLeaf:a,hydration:s},v=Pt;Pt=g,c&&(c.childSpawns[d.id]||(c.childSpawns[d.id]=[]),c.childSpawns[d.id].push(h)),h.fullID=c?`${c.fullID}_${h.id}`:""+h.id,c&&Object.assign(f,c.reg);for(let e of d.closure){let t=e,a=h.parent;e:for(;a;){if(e.id in a.reg){t=a.reg[e.id];break e}a=a.parent}f[e.id]=t}for(let e of d.plain){let t={id:e.id,current:A(e)};f[e.id]=t}for(let e in t){let a=d.nameMap[e].stateRef.id;f[a]={id:a,current:t[e]}}for(let e of d.closure)u(e);for(let e of d.plain)u(e);let y={i:0,stop:0};for(;!y.stop;)p(d.watch,y,f);if(c)for(let e in h.childSpawns)e in c.childSpawns||(c.childSpawns[e]=[]),c.childSpawns[e].push(...h.childSpawns[e]);if(m.mount=(t,a=1)=>tt({target:e.trigger.mount,params:t,defer:a,page:h}),m.unmount=(t,a=1)=>tt({target:e.trigger.unmount,params:t,defer:a,page:h}),e.api)for(let t in e.api)m[t]=(a,r=1)=>tt({target:e.api[t],params:a,defer:r,page:h});return g.spawn.api=m,g.spawn.leaf=g,g.api.mount({node:r,leaf:g}),Pt=v,g}function N(e){let t=function e(t){switch(t.type){case'fragment':switch(t.parent.type){case'EF':case'UF':return t.parent.parent}return e(t.parent.parent);case'route':default:return e(t.parent.parent)}}(e);return t?t.value:null}function D(e){if(!e.visible)return null;switch(e.type){case'FE':case'FT':return e.child;case'FR':return D(e.child.child);case'LF':case'RF':case'FF':return M(e.child);case'FRec':case'FRecItem':return M(e.child.child.child);case'FL':{let t=e.child.lastChild;if(!t)return null;for(;t;){let e=D(t);if(e)return e;t=t.left}return null}default:return null}}function M(e){let t=e.child;for(let e=t.length-1;e>=0;e--){let a=D(t[e]);if(a)return a}return null}function O(e){if('fragment'===e.type)switch(e.parent.type){case'EF':case'UF':return null;case'RecF':case'RecItemF':case'RF':{let t=e.parent.parent.parent,a=t.parent;for(let e=t.index-1;e>=0;e--){let t=D(a.child[e]);if(t)return t}return O(a)}case'FF':{let t=e.parent,a=t.parent;for(let e=t.index-1;e>=0;e--){let t=D(a.child[e]);if(t)return t}return O(a)}case'LF':{let t=e.parent.left;for(;t;){let e=D(t);if(e)return e;t=t.left}return O(e.parent.parent)}default:return null}if('route'===e.type){let t=e.parent.parent;for(let a=e.parent.index-1;a>=0;a--){let e=t.child[a];if(!e)continue;let r=D(e);if(r)return r}return O(t)}let t=e.parent.parent;for(let a=e.parent.index-1;a>=0;a--){let e=t.child[a];if(!e)continue;let r=D(e);if(r)return r}return O(t)}function E(e){let t=O(e);return t?t.value:null}function V(e,{parentBlockFragment:t,leaf:a,node:r,svgRoot:n,values:l}){e.childTemplates.forEach(e=>{z({parentBlockFragment:t,leaf:a,node:r,svgRoot:n,values:l,actor:e})})}function z({parentBlockFragment:e,leaf:t,node:a,actor:r,svgRoot:n,values:l}){let o,{draft:i}=r,{queue:s}=t.ops.group,u=y(s),p=t.ops.domSubtree,c=p;switch(i.type){case'route':{let t={type:'route',parent:{type:'FR',parent:e,child:null,visible:1,index:i.inParentIndex},child:{type:'RF',parent:null,child:{type:'fragment',parent:null,child:[]},visible:0}};t.parent.child=t,t.child.parent=t,t.child.child.parent=t.child,e.child[i.inParentIndex]=t.parent,o={type:'route',block:t,ops:{},initialized:0};break}case'element':{let t={type:'element',parent:{type:'FE',parent:e,child:null,visible:0,index:i.inParentIndex},child:{type:'EF',parent:null,child:{type:'fragment',parent:null,child:[]}},value:i.stencil.cloneNode()};t.parent.child=t,t.child.parent=t,t.child.child.parent=t.child,e.child[i.inParentIndex]=t.parent,o={type:'element',block:t,ops:{visible:g({value:0,priority:'tree',runOp(e){e?(L(t),o.needToCallNode&&(o.needToCallNode=0,tt({target:Dt,params:{element:t.value,fns:i.node},page:d.spawn}))):(t.value.remove(),t.parent.visible=0)},group:p})},needToCallNode:i.node.length>0},c=y(s);break}case'list':{let t={type:'list',parent:{type:'FL',parent:e,child:null,visible:1,index:i.inParentIndex},child:[],lastChild:null};t.parent.child=t,e.child[i.inParentIndex]=t.parent,o={type:'list',draft:i,block:t};break}case'using':case'listItem':break;case'rec':{let t={type:'rec',parent:{type:'FRec',parent:e,child:null,visible:1,index:i.inParentIndex},child:{type:'RecF',parent:null,child:{type:'fragment',parent:null,child:[]}}};t.parent.child=t,t.child.parent=t,t.child.child.parent=t.child,e.child[i.inParentIndex]=t.parent,o={type:'rec',block:t};break}case'recItem':{let t={type:'recItem',parent:{type:'FRecItem',parent:e,child:null,visible:1,index:i.inParentIndex},child:{type:'RecItemF',parent:null,child:{type:'fragment',parent:null,child:[]}}};t.parent.child=t,t.child.parent=t,t.child.child.parent=t.child,e.child[i.inParentIndex]=t.parent,o={type:'rec item',block:t};break}default:console.warn("unexpected draft type "+i.type)}let d=P(r,{values:l,parentLeaf:t,mountNode:a,svgRoot:n||t.svgRoot,leafData:o,opGroup:u,domSubtree:c,hydration:t.hydration})}function L(e){let t=E(e);t?t.after(e.value):N(e).prepend(e.value),e.parent.visible=1}function j(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 B(){if('undefined'!=typeof document)return{document};throw Error('your environment has no document')}function U(e){let t=Nt.draft;switch(t.type){case'list':return void(e.visible&&(t.itemVisible=e.visible));case'listItem':case'using':case'route':case'rec':case'recItem':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&&t.styleProp.push(e.style),e.styleVar&&t.styleVar.push(e.styleVar),e.visible&&(t.visible=e.visible),e.handler){let t=e.handler;'object'==typeof t.on?_(t.config||{},t.on):_(t)}e.ɔ&&U(e.ɔ)}function _(e,t){if(!Nt)return;let a=Nt.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(!Y(t[e]))throw Error(`handler for "${e}" should be event`);let{passive:r=1,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 Q({source:e,visible:t,fn:a}){if(!Nt)throw Error('route() called outside from using() closure');let r=F({name:'route',isSvgRoot:0,namespace:Nt.namespace,env:Nt.env,draft:{type:'route',childTemplates:[],childCount:0,inParentIndex:-1},fn(r,{mount:l,unmount:o}){let u=e.map(e=>({value:e,visible:t(e)})),p={type:'route',childTemplates:[],childCount:0,inParentIndex:-1},c=F({name:'route item',isSvgRoot:0,namespace:Nt.namespace,env:Nt.env,draft:p,state:{store:null},fn({store:e},{mount:t,unmount:r}){let l=n();e.on(l,(e,t)=>t),a({store:e});let o=i({source:t,clock:u,fn:({leaf:e,node:t},{visible:a,value:r})=>({leaf:e,visible:a,node:t,value:r}),greedy:1});t.watch(({leaf:e,node:t})=>{let a=e.data;a.block.child.visible=1,V(p,{parentBlockFragment:a.block.child.child,leaf:e,node:t})}),o.watch(({leaf:e,visible:t,value:a})=>{e.data.block.child.visible=t,t&&tt({target:l,params:a,defer:1,page:e.spawn}),$(t,e)}),i({source:t,clock:r,greedy:1}).watch(({leaf:e})=>{G(e,e=>{e.api.unmount()});let{spawn:t}=e;t.active=0,K(t,t.parent.childSpawns[t.template.id]),K(t,t.template.pages)})}});J(c);let{onMount:d,onState:f}=X({mount:l,state:u,onMount:({visible:e,value:t},{leaf:a,node:r})=>({leaf:a,visible:e,node:r,value:t}),onState:({leaf:e,node:t},{visible:a,value:r})=>({leaf:e,visible:a,node:t,value:r})});s([d,f]).watch(({leaf:e,visible:t,value:a,node:r})=>{let n=e.data;n.block.child.visible=t,t&&!n.initialized&&(z({parentBlockFragment:n.block.child.child,leaf:e,node:r,actor:c,values:{store:a}}),n.initialized=1)}),i({source:l,clock:o,greedy:1}).watch(({leaf:e})=>{G(e,e=>{e.api.unmount()});let{spawn:t}=e;t.active=0,K(t,t.parent.childSpawns[t.template.id]),K(t,t.template.pages)})}});J(r)}function $(e,t){let a=t=>{let r=t.data;switch(r.type){case'element':h(e,r.ops.visible);break;case'route':case'list':case'list item':G(t,a);break;default:console.log('unsupported type',r.type)}};G(t,a)}function G(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 W(e){let t={type:'rec',childTemplates:[],childCount:0,inParentIndex:0},a=F({name:'rec',state:{store:null},isSvgRoot:0,namespace:Nt.namespace,env:Nt.env,draft:t,defer:1,fn({store:a},{mount:r,unmount:l}){e({state:a});let o=n();return a.on(o,(e,t)=>t),r.watch(({node:e,leaf:a})=>{V(t,{parentBlockFragment:a.data.block.child.child,leaf:a,node:e})}),i({source:r,clock:l,greedy:1}).watch(({leaf:e})=>{e.spawn.active=0,G(e,e=>{e.api.unmount()})}),{itemUpdater:o}}});return({state:e})=>{a.deferredInit&&a.deferredInit();let{env:t,namespace:r}=Nt;J(F({name:'rec item',isSvgRoot:0,namespace:r,env:t,draft:{type:'recItem',childTemplates:[],childCount:0,inParentIndex:-1},fn(t,{mount:r,unmount:n}){let{onMount:l,onState:o}=X({state:e,mount:r,onMount:(e,{leaf:t,node:a})=>({state:e,leaf:t,node:a}),onState:({leaf:e,node:t},a)=>({state:a,leaf:e,node:t})});i({source:r,clock:n,greedy:1}).watch(({leaf:e})=>{e.spawn.active=0,G(e,e=>{e.api.unmount()})}),o.watch(({state:e,leaf:t})=>{G(t,t=>{t.api.itemUpdater(e)})}),l.watch(({node:e,leaf:t,state:r})=>{z({parentBlockFragment:t.data.block.child.child,leaf:t,node:e,actor:a,values:{store:r}})})}}))}}function H(e,t){'function'==typeof t&&(Y(e)?e={source:e,fn:t}:e.fn=t);let{fn:a,key:r,source:l,fields:u=[]}=e,p=void 0!==r?'function'==typeof r?r:e=>e[r]:(e,t)=>t,c={type:'list',key:ee(e)?{type:'index'}:{type:'key',key:e.key},childTemplates:[],childCount:0,inParentIndex:-1};if(!Nt)throw Error('list() called outside from using() closure');let d=Nt.env,f=Nt.namespace;J(F({name:'list',draft:c,isSvgRoot:0,namespace:f,fn(e,{mount:t,unmount:r}){let h=F({name:'list item',state:{id:-1,store:null},draft:c,isSvgRoot:0,namespace:f,fn({id:e,store:t},{mount:r,unmount:l}){a({store:t,key:e,fields:j(t,u)});let s=n();t.on(s,(e,t)=>t);let p=o({leaf:null});if(i({source:p,clock:l,greedy:1}).watch(({leaf:e})=>{let t=e.data.block;K(t,t.parent.child);let a=t.left,r=t.right;a&&(a.right=r,r||t.parent.lastChild!==t||(t.parent.lastChild=a)),r&&(r.left=a),a||r||t.parent.lastChild!==t||(t.parent.lastChild=null),t.left=null,t.right=null,G(e,e=>{e.api.unmount()});let{spawn:n}=e;n.active=0,K(n,n.parent.childSpawns[n.template.id]),K(n,n.template.pages)}),c.itemVisible){let{onMount:e,onState:t}=X({mount:r,state:c.itemVisible,onMount:(e,{node:t,leaf:a})=>({visible:e,node:t,leaf:a}),onState:({node:e,leaf:t},a)=>({visible:a,node:e,leaf:t})});e.watch(({visible:e,node:t,leaf:a})=>{p.setState({leaf:a});let r=a.data.block;r.visible=e,r.childInitialized=e,e&&V(c,{parentBlockFragment:r.child,leaf:a,node:t})}),t.watch(({visible:e,node:t,leaf:a})=>{let r=a.data.block;r.visible=e,r.childInitialized?$(e,a):e&&(r.childInitialized=1,V(c,{parentBlockFragment:r.child,leaf:a,node:t}))})}else r.watch(({node:e,leaf:t})=>{p.setState({leaf:t});let a=t.data.block;a.visible=1,a.childInitialized=1,V(c,{parentBlockFragment:a.child,leaf:t,node:e})});return{itemUpdater:s}},env:d}),m=o([]),g=l.map(e=>e),v=i({source:l,clock:t,fn:(e,{node:t,leaf:a})=>({updates:e,node:t,leaf:a,hydration:a.hydration}),greedy:1}),x=i({source:v,clock:g,fn:({node:e,leaf:t},a)=>({updates:a,node:e,leaf:t,hydration:0}),greedy:1});i({source:m,clock:s([v,x]),greedy:1,fn(e,{node:t,updates:a,leaf:r,hydration:n}){let o=r.data.block;St('list update ['+l.shortName+']');let i=Array(a.length).fill(0),s=a.map(p),u=[];for(let t=0;t<e.length;t++){let r=e[t],n=s.indexOf(r.key);-1!==n?(u.push(r),i[n]=1,w(a[n],r.asyncValue)):(r.active=0,r.instance&&r.instance.api.unmount(),k(r.asyncValue))}for(let e=0;e<a.length;e++){if(i[e])continue;let l=a[e],p=s[e],c=y(r.ops.group.queue),d={type:'LF',parent:o,child:{type:'fragment',parent:null,child:[]},childInitialized:0,visible:0,left:null,right:null},f={type:'listItem',key:p,index:p,active:1,leafData:{type:'list item',block:d},asyncValue:b({value:l,group:c,onTerminate(e){},onChange(e){f.instance&&f.instance.api.itemUpdater(e)},onInit(e){f.active&&(n||(f.instance=P(h,{values:{id:p,store:e},parentLeaf:r,mountNode:t,svgRoot:r.svgRoot,leafData:f.leafData,opGroup:c,domSubtree:r.ops.domSubtree,hydration:n})))}})},m=u.length;u.push(f);let g=m>0?u[m-1].leafData:null;if(d.child.parent=d,o.child.push(d),g){let e=g.block;d.left=e;let t=e.right;t?(t.left=d,d.right=t):o.lastChild=d,e.right=d}else o.lastChild=d;n&&(f.instance=P(h,{values:{id:p,store:l},parentLeaf:r,mountNode:t,svgRoot:r.svgRoot,leafData:f.leafData,opGroup:c,domSubtree:r.ops.domSubtree,hydration:n}))}return It('list update ['+l.shortName+']'),0===u.length&&(o.lastChild=null),u},target:m}),i({source:t,clock:i({source:m,clock:r,greedy:1}),fn:({leaf:e},t)=>({leaf:e,records:t}),greedy:1}).watch(({leaf:e,records:t})=>{for(let e=0;e<t.length;e++){let a=t[e];a.instance&&a.instance.api.unmount(),a.active=0}let{spawn:a}=e;a.active=0,K(a,a.parent.childSpawns[a.template.id]),K(a,a.template.pages)})},env:d}))}function J(e){if(!Nt)return;let{draft:t}=e;if('listItem'!==t.type&&'rec'!==t.type)switch(Nt.draft.type){case'element':case'using':case'route':case'list':case'rec':case'recItem':t.inParentIndex=Nt.draft.childCount,Nt.draft.childCount+=1,Nt.draft.childTemplates.push(e);break;default:console.warn("unexpected currentActor type "+Nt.draft.type)}}function K(e,t){if(!t)return;let a=t.indexOf(e);-1!==a&&t.splice(a,1)}function X({mount:e,state:t,onMount:a,onState:r}){return{onMount:i({source:t,clock:e,fn:a,greedy:1}),onState:i({source:e,clock:t,fn:r,greedy:1})}}let Y=e=>(oe(e)||le(e))&&'kind'in e;const Z=e=>t=>Y(t)&&t.kind===e;let ee=Z('store'),te=Z('event'),ae=Z('effect'),re=Z('domain'),ne=e=>{throw Error(e)},le=e=>'object'==typeof e&&null!==e,oe=e=>'function'==typeof e,ie=e=>e.graphite||e,se=e=>e.family.owners,ue=e=>e.family.links,pe=e=>e.stateRef,ce=e=>e.config,de=e=>e.ɔ,fe=e=>e.value,he=e=>e.subscribers,me=e=>e.parent,ge=(e,t)=>''+e.shortName+t,ve=(e,t)=>null==t?ge(e,' → *'):t;var ye=(()=>{var e,t=('undefined'!=typeof self?self:'undefined'!=typeof window?window:'undefined'!=typeof global?global:'undefined'!=typeof module?module:Function("","return this")()).Symbol;return'function'==typeof t?t.observable?e=t.observable:(e=t('observable'),t.observable=e):e='@@observable',e})();const be=()=>{let e=0;return()=>(++e).toString(36)};let ke=be(),we=be(),xe=(e,t)=>e.bind(null,t),Se=(e,t,a)=>e.bind(null,t,a);const Ie=(e,t,a)=>({id:we(),type:e,data:a,hasRef:t});let Re=0,Te=({priority:e="barrier"})=>Ie('barrier',0,{barrierID:++Re,priority:e}),Ce=({from:e="store",store:t,target:a,to:r=(a?'store':'stack')})=>Ie('mov','store'===e,{from:e,store:t,to:r,target:a}),Fe=()=>Ie('check',0,{type:'defined'}),Ae=({store:e})=>Ie('check',1,{type:'changed',store:e}),qe=Se(Ie,'compute',0),Pe=Se(Ie,'filter',0),Ne=Se(Ie,'run',0),De=({store:e})=>Ce({from:'stack',target:e}),Me=e=>({id:we(),current:e}),Oe=({current:e})=>e,Ee=(e,{fn:t},{a})=>t(e,a),Ve=(e,{fn:t},{a})=>t(a,e),ze=(e,{fn:t})=>t(e),Le=(e,t)=>{let a=ie(e);for(let e=0;e<t.length;e++){let r=ie(t[e]);'domain'!==a.family.type&&(r.family.type='crosslink'),se(r).push(a),ue(a).push(r)}};const je=(e=[])=>{let t=[];if(Array.isArray(e))for(let a=0;a<e.length;a++)Array.isArray(e[a])?t.push(...e[a]):t.push(e[a]);else t.push(e);return t.map(ie)};let Be=({hasRef:e,type:t,data:a},r)=>{let n;e&&(n=a.store,r[n.id]=n),'mov'===t&&'store'===a.to&&(n=a.target,r[n.id]=n)},Ue=null;const _e=(e,t)=>{if(!e)return t;if(!t)return e;let a,r=e.v.type===t.v.type;return(r&&e.v.id>t.v.id||!r&&'sampler'===e.v.type)&&(a=e,e=t,t=a),a=_e(e.r,t),e.r=e.l,e.l=a,e},Qe=[];let $e=0;for(;$e<5;)Qe.push({first:null,last:null,size:0}),$e+=1;const Ge=()=>{for(let e=0;e<5;e++){let t=Qe[e];if(t.size>0){if(2===e||3===e){t.size-=1;let e=Ue.v;return Ue=_e(Ue.l,Ue.r),e}1===t.size&&(t.last=null);let a=t.first;return t.first=a.r,t.size-=1,a.v}}},We=(e,t,a,r,n,l)=>He(0,{a:null,b:null,node:a,parent:r,value:n,page:t,forkPage:l},e),He=(e,t,a,r=0)=>{let n=Je(a),l=Qe[n],o={v:{idx:e,stack:t,type:a,id:r},l:0,r:0};2===n||3===n?Ue=_e(Ue,o):(0===l.size?l.first=o:l.last.r=o,l.last=o),l.size+=1},Je=e=>{switch(e){case'child':return 0;case'pure':return 1;case'barrier':return 2;case'sampler':return 3;case'effect':return 4;default:return-1}},Ke=new Set;let Xe,Ye=0,Ze=null,et=()=>Ze,tt=(e,t,a)=>{let r=Ze,n=null,l=Xe;if(e.target&&(t=e.params,a=e.defer,r='page'in e?e.page:r,e.stack&&(n=e.stack),l=e.forkPage||l,e=e.target),Array.isArray(e))for(let a=0;a<e.length;a++)We('pure',r,ie(e[a]),n,t[a],l);else We('pure',r,ie(e),n,t,l);a&&Ye||(()=>{let e,t,a,r,n,l,o={alreadyStarted:Ye,currentPage:Ze,forkPage:Xe};Ye=1;e:for(;r=Ge();){let{idx:o,stack:i,type:s}=r;a=i.node,Ze=n=i.page,Xe=i.forkPage,l=(n||a).reg;let u={fail:0,scope:a.scope};e=t=0;for(let r=o;r<a.seq.length&&!e;r++){let p=a.seq[r],c=p.data;switch(p.type){case'barrier':{let e=c.barrierID;n&&(e=`${n.fullID}_${e}`);let t=c.priority;if(r!==o||s!==t){Ke.has(e)||(Ke.add(e),He(r,i,t,e));continue e}Ke.delete(e);break}case'mov':{let e;switch(c.from){case'stack':e=fe(i);break;case'a':e=i.a;break;case'b':e=i.b;break;case'value':e=c.store;break;case'store':l[c.store.id]||(i.page=n=null,l=a.reg),e=Oe(l[c.store.id])}switch(c.to){case'stack':i.value=e;break;case'a':i.a=e;break;case'b':i.b=e;break;case'store':l[c.target.id].current=e}break}case'check':switch(c.type){case'defined':t=void 0===fe(i);break;case'changed':t=fe(i)===Oe(l[c.store.id])}break;case'filter':t=!at(u,c,i);break;case'run':if(r!==o||'effect'!==s){He(r,i,'effect');continue e}case'compute':i.value=at(u,c,i)}e=u.fail||t}if(!e)for(let e=0;e<a.next.length;e++)We('child',n,a.next[e],i,fe(i),i.forkPage)}Ye=o.alreadyStarted,Ze=o.currentPage,Xe=o.forkPage})()};const at=(e,{fn:t},a)=>{try{return t(fe(a),e.scope,a)}catch(t){console.error(t),e.fail=1}};let rt=(e,t)=>{de(e)&&t(ce(e),de(e))};const nt=(e,t)=>{let a=e.indexOf(t);-1!==a&&e.splice(a,1)},lt=(e,t)=>{nt(e.next,t),nt(se(e),t),nt(ue(e),t)},ot=(e,t,a)=>{let r;e.next.length=0,e.seq.length=0,e.scope=null;let n=ue(e);for(;r=n.pop();)lt(r,e),(t||a&&!e.meta.sample||'crosslink'===r.family.type)&&ot(r,t,a);for(n=se(e);r=n.pop();)lt(r,e),a&&'crosslink'===r.family.type&&ot(r,t,a)},st=e=>e.clear();let ut=(e,{deep:t}={})=>{let a=0;if(e.ownerSet&&e.ownerSet.delete(e),ee(e))st(he(e));else if(re(e)){a=1;let t=e.history;st(t.events),st(t.effects),st(t.stores),st(t.domains)}ot(ie(e),!!t,a)},pt=e=>{let t=Se(ut,e,void 0);return t.unsubscribe=t,t},ct=e=>(dt&&Le(fe(dt),[e]),e),dt=null,ft=()=>dt&&dt.template,ht=(e,t,{node:r,scope:n,meta:l})=>ct(a({node:r,parent:e,child:t,scope:n,meta:l,family:{owners:[e,t],links:t}})),mt=(e,t)=>pt(ct(a({scope:{fn:t},node:[Ne({fn:ze})],parent:e,meta:{op:'watch'},family:{owners:e}})));const gt=(e,t)=>(le(e)&&(gt(ce(e),t),null!=e.name&&(le(e.name)?gt(e.name,t):t.name=e.name),e.loc&&(t.loc=e.loc),(e.sid||null===e.sid)&&(t.sid=e.sid),e.handler&&(t.handler=e.handler),me(e)&&(t.parent=me(e)),'strict'in e&&(t.strict=e.strict),e.named&&(t.named=e.named),gt(de(e),t)),t);let vt,yt=(e,t,a,r)=>{let n=gt({name:r,config:a},{}),l=ke(),{parent:o=null,sid:i=null,strict:s=1,named:u=null}=n,p=u||n.name||('domain'===e?'':l),c=((e,t)=>{let a,r,n,l=e;return t?(n=t.compositeName,0===e.length?(a=n.path,r=n.fullName):(a=n.path.concat([e]),r=0===n.fullName.length?e:n.fullName+'/'+e)):(a=0===e.length?[]:[e],r=e),{shortName:l,fullName:r,path:a}})(p,o);return t.kind=e,t.id=l,t.sid=i,t.shortName=p,t.parent=o,t.compositeName=c,t.defaultConfig=n,t.thru=e=>e(t),t.getType=()=>c.fullName,'domain'!==e&&(t.subscribe=e=>((e=>{le(e)||oe(e)||ne('expect value to be an object')})(e),t.watch(oe(e)?e:t=>{e.next&&e.next(t)})),t[ye]=()=>t),vt=s,{unit:e,name:p,sid:i,named:u}};const bt=(e,t,a,r)=>ht(e,t,{scope:{fn:r},node:[qe({fn:ze})],meta:{op:a}}),kt=(e,t,a,r)=>{let l;le(a)&&(l=a,a=a.fn);let o=n(ge(e,' →? *'),l);return ht(e,o,{scope:{fn:a},node:r,meta:{op:t}}),o},wt=(e,t,a,r,n)=>{let l=pe(t),o=[Ce({store:l,to:'a'}),qe({fn:r?Ve:Ee}),Fe(),Ae({store:l}),De({store:l})],i=ft();if(i&&(o.unshift(i.loader),o.push(i.upward),ee(e))){let t=pe(e);i.plain.includes(t)||(i.closure.includes(t)||i.closure.push(t),l.before||(l.before=[]),l.before.push({type:'closure',of:t}))}return ht(e,t,{scope:{fn:n},node:o,meta:{op:a}})};let xt=(e,t)=>{for(let a in e)t(e[a],a)};a({node:[Ne({fn({fn:e,value:t}){e(t)}})],meta:{op:'fx',fx:'sidechain'}});let St,It,Rt,Tt=e=>Y(e)?e:((...e)=>{let a,r,n;0===e.length&&ne('at least one argument required'),rt(e[0],(t,a)=>{n=t,e=a});let l,i,s=e[e.length-1];if(oe(s)?(r=e.slice(0,-1),a=s):r=e,1===r.length){let e=r[0];ee(e)||(l=e,i=1)}return i||(l=r,a&&(a=(e=>t=>e(...t))(a))),((e,a,r,n)=>{let l=e?e=>e.slice():e=>Object.assign({},e),i=e?[]:{},s=ft(),u=l(i),p=Me(u),c=Me(1);p.type=e?'list':'shape',s&&s.plain.push(p,c);let d=o(u,{name:r||t(a)}),f=[Fe(),Ce({store:p,to:'a'}),Pe({fn:(e,{key:t},{a})=>e!==a[t]}),Ce({store:c,to:'b'}),qe({fn(e,{clone:t,key:a},r){r.b&&(r.a=t(r.a)),r.a[a]=e}}),Ce({from:'a',target:p}),Ce({from:'value',store:0,target:c}),Te({priority:'barrier'}),Ce({from:'value',store:1,target:c}),Ce({store:p}),n&&qe({fn:n}),Ae({store:pe(d)})],h=p.before=[];return xt(a,(e,t)=>{if(!ee(e))return void(u[t]=i[t]=e);i[t]=e.defaultState,u[t]=e.getState();let a=ht(e,d,{scope:{key:t,clone:l},node:f,meta:{op:'combine'}}),r=pe(e);h.push({type:'field',field:t,from:r}),s&&(s.plain.includes(r)||a.seq.unshift(s.loader))}),d.defaultShape=a,p.after=[n?{type:'map',to:pe(d),fn:n}:{type:'copy',to:pe(d)}],s||(d.defaultState=n?pe(d).current=n(u):i),d})(Array.isArray(l),l,n,a)})(e);Pe({fn:(e,{state:t})=>void 0!==e&&e!==Oe(t)}),qe({fn:e=>e}),'undefined'!=typeof performance&&performance.mark?(St=e=>{performance.mark('☄️ '+e+' start')},It=e=>{try{performance.measure('☄️ '+e,'☄️ '+e+' start')}catch(e){}performance.clearMarks('☄️ '+e+' start'),performance.clearMeasures('☄️ '+e)}):(St=()=>{},It=()=>{}),Rt='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 Ct='undefined'!=typeof requestAnimationFrame?requestAnimationFrame:e=>setTimeout(e,0),Ft=0,At=0,qt=null,Pt=null,Nt=null,Dt=n();Dt.watch(({fns:e,element:t})=>{e.forEach(e=>{e(t)})}),e.h=(e,t)=>{function a(e){return e.data.block.value}function r(e,t,a){let r=e.data.block.child.child,n={type:'text',parent:{type:'FT',parent:r,child:null,visible:0,index:a},value:null};if(n.parent.child=n,r.child[a]=n.parent,e.hydration){let e=O(n);if(e)switch(e.type){case'text':n.value=p.document.createTextNode(t),e.value.after(n.value);break;case'element':n.value=e.value.nextSibling,C(n.value,t)}else{let e=N(n);n.value=e.firstChild,C(n.value,t)}n.parent.visible=1}else n.value=p.document.createTextNode(t),L(n);return n}let l,o=0,u=0;if('function'==typeof t?(o=1,l=t):t&&(u=1,t.fn&&(o=1,l=t.fn),t.ɔ&&('function'==typeof t.ɔ?(o=1,l=t.ɔ):'function'==typeof t.ɔ.fn&&(o=1,l=t.ɔ.fn))),!Nt)throw Error('h() called outside from using() closure');let p=Nt.env,c=Nt.namespace,d=c,m='html';d=m='svg'===c?'svg':'html','svg'===e&&(m='svg',d='svg');let v='svg'===m?p.document.createElementNS('http://www.w3.org/2000/svg',e):p.document.createElement(e);'foreignObject'===c?(v.setAttribute('xmlns','http://www.w3.org/1999/xhtml'),d='html'):'svg'===e?(v.setAttribute('xmlns','http://www.w3.org/2000/svg'),d='svg'):'foreignObject'===e&&(d='foreignObject');let y=v,b={type:'element',tag:e,attr:[],data:[],text:[],styleProp:[],styleVar:[],handler:[],stencil:y,seq:[],childTemplates:[],childCount:0,inParentIndex:-1,opsAmount:1,node:[]},k=F({name:'element',draft:b,isSvgRoot:'svg'===e,namespace:d,fn(e,{mount:p,unmount:c}){function d(e){return X({mount:m,state:e,onMount:(e,t)=>({leaf:t,value:e}),onState:(e,t)=>({leaf:e,value:t})})}let m=n(),v=p.map(({leaf:e})=>e);o&&l(),u&&U(t);let w={attr:{},data:{},text:b.text,styleProp:{},styleVar:{},visible:b.visible||null,handler:b.handler};for(let e=0;e<b.attr.length;e++){let t=b.attr[e];for(let e in t)'xlink:href'===e?w.attr.href=t[e]:w.attr[e]=t[e]}for(let e=0;e<b.data.length;e++){let t=b.data[e];for(let e in t)w.data[e]=t[e]}for(let e=0;e<b.styleProp.length;e++){let t=b.styleProp[e];for(let e in t)e.startsWith('--')?w.styleVar[e.slice(2)]=t[e]:w.styleProp[e]=t[e]}for(let e=0;e<b.styleVar.length;e++){let t=b.styleVar[e];for(let e in t)w.styleVar[e]=t[e]}w.visible&&b.seq.push({type:'visible',value:w.visible});for(let e in w.attr){let t=w.attr[e];Y(t)?b.seq.push({type:'attr',field:e,value:t}):T(y,e,t)}for(let e in w.data){let t=w.data[e];Y(t)?b.seq.push({type:'data',field:e,value:t}):R(y,e,t)}for(let e in w.styleProp){let t=w.styleProp[e];Y(t)?b.seq.push({type:'style',field:e,value:t}):I(y,e,t)}for(let e in w.styleVar){let t=w.styleVar[e];Y(t)?b.seq.push({type:'styleVar',field:e,value:t}):S(y,e,t)}for(let e=0;e<w.text.length;e++){let t=w.text[e];if(null!==t.value)if(Y(t.value)){b.seq.push({type:'dynamicText',value:t.value,childIndex:t.index});let e=t.value.stateRef,a=qt;a.plain.includes(e)||a.closure.includes(e)||a.closure.push(e)}else b.seq.push({type:'staticText',value:String(t.value),childIndex:t.index})}for(let e=0;e<w.handler.length;e++){let t=w.handler[e];for(let e in t.map)b.seq.push({type:'handler',for:e,handler:t.map[e],options:t.options,domConfig:t.domConfig})}if(w.visible){let{onMount:e,onState:t}=X({mount:v,state:w.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&&(f(t,r.ops.visible),t)){let e,t=E(n);if(e=t?t.nextSibling:N(n).firstChild,'#text'===e.nodeName){let t=e;e=e.nextSibling,t.remove()}n.value=e,n.parent.visible=1}V(b,{parentBlockFragment:n.child.child,leaf:e,node:n.value,svgRoot:k.isSvgRoot?n.value:null}),t&&r.needToCallNode&&(r.needToCallNode=0,tt({target:Dt,params:{element:r.block.value,fns:b.node},page:e.spawn,defer:1})),tt({target:m,params:e,defer:1,page:e.spawn})}),s([t,e]).watch(({leaf:e,value:t,hydration:a})=>{a||h(t,e.data.ops.visible)})}for(let e=0;e<b.seq.length;e++){let t=b.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:l}=d(t.value);if(r)s([l,n]).watch(({leaf:t,value:r})=>{T(a(t),e,r)});else{let t=b.opsAmount++;n.watch(({value:r,leaf:n})=>{let l=a(n),o=g({value:r,priority:'props',runOp(t){T(l,e,t)},group:n.ops.group});n.ops.group.ops[t]=o,T(l,e,r)}),l.watch(({value:e,leaf:a})=>{h(e,a.ops.group.ops[t])})}break}case'data':{let{field:e}=t,{onMount:r,onState:n}=d(t.value),l=b.opsAmount++;r.watch(({value:t,leaf:r})=>{let n=a(r),o=g({value:t,priority:'props',runOp(t){R(n,e,t)},group:r.ops.group});r.ops.group.ops[l]=o,R(n,e,t)}),n.watch(({value:e,leaf:t})=>{h(e,t.ops.group.ops[l])});break}case'style':{let e=b.opsAmount++,{field:r}=t,{onMount:n,onState:l}=d(t.value);n.watch(({value:t,leaf:n})=>{let l=a(n),o=g({value:t,priority:'props',runOp(e){I(l,r,e)},group:n.ops.group});n.ops.group.ops[e]=o,I(l,r,t)}),l.watch(({value:t,leaf:a})=>{h(t,a.ops.group.ops[e])});break}case'styleVar':{let{field:e}=t,{onMount:r,onState:n}=d(t.value),l=b.opsAmount++;r.watch(({value:t,leaf:r})=>{let n=a(r),o=g({value:t,priority:'props',runOp(t){S(n,e,t)},group:r.ops.group});r.ops.group.ops[l]=o,S(n,e,t)}),n.watch(({value:e,leaf:t})=>{h(e,t.ops.group.ops[l])});break}case'staticText':m.map(e=>e).watch(e=>{r(e,t.value,t.childIndex)});break;case'dynamicText':{let e=b.opsAmount++;i({source:t.value,clock:m,fn:(e,t)=>({value:String(e),leaf:t}),greedy:1}).watch(({value:a,leaf:n})=>{let l=g({value:a,priority:'props',runOp(e){C(o.value,e)},group:n.ops.group});n.ops.group.ops[e]=l;let o=r(n,a,t.childIndex)}),i({source:m,clock:t.value,fn:(e,t)=>({leaf:e,text:t}),greedy:1}).watch(({leaf:t,text:a})=>{h(a,t.ops.group.ops[e])});break}case'handler':{let e=t.handler.graphite.meta.nativeTemplate||null;m.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(),tt({target:t.handler,params:e,page:n})},t.domConfig)});break}}}i({source:v,clock:c,greedy:1}).watch(e=>{let{spawn:t}=e;K(t,t.parent.childSpawns[t.template.id]),function e(t){t.active=0,K(t,t.template.pages);for(let a in t.childSpawns)t.childSpawns[a].forEach(e)}(t),h(0,e.data.ops.visible)}),p.watch(({leaf:e})=>{let t=e.data;if(!b.visible){let a=t.ops.visible,r=t.block;if(e.hydration){f(1,a);let e,t=E(r);if(e=t?t.nextSibling:N(r).firstChild,'#text'===e.nodeName){let t=e;e=e.nextSibling,t.remove()}r.value=e,r.parent.visible=1}V(b,{parentBlockFragment:r.child.child,leaf:e,node:r.value,svgRoot:k.isSvgRoot?r.value:null}),tt({target:m,params:e,defer:1,page:e.spawn}),e.hydration?t.needToCallNode&&(t.needToCallNode=0,tt({target:Dt,params:{element:t.block.value,fns:b.node},page:e.spawn,defer:1})):h(1,a)}})},env:p});J(k)},e.handler=_,e.list=H,e.node=e=>{let t=Nt.draft;switch(t.type){case'list':case'listItem':case'using':case'route':case'rec':case'recItem':return}t.node.push(e)},e.rec=W,e.remap=j,e.route=Q,e.spec=U,e.text=(e,...t)=>{let a=[e[0]];for(let r=0;r<t.length;r++)a.push(t[r],e[r+1]);U({text:a})},e.tree=({source:e,child:t,fn:a})=>{let r=W(({state:e})=>{H({source:e,fn({store:e}){let n=e.map(e=>e[t]||[]);a({store:e,child(){r({state:n})}})}})});r({state:e})},e.using=(e,t)=>{let a,r,n,l,o;if('function'==typeof t)a=t,n=B(),l=0;else{if(!t)throw Error('using() second argument is missing');a=t.fn,n=t.env?t.env:B(),l=t.hydrate,r=t.onComplete,o=t.onRoot}if(!e)throw Error('using() first argument is missing');let i=e.namespaceURI,s=e.tagName.toLowerCase(),u={type:'using',childTemplates:[],childCount:0,inParentIndex:-1},p=F({name:'using',draft:u,isSvgRoot:'svg'===s,namespace:'http://www.w3.org/2000/svg'===i?'svg':'foreignobject'===s?'foreignObject':'html',fn(e,{mount:t}){a(),t.watch(({node:e,leaf:t})=>{V(u,{parentBlockFragment:t.data.block.child.child,leaf:t,node:e})})},env:n}),c={type:'using',child:{type:'UF',parent:null,child:{type:'fragment',parent:null,child:[]}},value:e};c.child.parent=c,c.child.child.parent=c.child;let d=v({onComplete:r}),f=P(p,{parentLeaf:Pt||null,mountNode:e,svgRoot:p.isSvgRoot?e:Pt?Pt.svgRoot:null,leafData:{type:'using',draft:u,element:e,block:c},opGroup:y(d),domSubtree:y(d),hydration:l});o&&o({template:p,leaf:f})},e.variant=({source:e,cases:t,key:a})=>{if(!Y(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 n=0;for(let a in t)'__'!==a?Q({source:e,visible:e=>r(e)===a,fn:t[a]}):n=1;if(n){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):'function'==typeof define&&define.amd?define(['exports'],t):t((e=e||self).forest={})})(this,e=>{function t(e,t="combine"){let a=t+'(',r='',n=0;for(let t in e){let l=e[t];if(null!=l&&(a+=r,a+=Y(l)?l.compositeName.fullName:l.toString()),n+=1,25===n)break;r=', '}return a+=')',a}function a({node:e=[],from:t,source:a,parent:r=t||a,to:n,target:l,child:o=n||l,scope:i={},meta:s={},family:u={type:'regular'}}={}){let c=Le(r),p=Le(u.links),d=Le(u.owners),f=[],h={};for(let t=0;t<e.length;t++){let a=e[t];a&&(f.push(a),Be(a,h))}let m={seq:f,next:Le(o),meta:s,scope:i,family:{type:u.type||'crosslink',links:p,owners:d},reg:h};for(let e=0;e<p.length;e++)se(p[e]).push(m);for(let e=0;e<d.length;e++)ue(d[e]).push(m);for(let e=0;e<c.length;e++)c[e].next.push(m);return m}function r(e,t){dt={parent:dt,value:e,template:ie(e).meta.template||dt&&dt.template};try{return t()}finally{dt=me(dt)}}function n(e,t){let r=(e,...t)=>r.create(e,t,t);r.graphite=a({meta:yt('event',r,t,e)}),r.create=e=>(tt(r,e),e),r.watch=xe(mt,r),r.map=e=>{let t,a;le(e)&&(t=e,a=e.name,e=e.fn);let l=n(ve(r,a),t);return bt(r,l,'map',e),l},r.filter=e=>oe(e)?(console.error('.filter(fn) is deprecated, use .filterMap instead'),l(r,e)):kt(r,'filter',e.fn,[Pe({fn:je})]),r.filterMap=xe(l,r),r.prepend=e=>{let t=n('* → '+r.shortName,{parent:me(r)}),a=ft();return a&&ie(t).seq.push(a.upward),bt(t,r,'prepend',e),((e,t,a="event")=>{me(e)&&me(e).hooks[a](t)})(r,t),t};let o=ft();return o&&(ie(r).meta.nativeTemplate=o),pt(r)}function l(e,t){return kt(e,'filterMap',t,[qe({fn:je}),Fe()])}function o(e,t){function r(e,t){c.off(e),he(c).set(e,ct(wt(e,c,'on',1,t)))}let l=Me(e),i=Me(e),s=(()=>n({named:'updates'}))(),u=ft();l.after=[{type:'copy',to:i}],u&&u.plain.push(l);let c={subscribers:new Map,updates:s,defaultState:e,stateRef:l,getState(){let e=et();return Oe(e&&e.reg[l.id]?e.reg[l.id]:l)},setState(e){tt({target:c,params:e,defer:1})},reset(...e){for(let t of e)c.on(t,()=>c.defaultState);return c},on(e,t){if(Array.isArray(e))for(let a of e)r(a,t);else r(e,t);return c},off(e){let t=he(c).get(e);return t&&(t(),he(c).delete(e)),c},map(e,t){let a,r,n;le(e)&&(a=e,r=e.name,t=e.firstState,e=e.fn);let i=c.getState(),s=ft();s?n=null:void 0!==i&&(n=e(i,t));let u=o(n,{name:ve(c,r),config:a,strict:0}),p=wt(c,u,'map',0,e);return ce(u).before=[{type:'map',fn:e,from:l}],s&&(s.plain.includes(l)||p.seq.includes(s.loader)||p.seq.unshift(s.loader)),u},watch(e,t){if(!t||!Y(e)){let t=mt(c,e),a=ft();return a?a.watch.push({of:l,fn:e}):e(c.getState()),t}return oe(t)||ne('second argument should be a function'),e.watch(e=>t(c.getState(),e))}};return c.graphite=a({scope:{state:l},node:[Fe(),De({store:l}),Ae({store:i}),De({store:i})],child:s,meta:yt('store',c,t)}),vt&&void 0===e&&ne("current state can't be undefined, use null instead"),u&&(ie(c).meta.nativeTemplate=u),ze(c,[s]),pt(c)}function i(...e){let t,r,l;rt(e[0],(t,a)=>{l=t,e=a});let i,[s,u,c,p=0]=e;void 0===u&&'source'in s&&('clock'in s&&null==s.clock&&ne('config.clock should be defined'),u=s.clock,c=s.fn,p=s.greedy,t=s.target,r=s.name,i=s.sid,s=s.source),void 0===u&&(u=s),r=l||r||s.shortName,s=St(s),u=St(u,1),'boolean'==typeof c&&(p=c,c=null);let d=ft(),f=!!t;t||(ee(s)&&ee(u)?t=o(c?c(Oe(ce(s)),Oe(ce(u))):Oe(ce(s)),{name:r,sid:i}):(t=n(r),d&&ie(t).seq.push(d.loader)));let h=f&&Y(t)&&ie(t).meta.nativeTemplate;if(ee(s))ze(s,[ht(u,t,{scope:{fn:c,targetTemplate:h},node:[d&&d.loader,!p&&Te({priority:'sampler'}),Ce({store:ce(s),to:c?'a':'stack'}),c&&qe({fn:Ve}),d&&f&&d.upward],meta:{op:'sample',sample:'store'}})]);else{let e=Me(0),r=Me(),n=Me();d&&d.plain.push(e,r,n),pt(a({parent:s,node:[De({store:r}),Ce({from:'value',store:1,target:e})],family:{owners:[s,t,u],links:t},meta:{op:'sample',sample:'source'}})),ze(s,[ht(u,t,{scope:{fn:c,targetTemplate:h},node:[d&&d.loader,De({store:n}),Ce({store:e}),Pe({fn:e=>e}),!p&&Te({priority:'sampler'}),Ce({store:r}),Ce({store:n,to:'a'}),c&&qe({fn:Ee}),d&&f&&d.upward],meta:{op:'sample',sample:'clock'}})])}return t}function s(e){let r=n(t(e,'merge'));return(e=>{let t;rt(e,(a,r)=>{t=a,e=r});let{from:r,to:n,meta:l={op:'forward'}}=e;r&&n||ne('from and to fields should be defined'),t&&(l.config=t),ct(pt(a({parent:r,child:n,meta:l,family:{}})))})({from:e,to:r,meta:{op:'merge'}}),r}function u(e,t,a){if(ee(e))return e;if(Y(e)){let r,n=me(e);return te(e)&&(r=o(t,{parent:n,name:e.shortName,ɔ:a}).on(e,(e,t)=>t)),ae(e)&&(r=o(t,{parent:n,name:e.shortName,ɔ:a}).on(e.done,(e,{result:t})=>t)),n&&n.hooks.store(r),r}let r={};return xt(e,(e,t)=>{r[t]=ee(e)?e:o(e,{name:t})}),r}function c(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 p(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})(d(e),e)}function d(e){return e.group.activeChilds[e.priority]}function f(e,t){t.value.active=t.value.pending=e,'active'!==t.status&&p(t)}function h(e,t){if(t.value.active===e)return t.value.pending=e,void('pending'===t.status&&(p(t),d(t).first||c(t.group,t.priority)));'active'===t.status&&(t.status='pending',d(t).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})(t.group,t.priority),((e,t)=>{e.last?(t.cursor.prev=e.last,e.last.cursor.next=t,e.last=t):e.first=e.last=t})(d(t),t)),t.value.pending=e,t.group.queue.rafID||(t.group.queue.rafID=Ct(t.group.queue.execQueue))}function m(e){It('execQueue');let t,a,r=Tt(),n=0;e:for(;e.props.first||e.tree.first||e.data.first;){if(Tt()-r>=10){n=1;break e}let l=!!e.props.first;for(l&&It('props');t=e.props.first;){for(;a=t.activeChilds.props.first;){if(Tt()-r>=10){n=1,Rt('props');break e}a.runOp(a.value.pending),a.value.active=a.value.pending,p(a)}c(t,'props')}l&&Rt('props');let o=!!e.tree.first;for(o&&It('tree');t=e.tree.first;){for(;a=t.activeChilds.tree.first;){if(Tt()-r>=10){n=1,Rt('tree');break e}a.runOp(a.value.pending),a.value.active=a.value.pending,p(a)}c(t,'tree')}o&&Rt('tree');let i=!!e.data.first;for(i&&It('data');t=e.data.first;){for(;a=t.activeChilds.data.first;){if(Tt()-r>=10){n=1,Rt('data');break e}a.runOp(a.value.pending),a.value.active=a.value.pending,p(a)}c(t,'data')}i&&Rt('data')}if(Rt('execQueue'),n)e.rafID=Ct(e.execQueue);else if(e.rafID=null,e.onDrain){let t=e.onDrain;e.onDrain=null,t()}}function g({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 v({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=m.bind(null,t),t}function y(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 b({value:e,group:t,onInit:a,onChange:r,onTerminate:n}){let l=g({value:e,group:t,runOp(e){o.status='A',r(e)},priority:'data'}),o={status:'IA',value:l.value,hooks:{onTerminate:n},ops:{init:g({value:0,group:t,runOp(e){o.status='A',a(o.value.active)},priority:'data'}),change:l,terminate:g({value:0,group:t,runOp(e){o.status='T',o.hooks.onTerminate(1)},priority:'data'})}};return h(1,o.ops.init),o}function k(e){switch(e.status){case'I':case'T':case'AT':return;case'A':e.status='AT',h(1,e.ops.terminate);break;case'AA':e.status='AT',h(1,e.ops.terminate),h(e.value.active,e.ops.change);break;case'IA':e.status='T',h(0,e.ops.init),e.hooks.onTerminate(0)}}function w(e,t){switch(t.status){case'I':case'T':return;case'A':t.value.active!==e&&(t.status='AA',h(e,t.ops.change));break;case'AA':t.value.active===e?(t.status='A',h(e,t.ops.change)):t.value.pending!==e&&(t.value.pending=e);break;case'IA':t.value.active=t.value.pending=e}}function x(e){return''!==e&&0!==e&&'0'!==e&&(0==e||null==e)}function S(e,t,a){x(a)?e.style.removeProperty("--"+t):e.style.setProperty("--"+t,""+a)}function I(e,t,a){x(a)?delete e.style[t]:e.style[t]=""+a}function R(e,t,a){x(a)?delete e.dataset[t]:e.dataset[t]=""+a}function T(e,t,a){if(x(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 C(e,t){e.replaceData(0,(e.textContent||'').length,String(t))}function F({fn:e,state:t={},defer:l=0,name:o="",draft:i,isSvgRoot:s,namespace:c,env:p}){let d=Nt,f=qt,h={id:++Ft,name:o,plain:[],watch:[],nameMap:{},pages:[],closure:[],childTemplates:[],upward:Pe({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 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)?tt({target:t,params:e,defer:1,page:n[r.indexOf(l)],stack:a}):console.error('context drift',{stack:a,node:t}):tt({target:t,params:e,defer:1,page:null,stack:a})}),0}}),loader:Pe({fn(e,t,a){if(a.parent){if(a.page){if(!a.page.active)return 0;if(a.page.template===h)return 1;if(a.page.childSpawns[h.id])a.page.childSpawns[h.id].forEach(t=>{tt({params:e,target:a.node,page:t,defer:1})});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);tt(-1===n?{params:e,target:a.node,page:null,defer:1}:{params:e,target:a.node,page:r[n],defer:1})}else h.pages.forEach(t=>{t.fullID.startsWith(a.page.fullID)&&tt({params:e,target:a.node,page:t,defer:1})})}else h.pages.forEach(t=>{tt({params:e,target:a.node,page:t,defer:1})});return 0}return 1}}),parent:f};f&&f.childTemplates.push(h);let m=a({meta:{template:h}});qt=h;let g=Nt={template:h,node:m,api:null,trigger:{mount:n(),unmount:n()},draft:i,isSvgRoot:s,namespace:c,env:p};return l?g.deferredInit=()=>{let a=Nt,n=qt;Nt=g,qt=h,g.deferredInit=null;try{r(m,()=>{let a=u(t);g.api=e(a,g.trigger),h.nameMap=a})}finally{Nt=a,qt=n}}:r(m,()=>{let a=u(t);g.api=e(a,g.trigger),h.nameMap=a}),Nt=d,qt=f,h.actor=g,g}function A(e){switch(e.type){case'list':return[...e.current];case'shape':return{...e.current};default:return e.current}}function q(e,t){let a=t;for(;a&&!a.spawn.reg[e.id];)a=a.parentLeaf;return a?a.spawn.reg[e.id].current:e.current}function P(e,{values:t={},parentLeaf:a,mountNode:r,svgRoot:n,leafData:l,opGroup:o,domSubtree:i,hydration:s}){function u(e){if(e.before)for(let t of e.before)switch(t.type){case'map':{let a=t.from;f[a.id]||(f[a.id]=a),f[e.id].current=t.fn(f[a.id].current);break}case'field':{let a=t.from;f[a.id]||(f[a.id]=a),f[e.id].current[t.field]=f[a.id].current;break}case'closure':f[t.of.id]||(f[t.of.id]=t.of)}if(!e.after)return;let t=f[e.id].current;for(let a of e.after){let e=a.to;switch(f[e.id]||(f[e.id]={id:e.id,current:e.current}),a.type){case'copy':f[e.id].current=t;break;case'map':f[e.id].current=a.fn(t)}}}function c(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:q(r.of,g.parentLeaf))}catch(e){console.error(e),t.stop=0}}let p=a?a.spawn:null,d=e.template,f={},h={id:++At,fullID:'',reg:f,template:d,parent:p,childSpawns:{},active:1};d.pages.push(h);let m={},g={spawn:h,api:m,draft:e.draft,ops:{group:o,domSubtree:i},svgRoot:n,data:l,parentLeaf:a,hydration:s},v=Pt;Pt=g,p&&(p.childSpawns[d.id]||(p.childSpawns[d.id]=[]),p.childSpawns[d.id].push(h)),h.fullID=p?`${p.fullID}_${h.id}`:""+h.id,p&&Object.assign(f,p.reg);for(let e of d.closure){let t=e,a=h.parent;e:for(;a;){if(e.id in a.reg){t=a.reg[e.id];break e}a=a.parent}f[e.id]=t}for(let e of d.plain){let t={id:e.id,current:A(e)};f[e.id]=t}for(let e in t){let a=d.nameMap[e].stateRef.id;f[a]={id:a,current:t[e]}}for(let e of d.closure)u(e);for(let e of d.plain)u(e);let y={i:0,stop:0};for(;!y.stop;)c(d.watch,y,f);if(p)for(let e in h.childSpawns)e in p.childSpawns||(p.childSpawns[e]=[]),p.childSpawns[e].push(...h.childSpawns[e]);if(m.mount=(t,a=1)=>tt({target:e.trigger.mount,params:t,defer:a,page:h}),m.unmount=(t,a=1)=>tt({target:e.trigger.unmount,params:t,defer:a,page:h}),e.api)for(let t in e.api)m[t]=(a,r=1)=>tt({target:e.api[t],params:a,defer:r,page:h});return g.spawn.api=m,g.spawn.leaf=g,g.api.mount({node:r,leaf:g}),Pt=v,g}function N(e){let t=function e(t){switch(t.type){case'fragment':switch(t.parent.type){case'EF':case'UF':return t.parent.parent}return e(t.parent.parent);case'route':default:return e(t.parent.parent)}}(e);return t?t.value:null}function D(e){if(!e.visible)return null;switch(e.type){case'FE':case'FT':return e.child;case'FR':return D(e.child.child);case'LF':case'RF':case'FF':return M(e.child);case'FRec':case'FRecItem':return M(e.child.child.child);case'FL':{let t=e.child.lastChild;if(!t)return null;for(;t;){let e=D(t);if(e)return e;t=t.left}return null}default:return null}}function M(e){let t=e.child;for(let e=t.length-1;e>=0;e--){let a=D(t[e]);if(a)return a}return null}function O(e){if('fragment'===e.type)switch(e.parent.type){case'EF':case'UF':return null;case'RecF':case'RecItemF':case'RF':{let t=e.parent.parent.parent,a=t.parent;for(let e=t.index-1;e>=0;e--){let t=D(a.child[e]);if(t)return t}return O(a)}case'FF':{let t=e.parent,a=t.parent;for(let e=t.index-1;e>=0;e--){let t=D(a.child[e]);if(t)return t}return O(a)}case'LF':{let t=e.parent.left;for(;t;){let e=D(t);if(e)return e;t=t.left}return O(e.parent.parent)}default:return null}if('route'===e.type){let t=e.parent.parent;for(let a=e.parent.index-1;a>=0;a--){let e=t.child[a];if(!e)continue;let r=D(e);if(r)return r}return O(t)}let t=e.parent.parent;for(let a=e.parent.index-1;a>=0;a--){let e=t.child[a];if(!e)continue;let r=D(e);if(r)return r}return O(t)}function E(e){let t=O(e);return t?t.value:null}function V(e,{parentBlockFragment:t,leaf:a,node:r,svgRoot:n,values:l}){e.childTemplates.forEach(e=>{j({parentBlockFragment:t,leaf:a,node:r,svgRoot:n,values:l,actor:e})})}function j({parentBlockFragment:e,leaf:t,node:a,actor:r,svgRoot:n,values:l}){let o,{draft:i}=r,{queue:s}=t.ops.group,u=y(s),c=t.ops.domSubtree,p=c;switch(i.type){case'route':{let t={type:'route',parent:{type:'FR',parent:e,child:null,visible:1,index:i.inParentIndex},child:{type:'RF',parent:null,child:{type:'fragment',parent:null,child:[]},visible:0}};t.parent.child=t,t.child.parent=t,t.child.child.parent=t.child,e.child[i.inParentIndex]=t.parent,o={type:'route',block:t,ops:{},initialized:0};break}case'element':{let t={type:'element',parent:{type:'FE',parent:e,child:null,visible:0,index:i.inParentIndex},child:{type:'EF',parent:null,child:{type:'fragment',parent:null,child:[]}},value:i.stencil.cloneNode()};t.parent.child=t,t.child.parent=t,t.child.child.parent=t.child,e.child[i.inParentIndex]=t.parent,o={type:'element',block:t,ops:{visible:g({value:0,priority:'tree',runOp(e){e?(z(t),o.needToCallNode&&(o.needToCallNode=0,tt({target:Dt,params:{element:t.value,fns:i.node},page:d.spawn}))):(t.value.remove(),t.parent.visible=0)},group:c})},needToCallNode:i.node.length>0},p=y(s);break}case'list':{let t={type:'list',parent:{type:'FL',parent:e,child:null,visible:1,index:i.inParentIndex},child:[],lastChild:null};t.parent.child=t,e.child[i.inParentIndex]=t.parent,o={type:'list',draft:i,block:t};break}case'using':case'listItem':break;case'rec':{let t={type:'rec',parent:{type:'FRec',parent:e,child:null,visible:1,index:i.inParentIndex},child:{type:'RecF',parent:null,child:{type:'fragment',parent:null,child:[]}}};t.parent.child=t,t.child.parent=t,t.child.child.parent=t.child,e.child[i.inParentIndex]=t.parent,o={type:'rec',block:t};break}case'recItem':{let t={type:'recItem',parent:{type:'FRecItem',parent:e,child:null,visible:1,index:i.inParentIndex},child:{type:'RecItemF',parent:null,child:{type:'fragment',parent:null,child:[]}}};t.parent.child=t,t.child.parent=t,t.child.child.parent=t.child,e.child[i.inParentIndex]=t.parent,o={type:'rec item',block:t};break}default:console.warn("unexpected draft type "+i.type)}let d=P(r,{values:l,parentLeaf:t,mountNode:a,svgRoot:n||t.svgRoot,leafData:o,opGroup:u,domSubtree:p,hydration:t.hydration})}function z(e){let t=E(e);t?t.after(e.value):N(e).prepend(e.value),e.parent.visible=1}function L(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 B(){if('undefined'!=typeof document)return{document};throw Error('your environment has no document')}function U(e){let t=Nt.draft;switch(t.type){case'list':return void(e.visible&&(t.itemVisible=e.visible));case'listItem':case'using':case'route':case'rec':case'recItem':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&&t.styleProp.push(e.style),e.styleVar&&t.styleVar.push(e.styleVar),e.visible&&(t.visible=e.visible),e.handler){let t=e.handler;'object'==typeof t.on?_(t.config||{},t.on):_(t)}e.ɔ&&U(e.ɔ)}function _(e,t){if(!Nt)return;let a=Nt.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(!Y(t[e]))throw Error(`handler for "${e}" should be event`);let{passive:r=1,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 Q({source:e,visible:t,fn:a}){if(!Nt)throw Error('route() called outside from using() closure');let r=F({name:'route',isSvgRoot:0,namespace:Nt.namespace,env:Nt.env,draft:{type:'route',childTemplates:[],childCount:0,inParentIndex:-1},fn(r,{mount:l,unmount:o}){let u=e.map(e=>({value:e,visible:t(e)})),c={type:'route',childTemplates:[],childCount:0,inParentIndex:-1},p=F({name:'route item',isSvgRoot:0,namespace:Nt.namespace,env:Nt.env,draft:c,state:{store:null},fn({store:e},{mount:t,unmount:r}){let l=n();e.on(l,(e,t)=>t),a({store:e});let o=i({source:t,clock:u,fn:({leaf:e,node:t},{visible:a,value:r})=>({leaf:e,visible:a,node:t,value:r}),greedy:1});t.watch(({leaf:e,node:t})=>{let a=e.data;a.block.child.visible=1,V(c,{parentBlockFragment:a.block.child.child,leaf:e,node:t})}),o.watch(({leaf:e,visible:t,value:a})=>{e.data.block.child.visible=t,t&&tt({target:l,params:a,defer:1,page:e.spawn}),$(t,e)}),i({source:t,clock:r,greedy:1}).watch(({leaf:e})=>{G(e,e=>{e.api.unmount()});let{spawn:t}=e;t.active=0,K(t,t.parent.childSpawns[t.template.id]),K(t,t.template.pages)})}});J(p);let{onMount:d,onState:f}=X({mount:l,state:u,onMount:({visible:e,value:t},{leaf:a,node:r})=>({leaf:a,visible:e,node:r,value:t}),onState:({leaf:e,node:t},{visible:a,value:r})=>({leaf:e,visible:a,node:t,value:r})});s([d,f]).watch(({leaf:e,visible:t,value:a,node:r})=>{let n=e.data;n.block.child.visible=t,t&&!n.initialized&&(j({parentBlockFragment:n.block.child.child,leaf:e,node:r,actor:p,values:{store:a}}),n.initialized=1)}),i({source:l,clock:o,greedy:1}).watch(({leaf:e})=>{G(e,e=>{e.api.unmount()});let{spawn:t}=e;t.active=0,K(t,t.parent.childSpawns[t.template.id]),K(t,t.template.pages)})}});J(r)}function $(e,t){let a=t=>{let r=t.data;switch(r.type){case'element':h(e,r.ops.visible);break;case'route':case'list':case'list item':G(t,a);break;default:console.log('unsupported type',r.type)}};G(t,a)}function G(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 W(e){let t={type:'rec',childTemplates:[],childCount:0,inParentIndex:0},a=F({name:'rec',state:{store:null},isSvgRoot:0,namespace:Nt.namespace,env:Nt.env,draft:t,defer:1,fn({store:a},{mount:r,unmount:l}){e({state:a});let o=n();return a.on(o,(e,t)=>t),r.watch(({node:e,leaf:a})=>{V(t,{parentBlockFragment:a.data.block.child.child,leaf:a,node:e})}),i({source:r,clock:l,greedy:1}).watch(({leaf:e})=>{e.spawn.active=0,G(e,e=>{e.api.unmount()})}),{itemUpdater:o}}});return({state:e})=>{a.deferredInit&&a.deferredInit();let{env:t,namespace:r}=Nt;J(F({name:'rec item',isSvgRoot:0,namespace:r,env:t,draft:{type:'recItem',childTemplates:[],childCount:0,inParentIndex:-1},fn(t,{mount:r,unmount:n}){let{onMount:l,onState:o}=X({state:e,mount:r,onMount:(e,{leaf:t,node:a})=>({state:e,leaf:t,node:a}),onState:({leaf:e,node:t},a)=>({state:a,leaf:e,node:t})});i({source:r,clock:n,greedy:1}).watch(({leaf:e})=>{e.spawn.active=0,G(e,e=>{e.api.unmount()})}),o.watch(({state:e,leaf:t})=>{G(t,t=>{t.api.itemUpdater(e)})}),l.watch(({node:e,leaf:t,state:r})=>{j({parentBlockFragment:t.data.block.child.child,leaf:t,node:e,actor:a,values:{store:r}})})}}))}}function H(e,t){'function'==typeof t&&(Y(e)?e={source:e,fn:t}:e.fn=t);let{fn:a,key:r,source:l,fields:u=[]}=e,c=void 0!==r?'function'==typeof r?r:e=>e[r]:(e,t)=>t,p={type:'list',key:ee(e)?{type:'index'}:{type:'key',key:e.key},childTemplates:[],childCount:0,inParentIndex:-1};if(!Nt)throw Error('list() called outside from using() closure');let d=Nt.env,f=Nt.namespace;J(F({name:'list',draft:p,isSvgRoot:0,namespace:f,fn(e,{mount:t,unmount:r}){let h=F({name:'list item',state:{id:-1,store:null},draft:p,isSvgRoot:0,namespace:f,fn({id:e,store:t},{mount:r,unmount:l}){a({store:t,key:e,fields:L(t,u)});let s=n();t.on(s,(e,t)=>t);let c=o({leaf:null});if(i({source:c,clock:l,greedy:1}).watch(({leaf:e})=>{let t=e.data.block;K(t,t.parent.child);let a=t.left,r=t.right;a&&(a.right=r,r||t.parent.lastChild!==t||(t.parent.lastChild=a)),r&&(r.left=a),a||r||t.parent.lastChild!==t||(t.parent.lastChild=null),t.left=null,t.right=null,G(e,e=>{e.api.unmount()});let{spawn:n}=e;n.active=0,K(n,n.parent.childSpawns[n.template.id]),K(n,n.template.pages)}),p.itemVisible){let{onMount:e,onState:t}=X({mount:r,state:p.itemVisible,onMount:(e,{node:t,leaf:a})=>({visible:e,node:t,leaf:a}),onState:({node:e,leaf:t},a)=>({visible:a,node:e,leaf:t})});e.watch(({visible:e,node:t,leaf:a})=>{c.setState({leaf:a});let r=a.data.block;r.visible=e,r.childInitialized=e,e&&V(p,{parentBlockFragment:r.child,leaf:a,node:t})}),t.watch(({visible:e,node:t,leaf:a})=>{let r=a.data.block;r.visible=e,r.childInitialized?$(e,a):e&&(r.childInitialized=1,V(p,{parentBlockFragment:r.child,leaf:a,node:t}))})}else r.watch(({node:e,leaf:t})=>{c.setState({leaf:t});let a=t.data.block;a.visible=1,a.childInitialized=1,V(p,{parentBlockFragment:a.child,leaf:t,node:e})});return{itemUpdater:s}},env:d}),m=o([]),g=l.map(e=>e),v=i({source:l,clock:t,fn:(e,{node:t,leaf:a})=>({updates:e,node:t,leaf:a,hydration:a.hydration}),greedy:1}),x=i({source:v,clock:g,fn:({node:e,leaf:t},a)=>({updates:a,node:e,leaf:t,hydration:0}),greedy:1});i({source:m,clock:s([v,x]),greedy:1,fn(e,{node:t,updates:a,leaf:r,hydration:n}){let o=r.data.block;It('list update ['+l.shortName+']');let i=Array(a.length).fill(0),s=a.map(c),u=[];for(let t=0;t<e.length;t++){let r=e[t],n=s.indexOf(r.key);-1!==n?(u.push(r),i[n]=1,w(a[n],r.asyncValue)):(r.active=0,r.instance&&r.instance.api.unmount(),k(r.asyncValue))}for(let e=0;e<a.length;e++){if(i[e])continue;let l=a[e],c=s[e],p=y(r.ops.group.queue),d={type:'LF',parent:o,child:{type:'fragment',parent:null,child:[]},childInitialized:0,visible:0,left:null,right:null},f={type:'listItem',key:c,index:c,active:1,leafData:{type:'list item',block:d},asyncValue:b({value:l,group:p,onTerminate(e){},onChange(e){f.instance&&f.instance.api.itemUpdater(e)},onInit(e){f.active&&(n||(f.instance=P(h,{values:{id:c,store:e},parentLeaf:r,mountNode:t,svgRoot:r.svgRoot,leafData:f.leafData,opGroup:p,domSubtree:r.ops.domSubtree,hydration:n})))}})},m=u.length;u.push(f);let g=m>0?u[m-1].leafData:null;if(d.child.parent=d,o.child.push(d),g){let e=g.block;d.left=e;let t=e.right;t?(t.left=d,d.right=t):o.lastChild=d,e.right=d}else o.lastChild=d;n&&(f.instance=P(h,{values:{id:c,store:l},parentLeaf:r,mountNode:t,svgRoot:r.svgRoot,leafData:f.leafData,opGroup:p,domSubtree:r.ops.domSubtree,hydration:n}))}return Rt('list update ['+l.shortName+']'),0===u.length&&(o.lastChild=null),u},target:m}),i({source:t,clock:i({source:m,clock:r,greedy:1}),fn:({leaf:e},t)=>({leaf:e,records:t}),greedy:1}).watch(({leaf:e,records:t})=>{for(let e=0;e<t.length;e++){let a=t[e];a.instance&&a.instance.api.unmount(),a.active=0}let{spawn:a}=e;a.active=0,K(a,a.parent.childSpawns[a.template.id]),K(a,a.template.pages)})},env:d}))}function J(e){if(!Nt)return;let{draft:t}=e;if('listItem'!==t.type&&'rec'!==t.type)switch(Nt.draft.type){case'element':case'using':case'route':case'list':case'rec':case'recItem':t.inParentIndex=Nt.draft.childCount,Nt.draft.childCount+=1,Nt.draft.childTemplates.push(e);break;default:console.warn("unexpected currentActor type "+Nt.draft.type)}}function K(e,t){if(!t)return;let a=t.indexOf(e);-1!==a&&t.splice(a,1)}function X({mount:e,state:t,onMount:a,onState:r}){return{onMount:i({source:t,clock:e,fn:a,greedy:1}),onState:i({source:e,clock:t,fn:r,greedy:1})}}let Y=e=>(oe(e)||le(e))&&'kind'in e;const Z=e=>t=>Y(t)&&t.kind===e;let ee=Z('store'),te=Z('event'),ae=Z('effect'),re=Z('domain'),ne=e=>{throw Error(e)},le=e=>'object'==typeof e&&null!==e,oe=e=>'function'==typeof e,ie=e=>e.graphite||e,se=e=>e.family.owners,ue=e=>e.family.links,ce=e=>e.stateRef,pe=e=>e.config,de=e=>e.ɔ,fe=e=>e.value,he=e=>e.subscribers,me=e=>e.parent,ge=(e,t)=>''+e.shortName+t,ve=(e,t)=>null==t?ge(e,' → *'):t;var ye=(()=>{var e,t=('undefined'!=typeof self?self:'undefined'!=typeof window?window:'undefined'!=typeof global?global:'undefined'!=typeof module?module:Function("","return this")()).Symbol;return'function'==typeof t?t.observable?e=t.observable:(e=t('observable'),t.observable=e):e='@@observable',e})();const be=()=>{let e=0;return()=>(++e).toString(36)};let ke=be(),we=be(),xe=(e,t)=>e.bind(null,t),Se=(e,t,a)=>e.bind(null,t,a);const Ie=(e,t,a)=>({id:we(),type:e,data:a,hasRef:t});let Re=0,Te=({priority:e="barrier"})=>Ie('barrier',0,{barrierID:++Re,priority:e}),Ce=({from:e="store",store:t,target:a,to:r=(a?'store':'stack')})=>Ie('mov','store'===e,{from:e,store:t,to:r,target:a}),Fe=()=>Ie('check',0,{type:'defined'}),Ae=({store:e})=>Ie('check',1,{type:'changed',store:e}),qe=Se(Ie,'compute',0),Pe=Se(Ie,'filter',0),Ne=Se(Ie,'run',0),De=({store:e})=>Ce({from:'stack',target:e}),Me=e=>({id:we(),current:e}),Oe=({current:e})=>e,Ee=(e,{fn:t},{a})=>t(e,a),Ve=(e,{fn:t},{a})=>t(a,e),je=(e,{fn:t})=>t(e),ze=(e,t)=>{let a=ie(e);for(let e=0;e<t.length;e++){let r=ie(t[e]);'domain'!==a.family.type&&(r.family.type='crosslink'),se(r).push(a),ue(a).push(r)}};const Le=(e=[])=>{let t=[];if(Array.isArray(e))for(let a=0;a<e.length;a++)Array.isArray(e[a])?t.push(...e[a]):t.push(e[a]);else t.push(e);return t.map(ie)};let Be=({hasRef:e,type:t,data:a},r)=>{let n;e&&(n=a.store,r[n.id]=n),'mov'===t&&'store'===a.to&&(n=a.target,r[n.id]=n)},Ue=null;const _e=(e,t)=>{if(!e)return t;if(!t)return e;let a,r=e.v.type===t.v.type;return(r&&e.v.id>t.v.id||!r&&'sampler'===e.v.type)&&(a=e,e=t,t=a),a=_e(e.r,t),e.r=e.l,e.l=a,e},Qe=[];let $e=0;for(;$e<5;)Qe.push({first:null,last:null,size:0}),$e+=1;const Ge=()=>{for(let e=0;e<5;e++){let t=Qe[e];if(t.size>0){if(2===e||3===e){t.size-=1;let e=Ue.v;return Ue=_e(Ue.l,Ue.r),e}1===t.size&&(t.last=null);let a=t.first;return t.first=a.r,t.size-=1,a.v}}},We=(e,t,a,r,n,l)=>He(0,{a:null,b:null,node:a,parent:r,value:n,page:t,forkPage:l},e),He=(e,t,a,r=0)=>{let n=Je(a),l=Qe[n],o={v:{idx:e,stack:t,type:a,id:r},l:0,r:0};2===n||3===n?Ue=_e(Ue,o):(0===l.size?l.first=o:l.last.r=o,l.last=o),l.size+=1},Je=e=>{switch(e){case'child':return 0;case'pure':return 1;case'barrier':return 2;case'sampler':return 3;case'effect':return 4;default:return-1}},Ke=new Set;let Xe,Ye=0,Ze=null,et=()=>Ze,tt=(e,t,a)=>{let r=Ze,n=null,l=Xe;if(e.target&&(t=e.params,a=e.defer,r='page'in e?e.page:r,e.stack&&(n=e.stack),l=e.forkPage||l,e=e.target),Array.isArray(e))for(let a=0;a<e.length;a++)We('pure',r,ie(e[a]),n,t[a],l);else We('pure',r,ie(e),n,t,l);a&&Ye||(()=>{let e,t,a,r,n,l,o={alreadyStarted:Ye,currentPage:Ze,forkPage:Xe};Ye=1;e:for(;r=Ge();){let{idx:o,stack:i,type:s}=r;a=i.node,Ze=n=i.page,Xe=i.forkPage,l=(n||a).reg;let u={fail:0,scope:a.scope};e=t=0;for(let r=o;r<a.seq.length&&!e;r++){let c=a.seq[r],p=c.data;switch(c.type){case'barrier':{let e=p.barrierID;n&&(e=`${n.fullID}_${e}`);let t=p.priority;if(r!==o||s!==t){Ke.has(e)||(Ke.add(e),He(r,i,t,e));continue e}Ke.delete(e);break}case'mov':{let e;switch(p.from){case'stack':e=fe(i);break;case'a':e=i.a;break;case'b':e=i.b;break;case'value':e=p.store;break;case'store':l[p.store.id]||(i.page=n=null,l=a.reg),e=Oe(l[p.store.id])}switch(p.to){case'stack':i.value=e;break;case'a':i.a=e;break;case'b':i.b=e;break;case'store':l[p.target.id].current=e}break}case'check':switch(p.type){case'defined':t=void 0===fe(i);break;case'changed':t=fe(i)===Oe(l[p.store.id])}break;case'filter':t=!at(u,p,i);break;case'run':if(r!==o||'effect'!==s){He(r,i,'effect');continue e}case'compute':i.value=at(u,p,i)}e=u.fail||t}if(!e)for(let e=0;e<a.next.length;e++)We('child',n,a.next[e],i,fe(i),i.forkPage)}Ye=o.alreadyStarted,Ze=o.currentPage,Xe=o.forkPage})()};const at=(e,{fn:t},a)=>{try{return t(fe(a),e.scope,a)}catch(t){console.error(t),e.fail=1}};let rt=(e,t)=>{de(e)&&t(pe(e),de(e))};const nt=(e,t)=>{let a=e.indexOf(t);-1!==a&&e.splice(a,1)},lt=(e,t)=>{nt(e.next,t),nt(se(e),t),nt(ue(e),t)},ot=(e,t,a)=>{let r;e.next.length=0,e.seq.length=0,e.scope=null;let n=ue(e);for(;r=n.pop();)lt(r,e),(t||a&&!e.meta.sample||'crosslink'===r.family.type)&&ot(r,t,a);for(n=se(e);r=n.pop();)lt(r,e),a&&'crosslink'===r.family.type&&ot(r,t,a)},st=e=>e.clear();let ut=(e,{deep:t}={})=>{let a=0;if(e.ownerSet&&e.ownerSet.delete(e),ee(e))st(he(e));else if(re(e)){a=1;let t=e.history;st(t.events),st(t.effects),st(t.stores),st(t.domains)}ot(ie(e),!!t,a)},ct=e=>{let t=Se(ut,e,void 0);return t.unsubscribe=t,t},pt=e=>(dt&&ze(fe(dt),[e]),e),dt=null,ft=()=>dt&&dt.template,ht=(e,t,{node:r,scope:n,meta:l})=>pt(a({node:r,parent:e,child:t,scope:n,meta:l,family:{owners:[e,t],links:t}})),mt=(e,t)=>(oe(t)||ne('.watch argument should be a function'),ct(pt(a({scope:{fn:t},node:[Ne({fn:je})],parent:e,meta:{op:'watch'},family:{owners:e}}))));const gt=(e,t)=>(le(e)&&(gt(pe(e),t),null!=e.name&&(le(e.name)?gt(e.name,t):t.name=e.name),e.loc&&(t.loc=e.loc),(e.sid||null===e.sid)&&(t.sid=e.sid),e.handler&&(t.handler=e.handler),me(e)&&(t.parent=me(e)),'strict'in e&&(t.strict=e.strict),e.named&&(t.named=e.named),gt(de(e),t)),t);let vt,yt=(e,t,a,r)=>{let n=gt({name:r,config:a},{}),l=ke(),{parent:o=null,sid:i=null,strict:s=1,named:u=null}=n,c=u||n.name||('domain'===e?'':l),p=((e,t)=>{let a,r,n,l=e;return t?(n=t.compositeName,0===e.length?(a=n.path,r=n.fullName):(a=n.path.concat([e]),r=0===n.fullName.length?e:n.fullName+'/'+e)):(a=0===e.length?[]:[e],r=e),{shortName:l,fullName:r,path:a}})(c,o);return t.kind=e,t.id=l,t.sid=i,t.shortName=c,t.parent=o,t.compositeName=p,t.defaultConfig=n,t.thru=e=>e(t),t.getType=()=>p.fullName,'domain'!==e&&(t.subscribe=e=>((e=>{le(e)||oe(e)||ne('expect value to be an object')})(e),t.watch(oe(e)?e:t=>{e.next&&e.next(t)})),t[ye]=()=>t),vt=s,{unit:e,name:c,sid:i,named:u}};const bt=(e,t,a,r)=>ht(e,t,{scope:{fn:r},node:[qe({fn:je})],meta:{op:a}}),kt=(e,t,a,r)=>{let l;le(a)&&(l=a,a=a.fn);let o=n(ge(e,' →? *'),l);return ht(e,o,{scope:{fn:a},node:r,meta:{op:t}}),o},wt=(e,t,a,r,n)=>{let l=ce(t),o=[Ce({store:l,to:'a'}),qe({fn:r?Ve:Ee}),Fe(),Ae({store:l}),De({store:l})],i=ft();if(i&&(o.unshift(i.loader),o.push(i.upward),ee(e))){let t=ce(e);i.plain.includes(t)||(i.closure.includes(t)||i.closure.push(t),l.before||(l.before=[]),l.before.push({type:'closure',of:t}))}return ht(e,t,{scope:{fn:n},node:o,meta:{op:a}})};let xt=(e,t)=>{for(let a in e)t(e[a],a)};const St=(a({node:[Ne({fn({fn:e,value:t}){e(t)}})],meta:{op:'fx',fx:'sidechain'}}),(e,a)=>(Y(e)||(e=((...e)=>{let a,r,n;0===e.length&&ne('at least one argument required'),rt(e[0],(t,a)=>{n=t,e=a});let l,i,s=e[e.length-1];if(oe(s)?(r=e.slice(0,-1),a=s):r=e,1===r.length){let e=r[0];ee(e)||(l=e,i=1)}return i||(l=r,a&&(a=(e=>t=>e(...t))(a))),le(l)||ne('shape should be an object'),((e,a,r,n)=>{let l=e?e=>e.slice():e=>Object.assign({},e),i=e?[]:{},s=ft(),u=l(i),c=Me(u),p=Me(1);c.type=e?'list':'shape',s&&s.plain.push(c,p);let d=o(u,{name:r||t(a)}),f=[Fe(),Ce({store:c,to:'a'}),Pe({fn:(e,{key:t},{a})=>e!==a[t]}),Ce({store:p,to:'b'}),qe({fn(e,{clone:t,key:a},r){r.b&&(r.a=t(r.a)),r.a[a]=e}}),Ce({from:'a',target:c}),Ce({from:'value',store:0,target:p}),Te({priority:'barrier'}),Ce({from:'value',store:1,target:p}),Ce({store:c}),n&&qe({fn:n}),Ae({store:ce(d)})],h=c.before=[];return xt(a,(e,t)=>{if(!ee(e))return void(u[t]=i[t]=e);i[t]=e.defaultState,u[t]=e.getState();let a=ht(e,d,{scope:{key:t,clone:l},node:f,meta:{op:'combine'}}),r=ce(e);h.push({type:'field',field:t,from:r}),s&&(s.plain.includes(r)||a.seq.unshift(s.loader))}),d.defaultShape=a,c.after=[n?{type:'map',to:ce(d),fn:n}:{type:'copy',to:ce(d)}],s||(d.defaultState=n?ce(d).current=n(u):i),d})(Array.isArray(l),l,n,a)})(e),a&&console.error('sample clock shape is deprecated')),e));let It,Rt,Tt;Pe({fn:(e,{state:t})=>void 0!==e&&e!==Oe(t)}),qe({fn:e=>e}),'undefined'!=typeof performance&&performance.mark?(It=e=>{performance.mark('☄️ '+e+' start')},Rt=e=>{try{performance.measure('☄️ '+e,'☄️ '+e+' start')}catch(e){}performance.clearMarks('☄️ '+e+' start'),performance.clearMeasures('☄️ '+e)}):(It=()=>{},Rt=()=>{}),Tt='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 Ct='undefined'!=typeof requestAnimationFrame?requestAnimationFrame:e=>setTimeout(e,0),Ft=0,At=0,qt=null,Pt=null,Nt=null,Dt=n();Dt.watch(({fns:e,element:t})=>{e.forEach(e=>{e(t)})}),e.h=(e,t)=>{function a(e){return e.data.block.value}function r(e,t,a){let r=e.data.block.child.child,n={type:'text',parent:{type:'FT',parent:r,child:null,visible:0,index:a},value:null};if(n.parent.child=n,r.child[a]=n.parent,e.hydration){let e=O(n);if(e)switch(e.type){case'text':n.value=c.document.createTextNode(t),e.value.after(n.value);break;case'element':n.value=e.value.nextSibling,C(n.value,t)}else{let e=N(n);n.value=e.firstChild,C(n.value,t)}n.parent.visible=1}else n.value=c.document.createTextNode(t),z(n);return n}let l,o=0,u=0;if('function'==typeof t?(o=1,l=t):t&&(u=1,t.fn&&(o=1,l=t.fn),t.ɔ&&('function'==typeof t.ɔ?(o=1,l=t.ɔ):'function'==typeof t.ɔ.fn&&(o=1,l=t.ɔ.fn))),!Nt)throw Error('h() called outside from using() closure');let c=Nt.env,p=Nt.namespace,d=p,m='html';d=m='svg'===p?'svg':'html','svg'===e&&(m='svg',d='svg');let v='svg'===m?c.document.createElementNS('http://www.w3.org/2000/svg',e):c.document.createElement(e);'foreignObject'===p?(v.setAttribute('xmlns','http://www.w3.org/1999/xhtml'),d='html'):'svg'===e?(v.setAttribute('xmlns','http://www.w3.org/2000/svg'),d='svg'):'foreignObject'===e&&(d='foreignObject');let y=v,b={type:'element',tag:e,attr:[],data:[],text:[],styleProp:[],styleVar:[],handler:[],stencil:y,seq:[],childTemplates:[],childCount:0,inParentIndex:-1,opsAmount:1,node:[]},k=F({name:'element',draft:b,isSvgRoot:'svg'===e,namespace:d,fn(e,{mount:c,unmount:p}){function d(e){return X({mount:m,state:e,onMount:(e,t)=>({leaf:t,value:e}),onState:(e,t)=>({leaf:e,value:t})})}let m=n(),v=c.map(({leaf:e})=>e);o&&l(),u&&U(t);let w={attr:{},data:{},text:b.text,styleProp:{},styleVar:{},visible:b.visible||null,handler:b.handler};for(let e=0;e<b.attr.length;e++){let t=b.attr[e];for(let e in t)'xlink:href'===e?w.attr.href=t[e]:w.attr[e]=t[e]}for(let e=0;e<b.data.length;e++){let t=b.data[e];for(let e in t)w.data[e]=t[e]}for(let e=0;e<b.styleProp.length;e++){let t=b.styleProp[e];for(let e in t)e.startsWith('--')?w.styleVar[e.slice(2)]=t[e]:w.styleProp[e]=t[e]}for(let e=0;e<b.styleVar.length;e++){let t=b.styleVar[e];for(let e in t)w.styleVar[e]=t[e]}w.visible&&b.seq.push({type:'visible',value:w.visible});for(let e in w.attr){let t=w.attr[e];Y(t)?b.seq.push({type:'attr',field:e,value:t}):T(y,e,t)}for(let e in w.data){let t=w.data[e];Y(t)?b.seq.push({type:'data',field:e,value:t}):R(y,e,t)}for(let e in w.styleProp){let t=w.styleProp[e];Y(t)?b.seq.push({type:'style',field:e,value:t}):I(y,e,t)}for(let e in w.styleVar){let t=w.styleVar[e];Y(t)?b.seq.push({type:'styleVar',field:e,value:t}):S(y,e,t)}for(let e=0;e<w.text.length;e++){let t=w.text[e];if(null!==t.value)if(Y(t.value)){b.seq.push({type:'dynamicText',value:t.value,childIndex:t.index});let e=t.value.stateRef,a=qt;a.plain.includes(e)||a.closure.includes(e)||a.closure.push(e)}else b.seq.push({type:'staticText',value:String(t.value),childIndex:t.index})}for(let e=0;e<w.handler.length;e++){let t=w.handler[e];for(let e in t.map)b.seq.push({type:'handler',for:e,handler:t.map[e],options:t.options,domConfig:t.domConfig})}if(w.visible){let{onMount:e,onState:t}=X({mount:v,state:w.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&&(f(t,r.ops.visible),t)){let e,t=E(n);if(e=t?t.nextSibling:N(n).firstChild,'#text'===e.nodeName){let t=e;e=e.nextSibling,t.remove()}n.value=e,n.parent.visible=1}V(b,{parentBlockFragment:n.child.child,leaf:e,node:n.value,svgRoot:k.isSvgRoot?n.value:null}),t&&r.needToCallNode&&(r.needToCallNode=0,tt({target:Dt,params:{element:r.block.value,fns:b.node},page:e.spawn,defer:1})),tt({target:m,params:e,defer:1,page:e.spawn})}),s([t,e]).watch(({leaf:e,value:t,hydration:a})=>{a||h(t,e.data.ops.visible)})}for(let e=0;e<b.seq.length;e++){let t=b.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:l}=d(t.value);if(r)s([l,n]).watch(({leaf:t,value:r})=>{T(a(t),e,r)});else{let t=b.opsAmount++;n.watch(({value:r,leaf:n})=>{let l=a(n),o=g({value:r,priority:'props',runOp(t){T(l,e,t)},group:n.ops.group});n.ops.group.ops[t]=o,T(l,e,r)}),l.watch(({value:e,leaf:a})=>{h(e,a.ops.group.ops[t])})}break}case'data':{let{field:e}=t,{onMount:r,onState:n}=d(t.value),l=b.opsAmount++;r.watch(({value:t,leaf:r})=>{let n=a(r),o=g({value:t,priority:'props',runOp(t){R(n,e,t)},group:r.ops.group});r.ops.group.ops[l]=o,R(n,e,t)}),n.watch(({value:e,leaf:t})=>{h(e,t.ops.group.ops[l])});break}case'style':{let e=b.opsAmount++,{field:r}=t,{onMount:n,onState:l}=d(t.value);n.watch(({value:t,leaf:n})=>{let l=a(n),o=g({value:t,priority:'props',runOp(e){I(l,r,e)},group:n.ops.group});n.ops.group.ops[e]=o,I(l,r,t)}),l.watch(({value:t,leaf:a})=>{h(t,a.ops.group.ops[e])});break}case'styleVar':{let{field:e}=t,{onMount:r,onState:n}=d(t.value),l=b.opsAmount++;r.watch(({value:t,leaf:r})=>{let n=a(r),o=g({value:t,priority:'props',runOp(t){S(n,e,t)},group:r.ops.group});r.ops.group.ops[l]=o,S(n,e,t)}),n.watch(({value:e,leaf:t})=>{h(e,t.ops.group.ops[l])});break}case'staticText':m.map(e=>e).watch(e=>{r(e,t.value,t.childIndex)});break;case'dynamicText':{let e=b.opsAmount++;i({source:t.value,clock:m,fn:(e,t)=>({value:String(e),leaf:t}),greedy:1}).watch(({value:a,leaf:n})=>{let l=g({value:a,priority:'props',runOp(e){C(o.value,e)},group:n.ops.group});n.ops.group.ops[e]=l;let o=r(n,a,t.childIndex)}),i({source:m,clock:t.value,fn:(e,t)=>({leaf:e,text:t}),greedy:1}).watch(({leaf:t,text:a})=>{h(a,t.ops.group.ops[e])});break}case'handler':{let e=t.handler.graphite.meta.nativeTemplate||null;m.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(),tt({target:t.handler,params:e,page:n})},t.domConfig)});break}}}i({source:v,clock:p,greedy:1}).watch(e=>{let{spawn:t}=e;K(t,t.parent.childSpawns[t.template.id]),function e(t){t.active=0,K(t,t.template.pages);for(let a in t.childSpawns)t.childSpawns[a].forEach(e)}(t),h(0,e.data.ops.visible)}),c.watch(({leaf:e})=>{let t=e.data;if(!b.visible){let a=t.ops.visible,r=t.block;if(e.hydration){f(1,a);let e,t=E(r);if(e=t?t.nextSibling:N(r).firstChild,'#text'===e.nodeName){let t=e;e=e.nextSibling,t.remove()}r.value=e,r.parent.visible=1}V(b,{parentBlockFragment:r.child.child,leaf:e,node:r.value,svgRoot:k.isSvgRoot?r.value:null}),tt({target:m,params:e,defer:1,page:e.spawn}),e.hydration?t.needToCallNode&&(t.needToCallNode=0,tt({target:Dt,params:{element:t.block.value,fns:b.node},page:e.spawn,defer:1})):h(1,a)}})},env:c});J(k)},e.handler=_,e.list=H,e.node=e=>{let t=Nt.draft;switch(t.type){case'list':case'listItem':case'using':case'route':case'rec':case'recItem':return}t.node.push(e)},e.rec=W,e.remap=L,e.route=Q,e.spec=U,e.text=(e,...t)=>{let a=[e[0]];for(let r=0;r<t.length;r++)a.push(t[r],e[r+1]);U({text:a})},e.tree=({source:e,child:t,fn:a})=>{let r=W(({state:e})=>{H({source:e,fn({store:e}){let n=e.map(e=>e[t]||[]);a({store:e,child(){r({state:n})}})}})});r({state:e})},e.using=(e,t)=>{let a,r,n,l,o;if('function'==typeof t)a=t,n=B(),l=0;else{if(!t)throw Error('using() second argument is missing');a=t.fn,n=t.env?t.env:B(),l=t.hydrate,r=t.onComplete,o=t.onRoot}if(!e)throw Error('using() first argument is missing');let i=e.namespaceURI,s=e.tagName.toLowerCase(),u={type:'using',childTemplates:[],childCount:0,inParentIndex:-1},c=F({name:'using',draft:u,isSvgRoot:'svg'===s,namespace:'http://www.w3.org/2000/svg'===i?'svg':'foreignobject'===s?'foreignObject':'html',fn(e,{mount:t}){a(),t.watch(({node:e,leaf:t})=>{V(u,{parentBlockFragment:t.data.block.child.child,leaf:t,node:e})})},env:n}),p={type:'using',child:{type:'UF',parent:null,child:{type:'fragment',parent:null,child:[]}},value:e};p.child.parent=p,p.child.child.parent=p.child;let d=v({onComplete:r}),f=P(c,{parentLeaf:Pt||null,mountNode:e,svgRoot:c.isSvgRoot?e:Pt?Pt.svgRoot:null,leafData:{type:'using',draft:u,element:e,block:p},opGroup:y(d),domSubtree:y(d),hydration:l});o&&o({template:c,leaf:f})},e.variant=({source:e,cases:t,key:a})=>{if(!Y(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 n=0;for(let a in t)'__'!==a?Q({source:e,visible:e=>r(e)===a,fn:t[a]}):n=1;if(n){let a=Object.keys(t);Q({source:e,visible:e=>!a.includes(r(e)),fn:t.__})}},Object.defineProperty(e,'__esModule',{value:1})});
//# sourceMappingURL=forest.umd.js.map
{
"name": "forest",
"version": "0.16.7",
"version": "0.16.8",
"description": "UI engine for web",

@@ -12,3 +12,3 @@ "main": "forest.cjs.js",

"peerDependencies": {
"effector": "^20.17.0"
"effector": "^20.17.2"
},

@@ -15,0 +15,0 @@ "keywords": [

@@ -1,135 +0,1 @@

import {Store, Event, Step} from 'effector'
export type Signal = Step
export type StoreOrData<T> = Store<T> | T
export type DOMProperty = string | number | null | boolean
export type PropertyMap = {[field: string]: StoreOrData<DOMProperty>}
export type StylePropertyMap = Partial<
{
[K in keyof CSSStyleDeclaration]: StoreOrData<DOMProperty>
}
>
export type TransformMap = {
translate: StoreOrData<{
x?: number
y?: number
}>
scale: StoreOrData<{
x?: number
y?: number
}>
rotate: StoreOrData<
| {
angle?: number
x?: number
y?: number
}
| number
>
skewX: StoreOrData<number>
skewY: StoreOrData<number>
}
export type DOMElement = HTMLElement | SVGElement
type Tuple<T = unknown> = [T] | T[]
type Combinable = {[key: string]: Store<any>} | Tuple<Store<any>>
type GetCombinedValue<T> = {
[K in keyof T]: T[K] extends Store<infer U> ? U : never
}
export function using(node: DOMElement, cb: () => any): void
export function spec(spec: {
attr?: PropertyMap
data?: PropertyMap
transform?: Partial<TransformMap>
text?: StoreOrData<DOMProperty>
visible?: Store<boolean>
style?: StylePropertyMap
styleVar?: PropertyMap
focus?: {
focus?: Event<any>
blur?: Event<any>
}
handler?: Partial<
{[K in keyof HTMLElementEventMap]: Event<HTMLElementEventMap[K]>}
>
}): void
export function handler(
map: Partial<
{[K in keyof HTMLElementEventMap]: Event<HTMLElementEventMap[K]>}
>,
): void
export function handler(
options: {passive?: boolean; capture?: boolean},
map: Partial<
{[K in keyof HTMLElementEventMap]: Event<HTMLElementEventMap[K]>}
>,
): void
export function h(tag: string, cb: () => void): void
export function h(
tag: string,
spec: {
attr?: PropertyMap
data?: PropertyMap
transform?: Partial<TransformMap>
text?: StoreOrData<DOMProperty>
visible?: Store<boolean>
style?: StylePropertyMap
styleVar?: PropertyMap
focus?: {
focus?: Event<any>
blur?: Event<any>
}
handler?: Partial<
{[K in keyof HTMLElementEventMap]: Event<HTMLElementEventMap[K]>}
>
},
): void
export function list<T>(
source: Store<T[]>,
cb: (opts: {store: Store<T>; index: number; signal: Signal}) => void,
): void
export function list<T, K extends keyof T>(
{
key,
source,
reverse,
}: {
key: T[K] extends string | number | symbol ? K : never
source: Store<T[]>
reverse?: boolean
},
cb: (opts: {store: Store<T>; key: T[K]; signal: Signal}) => void,
): void
export function map<T, S>(
store: Store<T>,
config: {fn: (value: T) => S},
): Store<S>
export function combine<A extends Combinable, B>(config: {
source: A
fn(source: GetCombinedValue<A>): B
}): Store<B>
export function node(fn: (node: DOMElement) => void): void
export function signalOwn<T>(value: T): T
export function explicitUnmount(unmountOn: Event<any>): void
export function remap<T extends {[field: string]: any}, S extends keyof T>(
store: Store<T>,
key: S,
): Store<T[S]>
export function remap<
T extends {[field: string]: any},
S extends {[field: number]: keyof T} | {[field: string]: keyof T}
>(
store: Store<T>,
shape: S,
): {[K in keyof S]: S[K] extends keyof T ? Store<T[S[K]]> : never}
export function renderStatic(cb: () => void): Promise<string>

@@ -1,2 +0,2 @@

function t(t,e){t.sibling.right=e,t.nextSibling=e}function e(t){return"-"+t.toLowerCase()}function i(t){switch(t){case'&':return'&amp;';case'<':return'&lt;';case'>':return'&gt;';case'"':return'&quot;';case"'":return'&#39;';default:return t}}function s(t){switch(t=String(t)){case'__proto__':case'__defineGetter__':case'__defineSetter__':case'constructor':case'prototype':case'hasOwnProperty':case'toString':case'valueOf':return'blacklisted';default:return t.replace(n,'')}}function r(t){return String(t).replace(a,'')}Object.defineProperty(exports,'__esModule',{value:1});var l=require('forest');const n=/[^a-zA-Z0-9\-]/g,a=/[\\<>"]/g,h=/[A-Z]/g,o=/[&<>'"]/g;class u{constructor(){this.child={first:null,last:null},this.sibling={left:null,right:null},this.parent=null,this.tagName='',this.nodeName='',this.namespaceURI='http://www.w3.org/1999/xhtml',this.dataset=Object.create(null),this.style=new c,this.value=void 0,this.firstChild=null,this.nextSibling=null,this.transform={baseVal:new g},this.isFragment=1,this.attributes=Object.create(null),this.textContent=null,this.__STATIC__=1}cloneNode(){let t=new u;t.tagName=this.tagName,t.nodeName=this.nodeName,t.namespaceURI=this.namespaceURI,Object.assign(t.dataset,this.dataset),Object.assign(t.style.properties,this.style.properties),t.value=this.value;for(let{value:e}of this.transform.baseVal.items){let i=new f;i.value=e,t.transform.baseVal.items.push(i)}return t.isFragment=this.isFragment,Object.assign(t.attributes,this.attributes),t.textContent=this.textContent,t}after(e){this.sibling.right!==e&&(e.parent&&e.remove(),this.parent&&(this.sibling.right?(this.sibling.right.sibling.left=e,t(e,this.sibling.right)):this.parent.child.last=e,t(this,e),e.sibling.left=this,e.parent=this.parent))}prepend(e){e.parent&&e.remove(),this.child.last?(this.child.first.sibling.left=e,t(e,this.child.first)):(this.child.first=e,this.child.last=e),this.child.first=e,this.firstChild=e,e.parent=this}remove(){if(!this.parent)return;let{parent:e}=this;e.child.first===this&&e.child.last===this?(e.firstChild=null,e.child.first=null,e.child.last=null):e.child.first===this?(e.child.first=this.sibling.right,e.firstChild=this.sibling.right,this.sibling.right.sibling.left=null):e.child.last===this?(e.child.last=this.sibling.left,t(this.sibling.left,null)):(this.sibling.right.sibling.left=this.sibling.left,t(this.sibling.left,this.sibling.right)),this.sibling.left=null,t(this,null),this.parent=null}addEventListener(t,e,i){}removeEventListener(t,e,i){}setAttribute(t,e){this.attributes[s(t)]=r(e)}removeAttribute(t){delete this.attributes[s(t)]}replaceWith(e){if(!this.parent)return;let{parent:i}=this;e.parent&&e.remove(),i.child.first===this&&i.child.last===this?(i.firstChild=e,i.child.first=e,i.child.last=e):i.child.first===this?(i.child.first=e,i.firstChild=e,this.sibling.right.sibling.left=e):i.child.last===this?(i.child.last=e,t(this.sibling.left,e)):(this.sibling.right.sibling.left=e,t(this.sibling.left,e)),e.sibling.left=this.sibling.left,t(e,this.sibling.right),e.parent=i,this.sibling.left=null,t(this,null),this.parent=null}createSVGTransform(){return new f}replaceData(t,e,i){'string'==typeof this.textContent&&(this.textContent=`${this.textContent.slice(0,t)}${i}${this.textContent.slice(t+e)}`)}splitText(t){if('string'!=typeof this.textContent)return null;let e=new u;return e.nodeName='#text',e.textContent=this.textContent.slice(t),this.textContent=this.textContent.slice(0,t),this.after(e),e}}class c{constructor(){this.properties=Object.create(null)}setProperty(t,e){this.properties[s(t)]=r(e)}removeProperty(t){delete this.properties[s(t)]}}class g{constructor(){this.items=[]}appendItem(t){this.items.push(t)}}class f{constructor(){this.value=''}setTranslate(t,e){this.value=`translate(${t} ${e})`}setScale(t,e){this.value=`scale(${t} ${e})`}setRotate(t,e,i){this.value=0!==e||0!==i?`rotate(${t} ${e} ${i})`:`rotate(${t})`}setSkewX(t){this.value=`skewX(${t})`}setSkewY(t){this.value=`skewY(${t})`}}const p=['area','base','br','col','embed','hr','img','input','keygen','link','meta','param','source','track','wbr'];exports.renderStatic=t=>{let n={document:{createTextNode(t){let e=new u;return e.textContent=String(t).replace(o,i),e.nodeName='#text',e},createElement(t){let e=new u;return e.tagName=s(t),e.isFragment=0,e},createElementNS(t,e){switch(t){case'http://www.w3.org/1999/xhtml':case'http://www.w3.org/2000/svg':break;default:t='http://www.w3.org/1999/xhtml'}let i=new u;return i.tagName=s(e),i.namespaceURI=t,i.isFragment=0,i}}},a=n.document.createDocumentFragment();return new Promise(i=>{l.using(a,{fn:t,env:n,onComplete(){i((t=>{let i=[];(function t(i,l){if(null!==i.textContent&&l.push(i.textContent),i.isFragment){let e=i.firstChild;for(;e;)t(e,l),e=e.sibling.right;return}l.push('<',i.tagName);for(let t in i.attributes)l.push(' ',t,'=','"',r(i.attributes[t]),'"');for(let t in i.dataset)l.push(' ','data-',s(t).replace(h,e),'=','"',r(i.dataset[t]),'"');let n=[];for(let t in i.style.properties)if(t.startsWith('--'))n.push(`${t}: ${i.style.properties[t]}`);else{let e=t.replace(/[A-Z]/g,t=>"-"+t.toLowerCase());(t.startsWith('webkit')||t.startsWith('moz'))&&(e="-"+e),n.push(`${e}: ${i.style.properties[t]}`)}if(n.length>0&&l.push(' ','style','=','"',n.join(';'),'"'),i.transform.baseVal.items.length>0){l.push(' ','transform','=','"');let t=i.transform.baseVal.items.map(({value:t})=>t);l.push(t.join(' '),'"')}if(l.push('>'),p.includes(i.tagName))return;let a=i.firstChild;for(;a;)t(a,l),a=a.sibling.right;l.push('</',i.tagName,'>')})(t,i);let l=i.join('');return function t(e){if('html'===e.tagName)return 1;if(e.isFragment&&null===e.textContent){let i=e.firstChild;if(i&&e.child.last===i)return t(i)}return 0}(t)?"<!DOCTYPE html>"+l:l})(a))}})})};
function t(t,e){t.sibling.right=e,t.nextSibling=e}function e(t){return"-"+t.toLowerCase()}function i(t){switch(t){case'&':return'&amp;';case'<':return'&lt;';case'>':return'&gt;';case'"':return'&quot;';case"'":return'&#39;';default:return t}}function s(t){switch(t=String(t)){case'__proto__':case'__defineGetter__':case'__defineSetter__':case'constructor':case'prototype':case'hasOwnProperty':case'toString':case'valueOf':return'blacklisted';default:return t.replace(n,'')}}function r(t){return String(t).replace(a,'')}Object.defineProperty(exports,'__esModule',{value:1});var l=require('forest');const n=/[^a-zA-Z0-9\-]/g,a=/[\\<>"]/g,h=/[A-Z]/g,o=/[&<>'"]/g;class u{constructor(){this.child={first:null,last:null},this.sibling={left:null,right:null},this.parent=null,this.tagName='',this.nodeName='',this.namespaceURI='http://www.w3.org/1999/xhtml',this.dataset=Object.create(null),this.style=new c,this.value=void 0,this.firstChild=null,this.nextSibling=null,this.transform={baseVal:new g},this.isFragment=1,this.attributes=Object.create(null),this.textContent=null,this.__STATIC__=1}cloneNode(){let t=new u;t.tagName=this.tagName,t.nodeName=this.nodeName,t.namespaceURI=this.namespaceURI,Object.assign(t.dataset,this.dataset),Object.assign(t.style.properties,this.style.properties),t.value=this.value;for(let{value:e}of this.transform.baseVal.items){let i=new f;i.value=e,t.transform.baseVal.items.push(i)}return t.isFragment=this.isFragment,Object.assign(t.attributes,this.attributes),t.textContent=this.textContent,t}after(e){this.sibling.right!==e&&(e.parent&&e.remove(),this.parent&&(this.sibling.right?(this.sibling.right.sibling.left=e,t(e,this.sibling.right)):this.parent.child.last=e,t(this,e),e.sibling.left=this,e.parent=this.parent))}prepend(e){e.parent&&e.remove(),this.child.last?(this.child.first.sibling.left=e,t(e,this.child.first)):(this.child.first=e,this.child.last=e),this.child.first=e,this.firstChild=e,e.parent=this}remove(){if(!this.parent)return;let{parent:e}=this;e.child.first===this&&e.child.last===this?(e.firstChild=null,e.child.first=null,e.child.last=null):e.child.first===this?(e.child.first=this.sibling.right,e.firstChild=this.sibling.right,this.sibling.right.sibling.left=null):e.child.last===this?(e.child.last=this.sibling.left,t(this.sibling.left,null)):(this.sibling.right.sibling.left=this.sibling.left,t(this.sibling.left,this.sibling.right)),this.sibling.left=null,t(this,null),this.parent=null}addEventListener(t,e,i){}removeEventListener(t,e,i){}setAttribute(t,e){this.attributes[s(t)]=r(e)}removeAttribute(t){delete this.attributes[s(t)]}replaceWith(e){if(!this.parent)return;let{parent:i}=this;e.parent&&e.remove(),i.child.first===this&&i.child.last===this?(i.firstChild=e,i.child.first=e,i.child.last=e):i.child.first===this?(i.child.first=e,i.firstChild=e,this.sibling.right.sibling.left=e):i.child.last===this?(i.child.last=e,t(this.sibling.left,e)):(this.sibling.right.sibling.left=e,t(this.sibling.left,e)),e.sibling.left=this.sibling.left,t(e,this.sibling.right),e.parent=i,this.sibling.left=null,t(this,null),this.parent=null}createSVGTransform(){return new f}replaceData(t,e,i){'string'==typeof this.textContent&&(this.textContent=`${this.textContent.slice(0,t)}${i}${this.textContent.slice(t+e)}`)}splitText(t){if('string'!=typeof this.textContent)return null;let e=new u;return e.nodeName='#text',e.textContent=this.textContent.slice(t),this.textContent=this.textContent.slice(0,t),this.after(e),e}}class c{constructor(){this.properties=Object.create(null)}setProperty(t,e){this.properties[s(t)]=r(e)}removeProperty(t){delete this.properties[s(t)]}}class g{constructor(){this.items=[]}appendItem(t){this.items.push(t)}}class f{constructor(){this.value=''}setTranslate(t,e){this.value=`translate(${t} ${e})`}setScale(t,e){this.value=`scale(${t} ${e})`}setRotate(t,e,i){this.value=0!==e||0!==i?`rotate(${t} ${e} ${i})`:`rotate(${t})`}setSkewX(t){this.value=`skewX(${t})`}setSkewY(t){this.value=`skewY(${t})`}}const p=['area','base','br','col','embed','hr','img','input','keygen','link','meta','param','source','track','wbr'];exports.renderStatic=t=>{let n={document:{createTextNode(t){let e=new u;return e.textContent=String(t).replace(o,i),e.nodeName='#text',e},createElement(t){let e=new u;return e.tagName=s(t),e.isFragment=0,e},createElementNS(t,e){switch(t){case'http://www.w3.org/1999/xhtml':case'http://www.w3.org/2000/svg':break;default:t='http://www.w3.org/1999/xhtml'}let i=new u;return i.tagName=s(e),i.namespaceURI=t,i.isFragment=0,i},createDocumentFragment:()=>new u}},a=n.document.createDocumentFragment();return new Promise(i=>{l.using(a,{fn:t,env:n,onComplete(){i((t=>{let i=[];(function t(i,l){if(null!==i.textContent&&l.push(i.textContent),i.isFragment){let e=i.firstChild;for(;e;)t(e,l),e=e.sibling.right;return}l.push('<',i.tagName);for(let t in i.attributes)l.push(' ',t,'=','"',r(i.attributes[t]),'"');for(let t in i.dataset)l.push(' ','data-',s(t).replace(h,e),'=','"',r(i.dataset[t]),'"');let n=[];for(let t in i.style.properties)if(t.startsWith('--'))n.push(`${t}: ${i.style.properties[t]}`);else{let e=t.replace(/[A-Z]/g,t=>"-"+t.toLowerCase());(t.startsWith('webkit')||t.startsWith('moz'))&&(e="-"+e),n.push(`${e}: ${i.style.properties[t]}`)}if(n.length>0&&l.push(' ','style','=','"',n.join(';'),'"'),i.transform.baseVal.items.length>0){l.push(' ','transform','=','"');let t=i.transform.baseVal.items.map(({value:t})=>t);l.push(t.join(' '),'"')}if(l.push('>'),p.includes(i.tagName))return;let a=i.firstChild;for(;a;)t(a,l),a=a.sibling.right;l.push('</',i.tagName,'>')})(t,i);let l=i.join('');return function t(e){if('html'===e.tagName)return 1;if(e.isFragment&&null===e.textContent){let i=e.firstChild;if(i&&e.child.last===i)return t(i)}return 0}(t)?"<!DOCTYPE html>"+l:l})(a))}})})};
//# sourceMappingURL=server.js.map

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc