From 730c5c1f1976557d82ede97b6f39b6d9baa9343e Mon Sep 17 00:00:00 2001 From: Spaaaacccee Date: Wed, 15 Nov 2023 11:45:50 +0000 Subject: [PATCH] =?UTF-8?q?Deploying=20to=20gh-pages=20from=20@=20path-vis?= =?UTF-8?q?ualiser/app@df28384a1427b66b89596085c369915ada6b312e=20?= =?UTF-8?q?=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/{index-5ff0211a.js => index-0bc64681.js} | 2 +- index.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename assets/{index-5ff0211a.js => index-0bc64681.js} (99%) diff --git a/assets/index-5ff0211a.js b/assets/index-0bc64681.js similarity index 99% rename from assets/index-5ff0211a.js rename to assets/index-0bc64681.js index 48f46b24..7d0d265e 100644 --- a/assets/index-5ff0211a.js +++ b/assets/index-0bc64681.js @@ -531,7 +531,7 @@ https://fb.me/react-async-component-lifecycle-hooks`)}if(typeof e.getDerivedStat `+e.slice(i,o),i=o+1),s=l;return c+=` `,e.length-i>t&&s>i?c+=e.slice(i,s)+` `+e.slice(s+1):c+=e.slice(i),c.slice(1)}function j$e(e){for(var t="",n=0,r,i=0;i=65536?i+=2:i++)n=Lb(e,i),r=io[n],!r&&m1(n)?(t+=e[i],n>=65536&&(t+=e[i+1])):t+=r||O$e(n);return t}function U$e(e,t,n){var r="",i=e.tag,o,s,l;for(o=0,s=n.length;o"u"&&_u(e,t,null,!1,!1))&&(r!==""&&(r+=","+(e.condenseFlow?"":" ")),r+=e.dump);e.tag=i,e.dump="["+r+"]"}function n9(e,t,n,r){var i="",o=e.tag,s,l,c;for(s=0,l=n.length;s"u"&&_u(e,t+1,null,!0,!0,!1,!0))&&((!r||i!=="")&&(i+=r3(e,t)),e.dump&&h1===e.dump.charCodeAt(0)?i+="-":i+="- ",i+=e.dump);e.tag=o,e.dump=i||"[]"}function H$e(e,t,n){var r="",i=e.tag,o=Object.keys(n),s,l,c,d,f;for(s=0,l=o.length;s1024&&(f+="? "),f+=e.dump+(e.condenseFlow?'"':"")+":"+(e.condenseFlow?"":" "),_u(e,t,d,!1,!1)&&(f+=e.dump,r+=f));e.tag=i,e.dump="{"+r+"}"}function W$e(e,t,n,r){var i="",o=e.tag,s=Object.keys(n),l,c,d,f,h,p;if(e.sortKeys===!0)s.sort();else if(typeof e.sortKeys=="function")s.sort(e.sortKeys);else if(e.sortKeys)throw new Zs("sortKeys must be a boolean or a function");for(l=0,c=s.length;l1024,h&&(e.dump&&h1===e.dump.charCodeAt(0)?p+="?":p+="? "),p+=e.dump,h&&(p+=r3(e,t)),_u(e,t+1,f,!0,h)&&(e.dump&&h1===e.dump.charCodeAt(0)?p+=":":p+=": ",p+=e.dump,i+=p));e.tag=o,e.dump=i||"{}"}function r9(e,t,n){var r,i,o,s,l,c;for(i=n?e.explicitTypes:e.implicitTypes,o=0,s=i.length;o tag resolver accepts not "'+c+'" style');e.dump=r}return!0}return!1}function _u(e,t,n,r,i,o,s){e.tag=null,e.dump=n,r9(e,n,!1)||r9(e,n,!0);var l=Oee.call(e.dump),c=r,d;r&&(r=e.flowLevel<0||e.flowLevel>t);var f=l==="[object Object]"||l==="[object Array]",h,p;if(f&&(h=e.duplicates.indexOf(n),p=h!==-1),(e.tag!==null&&e.tag!=="?"||p||e.indent!==2&&t>0)&&(i=!1),p&&e.usedDuplicates[h])e.dump="*ref_"+h;else{if(f&&p&&!e.usedDuplicates[h]&&(e.usedDuplicates[h]=!0),l==="[object Object]")r&&Object.keys(e.dump).length!==0?(W$e(e,t,e.dump,i),p&&(e.dump="&ref_"+h+e.dump)):(H$e(e,t,e.dump),p&&(e.dump="&ref_"+h+" "+e.dump));else if(l==="[object Array]")r&&e.dump.length!==0?(e.noArrayIndent&&!s&&t>0?n9(e,t-1,e.dump,i):n9(e,t,e.dump,i),p&&(e.dump="&ref_"+h+e.dump)):(U$e(e,t,e.dump),p&&(e.dump="&ref_"+h+" "+e.dump));else if(l==="[object String]")e.tag!=="?"&&F$e(e,e.dump,t,o,c);else{if(l==="[object Undefined]")return!1;if(e.skipInvalid)return!1;throw new Zs("unacceptable kind of an object to dump "+l)}e.tag!==null&&e.tag!=="?"&&(d=encodeURI(e.tag[0]==="!"?e.tag.slice(1):e.tag).replace(/!/g,"%21"),e.tag[0]==="!"?d="!"+d:d.slice(0,18)==="tag:yaml.org,2002:"?d="!!"+d.slice(18):d="!<"+d+">",e.dump=d+" "+e.dump)}return!0}function G$e(e,t){var n=[],r=[],i,o;for(o3(e,n,r),i=0,o=r.length;in(async()=>{var r;if(e!=null&&e.trace){t("Processing trace...");try{const i=await Q$e(e);return t("Trace loaded",qNe("step",((r=i==null?void 0:i.stepsPersistent)==null?void 0:r.length)??0,!0)),i}catch(i){console.error(i),t("Error parsing",`${Y$e(i)}`)}}}),[e])}function Nm({label:e,icon:t,...n}){return C.jsx(Gd,{title:te.startCase(e),children:C.jsx("span",{children:C.jsx(dp,{...n,children:t})})},e)}function Z$e(){return R.useCallback(e=>({result:"",error:void 0,offset:0}),[])}function sj(e){const t=hl(),{layer:n,setLayer:r}=vp(e),{playback:i,playbackTo:o,step:s=0}=(n==null?void 0:n.source)??{},l=te.min([o,s])??0,c=!!o,d=i==="playing",[f,h]=[0,(o??1)-1];return R.useMemo(()=>{function p(S){r(ca(n,_=>te.set(_,"source",{..._==null?void 0:_.source,...S})))}const g={start:f,end:h,step:l,canPlay:c&&!d&&l0},v=S=>te.clamp(l+S,f,h);return{playing:i==="playing",...g,...{play:()=>{t("Playback started"),p({playback:"playing",step:v(1)})},pause:(S=0)=>{t("Playback paused"),p({playback:"paused",step:v(S)})},stepTo:(S=0)=>p({step:S}),stop:()=>p({step:f,playback:"paused"}),stepForward:()=>p({step:v(1)}),stepBackward:()=>p({step:v(-1)}),tick:(S=1)=>p({playback:"playing",step:v(S)})}}},[h,i,d,c,f,l,r])}function eFe(e,t){let n=!1;return requestAnimationFrame(async()=>{const r=await e();n||t(r)}),()=>{n=!0}}function tFe({children:e,value:t}){const{step:n,tick:r,end:i,playing:o,pause:s}=sj(t==null?void 0:t.key),l=hl(),[{playbackRate:c=1}]=Ru(),d=Z$e(),f=R.useCallback((h,p)=>C.jsx(W4,{primary:h,secondary:`Step ${n+p}`}),[n]);return R.useEffect(()=>{if(o){let h=te.noop;const p=setInterval(()=>{n{for(const g of te.range(c)){const v=d(n+g);if(v.result||v.error)return{...v,offset:g}}return{result:"",offset:0,error:void 0}},({result:g,offset:v,error:y})=>{y?(l(`${te.trimEnd(y,".")}.`,`${v}`),s()):g?(l(`Breakpoint hit: ${g}.`,`${v}`),s(v)):r(c)}):s()},1e3/60);return()=>{h(),clearInterval(p)}}},[f,o,i,n,s,r,l,d,c]),C.jsx(C.Fragment,{children:e})}function nFe({layer:e}){const{playing:t,canPause:n,canPlay:r,canStepBackward:i,canStepForward:o,canStop:s,pause:l,play:c,stepBackward:d,stepForward:f,stop:h}=sj(e==null?void 0:e.key);return C.jsxs(C.Fragment,{children:[C.jsx(Nm,{label:"step-backward",icon:C.jsx(gxe,{}),onClick:d,disabled:!i}),C.jsx(Nm,{...t?{label:"pause",icon:C.jsx(uxe,{}),onClick:()=>l(),disabled:!n}:{label:"play",icon:C.jsx(fxe,{}),onClick:()=>c(),disabled:!r,color:"primary"}}),C.jsx(Nm,{label:"step-forward",icon:C.jsx(mxe,{}),onClick:f,disabled:!o}),C.jsx(Nm,{label:"stop",icon:C.jsx(vxe,{}),onClick:h,disabled:!s})]})}const rFe=e=>e==null;function iFe(e){const t=[],n={},r={},i=te.chain(e==null?void 0:e.events).map((l,c)=>({step:c,id:l.id,pId:l.pId})).groupBy("id").value();te.forEach(e==null?void 0:e.events,({id:l,pId:c},d)=>{!rFe(c)&&n[l]!==c&&(t.push({id:l,pId:c,step:d,prev:te.last(t)}),n[l]=c),r[d]=te.last(t)});const o=(l,c=(d=>(d=e==null?void 0:e.events)==null?void 0:d.length)()??0)=>{let f=r[c];for(;f;){if(f.id===l)return f.pId;f=f.prev}};return{getParent:o,getPath:l=>{const c=[l];let d={...(e.events??[])[l],step:l};for(;d;){const f=o(d.id,d.step);if(f){const h=te.findLast(i[f],p=>p.step<=d.step);if(h)c.push(h.step),d=h;else break}else break}return c}}}const LS={key:"trace",inferName:e=>{var t,n;return((n=(t=e.source)==null?void 0:t.trace)==null?void 0:n.name)??"Untitled Trace"},editor:Cg(({value:e,produce:t})=>{var n,r,i,o;return C.jsxs(C.Fragment,{children:[C.jsx(r1,{label:"Trace",content:C.jsx(LPe,{onChange:s=>t(l=>te.set(l,"source.trace",{...s,key:Mo()})),value:(n=e==null?void 0:e.source)==null?void 0:n.trace})}),C.jsx(r1,{label:"Onion Skinning",content:C.jsx(Is,{disabled:!0,showArrow:!0,value:((r=e==null?void 0:e.source)==null?void 0:r.onion)??"off",items:["off","transparent","solid"].map(s=>({id:s,name:te.startCase(s)})),onChange:s=>t(l=>te.set(l,"source.onion",s))})}),C.jsx(PZ,{label:"Preview"}),C.jsx(dt,{sx:{height:240,mx:-2,mb:-2},children:C.jsx(Eee,{trace:(o=(i=e==null?void 0:e.source)==null?void 0:i.trace)==null?void 0:o.content})})]})}),service:Cg(({value:e,produce:t})=>{var i,o,s,l,c,d,f,h;const{palette:n}=Rn(),r=J$e({trace:(o=(i=e==null?void 0:e.source)==null?void 0:i.trace)==null?void 0:o.content,context:{color:Hz,themeAccent:n.primary.main,themeTextPrimary:n.text.primary,themeBackground:n.background.paper},view:"main"});return R.useEffect(()=>{t(p=>{var g,v,y,S;return te.set(p,"source.playbackTo",((S=(y=(v=(g=e==null?void 0:e.source)==null?void 0:g.trace)==null?void 0:v.content)==null?void 0:y.events)==null?void 0:S.length)??0)})},[(d=(c=(l=(s=e==null?void 0:e.source)==null?void 0:s.trace)==null?void 0:l.content)==null?void 0:c.events)==null?void 0:d.length]),See(async()=>{const p=await r();t(g=>te.set(g,"source.parsedTrace",p))},[r],[(h=(f=e==null?void 0:e.source)==null?void 0:f.trace)==null?void 0:h.key]),C.jsx(C.Fragment,{children:C.jsx(tFe,{value:e})})}),renderer:({layer:e})=>{var l,c;const t=(l=e==null?void 0:e.source)==null?void 0:l.parsedTrace,n=UK(((c=e==null?void 0:e.source)==null?void 0:c.step)??0,1e3/60),r=oFe(e,n),i=R.useMemo(()=>te.map(t==null?void 0:t.stepsPersistent,d=>te.map(d,f=>te.merge(f,{meta:{sourceLayer:e==null?void 0:e.key}}))),[t==null?void 0:t.stepsPersistent,e==null?void 0:e.key]),o=R.useMemo(()=>te.map(t==null?void 0:t.stepsTransient,d=>te.map(d,f=>te.merge(f,{meta:{sourceLayer:e==null?void 0:e.key}}))),[t==null?void 0:t.stepsTransient,e==null?void 0:e.key]),s=R.useMemo(()=>[o[n]??[]],[o,n]);return C.jsxs(C.Fragment,{children:[C.jsx(INe,{step:n,nodes:i}),C.jsx(d1,{nodes:s}),r]})},steps:({layer:e,children:t})=>{var n,r,i;return C.jsx(C.Fragment,{children:t==null?void 0:t(((i=(r=(n=e==null?void 0:e.source)==null?void 0:n.trace)==null?void 0:r.content)==null?void 0:i.events)??[])})},getSelectionInfo:({layer:e,event:t,children:n})=>{const{layer:r,setLayer:i}=vp(e),o=R.useMemo(()=>{var d,f,h,p,g;const s=((h=(f=(d=r==null?void 0:r.source)==null?void 0:d.trace)==null?void 0:f.content)==null?void 0:h.events)??[],l=te.chain((p=t==null?void 0:t.info)==null?void 0:p.components).filter(v=>{var y;return((y=v.meta)==null?void 0:y.sourceLayer)===(r==null?void 0:r.key)}).map(v=>{var y;return(y=v.meta)==null?void 0:y.step}).filter(te.negate(te.isUndefined)).sort((v,y)=>v-y).value(),c=te.chain((g=t==null?void 0:t.info)==null?void 0:g.components).filter(v=>{var y;return((y=v.meta)==null?void 0:y.sourceLayer)===(r==null?void 0:r.key)}).map(v=>v.meta).value();if(l.length&&r){const v=te.last(l),y=s[v];if(y)return{...te.keyBy(te.map(c,S=>({primary:`Selection in ${_s(r)}`,items:{info:{index:-1,primary:C.jsx(nC,{event:S.info,vertical:!0})}}})),"primary"),[r.key]:{primary:_s(r),items:{properties:{index:-2,primary:C.jsx(nC,{event:y,vertical:!0})},[`${y}`]:{primary:`Go to Step ${v}`,secondary:`${te.startCase(y.type)}`,action:()=>i(ca(r,S=>{te.set(S,"source.step",v)})),icon:C.jsx(qbe,{})}}}}}return{}},[r,t]);return C.jsx(C.Fragment,{children:n==null?void 0:n(o)})}};function oFe(e,t=0){var o,s;const{palette:n}=Rn(),{getPath:r}=R.useMemo(()=>{var l,c;return(c=(l=e==null?void 0:e.source)==null?void 0:l.trace)!=null&&c.content?iFe(e.source.trace.content):{getParent:te.constant(void 0),getPath:te.constant([])}},[(s=(o=e==null?void 0:e.source)==null?void 0:o.trace)==null?void 0:s.content]);return R.useMemo(()=>{var l,c,d,f;if((f=(d=(c=(l=e==null?void 0:e.source)==null?void 0:l.trace)==null?void 0:c.content)==null?void 0:d.render)!=null&&f.path){const{pivot:h={},scale:p=1}=e.source.trace.content.render.path,{x:g,y:v}=h,y=g?e3(g):b=>b.event.x,S=v?e3(v):b=>b.event.y,_=te.map(r(t),b=>{var x,E,A,I;return(I=(A=(E=(x=e==null?void 0:e.source)==null?void 0:x.trace)==null?void 0:E.content)==null?void 0:A.events)==null?void 0:I[b]});if(_.length){const b=[{$:"rect",x:y({event:{x:0,y:0,...te.head(_)}})-2*p/2,y:S({event:{x:0,y:0,...te.head(_)}})-2*p/2,fill:i1("destination"),width:2*p,height:2*p},{$:"rect",x:y({event:{x:0,y:0,...te.last(_)}})-2*p/2,y:S({event:{x:0,y:0,...te.last(_)}})-2*p/2,fill:i1("source"),width:2*p,height:2*p},{$:"path",points:_.map(x=>({x:y({event:{x:0,y:0,...x}}),y:S({event:{x:0,y:0,...x}})})),fill:n.primary.main,alpha:1,lineWidth:1*p}];return C.jsx(d1,{nodes:[te.map(b,x=>({component:x,meta:{source:"path"}}))]})}}return C.jsx(C.Fragment,{})},[e,t,n,r])}async function sFe(e,t,n){for(const r of e){const i=await r.call("features/algorithms"),o=await r.call("features/formats");if(te.find(i,{id:t})&&te.find(o,{id:n}))return r}}const aFe={...LS,key:"query",editor:Cg(({value:e,produce:t})=>{var c,d;const{algorithm:n}=(e==null?void 0:e.source)??{},{layers:r,layer:i,key:o}=vp(void 0,f=>{var h;return((h=f.source)==null?void 0:h.type)==="map"}),[{algorithms:s}]=qE(),[l]=Ig();return C.jsxs(C.Fragment,{children:[C.jsx(r1,{label:"Algorithm",content:C.jsx(Is,{showArrow:!0,icon:C.jsx(exe,{}),label:"Choose Algorithm",value:n,items:s.map(f=>{var h;return{...f,description:(h=te.find(l,{url:f.source}))==null?void 0:h.name}}),onChange:async f=>t(h=>te.set(h,"source.algorithm",f))})}),!(s!=null&&s.length)&&C.jsx(zt,{variant:"body2",color:"warning.main",sx:{mb:1},children:"No connected solver has declared support for running algorithms"}),C.jsx(r1,{label:"Map",content:C.jsx(Is,{showArrow:!0,icon:C.jsx(H1,{}),label:"Choose Layer",value:o,items:r.map(f=>({id:f.key,name:_s(f)})),onChange:async f=>t(h=>te.set(h,"source.mapLayerKey",f))})}),i&&C.jsxs(zt,{variant:"body2",color:"text.secondary",sx:{mb:1,mt:1},children:["Define source and destination nodes by clicking on valid regions on"," ",_s(i)]}),C.jsx(PZ,{label:"Preview"}),C.jsx(dt,{sx:{height:240,mx:-2,mb:-2},children:C.jsx(Eee,{trace:(d=(c=e==null?void 0:e.source)==null?void 0:c.trace)==null?void 0:d.content})})]})}),service:Cg(({value:e,produce:t})=>{const n=hl(),{algorithm:r,mapLayerKey:i,start:o,end:s}=(e==null?void 0:e.source)??{},[{layers:l}]=Ip(),[c]=Ig(),[{algorithms:d}]=qE(),f=R.useMemo(()=>{if(i&&r)return te.find(l,{key:i})},[i,r,l]);return PNe(async h=>{var p;if(f&&r){const{format:g,content:v}=((p=f==null?void 0:f.source)==null?void 0:p.map)??{};if(g&&v){const y=await sFe(c,r,g),S=te.find(d,{id:r});if(y){n(`Executing ${_s(e)} using ${y.name}...`);const _=await y.call("solve/pathfinding",{format:g,instances:[{start:o??0,end:s??0}],mapURI:`map:${encodeURIComponent(v)}`,algorithm:r});h.aborted?n("Canceled."):t(b=>te.set(b,"source.trace",{name:`${S==null?void 0:S.name}`,content:_,key:Mo()}))}}}},[f,c,r,o,s,t,n,e,d],[f,c,r,o,s]),C.jsx(C.Fragment,{children:LS.service})}),inferName:e=>{var t,n;return((n=(t=e.source)==null?void 0:t.trace)==null?void 0:n.name)??"Untitled Query"},getSelectionInfo:({children:e,event:t,layer:n})=>{const r=LS.getSelectionInfo,{layer:i,setLayer:o,layers:s}=vp(n),l=R.useMemo(()=>{const d=te.filter(s,{source:{type:"map"}});return te.filter(te.map(d,f=>{var p,g,v,y;const{parsedMap:h}=(f==null?void 0:f.source)??{};if(h&&t){const S=(y=(v=Uz((g=(p=f==null?void 0:f.source)==null?void 0:p.map)==null?void 0:g.format))==null?void 0:v.hydrate)==null?void 0:y.call(v,h);if(S){const _=(t==null?void 0:t.world)&&S.snap(t.world);if(_){const b=(t==null?void 0:t.world)&&S.nodeAt(_);return{point:_,node:b,key:f.key,name:_s(f)}}}}}))},[s]),c=R.useMemo(()=>!!i&&!!l.length&&{[i.key]:{primary:_s(i),items:{...te.reduce(l,(d,f)=>({...d,[`${n}-${f==null?void 0:f.key}-source`]:{primary:"Set as source",secondary:f==null?void 0:f.name,action:()=>o(ca(i,h=>{te.set(h,"source.start",f==null?void 0:f.node),te.set(h,"source.query",void 0),te.set(h,"source.mapLayerKey",f==null?void 0:f.key),te.set(h,"source.trace",void 0)})),icon:C.jsx(yxe,{sx:{transform:"scale(0.5)"}})},[`${n}-${f==null?void 0:f.key}-destination`]:{primary:"Set as destination",secondary:f==null?void 0:f.name,action:()=>o(ca(i,h=>{te.set(h,"source.end",f==null?void 0:f.node),te.set(h,"source.query",void 0),te.set(h,"source.mapLayerKey",f==null?void 0:f.key),te.set(h,"source.trace",void 0)})),icon:C.jsx(dxe,{})}}),{})}}},[l,i,s,o]);return C.jsx(r,{event:t,layer:n,children:d=>e==null?void 0:e(te.merge(d,c))})}};function lFe({layer:e}){var t,n;return C.jsx(C.Fragment,{children:e&&R.createElement((n=cw[((t=e==null?void 0:e.source)==null?void 0:t.type)??""])==null?void 0:n.renderer,{layer:e})})}function _s(e){var t,n;return e!=null&&e.name?e==null?void 0:e.name:(t=e==null?void 0:e.source)!=null&&t.type?cw[(n=e.source)==null?void 0:n.type].inferName(e):"Untitled Layer"}function Hee(e){var t;return cw[((t=e==null?void 0:e.source)==null?void 0:t.type)??""]}const cw={map:LNe,trace:LS,query:aFe};function cFe(e,t,n=600){const[r,i]=R.useState(e);R.useEffect(()=>void i(e),[i,e]);const o=R.useMemo(()=>te.debounce(s=>t==null?void 0:t(s),n),[t,n]);return[r,s=>{i(s),o(s)}]}function uFe({value:e,onValueChange:t},n){var f,h,p;const[r,i]=cFe(e,t),o=g=>C.jsx(zt,{variant:"overline",color:"text.secondary",sx:{pt:1},component:"p",children:g}),s=g=>C.jsx(zt,{variant:"body1",children:g}),l=(g,v)=>C.jsxs(bn,{alignItems:"center",children:[s(g),C.jsx(Kr,{flex:1}),v]}),c=g=>g.map(v=>({id:v,name:te.startCase(v)})),d=r.name||_s(e);return C.jsx(C.Fragment,{children:C.jsxs(Rd,{alignItems:"center",direction:"row",gap:2,children:[C.jsxs(dt,{py:1,ml:-1,children:[C.jsx(zt,{children:d}),C.jsx(zt,{variant:"body2",color:"text.secondary",children:te.startCase((f=r.source)==null?void 0:f.type)})]}),C.jsx(Kr,{flex:1}),C.jsx(Rd,{alignItems:"center",direction:"row",children:C.jsx(Dz,{appBar:{children:C.jsx(Mz,{children:"Edit Layer"})},trigger:g=>C.jsx(dp,{size:"small",onClick:g,children:C.jsx(ek,{})}),children:C.jsxs(dt,{p:2,children:[C.jsx(dt,{pb:2,children:C.jsx(U1,{fullWidth:!0,variant:"filled",label:"Layer Name",value:r.name??"",onChange:g=>i==null?void 0:i(ca(r,v=>te.set(v,"name",g.target.value)))})}),o("Layer Options"),l("Transparency",C.jsx(Is,{label:"Transparency",items:["25","50","75","100"].map(g=>({id:g,name:`${g}%`})),value:"100",showArrow:!0})),l("Display Mode",C.jsx(Is,{label:"Display Mode",value:"normal",items:c(["normal","difference"]),showArrow:!0})),o("Source Options"),l("Type",C.jsx(Is,{label:"Type",value:(h=r.source)==null?void 0:h.type,items:["map","trace","query"].map(g=>({id:g,name:te.startCase(g)})),onChange:g=>i==null?void 0:i(ca(r,v=>{te.set(v,"source",{type:g})})),showArrow:!0})),((p=r.source)==null?void 0:p.type)&&R.createElement(cw[r.source.type].editor,{onChange:g=>i(g(r)),value:r})]})})})]})})}const dFe=R.forwardRef(uFe);function fFe(){const[{layers:e=[]},t]=Ip();return C.jsx(dt,{sx:{overflow:"auto hidden",width:"100%"},children:C.jsx(dt,{sx:{mb:2},children:C.jsx(wk,{sortable:!0,icon:null,value:e,useDelete:!0,useReorder:!0,editor:n=>C.jsx(dFe,{value:n}),create:()=>({source:{type:"trace",trace:{}}}),onChange:n=>t(()=>({layers:n})),addItemLabel:"Layer",placeholderText:C.jsx(dt,{pt:2,children:"Click the button below to add a layer."})})})})}function hFe(){const{controls:e,onChange:t,state:n}=qd();return C.jsxs(Ln,{onChange:t,stack:n,children:[C.jsx(Ln.Content,{children:C.jsx(dt,{p:2,pr:1,pt:6,children:C.jsx(fFe,{})})}),C.jsx(Ln.Extras,{children:e})]})}function Wee(e){return C.jsx(rxe,{...e,sx:{fontSize:12,transform:"translateY(1.75px) translateX(-2px)",...e.sx}})}function pFe({children:e}){return C.jsx(zt,{variant:"overline",sx:{my:-.75,display:"block"},children:e})}var oC={exports:{}};/** +`:""}var q$e=V$e,X$e={dump:q$e},Y$e=X$e.dump;class K$e extends Worker{constructor(){super(XNe,{type:"module"})}}const Q$e=nv(K$e);function J$e(e){const t=hl(),n=Rp("specimen");return R.useCallback(()=>n(async()=>{var r;if(e!=null&&e.trace){t("Processing trace...");try{const i=await Q$e(e);return t("Trace loaded",qNe("step",((r=i==null?void 0:i.stepsPersistent)==null?void 0:r.length)??0,!0)),i}catch(i){console.error(i),t("Error parsing",`${Y$e(i)}`)}}}),[e])}function Nm({label:e,icon:t,...n}){return C.jsx(Gd,{title:te.startCase(e),children:C.jsx("span",{children:C.jsx(dp,{...n,children:t})})},e)}function Z$e(){return R.useCallback(e=>({result:"",error:void 0,offset:0}),[])}function sj(e){const t=hl(),{layer:n,setLayer:r}=vp(e),{playback:i,playbackTo:o,step:s=0}=(n==null?void 0:n.source)??{},l=te.min([o,s])??0,c=!!o,d=i==="playing",[f,h]=[0,(o??1)-1];return R.useMemo(()=>{function p(S){r(ca(n,_=>te.set(_,"source",{..._==null?void 0:_.source,...S})))}const g={start:f,end:h,step:l,canPlay:c&&!d&&l0},v=S=>te.clamp(l+S,f,h);return{playing:i==="playing",...g,...{play:()=>{t("Playback started"),p({playback:"playing",step:v(1)})},pause:(S=0)=>{t("Playback paused"),p({playback:"paused",step:v(S)})},stepTo:(S=0)=>p({step:S}),stop:()=>p({step:f,playback:"paused"}),stepForward:()=>p({step:v(1)}),stepBackward:()=>p({step:v(-1)}),tick:(S=1)=>p({playback:"playing",step:v(S)})}}},[h,i,d,c,f,l,r])}function eFe(e,t){let n=!1;return requestAnimationFrame(async()=>{const r=await e();n||t(r)}),()=>{n=!0}}function tFe({children:e,value:t}){const{step:n,tick:r,end:i,playing:o,pause:s}=sj(t==null?void 0:t.key),l=hl(),[{playbackRate:c=1}]=Ru(),d=Z$e(),f=R.useCallback((h,p)=>C.jsx(W4,{primary:h,secondary:`Step ${n+p}`}),[n]);return R.useEffect(()=>{if(o){let h=te.noop;const p=setInterval(()=>{n{for(const g of te.range(c)){const v=d(n+g);if(v.result||v.error)return{...v,offset:g}}return{result:"",offset:0,error:void 0}},({result:g,offset:v,error:y})=>{y?(l(`${te.trimEnd(y,".")}.`,`${v}`),s()):g?(l(`Breakpoint hit: ${g}.`,`${v}`),s(v)):r(c)}):s()},1e3/60);return()=>{h(),clearInterval(p)}}},[f,o,i,n,s,r,l,d,c]),C.jsx(C.Fragment,{children:e})}function nFe({layer:e}){const{playing:t,canPause:n,canPlay:r,canStepBackward:i,canStepForward:o,canStop:s,pause:l,play:c,stepBackward:d,stepForward:f,stop:h}=sj(e==null?void 0:e.key);return C.jsxs(C.Fragment,{children:[C.jsx(Nm,{label:"step-backward",icon:C.jsx(gxe,{}),onClick:d,disabled:!i}),C.jsx(Nm,{...t?{label:"pause",icon:C.jsx(uxe,{}),onClick:()=>l(),disabled:!n}:{label:"play",icon:C.jsx(fxe,{}),onClick:()=>c(),disabled:!r,color:"primary"}}),C.jsx(Nm,{label:"step-forward",icon:C.jsx(mxe,{}),onClick:f,disabled:!o}),C.jsx(Nm,{label:"stop",icon:C.jsx(vxe,{}),onClick:h,disabled:!s})]})}const rFe=e=>e==null;function iFe(e){const t=[],n={},r={},i=te.chain(e==null?void 0:e.events).map((l,c)=>({step:c,id:l.id,pId:l.pId})).groupBy("id").value();te.forEach(e==null?void 0:e.events,({id:l,pId:c},d)=>{!rFe(c)&&n[l]!==c&&(t.push({id:l,pId:c,step:d,prev:te.last(t)}),n[l]=c),r[d]=te.last(t)});const o=(l,c=(d=>(d=e==null?void 0:e.events)==null?void 0:d.length)()??0)=>{let f=r[c];for(;f;){if(f.id===l)return f.pId;f=f.prev}};return{getParent:o,getPath:l=>{const c=[l];let d={...(e.events??[])[l],step:l};for(;d;){const f=o(d.id,d.step);if(f){const h=te.findLast(i[f],p=>p.step<=d.step);if(h)c.push(h.step),d=h;else break}else break}return c}}}const LS={key:"trace",inferName:e=>{var t,n;return((n=(t=e.source)==null?void 0:t.trace)==null?void 0:n.name)??"Untitled Trace"},editor:Cg(({value:e,produce:t})=>{var n,r,i,o;return C.jsxs(C.Fragment,{children:[C.jsx(r1,{label:"Trace",content:C.jsx(LPe,{onChange:s=>t(l=>te.set(l,"source.trace",{...s,key:Mo()})),value:(n=e==null?void 0:e.source)==null?void 0:n.trace})}),C.jsx(r1,{label:"Onion Skinning",content:C.jsx(Is,{disabled:!0,showArrow:!0,value:((r=e==null?void 0:e.source)==null?void 0:r.onion)??"off",items:["off","transparent","solid"].map(s=>({id:s,name:te.startCase(s)})),onChange:s=>t(l=>te.set(l,"source.onion",s))})}),C.jsx(PZ,{label:"Preview"}),C.jsx(dt,{sx:{height:240,mx:-2,mb:-2},children:C.jsx(Eee,{trace:(o=(i=e==null?void 0:e.source)==null?void 0:i.trace)==null?void 0:o.content})})]})}),service:Cg(({value:e,produce:t})=>{var i,o,s,l,c,d,f,h;const{palette:n}=Rn(),r=J$e({trace:(o=(i=e==null?void 0:e.source)==null?void 0:i.trace)==null?void 0:o.content,context:{color:Hz,themeAccent:n.primary.main,themeTextPrimary:n.text.primary,themeBackground:n.background.paper},view:"main"});return R.useEffect(()=>{t(p=>{var g,v,y,S;return te.set(p,"source.playbackTo",((S=(y=(v=(g=e==null?void 0:e.source)==null?void 0:g.trace)==null?void 0:v.content)==null?void 0:y.events)==null?void 0:S.length)??0)})},[(d=(c=(l=(s=e==null?void 0:e.source)==null?void 0:s.trace)==null?void 0:l.content)==null?void 0:c.events)==null?void 0:d.length]),See(async()=>{const p=await r();t(g=>te.set(g,"source.parsedTrace",p))},[r],[(h=(f=e==null?void 0:e.source)==null?void 0:f.trace)==null?void 0:h.key]),C.jsx(C.Fragment,{children:C.jsx(tFe,{value:e})})}),renderer:({layer:e})=>{var l,c;const t=(l=e==null?void 0:e.source)==null?void 0:l.parsedTrace,n=UK(((c=e==null?void 0:e.source)==null?void 0:c.step)??0,1e3/60),r=oFe(e,n),i=R.useMemo(()=>te.map(t==null?void 0:t.stepsPersistent,d=>te.map(d,f=>te.merge(f,{meta:{sourceLayer:e==null?void 0:e.key}}))),[t==null?void 0:t.stepsPersistent,e==null?void 0:e.key]),o=R.useMemo(()=>te.map(t==null?void 0:t.stepsTransient,d=>te.map(d,f=>te.merge(f,{meta:{sourceLayer:e==null?void 0:e.key}}))),[t==null?void 0:t.stepsTransient,e==null?void 0:e.key]),s=R.useMemo(()=>[o[n]??[]],[o,n]);return C.jsxs(C.Fragment,{children:[C.jsx(INe,{step:n,nodes:i}),C.jsx(d1,{nodes:s}),r]})},steps:({layer:e,children:t})=>{var n,r,i;return C.jsx(C.Fragment,{children:t==null?void 0:t(((i=(r=(n=e==null?void 0:e.source)==null?void 0:n.trace)==null?void 0:r.content)==null?void 0:i.events)??[])})},getSelectionInfo:({layer:e,event:t,children:n})=>{const{layer:r,setLayer:i}=vp(e),o=R.useMemo(()=>{var d,f,h,p,g;const s=((h=(f=(d=r==null?void 0:r.source)==null?void 0:d.trace)==null?void 0:f.content)==null?void 0:h.events)??[],l=te.chain((p=t==null?void 0:t.info)==null?void 0:p.components).filter(v=>{var y;return((y=v.meta)==null?void 0:y.sourceLayer)===(r==null?void 0:r.key)}).map(v=>{var y;return(y=v.meta)==null?void 0:y.step}).filter(te.negate(te.isUndefined)).sort((v,y)=>v-y).value(),c=te.chain((g=t==null?void 0:t.info)==null?void 0:g.components).filter(v=>{var y;return((y=v.meta)==null?void 0:y.sourceLayer)===(r==null?void 0:r.key)}).filter(v=>v.meta.info).value();if(l.length&&r){const v=te.last(l),y=s[v];if(y)return{...te.keyBy(te.map(c,(S,_)=>({key:`${r.key}.${_}`,primary:`Selection in ${_s(r)}`,items:{info:{index:-1,primary:C.jsx(nC,{event:S.meta.info,vertical:!0})}}})),"key"),[r.key]:{primary:_s(r),items:{properties:{index:-2,primary:C.jsx(nC,{event:y,vertical:!0})},[`${y}`]:{primary:`Go to Step ${v}`,secondary:`${te.startCase(y.type)}`,action:()=>i(ca(r,S=>{te.set(S,"source.step",v)})),icon:C.jsx(qbe,{})}}}}}return{}},[r,t]);return C.jsx(C.Fragment,{children:n==null?void 0:n(o)})}};function oFe(e,t=0){var o,s;const{palette:n}=Rn(),{getPath:r}=R.useMemo(()=>{var l,c;return(c=(l=e==null?void 0:e.source)==null?void 0:l.trace)!=null&&c.content?iFe(e.source.trace.content):{getParent:te.constant(void 0),getPath:te.constant([])}},[(s=(o=e==null?void 0:e.source)==null?void 0:o.trace)==null?void 0:s.content]);return R.useMemo(()=>{var l,c,d,f;if((f=(d=(c=(l=e==null?void 0:e.source)==null?void 0:l.trace)==null?void 0:c.content)==null?void 0:d.render)!=null&&f.path){const{pivot:h={},scale:p=1}=e.source.trace.content.render.path,{x:g,y:v}=h,y=g?e3(g):b=>b.event.x,S=v?e3(v):b=>b.event.y,_=te.map(r(t),b=>{var x,E,A,I;return(I=(A=(E=(x=e==null?void 0:e.source)==null?void 0:x.trace)==null?void 0:E.content)==null?void 0:A.events)==null?void 0:I[b]});if(_.length){const b=[{$:"rect",x:y({event:{x:0,y:0,...te.head(_)}})-2*p/2,y:S({event:{x:0,y:0,...te.head(_)}})-2*p/2,fill:i1("destination"),width:2*p,height:2*p},{$:"rect",x:y({event:{x:0,y:0,...te.last(_)}})-2*p/2,y:S({event:{x:0,y:0,...te.last(_)}})-2*p/2,fill:i1("source"),width:2*p,height:2*p},{$:"path",points:_.map(x=>({x:y({event:{x:0,y:0,...x}}),y:S({event:{x:0,y:0,...x}})})),fill:n.primary.main,alpha:1,lineWidth:1*p}];return C.jsx(d1,{nodes:[te.map(b,x=>({component:x,meta:{source:"path"}}))]})}}return C.jsx(C.Fragment,{})},[e,t,n,r])}async function sFe(e,t,n){for(const r of e){const i=await r.call("features/algorithms"),o=await r.call("features/formats");if(te.find(i,{id:t})&&te.find(o,{id:n}))return r}}const aFe={...LS,key:"query",editor:Cg(({value:e,produce:t})=>{var c,d;const{algorithm:n}=(e==null?void 0:e.source)??{},{layers:r,layer:i,key:o}=vp(void 0,f=>{var h;return((h=f.source)==null?void 0:h.type)==="map"}),[{algorithms:s}]=qE(),[l]=Ig();return C.jsxs(C.Fragment,{children:[C.jsx(r1,{label:"Algorithm",content:C.jsx(Is,{showArrow:!0,icon:C.jsx(exe,{}),label:"Choose Algorithm",value:n,items:s.map(f=>{var h;return{...f,description:(h=te.find(l,{url:f.source}))==null?void 0:h.name}}),onChange:async f=>t(h=>te.set(h,"source.algorithm",f))})}),!(s!=null&&s.length)&&C.jsx(zt,{variant:"body2",color:"warning.main",sx:{mb:1},children:"No connected solver has declared support for running algorithms"}),C.jsx(r1,{label:"Map",content:C.jsx(Is,{showArrow:!0,icon:C.jsx(H1,{}),label:"Choose Layer",value:o,items:r.map(f=>({id:f.key,name:_s(f)})),onChange:async f=>t(h=>te.set(h,"source.mapLayerKey",f))})}),i&&C.jsxs(zt,{variant:"body2",color:"text.secondary",sx:{mb:1,mt:1},children:["Define source and destination nodes by clicking on valid regions on"," ",_s(i)]}),C.jsx(PZ,{label:"Preview"}),C.jsx(dt,{sx:{height:240,mx:-2,mb:-2},children:C.jsx(Eee,{trace:(d=(c=e==null?void 0:e.source)==null?void 0:c.trace)==null?void 0:d.content})})]})}),service:Cg(({value:e,produce:t})=>{const n=hl(),{algorithm:r,mapLayerKey:i,start:o,end:s}=(e==null?void 0:e.source)??{},[{layers:l}]=Ip(),[c]=Ig(),[{algorithms:d}]=qE(),f=R.useMemo(()=>{if(i&&r)return te.find(l,{key:i})},[i,r,l]);return PNe(async h=>{var p;if(f&&r){const{format:g,content:v}=((p=f==null?void 0:f.source)==null?void 0:p.map)??{};if(g&&v){const y=await sFe(c,r,g),S=te.find(d,{id:r});if(y){n(`Executing ${_s(e)} using ${y.name}...`);const _=await y.call("solve/pathfinding",{format:g,instances:[{start:o??0,end:s??0}],mapURI:`map:${encodeURIComponent(v)}`,algorithm:r});h.aborted?n("Canceled."):t(b=>te.set(b,"source.trace",{name:`${S==null?void 0:S.name}`,content:_,key:Mo()}))}}}},[f,c,r,o,s,t,n,e,d],[f,c,r,o,s]),C.jsx(C.Fragment,{children:LS.service})}),inferName:e=>{var t,n;return((n=(t=e.source)==null?void 0:t.trace)==null?void 0:n.name)??"Untitled Query"},getSelectionInfo:({children:e,event:t,layer:n})=>{const r=LS.getSelectionInfo,{layer:i,setLayer:o,layers:s}=vp(n),l=R.useMemo(()=>{const d=te.filter(s,{source:{type:"map"}});return te.filter(te.map(d,f=>{var p,g,v,y;const{parsedMap:h}=(f==null?void 0:f.source)??{};if(h&&t){const S=(y=(v=Uz((g=(p=f==null?void 0:f.source)==null?void 0:p.map)==null?void 0:g.format))==null?void 0:v.hydrate)==null?void 0:y.call(v,h);if(S){const _=(t==null?void 0:t.world)&&S.snap(t.world);if(_){const b=(t==null?void 0:t.world)&&S.nodeAt(_);return{point:_,node:b,key:f.key,name:_s(f)}}}}}))},[s]),c=R.useMemo(()=>!!i&&!!l.length&&{[i.key]:{primary:_s(i),items:{...te.reduce(l,(d,f)=>({...d,[`${n}-${f==null?void 0:f.key}-source`]:{primary:"Set as source",secondary:f==null?void 0:f.name,action:()=>o(ca(i,h=>{te.set(h,"source.start",f==null?void 0:f.node),te.set(h,"source.query",void 0),te.set(h,"source.mapLayerKey",f==null?void 0:f.key),te.set(h,"source.trace",void 0)})),icon:C.jsx(yxe,{sx:{transform:"scale(0.5)"}})},[`${n}-${f==null?void 0:f.key}-destination`]:{primary:"Set as destination",secondary:f==null?void 0:f.name,action:()=>o(ca(i,h=>{te.set(h,"source.end",f==null?void 0:f.node),te.set(h,"source.query",void 0),te.set(h,"source.mapLayerKey",f==null?void 0:f.key),te.set(h,"source.trace",void 0)})),icon:C.jsx(dxe,{})}}),{})}}},[l,i,s,o]);return C.jsx(r,{event:t,layer:n,children:d=>e==null?void 0:e(te.merge(d,c))})}};function lFe({layer:e}){var t,n;return C.jsx(C.Fragment,{children:e&&R.createElement((n=cw[((t=e==null?void 0:e.source)==null?void 0:t.type)??""])==null?void 0:n.renderer,{layer:e})})}function _s(e){var t,n;return e!=null&&e.name?e==null?void 0:e.name:(t=e==null?void 0:e.source)!=null&&t.type?cw[(n=e.source)==null?void 0:n.type].inferName(e):"Untitled Layer"}function Hee(e){var t;return cw[((t=e==null?void 0:e.source)==null?void 0:t.type)??""]}const cw={map:LNe,trace:LS,query:aFe};function cFe(e,t,n=600){const[r,i]=R.useState(e);R.useEffect(()=>void i(e),[i,e]);const o=R.useMemo(()=>te.debounce(s=>t==null?void 0:t(s),n),[t,n]);return[r,s=>{i(s),o(s)}]}function uFe({value:e,onValueChange:t},n){var f,h,p;const[r,i]=cFe(e,t),o=g=>C.jsx(zt,{variant:"overline",color:"text.secondary",sx:{pt:1},component:"p",children:g}),s=g=>C.jsx(zt,{variant:"body1",children:g}),l=(g,v)=>C.jsxs(bn,{alignItems:"center",children:[s(g),C.jsx(Kr,{flex:1}),v]}),c=g=>g.map(v=>({id:v,name:te.startCase(v)})),d=r.name||_s(e);return C.jsx(C.Fragment,{children:C.jsxs(Rd,{alignItems:"center",direction:"row",gap:2,children:[C.jsxs(dt,{py:1,ml:-1,children:[C.jsx(zt,{children:d}),C.jsx(zt,{variant:"body2",color:"text.secondary",children:te.startCase((f=r.source)==null?void 0:f.type)})]}),C.jsx(Kr,{flex:1}),C.jsx(Rd,{alignItems:"center",direction:"row",children:C.jsx(Dz,{appBar:{children:C.jsx(Mz,{children:"Edit Layer"})},trigger:g=>C.jsx(dp,{size:"small",onClick:g,children:C.jsx(ek,{})}),children:C.jsxs(dt,{p:2,children:[C.jsx(dt,{pb:2,children:C.jsx(U1,{fullWidth:!0,variant:"filled",label:"Layer Name",value:r.name??"",onChange:g=>i==null?void 0:i(ca(r,v=>te.set(v,"name",g.target.value)))})}),o("Layer Options"),l("Transparency",C.jsx(Is,{label:"Transparency",items:["25","50","75","100"].map(g=>({id:g,name:`${g}%`})),value:"100",showArrow:!0})),l("Display Mode",C.jsx(Is,{label:"Display Mode",value:"normal",items:c(["normal","difference"]),showArrow:!0})),o("Source Options"),l("Type",C.jsx(Is,{label:"Type",value:(h=r.source)==null?void 0:h.type,items:["map","trace","query"].map(g=>({id:g,name:te.startCase(g)})),onChange:g=>i==null?void 0:i(ca(r,v=>{te.set(v,"source",{type:g})})),showArrow:!0})),((p=r.source)==null?void 0:p.type)&&R.createElement(cw[r.source.type].editor,{onChange:g=>i(g(r)),value:r})]})})})]})})}const dFe=R.forwardRef(uFe);function fFe(){const[{layers:e=[]},t]=Ip();return C.jsx(dt,{sx:{overflow:"auto hidden",width:"100%"},children:C.jsx(dt,{sx:{mb:2},children:C.jsx(wk,{sortable:!0,icon:null,value:e,useDelete:!0,useReorder:!0,editor:n=>C.jsx(dFe,{value:n}),create:()=>({source:{type:"trace",trace:{}}}),onChange:n=>t(()=>({layers:n})),addItemLabel:"Layer",placeholderText:C.jsx(dt,{pt:2,children:"Click the button below to add a layer."})})})})}function hFe(){const{controls:e,onChange:t,state:n}=qd();return C.jsxs(Ln,{onChange:t,stack:n,children:[C.jsx(Ln.Content,{children:C.jsx(dt,{p:2,pr:1,pt:6,children:C.jsx(fFe,{})})}),C.jsx(Ln.Extras,{children:e})]})}function Wee(e){return C.jsx(rxe,{...e,sx:{fontSize:12,transform:"translateY(1.75px) translateX(-2px)",...e.sx}})}function pFe({children:e}){return C.jsx(zt,{variant:"overline",sx:{my:-.75,display:"block"},children:e})}var oC={exports:{}};/** * @license * Lodash * Copyright OpenJS Foundation and other contributors diff --git a/index.html b/index.html index ca2dd000..82b71a6b 100644 --- a/index.html +++ b/index.html @@ -10,7 +10,7 @@ - +