From 2319312d0eb1fe7eda312acb29ac6e9ab895ce38 Mon Sep 17 00:00:00 2001 From: dabreegster Date: Thu, 24 Oct 2024 10:00:12 +0000 Subject: [PATCH] deploy: 1cad827207b93077b7d4fc177f3b2f32edaafb16 --- ...{nested-53eb274c.js => nested-6246bc8b.js} | 56 +++++++++---------- move_draw_controls/scheme.html | 2 +- 2 files changed, 29 insertions(+), 29 deletions(-) rename move_draw_controls/assets/{nested-53eb274c.js => nested-6246bc8b.js} (63%) diff --git a/move_draw_controls/assets/nested-53eb274c.js b/move_draw_controls/assets/nested-6246bc8b.js similarity index 63% rename from move_draw_controls/assets/nested-53eb274c.js rename to move_draw_controls/assets/nested-6246bc8b.js index d014b44e..8679a50f 100644 --- a/move_draw_controls/assets/nested-53eb274c.js +++ b/move_draw_controls/assets/nested-6246bc8b.js @@ -1,5 +1,5 @@ -var xs=Object.defineProperty;var el=(r,e,n)=>e in r?xs(r,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):r[e]=n;var de=(r,e,n)=>(el(r,typeof e!="symbol"?e+"":e,n),n);import{S as re,i as ie,s as te,Q as Kt,e as q,b as J,c as y,T as Ht,U as Zt,V as Vt,t as _,q as $,d as w,W as Ct,j as P,p as L,v as F,X as At,E as Ye,f as _e,a as R,Y as Le,Z as he,y as D,o as G,P as be,_ as er,$ as Uo,a0 as we,a1 as xr,a2 as Se,a3 as ei,a4 as ce,z as se,r as le,a5 as Do,a6 as tl,w as K,a7 as Xe,a8 as nl,a9 as je,aa as rl,ab as il,n as Q,J as hn,ac as ol,ad as sl,ae as ll,af as al,ag as Ie,ah as Br,ai as qr,aj as ul,ak as zo,al as fl,am as Jo,an as cl,ao as pl,ap as at,aq as ml,ar as dl,G as Mt,as as gl,at as Ee,au as pe,g as V,h as x,u as ne,m as ge,av as on,aw as sn,ax as kt,N as Dt,ay as jn,az as We,aA as ln,aB as Gr,aC as zt,aD as ct,x as rt,R as Pt,aE as ti,D as _t,aF as Lt,aG as pn,aH as tr,aI as it,aJ as In,aK as hl,aL as _n,aM as nr,aN as ni,aO as De,aP as gr,aQ as _l,aR as bl,aS as Te,aT as Bn,aU as ri,aV as pt,aW as Yo,aX as vl,aY as ii,aZ as ot,a_ as Nt,O as Qe,a$ as Et,b0 as hr,b1 as $l,b2 as yl,I as wl,F as Xo,b3 as Tr,b4 as oi,b5 as kl,M as Sl,A as El,L as Ml,k as Pl,B as Ll,C as Fl,b6 as Cl}from"./index-8de582eb.js";import{M as _r,m as xe,b as Wo,l as ue,R as Al,e as Jt,i as St,a as mn,c as dn,C as Yt,d as Nl,f as xt,S as Rl,H as Rt,g as Ol,h as Ko,j as Ft,k as rr,p as qn,n as jl,o as Il,t as Bl,r as si,W as Ho,q as ql,s as Gl,B as Tl,Z as Ul,G as Dl}from"./WarningIcon-4ae5d124.js";import{A as zl}from"./About-05c49103.js";function Jl(r){let e,n;const t=r[1].default,i=Kt(t,r,r[0],null);return{c(){e=q("div"),i&&i.c(),J(e,"class","govuk-button-group")},m(o,s){y(o,e,s),i&&i.m(e,null),n=!0},p(o,[s]){i&&i.p&&(!n||s&1)&&Ht(i,t,o,o[0],n?Vt(t,o[0],s,null):Zt(o[0]),null)},i(o){n||(_(i,o),n=!0)},o(o){$(i,o),n=!1},d(o){o&&w(e),i&&i.d(o)}}}function Yl(r,e,n){let{$$slots:t={},$$scope:i}=e;return r.$$set=o=>{"$$scope"in o&&n(0,i=o.$$scope)},[i,t]}class Ke extends re{constructor(e){super(),ie(this,e,Yl,Jl,te,{})}}function li(r){let e,n,t=Gn(r[0])+"",i;return{c(){e=q("div"),n=D("£"),i=D(t),J(e,"class","govuk-hint")},m(o,s){y(o,e,s),G(e,n),G(e,i)},p(o,s){s&1&&t!==(t=Gn(o[0])+"")&&be(i,t)},d(o){o&&w(e)}}}function Xl(r){let e;return{c(){e=D("multiply by 1 million")},m(n,t){y(n,e,t)},d(n){n&&w(e)}}}function Wl(r){let e,n,t,i,o,s,a,l,u;e=new Ye({props:{errorMessage:ai(r[2])}});let f=r[0]!=null&&li(r);return s=new _e({props:{disabled:r[0]==null||r[0]>1e3,$$slots:{default:[Xl]},$$scope:{ctx:r}}}),s.$on("click",r[4]),{c(){P(e.$$.fragment),n=R(),f&&f.c(),t=R(),i=q("input"),o=R(),P(s.$$.fragment),J(i,"type","text"),J(i,"inputmode","numeric"),J(i,"class","govuk-input govuk-input--width-10"),J(i,"id",r[3])},m(c,p){L(e,c,p),y(c,n,p),f&&f.m(c,p),y(c,t,p),y(c,i,p),Le(i,r[2]),y(c,o,p),L(s,c,p),a=!0,l||(u=he(i,"input",r[5]),l=!0)},p(c,p){const m={};p&4&&(m.errorMessage=ai(c[2])),e.$set(m),c[0]!=null?f?f.p(c,p):(f=li(c),f.c(),f.m(t.parentNode,t)):f&&(f.d(1),f=null),p&4&&i.value!==c[2]&&Le(i,c[2]);const g={};p&1&&(g.disabled=c[0]==null||c[0]>1e3),p&128&&(g.$$scope={dirty:p,ctx:c}),s.$set(g)},i(c){a||(_(e.$$.fragment,c),_(s.$$.fragment,c),a=!0)},o(c){$(e.$$.fragment,c),$(s.$$.fragment,c),a=!1},d(c){c&&(w(n),w(t),w(i),w(o)),F(e,c),f&&f.d(c),F(s,c),l=!1,u()}}}function Kl(r){let e,n;return e=new Ct({props:{label:r[1],id:r[3],$$slots:{default:[Wl]},$$scope:{ctx:r}}}),{c(){P(e.$$.fragment)},m(t,i){L(e,t,i),n=!0},p(t,[i]){const o={};i&2&&(o.label=t[1]),i&133&&(o.$$scope={dirty:i,ctx:t}),e.$set(o)},i(t){n||(_(e.$$.fragment,t),n=!0)},o(t){$(e.$$.fragment,t),n=!1},d(t){F(e,t)}}}function Zo(r){if(r!="")return parseFloat(r.replaceAll(",",""))}function ai(r){let e=Zo(r);return e==null?"":isNaN(e)?"Please enter a valid number":e<0?"Please enter a positive number":""}function Gn(r){return r.toLocaleString()}function Hl(r,e,n){let{label:t}=e,{value:i}=e,o=At(),s=i==null?"":Gn(i);function a(f){n(0,i=Zo(f))}function l(){n(2,s=Gn(i*1e6))}function u(){s=this.value,n(2,s)}return r.$$set=f=>{"label"in f&&n(1,t=f.label),"value"in f&&n(0,i=f.value)},r.$$.update=()=>{r.$$.dirty&4&&a(s)},[i,t,s,o,l,u]}class Zl extends re{constructor(e){super(),ie(this,e,Hl,Kl,te,{label:1,value:0})}}function Vl(r){let e,n,t,i,o,s,a;return e=new Ye({props:{errorMessage:r[5](r[2])}}),{c(){P(e.$$.fragment),n=R(),t=q("input"),J(t,"type","text"),J(t,"inputmode","numeric"),J(t,"class",i=`govuk-input govuk-input--width-${r[1]}`),J(t,"id",r[3])},m(l,u){L(e,l,u),y(l,n,u),y(l,t,u),Le(t,r[2]),o=!0,s||(a=[he(t,"input",r[9]),he(t,"change",r[4])],s=!0)},p(l,u){const f={};u&4&&(f.errorMessage=l[5](l[2])),e.$set(f),(!o||u&2&&i!==(i=`govuk-input govuk-input--width-${l[1]}`))&&J(t,"class",i),u&4&&t.value!==l[2]&&Le(t,l[2])},i(l){o||(_(e.$$.fragment,l),o=!0)},o(l){$(e.$$.fragment,l),o=!1},d(l){l&&(w(n),w(t)),F(e,l),s=!1,er(a)}}}function Ql(r){let e,n;return e=new Ct({props:{label:r[0],id:r[3],$$slots:{default:[Vl]},$$scope:{ctx:r}}}),{c(){P(e.$$.fragment)},m(t,i){L(e,t,i),n=!0},p(t,[i]){const o={};i&1&&(o.label=t[0]),i&1030&&(o.$$scope={dirty:i,ctx:t}),e.$set(o)},i(t){n||(_(e.$$.fragment,t),n=!0)},o(t){$(e.$$.fragment,t),n=!1},d(t){F(e,t)}}}function xl(r,e,n){let{label:t}=e,{value:i}=e,{width:o}=e,{min:s=void 0}=e,{max:a=void 0}=e,l=i==null?void 0:i.toString(),u=At();function f(){n(6,i=l==null?void 0:parseInt(l,10))}function c(m){if(m==""||m==null)return"";if(m.includes("."))return"Please enter a number without decimals";let g=Number(m);return isNaN(g)?"Please enter a valid number":s!=null&&ga?`Please enter a number that's at most ${a};`:""}function p(){l=this.value,n(2,l)}return r.$$set=m=>{"label"in m&&n(0,t=m.label),"value"in m&&n(6,i=m.value),"width"in m&&n(1,o=m.width),"min"in m&&n(7,s=m.min),"max"in m&&n(8,a=m.max)},[t,o,l,u,f,c,i,s,a,p]}class sr extends re{constructor(e){super(),ie(this,e,xl,Ql,te,{label:0,value:6,width:1,min:7,max:8})}}function ui(r){let e,n;return{c(){e=q("div"),n=D(r[2]),J(e,"class","govuk-hint")},m(t,i){y(t,e,i),G(e,n)},p(t,i){i&4&&be(n,t[2])},d(t){t&&w(e)}}}function ea(r){let e,n,t,i,o,s,a;e=new Ye({props:{errorMessage:r[4]}});let l=r[2]&&ui(r);return{c(){P(e.$$.fragment),n=R(),l&&l.c(),t=R(),i=q("textarea"),J(i,"class","govuk-textarea"),J(i,"id",r[5]),J(i,"rows",r[3])},m(u,f){L(e,u,f),y(u,n,f),l&&l.m(u,f),y(u,t,f),y(u,i,f),Le(i,r[0]),o=!0,s||(a=he(i,"input",r[6]),s=!0)},p(u,f){const c={};f&16&&(c.errorMessage=u[4]),e.$set(c),u[2]?l?l.p(u,f):(l=ui(u),l.c(),l.m(t.parentNode,t)):l&&(l.d(1),l=null),(!o||f&8)&&J(i,"rows",u[3]),f&1&&Le(i,u[0])},i(u){o||(_(e.$$.fragment,u),o=!0)},o(u){$(e.$$.fragment,u),o=!1},d(u){u&&(w(n),w(t),w(i)),F(e,u),l&&l.d(u),s=!1,a()}}}function ta(r){let e,n;return e=new Ct({props:{label:r[1],id:r[5],$$slots:{default:[ea]},$$scope:{ctx:r}}}),{c(){P(e.$$.fragment)},m(t,i){L(e,t,i),n=!0},p(t,[i]){const o={};i&2&&(o.label=t[1]),i&157&&(o.$$scope={dirty:i,ctx:t}),e.$set(o)},i(t){n||(_(e.$$.fragment,t),n=!0)},o(t){$(e.$$.fragment,t),n=!1},d(t){F(e,t)}}}function na(r,e,n){let{label:t}=e,{hint:i=""}=e,{value:o}=e,{rows:s=5}=e,{errorMessage:a=""}=e,l=At();function u(){o=this.value,n(0,o)}return r.$$set=f=>{"label"in f&&n(1,t=f.label),"hint"in f&&n(2,i=f.hint),"value"in f&&n(0,o=f.value),"rows"in f&&n(3,s=f.rows),"errorMessage"in f&&n(4,a=f.errorMessage)},[o,t,i,s,a,l,u]}class Ur extends re{constructor(e){super(),ie(this,e,na,ta,te,{label:1,hint:2,value:0,rows:3,errorMessage:4})}}function ra(r){let e,n,t,i,o,s;return e=new Ye({props:{errorMessage:r[2]}}),{c(){P(e.$$.fragment),n=R(),t=q("input"),J(t,"type","text"),J(t,"class","govuk-input"),J(t,"id",r[3])},m(a,l){L(e,a,l),y(a,n,l),y(a,t,l),Le(t,r[0]),i=!0,o||(s=[he(t,"input",r[6]),he(t,"change",r[5])],o=!0)},p(a,l){const u={};l&4&&(u.errorMessage=a[2]),e.$set(u),l&1&&t.value!==a[0]&&Le(t,a[0])},i(a){i||(_(e.$$.fragment,a),i=!0)},o(a){$(e.$$.fragment,a),i=!1},d(a){a&&(w(n),w(t)),F(e,a),o=!1,er(s)}}}function ia(r){let e,n;return e=new Ct({props:{label:r[1],id:r[3],$$slots:{default:[ra]},$$scope:{ctx:r}}}),{c(){P(e.$$.fragment)},m(t,i){L(e,t,i),n=!0},p(t,[i]){const o={};i&2&&(o.label=t[1]),i&133&&(o.$$scope={dirty:i,ctx:t}),e.$set(o)},i(t){n||(_(e.$$.fragment,t),n=!0)},o(t){$(e.$$.fragment,t),n=!1},d(t){F(e,t)}}}function oa(r,e,n){let t,{label:i}=e,{value:o}=e,{required:s=!1}=e,a=At();function l(f){Uo.call(this,r,f)}function u(){o=this.value,n(0,o)}return r.$$set=f=>{"label"in f&&n(1,i=f.label),"value"in f&&n(0,o=f.value),"required"in f&&n(4,s=f.required)},r.$$.update=()=>{r.$$.dirty&17&&n(2,t=s&&(o==null||o=="")?"Required":"")},[o,i,t,a,s,l,u]}class ir extends re{constructor(e){super(),ie(this,e,oa,ia,te,{label:1,value:0,required:4})}}function sa(r){let e,n,t,i;const o=r[2].default,s=Kt(o,r,r[1],null);let a=[{type:"button"},{class:"govuk-button govuk-button--warning"},{"data-module":"govuk-button"},r[0]],l={};for(let u=0;u{n(0,e=we(we({},e),ei(s))),"$$scope"in s&&n(1,i=s.$$scope)},e=ei(e),[e,i,t,o]}class bt extends re{constructor(e){super(),ie(this,e,la,sa,te,{})}}function fi(r){let e=r[0],n,t,i=ci(r);return{c(){i.c(),n=ce()},m(o,s){i.m(o,s),y(o,n,s),t=!0},p(o,s){s&1&&te(e,e=o[0])?(se(),$(i,1,1,Q),le(),i=ci(o),i.c(),_(i,1),i.m(n.parentNode,n)):i.p(o,s)},i(o){t||(_(i),t=!0)},o(o){$(i),t=!1},d(o){o&&w(n),i.d(o)}}}function ci(r){let e;const n=r[10].default,t=Kt(n,r,r[9],null);return{c(){t&&t.c()},m(i,o){t&&t.m(i,o),e=!0},p(i,o){t&&t.p&&(!e||o&512)&&Ht(t,n,i,i[9],e?Vt(n,i[9],o,null):Zt(i[9]),null)},i(i){e||(_(t,i),e=!0)},o(i){$(t,i),e=!1},d(i){t&&t.d(i)}}}function aa(r){let e,n,t=r[0]&&fi(r);return{c(){t&&t.c(),e=ce()},m(i,o){t&&t.m(i,o),y(i,e,o),n=!0},p(i,[o]){i[0]?t?(t.p(i,o),o&1&&_(t,1)):(t=fi(i),t.c(),_(t,1),t.m(e.parentNode,e)):t&&(se(),$(t,1,1,()=>{t=null}),le())},i(i){n||(_(t),n=!0)},o(i){$(t),n=!1},d(i){i&&w(e),t&&t.d(i)}}}function ua(r,e,n){let t,i,{$$slots:o={},$$scope:s}=e,{id:a=Do("image")}=e,{url:l}=e,{coordinates:u}=e;const{map:f,self:c}=tl();K(r,f,g=>n(8,i=g)),K(r,c,g=>n(0,t=g));let p,m=!0;return Xe(()=>{t&&i&&(nl(f,t,p),je(c,t=null,t),n(6,p=void 0))}),r.$$set=g=>{"id"in g&&n(3,a=g.id),"url"in g&&n(4,l=g.url),"coordinates"in g&&n(5,u=g.coordinates),"$$scope"in g&&n(9,s=g.$$scope)},r.$$.update=()=>{r.$$.dirty&313&&i&&t!==a&&(je(c,t=a,t),rl(i,t,il({type:"image",url:l,coordinates:u}),g=>i&&g===t,()=>{t&&(n(6,p=i==null?void 0:i.getSource(t)),n(7,m=!0))})),r.$$.dirty&264&&(i==null||i.on("style.load",()=>{n(6,p=i==null?void 0:i.getSource(a))})),r.$$.dirty&224&&p&&(m?n(7,m=!1):p.setCoordinates(u))},[t,f,c,a,l,u,p,m,i,s,o]}class fa extends re{constructor(e){super(),ie(this,e,ua,aa,te,{id:3,url:4,coordinates:5})}}class lr{constructor(){this._partials=new Float64Array(32),this._n=0}add(e){const n=this._partials;let t=0;for(let i=0;i0){for(s=e[--n];n>0&&(t=s,i=e[--n],s=t+i,o=i-(s-t),!o););n>0&&(o<0&&e[n-1]<0||o>0&&e[n-1]>0)&&(i=o*2,t=s+i,i==t-s&&(s=t))}return s}}var ca=1e-6,pi=1e-12,Dr=Math.PI,mi=Dr/2,di=180/Dr,et=Dr/180,Vo=Math.atan2,tt=Math.cos,br=Math.hypot,nt=Math.sin,pa=Math.sqrt;function Qo(r){return r>1?mi:r<-1?-mi:Math.asin(r)}function ma(){}function Tn(r,e){r&&hi.hasOwnProperty(r.type)&&hi[r.type](r,e)}var gi={Feature:function(r,e){Tn(r.geometry,e)},FeatureCollection:function(r,e){for(var n=r.features,t=-1,i=n.length;++t({feature:r[0]&1024,position:r[0]&1026}),yi=r=>({feature:r[40],position:r[41]});function wi(r){let e=[],n=new ya,t,i,o=Ie(r[10]);const s=a=>a[40].id;for(let a=0;a=r[13]&&r[11]<=r[12]&&wi(r);return{c(){P(e.$$.fragment),n=R(),o&&o.c(),t=ce()},m(s,a){L(e,s,a),y(s,n,a),o&&o.m(s,a),y(s,t,a),i=!0},p(s,a){const l={};a[0]&32&&(l.minzoom=s[5]),a[0]&64&&(l.maxzoom=s[6]),e.$set(l),s[11]>=s[13]&&s[11]<=s[12]?o?(o.p(s,a),a[0]&14336&&_(o,1)):(o=wi(s),o.c(),_(o,1),o.m(t.parentNode,t)):o&&(se(),$(o,1,1,()=>{o=null}),le())},i(s){i||(_(e.$$.fragment,s),_(o),i=!0)},o(s){$(e.$$.fragment,s),$(o),i=!1},d(s){s&&(w(n),w(t)),F(e,s),o&&o.d(s)}}}function Ea(r,e,n){let t,i,o,s,a,l,u,{$$slots:f={},$$scope:c}=e;const{map:p,source:m,minzoom:g,maxzoom:v}=ol();K(r,p,H=>n(21,s=H)),K(r,m,H=>n(9,a=H)),K(r,g,H=>n(23,u=H)),K(r,v,H=>n(22,l=H));const S=sl();let{applyToClusters:k=void 0}=e,{filter:b=void 0}=e,{markerLngLat:h=$a}=e,{interactive:M=!0}=e,{asButton:d=!1}=e,{draggable:E=!1}=e,{minzoom:N=void 0}=e,{maxzoom:j=void 0}=e,{hovered:U=null}=e,{zIndex:B=void 0}=e,{class:O=void 0}=e,C=!1;function A(){s&&(C=!0,s.on("zoom",T),s.on("move",z),s.on("moveend",z),s.loaded()?s.once("load",z):z())}function I(H){H.sourceId===a&&H.isSourceLoaded&&(C?z():A())}Xe(()=>{s&&(s.off("zoom",T),s.off("move",z),s.off("moveend",z),s.off("sourcedata",I))});let W=[];function z(){var It;if(!s||!a)return;let H=s.querySourceFeatures(a,{filter:o}),ke=new Map;for(let Pe of H)Pe.id||((It=Pe.properties)!=null&&It.cluster_id?Pe.id="autocluster_"+Pe.properties.cluster_id:Pe.id=Do("autofeat")),ke.set(Pe.id,Pe);n(10,W=[...ke.values()].sort((Pe,Qs)=>Pe.id.toString().localeCompare(Qs.id.toString())))}let ee=(s==null?void 0:s.getZoom())??0;function T(H){n(11,ee=s.getZoom()),z()}const fe=H=>{n(0,U=H)},me=H=>{(U==null?void 0:U.id)===H.id&&n(0,U=null)},ve=(H,ke)=>S("dragstart",{...ke.detail,source:a,feature:H}),$e=(H,ke)=>S("drag",{...ke.detail,source:a,feature:H}),yn=(H,ke)=>S("dragend",{...ke.detail,source:a,feature:H}),Y=(H,ke)=>S("click",{...ke.detail,source:a,feature:H}),Z=(H,ke)=>S("dblclick",{...ke.detail,source:a,feature:H}),Be=(H,ke)=>S("contextmenu",{...ke.detail,source:a,feature:H});return r.$$set=H=>{"applyToClusters"in H&&n(19,k=H.applyToClusters),"filter"in H&&n(20,b=H.filter),"markerLngLat"in H&&n(1,h=H.markerLngLat),"interactive"in H&&n(2,M=H.interactive),"asButton"in H&&n(3,d=H.asButton),"draggable"in H&&n(4,E=H.draggable),"minzoom"in H&&n(5,N=H.minzoom),"maxzoom"in H&&n(6,j=H.maxzoom),"hovered"in H&&n(0,U=H.hovered),"zIndex"in H&&n(7,B=H.zIndex),"class"in H&&n(8,O=H.class),"$$scope"in H&&n(33,c=H.$$scope)},r.$$.update=()=>{if(r.$$.dirty[0]&8388640&&n(13,t=N??u),r.$$.dirty[0]&4194368&&n(12,i=j??l),r.$$.dirty[0]&1572864&&(o=ll("all",al(k),b)),r.$$.dirty[0]&2097664&&s&&a){let H=s.getSource(a);H!=null&&H.loaded()?A():s.on("sourcedata",I)}},[U,h,M,d,E,N,j,B,O,a,W,ee,i,t,p,m,g,v,S,k,b,s,l,u,f,fe,me,ve,$e,yn,Y,Z,Be,c]}class Ma extends re{constructor(e){super(),ie(this,e,Ea,Sa,te,{applyToClusters:19,filter:20,markerLngLat:1,interactive:2,asButton:3,draggable:4,minzoom:5,maxzoom:6,hovered:0,zIndex:7,class:8},null,[-1,-1])}}class Pa{constructor(e){de(this,"map");de(this,"active");de(this,"eventListenersSuccess");de(this,"eventListenersFailure");de(this,"cursor");de(this,"onMouseMove",e=>{this.active&&(this.cursor={type:"Feature",properties:{},geometry:{type:"Point",coordinates:zo(e.lngLat.toArray())}})});de(this,"onClick",()=>{if(this.active&&this.cursor){for(let e of this.eventListenersSuccess)e(this.cursor);this.stop()}});de(this,"onKeyDown",e=>{this.active&&e.key=="Escape"&&(e.stopPropagation(),this.cancel())});this.map=e,this.active=!1,this.eventListenersSuccess=[],this.eventListenersFailure=[],this.cursor=null,this.map.on("mousemove",this.onMouseMove),this.map.on("click",this.onClick),document.addEventListener("keydown",this.onKeyDown)}tearDown(){this.map.off("mousemove",this.onMouseMove),this.map.off("click",this.onClick),document.removeEventListener("keydown",this.onKeyDown)}cancel(){for(let e of this.eventListenersFailure)e();this.stop()}addEventListenerSuccess(e){this.eventListenersSuccess.push(e)}addEventListenerFailure(e){this.eventListenersFailure.push(e)}clearEventListeners(){this.eventListenersSuccess=[],this.eventListenersFailure=[]}start(){this.map.getCanvas().style.cursor="crosshair",this.active=!0}stop(){this.map.getCanvas().style.cursor="inherit",this.cursor=null,this.active=!1}}function La(r){var e=r%(2*Math.PI);return e*180/Math.PI}function wn(r){var e=r%360;return e*Math.PI/180}function gt(r){if(!r)throw new Error("coord is required");if(!Array.isArray(r)){if(r.type==="Feature"&&r.geometry!==null&&r.geometry.type==="Point")return r.geometry.coordinates;if(r.type==="Point")return r.coordinates}if(Array.isArray(r)&&r.length>=2&&!Array.isArray(r[0])&&!Array.isArray(r[1]))return r;throw new Error("coord must be GeoJSON Point or an Array of numbers")}function Ve(r){if(Array.isArray(r))return r;if(r.type==="Feature"){if(r.geometry!==null)return r.geometry.coordinates}else if(r.coordinates)return r.coordinates;throw new Error("coords must be GeoJSON Feature, Geometry Object or an Array")}function kr(r,e){return r.type==="FeatureCollection"?"FeatureCollection":r.type==="GeometryCollection"?"GeometryCollection":r.type==="Feature"&&r.geometry!==null?r.geometry.type:r.type}function ns(r,e,n){if(n===void 0&&(n={}),n.final===!0)return Fa(r,e);var t=gt(r),i=gt(e),o=wn(t[0]),s=wn(i[0]),a=wn(t[1]),l=wn(i[1]),u=Math.sin(s-o)*Math.cos(l),f=Math.cos(a)*Math.sin(l)-Math.sin(a)*Math.cos(l)*Math.cos(s-o);return La(Math.atan2(u,f))}function Fa(r,e){var n=ns(e,r);return n=(n+180)%360,n}var Re=63710088e-1,Ca={centimeters:Re*100,centimetres:Re*100,degrees:Re/111325,feet:Re*3.28084,inches:Re*39.37,kilometers:Re/1e3,kilometres:Re/1e3,meters:Re,metres:Re,miles:Re/1609.344,millimeters:Re*1e3,millimetres:Re*1e3,nauticalmiles:Re/1852,radians:1,yards:Re*1.0936};function Aa(r,e){e===void 0&&(e="kilometers");var n=Ca[e];if(!n)throw new Error(e+" units is invalid");return r*n}function kn(r){var e=r%360;return e*Math.PI/180}function ut(r,e,n){n===void 0&&(n={});var t=gt(r),i=gt(e),o=kn(i[1]-t[1]),s=kn(i[0]-t[0]),a=kn(t[1]),l=kn(i[1]),u=Math.pow(Math.sin(o/2),2)+Math.pow(Math.sin(s/2),2)*Math.cos(a)*Math.cos(l);return Aa(2*Math.atan2(Math.sqrt(u),Math.sqrt(1-u)),n.units)}var Oe=63710088e-1,Na={centimeters:Oe*100,centimetres:Oe*100,degrees:Oe/111325,feet:Oe*3.28084,inches:Oe*39.37,kilometers:Oe/1e3,kilometres:Oe/1e3,meters:Oe,metres:Oe,miles:Oe/1609.344,millimeters:Oe*1e3,millimetres:Oe*1e3,nauticalmiles:Oe/1852,radians:1,yards:Oe*1.0936};function Ra(r,e,n){n===void 0&&(n={});var t={type:"Feature"};return(n.id===0||n.id)&&(t.id=n.id),n.bbox&&(t.bbox=n.bbox),t.properties=e||{},t.geometry=r,t}function Oa(r,e,n){if(n===void 0&&(n={}),!r)throw new Error("coordinates is required");if(!Array.isArray(r))throw new Error("coordinates must be an Array");if(r.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!Ei(r[0])||!Ei(r[1]))throw new Error("coordinates must contain numbers");var t={type:"Point",coordinates:r};return Ra(t,e,n)}function ja(r,e){e===void 0&&(e="kilometers");var n=Na[e];if(!n)throw new Error(e+" units is invalid");return r/n}function Si(r){var e=r%(2*Math.PI);return e*180/Math.PI}function ar(r){var e=r%360;return e*Math.PI/180}function Ei(r){return!isNaN(r)&&r!==null&&!Array.isArray(r)}function Mi(r,e,n,t){t===void 0&&(t={});var i=gt(r),o=ar(i[0]),s=ar(i[1]),a=ar(n),l=ja(e,t.units),u=Math.asin(Math.sin(s)*Math.cos(l)+Math.cos(s)*Math.sin(l)*Math.cos(a)),f=o+Math.atan2(Math.sin(a)*Math.sin(l)*Math.cos(s),Math.cos(l)-Math.sin(s)*Math.sin(u)),c=Si(f),p=Si(u);return Oa([c,p],t.properties)}function Sr(r,e,n){n===void 0&&(n={});var t={type:"Feature"};return(n.id===0||n.id)&&(t.id=n.id),n.bbox&&(t.bbox=n.bbox),t.properties=e||{},t.geometry=r,t}function Ia(r,e,n){if(n===void 0&&(n={}),!r)throw new Error("coordinates is required");if(!Array.isArray(r))throw new Error("coordinates must be an Array");if(r.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!Li(r[0])||!Li(r[1]))throw new Error("coordinates must contain numbers");var t={type:"Point",coordinates:r};return Sr(t,e,n)}function Pi(r,e){e===void 0&&(e={});var n={type:"FeatureCollection"};return e.id&&(n.id=e.id),e.bbox&&(n.bbox=e.bbox),n.features=r,n}function Li(r){return!isNaN(r)&&r!==null&&!Array.isArray(r)}function Ba(r,e,n){n===void 0&&(n={});var t={type:"Feature"};return(n.id===0||n.id)&&(t.id=n.id),n.bbox&&(t.bbox=n.bbox),t.properties=e||{},t.geometry=r,t}function qa(r,e,n){if(n===void 0&&(n={}),r.length<2)throw new Error("coordinates must be an array of two or more positions");var t={type:"LineString",coordinates:r};return Ba(t,e,n)}function Ga(r,e){e===void 0&&(e={});var n={type:"FeatureCollection"};return e.id&&(n.id=e.id),e.bbox&&(n.bbox=e.bbox),n.features=r,n}function Kn(r,e,n){n===void 0&&(n={});var t={type:"Feature"};return(n.id===0||n.id)&&(t.id=n.id),n.bbox&&(t.bbox=n.bbox),t.properties=e||{},t.geometry=r,t}function Bt(r,e,n){if(n===void 0&&(n={}),!r)throw new Error("coordinates is required");if(!Array.isArray(r))throw new Error("coordinates must be an Array");if(r.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!Fi(r[0])||!Fi(r[1]))throw new Error("coordinates must contain numbers");var t={type:"Point",coordinates:r};return Kn(t,e,n)}function Ut(r,e,n){if(n===void 0&&(n={}),r.length<2)throw new Error("coordinates must be an array of two or more positions");var t={type:"LineString",coordinates:r};return Kn(t,e,n)}function Fi(r){return!isNaN(r)&&r!==null&&!Array.isArray(r)}function rs(r){return!!r&&r.constructor===Object}function Ot(r,e,n){if(r!==null)for(var t,i,o,s,a,l,u,f=0,c=0,p,m=r.type,g=m==="FeatureCollection",v=m==="Feature",S=g?r.features.length:1,k=0;kl||g>u||v>f){a=c,l=t,u=g,f=v,o=0;return}var S=Ut([a,c],n.properties);if(e(S,t,i,v,o)===!1)return!1;o++,a=c})===!1)return!1}}})}function ls(r,e,n){var t=n,i=!1;return ss(r,function(o,s,a,l,u){i===!1&&n===void 0?t=o:t=e(t,o,s,a,l,u),i=!0}),t}function as(r,e){if(!r)throw new Error("geojson is required");jt(r,function(n,t,i){if(n.geometry!==null){var o=n.geometry.type,s=n.geometry.coordinates;switch(o){case"LineString":if(e(n,t,i,0,0)===!1)return!1;break;case"Polygon":for(var a=0;ai?n:i,u=t>o?t:o;return[s,a,l,u]}var Yr={exports:{}},us={exports:{}};(function(r,e){(function(n,t){r.exports=t()})(fl,function(){function n(b,h,M,d,E){(function N(j,U,B,O,C){for(;O>B;){if(O-B>600){var A=O-B+1,I=U-B+1,W=Math.log(A),z=.5*Math.exp(2*W/3),ee=.5*Math.sqrt(W*z*(A-z)/A)*(I-A/2<0?-1:1),T=Math.max(B,Math.floor(U-I*z/A+ee)),fe=Math.min(O,Math.floor(U+(A-I)*z/A+ee));N(j,U,T,fe,C)}var me=j[U],ve=B,$e=O;for(t(j,B,U),C(j[O],me)>0&&t(j,B,O);ve<$e;){for(t(j,ve,$e),ve++,$e--;C(j[ve],me)<0;)ve++;for(;C(j[$e],me)>0;)$e--}C(j[B],me)===0?t(j,B,$e):t(j,++$e,O),$e<=U&&(B=$e+1),U<=$e&&(O=$e-1)}})(b,h,M||0,d||b.length-1,E||i)}function t(b,h,M){var d=b[h];b[h]=b[M],b[M]=d}function i(b,h){return bh?1:0}var o=function(b){b===void 0&&(b=9),this._maxEntries=Math.max(4,b),this._minEntries=Math.max(2,Math.ceil(.4*this._maxEntries)),this.clear()};function s(b,h,M){if(!M)return h.indexOf(b);for(var d=0;d=b.minX&&h.maxY>=b.minY}function S(b){return{children:b,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function k(b,h,M,d,E){for(var N=[h,M];N.length;)if(!((M=N.pop())-(h=N.pop())<=d)){var j=h+Math.ceil((M-h)/d/2)*d;n(b,j,h,M,E),N.push(h,j,j,M)}}return o.prototype.all=function(){return this._all(this.data,[])},o.prototype.search=function(b){var h=this.data,M=[];if(!v(b,h))return M;for(var d=this.toBBox,E=[];h;){for(var N=0;N=0&&E[h].children.length>this._maxEntries;)this._split(E,h),h--;this._adjustParentBBoxes(d,E,h)},o.prototype._split=function(b,h){var M=b[h],d=M.children.length,E=this._minEntries;this._chooseSplitAxis(M,E,d);var N=this._chooseSplitIndex(M,E,d),j=S(M.children.splice(N,M.children.length-N));j.height=M.height,j.leaf=M.leaf,a(M,this.toBBox),a(j,this.toBBox),h?b[h-1].children.push(j):this._splitRoot(M,j)},o.prototype._splitRoot=function(b,h){this.data=S([b,h]),this.data.height=b.height+1,this.data.leaf=!1,a(this.data,this.toBBox)},o.prototype._chooseSplitIndex=function(b,h,M){for(var d,E,N,j,U,B,O,C=1/0,A=1/0,I=h;I<=M-h;I++){var W=l(b,0,I,this.toBBox),z=l(b,I,M,this.toBBox),ee=(E=W,N=z,j=void 0,U=void 0,B=void 0,O=void 0,j=Math.max(E.minX,N.minX),U=Math.max(E.minY,N.minY),B=Math.min(E.maxX,N.maxX),O=Math.min(E.maxY,N.maxY),Math.max(0,B-j)*Math.max(0,O-U)),T=p(W)+p(z);ee=h;C--){var A=b.children[C];u(j,b.leaf?E(A):A),U+=m(j)}return U},o.prototype._adjustParentBBoxes=function(b,h,M){for(var d=M;d>=0;d--)u(h[d],b)},o.prototype._condense=function(b){for(var h=b.length-1,M=void 0;h>=0;h--)b[h].children.length===0?h>0?(M=b[h-1].children).splice(M.indexOf(b[h]),1):this.clear():a(b[h],this.toBBox)},o})})(us);var Qa=us.exports,fs={};(function(r){Object.defineProperty(r,"__esModule",{value:!0}),r.earthRadius=63710088e-1,r.factors={centimeters:r.earthRadius*100,centimetres:r.earthRadius*100,degrees:r.earthRadius/111325,feet:r.earthRadius*3.28084,inches:r.earthRadius*39.37,kilometers:r.earthRadius/1e3,kilometres:r.earthRadius/1e3,meters:r.earthRadius,metres:r.earthRadius,miles:r.earthRadius/1609.344,millimeters:r.earthRadius*1e3,millimetres:r.earthRadius*1e3,nauticalmiles:r.earthRadius/1852,radians:1,yards:r.earthRadius*1.0936},r.unitsFactors={centimeters:100,centimetres:100,degrees:1/111325,feet:3.28084,inches:39.37,kilometers:1/1e3,kilometres:1/1e3,meters:1,metres:1,miles:1/1609.344,millimeters:1e3,millimetres:1e3,nauticalmiles:1/1852,radians:1/r.earthRadius,yards:1.0936133},r.areaFactors={acres:247105e-9,centimeters:1e4,centimetres:1e4,feet:10.763910417,hectares:1e-4,inches:1550.003100006,kilometers:1e-6,kilometres:1e-6,meters:1,metres:1,miles:386e-9,millimeters:1e6,millimetres:1e6,yards:1.195990046};function e(O,C,A){A===void 0&&(A={});var I={type:"Feature"};return(A.id===0||A.id)&&(I.id=A.id),A.bbox&&(I.bbox=A.bbox),I.properties=C||{},I.geometry=O,I}r.feature=e;function n(O,C,A){switch(O){case"Point":return t(C).geometry;case"LineString":return a(C).geometry;case"Polygon":return o(C).geometry;case"MultiPoint":return c(C).geometry;case"MultiLineString":return f(C).geometry;case"MultiPolygon":return p(C).geometry;default:throw new Error(O+" is invalid")}}r.geometry=n;function t(O,C,A){if(A===void 0&&(A={}),!O)throw new Error("coordinates is required");if(!Array.isArray(O))throw new Error("coordinates must be an Array");if(O.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!N(O[0])||!N(O[1]))throw new Error("coordinates must contain numbers");var I={type:"Point",coordinates:O};return e(I,C,A)}r.point=t;function i(O,C,A){return A===void 0&&(A={}),u(O.map(function(I){return t(I,C)}),A)}r.points=i;function o(O,C,A){A===void 0&&(A={});for(var I=0,W=O;I=0))throw new Error("precision must be a positive number");var A=Math.pow(10,C||0);return Math.round(O*A)/A}r.round=g;function v(O,C){C===void 0&&(C="kilometers");var A=r.factors[C];if(!A)throw new Error(C+" units is invalid");return O*A}r.radiansToLength=v;function S(O,C){C===void 0&&(C="kilometers");var A=r.factors[C];if(!A)throw new Error(C+" units is invalid");return O/A}r.lengthToRadians=S;function k(O,C){return h(S(O,C))}r.lengthToDegrees=k;function b(O){var C=O%360;return C<0&&(C+=360),C}r.bearingToAzimuth=b;function h(O){var C=O%(2*Math.PI);return C*180/Math.PI}r.radiansToDegrees=h;function M(O){var C=O%360;return C*Math.PI/180}r.degreesToRadians=M;function d(O,C,A){if(C===void 0&&(C="kilometers"),A===void 0&&(A="kilometers"),!(O>=0))throw new Error("length must be a positive number");return v(S(O,C),A)}r.convertLength=d;function E(O,C,A){if(C===void 0&&(C="meters"),A===void 0&&(A="kilometers"),!(O>=0))throw new Error("area must be a positive number");var I=r.areaFactors[C];if(!I)throw new Error("invalid original units");var W=r.areaFactors[A];if(!W)throw new Error("invalid final units");return O/I*W}r.convertArea=E;function N(O){return!isNaN(O)&&O!==null&&!Array.isArray(O)}r.isNumber=N;function j(O){return!!O&&O.constructor===Object}r.isObject=j;function U(O){if(!O)throw new Error("bbox is required");if(!Array.isArray(O))throw new Error("bbox must be an Array");if(O.length!==4&&O.length!==6)throw new Error("bbox must be an Array of 4 or 6 numbers");O.forEach(function(C){if(!N(C))throw new Error("bbox must only contain numbers")})}r.validateBBox=U;function B(O){if(!O)throw new Error("id is required");if(["string","number"].indexOf(typeof O)===-1)throw new Error("id must be a number or a string")}r.validateId=B})(fs);const xa=Jo(Ka),eu=Jo(cl);var He=Qa,cs=fs,ps=xa,qt=eu.default,tu=ps.featureEach;ps.coordEach;cs.polygon;var Ci=cs.featureCollection;function ms(r){var e=new He(r);return e.insert=function(n){if(n.type!=="Feature")throw new Error("invalid feature");return n.bbox=n.bbox?n.bbox:qt(n),He.prototype.insert.call(this,n)},e.load=function(n){var t=[];return Array.isArray(n)?n.forEach(function(i){if(i.type!=="Feature")throw new Error("invalid features");i.bbox=i.bbox?i.bbox:qt(i),t.push(i)}):tu(n,function(i){if(i.type!=="Feature")throw new Error("invalid features");i.bbox=i.bbox?i.bbox:qt(i),t.push(i)}),He.prototype.load.call(this,t)},e.remove=function(n,t){if(n.type!=="Feature")throw new Error("invalid feature");return n.bbox=n.bbox?n.bbox:qt(n),He.prototype.remove.call(this,n,t)},e.clear=function(){return He.prototype.clear.call(this)},e.search=function(n){var t=He.prototype.search.call(this,this.toBBox(n));return Ci(t)},e.collides=function(n){return He.prototype.collides.call(this,this.toBBox(n))},e.all=function(){var n=He.prototype.all.call(this);return Ci(n)},e.toJSON=function(){return He.prototype.toJSON.call(this)},e.fromJSON=function(n){return He.prototype.fromJSON.call(this,n)},e.toBBox=function(n){var t;if(n.bbox)t=n.bbox;else if(Array.isArray(n)&&n.length===4)t=n;else if(Array.isArray(n)&&n.length===6)t=[n[0],n[1],n[3],n[4]];else if(n.type==="Feature")t=qt(n);else if(n.type==="FeatureCollection")t=qt(n);else throw new Error("invalid geojson");return{minX:t[0],minY:t[1],maxX:t[2],maxY:t[3]}},e}Yr.exports=ms;Yr.exports.default=ms;var nu=Yr.exports;const Xr=pl(nu);function ds(r,e){var n={},t=[];if(r.type==="LineString"&&(r=Sr(r)),e.type==="LineString"&&(e=Sr(e)),r.type==="Feature"&&e.type==="Feature"&&r.geometry!==null&&e.geometry!==null&&r.geometry.type==="LineString"&&e.geometry.type==="LineString"&&r.geometry.coordinates.length===2&&e.geometry.coordinates.length===2){var i=Ai(r,e);return i&&t.push(i),Pi(t)}var o=Xr();return o.load(Er(e)),Xt(Er(r),function(s){Xt(o.search(s),function(a){var l=Ai(s,a);if(l){var u=Ve(l).join(",");n[u]||(n[u]=!0,t.push(l))}})}),Pi(t)}function Ai(r,e){var n=Ve(r),t=Ve(e);if(n.length!==2)throw new Error(" line1 must only contain 2 coordinates");if(t.length!==2)throw new Error(" line2 must only contain 2 coordinates");var i=n[0][0],o=n[0][1],s=n[1][0],a=n[1][1],l=t[0][0],u=t[0][1],f=t[1][0],c=t[1][1],p=(c-u)*(s-i)-(f-l)*(a-o),m=(f-l)*(o-u)-(c-u)*(i-l),g=(s-i)*(o-u)-(a-o)*(i-l);if(p===0)return null;var v=m/p,S=g/p;if(v>=0&&v<=1&&S>=0&&S<=1){var k=i+v*(s-i),b=o+v*(a-o);return Ia([k,b])}return null}function gs(r,e,n){n===void 0&&(n={});var t={type:"Feature"};return(n.id===0||n.id)&&(t.id=n.id),n.bbox&&(t.bbox=n.bbox),t.properties=e||{},t.geometry=r,t}function ur(r,e,n){if(n===void 0&&(n={}),!r)throw new Error("coordinates is required");if(!Array.isArray(r))throw new Error("coordinates must be an Array");if(r.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!Ri(r[0])||!Ri(r[1]))throw new Error("coordinates must contain numbers");var t={type:"Point",coordinates:r};return gs(t,e,n)}function Ni(r,e,n){if(n===void 0&&(n={}),r.length<2)throw new Error("coordinates must be an array of two or more positions");var t={type:"LineString",coordinates:r};return gs(t,e,n)}function Ri(r){return!isNaN(r)&&r!==null&&!Array.isArray(r)}function Hn(r,e,n){n===void 0&&(n={});var t=ur([1/0,1/0],{dist:1/0}),i=0;return jt(r,function(o){for(var s=Ve(o),a=0;a0&&(S=v.features[0],S.properties.dist=ut(e,S,n),S.properties.location=i+ut(l,S,n)),l.properties.dist{if(this.active&&!this.dragFrom)this.recalculateHovering(e);else if(this.active&&this.dragFrom){if(this.hover=="polygon"){let n=this.dragFrom[0]-e.lngLat.lng,t=this.dragFrom[1]-e.lngLat.lat;for(let i of this.points)i[0]-=n,i[1]-=t}else this.points[this.hover]=e.lngLat.toArray();this.dragFrom=e.lngLat.toArray(),this.redraw()}});de(this,"onClick",e=>{if(this.beforeUpdate(),this.active&&this.cursor){let n=[];if(Oi(this.points).forEach((t,i)=>{n.push([i+1,Hn(t,this.cursor).properties.dist])}),n.sort((t,i)=>t[1]-i[1]),n.length>0){let t=n[0][0];this.points.splice(t,0,this.cursor.geometry.coordinates),this.hover=t}else this.points.push(this.cursor.geometry.coordinates),this.hover=this.points.length-1;this.redraw(),this.pointsUpdated()}else this.active&&typeof this.hover=="number"&&(this.points.splice(this.hover,1),this.hover=null,this.redraw(),this.pointsUpdated(),this.recalculateHovering(e))});de(this,"onDoubleClick",e=>{this.active&&(e.preventDefault(),this.cursor=fr(e.lngLat.toArray()),this.onClick(e),this.finish())});de(this,"onMouseDown",e=>{this.active&&!this.dragFrom&&this.hover!=null&&(e.preventDefault(),this.cursor=null,this.dragFrom=e.lngLat.toArray(),this.beforeUpdate(),this.redraw())});de(this,"onMouseUp",()=>{this.active&&this.dragFrom&&(this.dragFrom=null,this.redraw(),this.pointsUpdated())});de(this,"onKeypress",e=>{this.active&&(e.key=="Enter"?(e.stopPropagation(),this.finish()):e.key=="z"&&e.ctrlKey&&this.undo())});de(this,"onKeyDown",e=>{this.active&&e.key=="Escape"&&(e.stopPropagation(),this.cancel())});this.map=e,this.active=!1,this.eventListenersSuccess=[],this.eventListenersUpdated=[],this.eventListenersFailure=[],this.points=[],this.cursor=null,this.hover=null,this.dragFrom=null,this.previousStates=[],this.map.on("mousemove",this.onMouseMove),this.map.on("click",this.onClick),this.map.on("dblclick",this.onDoubleClick),this.map.on("mousedown",this.onMouseDown),this.map.on("mouseup",this.onMouseUp),document.addEventListener("keypress",this.onKeypress),document.addEventListener("keydown",this.onKeyDown)}tearDown(){this.map.off("mousemove",this.onMouseMove),this.map.off("click",this.onClick),this.map.off("dblclick",this.onDoubleClick),this.map.off("mousedown",this.onMouseDown),this.map.off("mouseup",this.onMouseUp),document.removeEventListener("keypress",this.onKeypress),document.removeEventListener("keydown",this.onKeyDown)}finish(){let e=this.polygonFeature();if(e)for(let n of this.eventListenersSuccess)n(e);else for(let n of this.eventListenersFailure)n();this.stop()}cancel(){for(let e of this.eventListenersFailure)e();this.stop()}addEventListenerSuccess(e){this.eventListenersSuccess.push(e)}addEventListenerUpdated(e){this.eventListenersUpdated.push(e)}addEventListenerFailure(e){this.eventListenersFailure.push(e)}clearEventListeners(){this.eventListenersSuccess=[],this.eventListenersUpdated=[],this.eventListenersFailure=[]}startNew(){this.active=!0,this.map.doubleClickZoom.disable()}editExisting(e){this.active=!0,this.map.doubleClickZoom.disable(),this.points=JSON.parse(JSON.stringify(e.geometry.coordinates[0])),this.points.pop(),this.redraw()}stop(){this.map.doubleClickZoom.enable(),this.points=[],this.cursor=null,this.active=!1,this.hover=null,this.dragFrom=null,this.previousStates=[],this.redraw(),this.map.getCanvas().style.cursor="inherit"}undo(){this.dragFrom!=null||this.previousStates.length==0||(this.points=this.previousStates.pop(),this.hover=null,this.redraw())}redraw(){let e=hs();this.points.forEach((i,o)=>{let s=fr(i);s.properties.hover=this.hover==o,s.properties.idx=o,e.features.push(s)}),e.features=e.features.concat(Oi(this.points));let n=this.polygonFeature();n&&(n.properties.hover=this.hover=="polygon",e.features.push(n)),bs.set(e);let t="crosshair";this.hover!=null&&(t=this.dragFrom?"grabbing":"pointer"),this.map.getCanvas().style.cursor=t,vs.set(this.previousStates.length)}pointsUpdated(){let e=this.polygonFeature();if(e)for(let n of this.eventListenersUpdated)n(e)}recalculateHovering(e){this.cursor=null,this.hover=null;for(let n of this.map.queryRenderedFeatures(e.point,{layers:["edit-polygon-fill","edit-polygon-vertices"]}))if(n.geometry.type=="Polygon"){this.hover="polygon";break}else if(n.geometry.type=="Point"&&Object.hasOwn(n.properties,"idx")){this.hover=n.properties.idx;break}this.hover==null&&(this.cursor=fr(e.lngLat.toArray())),this.redraw()}polygonFeature(){if(this.points.length<3)return null;let e=this.points.map(_s),n=[JSON.parse(JSON.stringify(e))];return n[0].push(JSON.parse(JSON.stringify(n[0][0]))),{type:"Feature",geometry:{type:"Polygon",coordinates:n},properties:{}}}beforeUpdate(){this.previousStates.push(JSON.parse(JSON.stringify(this.points))),this.previousStates.length>ru&&this.previousStates.shift()}}function Oi(r){let e=[];for(let n=0;n=3&&e.push({type:"Feature",geometry:{type:"LineString",coordinates:[r[r.length-1],r[0]]},properties:{}}),e}let X;const $s=typeof TextDecoder<"u"?new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}):{decode:()=>{throw Error("TextDecoder not available")}};typeof TextDecoder<"u"&&$s.decode();let tn=null;function an(){return(tn===null||tn.byteLength===0)&&(tn=new Uint8Array(X.memory.buffer)),tn}function qe(r,e){return r=r>>>0,$s.decode(an().subarray(r,r+e))}const lt=new Array(128).fill(void 0);lt.push(void 0,null,!0,!1);let un=lt.length;function ye(r){un===lt.length&<.push(lt.length+1);const e=un;return un=lt[e],lt[e]=r,e}function oe(r){return lt[r]}function ou(r){r<132||(lt[r]=un,un=r)}function Gt(r){const e=oe(r);return ou(r),e}function cr(r){return r==null}let nn=null;function su(){return(nn===null||nn.byteLength===0)&&(nn=new Float64Array(X.memory.buffer)),nn}let rn=null;function ae(){return(rn===null||rn.byteLength===0)&&(rn=new Int32Array(X.memory.buffer)),rn}let mt=0;const Fn=typeof TextEncoder<"u"?new TextEncoder("utf-8"):{encode:()=>{throw Error("TextEncoder not available")}},lu=typeof Fn.encodeInto=="function"?function(r,e){return Fn.encodeInto(r,e)}:function(r,e){const n=Fn.encode(r);return e.set(n),{read:r.length,written:n.length}};function Sn(r,e,n){if(n===void 0){const a=Fn.encode(r),l=e(a.length,1)>>>0;return an().subarray(l,l+a.length).set(a),mt=a.length,l}let t=r.length,i=e(t,1)>>>0;const o=an();let s=0;for(;s127)break;o[i+s]=a}if(s!==t){s!==0&&(r=r.slice(s)),i=n(i,t,t=s+r.length*3,1)>>>0;const a=an().subarray(i+s,i+t),l=lu(r,a);s+=l.written}return mt=s,i}function Mr(r){const e=typeof r;if(e=="number"||e=="boolean"||r==null)return`${r}`;if(e=="string")return`"${r}"`;if(e=="symbol"){const i=r.description;return i==null?"Symbol":`Symbol(${i})`}if(e=="function"){const i=r.name;return typeof i=="string"&&i.length>0?`Function(${i})`:"Function"}if(Array.isArray(r)){const i=r.length;let o="[";i>0&&(o+=Mr(r[0]));for(let s=1;s1)t=n[1];else return toString.call(r);if(t=="Object")try{return"Object("+JSON.stringify(r)+")"}catch{return"Object"}return r instanceof Error?`${r.name}: ${r.message} -${r.stack}`:t}function au(r,e){const n=e(r.length*1,1)>>>0;return an().set(r,n/1),mt=r.length,n}function pr(r,e){try{return r.apply(this,e)}catch(n){X.__wbindgen_exn_store(ye(n))}}class Zn{static __wrap(e){e=e>>>0;const n=Object.create(Zn.prototype);return n.__wbg_ptr=e,n}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,e}free(){const e=this.__destroy_into_raw();X.__wbg_jsroutesnapper_free(e)}constructor(e){try{const o=X.__wbindgen_add_to_stack_pointer(-16),s=au(e,X.__wbindgen_malloc),a=mt;X.jsroutesnapper_new(o,s,a);var n=ae()[o/4+0],t=ae()[o/4+1],i=ae()[o/4+2];if(i)throw Gt(t);return Zn.__wrap(n)}finally{X.__wbindgen_add_to_stack_pointer(16)}}setRouteConfig(e){X.jsroutesnapper_setRouteConfig(this.__wbg_ptr,ye(e))}setAreaMode(){X.jsroutesnapper_setAreaMode(this.__wbg_ptr)}getConfig(){let e,n;try{const o=X.__wbindgen_add_to_stack_pointer(-16);X.jsroutesnapper_getConfig(o,this.__wbg_ptr);var t=ae()[o/4+0],i=ae()[o/4+1];return e=t,n=i,qe(t,i)}finally{X.__wbindgen_add_to_stack_pointer(16),X.__wbindgen_free(e,n,1)}}toFinalFeature(){try{const t=X.__wbindgen_add_to_stack_pointer(-16);X.jsroutesnapper_toFinalFeature(t,this.__wbg_ptr);var e=ae()[t/4+0],n=ae()[t/4+1];let i;return e!==0&&(i=qe(e,n).slice(),X.__wbindgen_free(e,n*1)),i}finally{X.__wbindgen_add_to_stack_pointer(16)}}renderGeojson(){let e,n;try{const o=X.__wbindgen_add_to_stack_pointer(-16);X.jsroutesnapper_renderGeojson(o,this.__wbg_ptr);var t=ae()[o/4+0],i=ae()[o/4+1];return e=t,n=i,qe(t,i)}finally{X.__wbindgen_add_to_stack_pointer(16),X.__wbindgen_free(e,n,1)}}toggleSnapMode(){X.jsroutesnapper_toggleSnapMode(this.__wbg_ptr)}onMouseMove(e,n,t){return X.jsroutesnapper_onMouseMove(this.__wbg_ptr,e,n,t)!==0}onClick(){X.jsroutesnapper_onClick(this.__wbg_ptr)}onDragStart(){return X.jsroutesnapper_onDragStart(this.__wbg_ptr)!==0}onMouseUp(){return X.jsroutesnapper_onMouseUp(this.__wbg_ptr)!==0}clearState(){X.jsroutesnapper_clearState(this.__wbg_ptr)}editExisting(e){try{const i=X.__wbindgen_add_to_stack_pointer(-16);X.jsroutesnapper_editExisting(i,this.__wbg_ptr,ye(e));var n=ae()[i/4+0],t=ae()[i/4+1];if(t)throw Gt(n)}finally{X.__wbindgen_add_to_stack_pointer(16)}}debugRenderGraph(){let e,n;try{const o=X.__wbindgen_add_to_stack_pointer(-16);X.jsroutesnapper_debugRenderGraph(o,this.__wbg_ptr);var t=ae()[o/4+0],i=ae()[o/4+1];return e=t,n=i,qe(t,i)}finally{X.__wbindgen_add_to_stack_pointer(16),X.__wbindgen_free(e,n,1)}}debugSnappableNodes(){let e,n;try{const o=X.__wbindgen_add_to_stack_pointer(-16);X.jsroutesnapper_debugSnappableNodes(o,this.__wbg_ptr);var t=ae()[o/4+0],i=ae()[o/4+1];return e=t,n=i,qe(t,i)}finally{X.__wbindgen_add_to_stack_pointer(16),X.__wbindgen_free(e,n,1)}}routeNameForWaypoints(e){let n,t;try{const f=X.__wbindgen_add_to_stack_pointer(-16);X.jsroutesnapper_routeNameForWaypoints(f,this.__wbg_ptr,ye(e));var i=ae()[f/4+0],o=ae()[f/4+1],s=ae()[f/4+2],a=ae()[f/4+3],l=i,u=o;if(a)throw l=0,u=0,Gt(s);return n=l,t=u,qe(l,u)}finally{X.__wbindgen_add_to_stack_pointer(16),X.__wbindgen_free(n,t,1)}}addSnappedWaypoint(e,n){X.jsroutesnapper_addSnappedWaypoint(this.__wbg_ptr,e,n)}undo(){X.jsroutesnapper_undo(this.__wbg_ptr)}calculateRoute(e){let n,t;try{const f=X.__wbindgen_add_to_stack_pointer(-16);X.jsroutesnapper_calculateRoute(f,this.__wbg_ptr,ye(e));var i=ae()[f/4+0],o=ae()[f/4+1],s=ae()[f/4+2],a=ae()[f/4+3],l=i,u=o;if(a)throw l=0,u=0,Gt(s);return n=l,t=u,qe(l,u)}finally{X.__wbindgen_add_to_stack_pointer(16),X.__wbindgen_free(n,t,1)}}getExtraNodes(e,n){let t,i;try{const c=X.__wbindgen_add_to_stack_pointer(-16);X.jsroutesnapper_getExtraNodes(c,this.__wbg_ptr,ye(e),ye(n));var o=ae()[c/4+0],s=ae()[c/4+1],a=ae()[c/4+2],l=ae()[c/4+3],u=o,f=s;if(l)throw u=0,f=0,Gt(a);return t=u,i=f,qe(u,f)}finally{X.__wbindgen_add_to_stack_pointer(16),X.__wbindgen_free(t,i,1)}}}async function uu(r,e){if(typeof Response=="function"&&r instanceof Response){if(typeof WebAssembly.instantiateStreaming=="function")try{return await WebAssembly.instantiateStreaming(r,e)}catch(t){if(r.headers.get("Content-Type")!="application/wasm")console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n",t);else throw t}const n=await r.arrayBuffer();return await WebAssembly.instantiate(n,e)}else{const n=await WebAssembly.instantiate(r,e);return n instanceof WebAssembly.Instance?{instance:n,module:r}:n}}function fu(){const r={};return r.wbg={},r.wbg.__wbindgen_string_new=function(e,n){const t=qe(e,n);return ye(t)},r.wbg.__wbindgen_object_drop_ref=function(e){Gt(e)},r.wbg.__wbindgen_number_get=function(e,n){const t=oe(n),i=typeof t=="number"?t:void 0;su()[e/8+1]=cr(i)?0:i,ae()[e/4+0]=!cr(i)},r.wbg.__wbindgen_is_object=function(e){const n=oe(e);return typeof n=="object"&&n!==null},r.wbg.__wbindgen_is_undefined=function(e){return oe(e)===void 0},r.wbg.__wbindgen_in=function(e,n){return oe(e)in oe(n)},r.wbg.__wbindgen_boolean_get=function(e){const n=oe(e);return typeof n=="boolean"?n?1:0:2},r.wbg.__wbindgen_error_new=function(e,n){const t=new Error(qe(e,n));return ye(t)},r.wbg.__wbindgen_jsval_loose_eq=function(e,n){return oe(e)==oe(n)},r.wbg.__wbindgen_string_get=function(e,n){const t=oe(n),i=typeof t=="string"?t:void 0;var o=cr(i)?0:Sn(i,X.__wbindgen_malloc,X.__wbindgen_realloc),s=mt;ae()[e/4+1]=s,ae()[e/4+0]=o},r.wbg.__wbg_getwithrefkey_d1f0d12f1f1b63ea=function(e,n){const t=oe(e)[oe(n)];return ye(t)},r.wbg.__wbindgen_object_clone_ref=function(e){const n=oe(e);return ye(n)},r.wbg.__wbg_String_4370c5505c674d30=function(e,n){const t=String(oe(n)),i=Sn(t,X.__wbindgen_malloc,X.__wbindgen_realloc),o=mt;ae()[e/4+1]=o,ae()[e/4+0]=i},r.wbg.__wbg_new_abda76e883ba8a5f=function(){const e=new Error;return ye(e)},r.wbg.__wbg_stack_658279fe44541cf6=function(e,n){const t=oe(n).stack,i=Sn(t,X.__wbindgen_malloc,X.__wbindgen_realloc),o=mt;ae()[e/4+1]=o,ae()[e/4+0]=i},r.wbg.__wbg_error_f851667af71bcfc6=function(e,n){let t,i;try{t=e,i=n,console.error(qe(e,n))}finally{X.__wbindgen_free(t,i,1)}},r.wbg.__wbg_debug_9a6b3243fbbebb61=function(e){console.debug(oe(e))},r.wbg.__wbg_error_788ae33f81d3b84b=function(e){console.error(oe(e))},r.wbg.__wbg_info_2e30e8204b29d91d=function(e){console.info(oe(e))},r.wbg.__wbg_log_1d3ae0273d8f4f8a=function(e){console.log(oe(e))},r.wbg.__wbg_warn_d60e832f9882c1b2=function(e){console.warn(oe(e))},r.wbg.__wbg_get_44be0491f933a435=function(e,n){const t=oe(e)[n>>>0];return ye(t)},r.wbg.__wbg_length_fff51ee6522a1a18=function(e){return oe(e).length},r.wbg.__wbindgen_is_function=function(e){return typeof oe(e)=="function"},r.wbg.__wbg_next_526fc47e980da008=function(e){const n=oe(e).next;return ye(n)},r.wbg.__wbg_next_ddb3312ca1c4e32a=function(){return pr(function(e){const n=oe(e).next();return ye(n)},arguments)},r.wbg.__wbg_done_5c1f01fb660d73b5=function(e){return oe(e).done},r.wbg.__wbg_value_1695675138684bd5=function(e){const n=oe(e).value;return ye(n)},r.wbg.__wbg_iterator_97f0c81209c6c35a=function(){return ye(Symbol.iterator)},r.wbg.__wbg_get_97b561fb56f034b5=function(){return pr(function(e,n){const t=Reflect.get(oe(e),oe(n));return ye(t)},arguments)},r.wbg.__wbg_call_cb65541d95d71282=function(){return pr(function(e,n){const t=oe(e).call(oe(n));return ye(t)},arguments)},r.wbg.__wbg_isArray_4c24b343cb13cfb1=function(e){return Array.isArray(oe(e))},r.wbg.__wbg_instanceof_ArrayBuffer_39ac22089b74fddb=function(e){let n;try{n=oe(e)instanceof ArrayBuffer}catch{n=!1}return n},r.wbg.__wbg_buffer_085ec1f694018c4f=function(e){const n=oe(e).buffer;return ye(n)},r.wbg.__wbg_new_8125e318e6245eed=function(e){const n=new Uint8Array(oe(e));return ye(n)},r.wbg.__wbg_set_5cf90238115182c3=function(e,n,t){oe(e).set(oe(n),t>>>0)},r.wbg.__wbg_length_72e2208bbc0efc61=function(e){return oe(e).length},r.wbg.__wbg_instanceof_Uint8Array_d8d9cb2b8e8ac1d4=function(e){let n;try{n=oe(e)instanceof Uint8Array}catch{n=!1}return n},r.wbg.__wbindgen_debug_string=function(e,n){const t=Mr(oe(n)),i=Sn(t,X.__wbindgen_malloc,X.__wbindgen_realloc),o=mt;ae()[e/4+1]=o,ae()[e/4+0]=i},r.wbg.__wbindgen_throw=function(e,n){throw new Error(qe(e,n))},r.wbg.__wbindgen_memory=function(){const e=X.memory;return ye(e)},r}function cu(r,e){return X=r.exports,ys.__wbindgen_wasm_module=e,nn=null,rn=null,tn=null,X}async function ys(r){if(X!==void 0)return X;typeof r>"u"&&(r="/atip/move_draw_controls/assets/route_snapper_bg.wasm");const e=fu();(typeof r=="string"||typeof Request=="function"&&r instanceof Request||typeof URL=="function"&&r instanceof URL)&&(r=fetch(r));const{instance:n,module:t}=await uu(await r,e);return cu(n,t)}function pu(r,e,n){n===void 0&&(n={});var t={type:"Feature"};return(n.id===0||n.id)&&(t.id=n.id),n.bbox&&(t.bbox=n.bbox),t.properties=e||{},t.geometry=r,t}function mu(r,e,n){if(n===void 0&&(n={}),!r)throw new Error("coordinates is required");if(!Array.isArray(r))throw new Error("coordinates must be an Array");if(r.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!ji(r[0])||!ji(r[1]))throw new Error("coordinates must contain numbers");var t={type:"Point",coordinates:r};return pu(t,e,n)}function ji(r){return!isNaN(r)&&r!==null&&!Array.isArray(r)}function Pr(r,e){return e===void 0&&(e={}),ls(r,function(n,t){var i=t.geometry.coordinates;return n+ut(i[0],i[1],e)},0)}function du(r,e,n){n===void 0&&(n={});var t={type:"Feature"};return(n.id===0||n.id)&&(t.id=n.id),n.bbox&&(t.bbox=n.bbox),t.properties=e||{},t.geometry=r,t}function gu(r,e,n){if(n===void 0&&(n={}),r.length<2)throw new Error("coordinates must be an array of two or more positions");var t={type:"LineString",coordinates:r};return du(t,e,n)}function hu(r,e,n){var t=Ve(n);if(kr(n)!=="LineString")throw new Error("line must be a LineString");var i=Hn(n,r),o=Hn(n,e),s;i.properties.index<=o.properties.index?s=[i,o]:s=[o,i];for(var a=[s[0].geometry.coordinates],l=s[0].properties.index+1;l=s){var a=(n+i)/2;return[e,a-(t-e)/2,t,a+(t-e)/2]}else{var l=(e+t)/2;return[l-(i-n)/2,n,l+(i-n)/2,i]}}function Lr(r){var e=[1/0,1/0,-1/0,-1/0];return Ot(r,function(n){e[0]>n[0]&&(e[0]=n[0]),e[1]>n[1]&&(e[1]=n[1]),e[2] is required");if(typeof n!="number")throw new Error(" must be a number");if(typeof t!="number")throw new Error(" must be a number");(i===!1||i===void 0)&&(r=JSON.parse(JSON.stringify(r)));var o=Math.pow(10,n);return Ot(r,function(s){vu(s,o,t)}),r}function vu(r,e,n){r.length>n&&r.splice(n,r.length);for(var t=0;t1&&n.push(Ii(f)),fn(n)}function ws(r,e){if(!e.features.length)throw new Error("lines must contain features");if(e.features.length===1)return e.features[0];var n,t=1/0;return Xt(e,function(i){var o=Hn(i,r),s=o.properties.dist;s{if(!this.active)return;const a=[s.point.x-Su,s.point.y],l=this.map.unproject(s.point).distanceTo(this.map.unproject(a));this.inner.onMouseMove(s.lngLat.lng,s.lngLat.lat,l)&&(this.redraw(),this.dataUpdated())},this.onClick=()=>{this.active&&(this.inner.onClick(),this.redraw(),this.dataUpdated())},this.onDoubleClick=s=>{this.active&&(s.preventDefault(),this.inner.onClick(),this.finish())},this.onDragStart=()=>{this.active&&this.inner.onDragStart()&&this.map.dragPan.disable()},this.onMouseUp=()=>{this.active&&this.inner.onMouseUp()&&this.map.dragPan.enable()},this.onKeyDown=s=>{if(!this.active)return;let a=s.target.tagName;a=="INPUT"||a=="TEXTAREA"||s.key=="Escape"&&(s.stopPropagation(),this.cancel())},this.onKeyPress=s=>{if(!this.active)return;let a=s.target.tagName;a=="INPUT"||a=="TEXTAREA"||(s.key=="Enter"?(s.stopPropagation(),this.finish()):s.key=="s"||s.key=="S"?(s.stopPropagation(),this.inner.toggleSnapMode(),this.redraw()):s.key=="z"&&s.ctrlKey&&this.undo())},this.map=e,console.time("Deserialize and setup JsRouteSnapper"),this.inner=new Zn(n),console.timeEnd("Deserialize and setup JsRouteSnapper"),this.active=!1,this.eventListenersSuccess=[],this.eventListenersUpdated=[],this.eventListenersFailure=[],this.routeToolGj=t,this.snapMode=i,this.undoLength=o,this.map.on("mousemove",this.onMouseMove),this.map.on("click",this.onClick),this.map.on("dblclick",this.onDoubleClick),this.map.on("dragstart",this.onDragStart),this.map.on("mouseup",this.onMouseUp),document.addEventListener("keydown",this.onKeyDown),document.addEventListener("keypress",this.onKeyPress)}tearDown(){this.map.off("mousemove",this.onMouseMove),this.map.off("click",this.onClick),this.map.off("dblclick",this.onDoubleClick),this.map.off("dragstart",this.onDragStart),this.map.off("mouseup",this.onMouseUp),document.removeEventListener("keydown",this.onKeyDown),document.removeEventListener("keypress",this.onKeyPress)}startRoute(){this.active||(this.active=!0,this.map.boxZoom.disable(),this.map.doubleClickZoom.disable())}startArea(){this.active||(this.inner.setAreaMode(),this.active=!0,this.map.boxZoom.disable(),this.map.doubleClickZoom.disable())}stop(){this.active=!1,this.inner.clearState(),this.redraw(),this.map.boxZoom.enable(),this.map.doubleClickZoom.enable()}editExistingRoute(e){this.active&&window.alert("Bug: editExistingRoute called when tool is already active"),e.properties.waypoints||(e.properties.waypoints=[{lon:e.geometry.coordinates[0][0],lat:e.geometry.coordinates[0][1],snapped:!0},{lon:e.geometry.coordinates[e.geometry.coordinates.length-1][0],lat:e.geometry.coordinates[e.geometry.coordinates.length-1][1],snapped:!0}]),this.startRoute(),this.inner.editExisting(e.properties.waypoints),this.redraw()}editExistingArea(e){this.active&&window.alert("Bug: editExistingArea called when tool is already active"),e.properties.waypoints||window.alert("Bug: editExistingArea called for a polygon not produced by the route-snapper"),this.startArea(),this.inner.editExisting(e.properties.waypoints),this.redraw()}addEventListenerSuccess(e){this.eventListenersSuccess.push(e)}addEventListenerUpdated(e){this.eventListenersUpdated.push(e)}addEventListenerFailure(e){this.eventListenersFailure.push(e)}clearEventListeners(){this.eventListenersSuccess=[],this.eventListenersUpdated=[],this.eventListenersFailure=[]}isActive(){return this.active}finish(){let e=this.inner.toFinalFeature();if(e)for(let n of this.eventListenersSuccess)n(JSON.parse(e));else for(let n of this.eventListenersFailure)n();this.stop()}cancel(){this.inner.clearState(),this.finish()}setRouteConfig(e){this.inner.setRouteConfig(e),this.redraw()}addSnappedWaypoint(e){this.inner.addSnappedWaypoint(e[0],e[1]),this.redraw()}undo(){this.inner.undo(),this.redraw()}toggleSnapMode(){this.inner.toggleSnapMode(),this.redraw()}redraw(){let e=JSON.parse(this.inner.renderGeojson());this.routeToolGj.set(e),this.map.getCanvas().style.cursor=e.cursor,this.snapMode.set(e.snap_mode),this.undoLength.set(e.undo_length)}dataUpdated(){let e=this.inner.toFinalFeature();if(e)for(let n of this.eventListenersUpdated)n(JSON.parse(e))}}async function Mu(r,e){let n=await fetch(r),t=n.body.getReader(),i=n.headers.get("Content-Length");if(!i)throw new Error(`No Content-Length header from ${r}`);let o=parseInt(i),s=0,a=[];for(;;){let{done:f,value:c}=await t.read();if(f)break;c&&(a.push(c),s+=c.length,e(100*s/o))}let l=new Uint8Array(s),u=0;for(let f of a)l.set(f,u),u+=f.length;return l}/** +var xs=Object.defineProperty;var el=(r,e,n)=>e in r?xs(r,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):r[e]=n;var de=(r,e,n)=>(el(r,typeof e!="symbol"?e+"":e,n),n);import{S as re,i as ie,s as te,Q as Kt,e as q,b as J,c as y,T as Ht,U as Zt,V as Vt,t as b,q as $,d as w,W as Ft,j as P,p as L,v as C,X as At,E as Xe,f as _e,a as R,Y as Le,Z as he,y as z,o as G,P as be,_ as er,$ as Do,a0 as we,a1 as xr,a2 as Se,a3 as ei,a4 as ce,z as se,r as le,a5 as Uo,a6 as tl,w as W,a7 as We,a8 as nl,a9 as Ne,aa as rl,ab as il,n as Q,J as hn,ac as ol,ad as sl,ae as ll,af as al,ag as Ie,ah as Br,ai as qr,aj as ul,ak as zo,al as fl,am as Jo,an as cl,ao as pl,ap as ut,aq as ml,ar as dl,G as Mt,as as gl,at as Ee,au as pe,g as V,h as x,u as ne,m as ge,av as on,aw as sn,ax as kt,N as Ut,ay as jn,az as Ke,aA as ln,aB as Gr,aC as zt,aD as Ge,x as it,R as Pt,aE as ti,D as _t,aF as Lt,aG as pn,aH as tr,aI as ot,aJ as In,aK as hl,aL as _n,aM as nr,aN as ni,aO as ze,aP as gr,aQ as _l,aR as bl,aS as De,aT as Bn,aU as ri,aV as pt,aW as Yo,aX as vl,aY as ii,aZ as st,a_ as Nt,O as xe,a$ as Et,b0 as hr,b1 as $l,b2 as yl,I as wl,F as Xo,b3 as Tr,b4 as oi,b5 as kl,M as Sl,A as El,L as Ml,k as Pl,B as Ll,C as Cl,b6 as Fl}from"./index-8de582eb.js";import{M as _r,m as et,b as Wo,l as ue,R as Al,e as Jt,i as St,a as mn,c as dn,C as Yt,d as Nl,f as xt,S as Rl,H as Rt,g as Ol,h as Ko,j as Ct,k as rr,p as qn,n as jl,o as Il,t as Bl,r as si,W as Ho,q as ql,s as Gl,B as Tl,Z as Dl,G as Ul}from"./WarningIcon-4ae5d124.js";import{A as zl}from"./About-05c49103.js";function Jl(r){let e,n;const t=r[1].default,i=Kt(t,r,r[0],null);return{c(){e=q("div"),i&&i.c(),J(e,"class","govuk-button-group")},m(o,s){y(o,e,s),i&&i.m(e,null),n=!0},p(o,[s]){i&&i.p&&(!n||s&1)&&Ht(i,t,o,o[0],n?Vt(t,o[0],s,null):Zt(o[0]),null)},i(o){n||(b(i,o),n=!0)},o(o){$(i,o),n=!1},d(o){o&&w(e),i&&i.d(o)}}}function Yl(r,e,n){let{$$slots:t={},$$scope:i}=e;return r.$$set=o=>{"$$scope"in o&&n(0,i=o.$$scope)},[i,t]}class He extends re{constructor(e){super(),ie(this,e,Yl,Jl,te,{})}}function li(r){let e,n,t=Gn(r[0])+"",i;return{c(){e=q("div"),n=z("£"),i=z(t),J(e,"class","govuk-hint")},m(o,s){y(o,e,s),G(e,n),G(e,i)},p(o,s){s&1&&t!==(t=Gn(o[0])+"")&&be(i,t)},d(o){o&&w(e)}}}function Xl(r){let e;return{c(){e=z("multiply by 1 million")},m(n,t){y(n,e,t)},d(n){n&&w(e)}}}function Wl(r){let e,n,t,i,o,s,a,l,u;e=new Xe({props:{errorMessage:ai(r[2])}});let f=r[0]!=null&&li(r);return s=new _e({props:{disabled:r[0]==null||r[0]>1e3,$$slots:{default:[Xl]},$$scope:{ctx:r}}}),s.$on("click",r[4]),{c(){P(e.$$.fragment),n=R(),f&&f.c(),t=R(),i=q("input"),o=R(),P(s.$$.fragment),J(i,"type","text"),J(i,"inputmode","numeric"),J(i,"class","govuk-input govuk-input--width-10"),J(i,"id",r[3])},m(c,p){L(e,c,p),y(c,n,p),f&&f.m(c,p),y(c,t,p),y(c,i,p),Le(i,r[2]),y(c,o,p),L(s,c,p),a=!0,l||(u=he(i,"input",r[5]),l=!0)},p(c,p){const m={};p&4&&(m.errorMessage=ai(c[2])),e.$set(m),c[0]!=null?f?f.p(c,p):(f=li(c),f.c(),f.m(t.parentNode,t)):f&&(f.d(1),f=null),p&4&&i.value!==c[2]&&Le(i,c[2]);const g={};p&1&&(g.disabled=c[0]==null||c[0]>1e3),p&128&&(g.$$scope={dirty:p,ctx:c}),s.$set(g)},i(c){a||(b(e.$$.fragment,c),b(s.$$.fragment,c),a=!0)},o(c){$(e.$$.fragment,c),$(s.$$.fragment,c),a=!1},d(c){c&&(w(n),w(t),w(i),w(o)),C(e,c),f&&f.d(c),C(s,c),l=!1,u()}}}function Kl(r){let e,n;return e=new Ft({props:{label:r[1],id:r[3],$$slots:{default:[Wl]},$$scope:{ctx:r}}}),{c(){P(e.$$.fragment)},m(t,i){L(e,t,i),n=!0},p(t,[i]){const o={};i&2&&(o.label=t[1]),i&133&&(o.$$scope={dirty:i,ctx:t}),e.$set(o)},i(t){n||(b(e.$$.fragment,t),n=!0)},o(t){$(e.$$.fragment,t),n=!1},d(t){C(e,t)}}}function Zo(r){if(r!="")return parseFloat(r.replaceAll(",",""))}function ai(r){let e=Zo(r);return e==null?"":isNaN(e)?"Please enter a valid number":e<0?"Please enter a positive number":""}function Gn(r){return r.toLocaleString()}function Hl(r,e,n){let{label:t}=e,{value:i}=e,o=At(),s=i==null?"":Gn(i);function a(f){n(0,i=Zo(f))}function l(){n(2,s=Gn(i*1e6))}function u(){s=this.value,n(2,s)}return r.$$set=f=>{"label"in f&&n(1,t=f.label),"value"in f&&n(0,i=f.value)},r.$$.update=()=>{r.$$.dirty&4&&a(s)},[i,t,s,o,l,u]}class Zl extends re{constructor(e){super(),ie(this,e,Hl,Kl,te,{label:1,value:0})}}function Vl(r){let e,n,t,i,o,s,a;return e=new Xe({props:{errorMessage:r[5](r[2])}}),{c(){P(e.$$.fragment),n=R(),t=q("input"),J(t,"type","text"),J(t,"inputmode","numeric"),J(t,"class",i=`govuk-input govuk-input--width-${r[1]}`),J(t,"id",r[3])},m(l,u){L(e,l,u),y(l,n,u),y(l,t,u),Le(t,r[2]),o=!0,s||(a=[he(t,"input",r[9]),he(t,"change",r[4])],s=!0)},p(l,u){const f={};u&4&&(f.errorMessage=l[5](l[2])),e.$set(f),(!o||u&2&&i!==(i=`govuk-input govuk-input--width-${l[1]}`))&&J(t,"class",i),u&4&&t.value!==l[2]&&Le(t,l[2])},i(l){o||(b(e.$$.fragment,l),o=!0)},o(l){$(e.$$.fragment,l),o=!1},d(l){l&&(w(n),w(t)),C(e,l),s=!1,er(a)}}}function Ql(r){let e,n;return e=new Ft({props:{label:r[0],id:r[3],$$slots:{default:[Vl]},$$scope:{ctx:r}}}),{c(){P(e.$$.fragment)},m(t,i){L(e,t,i),n=!0},p(t,[i]){const o={};i&1&&(o.label=t[0]),i&1030&&(o.$$scope={dirty:i,ctx:t}),e.$set(o)},i(t){n||(b(e.$$.fragment,t),n=!0)},o(t){$(e.$$.fragment,t),n=!1},d(t){C(e,t)}}}function xl(r,e,n){let{label:t}=e,{value:i}=e,{width:o}=e,{min:s=void 0}=e,{max:a=void 0}=e,l=i==null?void 0:i.toString(),u=At();function f(){n(6,i=l==null?void 0:parseInt(l,10))}function c(m){if(m==""||m==null)return"";if(m.includes("."))return"Please enter a number without decimals";let g=Number(m);return isNaN(g)?"Please enter a valid number":s!=null&&ga?`Please enter a number that's at most ${a};`:""}function p(){l=this.value,n(2,l)}return r.$$set=m=>{"label"in m&&n(0,t=m.label),"value"in m&&n(6,i=m.value),"width"in m&&n(1,o=m.width),"min"in m&&n(7,s=m.min),"max"in m&&n(8,a=m.max)},[t,o,l,u,f,c,i,s,a,p]}class sr extends re{constructor(e){super(),ie(this,e,xl,Ql,te,{label:0,value:6,width:1,min:7,max:8})}}function ui(r){let e,n;return{c(){e=q("div"),n=z(r[2]),J(e,"class","govuk-hint")},m(t,i){y(t,e,i),G(e,n)},p(t,i){i&4&&be(n,t[2])},d(t){t&&w(e)}}}function ea(r){let e,n,t,i,o,s,a;e=new Xe({props:{errorMessage:r[4]}});let l=r[2]&&ui(r);return{c(){P(e.$$.fragment),n=R(),l&&l.c(),t=R(),i=q("textarea"),J(i,"class","govuk-textarea"),J(i,"id",r[5]),J(i,"rows",r[3])},m(u,f){L(e,u,f),y(u,n,f),l&&l.m(u,f),y(u,t,f),y(u,i,f),Le(i,r[0]),o=!0,s||(a=he(i,"input",r[6]),s=!0)},p(u,f){const c={};f&16&&(c.errorMessage=u[4]),e.$set(c),u[2]?l?l.p(u,f):(l=ui(u),l.c(),l.m(t.parentNode,t)):l&&(l.d(1),l=null),(!o||f&8)&&J(i,"rows",u[3]),f&1&&Le(i,u[0])},i(u){o||(b(e.$$.fragment,u),o=!0)},o(u){$(e.$$.fragment,u),o=!1},d(u){u&&(w(n),w(t),w(i)),C(e,u),l&&l.d(u),s=!1,a()}}}function ta(r){let e,n;return e=new Ft({props:{label:r[1],id:r[5],$$slots:{default:[ea]},$$scope:{ctx:r}}}),{c(){P(e.$$.fragment)},m(t,i){L(e,t,i),n=!0},p(t,[i]){const o={};i&2&&(o.label=t[1]),i&157&&(o.$$scope={dirty:i,ctx:t}),e.$set(o)},i(t){n||(b(e.$$.fragment,t),n=!0)},o(t){$(e.$$.fragment,t),n=!1},d(t){C(e,t)}}}function na(r,e,n){let{label:t}=e,{hint:i=""}=e,{value:o}=e,{rows:s=5}=e,{errorMessage:a=""}=e,l=At();function u(){o=this.value,n(0,o)}return r.$$set=f=>{"label"in f&&n(1,t=f.label),"hint"in f&&n(2,i=f.hint),"value"in f&&n(0,o=f.value),"rows"in f&&n(3,s=f.rows),"errorMessage"in f&&n(4,a=f.errorMessage)},[o,t,i,s,a,l,u]}class Dr extends re{constructor(e){super(),ie(this,e,na,ta,te,{label:1,hint:2,value:0,rows:3,errorMessage:4})}}function ra(r){let e,n,t,i,o,s;return e=new Xe({props:{errorMessage:r[2]}}),{c(){P(e.$$.fragment),n=R(),t=q("input"),J(t,"type","text"),J(t,"class","govuk-input"),J(t,"id",r[3])},m(a,l){L(e,a,l),y(a,n,l),y(a,t,l),Le(t,r[0]),i=!0,o||(s=[he(t,"input",r[6]),he(t,"change",r[5])],o=!0)},p(a,l){const u={};l&4&&(u.errorMessage=a[2]),e.$set(u),l&1&&t.value!==a[0]&&Le(t,a[0])},i(a){i||(b(e.$$.fragment,a),i=!0)},o(a){$(e.$$.fragment,a),i=!1},d(a){a&&(w(n),w(t)),C(e,a),o=!1,er(s)}}}function ia(r){let e,n;return e=new Ft({props:{label:r[1],id:r[3],$$slots:{default:[ra]},$$scope:{ctx:r}}}),{c(){P(e.$$.fragment)},m(t,i){L(e,t,i),n=!0},p(t,[i]){const o={};i&2&&(o.label=t[1]),i&133&&(o.$$scope={dirty:i,ctx:t}),e.$set(o)},i(t){n||(b(e.$$.fragment,t),n=!0)},o(t){$(e.$$.fragment,t),n=!1},d(t){C(e,t)}}}function oa(r,e,n){let t,{label:i}=e,{value:o}=e,{required:s=!1}=e,a=At();function l(f){Do.call(this,r,f)}function u(){o=this.value,n(0,o)}return r.$$set=f=>{"label"in f&&n(1,i=f.label),"value"in f&&n(0,o=f.value),"required"in f&&n(4,s=f.required)},r.$$.update=()=>{r.$$.dirty&17&&n(2,t=s&&(o==null||o=="")?"Required":"")},[o,i,t,a,s,l,u]}class ir extends re{constructor(e){super(),ie(this,e,oa,ia,te,{label:1,value:0,required:4})}}function sa(r){let e,n,t,i;const o=r[2].default,s=Kt(o,r,r[1],null);let a=[{type:"button"},{class:"govuk-button govuk-button--warning"},{"data-module":"govuk-button"},r[0]],l={};for(let u=0;u{n(0,e=we(we({},e),ei(s))),"$$scope"in s&&n(1,i=s.$$scope)},e=ei(e),[e,i,t,o]}class bt extends re{constructor(e){super(),ie(this,e,la,sa,te,{})}}function fi(r){let e=r[0],n,t,i=ci(r);return{c(){i.c(),n=ce()},m(o,s){i.m(o,s),y(o,n,s),t=!0},p(o,s){s&1&&te(e,e=o[0])?(se(),$(i,1,1,Q),le(),i=ci(o),i.c(),b(i,1),i.m(n.parentNode,n)):i.p(o,s)},i(o){t||(b(i),t=!0)},o(o){$(i),t=!1},d(o){o&&w(n),i.d(o)}}}function ci(r){let e;const n=r[10].default,t=Kt(n,r,r[9],null);return{c(){t&&t.c()},m(i,o){t&&t.m(i,o),e=!0},p(i,o){t&&t.p&&(!e||o&512)&&Ht(t,n,i,i[9],e?Vt(n,i[9],o,null):Zt(i[9]),null)},i(i){e||(b(t,i),e=!0)},o(i){$(t,i),e=!1},d(i){t&&t.d(i)}}}function aa(r){let e,n,t=r[0]&&fi(r);return{c(){t&&t.c(),e=ce()},m(i,o){t&&t.m(i,o),y(i,e,o),n=!0},p(i,[o]){i[0]?t?(t.p(i,o),o&1&&b(t,1)):(t=fi(i),t.c(),b(t,1),t.m(e.parentNode,e)):t&&(se(),$(t,1,1,()=>{t=null}),le())},i(i){n||(b(t),n=!0)},o(i){$(t),n=!1},d(i){i&&w(e),t&&t.d(i)}}}function ua(r,e,n){let t,i,{$$slots:o={},$$scope:s}=e,{id:a=Uo("image")}=e,{url:l}=e,{coordinates:u}=e;const{map:f,self:c}=tl();W(r,f,g=>n(8,i=g)),W(r,c,g=>n(0,t=g));let p,m=!0;return We(()=>{t&&i&&(nl(f,t,p),Ne(c,t=null,t),n(6,p=void 0))}),r.$$set=g=>{"id"in g&&n(3,a=g.id),"url"in g&&n(4,l=g.url),"coordinates"in g&&n(5,u=g.coordinates),"$$scope"in g&&n(9,s=g.$$scope)},r.$$.update=()=>{r.$$.dirty&313&&i&&t!==a&&(Ne(c,t=a,t),rl(i,t,il({type:"image",url:l,coordinates:u}),g=>i&&g===t,()=>{t&&(n(6,p=i==null?void 0:i.getSource(t)),n(7,m=!0))})),r.$$.dirty&264&&(i==null||i.on("style.load",()=>{n(6,p=i==null?void 0:i.getSource(a))})),r.$$.dirty&224&&p&&(m?n(7,m=!1):p.setCoordinates(u))},[t,f,c,a,l,u,p,m,i,s,o]}class fa extends re{constructor(e){super(),ie(this,e,ua,aa,te,{id:3,url:4,coordinates:5})}}class lr{constructor(){this._partials=new Float64Array(32),this._n=0}add(e){const n=this._partials;let t=0;for(let i=0;i0){for(s=e[--n];n>0&&(t=s,i=e[--n],s=t+i,o=i-(s-t),!o););n>0&&(o<0&&e[n-1]<0||o>0&&e[n-1]>0)&&(i=o*2,t=s+i,i==t-s&&(s=t))}return s}}var ca=1e-6,pi=1e-12,Ur=Math.PI,mi=Ur/2,di=180/Ur,tt=Ur/180,Vo=Math.atan2,nt=Math.cos,br=Math.hypot,rt=Math.sin,pa=Math.sqrt;function Qo(r){return r>1?mi:r<-1?-mi:Math.asin(r)}function ma(){}function Tn(r,e){r&&hi.hasOwnProperty(r.type)&&hi[r.type](r,e)}var gi={Feature:function(r,e){Tn(r.geometry,e)},FeatureCollection:function(r,e){for(var n=r.features,t=-1,i=n.length;++t({feature:r[0]&1024,position:r[0]&1026}),yi=r=>({feature:r[40],position:r[41]});function wi(r){let e=[],n=new ya,t,i,o=Ie(r[10]);const s=a=>a[40].id;for(let a=0;a=r[13]&&r[11]<=r[12]&&wi(r);return{c(){P(e.$$.fragment),n=R(),o&&o.c(),t=ce()},m(s,a){L(e,s,a),y(s,n,a),o&&o.m(s,a),y(s,t,a),i=!0},p(s,a){const l={};a[0]&32&&(l.minzoom=s[5]),a[0]&64&&(l.maxzoom=s[6]),e.$set(l),s[11]>=s[13]&&s[11]<=s[12]?o?(o.p(s,a),a[0]&14336&&b(o,1)):(o=wi(s),o.c(),b(o,1),o.m(t.parentNode,t)):o&&(se(),$(o,1,1,()=>{o=null}),le())},i(s){i||(b(e.$$.fragment,s),b(o),i=!0)},o(s){$(e.$$.fragment,s),$(o),i=!1},d(s){s&&(w(n),w(t)),C(e,s),o&&o.d(s)}}}function Ea(r,e,n){let t,i,o,s,a,l,u,{$$slots:f={},$$scope:c}=e;const{map:p,source:m,minzoom:g,maxzoom:v}=ol();W(r,p,H=>n(21,s=H)),W(r,m,H=>n(9,a=H)),W(r,g,H=>n(23,u=H)),W(r,v,H=>n(22,l=H));const k=sl();let{applyToClusters:M=void 0}=e,{filter:_=void 0}=e,{markerLngLat:h=$a}=e,{interactive:E=!0}=e,{asButton:d=!1}=e,{draggable:S=!1}=e,{minzoom:N=void 0}=e,{maxzoom:j=void 0}=e,{hovered:U=null}=e,{zIndex:B=void 0}=e,{class:O=void 0}=e,F=!1;function A(){s&&(F=!0,s.on("zoom",D),s.on("move",T),s.on("moveend",T),s.loaded()?s.once("load",T):T())}function I(H){H.sourceId===a&&H.isSourceLoaded&&(F?T():A())}We(()=>{s&&(s.off("zoom",D),s.off("move",T),s.off("moveend",T),s.off("sourcedata",I))});let K=[];function T(){var It;if(!s||!a)return;let H=s.querySourceFeatures(a,{filter:o}),ke=new Map;for(let Pe of H)Pe.id||((It=Pe.properties)!=null&&It.cluster_id?Pe.id="autocluster_"+Pe.properties.cluster_id:Pe.id=Uo("autofeat")),ke.set(Pe.id,Pe);n(10,K=[...ke.values()].sort((Pe,Qs)=>Pe.id.toString().localeCompare(Qs.id.toString())))}let ee=(s==null?void 0:s.getZoom())??0;function D(H){n(11,ee=s.getZoom()),T()}const fe=H=>{n(0,U=H)},me=H=>{(U==null?void 0:U.id)===H.id&&n(0,U=null)},ve=(H,ke)=>k("dragstart",{...ke.detail,source:a,feature:H}),$e=(H,ke)=>k("drag",{...ke.detail,source:a,feature:H}),yn=(H,ke)=>k("dragend",{...ke.detail,source:a,feature:H}),Y=(H,ke)=>k("click",{...ke.detail,source:a,feature:H}),Z=(H,ke)=>k("dblclick",{...ke.detail,source:a,feature:H}),Be=(H,ke)=>k("contextmenu",{...ke.detail,source:a,feature:H});return r.$$set=H=>{"applyToClusters"in H&&n(19,M=H.applyToClusters),"filter"in H&&n(20,_=H.filter),"markerLngLat"in H&&n(1,h=H.markerLngLat),"interactive"in H&&n(2,E=H.interactive),"asButton"in H&&n(3,d=H.asButton),"draggable"in H&&n(4,S=H.draggable),"minzoom"in H&&n(5,N=H.minzoom),"maxzoom"in H&&n(6,j=H.maxzoom),"hovered"in H&&n(0,U=H.hovered),"zIndex"in H&&n(7,B=H.zIndex),"class"in H&&n(8,O=H.class),"$$scope"in H&&n(33,c=H.$$scope)},r.$$.update=()=>{if(r.$$.dirty[0]&8388640&&n(13,t=N??u),r.$$.dirty[0]&4194368&&n(12,i=j??l),r.$$.dirty[0]&1572864&&(o=ll("all",al(M),_)),r.$$.dirty[0]&2097664&&s&&a){let H=s.getSource(a);H!=null&&H.loaded()?A():s.on("sourcedata",I)}},[U,h,E,d,S,N,j,B,O,a,K,ee,i,t,p,m,g,v,k,M,_,s,l,u,f,fe,me,ve,$e,yn,Y,Z,Be,c]}class Ma extends re{constructor(e){super(),ie(this,e,Ea,Sa,te,{applyToClusters:19,filter:20,markerLngLat:1,interactive:2,asButton:3,draggable:4,minzoom:5,maxzoom:6,hovered:0,zIndex:7,class:8},null,[-1,-1])}}class Pa{constructor(e){de(this,"map");de(this,"active");de(this,"eventListenersSuccess");de(this,"eventListenersFailure");de(this,"cursor");de(this,"onMouseMove",e=>{this.active&&(this.cursor={type:"Feature",properties:{},geometry:{type:"Point",coordinates:zo(e.lngLat.toArray())}})});de(this,"onClick",()=>{if(this.active&&this.cursor){for(let e of this.eventListenersSuccess)e(this.cursor);this.stop()}});de(this,"onKeyDown",e=>{this.active&&e.key=="Escape"&&(e.stopPropagation(),this.cancel())});this.map=e,this.active=!1,this.eventListenersSuccess=[],this.eventListenersFailure=[],this.cursor=null,this.map.on("mousemove",this.onMouseMove),this.map.on("click",this.onClick),document.addEventListener("keydown",this.onKeyDown)}tearDown(){this.map.off("mousemove",this.onMouseMove),this.map.off("click",this.onClick),document.removeEventListener("keydown",this.onKeyDown)}cancel(){for(let e of this.eventListenersFailure)e();this.stop()}addEventListenerSuccess(e){this.eventListenersSuccess.push(e)}addEventListenerFailure(e){this.eventListenersFailure.push(e)}clearEventListeners(){this.eventListenersSuccess=[],this.eventListenersFailure=[]}start(){this.map.getCanvas().style.cursor="crosshair",this.active=!0}stop(){this.map.getCanvas().style.cursor="inherit",this.cursor=null,this.active=!1}}function La(r){var e=r%(2*Math.PI);return e*180/Math.PI}function wn(r){var e=r%360;return e*Math.PI/180}function gt(r){if(!r)throw new Error("coord is required");if(!Array.isArray(r)){if(r.type==="Feature"&&r.geometry!==null&&r.geometry.type==="Point")return r.geometry.coordinates;if(r.type==="Point")return r.coordinates}if(Array.isArray(r)&&r.length>=2&&!Array.isArray(r[0])&&!Array.isArray(r[1]))return r;throw new Error("coord must be GeoJSON Point or an Array of numbers")}function Qe(r){if(Array.isArray(r))return r;if(r.type==="Feature"){if(r.geometry!==null)return r.geometry.coordinates}else if(r.coordinates)return r.coordinates;throw new Error("coords must be GeoJSON Feature, Geometry Object or an Array")}function kr(r,e){return r.type==="FeatureCollection"?"FeatureCollection":r.type==="GeometryCollection"?"GeometryCollection":r.type==="Feature"&&r.geometry!==null?r.geometry.type:r.type}function ns(r,e,n){if(n===void 0&&(n={}),n.final===!0)return Ca(r,e);var t=gt(r),i=gt(e),o=wn(t[0]),s=wn(i[0]),a=wn(t[1]),l=wn(i[1]),u=Math.sin(s-o)*Math.cos(l),f=Math.cos(a)*Math.sin(l)-Math.sin(a)*Math.cos(l)*Math.cos(s-o);return La(Math.atan2(u,f))}function Ca(r,e){var n=ns(e,r);return n=(n+180)%360,n}var Oe=63710088e-1,Fa={centimeters:Oe*100,centimetres:Oe*100,degrees:Oe/111325,feet:Oe*3.28084,inches:Oe*39.37,kilometers:Oe/1e3,kilometres:Oe/1e3,meters:Oe,metres:Oe,miles:Oe/1609.344,millimeters:Oe*1e3,millimetres:Oe*1e3,nauticalmiles:Oe/1852,radians:1,yards:Oe*1.0936};function Aa(r,e){e===void 0&&(e="kilometers");var n=Fa[e];if(!n)throw new Error(e+" units is invalid");return r*n}function kn(r){var e=r%360;return e*Math.PI/180}function ft(r,e,n){n===void 0&&(n={});var t=gt(r),i=gt(e),o=kn(i[1]-t[1]),s=kn(i[0]-t[0]),a=kn(t[1]),l=kn(i[1]),u=Math.pow(Math.sin(o/2),2)+Math.pow(Math.sin(s/2),2)*Math.cos(a)*Math.cos(l);return Aa(2*Math.atan2(Math.sqrt(u),Math.sqrt(1-u)),n.units)}var je=63710088e-1,Na={centimeters:je*100,centimetres:je*100,degrees:je/111325,feet:je*3.28084,inches:je*39.37,kilometers:je/1e3,kilometres:je/1e3,meters:je,metres:je,miles:je/1609.344,millimeters:je*1e3,millimetres:je*1e3,nauticalmiles:je/1852,radians:1,yards:je*1.0936};function Ra(r,e,n){n===void 0&&(n={});var t={type:"Feature"};return(n.id===0||n.id)&&(t.id=n.id),n.bbox&&(t.bbox=n.bbox),t.properties=e||{},t.geometry=r,t}function Oa(r,e,n){if(n===void 0&&(n={}),!r)throw new Error("coordinates is required");if(!Array.isArray(r))throw new Error("coordinates must be an Array");if(r.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!Ei(r[0])||!Ei(r[1]))throw new Error("coordinates must contain numbers");var t={type:"Point",coordinates:r};return Ra(t,e,n)}function ja(r,e){e===void 0&&(e="kilometers");var n=Na[e];if(!n)throw new Error(e+" units is invalid");return r/n}function Si(r){var e=r%(2*Math.PI);return e*180/Math.PI}function ar(r){var e=r%360;return e*Math.PI/180}function Ei(r){return!isNaN(r)&&r!==null&&!Array.isArray(r)}function Mi(r,e,n,t){t===void 0&&(t={});var i=gt(r),o=ar(i[0]),s=ar(i[1]),a=ar(n),l=ja(e,t.units),u=Math.asin(Math.sin(s)*Math.cos(l)+Math.cos(s)*Math.sin(l)*Math.cos(a)),f=o+Math.atan2(Math.sin(a)*Math.sin(l)*Math.cos(s),Math.cos(l)-Math.sin(s)*Math.sin(u)),c=Si(f),p=Si(u);return Oa([c,p],t.properties)}function Sr(r,e,n){n===void 0&&(n={});var t={type:"Feature"};return(n.id===0||n.id)&&(t.id=n.id),n.bbox&&(t.bbox=n.bbox),t.properties=e||{},t.geometry=r,t}function Ia(r,e,n){if(n===void 0&&(n={}),!r)throw new Error("coordinates is required");if(!Array.isArray(r))throw new Error("coordinates must be an Array");if(r.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!Li(r[0])||!Li(r[1]))throw new Error("coordinates must contain numbers");var t={type:"Point",coordinates:r};return Sr(t,e,n)}function Pi(r,e){e===void 0&&(e={});var n={type:"FeatureCollection"};return e.id&&(n.id=e.id),e.bbox&&(n.bbox=e.bbox),n.features=r,n}function Li(r){return!isNaN(r)&&r!==null&&!Array.isArray(r)}function Ba(r,e,n){n===void 0&&(n={});var t={type:"Feature"};return(n.id===0||n.id)&&(t.id=n.id),n.bbox&&(t.bbox=n.bbox),t.properties=e||{},t.geometry=r,t}function qa(r,e,n){if(n===void 0&&(n={}),r.length<2)throw new Error("coordinates must be an array of two or more positions");var t={type:"LineString",coordinates:r};return Ba(t,e,n)}function Ga(r,e){e===void 0&&(e={});var n={type:"FeatureCollection"};return e.id&&(n.id=e.id),e.bbox&&(n.bbox=e.bbox),n.features=r,n}function Kn(r,e,n){n===void 0&&(n={});var t={type:"Feature"};return(n.id===0||n.id)&&(t.id=n.id),n.bbox&&(t.bbox=n.bbox),t.properties=e||{},t.geometry=r,t}function Bt(r,e,n){if(n===void 0&&(n={}),!r)throw new Error("coordinates is required");if(!Array.isArray(r))throw new Error("coordinates must be an Array");if(r.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!Ci(r[0])||!Ci(r[1]))throw new Error("coordinates must contain numbers");var t={type:"Point",coordinates:r};return Kn(t,e,n)}function Dt(r,e,n){if(n===void 0&&(n={}),r.length<2)throw new Error("coordinates must be an array of two or more positions");var t={type:"LineString",coordinates:r};return Kn(t,e,n)}function Ci(r){return!isNaN(r)&&r!==null&&!Array.isArray(r)}function rs(r){return!!r&&r.constructor===Object}function Ot(r,e,n){if(r!==null)for(var t,i,o,s,a,l,u,f=0,c=0,p,m=r.type,g=m==="FeatureCollection",v=m==="Feature",k=g?r.features.length:1,M=0;Ml||g>u||v>f){a=c,l=t,u=g,f=v,o=0;return}var k=Dt([a,c],n.properties);if(e(k,t,i,v,o)===!1)return!1;o++,a=c})===!1)return!1}}})}function ls(r,e,n){var t=n,i=!1;return ss(r,function(o,s,a,l,u){i===!1&&n===void 0?t=o:t=e(t,o,s,a,l,u),i=!0}),t}function as(r,e){if(!r)throw new Error("geojson is required");jt(r,function(n,t,i){if(n.geometry!==null){var o=n.geometry.type,s=n.geometry.coordinates;switch(o){case"LineString":if(e(n,t,i,0,0)===!1)return!1;break;case"Polygon":for(var a=0;ai?n:i,u=t>o?t:o;return[s,a,l,u]}var Yr={exports:{}},us={exports:{}};(function(r,e){(function(n,t){r.exports=t()})(fl,function(){function n(_,h,E,d,S){(function N(j,U,B,O,F){for(;O>B;){if(O-B>600){var A=O-B+1,I=U-B+1,K=Math.log(A),T=.5*Math.exp(2*K/3),ee=.5*Math.sqrt(K*T*(A-T)/A)*(I-A/2<0?-1:1),D=Math.max(B,Math.floor(U-I*T/A+ee)),fe=Math.min(O,Math.floor(U+(A-I)*T/A+ee));N(j,U,D,fe,F)}var me=j[U],ve=B,$e=O;for(t(j,B,U),F(j[O],me)>0&&t(j,B,O);ve<$e;){for(t(j,ve,$e),ve++,$e--;F(j[ve],me)<0;)ve++;for(;F(j[$e],me)>0;)$e--}F(j[B],me)===0?t(j,B,$e):t(j,++$e,O),$e<=U&&(B=$e+1),U<=$e&&(O=$e-1)}})(_,h,E||0,d||_.length-1,S||i)}function t(_,h,E){var d=_[h];_[h]=_[E],_[E]=d}function i(_,h){return _h?1:0}var o=function(_){_===void 0&&(_=9),this._maxEntries=Math.max(4,_),this._minEntries=Math.max(2,Math.ceil(.4*this._maxEntries)),this.clear()};function s(_,h,E){if(!E)return h.indexOf(_);for(var d=0;d=_.minX&&h.maxY>=_.minY}function k(_){return{children:_,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function M(_,h,E,d,S){for(var N=[h,E];N.length;)if(!((E=N.pop())-(h=N.pop())<=d)){var j=h+Math.ceil((E-h)/d/2)*d;n(_,j,h,E,S),N.push(h,j,j,E)}}return o.prototype.all=function(){return this._all(this.data,[])},o.prototype.search=function(_){var h=this.data,E=[];if(!v(_,h))return E;for(var d=this.toBBox,S=[];h;){for(var N=0;N=0&&S[h].children.length>this._maxEntries;)this._split(S,h),h--;this._adjustParentBBoxes(d,S,h)},o.prototype._split=function(_,h){var E=_[h],d=E.children.length,S=this._minEntries;this._chooseSplitAxis(E,S,d);var N=this._chooseSplitIndex(E,S,d),j=k(E.children.splice(N,E.children.length-N));j.height=E.height,j.leaf=E.leaf,a(E,this.toBBox),a(j,this.toBBox),h?_[h-1].children.push(j):this._splitRoot(E,j)},o.prototype._splitRoot=function(_,h){this.data=k([_,h]),this.data.height=_.height+1,this.data.leaf=!1,a(this.data,this.toBBox)},o.prototype._chooseSplitIndex=function(_,h,E){for(var d,S,N,j,U,B,O,F=1/0,A=1/0,I=h;I<=E-h;I++){var K=l(_,0,I,this.toBBox),T=l(_,I,E,this.toBBox),ee=(S=K,N=T,j=void 0,U=void 0,B=void 0,O=void 0,j=Math.max(S.minX,N.minX),U=Math.max(S.minY,N.minY),B=Math.min(S.maxX,N.maxX),O=Math.min(S.maxY,N.maxY),Math.max(0,B-j)*Math.max(0,O-U)),D=p(K)+p(T);ee=h;F--){var A=_.children[F];u(j,_.leaf?S(A):A),U+=m(j)}return U},o.prototype._adjustParentBBoxes=function(_,h,E){for(var d=E;d>=0;d--)u(h[d],_)},o.prototype._condense=function(_){for(var h=_.length-1,E=void 0;h>=0;h--)_[h].children.length===0?h>0?(E=_[h-1].children).splice(E.indexOf(_[h]),1):this.clear():a(_[h],this.toBBox)},o})})(us);var Qa=us.exports,fs={};(function(r){Object.defineProperty(r,"__esModule",{value:!0}),r.earthRadius=63710088e-1,r.factors={centimeters:r.earthRadius*100,centimetres:r.earthRadius*100,degrees:r.earthRadius/111325,feet:r.earthRadius*3.28084,inches:r.earthRadius*39.37,kilometers:r.earthRadius/1e3,kilometres:r.earthRadius/1e3,meters:r.earthRadius,metres:r.earthRadius,miles:r.earthRadius/1609.344,millimeters:r.earthRadius*1e3,millimetres:r.earthRadius*1e3,nauticalmiles:r.earthRadius/1852,radians:1,yards:r.earthRadius*1.0936},r.unitsFactors={centimeters:100,centimetres:100,degrees:1/111325,feet:3.28084,inches:39.37,kilometers:1/1e3,kilometres:1/1e3,meters:1,metres:1,miles:1/1609.344,millimeters:1e3,millimetres:1e3,nauticalmiles:1/1852,radians:1/r.earthRadius,yards:1.0936133},r.areaFactors={acres:247105e-9,centimeters:1e4,centimetres:1e4,feet:10.763910417,hectares:1e-4,inches:1550.003100006,kilometers:1e-6,kilometres:1e-6,meters:1,metres:1,miles:386e-9,millimeters:1e6,millimetres:1e6,yards:1.195990046};function e(O,F,A){A===void 0&&(A={});var I={type:"Feature"};return(A.id===0||A.id)&&(I.id=A.id),A.bbox&&(I.bbox=A.bbox),I.properties=F||{},I.geometry=O,I}r.feature=e;function n(O,F,A){switch(O){case"Point":return t(F).geometry;case"LineString":return a(F).geometry;case"Polygon":return o(F).geometry;case"MultiPoint":return c(F).geometry;case"MultiLineString":return f(F).geometry;case"MultiPolygon":return p(F).geometry;default:throw new Error(O+" is invalid")}}r.geometry=n;function t(O,F,A){if(A===void 0&&(A={}),!O)throw new Error("coordinates is required");if(!Array.isArray(O))throw new Error("coordinates must be an Array");if(O.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!N(O[0])||!N(O[1]))throw new Error("coordinates must contain numbers");var I={type:"Point",coordinates:O};return e(I,F,A)}r.point=t;function i(O,F,A){return A===void 0&&(A={}),u(O.map(function(I){return t(I,F)}),A)}r.points=i;function o(O,F,A){A===void 0&&(A={});for(var I=0,K=O;I=0))throw new Error("precision must be a positive number");var A=Math.pow(10,F||0);return Math.round(O*A)/A}r.round=g;function v(O,F){F===void 0&&(F="kilometers");var A=r.factors[F];if(!A)throw new Error(F+" units is invalid");return O*A}r.radiansToLength=v;function k(O,F){F===void 0&&(F="kilometers");var A=r.factors[F];if(!A)throw new Error(F+" units is invalid");return O/A}r.lengthToRadians=k;function M(O,F){return h(k(O,F))}r.lengthToDegrees=M;function _(O){var F=O%360;return F<0&&(F+=360),F}r.bearingToAzimuth=_;function h(O){var F=O%(2*Math.PI);return F*180/Math.PI}r.radiansToDegrees=h;function E(O){var F=O%360;return F*Math.PI/180}r.degreesToRadians=E;function d(O,F,A){if(F===void 0&&(F="kilometers"),A===void 0&&(A="kilometers"),!(O>=0))throw new Error("length must be a positive number");return v(k(O,F),A)}r.convertLength=d;function S(O,F,A){if(F===void 0&&(F="meters"),A===void 0&&(A="kilometers"),!(O>=0))throw new Error("area must be a positive number");var I=r.areaFactors[F];if(!I)throw new Error("invalid original units");var K=r.areaFactors[A];if(!K)throw new Error("invalid final units");return O/I*K}r.convertArea=S;function N(O){return!isNaN(O)&&O!==null&&!Array.isArray(O)}r.isNumber=N;function j(O){return!!O&&O.constructor===Object}r.isObject=j;function U(O){if(!O)throw new Error("bbox is required");if(!Array.isArray(O))throw new Error("bbox must be an Array");if(O.length!==4&&O.length!==6)throw new Error("bbox must be an Array of 4 or 6 numbers");O.forEach(function(F){if(!N(F))throw new Error("bbox must only contain numbers")})}r.validateBBox=U;function B(O){if(!O)throw new Error("id is required");if(["string","number"].indexOf(typeof O)===-1)throw new Error("id must be a number or a string")}r.validateId=B})(fs);const xa=Jo(Ka),eu=Jo(cl);var Ze=Qa,cs=fs,ps=xa,qt=eu.default,tu=ps.featureEach;ps.coordEach;cs.polygon;var Fi=cs.featureCollection;function ms(r){var e=new Ze(r);return e.insert=function(n){if(n.type!=="Feature")throw new Error("invalid feature");return n.bbox=n.bbox?n.bbox:qt(n),Ze.prototype.insert.call(this,n)},e.load=function(n){var t=[];return Array.isArray(n)?n.forEach(function(i){if(i.type!=="Feature")throw new Error("invalid features");i.bbox=i.bbox?i.bbox:qt(i),t.push(i)}):tu(n,function(i){if(i.type!=="Feature")throw new Error("invalid features");i.bbox=i.bbox?i.bbox:qt(i),t.push(i)}),Ze.prototype.load.call(this,t)},e.remove=function(n,t){if(n.type!=="Feature")throw new Error("invalid feature");return n.bbox=n.bbox?n.bbox:qt(n),Ze.prototype.remove.call(this,n,t)},e.clear=function(){return Ze.prototype.clear.call(this)},e.search=function(n){var t=Ze.prototype.search.call(this,this.toBBox(n));return Fi(t)},e.collides=function(n){return Ze.prototype.collides.call(this,this.toBBox(n))},e.all=function(){var n=Ze.prototype.all.call(this);return Fi(n)},e.toJSON=function(){return Ze.prototype.toJSON.call(this)},e.fromJSON=function(n){return Ze.prototype.fromJSON.call(this,n)},e.toBBox=function(n){var t;if(n.bbox)t=n.bbox;else if(Array.isArray(n)&&n.length===4)t=n;else if(Array.isArray(n)&&n.length===6)t=[n[0],n[1],n[3],n[4]];else if(n.type==="Feature")t=qt(n);else if(n.type==="FeatureCollection")t=qt(n);else throw new Error("invalid geojson");return{minX:t[0],minY:t[1],maxX:t[2],maxY:t[3]}},e}Yr.exports=ms;Yr.exports.default=ms;var nu=Yr.exports;const Xr=pl(nu);function ds(r,e){var n={},t=[];if(r.type==="LineString"&&(r=Sr(r)),e.type==="LineString"&&(e=Sr(e)),r.type==="Feature"&&e.type==="Feature"&&r.geometry!==null&&e.geometry!==null&&r.geometry.type==="LineString"&&e.geometry.type==="LineString"&&r.geometry.coordinates.length===2&&e.geometry.coordinates.length===2){var i=Ai(r,e);return i&&t.push(i),Pi(t)}var o=Xr();return o.load(Er(e)),Xt(Er(r),function(s){Xt(o.search(s),function(a){var l=Ai(s,a);if(l){var u=Qe(l).join(",");n[u]||(n[u]=!0,t.push(l))}})}),Pi(t)}function Ai(r,e){var n=Qe(r),t=Qe(e);if(n.length!==2)throw new Error(" line1 must only contain 2 coordinates");if(t.length!==2)throw new Error(" line2 must only contain 2 coordinates");var i=n[0][0],o=n[0][1],s=n[1][0],a=n[1][1],l=t[0][0],u=t[0][1],f=t[1][0],c=t[1][1],p=(c-u)*(s-i)-(f-l)*(a-o),m=(f-l)*(o-u)-(c-u)*(i-l),g=(s-i)*(o-u)-(a-o)*(i-l);if(p===0)return null;var v=m/p,k=g/p;if(v>=0&&v<=1&&k>=0&&k<=1){var M=i+v*(s-i),_=o+v*(a-o);return Ia([M,_])}return null}function gs(r,e,n){n===void 0&&(n={});var t={type:"Feature"};return(n.id===0||n.id)&&(t.id=n.id),n.bbox&&(t.bbox=n.bbox),t.properties=e||{},t.geometry=r,t}function ur(r,e,n){if(n===void 0&&(n={}),!r)throw new Error("coordinates is required");if(!Array.isArray(r))throw new Error("coordinates must be an Array");if(r.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!Ri(r[0])||!Ri(r[1]))throw new Error("coordinates must contain numbers");var t={type:"Point",coordinates:r};return gs(t,e,n)}function Ni(r,e,n){if(n===void 0&&(n={}),r.length<2)throw new Error("coordinates must be an array of two or more positions");var t={type:"LineString",coordinates:r};return gs(t,e,n)}function Ri(r){return!isNaN(r)&&r!==null&&!Array.isArray(r)}function Hn(r,e,n){n===void 0&&(n={});var t=ur([1/0,1/0],{dist:1/0}),i=0;return jt(r,function(o){for(var s=Qe(o),a=0;a0&&(k=v.features[0],k.properties.dist=ft(e,k,n),k.properties.location=i+ft(l,k,n)),l.properties.dist{if(this.active&&!this.dragFrom)this.recalculateHovering(e);else if(this.active&&this.dragFrom){if(this.hover=="polygon"){let n=this.dragFrom[0]-e.lngLat.lng,t=this.dragFrom[1]-e.lngLat.lat;for(let i of this.points)i[0]-=n,i[1]-=t}else this.points[this.hover]=e.lngLat.toArray();this.dragFrom=e.lngLat.toArray(),this.redraw()}});de(this,"onClick",e=>{if(this.beforeUpdate(),this.active&&this.cursor){let n=[];if(Oi(this.points).forEach((t,i)=>{n.push([i+1,Hn(t,this.cursor).properties.dist])}),n.sort((t,i)=>t[1]-i[1]),n.length>0){let t=n[0][0];this.points.splice(t,0,this.cursor.geometry.coordinates),this.hover=t}else this.points.push(this.cursor.geometry.coordinates),this.hover=this.points.length-1;this.redraw(),this.pointsUpdated()}else this.active&&typeof this.hover=="number"&&(this.points.splice(this.hover,1),this.hover=null,this.redraw(),this.pointsUpdated(),this.recalculateHovering(e))});de(this,"onDoubleClick",e=>{this.active&&(e.preventDefault(),this.cursor=fr(e.lngLat.toArray()),this.onClick(e),this.finish())});de(this,"onMouseDown",e=>{this.active&&!this.dragFrom&&this.hover!=null&&(e.preventDefault(),this.cursor=null,this.dragFrom=e.lngLat.toArray(),this.beforeUpdate(),this.redraw())});de(this,"onMouseUp",()=>{this.active&&this.dragFrom&&(this.dragFrom=null,this.redraw(),this.pointsUpdated())});de(this,"onKeypress",e=>{this.active&&(e.key=="Enter"?(e.stopPropagation(),this.finish()):e.key=="z"&&e.ctrlKey&&this.undo())});de(this,"onKeyDown",e=>{this.active&&e.key=="Escape"&&(e.stopPropagation(),this.cancel())});this.map=e,this.active=!1,this.eventListenersSuccess=[],this.eventListenersUpdated=[],this.eventListenersFailure=[],this.points=[],this.cursor=null,this.hover=null,this.dragFrom=null,this.previousStates=[],this.map.on("mousemove",this.onMouseMove),this.map.on("click",this.onClick),this.map.on("dblclick",this.onDoubleClick),this.map.on("mousedown",this.onMouseDown),this.map.on("mouseup",this.onMouseUp),document.addEventListener("keypress",this.onKeypress),document.addEventListener("keydown",this.onKeyDown)}tearDown(){this.map.off("mousemove",this.onMouseMove),this.map.off("click",this.onClick),this.map.off("dblclick",this.onDoubleClick),this.map.off("mousedown",this.onMouseDown),this.map.off("mouseup",this.onMouseUp),document.removeEventListener("keypress",this.onKeypress),document.removeEventListener("keydown",this.onKeyDown)}finish(){let e=this.polygonFeature();if(e)for(let n of this.eventListenersSuccess)n(e);else for(let n of this.eventListenersFailure)n();this.stop()}cancel(){for(let e of this.eventListenersFailure)e();this.stop()}addEventListenerSuccess(e){this.eventListenersSuccess.push(e)}addEventListenerUpdated(e){this.eventListenersUpdated.push(e)}addEventListenerFailure(e){this.eventListenersFailure.push(e)}clearEventListeners(){this.eventListenersSuccess=[],this.eventListenersUpdated=[],this.eventListenersFailure=[]}startNew(){this.active=!0,this.map.doubleClickZoom.disable()}editExisting(e){this.active=!0,this.map.doubleClickZoom.disable(),this.points=JSON.parse(JSON.stringify(e.geometry.coordinates[0])),this.points.pop(),this.redraw()}stop(){this.map.doubleClickZoom.enable(),this.points=[],this.cursor=null,this.active=!1,this.hover=null,this.dragFrom=null,this.previousStates=[],this.redraw(),this.map.getCanvas().style.cursor="inherit"}undo(){this.dragFrom!=null||this.previousStates.length==0||(this.points=this.previousStates.pop(),this.hover=null,this.redraw())}redraw(){let e=hs();this.points.forEach((i,o)=>{let s=fr(i);s.properties.hover=this.hover==o,s.properties.idx=o,e.features.push(s)}),e.features=e.features.concat(Oi(this.points));let n=this.polygonFeature();n&&(n.properties.hover=this.hover=="polygon",e.features.push(n)),bs.set(e);let t="crosshair";this.hover!=null&&(t=this.dragFrom?"grabbing":"pointer"),this.map.getCanvas().style.cursor=t,vs.set(this.previousStates.length)}pointsUpdated(){let e=this.polygonFeature();if(e)for(let n of this.eventListenersUpdated)n(e)}recalculateHovering(e){this.cursor=null,this.hover=null;for(let n of this.map.queryRenderedFeatures(e.point,{layers:["edit-polygon-fill","edit-polygon-vertices"]}))if(n.geometry.type=="Polygon"){this.hover="polygon";break}else if(n.geometry.type=="Point"&&Object.hasOwn(n.properties,"idx")){this.hover=n.properties.idx;break}this.hover==null&&(this.cursor=fr(e.lngLat.toArray())),this.redraw()}polygonFeature(){if(this.points.length<3)return null;let e=this.points.map(_s),n=[JSON.parse(JSON.stringify(e))];return n[0].push(JSON.parse(JSON.stringify(n[0][0]))),{type:"Feature",geometry:{type:"Polygon",coordinates:n},properties:{}}}beforeUpdate(){this.previousStates.push(JSON.parse(JSON.stringify(this.points))),this.previousStates.length>ru&&this.previousStates.shift()}}function Oi(r){let e=[];for(let n=0;n=3&&e.push({type:"Feature",geometry:{type:"LineString",coordinates:[r[r.length-1],r[0]]},properties:{}}),e}let X;const $s=typeof TextDecoder<"u"?new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}):{decode:()=>{throw Error("TextDecoder not available")}};typeof TextDecoder<"u"&&$s.decode();let tn=null;function an(){return(tn===null||tn.byteLength===0)&&(tn=new Uint8Array(X.memory.buffer)),tn}function qe(r,e){return r=r>>>0,$s.decode(an().subarray(r,r+e))}const at=new Array(128).fill(void 0);at.push(void 0,null,!0,!1);let un=at.length;function ye(r){un===at.length&&at.push(at.length+1);const e=un;return un=at[e],at[e]=r,e}function oe(r){return at[r]}function ou(r){r<132||(at[r]=un,un=r)}function Gt(r){const e=oe(r);return ou(r),e}function cr(r){return r==null}let nn=null;function su(){return(nn===null||nn.byteLength===0)&&(nn=new Float64Array(X.memory.buffer)),nn}let rn=null;function ae(){return(rn===null||rn.byteLength===0)&&(rn=new Int32Array(X.memory.buffer)),rn}let mt=0;const Cn=typeof TextEncoder<"u"?new TextEncoder("utf-8"):{encode:()=>{throw Error("TextEncoder not available")}},lu=typeof Cn.encodeInto=="function"?function(r,e){return Cn.encodeInto(r,e)}:function(r,e){const n=Cn.encode(r);return e.set(n),{read:r.length,written:n.length}};function Sn(r,e,n){if(n===void 0){const a=Cn.encode(r),l=e(a.length,1)>>>0;return an().subarray(l,l+a.length).set(a),mt=a.length,l}let t=r.length,i=e(t,1)>>>0;const o=an();let s=0;for(;s127)break;o[i+s]=a}if(s!==t){s!==0&&(r=r.slice(s)),i=n(i,t,t=s+r.length*3,1)>>>0;const a=an().subarray(i+s,i+t),l=lu(r,a);s+=l.written}return mt=s,i}function Mr(r){const e=typeof r;if(e=="number"||e=="boolean"||r==null)return`${r}`;if(e=="string")return`"${r}"`;if(e=="symbol"){const i=r.description;return i==null?"Symbol":`Symbol(${i})`}if(e=="function"){const i=r.name;return typeof i=="string"&&i.length>0?`Function(${i})`:"Function"}if(Array.isArray(r)){const i=r.length;let o="[";i>0&&(o+=Mr(r[0]));for(let s=1;s1)t=n[1];else return toString.call(r);if(t=="Object")try{return"Object("+JSON.stringify(r)+")"}catch{return"Object"}return r instanceof Error?`${r.name}: ${r.message} +${r.stack}`:t}function au(r,e){const n=e(r.length*1,1)>>>0;return an().set(r,n/1),mt=r.length,n}function pr(r,e){try{return r.apply(this,e)}catch(n){X.__wbindgen_exn_store(ye(n))}}class Zn{static __wrap(e){e=e>>>0;const n=Object.create(Zn.prototype);return n.__wbg_ptr=e,n}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,e}free(){const e=this.__destroy_into_raw();X.__wbg_jsroutesnapper_free(e)}constructor(e){try{const o=X.__wbindgen_add_to_stack_pointer(-16),s=au(e,X.__wbindgen_malloc),a=mt;X.jsroutesnapper_new(o,s,a);var n=ae()[o/4+0],t=ae()[o/4+1],i=ae()[o/4+2];if(i)throw Gt(t);return Zn.__wrap(n)}finally{X.__wbindgen_add_to_stack_pointer(16)}}setRouteConfig(e){X.jsroutesnapper_setRouteConfig(this.__wbg_ptr,ye(e))}setAreaMode(){X.jsroutesnapper_setAreaMode(this.__wbg_ptr)}getConfig(){let e,n;try{const o=X.__wbindgen_add_to_stack_pointer(-16);X.jsroutesnapper_getConfig(o,this.__wbg_ptr);var t=ae()[o/4+0],i=ae()[o/4+1];return e=t,n=i,qe(t,i)}finally{X.__wbindgen_add_to_stack_pointer(16),X.__wbindgen_free(e,n,1)}}toFinalFeature(){try{const t=X.__wbindgen_add_to_stack_pointer(-16);X.jsroutesnapper_toFinalFeature(t,this.__wbg_ptr);var e=ae()[t/4+0],n=ae()[t/4+1];let i;return e!==0&&(i=qe(e,n).slice(),X.__wbindgen_free(e,n*1)),i}finally{X.__wbindgen_add_to_stack_pointer(16)}}renderGeojson(){let e,n;try{const o=X.__wbindgen_add_to_stack_pointer(-16);X.jsroutesnapper_renderGeojson(o,this.__wbg_ptr);var t=ae()[o/4+0],i=ae()[o/4+1];return e=t,n=i,qe(t,i)}finally{X.__wbindgen_add_to_stack_pointer(16),X.__wbindgen_free(e,n,1)}}toggleSnapMode(){X.jsroutesnapper_toggleSnapMode(this.__wbg_ptr)}onMouseMove(e,n,t){return X.jsroutesnapper_onMouseMove(this.__wbg_ptr,e,n,t)!==0}onClick(){X.jsroutesnapper_onClick(this.__wbg_ptr)}onDragStart(){return X.jsroutesnapper_onDragStart(this.__wbg_ptr)!==0}onMouseUp(){return X.jsroutesnapper_onMouseUp(this.__wbg_ptr)!==0}clearState(){X.jsroutesnapper_clearState(this.__wbg_ptr)}editExisting(e){try{const i=X.__wbindgen_add_to_stack_pointer(-16);X.jsroutesnapper_editExisting(i,this.__wbg_ptr,ye(e));var n=ae()[i/4+0],t=ae()[i/4+1];if(t)throw Gt(n)}finally{X.__wbindgen_add_to_stack_pointer(16)}}debugRenderGraph(){let e,n;try{const o=X.__wbindgen_add_to_stack_pointer(-16);X.jsroutesnapper_debugRenderGraph(o,this.__wbg_ptr);var t=ae()[o/4+0],i=ae()[o/4+1];return e=t,n=i,qe(t,i)}finally{X.__wbindgen_add_to_stack_pointer(16),X.__wbindgen_free(e,n,1)}}debugSnappableNodes(){let e,n;try{const o=X.__wbindgen_add_to_stack_pointer(-16);X.jsroutesnapper_debugSnappableNodes(o,this.__wbg_ptr);var t=ae()[o/4+0],i=ae()[o/4+1];return e=t,n=i,qe(t,i)}finally{X.__wbindgen_add_to_stack_pointer(16),X.__wbindgen_free(e,n,1)}}routeNameForWaypoints(e){let n,t;try{const f=X.__wbindgen_add_to_stack_pointer(-16);X.jsroutesnapper_routeNameForWaypoints(f,this.__wbg_ptr,ye(e));var i=ae()[f/4+0],o=ae()[f/4+1],s=ae()[f/4+2],a=ae()[f/4+3],l=i,u=o;if(a)throw l=0,u=0,Gt(s);return n=l,t=u,qe(l,u)}finally{X.__wbindgen_add_to_stack_pointer(16),X.__wbindgen_free(n,t,1)}}addSnappedWaypoint(e,n){X.jsroutesnapper_addSnappedWaypoint(this.__wbg_ptr,e,n)}undo(){X.jsroutesnapper_undo(this.__wbg_ptr)}calculateRoute(e){let n,t;try{const f=X.__wbindgen_add_to_stack_pointer(-16);X.jsroutesnapper_calculateRoute(f,this.__wbg_ptr,ye(e));var i=ae()[f/4+0],o=ae()[f/4+1],s=ae()[f/4+2],a=ae()[f/4+3],l=i,u=o;if(a)throw l=0,u=0,Gt(s);return n=l,t=u,qe(l,u)}finally{X.__wbindgen_add_to_stack_pointer(16),X.__wbindgen_free(n,t,1)}}getExtraNodes(e,n){let t,i;try{const c=X.__wbindgen_add_to_stack_pointer(-16);X.jsroutesnapper_getExtraNodes(c,this.__wbg_ptr,ye(e),ye(n));var o=ae()[c/4+0],s=ae()[c/4+1],a=ae()[c/4+2],l=ae()[c/4+3],u=o,f=s;if(l)throw u=0,f=0,Gt(a);return t=u,i=f,qe(u,f)}finally{X.__wbindgen_add_to_stack_pointer(16),X.__wbindgen_free(t,i,1)}}}async function uu(r,e){if(typeof Response=="function"&&r instanceof Response){if(typeof WebAssembly.instantiateStreaming=="function")try{return await WebAssembly.instantiateStreaming(r,e)}catch(t){if(r.headers.get("Content-Type")!="application/wasm")console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n",t);else throw t}const n=await r.arrayBuffer();return await WebAssembly.instantiate(n,e)}else{const n=await WebAssembly.instantiate(r,e);return n instanceof WebAssembly.Instance?{instance:n,module:r}:n}}function fu(){const r={};return r.wbg={},r.wbg.__wbindgen_string_new=function(e,n){const t=qe(e,n);return ye(t)},r.wbg.__wbindgen_object_drop_ref=function(e){Gt(e)},r.wbg.__wbindgen_number_get=function(e,n){const t=oe(n),i=typeof t=="number"?t:void 0;su()[e/8+1]=cr(i)?0:i,ae()[e/4+0]=!cr(i)},r.wbg.__wbindgen_is_object=function(e){const n=oe(e);return typeof n=="object"&&n!==null},r.wbg.__wbindgen_is_undefined=function(e){return oe(e)===void 0},r.wbg.__wbindgen_in=function(e,n){return oe(e)in oe(n)},r.wbg.__wbindgen_boolean_get=function(e){const n=oe(e);return typeof n=="boolean"?n?1:0:2},r.wbg.__wbindgen_error_new=function(e,n){const t=new Error(qe(e,n));return ye(t)},r.wbg.__wbindgen_jsval_loose_eq=function(e,n){return oe(e)==oe(n)},r.wbg.__wbindgen_string_get=function(e,n){const t=oe(n),i=typeof t=="string"?t:void 0;var o=cr(i)?0:Sn(i,X.__wbindgen_malloc,X.__wbindgen_realloc),s=mt;ae()[e/4+1]=s,ae()[e/4+0]=o},r.wbg.__wbg_getwithrefkey_d1f0d12f1f1b63ea=function(e,n){const t=oe(e)[oe(n)];return ye(t)},r.wbg.__wbindgen_object_clone_ref=function(e){const n=oe(e);return ye(n)},r.wbg.__wbg_String_4370c5505c674d30=function(e,n){const t=String(oe(n)),i=Sn(t,X.__wbindgen_malloc,X.__wbindgen_realloc),o=mt;ae()[e/4+1]=o,ae()[e/4+0]=i},r.wbg.__wbg_new_abda76e883ba8a5f=function(){const e=new Error;return ye(e)},r.wbg.__wbg_stack_658279fe44541cf6=function(e,n){const t=oe(n).stack,i=Sn(t,X.__wbindgen_malloc,X.__wbindgen_realloc),o=mt;ae()[e/4+1]=o,ae()[e/4+0]=i},r.wbg.__wbg_error_f851667af71bcfc6=function(e,n){let t,i;try{t=e,i=n,console.error(qe(e,n))}finally{X.__wbindgen_free(t,i,1)}},r.wbg.__wbg_debug_9a6b3243fbbebb61=function(e){console.debug(oe(e))},r.wbg.__wbg_error_788ae33f81d3b84b=function(e){console.error(oe(e))},r.wbg.__wbg_info_2e30e8204b29d91d=function(e){console.info(oe(e))},r.wbg.__wbg_log_1d3ae0273d8f4f8a=function(e){console.log(oe(e))},r.wbg.__wbg_warn_d60e832f9882c1b2=function(e){console.warn(oe(e))},r.wbg.__wbg_get_44be0491f933a435=function(e,n){const t=oe(e)[n>>>0];return ye(t)},r.wbg.__wbg_length_fff51ee6522a1a18=function(e){return oe(e).length},r.wbg.__wbindgen_is_function=function(e){return typeof oe(e)=="function"},r.wbg.__wbg_next_526fc47e980da008=function(e){const n=oe(e).next;return ye(n)},r.wbg.__wbg_next_ddb3312ca1c4e32a=function(){return pr(function(e){const n=oe(e).next();return ye(n)},arguments)},r.wbg.__wbg_done_5c1f01fb660d73b5=function(e){return oe(e).done},r.wbg.__wbg_value_1695675138684bd5=function(e){const n=oe(e).value;return ye(n)},r.wbg.__wbg_iterator_97f0c81209c6c35a=function(){return ye(Symbol.iterator)},r.wbg.__wbg_get_97b561fb56f034b5=function(){return pr(function(e,n){const t=Reflect.get(oe(e),oe(n));return ye(t)},arguments)},r.wbg.__wbg_call_cb65541d95d71282=function(){return pr(function(e,n){const t=oe(e).call(oe(n));return ye(t)},arguments)},r.wbg.__wbg_isArray_4c24b343cb13cfb1=function(e){return Array.isArray(oe(e))},r.wbg.__wbg_instanceof_ArrayBuffer_39ac22089b74fddb=function(e){let n;try{n=oe(e)instanceof ArrayBuffer}catch{n=!1}return n},r.wbg.__wbg_buffer_085ec1f694018c4f=function(e){const n=oe(e).buffer;return ye(n)},r.wbg.__wbg_new_8125e318e6245eed=function(e){const n=new Uint8Array(oe(e));return ye(n)},r.wbg.__wbg_set_5cf90238115182c3=function(e,n,t){oe(e).set(oe(n),t>>>0)},r.wbg.__wbg_length_72e2208bbc0efc61=function(e){return oe(e).length},r.wbg.__wbg_instanceof_Uint8Array_d8d9cb2b8e8ac1d4=function(e){let n;try{n=oe(e)instanceof Uint8Array}catch{n=!1}return n},r.wbg.__wbindgen_debug_string=function(e,n){const t=Mr(oe(n)),i=Sn(t,X.__wbindgen_malloc,X.__wbindgen_realloc),o=mt;ae()[e/4+1]=o,ae()[e/4+0]=i},r.wbg.__wbindgen_throw=function(e,n){throw new Error(qe(e,n))},r.wbg.__wbindgen_memory=function(){const e=X.memory;return ye(e)},r}function cu(r,e){return X=r.exports,ys.__wbindgen_wasm_module=e,nn=null,rn=null,tn=null,X}async function ys(r){if(X!==void 0)return X;typeof r>"u"&&(r="/atip/move_draw_controls/assets/route_snapper_bg.wasm");const e=fu();(typeof r=="string"||typeof Request=="function"&&r instanceof Request||typeof URL=="function"&&r instanceof URL)&&(r=fetch(r));const{instance:n,module:t}=await uu(await r,e);return cu(n,t)}function pu(r,e,n){n===void 0&&(n={});var t={type:"Feature"};return(n.id===0||n.id)&&(t.id=n.id),n.bbox&&(t.bbox=n.bbox),t.properties=e||{},t.geometry=r,t}function mu(r,e,n){if(n===void 0&&(n={}),!r)throw new Error("coordinates is required");if(!Array.isArray(r))throw new Error("coordinates must be an Array");if(r.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!ji(r[0])||!ji(r[1]))throw new Error("coordinates must contain numbers");var t={type:"Point",coordinates:r};return pu(t,e,n)}function ji(r){return!isNaN(r)&&r!==null&&!Array.isArray(r)}function Pr(r,e){return e===void 0&&(e={}),ls(r,function(n,t){var i=t.geometry.coordinates;return n+ft(i[0],i[1],e)},0)}function du(r,e,n){n===void 0&&(n={});var t={type:"Feature"};return(n.id===0||n.id)&&(t.id=n.id),n.bbox&&(t.bbox=n.bbox),t.properties=e||{},t.geometry=r,t}function gu(r,e,n){if(n===void 0&&(n={}),r.length<2)throw new Error("coordinates must be an array of two or more positions");var t={type:"LineString",coordinates:r};return du(t,e,n)}function hu(r,e,n){var t=Qe(n);if(kr(n)!=="LineString")throw new Error("line must be a LineString");var i=Hn(n,r),o=Hn(n,e),s;i.properties.index<=o.properties.index?s=[i,o]:s=[o,i];for(var a=[s[0].geometry.coordinates],l=s[0].properties.index+1;l=s){var a=(n+i)/2;return[e,a-(t-e)/2,t,a+(t-e)/2]}else{var l=(e+t)/2;return[l-(i-n)/2,n,l+(i-n)/2,i]}}function Lr(r){var e=[1/0,1/0,-1/0,-1/0];return Ot(r,function(n){e[0]>n[0]&&(e[0]=n[0]),e[1]>n[1]&&(e[1]=n[1]),e[2] is required");if(typeof n!="number")throw new Error(" must be a number");if(typeof t!="number")throw new Error(" must be a number");(i===!1||i===void 0)&&(r=JSON.parse(JSON.stringify(r)));var o=Math.pow(10,n);return Ot(r,function(s){vu(s,o,t)}),r}function vu(r,e,n){r.length>n&&r.splice(n,r.length);for(var t=0;t1&&n.push(Ii(f)),fn(n)}function ws(r,e){if(!e.features.length)throw new Error("lines must contain features");if(e.features.length===1)return e.features[0];var n,t=1/0;return Xt(e,function(i){var o=Hn(i,r),s=o.properties.dist;s{if(!this.active)return;const a=[s.point.x-Su,s.point.y],l=this.map.unproject(s.point).distanceTo(this.map.unproject(a));this.inner.onMouseMove(s.lngLat.lng,s.lngLat.lat,l)&&(this.redraw(),this.dataUpdated())},this.onClick=()=>{this.active&&(this.inner.onClick(),this.redraw(),this.dataUpdated())},this.onDoubleClick=s=>{this.active&&(s.preventDefault(),this.inner.onClick(),this.finish())},this.onDragStart=()=>{this.active&&this.inner.onDragStart()&&this.map.dragPan.disable()},this.onMouseUp=()=>{this.active&&this.inner.onMouseUp()&&this.map.dragPan.enable()},this.onKeyDown=s=>{if(!this.active)return;let a=s.target.tagName;a=="INPUT"||a=="TEXTAREA"||s.key=="Escape"&&(s.stopPropagation(),this.cancel())},this.onKeyPress=s=>{if(!this.active)return;let a=s.target.tagName;a=="INPUT"||a=="TEXTAREA"||(s.key=="Enter"?(s.stopPropagation(),this.finish()):s.key=="s"||s.key=="S"?(s.stopPropagation(),this.inner.toggleSnapMode(),this.redraw()):s.key=="z"&&s.ctrlKey&&this.undo())},this.map=e,console.time("Deserialize and setup JsRouteSnapper"),this.inner=new Zn(n),console.timeEnd("Deserialize and setup JsRouteSnapper"),this.active=!1,this.eventListenersSuccess=[],this.eventListenersUpdated=[],this.eventListenersFailure=[],this.routeToolGj=t,this.snapMode=i,this.undoLength=o,this.map.on("mousemove",this.onMouseMove),this.map.on("click",this.onClick),this.map.on("dblclick",this.onDoubleClick),this.map.on("dragstart",this.onDragStart),this.map.on("mouseup",this.onMouseUp),document.addEventListener("keydown",this.onKeyDown),document.addEventListener("keypress",this.onKeyPress)}tearDown(){this.map.off("mousemove",this.onMouseMove),this.map.off("click",this.onClick),this.map.off("dblclick",this.onDoubleClick),this.map.off("dragstart",this.onDragStart),this.map.off("mouseup",this.onMouseUp),document.removeEventListener("keydown",this.onKeyDown),document.removeEventListener("keypress",this.onKeyPress)}startRoute(){this.active||(this.active=!0,this.map.boxZoom.disable(),this.map.doubleClickZoom.disable())}startArea(){this.active||(this.inner.setAreaMode(),this.active=!0,this.map.boxZoom.disable(),this.map.doubleClickZoom.disable())}stop(){this.active=!1,this.inner.clearState(),this.redraw(),this.map.boxZoom.enable(),this.map.doubleClickZoom.enable()}editExistingRoute(e){this.active&&window.alert("Bug: editExistingRoute called when tool is already active"),e.properties.waypoints||(e.properties.waypoints=[{lon:e.geometry.coordinates[0][0],lat:e.geometry.coordinates[0][1],snapped:!0},{lon:e.geometry.coordinates[e.geometry.coordinates.length-1][0],lat:e.geometry.coordinates[e.geometry.coordinates.length-1][1],snapped:!0}]),this.startRoute(),this.inner.editExisting(e.properties.waypoints),this.redraw()}editExistingArea(e){this.active&&window.alert("Bug: editExistingArea called when tool is already active"),e.properties.waypoints||window.alert("Bug: editExistingArea called for a polygon not produced by the route-snapper"),this.startArea(),this.inner.editExisting(e.properties.waypoints),this.redraw()}addEventListenerSuccess(e){this.eventListenersSuccess.push(e)}addEventListenerUpdated(e){this.eventListenersUpdated.push(e)}addEventListenerFailure(e){this.eventListenersFailure.push(e)}clearEventListeners(){this.eventListenersSuccess=[],this.eventListenersUpdated=[],this.eventListenersFailure=[]}isActive(){return this.active}finish(){let e=this.inner.toFinalFeature();if(e)for(let n of this.eventListenersSuccess)n(JSON.parse(e));else for(let n of this.eventListenersFailure)n();this.stop()}cancel(){this.inner.clearState(),this.finish()}setRouteConfig(e){this.inner.setRouteConfig(e),this.redraw()}addSnappedWaypoint(e){this.inner.addSnappedWaypoint(e[0],e[1]),this.redraw()}undo(){this.inner.undo(),this.redraw()}toggleSnapMode(){this.inner.toggleSnapMode(),this.redraw()}redraw(){let e=JSON.parse(this.inner.renderGeojson());this.routeToolGj.set(e),this.map.getCanvas().style.cursor=e.cursor,this.snapMode.set(e.snap_mode),this.undoLength.set(e.undo_length)}dataUpdated(){let e=this.inner.toFinalFeature();if(e)for(let n of this.eventListenersUpdated)n(JSON.parse(e))}}async function Mu(r,e){let n=await fetch(r),t=n.body.getReader(),i=n.headers.get("Content-Length");if(!i)throw new Error(`No Content-Length header from ${r}`);let o=parseInt(i),s=0,a=[];for(;;){let{done:f,value:c}=await t.read();if(f)break;c&&(a.push(c),s+=c.length,e(100*s/o))}let l=new Uint8Array(s),u=0;for(let f of a)l.set(f,u),u+=f.length;return l}/** * splaytree v3.1.1 * Fast Splay tree for Node and browser * @@ -19,9 +19,9 @@ MERCHANTABLITY OR NON-INFRINGEMENT. See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. -***************************************************************************** */function Pu(r,e){var n={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},t,i,o,s;return s={next:a(0),throw:a(1),return:a(2)},typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function a(u){return function(f){return l([u,f])}}function l(u){if(t)throw new TypeError("Generator is already executing.");for(;n;)try{if(t=1,i&&(o=u[0]&2?i.return:u[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,u[1])).done)return o;switch(i=0,o&&(u=[u[0]&2,o.value]),u[0]){case 0:case 1:o=u;break;case 4:return n.label++,{value:u[1],done:!1};case 5:n.label++,i=u[1],u=[0];continue;case 7:u=n.ops.pop(),n.trys.pop();continue;default:if(o=n.trys,!(o=o.length>0&&o[o.length-1])&&(u[0]===6||u[0]===2)){n=0;continue}if(u[0]===3&&(!o||u[1]>o[0]&&u[1]e?1:r0){if(e.right===null)break;if(n(r,e.right.key)>0){var a=e.right;if(e.right=a.left,a.left=e,e=a,e.right===null)break}i.right=e,i=e,e=e.right}else break}return i.right=e.left,o.left=e.right,e.left=t.right,e.right=t.left,e}function dr(r,e,n,t){var i=new ht(r,e);if(n===null)return i.left=i.right=null,i;n=ft(r,n,t);var o=t(r,n.key);return o<0?(i.left=n.left,i.right=n,n.left=null):o>=0&&(i.right=n.right,i.left=n,n.right=null),i}function Ti(r,e,n){var t=null,i=null;if(e){e=ft(r,e,n);var o=n(e.key,r);o===0?(t=e.left,i=e.right):o<0?(i=e.right,e.right=null,t=e):(t=e.left,e.left=null,i=e)}return{left:t,right:i}}function Fu(r,e,n){return e===null?r:(r===null||(e=ft(r.key,e,n),e.left=r),e)}function Cr(r,e,n,t,i){if(r){t(""+e+(n?"└── ":"├── ")+i(r)+` -`);var o=e+(n?" ":"│ ");r.left&&Cr(r.left,o,!1,t,i),r.right&&Cr(r.right,o,!0,t,i)}}var Wr=function(){function r(e){e===void 0&&(e=Lu),this._root=null,this._size=0,this._comparator=e}return r.prototype.insert=function(e,n){return this._size++,this._root=dr(e,n,this._root,this._comparator)},r.prototype.add=function(e,n){var t=new ht(e,n);this._root===null&&(t.left=t.right=null,this._size++,this._root=t);var i=this._comparator,o=ft(e,this._root,i),s=i(e,o.key);return s===0?this._root=o:(s<0?(t.left=o.left,t.right=o,o.left=null):s>0&&(t.right=o.right,t.left=o,o.right=null),this._size++,this._root=t),this._root},r.prototype.remove=function(e){this._root=this._remove(e,this._root,this._comparator)},r.prototype._remove=function(e,n,t){var i;if(n===null)return null;n=ft(e,n,t);var o=t(e,n.key);return o===0?(n.left===null?i=n.right:(i=ft(e,n.left,t),i.right=n.right),this._size--,i):n},r.prototype.pop=function(){var e=this._root;if(e){for(;e.left;)e=e.left;return this._root=ft(e.key,this._root,this._comparator),this._root=this._remove(e.key,this._root,this._comparator),{key:e.key,data:e.data}}return null},r.prototype.findStatic=function(e){for(var n=this._root,t=this._comparator;n;){var i=t(e,n.key);if(i===0)return n;i<0?n=n.left:n=n.right}return null},r.prototype.find=function(e){return this._root&&(this._root=ft(e,this._root,this._comparator),this._comparator(e,this._root.key)!==0)?null:this._root},r.prototype.contains=function(e){for(var n=this._root,t=this._comparator;n;){var i=t(e,n.key);if(i===0)return!0;i<0?n=n.left:n=n.right}return!1},r.prototype.forEach=function(e,n){for(var t=this._root,i=[],o=!1;!o;)t!==null?(i.push(t),t=t.left):i.length!==0?(t=i.pop(),e.call(n,t),t=t.right):o=!0;return this},r.prototype.range=function(e,n,t,i){for(var o=[],s=this._comparator,a=this._root,l;o.length!==0||a;)if(a)o.push(a),a=a.left;else{if(a=o.pop(),l=s(a.key,n),l>0)break;if(s(a.key,e)>=0&&t.call(i,a))return this;a=a.right}return this},r.prototype.keys=function(){var e=[];return this.forEach(function(n){var t=n.key;return e.push(t)}),e},r.prototype.values=function(){var e=[];return this.forEach(function(n){var t=n.data;return e.push(t)}),e},r.prototype.min=function(){return this._root?this.minNode(this._root).key:null},r.prototype.max=function(){return this._root?this.maxNode(this._root).key:null},r.prototype.minNode=function(e){if(e===void 0&&(e=this._root),e)for(;e.left;)e=e.left;return e},r.prototype.maxNode=function(e){if(e===void 0&&(e=this._root),e)for(;e.right;)e=e.right;return e},r.prototype.at=function(e){for(var n=this._root,t=!1,i=0,o=[];!t;)if(n)o.push(n),n=n.left;else if(o.length>0){if(n=o.pop(),i===e)return n;i++,n=n.right}else t=!0;return null},r.prototype.next=function(e){var n=this._root,t=null;if(e.right){for(t=e.right;t.left;)t=t.left;return t}for(var i=this._comparator;n;){var o=i(e.key,n.key);if(o===0)break;o<0?(t=n,n=n.left):n=n.right}return t},r.prototype.prev=function(e){var n=this._root,t=null;if(e.left!==null){for(t=e.left;t.right;)t=t.right;return t}for(var i=this._comparator;n;){var o=i(e.key,n.key);if(o===0)break;o<0?n=n.left:(t=n,n=n.right)}return t},r.prototype.clear=function(){return this._root=null,this._size=0,this},r.prototype.toList=function(){return Au(this._root)},r.prototype.load=function(e,n,t){n===void 0&&(n=[]),t===void 0&&(t=!1);var i=e.length,o=this._comparator;if(t&&Rr(e,n,0,i-1,o),this._root===null)this._root=Ar(e,n,0,i),this._size=i;else{var s=Nu(this.toList(),Cu(e,n),o);i=this._size+i,this._root=Nr({head:s},0,i)}return this},r.prototype.isEmpty=function(){return this._root===null},Object.defineProperty(r.prototype,"size",{get:function(){return this._size},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"root",{get:function(){return this._root},enumerable:!0,configurable:!0}),r.prototype.toString=function(e){e===void 0&&(e=function(t){return String(t.key)});var n=[];return Cr(this._root,"",!0,function(t){return n.push(t)},e),n.join("")},r.prototype.update=function(e,n,t){var i=this._comparator,o=Ti(e,this._root,i),s=o.left,a=o.right;i(e,n)<0?a=dr(n,t,a,i):s=dr(n,t,s,i),this._root=Fu(s,a,i)},r.prototype.split=function(e){return Ti(e,this._root,this._comparator)},r.prototype[Symbol.iterator]=function(){var e;return Pu(this,function(n){switch(n.label){case 0:e=this.minNode(),n.label=1;case 1:return e?[4,e]:[3,3];case 2:return n.sent(),e=this.next(e),[3,1];case 3:return[2]}})},r}();function Ar(r,e,n,t){var i=t-n;if(i>0){var o=n+Math.floor(i/2),s=r[o],a=e[o],l=new ht(s,a);return l.left=Ar(r,e,n,o),l.right=Ar(r,e,o+1,t),l}return null}function Cu(r,e){for(var n=new ht(null,null),t=n,i=0;i0?(e=o=o.next=n.pop(),e=e.right):t=!0;return o.next=null,i.next}function Nr(r,e,n){var t=n-e;if(t>0){var i=e+Math.floor(t/2),o=Nr(r,e,i),s=r.head;return s.left=o,r.head=r.head.next,s.right=Nr(r,i+1,n),s}return null}function Nu(r,e,n){for(var t=new ht(null,null),i=t,o=r,s=e;o!==null&&s!==null;)n(o.key,s.key)<0?(i.next=o,o=o.next):(i.next=s,s=s.next),i=i.next;return o!==null?i.next=o:s!==null&&(i.next=s),t.next}function Rr(r,e,n,t,i){if(!(n>=t)){for(var o=r[n+t>>1],s=n-1,a=t+1;;){do s++;while(i(r[s],o)<0);do a--;while(i(r[a],o)>0);if(s>=a)break;var l=r[s];r[s]=r[a],r[a]=l,l=e[s],e[s]=e[a],e[a]=l}Rr(r,e,n,a,i),Rr(r,e,a+1,t,i)}}function Ge(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}function Ui(r,e){for(var n=0;nt.x?1:n.yt.y?1:0}}]);function r(e,n){Ge(this,r),e.events===void 0?e.events=[this]:e.events.push(this),this.point=e,this.isLeft=n}return Ne(r,[{key:"link",value:function(n){if(n.point===this.point)throw new Error("Tried to link already linked events");for(var t=n.point.events,i=0,o=t.length;i=0&&p>=0?fm?-1:0:u<0&&p<0?fm?1:0:pu?1:0}}}]),r}(),qu=0,Qn=function(){Ne(r,null,[{key:"compare",value:function(n,t){var i=n.leftSE.point.x,o=t.leftSE.point.x,s=n.rightSE.point.x,a=t.rightSE.point.x;if(al&&u>f)return-1;var p=n.comparePoint(t.leftSE.point);if(p<0)return 1;if(p>0)return-1;var m=t.comparePoint(n.rightSE.point);return m!==0?m:-1}if(i>o){if(lu&&l>c)return 1;var g=t.comparePoint(n.leftSE.point);if(g!==0)return g;var v=n.comparePoint(t.rightSE.point);return v<0?1:v>0?-1:1}if(lu)return 1;if(sa){var k=n.comparePoint(t.rightSE.point);if(k<0)return 1;if(k>0)return-1}if(s!==a){var b=f-l,h=s-i,M=c-u,d=a-o;if(b>h&&Md)return-1}return s>a?1:sc?1:n.idt.id?1:0}}]);function r(e,n,t,i){Ge(this,r),this.id=++qu,this.leftSE=e,e.segment=this,e.otherSE=n,this.rightSE=n,n.segment=this,n.otherSE=e,this.rings=t,this.windings=i}return Ne(r,[{key:"replaceRightSE",value:function(n){this.rightSE=n,this.rightSE.segment=this,this.rightSE.otherSE=this.leftSE,this.leftSE.otherSE=this.rightSE}},{key:"bbox",value:function(){var n=this.leftSE.point.y,t=this.rightSE.point.y;return{ll:{x:this.leftSE.point.x,y:nt?n:t}}}},{key:"vector",value:function(){return{x:this.rightSE.point.x-this.leftSE.point.x,y:this.rightSE.point.y-this.leftSE.point.y}}},{key:"isAnEndpoint",value:function(n){return n.x===this.leftSE.point.x&&n.y===this.leftSE.point.y||n.x===this.rightSE.point.x&&n.y===this.rightSE.point.y}},{key:"comparePoint",value:function(n){if(this.isAnEndpoint(n))return 0;var t=this.leftSE.point,i=this.rightSE.point,o=this.vector();if(t.x===i.x)return n.x===t.x?0:n.x0&&l.swapEvents(),Ze.comparePoints(this.leftSE.point,this.rightSE.point)>0&&this.swapEvents(),i&&(o.checkForConsuming(),s.checkForConsuming()),t}},{key:"swapEvents",value:function(){var n=this.rightSE;this.rightSE=this.leftSE,this.leftSE=n,this.leftSE.isLeft=!0,this.rightSE.isLeft=!1;for(var t=0,i=this.windings.length;t0){var s=t;t=i,i=s}if(t.prev===i){var a=t;t=i,i=a}for(var l=0,u=i.rings.length;l0)o=t,s=n,a=-1;else throw new Error("Tried to create degenerate segment at [".concat(n.x,", ").concat(n.y,"]"));var u=new Ze(o,!0),f=new Ze(s,!1);return new r(u,f,[i],[a])}}]),r}(),Xi=function(){function r(e,n,t){if(Ge(this,r),!Array.isArray(e)||e.length===0)throw new Error("Input geometry is not a valid Polygon or MultiPolygon");if(this.poly=n,this.isExterior=t,this.segments=[],typeof e[0][0]!="number"||typeof e[0][1]!="number")throw new Error("Input geometry is not a valid Polygon or MultiPolygon");var i=gn.round(e[0][0],e[0][1]);this.bbox={ll:{x:i.x,y:i.y},ur:{x:i.x,y:i.y}};for(var o=i,s=1,a=e.length;sthis.bbox.ur.x&&(this.bbox.ur.x=l.x),l.y>this.bbox.ur.y&&(this.bbox.ur.y=l.y),o=l)}(i.x!==o.x||i.y!==o.y)&&this.segments.push(Qn.fromRing(o,i,this))}return Ne(r,[{key:"getSweepEvents",value:function(){for(var n=[],t=0,i=this.segments.length;tthis.bbox.ur.x&&(this.bbox.ur.x=o.bbox.ur.x),o.bbox.ur.y>this.bbox.ur.y&&(this.bbox.ur.y=o.bbox.ur.y),this.interiorRings.push(o)}this.multiPoly=n}return Ne(r,[{key:"getSweepEvents",value:function(){for(var n=this.exteriorRing.getSweepEvents(),t=0,i=this.interiorRings.length;tthis.bbox.ur.x&&(this.bbox.ur.x=o.bbox.ur.x),o.bbox.ur.y>this.bbox.ur.y&&(this.bbox.ur.y=o.bbox.ur.y),this.polys.push(o)}this.isSubject=n}return Ne(r,[{key:"getSweepEvents",value:function(){for(var n=[],t=0,i=this.polys.length;t0&&(n=o)}for(var s=n.segment.prevInResult(),a=s?s.prevInResult():null;;){if(!s)return null;if(!a)return s.ringOut;if(a.ringOut!==s.ringOut)return a.ringOut.enclosingRing()!==s.ringOut?s.ringOut:s.ringOut.enclosingRing();s=a.prevInResult(),a=s?s.prevInResult():null}}}]),r}(),Ki=function(){function r(e){Ge(this,r),this.exteriorRing=e,e.poly=this,this.interiorRings=[]}return Ne(r,[{key:"addInterior",value:function(n){this.interiorRings.push(n),n.poly=this}},{key:"getGeom",value:function(){var n=[this.exteriorRing.getGeom()];if(n[0]===null)return null;for(var t=0,i=this.interiorRings.length;t1&&arguments[1]!==void 0?arguments[1]:Qn.compare;Ge(this,r),this.queue=e,this.tree=new Wr(n),this.segments=[]}return Ne(r,[{key:"process",value:function(n){var t=n.segment,i=[];if(n.consumedBy)return n.isLeft?this.queue.remove(n.otherSE):this.tree.remove(t),i;var o=n.isLeft?this.tree.insert(t):this.tree.find(t);if(!o)throw new Error("Unable to find segment #".concat(t.id," ")+"[".concat(t.leftSE.point.x,", ").concat(t.leftSE.point.y,"] -> ")+"[".concat(t.rightSE.point.x,", ").concat(t.rightSE.point.y,"] ")+"in SweepLine tree. Please submit a bug report.");for(var s=o,a=o,l=void 0,u=void 0;l===void 0;)s=this.tree.prev(s),s===null?l=null:s.key.consumedBy===void 0&&(l=s.key);for(;u===void 0;)a=this.tree.next(a),a===null?u=null:a.key.consumedBy===void 0&&(u=a.key);if(n.isLeft){var f=null;if(l){var c=l.getIntersection(t);if(c!==null&&(t.isAnEndpoint(c)||(f=c),!l.isAnEndpoint(c)))for(var p=this._splitSafely(l,c),m=0,g=p.length;m0?(this.tree.remove(t),i.push(n)):(this.segments.push(t),t.prev=l)}else{if(l&&u){var U=l.getIntersection(u);if(U!==null){if(!l.isAnEndpoint(U))for(var B=this._splitSafely(l,U),O=0,C=B.length;OHi)throw new Error("Infinite loop when putting segment endpoints in a priority queue (queue size too big). Please file a bug report.");for(var d=new Du(v),E=v.size,N=v.pop();N;){var j=N.key;if(v.size===E){var U=j.segment;throw new Error("Unable to pop() ".concat(j.isLeft?"left":"right"," SweepEvent ")+"[".concat(j.point.x,", ").concat(j.point.y,"] from segment #").concat(U.id," ")+"[".concat(U.leftSE.point.x,", ").concat(U.leftSE.point.y,"] -> ")+"[".concat(U.rightSE.point.x,", ").concat(U.rightSE.point.y,"] from queue. ")+"Please file a bug report.")}if(v.size>Hi)throw new Error("Infinite loop when passing sweep line over endpoints (queue size too big). Please file a bug report.");if(d.segments.length>zu)throw new Error("Infinite loop when passing sweep line over endpoints (too many sweep line segments). Please file a bug report.");for(var B=d.process(j),O=0,C=B.length;O1?n-1:0),i=1;i1?n-1:0),i=1;i1?n-1:0),i=1;i1?n-1:0),i=1;iHu(r,"name",{value:e,configurable:!0});function Ss(r,e){var n=Ms(e),t=null;return r.type==="FeatureCollection"?t=Es(r):t=Kr(Cn.union(r.geometry.coordinates)),t.geometry.coordinates.forEach(function(i){n.geometry.coordinates.push(i[0])}),n}or(Ss,"mask");function Es(r){var e=r.features.length===2?Cn.union(r.features[0].geometry.coordinates,r.features[1].geometry.coordinates):Cn.union.apply(Cn,r.features.map(function(n){return n.geometry.coordinates}));return Kr(e)}or(Es,"unionFc");function Kr(r){return ml(r)}or(Kr,"createGeomFromPolygonClippingOutput");function Ms(r){var e=[[[180,90],[-180,90],[-180,-90],[180,-90],[180,90]]],n=r&&r.geometry.coordinates||e;return dl(n)}or(Ms,"createMask");var Zi=Ss;function Zu(r){let e,n;const t=[ue(r[0],"boundary"),{paint:{"fill-color":"black","fill-opacity":.5}}];let i={};for(let o=0;on(3,t=a));let{cfg:i}=e,{boundaryGeojson:o}=e,{fitBoundsAtStart:s=!1}=e;return(gl("setCamera")||s)&&(t==null||t.fitBounds(Wo(o),{padding:20,animate:!1})),r.$$set=a=>{"cfg"in a&&n(0,i=a.cfg),"boundaryGeojson"in a&&n(1,o=a.boundaryGeojson),"fitBoundsAtStart"in a&&n(2,s=a.fitBoundsAtStart)},[i,o,s]}class xu extends re{constructor(e){super(),ie(this,e,Qu,Vu,te,{cfg:0,boundaryGeojson:1,fitBoundsAtStart:2})}}const An=at(null),Nn=at(100);function Vi(r){let e,n;return e=new fa({props:{url:r[3],coordinates:[[r[1].lng,r[1].lat],[r[4].lng,r[1].lat],[r[4].lng,r[4].lat],[r[1].lng,r[4].lat]],$$slots:{default:[ef]},$$scope:{ctx:r}}}),{c(){P(e.$$.fragment)},m(t,i){L(e,t,i),n=!0},p(t,i){const o={};i&8&&(o.url=t[3]),i&18&&(o.coordinates=[[t[1].lng,t[1].lat],[t[4].lng,t[1].lat],[t[4].lng,t[4].lat],[t[1].lng,t[4].lat]]),i&545&&(o.$$scope={dirty:i,ctx:t}),e.$set(o)},i(t){n||(_(e.$$.fragment,t),n=!0)},o(t){$(e.$$.fragment,t),n=!1},d(t){F(e,t)}}}function ef(r){let e,n;const t=[ue(r[0],"georeferenced-image"),{paint:{"raster-fade-duration":0,"raster-opacity":r[5]/100}}];let i={};for(let o=0;ox(e,"lngLat",a));function u(c){r[8](c)}let f={draggable:!0,$$slots:{default:[nf]},$$scope:{ctx:r}};return r[4]!==void 0&&(f.lngLat=r[4]),i=new _r({props:f}),V.push(()=>x(i,"lngLat",u)),{c(){P(e.$$.fragment),t=R(),P(i.$$.fragment)},m(c,p){L(e,c,p),y(c,t,p),L(i,c,p),s=!0},p(c,p){const m={};p&512&&(m.$$scope={dirty:p,ctx:c}),!n&&p&2&&(n=!0,m.lngLat=c[1],ne(()=>n=!1)),e.$set(m);const g={};p&512&&(g.$$scope={dirty:p,ctx:c}),!o&&p&16&&(o=!0,g.lngLat=c[4],ne(()=>o=!1)),i.$set(g)},i(c){s||(_(e.$$.fragment,c),_(i.$$.fragment,c),s=!0)},o(c){$(e.$$.fragment,c),$(i.$$.fragment,c),s=!1},d(c){c&&w(t),F(e,c),F(i,c)}}}function tf(r){let e;return{c(){e=q("span"),J(e,"class","dot svelte-1tmbx1c"),ge(e,"background-color","red")},m(n,t){y(n,e,t)},p:Q,d(n){n&&w(e)}}}function nf(r){let e;return{c(){e=q("span"),J(e,"class","dot svelte-1tmbx1c"),ge(e,"background-color","blue")},m(n,t){y(n,e,t)},p:Q,d(n){n&&w(e)}}}function rf(r){let e,n,t,i=r[3]&&Vi(r),o=r[3]&&r[2].mode=="set-image"&&Qi(r);return{c(){i&&i.c(),e=R(),o&&o.c(),n=ce()},m(s,a){i&&i.m(s,a),y(s,e,a),o&&o.m(s,a),y(s,n,a),t=!0},p(s,[a]){s[3]?i?(i.p(s,a),a&8&&_(i,1)):(i=Vi(s),i.c(),_(i,1),i.m(e.parentNode,e)):i&&(se(),$(i,1,1,()=>{i=null}),le()),s[3]&&s[2].mode=="set-image"?o?(o.p(s,a),a&12&&_(o,1)):(o=Qi(s),o.c(),_(o,1),o.m(n.parentNode,n)):o&&(se(),$(o,1,1,()=>{o=null}),le())},i(s){t||(_(i),_(o),t=!0)},o(s){$(i),$(o),t=!1},d(s){s&&(w(e),w(n)),i&&i.d(s),o&&o.d(s)}}}function of(r,e,n){let t,i,o,s;K(r,xe,p=>n(6,t=p)),K(r,pe,p=>n(2,i=p)),K(r,An,p=>n(3,o=p)),K(r,Nn,p=>n(5,s=p));let{cfg:a}=e,l={lng:0,lat:0},u={lng:0,lat:0};function f(p){l=p,n(1,l),n(6,t),n(3,o),n(2,i)}function c(p){u=p,n(4,u),n(6,t),n(3,o),n(2,i),n(1,l)}return r.$$set=p=>{"cfg"in p&&n(0,a=p.cfg)},r.$$.update=()=>{if(r.$$.dirty&78&&t&&o&&i.mode=="set-image"&&l.lng==0&&l.lat==0){let p=t.getBounds();n(1,l.lng=p.getWest()+.4*(p.getEast()-p.getWest()),l),n(4,u.lng=p.getWest()+.6*(p.getEast()-p.getWest()),u),n(1,l.lat=p.getNorth()+.4*(p.getSouth()-p.getNorth()),l),n(4,u.lat=p.getNorth()+.6*(p.getSouth()-p.getNorth()),u)}},[a,l,i,o,u,s,t,f,c]}class sf extends re{constructor(e){super(),ie(this,e,of,rf,te,{cfg:0})}}function lf(r){let e,n,t,i,o,s;const a=[ue(r[0],"hover-polygons"),{filter:St},{paint:{"line-color":sn.hovering,"line-width":.5*kt}}];let l={};for(let m=0;m(s(),s=We(u,f=>n(4,o=f)),u);K(r,on,f=>n(3,i=f)),r.$$.on_destroy.push(()=>s());let{cfg:l}=e,{gjSchemes:u}=e;return a(),r.$$set=f=>{"cfg"in f&&n(0,l=f.cfg),"gjSchemes"in f&&a(n(1,u=f.gjSchemes))},r.$$.update=()=>{r.$$.dirty&24&&n(2,t=i==null?Jt():o.features.find(f=>f.id==i))},[l,u,t,i,o]}class ff extends re{constructor(e){super(),ie(this,e,uf,af,te,{cfg:0,gjSchemes:1})}}function xi(r){let e,n;return e=new Gr({props:{openOn:"hover",openIfTopMost:!0,$$slots:{default:[cf,({features:t})=>({16:t}),({features:t})=>t?65536:0]},$$scope:{ctx:r}}}),{c(){P(e.$$.fragment)},m(t,i){L(e,t,i),n=!0},p(t,i){const o={};i&196608&&(o.$$scope={dirty:i,ctx:t}),e.$set(o)},i(t){n||(_(e.$$.fragment,t),n=!0)},o(t){$(e.$$.fragment,t),n=!1},d(t){F(e,t)}}}function cf(r){let e,n,t=r[9](r[16])+"",i;return{c(){e=q("div"),n=q("p"),i=D(t),J(e,"class","govuk-prose")},m(o,s){y(o,e,s),G(e,n),G(n,i)},p(o,s){s&65536&&t!==(t=o[9](o[16])+"")&&be(i,t)},d(o){o&&w(e)}}}function pf(r){let e,n,t=r[4]&&xi(r);return{c(){t&&t.c(),e=ce()},m(i,o){t&&t.m(i,o),y(i,e,o),n=!0},p(i,o){i[4]?t?(t.p(i,o),o&16&&_(t,1)):(t=xi(i),t.c(),_(t,1),t.m(e.parentNode,e)):t&&(se(),$(t,1,1,()=>{t=null}),le())},i(i){n||(_(t),n=!0)},o(i){$(t),n=!1},d(i){i&&w(e),t&&t.d(i)}}}function eo(r){let e,n;return e=new Gr({props:{openOn:"hover",openIfTopMost:!0,$$slots:{default:[mf,({features:t})=>({16:t}),({features:t})=>t?65536:0]},$$scope:{ctx:r}}}),{c(){P(e.$$.fragment)},m(t,i){L(e,t,i),n=!0},p(t,i){const o={};i&196608&&(o.$$scope={dirty:i,ctx:t}),e.$set(o)},i(t){n||(_(e.$$.fragment,t),n=!0)},o(t){$(e.$$.fragment,t),n=!1},d(t){F(e,t)}}}function mf(r){let e,n,t=r[9](r[16])+"",i;return{c(){e=q("div"),n=q("p"),i=D(t),J(e,"class","govuk-prose")},m(o,s){y(o,e,s),G(e,n),G(n,i)},p(o,s){s&65536&&t!==(t=o[9](o[16])+"")&&be(i,t)},d(o){o&&w(e)}}}function df(r){let e,n,t=r[4]&&eo(r);return{c(){t&&t.c(),e=ce()},m(i,o){t&&t.m(i,o),y(i,e,o),n=!0},p(i,o){i[4]?t?(t.p(i,o),o&16&&_(t,1)):(t=eo(i),t.c(),_(t,1),t.m(e.parentNode,e)):t&&(se(),$(t,1,1,()=>{t=null}),le())},i(i){n||(_(t),n=!0)},o(i){$(t),n=!1},d(i){i&&w(e),t&&t.d(i)}}}function to(r){let e,n;return e=new Gr({props:{openOn:"hover",openIfTopMost:!0,$$slots:{default:[gf,({features:t})=>({16:t}),({features:t})=>t?65536:0]},$$scope:{ctx:r}}}),{c(){P(e.$$.fragment)},m(t,i){L(e,t,i),n=!0},p(t,i){const o={};i&196608&&(o.$$scope={dirty:i,ctx:t}),e.$set(o)},i(t){n||(_(e.$$.fragment,t),n=!0)},o(t){$(e.$$.fragment,t),n=!1},d(t){F(e,t)}}}function gf(r){let e,n,t=r[9](r[16])+"",i;return{c(){e=q("div"),n=q("p"),i=D(t),J(e,"class","govuk-prose")},m(o,s){y(o,e,s),G(e,n),G(n,i)},p(o,s){s&65536&&t!==(t=o[9](o[16])+"")&&be(i,t)},d(o){o&&w(e)}}}function hf(r){let e,n,t=r[4]&&to(r);return{c(){t&&t.c(),e=ce()},m(i,o){t&&t.m(i,o),y(i,e,o),n=!0},p(i,o){i[4]?t?(t.p(i,o),o&16&&_(t,1)):(t=to(i),t.c(),_(t,1),t.m(e.parentNode,e)):t&&(se(),$(t,1,1,()=>{t=null}),le())},i(i){n||(_(t),n=!0)},o(i){$(t),n=!1},d(i){i&&w(e),t&&t.d(i)}}}function _f(r){let e,n,t,i,o,s,a,l,u,f;const c=[ue(r[0],"interventions-points"),{filter:["all",dn,r[6],r[7],r[3]]},{paint:{"circle-color":r[2],"circle-radius":jn}},{hoverCursor:r[4]?"pointer":void 0},{manageHoverState:r[4]}];let p={$$slots:{default:[pf]},$$scope:{ctx:r}};for(let d=0;d(l(),l=We(g,d=>n(11,a=d)),g),f,c,p;K(r,xe,d=>n(14,f=d)),K(r,pe,d=>n(12,c=d)),K(r,ln,d=>n(13,p=d)),r.$$.on_destroy.push(()=>l());let{cfg:m}=e,{gjSchemes:g}=e;u();const v=["!=",["get","hide_while_editing"],!0],S=["!=",["get","endpoint"],!0];let k;function b(d){return xt(["get","scheme_reference"],Object.fromEntries(Object.values(d.schemes).map(E=>[E.scheme_reference,E.color])),"black")}function h(d){c.mode!="list"||!f||d.detail.features[0]&&(f.getCanvas().style.cursor="inherit",pe.set({mode:"edit",id:d.detail.features[0].id}))}function M(d){if(d){let E=d[0],N=m.interventionName(E),j=m.schemeName(a.schemes[E.properties.scheme_reference]);return`${N} (${j})`}return"Tooltip bug"}return r.$$set=d=>{"cfg"in d&&n(0,m=d.cfg),"gjSchemes"in d&&u(n(1,g=d.gjSchemes))},r.$$.update=()=>{if(r.$$.dirty&2048&&n(5,t=Nl(a)),r.$$.dirty&4096&&n(4,i=c.mode=="list"),r.$$.dirty&8192&&n(3,o=vf(p)),r.$$.dirty&2048&&n(10,s=b(a)),r.$$.dirty&5120){let d="grey";c.mode=="list"?n(2,k=s):c.mode=="split-route"?n(2,k=["case",["==","intervention_type","route"],s,d]):n(2,k=d)}},[m,g,k,o,i,t,v,S,h,M,s,a,c,p]}class yf extends re{constructor(e){super(),ie(this,e,$f,bf,te,{cfg:0,gjSchemes:1})}}function wf(r){let e,n,t,i,o,s;function a(f){r[3](f)}var l=r[0].editFeatureForm;function u(f,c){let p={cfg:f[0],gjSchemes:f[1],id:null};return f[2]!==void 0&&(p.props=f[2]),{props:p}}return l&&(t=zt(l,u(r)),V.push(()=>x(t,"props",a))),{c(){e=q("h2"),e.textContent="New intervention",n=R(),t&&P(t.$$.fragment),o=ce()},m(f,c){y(f,e,c),y(f,n,c),t&&L(t,f,c),y(f,o,c),s=!0},p(f,[c]){if(c&1&&l!==(l=f[0].editFeatureForm)){if(t){se();const p=t;$(p.$$.fragment,1,0,()=>{F(p,1)}),le()}l?(t=zt(l,u(f)),V.push(()=>x(t,"props",a)),P(t.$$.fragment),_(t.$$.fragment,1),L(t,o.parentNode,o)):t=null}else if(l){const p={};c&1&&(p.cfg=f[0]),c&2&&(p.gjSchemes=f[1]),!i&&c&4&&(i=!0,p.props=f[2],ne(()=>i=!1)),t.$set(p)}},i(f){s||(t&&_(t.$$.fragment,f),s=!0)},o(f){t&&$(t.$$.fragment,f),s=!1},d(f){f&&(w(e),w(n),w(o)),t&&F(t,f)}}}function kf(r,e,n){let t;K(r,ct,a=>n(2,t=a));let{cfg:i}=e,{gjSchemes:o}=e;rt(()=>{je(ct,t={},t)}),Xe(()=>{je(ct,t={},t)});function s(a){t=a,ct.set(t)}return r.$$set=a=>{"cfg"in a&&n(0,i=a.cfg),"gjSchemes"in a&&n(1,o=a.gjSchemes)},[i,o,t,s]}class Sf extends re{constructor(e){super(),ie(this,e,kf,wf,te,{cfg:0,gjSchemes:1})}}function Ef(r){let e,n,t,i,o,s;const a=[ue(r[0],"edit-polygon-fill"),{filter:St},{paint:{"fill-color":"red","fill-opacity":["case",["boolean",["get","hover"],"false"],1,.5]}}];let l={};for(let m=0;mn(1,t=o));let{cfg:i}=e;return r.$$set=o=>{"cfg"in o&&n(0,i=o.cfg)},[i,t]}class Lf extends re{constructor(e){super(),ie(this,e,Pf,Mf,te,{cfg:0})}}const Ps=at(Jt()),Rn=at(Jt()),Ls=at(!0),Hr=at(0);function Ff(r){let e,n,t,i,o,s;const a=[ue(r[0],"route-points"),{filter:dn},{paint:{"circle-color":xt(["get","type"],{"snapped-waypoint":"red","free-waypoint":"blue"},"black"),"circle-opacity":["case",["has","hovered"],.5,1],"circle-radius":xt(["get","type"],{node:En/2},En)}}];let l={};for(let m=0;m({3:t}),({feature:t})=>t?8:0]},$$scope:{ctx:r}}}),{c(){P(e.$$.fragment)},m(t,i){L(e,t,i),n=!0},p(t,i){const o={};i&24&&(o.$$scope={dirty:i,ctx:t}),e.$set(o)},i(t){n||(_(e.$$.fragment,t),n=!0)},o(t){$(e.$$.fragment,t),n=!1},d(t){F(e,t)}}}function Nf(r){let e,n,t,i;return e=new Mt({props:{data:r[1],$$slots:{default:[Ff]},$$scope:{ctx:r}}}),t=new Mt({props:{data:r[2],$$slots:{default:[Af]},$$scope:{ctx:r}}}),{c(){P(e.$$.fragment),n=R(),P(t.$$.fragment)},m(o,s){L(e,o,s),y(o,n,s),L(t,o,s),i=!0},p(o,[s]){const a={};s&2&&(a.data=o[1]),s&17&&(a.$$scope={dirty:s,ctx:o}),e.$set(a);const l={};s&4&&(l.data=o[2]),s&16&&(l.$$scope={dirty:s,ctx:o}),t.$set(l)},i(o){i||(_(e.$$.fragment,o),_(t.$$.fragment,o),i=!0)},o(o){$(e.$$.fragment,o),$(t.$$.fragment,o),i=!1},d(o){o&&w(n),F(e,o),F(t,o)}}}const En=10;function no(r){var e;return(e=r.properties)==null?void 0:e.number}function Rf(r,e,n){let t,i;K(r,Ps,s=>n(1,t=s)),K(r,Rn,s=>n(2,i=s));let{cfg:o}=e;return r.$$set=s=>{"cfg"in s&&n(0,o=s.cfg)},[o,t,i]}class Of extends re{constructor(e){super(),ie(this,e,Rf,Nf,te,{cfg:0})}}function jf(r){let e;return{c(){e=D("Finish")},m(n,t){y(n,e,t)},d(n){n&&w(e)}}}function If(r){let e,n;return e=new Ol({}),{c(){P(e.$$.fragment)},m(t,i){L(e,t,i),n=!0},i(t){n||(_(e.$$.fragment,t),n=!0)},o(t){$(e.$$.fragment,t),n=!1},d(t){F(e,t)}}}function Bf(r){let e,n,t,i;return e=new _t({props:{$$slots:{default:[jf]},$$scope:{ctx:r}}}),e.$on("click",r[6]),t=new Rt({props:{$$slots:{default:[If]},$$scope:{ctx:r}}}),{c(){P(e.$$.fragment),n=R(),P(t.$$.fragment)},m(o,s){L(e,o,s),y(o,n,s),L(t,o,s),i=!0},p(o,s){const a={};s&128&&(a.$$scope={dirty:s,ctx:o}),e.$set(a);const l={};s&128&&(l.$$scope={dirty:s,ctx:o}),t.$set(l)},i(o){i||(_(e.$$.fragment,o),_(t.$$.fragment,o),i=!0)},o(o){$(e.$$.fragment,o),$(t.$$.fragment,o),i=!1},d(o){o&&w(n),F(e,o),F(t,o)}}}function qf(r){let e,n,t,i,o,s,a,l,u,f;function c(v){r[4](v)}let p={cfg:r[0],map:r[2],showControls:!1};r[1]!==void 0&&(p.enabled=r[1]),e=new Rl({props:p}),V.push(()=>x(e,"enabled",c));function m(v){r[5](v)}let g={label:"Source",choices:[["google","Google Street View"],["bing","Bing Streetside"]],inlineSmall:!0,leftLabel:!0};return r[3].streetViewImagery!==void 0&&(g.value=r[3].streetViewImagery),o=new Pt({props:g}),V.push(()=>x(o,"value",m)),u=new Ke({props:{$$slots:{default:[Bf]},$$scope:{ctx:r}}}),{c(){P(e.$$.fragment),t=R(),i=q("div"),P(o.$$.fragment),a=R(),l=q("div"),P(u.$$.fragment),ge(l,"margin-left","auto"),ge(i,"display","flex")},m(v,S){L(e,v,S),y(v,t,S),y(v,i,S),L(o,i,null),G(i,a),G(i,l),L(u,l,null),f=!0},p(v,[S]){const k={};S&1&&(k.cfg=v[0]),S&4&&(k.map=v[2]),!n&&S&2&&(n=!0,k.enabled=v[1],ne(()=>n=!1)),e.$set(k);const b={};!s&&S&8&&(s=!0,b.value=v[3].streetViewImagery,ne(()=>s=!1)),o.$set(b);const h={};S&130&&(h.$$scope={dirty:S,ctx:v}),u.$set(h)},i(v){f||(_(e.$$.fragment,v),_(o.$$.fragment,v),_(u.$$.fragment,v),f=!0)},o(v){$(e.$$.fragment,v),$(o.$$.fragment,v),$(u.$$.fragment,v),f=!1},d(v){v&&(w(t),w(i)),F(e,v),F(o),F(u)}}}function Gf(r,e,n){let t,i;K(r,xe,f=>n(2,t=f)),K(r,ti,f=>n(3,i=f));let{cfg:o}=e,s=!0;function a(f){s=f,n(1,s)}function l(f){r.$$.not_equal(i.streetViewImagery,f)&&(i.streetViewImagery=f,ti.set(i))}const u=()=>n(1,s=!1);return r.$$set=f=>{"cfg"in f&&n(0,o=f.cfg)},r.$$.update=()=>{r.$$.dirty&2&&(s||pe.set({mode:"list"}))},[o,s,t,i,a,l,u]}class Tf extends re{constructor(e){super(),ie(this,e,Gf,qf,te,{cfg:0})}}const Uf="/atip/move_draw_controls/assets/image-3e3a13e8.svg",Df="/atip/move_draw_controls/assets/point-276f4055.svg",zf="/atip/move_draw_controls/assets/polygon_freehand-cf965967.svg",Jf="/atip/move_draw_controls/assets/polygon_snapped-18efbbea.svg",Yf="/atip/move_draw_controls/assets/route-d3c0ebad.svg",Fs="/atip/move_draw_controls/assets/split_route-9e0ea2da.svg",Xf="/atip/move_draw_controls/assets/street_view-48580b6a.svg";function Wf(r){let e;return{c(){e=D("Cancel")},m(n,t){y(n,e,t)},d(n){n&&w(e)}}}function Kf(r){let e;return{c(){e=q("li"),e.textContent="Click to add a new point"},m(n,t){y(n,e,t)},d(n){n&&w(e)}}}function Hf(r){let e;return{c(){e=q("li"),e.textContent="Click to move the point here"},m(n,t){y(n,e,t)},d(n){n&&w(e)}}}function Zf(r){let e,n,t;function i(a,l){return a[0]?Hf:Kf}let o=i(r),s=o(r);return{c(){e=q("ul"),s.c(),n=R(),t=q("li"),t.innerHTML=`Press Escape - to cancel`},m(a,l){y(a,e,l),s.m(e,null),G(e,n),G(e,t)},p(a,l){o!==(o=i(a))&&(s.d(1),s=o(a),s&&(s.c(),s.m(e,n)))},d(a){a&&w(e),s.d()}}}function Vf(r){let e,n,t,i;return e=new _e({props:{$$slots:{default:[Wf]},$$scope:{ctx:r}}}),e.$on("click",function(){Lt(r[1])&&r[1].apply(this,arguments)}),t=new Rt({props:{$$slots:{default:[Zf]},$$scope:{ctx:r}}}),{c(){P(e.$$.fragment),n=R(),P(t.$$.fragment)},m(o,s){L(e,o,s),y(o,n,s),L(t,o,s),i=!0},p(o,s){r=o;const a={};s&4&&(a.$$scope={dirty:s,ctx:r}),e.$set(a);const l={};s&5&&(l.$$scope={dirty:s,ctx:r}),t.$set(l)},i(o){i||(_(e.$$.fragment,o),_(t.$$.fragment,o),i=!0)},o(o){$(e.$$.fragment,o),$(t.$$.fragment,o),i=!1},d(o){o&&w(n),F(e,o),F(t,o)}}}function Qf(r){let e,n,t;return n=new Ke({props:{$$slots:{default:[Vf]},$$scope:{ctx:r}}}),{c(){e=q("div"),P(n.$$.fragment),ge(e,"float","right")},m(i,o){y(i,e,o),L(n,e,null),t=!0},p(i,[o]){const s={};o&7&&(s.$$scope={dirty:o,ctx:i}),n.$set(s)},i(i){t||(_(n.$$.fragment,i),t=!0)},o(i){$(n.$$.fragment,i),t=!1},d(i){i&&w(e),F(n)}}}function xf(r,e,n){let{editingExisting:t}=e,{cancel:i}=e;return r.$$set=o=>{"editingExisting"in o&&n(0,t=o.editingExisting),"cancel"in o&&n(1,i=o.cancel)},[t,i]}class Cs extends re{constructor(e){super(),ie(this,e,xf,Qf,te,{editingExisting:0,cancel:1})}}function ec(r){let e;return{c(){e=D("Finish")},m(n,t){y(n,e,t)},d(n){n&&w(e)}}}function tc(r){let e,n,t;return{c(){e=D("Undo ("),n=D(r[2]),t=D(")")},m(i,o){y(i,e,o),y(i,n,o),y(i,t,o)},p(i,o){o&4&&be(n,i[2])},d(i){i&&(w(e),w(n),w(t))}}}function nc(r){let e;return{c(){e=D("Undo")},m(n,t){y(n,e,t)},p:Q,d(n){n&&w(e)}}}function rc(r){let e;function n(o,s){return o[2]==0?nc:tc}let t=n(r),i=t(r);return{c(){i.c(),e=ce()},m(o,s){i.m(o,s),y(o,e,s)},p(o,s){t===(t=n(o))&&i?i.p(o,s):(i.d(1),i=t(o),i&&(i.c(),i.m(e.parentNode,e)))},d(o){o&&w(e),i.d(o)}}}function ic(r){let e;return{c(){e=D("Cancel")},m(n,t){y(n,e,t)},d(n){n&&w(e)}}}function oc(r){let e;return{c(){e=q("ul"),e.innerHTML=`
  • Click +***************************************************************************** */function Pu(r,e){var n={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},t,i,o,s;return s={next:a(0),throw:a(1),return:a(2)},typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function a(u){return function(f){return l([u,f])}}function l(u){if(t)throw new TypeError("Generator is already executing.");for(;n;)try{if(t=1,i&&(o=u[0]&2?i.return:u[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,u[1])).done)return o;switch(i=0,o&&(u=[u[0]&2,o.value]),u[0]){case 0:case 1:o=u;break;case 4:return n.label++,{value:u[1],done:!1};case 5:n.label++,i=u[1],u=[0];continue;case 7:u=n.ops.pop(),n.trys.pop();continue;default:if(o=n.trys,!(o=o.length>0&&o[o.length-1])&&(u[0]===6||u[0]===2)){n=0;continue}if(u[0]===3&&(!o||u[1]>o[0]&&u[1]e?1:r0){if(e.right===null)break;if(n(r,e.right.key)>0){var a=e.right;if(e.right=a.left,a.left=e,e=a,e.right===null)break}i.right=e,i=e,e=e.right}else break}return i.right=e.left,o.left=e.right,e.left=t.right,e.right=t.left,e}function dr(r,e,n,t){var i=new ht(r,e);if(n===null)return i.left=i.right=null,i;n=ct(r,n,t);var o=t(r,n.key);return o<0?(i.left=n.left,i.right=n,n.left=null):o>=0&&(i.right=n.right,i.left=n,n.right=null),i}function Ti(r,e,n){var t=null,i=null;if(e){e=ct(r,e,n);var o=n(e.key,r);o===0?(t=e.left,i=e.right):o<0?(i=e.right,e.right=null,t=e):(t=e.left,e.left=null,i=e)}return{left:t,right:i}}function Cu(r,e,n){return e===null?r:(r===null||(e=ct(r.key,e,n),e.left=r),e)}function Fr(r,e,n,t,i){if(r){t(""+e+(n?"└── ":"├── ")+i(r)+` +`);var o=e+(n?" ":"│ ");r.left&&Fr(r.left,o,!1,t,i),r.right&&Fr(r.right,o,!0,t,i)}}var Wr=function(){function r(e){e===void 0&&(e=Lu),this._root=null,this._size=0,this._comparator=e}return r.prototype.insert=function(e,n){return this._size++,this._root=dr(e,n,this._root,this._comparator)},r.prototype.add=function(e,n){var t=new ht(e,n);this._root===null&&(t.left=t.right=null,this._size++,this._root=t);var i=this._comparator,o=ct(e,this._root,i),s=i(e,o.key);return s===0?this._root=o:(s<0?(t.left=o.left,t.right=o,o.left=null):s>0&&(t.right=o.right,t.left=o,o.right=null),this._size++,this._root=t),this._root},r.prototype.remove=function(e){this._root=this._remove(e,this._root,this._comparator)},r.prototype._remove=function(e,n,t){var i;if(n===null)return null;n=ct(e,n,t);var o=t(e,n.key);return o===0?(n.left===null?i=n.right:(i=ct(e,n.left,t),i.right=n.right),this._size--,i):n},r.prototype.pop=function(){var e=this._root;if(e){for(;e.left;)e=e.left;return this._root=ct(e.key,this._root,this._comparator),this._root=this._remove(e.key,this._root,this._comparator),{key:e.key,data:e.data}}return null},r.prototype.findStatic=function(e){for(var n=this._root,t=this._comparator;n;){var i=t(e,n.key);if(i===0)return n;i<0?n=n.left:n=n.right}return null},r.prototype.find=function(e){return this._root&&(this._root=ct(e,this._root,this._comparator),this._comparator(e,this._root.key)!==0)?null:this._root},r.prototype.contains=function(e){for(var n=this._root,t=this._comparator;n;){var i=t(e,n.key);if(i===0)return!0;i<0?n=n.left:n=n.right}return!1},r.prototype.forEach=function(e,n){for(var t=this._root,i=[],o=!1;!o;)t!==null?(i.push(t),t=t.left):i.length!==0?(t=i.pop(),e.call(n,t),t=t.right):o=!0;return this},r.prototype.range=function(e,n,t,i){for(var o=[],s=this._comparator,a=this._root,l;o.length!==0||a;)if(a)o.push(a),a=a.left;else{if(a=o.pop(),l=s(a.key,n),l>0)break;if(s(a.key,e)>=0&&t.call(i,a))return this;a=a.right}return this},r.prototype.keys=function(){var e=[];return this.forEach(function(n){var t=n.key;return e.push(t)}),e},r.prototype.values=function(){var e=[];return this.forEach(function(n){var t=n.data;return e.push(t)}),e},r.prototype.min=function(){return this._root?this.minNode(this._root).key:null},r.prototype.max=function(){return this._root?this.maxNode(this._root).key:null},r.prototype.minNode=function(e){if(e===void 0&&(e=this._root),e)for(;e.left;)e=e.left;return e},r.prototype.maxNode=function(e){if(e===void 0&&(e=this._root),e)for(;e.right;)e=e.right;return e},r.prototype.at=function(e){for(var n=this._root,t=!1,i=0,o=[];!t;)if(n)o.push(n),n=n.left;else if(o.length>0){if(n=o.pop(),i===e)return n;i++,n=n.right}else t=!0;return null},r.prototype.next=function(e){var n=this._root,t=null;if(e.right){for(t=e.right;t.left;)t=t.left;return t}for(var i=this._comparator;n;){var o=i(e.key,n.key);if(o===0)break;o<0?(t=n,n=n.left):n=n.right}return t},r.prototype.prev=function(e){var n=this._root,t=null;if(e.left!==null){for(t=e.left;t.right;)t=t.right;return t}for(var i=this._comparator;n;){var o=i(e.key,n.key);if(o===0)break;o<0?n=n.left:(t=n,n=n.right)}return t},r.prototype.clear=function(){return this._root=null,this._size=0,this},r.prototype.toList=function(){return Au(this._root)},r.prototype.load=function(e,n,t){n===void 0&&(n=[]),t===void 0&&(t=!1);var i=e.length,o=this._comparator;if(t&&Rr(e,n,0,i-1,o),this._root===null)this._root=Ar(e,n,0,i),this._size=i;else{var s=Nu(this.toList(),Fu(e,n),o);i=this._size+i,this._root=Nr({head:s},0,i)}return this},r.prototype.isEmpty=function(){return this._root===null},Object.defineProperty(r.prototype,"size",{get:function(){return this._size},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"root",{get:function(){return this._root},enumerable:!0,configurable:!0}),r.prototype.toString=function(e){e===void 0&&(e=function(t){return String(t.key)});var n=[];return Fr(this._root,"",!0,function(t){return n.push(t)},e),n.join("")},r.prototype.update=function(e,n,t){var i=this._comparator,o=Ti(e,this._root,i),s=o.left,a=o.right;i(e,n)<0?a=dr(n,t,a,i):s=dr(n,t,s,i),this._root=Cu(s,a,i)},r.prototype.split=function(e){return Ti(e,this._root,this._comparator)},r.prototype[Symbol.iterator]=function(){var e;return Pu(this,function(n){switch(n.label){case 0:e=this.minNode(),n.label=1;case 1:return e?[4,e]:[3,3];case 2:return n.sent(),e=this.next(e),[3,1];case 3:return[2]}})},r}();function Ar(r,e,n,t){var i=t-n;if(i>0){var o=n+Math.floor(i/2),s=r[o],a=e[o],l=new ht(s,a);return l.left=Ar(r,e,n,o),l.right=Ar(r,e,o+1,t),l}return null}function Fu(r,e){for(var n=new ht(null,null),t=n,i=0;i0?(e=o=o.next=n.pop(),e=e.right):t=!0;return o.next=null,i.next}function Nr(r,e,n){var t=n-e;if(t>0){var i=e+Math.floor(t/2),o=Nr(r,e,i),s=r.head;return s.left=o,r.head=r.head.next,s.right=Nr(r,i+1,n),s}return null}function Nu(r,e,n){for(var t=new ht(null,null),i=t,o=r,s=e;o!==null&&s!==null;)n(o.key,s.key)<0?(i.next=o,o=o.next):(i.next=s,s=s.next),i=i.next;return o!==null?i.next=o:s!==null&&(i.next=s),t.next}function Rr(r,e,n,t,i){if(!(n>=t)){for(var o=r[n+t>>1],s=n-1,a=t+1;;){do s++;while(i(r[s],o)<0);do a--;while(i(r[a],o)>0);if(s>=a)break;var l=r[s];r[s]=r[a],r[a]=l,l=e[s],e[s]=e[a],e[a]=l}Rr(r,e,n,a,i),Rr(r,e,a+1,t,i)}}function Te(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}function Di(r,e){for(var n=0;nt.x?1:n.yt.y?1:0}}]);function r(e,n){Te(this,r),e.events===void 0?e.events=[this]:e.events.push(this),this.point=e,this.isLeft=n}return Re(r,[{key:"link",value:function(n){if(n.point===this.point)throw new Error("Tried to link already linked events");for(var t=n.point.events,i=0,o=t.length;i=0&&p>=0?fm?-1:0:u<0&&p<0?fm?1:0:pu?1:0}}}]),r}(),qu=0,Qn=function(){Re(r,null,[{key:"compare",value:function(n,t){var i=n.leftSE.point.x,o=t.leftSE.point.x,s=n.rightSE.point.x,a=t.rightSE.point.x;if(al&&u>f)return-1;var p=n.comparePoint(t.leftSE.point);if(p<0)return 1;if(p>0)return-1;var m=t.comparePoint(n.rightSE.point);return m!==0?m:-1}if(i>o){if(lu&&l>c)return 1;var g=t.comparePoint(n.leftSE.point);if(g!==0)return g;var v=n.comparePoint(t.rightSE.point);return v<0?1:v>0?-1:1}if(lu)return 1;if(sa){var M=n.comparePoint(t.rightSE.point);if(M<0)return 1;if(M>0)return-1}if(s!==a){var _=f-l,h=s-i,E=c-u,d=a-o;if(_>h&&Ed)return-1}return s>a?1:sc?1:n.idt.id?1:0}}]);function r(e,n,t,i){Te(this,r),this.id=++qu,this.leftSE=e,e.segment=this,e.otherSE=n,this.rightSE=n,n.segment=this,n.otherSE=e,this.rings=t,this.windings=i}return Re(r,[{key:"replaceRightSE",value:function(n){this.rightSE=n,this.rightSE.segment=this,this.rightSE.otherSE=this.leftSE,this.leftSE.otherSE=this.rightSE}},{key:"bbox",value:function(){var n=this.leftSE.point.y,t=this.rightSE.point.y;return{ll:{x:this.leftSE.point.x,y:nt?n:t}}}},{key:"vector",value:function(){return{x:this.rightSE.point.x-this.leftSE.point.x,y:this.rightSE.point.y-this.leftSE.point.y}}},{key:"isAnEndpoint",value:function(n){return n.x===this.leftSE.point.x&&n.y===this.leftSE.point.y||n.x===this.rightSE.point.x&&n.y===this.rightSE.point.y}},{key:"comparePoint",value:function(n){if(this.isAnEndpoint(n))return 0;var t=this.leftSE.point,i=this.rightSE.point,o=this.vector();if(t.x===i.x)return n.x===t.x?0:n.x0&&l.swapEvents(),Ve.comparePoints(this.leftSE.point,this.rightSE.point)>0&&this.swapEvents(),i&&(o.checkForConsuming(),s.checkForConsuming()),t}},{key:"swapEvents",value:function(){var n=this.rightSE;this.rightSE=this.leftSE,this.leftSE=n,this.leftSE.isLeft=!0,this.rightSE.isLeft=!1;for(var t=0,i=this.windings.length;t0){var s=t;t=i,i=s}if(t.prev===i){var a=t;t=i,i=a}for(var l=0,u=i.rings.length;l0)o=t,s=n,a=-1;else throw new Error("Tried to create degenerate segment at [".concat(n.x,", ").concat(n.y,"]"));var u=new Ve(o,!0),f=new Ve(s,!1);return new r(u,f,[i],[a])}}]),r}(),Xi=function(){function r(e,n,t){if(Te(this,r),!Array.isArray(e)||e.length===0)throw new Error("Input geometry is not a valid Polygon or MultiPolygon");if(this.poly=n,this.isExterior=t,this.segments=[],typeof e[0][0]!="number"||typeof e[0][1]!="number")throw new Error("Input geometry is not a valid Polygon or MultiPolygon");var i=gn.round(e[0][0],e[0][1]);this.bbox={ll:{x:i.x,y:i.y},ur:{x:i.x,y:i.y}};for(var o=i,s=1,a=e.length;sthis.bbox.ur.x&&(this.bbox.ur.x=l.x),l.y>this.bbox.ur.y&&(this.bbox.ur.y=l.y),o=l)}(i.x!==o.x||i.y!==o.y)&&this.segments.push(Qn.fromRing(o,i,this))}return Re(r,[{key:"getSweepEvents",value:function(){for(var n=[],t=0,i=this.segments.length;tthis.bbox.ur.x&&(this.bbox.ur.x=o.bbox.ur.x),o.bbox.ur.y>this.bbox.ur.y&&(this.bbox.ur.y=o.bbox.ur.y),this.interiorRings.push(o)}this.multiPoly=n}return Re(r,[{key:"getSweepEvents",value:function(){for(var n=this.exteriorRing.getSweepEvents(),t=0,i=this.interiorRings.length;tthis.bbox.ur.x&&(this.bbox.ur.x=o.bbox.ur.x),o.bbox.ur.y>this.bbox.ur.y&&(this.bbox.ur.y=o.bbox.ur.y),this.polys.push(o)}this.isSubject=n}return Re(r,[{key:"getSweepEvents",value:function(){for(var n=[],t=0,i=this.polys.length;t0&&(n=o)}for(var s=n.segment.prevInResult(),a=s?s.prevInResult():null;;){if(!s)return null;if(!a)return s.ringOut;if(a.ringOut!==s.ringOut)return a.ringOut.enclosingRing()!==s.ringOut?s.ringOut:s.ringOut.enclosingRing();s=a.prevInResult(),a=s?s.prevInResult():null}}}]),r}(),Ki=function(){function r(e){Te(this,r),this.exteriorRing=e,e.poly=this,this.interiorRings=[]}return Re(r,[{key:"addInterior",value:function(n){this.interiorRings.push(n),n.poly=this}},{key:"getGeom",value:function(){var n=[this.exteriorRing.getGeom()];if(n[0]===null)return null;for(var t=0,i=this.interiorRings.length;t1&&arguments[1]!==void 0?arguments[1]:Qn.compare;Te(this,r),this.queue=e,this.tree=new Wr(n),this.segments=[]}return Re(r,[{key:"process",value:function(n){var t=n.segment,i=[];if(n.consumedBy)return n.isLeft?this.queue.remove(n.otherSE):this.tree.remove(t),i;var o=n.isLeft?this.tree.insert(t):this.tree.find(t);if(!o)throw new Error("Unable to find segment #".concat(t.id," ")+"[".concat(t.leftSE.point.x,", ").concat(t.leftSE.point.y,"] -> ")+"[".concat(t.rightSE.point.x,", ").concat(t.rightSE.point.y,"] ")+"in SweepLine tree. Please submit a bug report.");for(var s=o,a=o,l=void 0,u=void 0;l===void 0;)s=this.tree.prev(s),s===null?l=null:s.key.consumedBy===void 0&&(l=s.key);for(;u===void 0;)a=this.tree.next(a),a===null?u=null:a.key.consumedBy===void 0&&(u=a.key);if(n.isLeft){var f=null;if(l){var c=l.getIntersection(t);if(c!==null&&(t.isAnEndpoint(c)||(f=c),!l.isAnEndpoint(c)))for(var p=this._splitSafely(l,c),m=0,g=p.length;m0?(this.tree.remove(t),i.push(n)):(this.segments.push(t),t.prev=l)}else{if(l&&u){var U=l.getIntersection(u);if(U!==null){if(!l.isAnEndpoint(U))for(var B=this._splitSafely(l,U),O=0,F=B.length;OHi)throw new Error("Infinite loop when putting segment endpoints in a priority queue (queue size too big). Please file a bug report.");for(var d=new Uu(v),S=v.size,N=v.pop();N;){var j=N.key;if(v.size===S){var U=j.segment;throw new Error("Unable to pop() ".concat(j.isLeft?"left":"right"," SweepEvent ")+"[".concat(j.point.x,", ").concat(j.point.y,"] from segment #").concat(U.id," ")+"[".concat(U.leftSE.point.x,", ").concat(U.leftSE.point.y,"] -> ")+"[".concat(U.rightSE.point.x,", ").concat(U.rightSE.point.y,"] from queue. ")+"Please file a bug report.")}if(v.size>Hi)throw new Error("Infinite loop when passing sweep line over endpoints (queue size too big). Please file a bug report.");if(d.segments.length>zu)throw new Error("Infinite loop when passing sweep line over endpoints (too many sweep line segments). Please file a bug report.");for(var B=d.process(j),O=0,F=B.length;O1?n-1:0),i=1;i1?n-1:0),i=1;i1?n-1:0),i=1;i1?n-1:0),i=1;iHu(r,"name",{value:e,configurable:!0});function Ss(r,e){var n=Ms(e),t=null;return r.type==="FeatureCollection"?t=Es(r):t=Kr(Fn.union(r.geometry.coordinates)),t.geometry.coordinates.forEach(function(i){n.geometry.coordinates.push(i[0])}),n}or(Ss,"mask");function Es(r){var e=r.features.length===2?Fn.union(r.features[0].geometry.coordinates,r.features[1].geometry.coordinates):Fn.union.apply(Fn,r.features.map(function(n){return n.geometry.coordinates}));return Kr(e)}or(Es,"unionFc");function Kr(r){return ml(r)}or(Kr,"createGeomFromPolygonClippingOutput");function Ms(r){var e=[[[180,90],[-180,90],[-180,-90],[180,-90],[180,90]]],n=r&&r.geometry.coordinates||e;return dl(n)}or(Ms,"createMask");var Zi=Ss;function Zu(r){let e,n;const t=[ue(r[0],"boundary"),{paint:{"fill-color":"black","fill-opacity":.5}}];let i={};for(let o=0;on(3,t=a));let{cfg:i}=e,{boundaryGeojson:o}=e,{fitBoundsAtStart:s=!1}=e;return(gl("setCamera")||s)&&(t==null||t.fitBounds(Wo(o),{padding:20,animate:!1})),r.$$set=a=>{"cfg"in a&&n(0,i=a.cfg),"boundaryGeojson"in a&&n(1,o=a.boundaryGeojson),"fitBoundsAtStart"in a&&n(2,s=a.fitBoundsAtStart)},[i,o,s]}class xu extends re{constructor(e){super(),ie(this,e,Qu,Vu,te,{cfg:0,boundaryGeojson:1,fitBoundsAtStart:2})}}const An=ut(null),Nn=ut(100);function Vi(r){let e,n;return e=new fa({props:{url:r[3],coordinates:[[r[1].lng,r[1].lat],[r[4].lng,r[1].lat],[r[4].lng,r[4].lat],[r[1].lng,r[4].lat]],$$slots:{default:[ef]},$$scope:{ctx:r}}}),{c(){P(e.$$.fragment)},m(t,i){L(e,t,i),n=!0},p(t,i){const o={};i&8&&(o.url=t[3]),i&18&&(o.coordinates=[[t[1].lng,t[1].lat],[t[4].lng,t[1].lat],[t[4].lng,t[4].lat],[t[1].lng,t[4].lat]]),i&545&&(o.$$scope={dirty:i,ctx:t}),e.$set(o)},i(t){n||(b(e.$$.fragment,t),n=!0)},o(t){$(e.$$.fragment,t),n=!1},d(t){C(e,t)}}}function ef(r){let e,n;const t=[ue(r[0],"georeferenced-image"),{paint:{"raster-fade-duration":0,"raster-opacity":r[5]/100}}];let i={};for(let o=0;ox(e,"lngLat",a));function u(c){r[8](c)}let f={draggable:!0,$$slots:{default:[nf]},$$scope:{ctx:r}};return r[4]!==void 0&&(f.lngLat=r[4]),i=new _r({props:f}),V.push(()=>x(i,"lngLat",u)),{c(){P(e.$$.fragment),t=R(),P(i.$$.fragment)},m(c,p){L(e,c,p),y(c,t,p),L(i,c,p),s=!0},p(c,p){const m={};p&512&&(m.$$scope={dirty:p,ctx:c}),!n&&p&2&&(n=!0,m.lngLat=c[1],ne(()=>n=!1)),e.$set(m);const g={};p&512&&(g.$$scope={dirty:p,ctx:c}),!o&&p&16&&(o=!0,g.lngLat=c[4],ne(()=>o=!1)),i.$set(g)},i(c){s||(b(e.$$.fragment,c),b(i.$$.fragment,c),s=!0)},o(c){$(e.$$.fragment,c),$(i.$$.fragment,c),s=!1},d(c){c&&w(t),C(e,c),C(i,c)}}}function tf(r){let e;return{c(){e=q("span"),J(e,"class","dot svelte-1tmbx1c"),ge(e,"background-color","red")},m(n,t){y(n,e,t)},p:Q,d(n){n&&w(e)}}}function nf(r){let e;return{c(){e=q("span"),J(e,"class","dot svelte-1tmbx1c"),ge(e,"background-color","blue")},m(n,t){y(n,e,t)},p:Q,d(n){n&&w(e)}}}function rf(r){let e,n,t,i=r[3]&&Vi(r),o=r[3]&&r[2].mode=="set-image"&&Qi(r);return{c(){i&&i.c(),e=R(),o&&o.c(),n=ce()},m(s,a){i&&i.m(s,a),y(s,e,a),o&&o.m(s,a),y(s,n,a),t=!0},p(s,[a]){s[3]?i?(i.p(s,a),a&8&&b(i,1)):(i=Vi(s),i.c(),b(i,1),i.m(e.parentNode,e)):i&&(se(),$(i,1,1,()=>{i=null}),le()),s[3]&&s[2].mode=="set-image"?o?(o.p(s,a),a&12&&b(o,1)):(o=Qi(s),o.c(),b(o,1),o.m(n.parentNode,n)):o&&(se(),$(o,1,1,()=>{o=null}),le())},i(s){t||(b(i),b(o),t=!0)},o(s){$(i),$(o),t=!1},d(s){s&&(w(e),w(n)),i&&i.d(s),o&&o.d(s)}}}function of(r,e,n){let t,i,o,s;W(r,et,p=>n(6,t=p)),W(r,pe,p=>n(2,i=p)),W(r,An,p=>n(3,o=p)),W(r,Nn,p=>n(5,s=p));let{cfg:a}=e,l={lng:0,lat:0},u={lng:0,lat:0};function f(p){l=p,n(1,l),n(6,t),n(3,o),n(2,i)}function c(p){u=p,n(4,u),n(6,t),n(3,o),n(2,i),n(1,l)}return r.$$set=p=>{"cfg"in p&&n(0,a=p.cfg)},r.$$.update=()=>{if(r.$$.dirty&78&&t&&o&&i.mode=="set-image"&&l.lng==0&&l.lat==0){let p=t.getBounds();n(1,l.lng=p.getWest()+.4*(p.getEast()-p.getWest()),l),n(4,u.lng=p.getWest()+.6*(p.getEast()-p.getWest()),u),n(1,l.lat=p.getNorth()+.4*(p.getSouth()-p.getNorth()),l),n(4,u.lat=p.getNorth()+.6*(p.getSouth()-p.getNorth()),u)}},[a,l,i,o,u,s,t,f,c]}class sf extends re{constructor(e){super(),ie(this,e,of,rf,te,{cfg:0})}}function lf(r){let e,n,t,i,o,s;const a=[ue(r[0],"hover-polygons"),{filter:St},{paint:{"line-color":sn.hovering,"line-width":.5*kt}}];let l={};for(let m=0;m(s(),s=Ke(u,f=>n(4,o=f)),u);W(r,on,f=>n(3,i=f)),r.$$.on_destroy.push(()=>s());let{cfg:l}=e,{gjSchemes:u}=e;return a(),r.$$set=f=>{"cfg"in f&&n(0,l=f.cfg),"gjSchemes"in f&&a(n(1,u=f.gjSchemes))},r.$$.update=()=>{r.$$.dirty&24&&n(2,t=i==null?Jt():o.features.find(f=>f.id==i))},[l,u,t,i,o]}class ff extends re{constructor(e){super(),ie(this,e,uf,af,te,{cfg:0,gjSchemes:1})}}function xi(r){let e,n;return e=new Gr({props:{openOn:"hover",openIfTopMost:!0,$$slots:{default:[cf,({features:t})=>({16:t}),({features:t})=>t?65536:0]},$$scope:{ctx:r}}}),{c(){P(e.$$.fragment)},m(t,i){L(e,t,i),n=!0},p(t,i){const o={};i&196608&&(o.$$scope={dirty:i,ctx:t}),e.$set(o)},i(t){n||(b(e.$$.fragment,t),n=!0)},o(t){$(e.$$.fragment,t),n=!1},d(t){C(e,t)}}}function cf(r){let e,n,t=r[9](r[16])+"",i;return{c(){e=q("div"),n=q("p"),i=z(t),J(e,"class","govuk-prose")},m(o,s){y(o,e,s),G(e,n),G(n,i)},p(o,s){s&65536&&t!==(t=o[9](o[16])+"")&&be(i,t)},d(o){o&&w(e)}}}function pf(r){let e,n,t=r[4]&&xi(r);return{c(){t&&t.c(),e=ce()},m(i,o){t&&t.m(i,o),y(i,e,o),n=!0},p(i,o){i[4]?t?(t.p(i,o),o&16&&b(t,1)):(t=xi(i),t.c(),b(t,1),t.m(e.parentNode,e)):t&&(se(),$(t,1,1,()=>{t=null}),le())},i(i){n||(b(t),n=!0)},o(i){$(t),n=!1},d(i){i&&w(e),t&&t.d(i)}}}function eo(r){let e,n;return e=new Gr({props:{openOn:"hover",openIfTopMost:!0,$$slots:{default:[mf,({features:t})=>({16:t}),({features:t})=>t?65536:0]},$$scope:{ctx:r}}}),{c(){P(e.$$.fragment)},m(t,i){L(e,t,i),n=!0},p(t,i){const o={};i&196608&&(o.$$scope={dirty:i,ctx:t}),e.$set(o)},i(t){n||(b(e.$$.fragment,t),n=!0)},o(t){$(e.$$.fragment,t),n=!1},d(t){C(e,t)}}}function mf(r){let e,n,t=r[9](r[16])+"",i;return{c(){e=q("div"),n=q("p"),i=z(t),J(e,"class","govuk-prose")},m(o,s){y(o,e,s),G(e,n),G(n,i)},p(o,s){s&65536&&t!==(t=o[9](o[16])+"")&&be(i,t)},d(o){o&&w(e)}}}function df(r){let e,n,t=r[4]&&eo(r);return{c(){t&&t.c(),e=ce()},m(i,o){t&&t.m(i,o),y(i,e,o),n=!0},p(i,o){i[4]?t?(t.p(i,o),o&16&&b(t,1)):(t=eo(i),t.c(),b(t,1),t.m(e.parentNode,e)):t&&(se(),$(t,1,1,()=>{t=null}),le())},i(i){n||(b(t),n=!0)},o(i){$(t),n=!1},d(i){i&&w(e),t&&t.d(i)}}}function to(r){let e,n;return e=new Gr({props:{openOn:"hover",openIfTopMost:!0,$$slots:{default:[gf,({features:t})=>({16:t}),({features:t})=>t?65536:0]},$$scope:{ctx:r}}}),{c(){P(e.$$.fragment)},m(t,i){L(e,t,i),n=!0},p(t,i){const o={};i&196608&&(o.$$scope={dirty:i,ctx:t}),e.$set(o)},i(t){n||(b(e.$$.fragment,t),n=!0)},o(t){$(e.$$.fragment,t),n=!1},d(t){C(e,t)}}}function gf(r){let e,n,t=r[9](r[16])+"",i;return{c(){e=q("div"),n=q("p"),i=z(t),J(e,"class","govuk-prose")},m(o,s){y(o,e,s),G(e,n),G(n,i)},p(o,s){s&65536&&t!==(t=o[9](o[16])+"")&&be(i,t)},d(o){o&&w(e)}}}function hf(r){let e,n,t=r[4]&&to(r);return{c(){t&&t.c(),e=ce()},m(i,o){t&&t.m(i,o),y(i,e,o),n=!0},p(i,o){i[4]?t?(t.p(i,o),o&16&&b(t,1)):(t=to(i),t.c(),b(t,1),t.m(e.parentNode,e)):t&&(se(),$(t,1,1,()=>{t=null}),le())},i(i){n||(b(t),n=!0)},o(i){$(t),n=!1},d(i){i&&w(e),t&&t.d(i)}}}function _f(r){let e,n,t,i,o,s,a,l,u,f;const c=[ue(r[0],"interventions-points"),{filter:["all",dn,r[6],r[7],r[3]]},{paint:{"circle-color":r[2],"circle-radius":jn}},{hoverCursor:r[4]?"pointer":void 0},{manageHoverState:r[4]}];let p={$$slots:{default:[pf]},$$scope:{ctx:r}};for(let d=0;d(l(),l=Ke(g,d=>n(11,a=d)),g),f,c,p;W(r,et,d=>n(14,f=d)),W(r,pe,d=>n(12,c=d)),W(r,ln,d=>n(13,p=d)),r.$$.on_destroy.push(()=>l());let{cfg:m}=e,{gjSchemes:g}=e;u();const v=["!=",["get","hide_while_editing"],!0],k=["!=",["get","endpoint"],!0];let M;function _(d){return xt(["get","scheme_reference"],Object.fromEntries(Object.values(d.schemes).map(S=>[S.scheme_reference,S.color])),"black")}function h(d){c.mode!="list"||!f||d.detail.features[0]&&(f.getCanvas().style.cursor="inherit",pe.set({mode:"edit",id:d.detail.features[0].id}))}function E(d){if(d){let S=d[0],N=m.interventionName(S),j=m.schemeName(a.schemes[S.properties.scheme_reference]);return`${N} (${j})`}return"Tooltip bug"}return r.$$set=d=>{"cfg"in d&&n(0,m=d.cfg),"gjSchemes"in d&&u(n(1,g=d.gjSchemes))},r.$$.update=()=>{if(r.$$.dirty&2048&&n(5,t=Nl(a)),r.$$.dirty&4096&&n(4,i=c.mode=="list"),r.$$.dirty&8192&&n(3,o=vf(p)),r.$$.dirty&2048&&n(10,s=_(a)),r.$$.dirty&5120){let d="grey";c.mode=="list"?n(2,M=s):c.mode=="split-route"?n(2,M=["case",["==","intervention_type","route"],s,d]):n(2,M=d)}},[m,g,M,o,i,t,v,k,h,E,s,a,c,p]}class yf extends re{constructor(e){super(),ie(this,e,$f,bf,te,{cfg:0,gjSchemes:1})}}function wf(r){let e,n,t,i,o,s;function a(f){r[3](f)}var l=r[0].editFeatureForm;function u(f,c){let p={cfg:f[0],gjSchemes:f[1],id:null};return f[2]!==void 0&&(p.props=f[2]),{props:p}}return l&&(t=zt(l,u(r)),V.push(()=>x(t,"props",a))),{c(){e=q("h2"),e.textContent="New intervention",n=R(),t&&P(t.$$.fragment),o=ce()},m(f,c){y(f,e,c),y(f,n,c),t&&L(t,f,c),y(f,o,c),s=!0},p(f,[c]){if(c&1&&l!==(l=f[0].editFeatureForm)){if(t){se();const p=t;$(p.$$.fragment,1,0,()=>{C(p,1)}),le()}l?(t=zt(l,u(f)),V.push(()=>x(t,"props",a)),P(t.$$.fragment),b(t.$$.fragment,1),L(t,o.parentNode,o)):t=null}else if(l){const p={};c&1&&(p.cfg=f[0]),c&2&&(p.gjSchemes=f[1]),!i&&c&4&&(i=!0,p.props=f[2],ne(()=>i=!1)),t.$set(p)}},i(f){s||(t&&b(t.$$.fragment,f),s=!0)},o(f){t&&$(t.$$.fragment,f),s=!1},d(f){f&&(w(e),w(n),w(o)),t&&C(t,f)}}}function kf(r,e,n){let t;W(r,Ge,a=>n(2,t=a));let{cfg:i}=e,{gjSchemes:o}=e;it(()=>{Ne(Ge,t={},t)}),We(()=>{Ne(Ge,t={},t)});function s(a){t=a,Ge.set(t)}return r.$$set=a=>{"cfg"in a&&n(0,i=a.cfg),"gjSchemes"in a&&n(1,o=a.gjSchemes)},[i,o,t,s]}class Sf extends re{constructor(e){super(),ie(this,e,kf,wf,te,{cfg:0,gjSchemes:1})}}function Ef(r){let e,n,t,i,o,s;const a=[ue(r[0],"edit-polygon-fill"),{filter:St},{paint:{"fill-color":"red","fill-opacity":["case",["boolean",["get","hover"],"false"],1,.5]}}];let l={};for(let m=0;mn(1,t=o));let{cfg:i}=e;return r.$$set=o=>{"cfg"in o&&n(0,i=o.cfg)},[i,t]}class Lf extends re{constructor(e){super(),ie(this,e,Pf,Mf,te,{cfg:0})}}const Ps=ut(Jt()),Rn=ut(Jt()),Ls=ut(!0),Hr=ut(0);function Cf(r){let e,n,t,i,o,s;const a=[ue(r[0],"route-points"),{filter:dn},{paint:{"circle-color":xt(["get","type"],{"snapped-waypoint":"red","free-waypoint":"blue"},"black"),"circle-opacity":["case",["has","hovered"],.5,1],"circle-radius":xt(["get","type"],{node:En/2},En)}}];let l={};for(let m=0;m({3:t}),({feature:t})=>t?8:0]},$$scope:{ctx:r}}}),{c(){P(e.$$.fragment)},m(t,i){L(e,t,i),n=!0},p(t,i){const o={};i&24&&(o.$$scope={dirty:i,ctx:t}),e.$set(o)},i(t){n||(b(e.$$.fragment,t),n=!0)},o(t){$(e.$$.fragment,t),n=!1},d(t){C(e,t)}}}function Nf(r){let e,n,t,i;return e=new Mt({props:{data:r[1],$$slots:{default:[Cf]},$$scope:{ctx:r}}}),t=new Mt({props:{data:r[2],$$slots:{default:[Af]},$$scope:{ctx:r}}}),{c(){P(e.$$.fragment),n=R(),P(t.$$.fragment)},m(o,s){L(e,o,s),y(o,n,s),L(t,o,s),i=!0},p(o,[s]){const a={};s&2&&(a.data=o[1]),s&17&&(a.$$scope={dirty:s,ctx:o}),e.$set(a);const l={};s&4&&(l.data=o[2]),s&16&&(l.$$scope={dirty:s,ctx:o}),t.$set(l)},i(o){i||(b(e.$$.fragment,o),b(t.$$.fragment,o),i=!0)},o(o){$(e.$$.fragment,o),$(t.$$.fragment,o),i=!1},d(o){o&&w(n),C(e,o),C(t,o)}}}const En=10;function no(r){var e;return(e=r.properties)==null?void 0:e.number}function Rf(r,e,n){let t,i;W(r,Ps,s=>n(1,t=s)),W(r,Rn,s=>n(2,i=s));let{cfg:o}=e;return r.$$set=s=>{"cfg"in s&&n(0,o=s.cfg)},[o,t,i]}class Of extends re{constructor(e){super(),ie(this,e,Rf,Nf,te,{cfg:0})}}function jf(r){let e;return{c(){e=z("Finish")},m(n,t){y(n,e,t)},d(n){n&&w(e)}}}function If(r){let e,n;return e=new Ol({}),{c(){P(e.$$.fragment)},m(t,i){L(e,t,i),n=!0},i(t){n||(b(e.$$.fragment,t),n=!0)},o(t){$(e.$$.fragment,t),n=!1},d(t){C(e,t)}}}function Bf(r){let e,n,t,i;return e=new _t({props:{$$slots:{default:[jf]},$$scope:{ctx:r}}}),e.$on("click",r[6]),t=new Rt({props:{$$slots:{default:[If]},$$scope:{ctx:r}}}),{c(){P(e.$$.fragment),n=R(),P(t.$$.fragment)},m(o,s){L(e,o,s),y(o,n,s),L(t,o,s),i=!0},p(o,s){const a={};s&128&&(a.$$scope={dirty:s,ctx:o}),e.$set(a);const l={};s&128&&(l.$$scope={dirty:s,ctx:o}),t.$set(l)},i(o){i||(b(e.$$.fragment,o),b(t.$$.fragment,o),i=!0)},o(o){$(e.$$.fragment,o),$(t.$$.fragment,o),i=!1},d(o){o&&w(n),C(e,o),C(t,o)}}}function qf(r){let e,n,t,i,o,s,a,l,u,f;function c(v){r[4](v)}let p={cfg:r[0],map:r[2],showControls:!1};r[1]!==void 0&&(p.enabled=r[1]),e=new Rl({props:p}),V.push(()=>x(e,"enabled",c));function m(v){r[5](v)}let g={label:"Source",choices:[["google","Google Street View"],["bing","Bing Streetside"]],inlineSmall:!0,leftLabel:!0};return r[3].streetViewImagery!==void 0&&(g.value=r[3].streetViewImagery),o=new Pt({props:g}),V.push(()=>x(o,"value",m)),u=new He({props:{$$slots:{default:[Bf]},$$scope:{ctx:r}}}),{c(){P(e.$$.fragment),t=R(),i=q("div"),P(o.$$.fragment),a=R(),l=q("div"),P(u.$$.fragment),ge(l,"margin-left","auto"),ge(i,"display","flex")},m(v,k){L(e,v,k),y(v,t,k),y(v,i,k),L(o,i,null),G(i,a),G(i,l),L(u,l,null),f=!0},p(v,[k]){const M={};k&1&&(M.cfg=v[0]),k&4&&(M.map=v[2]),!n&&k&2&&(n=!0,M.enabled=v[1],ne(()=>n=!1)),e.$set(M);const _={};!s&&k&8&&(s=!0,_.value=v[3].streetViewImagery,ne(()=>s=!1)),o.$set(_);const h={};k&130&&(h.$$scope={dirty:k,ctx:v}),u.$set(h)},i(v){f||(b(e.$$.fragment,v),b(o.$$.fragment,v),b(u.$$.fragment,v),f=!0)},o(v){$(e.$$.fragment,v),$(o.$$.fragment,v),$(u.$$.fragment,v),f=!1},d(v){v&&(w(t),w(i)),C(e,v),C(o),C(u)}}}function Gf(r,e,n){let t,i;W(r,et,f=>n(2,t=f)),W(r,ti,f=>n(3,i=f));let{cfg:o}=e,s=!0;function a(f){s=f,n(1,s)}function l(f){r.$$.not_equal(i.streetViewImagery,f)&&(i.streetViewImagery=f,ti.set(i))}const u=()=>n(1,s=!1);return r.$$set=f=>{"cfg"in f&&n(0,o=f.cfg)},r.$$.update=()=>{r.$$.dirty&2&&(s||pe.set({mode:"list"}))},[o,s,t,i,a,l,u]}class Tf extends re{constructor(e){super(),ie(this,e,Gf,qf,te,{cfg:0})}}const Df="/atip/move_draw_controls/assets/image-3e3a13e8.svg",Uf="/atip/move_draw_controls/assets/point-276f4055.svg",zf="/atip/move_draw_controls/assets/polygon_freehand-cf965967.svg",Jf="/atip/move_draw_controls/assets/polygon_snapped-18efbbea.svg",Yf="/atip/move_draw_controls/assets/route-d3c0ebad.svg",Cs="/atip/move_draw_controls/assets/split_route-9e0ea2da.svg",Xf="/atip/move_draw_controls/assets/street_view-48580b6a.svg";function Wf(r){let e;return{c(){e=z("Cancel")},m(n,t){y(n,e,t)},d(n){n&&w(e)}}}function Kf(r){let e;return{c(){e=q("li"),e.textContent="Click to add a new point"},m(n,t){y(n,e,t)},d(n){n&&w(e)}}}function Hf(r){let e;return{c(){e=q("li"),e.textContent="Click to move the point here"},m(n,t){y(n,e,t)},d(n){n&&w(e)}}}function Zf(r){let e,n,t;function i(a,l){return a[0]?Hf:Kf}let o=i(r),s=o(r);return{c(){e=q("ul"),s.c(),n=R(),t=q("li"),t.innerHTML=`Press Escape + to cancel`},m(a,l){y(a,e,l),s.m(e,null),G(e,n),G(e,t)},p(a,l){o!==(o=i(a))&&(s.d(1),s=o(a),s&&(s.c(),s.m(e,n)))},d(a){a&&w(e),s.d()}}}function Vf(r){let e,n,t,i;return e=new _e({props:{$$slots:{default:[Wf]},$$scope:{ctx:r}}}),e.$on("click",function(){Lt(r[1])&&r[1].apply(this,arguments)}),t=new Rt({props:{$$slots:{default:[Zf]},$$scope:{ctx:r}}}),{c(){P(e.$$.fragment),n=R(),P(t.$$.fragment)},m(o,s){L(e,o,s),y(o,n,s),L(t,o,s),i=!0},p(o,s){r=o;const a={};s&4&&(a.$$scope={dirty:s,ctx:r}),e.$set(a);const l={};s&5&&(l.$$scope={dirty:s,ctx:r}),t.$set(l)},i(o){i||(b(e.$$.fragment,o),b(t.$$.fragment,o),i=!0)},o(o){$(e.$$.fragment,o),$(t.$$.fragment,o),i=!1},d(o){o&&w(n),C(e,o),C(t,o)}}}function Qf(r){let e,n,t;return n=new He({props:{$$slots:{default:[Vf]},$$scope:{ctx:r}}}),{c(){e=q("div"),P(n.$$.fragment),ge(e,"float","right")},m(i,o){y(i,e,o),L(n,e,null),t=!0},p(i,[o]){const s={};o&7&&(s.$$scope={dirty:o,ctx:i}),n.$set(s)},i(i){t||(b(n.$$.fragment,i),t=!0)},o(i){$(n.$$.fragment,i),t=!1},d(i){i&&w(e),C(n)}}}function xf(r,e,n){let{editingExisting:t}=e,{cancel:i}=e;return r.$$set=o=>{"editingExisting"in o&&n(0,t=o.editingExisting),"cancel"in o&&n(1,i=o.cancel)},[t,i]}class Fs extends re{constructor(e){super(),ie(this,e,xf,Qf,te,{editingExisting:0,cancel:1})}}function ec(r){let e;return{c(){e=z("Finish")},m(n,t){y(n,e,t)},d(n){n&&w(e)}}}function tc(r){let e,n,t;return{c(){e=z("Undo ("),n=z(r[2]),t=z(")")},m(i,o){y(i,e,o),y(i,n,o),y(i,t,o)},p(i,o){o&4&&be(n,i[2])},d(i){i&&(w(e),w(n),w(t))}}}function nc(r){let e;return{c(){e=z("Undo")},m(n,t){y(n,e,t)},p:Q,d(n){n&&w(e)}}}function rc(r){let e;function n(o,s){return o[2]==0?nc:tc}let t=n(r),i=t(r);return{c(){i.c(),e=ce()},m(o,s){i.m(o,s),y(o,e,s)},p(o,s){t===(t=n(o))&&i?i.p(o,s):(i.d(1),i=t(o),i&&(i.c(),i.m(e.parentNode,e)))},d(o){o&&w(e),i.d(o)}}}function ic(r){let e;return{c(){e=z("Cancel")},m(n,t){y(n,e,t)},d(n){n&&w(e)}}}function oc(r){let e;return{c(){e=q("ul"),e.innerHTML=`
  • Click the map to add a vertex
  • Click a vertex to delete it
  • Drag a vertex or the polygon to move it
  • Press Control+Z @@ -29,7 +29,7 @@ and limitations under the License. or double click to finish
  • Press Escape - to cancel
  • `},m(n,t){y(n,e,t)},p:Q,d(n){n&&w(e)}}}function sc(r){let e,n,t,i,o,s,a,l;return e=new _t({props:{$$slots:{default:[ec]},$$scope:{ctx:r}}}),e.$on("click",function(){Lt(r[0])&&r[0].apply(this,arguments)}),t=new _e({props:{disabled:r[2]==0,$$slots:{default:[rc]},$$scope:{ctx:r}}}),t.$on("click",r[3]),o=new _e({props:{$$slots:{default:[ic]},$$scope:{ctx:r}}}),o.$on("click",function(){Lt(r[1])&&r[1].apply(this,arguments)}),a=new Rt({props:{$$slots:{default:[oc]},$$scope:{ctx:r}}}),{c(){P(e.$$.fragment),n=R(),P(t.$$.fragment),i=R(),P(o.$$.fragment),s=R(),P(a.$$.fragment)},m(u,f){L(e,u,f),y(u,n,f),L(t,u,f),y(u,i,f),L(o,u,f),y(u,s,f),L(a,u,f),l=!0},p(u,f){r=u;const c={};f&32&&(c.$$scope={dirty:f,ctx:r}),e.$set(c);const p={};f&4&&(p.disabled=r[2]==0),f&36&&(p.$$scope={dirty:f,ctx:r}),t.$set(p);const m={};f&32&&(m.$$scope={dirty:f,ctx:r}),o.$set(m);const g={};f&32&&(g.$$scope={dirty:f,ctx:r}),a.$set(g)},i(u){l||(_(e.$$.fragment,u),_(t.$$.fragment,u),_(o.$$.fragment,u),_(a.$$.fragment,u),l=!0)},o(u){$(e.$$.fragment,u),$(t.$$.fragment,u),$(o.$$.fragment,u),$(a.$$.fragment,u),l=!1},d(u){u&&(w(n),w(i),w(s)),F(e,u),F(t,u),F(o,u),F(a,u)}}}function lc(r){let e,n,t;return n=new Ke({props:{$$slots:{default:[sc]},$$scope:{ctx:r}}}),{c(){e=q("div"),P(n.$$.fragment),ge(e,"float","right")},m(i,o){y(i,e,o),L(n,e,null),t=!0},p(i,[o]){const s={};o&39&&(s.$$scope={dirty:o,ctx:i}),n.$set(s)},i(i){t||(_(n.$$.fragment,i),t=!0)},o(i){$(n.$$.fragment,i),t=!1},d(i){i&&w(e),F(n)}}}function ac(r,e,n){let t,i;K(r,pn,l=>n(4,t=l)),K(r,vs,l=>n(2,i=l));let{finish:o}=e,{cancel:s}=e;function a(){t.undo()}return r.$$set=l=>{"finish"in l&&n(0,o=l.finish),"cancel"in l&&n(1,s=l.cancel)},[o,s,i,a]}class As extends re{constructor(e){super(),ie(this,e,ac,lc,te,{finish:0,cancel:1})}}function ro(r,e,n){const t=r.slice();return t[9]=e[n],t}function io(r){let e,n,t=r[9].place_name+"",i,o,s;function a(...l){return r[5](r[9],...l)}return{c(){e=q("li"),n=q("a"),i=D(t),J(n,"href","#")},m(l,u){y(l,e,u),G(e,n),G(n,i),o||(s=he(n,"click",a),o=!0)},p(l,u){r=l,u&2&&t!==(t=r[9].place_name+"")&&be(i,t)},d(l){l&&w(e),o=!1,s()}}}function uc(r){let e,n,t,i,o;function s(f){r[4](f)}let a={label:"Add waypoint by search"};r[0]!==void 0&&(a.value=r[0]),e=new ir({props:a}),V.push(()=>x(e,"value",s));let l=Ie(r[1].features),u=[];for(let f=0;fn=!1)),e.$set(p),c&6){l=Ie(f[1].features);let m;for(m=0;mn(6,t=p)),K(r,Rn,p=>n(1,i=p)),K(r,xe,p=>n(7,o=p));let{maptilerApiKey:s}=e,a="";async function l(p){if(!p){je(Rn,i=Jt(),i);return}let m=new URLSearchParams({country:"gb",proximity:o.getCenter().toArray().join(","),fuzzyMatch:"true",key:s}).toString(),g=`https://api.maptiler.com/geocoding/${p}.json?${m}`,S=await(await fetch(g)).json(),k=1;for(let b of S.features)b.properties.number=k++;je(Rn,i=S,i)}function u(p,m){p.preventDefault(),t.addSnappedWaypoint(m),n(0,a="")}function f(p){a=p,n(0,a)}const c=(p,m)=>u(m,p.center);return r.$$set=p=>{"maptilerApiKey"in p&&n(3,s=p.maptilerApiKey)},r.$$.update=()=>{r.$$.dirty&1&&l(a)},[a,i,u,s,f,c]}class cc extends re{constructor(e){super(),ie(this,e,fc,uc,te,{maptilerApiKey:3})}}function oo(r){let e,n;return e=new cc({props:{maptilerApiKey:r[1]}}),{c(){P(e.$$.fragment)},m(t,i){L(e,t,i),n=!0},p(t,i){const o={};i&2&&(o.maptilerApiKey=t[1]),e.$set(o)},i(t){n||(_(e.$$.fragment,t),n=!0)},o(t){$(e.$$.fragment,t),n=!1},d(t){F(e,t)}}}function pc(r){let e;return{c(){e=D("Add points to end")},m(n,t){y(n,e,t)},d(n){n&&w(e)}}}function mc(r){let e,n,t;function i(s){r[9](s)}let o={hint:"Keep clicking to add more points to the end of the route",$$slots:{default:[pc]},$$scope:{ctx:r}};return r[0]!==void 0&&(o.checked=r[0]),e=new Ft({props:o}),V.push(()=>x(e,"checked",i)),{c(){P(e.$$.fragment)},m(s,a){L(e,s,a),t=!0},p(s,a){const l={};a&1024&&(l.$$scope={dirty:a,ctx:s}),!n&&a&1&&(n=!0,l.checked=s[0],ne(()=>n=!1)),e.$set(l)},i(s){t||(_(e.$$.fragment,s),t=!0)},o(s){$(e.$$.fragment,s),t=!1},d(s){F(e,s)}}}function dc(r){let e;return{c(){e=D("Finish")},m(n,t){y(n,e,t)},d(n){n&&w(e)}}}function gc(r){let e,n,t;return{c(){e=D("Undo ("),n=D(r[5]),t=D(")")},m(i,o){y(i,e,o),y(i,n,o),y(i,t,o)},p(i,o){o&32&&be(n,i[5])},d(i){i&&(w(e),w(n),w(t))}}}function hc(r){let e;return{c(){e=D("Undo")},m(n,t){y(n,e,t)},p:Q,d(n){n&&w(e)}}}function _c(r){let e;function n(o,s){return o[5]==0?hc:gc}let t=n(r),i=t(r);return{c(){i.c(),e=ce()},m(o,s){i.m(o,s),y(o,e,s)},p(o,s){t===(t=n(o))&&i?i.p(o,s):(i.d(1),i=t(o),i&&(i.c(),i.m(e.parentNode,e)))},d(o){o&&w(e),i.d(o)}}}function bc(r){let e;return{c(){e=D("Cancel")},m(n,t){y(n,e,t)},d(n){n&&w(e)}}}function vc(r){let e;return{c(){e=q("ul"),e.innerHTML=`
  • Click + to cancel
  • `},m(n,t){y(n,e,t)},p:Q,d(n){n&&w(e)}}}function sc(r){let e,n,t,i,o,s,a,l;return e=new _t({props:{$$slots:{default:[ec]},$$scope:{ctx:r}}}),e.$on("click",function(){Lt(r[0])&&r[0].apply(this,arguments)}),t=new _e({props:{disabled:r[2]==0,$$slots:{default:[rc]},$$scope:{ctx:r}}}),t.$on("click",r[3]),o=new _e({props:{$$slots:{default:[ic]},$$scope:{ctx:r}}}),o.$on("click",function(){Lt(r[1])&&r[1].apply(this,arguments)}),a=new Rt({props:{$$slots:{default:[oc]},$$scope:{ctx:r}}}),{c(){P(e.$$.fragment),n=R(),P(t.$$.fragment),i=R(),P(o.$$.fragment),s=R(),P(a.$$.fragment)},m(u,f){L(e,u,f),y(u,n,f),L(t,u,f),y(u,i,f),L(o,u,f),y(u,s,f),L(a,u,f),l=!0},p(u,f){r=u;const c={};f&32&&(c.$$scope={dirty:f,ctx:r}),e.$set(c);const p={};f&4&&(p.disabled=r[2]==0),f&36&&(p.$$scope={dirty:f,ctx:r}),t.$set(p);const m={};f&32&&(m.$$scope={dirty:f,ctx:r}),o.$set(m);const g={};f&32&&(g.$$scope={dirty:f,ctx:r}),a.$set(g)},i(u){l||(b(e.$$.fragment,u),b(t.$$.fragment,u),b(o.$$.fragment,u),b(a.$$.fragment,u),l=!0)},o(u){$(e.$$.fragment,u),$(t.$$.fragment,u),$(o.$$.fragment,u),$(a.$$.fragment,u),l=!1},d(u){u&&(w(n),w(i),w(s)),C(e,u),C(t,u),C(o,u),C(a,u)}}}function lc(r){let e,n,t;return n=new He({props:{$$slots:{default:[sc]},$$scope:{ctx:r}}}),{c(){e=q("div"),P(n.$$.fragment),ge(e,"float","right")},m(i,o){y(i,e,o),L(n,e,null),t=!0},p(i,[o]){const s={};o&39&&(s.$$scope={dirty:o,ctx:i}),n.$set(s)},i(i){t||(b(n.$$.fragment,i),t=!0)},o(i){$(n.$$.fragment,i),t=!1},d(i){i&&w(e),C(n)}}}function ac(r,e,n){let t,i;W(r,pn,l=>n(4,t=l)),W(r,vs,l=>n(2,i=l));let{finish:o}=e,{cancel:s}=e;function a(){t.undo()}return r.$$set=l=>{"finish"in l&&n(0,o=l.finish),"cancel"in l&&n(1,s=l.cancel)},[o,s,i,a]}class As extends re{constructor(e){super(),ie(this,e,ac,lc,te,{finish:0,cancel:1})}}function ro(r,e,n){const t=r.slice();return t[9]=e[n],t}function io(r){let e,n,t=r[9].place_name+"",i,o,s;function a(...l){return r[5](r[9],...l)}return{c(){e=q("li"),n=q("a"),i=z(t),J(n,"href","#")},m(l,u){y(l,e,u),G(e,n),G(n,i),o||(s=he(n,"click",a),o=!0)},p(l,u){r=l,u&2&&t!==(t=r[9].place_name+"")&&be(i,t)},d(l){l&&w(e),o=!1,s()}}}function uc(r){let e,n,t,i,o;function s(f){r[4](f)}let a={label:"Add waypoint by search"};r[0]!==void 0&&(a.value=r[0]),e=new ir({props:a}),V.push(()=>x(e,"value",s));let l=Ie(r[1].features),u=[];for(let f=0;fn=!1)),e.$set(p),c&6){l=Ie(f[1].features);let m;for(m=0;mn(6,t=p)),W(r,Rn,p=>n(1,i=p)),W(r,et,p=>n(7,o=p));let{maptilerApiKey:s}=e,a="";async function l(p){if(!p){Ne(Rn,i=Jt(),i);return}let m=new URLSearchParams({country:"gb",proximity:o.getCenter().toArray().join(","),fuzzyMatch:"true",key:s}).toString(),g=`https://api.maptiler.com/geocoding/${p}.json?${m}`,k=await(await fetch(g)).json(),M=1;for(let _ of k.features)_.properties.number=M++;Ne(Rn,i=k,i)}function u(p,m){p.preventDefault(),t.addSnappedWaypoint(m),n(0,a="")}function f(p){a=p,n(0,a)}const c=(p,m)=>u(m,p.center);return r.$$set=p=>{"maptilerApiKey"in p&&n(3,s=p.maptilerApiKey)},r.$$.update=()=>{r.$$.dirty&1&&l(a)},[a,i,u,s,f,c]}class cc extends re{constructor(e){super(),ie(this,e,fc,uc,te,{maptilerApiKey:3})}}function oo(r){let e,n;return e=new cc({props:{maptilerApiKey:r[1]}}),{c(){P(e.$$.fragment)},m(t,i){L(e,t,i),n=!0},p(t,i){const o={};i&2&&(o.maptilerApiKey=t[1]),e.$set(o)},i(t){n||(b(e.$$.fragment,t),n=!0)},o(t){$(e.$$.fragment,t),n=!1},d(t){C(e,t)}}}function pc(r){let e;return{c(){e=z("Add points to end")},m(n,t){y(n,e,t)},d(n){n&&w(e)}}}function mc(r){let e,n,t;function i(s){r[9](s)}let o={hint:"Keep clicking to add more points to the end of the route",$$slots:{default:[pc]},$$scope:{ctx:r}};return r[0]!==void 0&&(o.checked=r[0]),e=new Ct({props:o}),V.push(()=>x(e,"checked",i)),{c(){P(e.$$.fragment)},m(s,a){L(e,s,a),t=!0},p(s,a){const l={};a&1024&&(l.$$scope={dirty:a,ctx:s}),!n&&a&1&&(n=!0,l.checked=s[0],ne(()=>n=!1)),e.$set(l)},i(s){t||(b(e.$$.fragment,s),t=!0)},o(s){$(e.$$.fragment,s),t=!1},d(s){C(e,s)}}}function dc(r){let e;return{c(){e=z("Finish")},m(n,t){y(n,e,t)},d(n){n&&w(e)}}}function gc(r){let e,n,t;return{c(){e=z("Undo ("),n=z(r[5]),t=z(")")},m(i,o){y(i,e,o),y(i,n,o),y(i,t,o)},p(i,o){o&32&&be(n,i[5])},d(i){i&&(w(e),w(n),w(t))}}}function hc(r){let e;return{c(){e=z("Undo")},m(n,t){y(n,e,t)},p:Q,d(n){n&&w(e)}}}function _c(r){let e;function n(o,s){return o[5]==0?hc:gc}let t=n(r),i=t(r);return{c(){i.c(),e=ce()},m(o,s){i.m(o,s),y(o,e,s)},p(o,s){t===(t=n(o))&&i?i.p(o,s):(i.d(1),i=t(o),i&&(i.c(),i.m(e.parentNode,e)))},d(o){o&&w(e),i.d(o)}}}function bc(r){let e;return{c(){e=z("Cancel")},m(n,t){y(n,e,t)},d(n){n&&w(e)}}}function vc(r){let e;return{c(){e=q("ul"),e.innerHTML=`
  • Click the map to add points
  • Press s to switch between snapping points to existing roads and drawing anywhere
  • Click and drag any point to move it
  • Click @@ -38,7 +38,7 @@ and limitations under the License. or double click to finish
  • Press Escape - to cancel
  • `},m(n,t){y(n,e,t)},p:Q,d(n){n&&w(e)}}}function $c(r){let e,n,t,i,o,s,a,l;return e=new _t({props:{$$slots:{default:[dc]},$$scope:{ctx:r}}}),e.$on("click",function(){Lt(r[2])&&r[2].apply(this,arguments)}),t=new _e({props:{disabled:r[5]==0,$$slots:{default:[_c]},$$scope:{ctx:r}}}),t.$on("click",r[6]),o=new _e({props:{$$slots:{default:[bc]},$$scope:{ctx:r}}}),o.$on("click",function(){Lt(r[3])&&r[3].apply(this,arguments)}),a=new Rt({props:{$$slots:{default:[vc]},$$scope:{ctx:r}}}),{c(){P(e.$$.fragment),n=R(),P(t.$$.fragment),i=R(),P(o.$$.fragment),s=R(),P(a.$$.fragment)},m(u,f){L(e,u,f),y(u,n,f),L(t,u,f),y(u,i,f),L(o,u,f),y(u,s,f),L(a,u,f),l=!0},p(u,f){r=u;const c={};f&1024&&(c.$$scope={dirty:f,ctx:r}),e.$set(c);const p={};f&32&&(p.disabled=r[5]==0),f&1056&&(p.$$scope={dirty:f,ctx:r}),t.$set(p);const m={};f&1024&&(m.$$scope={dirty:f,ctx:r}),o.$set(m);const g={};f&1024&&(g.$$scope={dirty:f,ctx:r}),a.$set(g)},i(u){l||(_(e.$$.fragment,u),_(t.$$.fragment,u),_(o.$$.fragment,u),_(a.$$.fragment,u),l=!0)},o(u){$(e.$$.fragment,u),$(t.$$.fragment,u),$(o.$$.fragment,u),$(a.$$.fragment,u),l=!1},d(u){u&&(w(n),w(i),w(s)),F(e,u),F(t,u),F(o,u),F(a,u)}}}function yc(r){let e,n,t,i,o,s,a,l,u;n=new Pt({props:{label:"Draw",choices:[["snap","Snap to roads"],["free","Draw anywhere"]],value:r[4]?"snap":"free",leftLabel:!0}}),n.$on("change",r[7]);let f=r[1]&&oo(r);return o=new Ko({props:{small:!0,$$slots:{default:[mc]},$$scope:{ctx:r}}}),l=new Ke({props:{$$slots:{default:[$c]},$$scope:{ctx:r}}}),{c(){e=q("div"),P(n.$$.fragment),t=R(),f&&f.c(),i=R(),P(o.$$.fragment),s=R(),a=q("div"),P(l.$$.fragment),ge(a,"margin-left","auto"),ge(e,"display","flex")},m(c,p){y(c,e,p),L(n,e,null),G(e,t),f&&f.m(e,null),G(e,i),L(o,e,null),G(e,s),G(e,a),L(l,a,null),u=!0},p(c,[p]){const m={};p&16&&(m.value=c[4]?"snap":"free"),n.$set(m),c[1]?f?(f.p(c,p),p&2&&_(f,1)):(f=oo(c),f.c(),_(f,1),f.m(e,i)):f&&(se(),$(f,1,1,()=>{f=null}),le());const g={};p&1025&&(g.$$scope={dirty:p,ctx:c}),o.$set(g);const v={};p&1068&&(v.$$scope={dirty:p,ctx:c}),l.$set(v)},i(c){u||(_(n.$$.fragment,c),_(f),_(o.$$.fragment,c),_(l.$$.fragment,c),u=!0)},o(c){$(n.$$.fragment,c),$(f),$(o.$$.fragment,c),$(l.$$.fragment,c),u=!1},d(c){c&&w(e),F(n),f&&f.d(),F(o),F(l)}}}function wc(r,e,n){let t,i,o;K(r,it,m=>n(8,t=m)),K(r,Ls,m=>n(4,i=m)),K(r,Hr,m=>n(5,o=m));let{maptilerApiKey:s}=e,{extendRoute:a}=e,{finish:l}=e,{cancel:u}=e;function f(){t.undo()}function c(){t.toggleSnapMode()}function p(m){a=m,n(0,a)}return r.$$set=m=>{"maptilerApiKey"in m&&n(1,s=m.maptilerApiKey),"extendRoute"in m&&n(0,a=m.extendRoute),"finish"in m&&n(2,l=m.finish),"cancel"in m&&n(3,u=m.cancel)},r.$$.update=()=>{r.$$.dirty&257&&t.setRouteConfig({avoid_doubling_back:!1,extend_route:a})},[a,s,l,u,i,o,f,c,t,p]}class Ns extends re{constructor(e){super(),ie(this,e,wc,yc,te,{maptilerApiKey:1,extendRoute:0,finish:2,cancel:3})}}function kc(r){let e;return{c(){e=D("Finish")},m(n,t){y(n,e,t)},d(n){n&&w(e)}}}function Sc(r){let e,n,t;return{c(){e=D("Undo ("),n=D(r[2]),t=D(")")},m(i,o){y(i,e,o),y(i,n,o),y(i,t,o)},p(i,o){o&4&&be(n,i[2])},d(i){i&&(w(e),w(n),w(t))}}}function Ec(r){let e;return{c(){e=D("Undo")},m(n,t){y(n,e,t)},p:Q,d(n){n&&w(e)}}}function Mc(r){let e;function n(o,s){return o[2]==0?Ec:Sc}let t=n(r),i=t(r);return{c(){i.c(),e=ce()},m(o,s){i.m(o,s),y(o,e,s)},p(o,s){t===(t=n(o))&&i?i.p(o,s):(i.d(1),i=t(o),i&&(i.c(),i.m(e.parentNode,e)))},d(o){o&&w(e),i.d(o)}}}function Pc(r){let e;return{c(){e=D("Cancel")},m(n,t){y(n,e,t)},d(n){n&&w(e)}}}function Lc(r){let e;return{c(){e=q("ul"),e.innerHTML=`
  • Click + to cancel
  • `},m(n,t){y(n,e,t)},p:Q,d(n){n&&w(e)}}}function $c(r){let e,n,t,i,o,s,a,l;return e=new _t({props:{$$slots:{default:[dc]},$$scope:{ctx:r}}}),e.$on("click",function(){Lt(r[2])&&r[2].apply(this,arguments)}),t=new _e({props:{disabled:r[5]==0,$$slots:{default:[_c]},$$scope:{ctx:r}}}),t.$on("click",r[6]),o=new _e({props:{$$slots:{default:[bc]},$$scope:{ctx:r}}}),o.$on("click",function(){Lt(r[3])&&r[3].apply(this,arguments)}),a=new Rt({props:{$$slots:{default:[vc]},$$scope:{ctx:r}}}),{c(){P(e.$$.fragment),n=R(),P(t.$$.fragment),i=R(),P(o.$$.fragment),s=R(),P(a.$$.fragment)},m(u,f){L(e,u,f),y(u,n,f),L(t,u,f),y(u,i,f),L(o,u,f),y(u,s,f),L(a,u,f),l=!0},p(u,f){r=u;const c={};f&1024&&(c.$$scope={dirty:f,ctx:r}),e.$set(c);const p={};f&32&&(p.disabled=r[5]==0),f&1056&&(p.$$scope={dirty:f,ctx:r}),t.$set(p);const m={};f&1024&&(m.$$scope={dirty:f,ctx:r}),o.$set(m);const g={};f&1024&&(g.$$scope={dirty:f,ctx:r}),a.$set(g)},i(u){l||(b(e.$$.fragment,u),b(t.$$.fragment,u),b(o.$$.fragment,u),b(a.$$.fragment,u),l=!0)},o(u){$(e.$$.fragment,u),$(t.$$.fragment,u),$(o.$$.fragment,u),$(a.$$.fragment,u),l=!1},d(u){u&&(w(n),w(i),w(s)),C(e,u),C(t,u),C(o,u),C(a,u)}}}function yc(r){let e,n,t,i,o,s,a,l,u;n=new Pt({props:{label:"Draw",choices:[["snap","Snap to roads"],["free","Draw anywhere"]],value:r[4]?"snap":"free",leftLabel:!0}}),n.$on("change",r[7]);let f=r[1]&&oo(r);return o=new Ko({props:{small:!0,$$slots:{default:[mc]},$$scope:{ctx:r}}}),l=new He({props:{$$slots:{default:[$c]},$$scope:{ctx:r}}}),{c(){e=q("div"),P(n.$$.fragment),t=R(),f&&f.c(),i=R(),P(o.$$.fragment),s=R(),a=q("div"),P(l.$$.fragment),ge(a,"margin-left","auto"),ge(e,"display","flex")},m(c,p){y(c,e,p),L(n,e,null),G(e,t),f&&f.m(e,null),G(e,i),L(o,e,null),G(e,s),G(e,a),L(l,a,null),u=!0},p(c,[p]){const m={};p&16&&(m.value=c[4]?"snap":"free"),n.$set(m),c[1]?f?(f.p(c,p),p&2&&b(f,1)):(f=oo(c),f.c(),b(f,1),f.m(e,i)):f&&(se(),$(f,1,1,()=>{f=null}),le());const g={};p&1025&&(g.$$scope={dirty:p,ctx:c}),o.$set(g);const v={};p&1068&&(v.$$scope={dirty:p,ctx:c}),l.$set(v)},i(c){u||(b(n.$$.fragment,c),b(f),b(o.$$.fragment,c),b(l.$$.fragment,c),u=!0)},o(c){$(n.$$.fragment,c),$(f),$(o.$$.fragment,c),$(l.$$.fragment,c),u=!1},d(c){c&&w(e),C(n),f&&f.d(),C(o),C(l)}}}function wc(r,e,n){let t,i,o;W(r,ot,m=>n(8,t=m)),W(r,Ls,m=>n(4,i=m)),W(r,Hr,m=>n(5,o=m));let{maptilerApiKey:s}=e,{extendRoute:a}=e,{finish:l}=e,{cancel:u}=e;function f(){t.undo()}function c(){t.toggleSnapMode()}function p(m){a=m,n(0,a)}return r.$$set=m=>{"maptilerApiKey"in m&&n(1,s=m.maptilerApiKey),"extendRoute"in m&&n(0,a=m.extendRoute),"finish"in m&&n(2,l=m.finish),"cancel"in m&&n(3,u=m.cancel)},r.$$.update=()=>{r.$$.dirty&257&&t.setRouteConfig({avoid_doubling_back:!1,extend_route:a})},[a,s,l,u,i,o,f,c,t,p]}class Ns extends re{constructor(e){super(),ie(this,e,wc,yc,te,{maptilerApiKey:1,extendRoute:0,finish:2,cancel:3})}}function kc(r){let e;return{c(){e=z("Finish")},m(n,t){y(n,e,t)},d(n){n&&w(e)}}}function Sc(r){let e,n,t;return{c(){e=z("Undo ("),n=z(r[2]),t=z(")")},m(i,o){y(i,e,o),y(i,n,o),y(i,t,o)},p(i,o){o&4&&be(n,i[2])},d(i){i&&(w(e),w(n),w(t))}}}function Ec(r){let e;return{c(){e=z("Undo")},m(n,t){y(n,e,t)},p:Q,d(n){n&&w(e)}}}function Mc(r){let e;function n(o,s){return o[2]==0?Ec:Sc}let t=n(r),i=t(r);return{c(){i.c(),e=ce()},m(o,s){i.m(o,s),y(o,e,s)},p(o,s){t===(t=n(o))&&i?i.p(o,s):(i.d(1),i=t(o),i&&(i.c(),i.m(e.parentNode,e)))},d(o){o&&w(e),i.d(o)}}}function Pc(r){let e;return{c(){e=z("Cancel")},m(n,t){y(n,e,t)},d(n){n&&w(e)}}}function Lc(r){let e;return{c(){e=q("ul"),e.innerHTML=`
  • Click the map to add points
  • Click and drag any point to move it
  • Click a waypoint to delete it
  • Press Control+Z @@ -46,29 +46,29 @@ and limitations under the License. or double click to finish
  • Press Escape - to cancel
  • `},m(n,t){y(n,e,t)},p:Q,d(n){n&&w(e)}}}function Fc(r){let e,n,t,i,o,s,a,l;return e=new _t({props:{$$slots:{default:[kc]},$$scope:{ctx:r}}}),e.$on("click",function(){Lt(r[0])&&r[0].apply(this,arguments)}),t=new _e({props:{disabled:r[2]==0,$$slots:{default:[Mc]},$$scope:{ctx:r}}}),t.$on("click",r[3]),o=new _e({props:{$$slots:{default:[Pc]},$$scope:{ctx:r}}}),o.$on("click",function(){Lt(r[1])&&r[1].apply(this,arguments)}),a=new Rt({props:{$$slots:{default:[Lc]},$$scope:{ctx:r}}}),{c(){P(e.$$.fragment),n=R(),P(t.$$.fragment),i=R(),P(o.$$.fragment),s=R(),P(a.$$.fragment)},m(u,f){L(e,u,f),y(u,n,f),L(t,u,f),y(u,i,f),L(o,u,f),y(u,s,f),L(a,u,f),l=!0},p(u,f){r=u;const c={};f&32&&(c.$$scope={dirty:f,ctx:r}),e.$set(c);const p={};f&4&&(p.disabled=r[2]==0),f&36&&(p.$$scope={dirty:f,ctx:r}),t.$set(p);const m={};f&32&&(m.$$scope={dirty:f,ctx:r}),o.$set(m);const g={};f&32&&(g.$$scope={dirty:f,ctx:r}),a.$set(g)},i(u){l||(_(e.$$.fragment,u),_(t.$$.fragment,u),_(o.$$.fragment,u),_(a.$$.fragment,u),l=!0)},o(u){$(e.$$.fragment,u),$(t.$$.fragment,u),$(o.$$.fragment,u),$(a.$$.fragment,u),l=!1},d(u){u&&(w(n),w(i),w(s)),F(e,u),F(t,u),F(o,u),F(a,u)}}}function Cc(r){let e,n,t;return n=new Ke({props:{$$slots:{default:[Fc]},$$scope:{ctx:r}}}),{c(){e=q("div"),P(n.$$.fragment),ge(e,"float","right")},m(i,o){y(i,e,o),L(n,e,null),t=!0},p(i,[o]){const s={};o&39&&(s.$$scope={dirty:o,ctx:i}),n.$set(s)},i(i){t||(_(n.$$.fragment,i),t=!0)},o(i){$(n.$$.fragment,i),t=!1},d(i){i&&w(e),F(n)}}}function Ac(r,e,n){let t,i;K(r,it,l=>n(4,t=l)),K(r,Hr,l=>n(2,i=l));let{finish:o}=e,{cancel:s}=e;function a(){t.undo()}return r.$$set=l=>{"finish"in l&&n(0,o=l.finish),"cancel"in l&&n(1,s=l.cancel)},[o,s,i,a]}class Rs extends re{constructor(e){super(),ie(this,e,Ac,Cc,te,{finish:0,cancel:1})}}function Nc(r){let e,n;return e=new Rs({props:{finish:r[2],cancel:r[3]}}),{c(){P(e.$$.fragment)},m(t,i){L(e,t,i),n=!0},p:Q,i(t){n||(_(e.$$.fragment,t),n=!0)},o(t){$(e.$$.fragment,t),n=!1},d(t){F(e,t)}}}function Rc(r){let e,n;return e=new As({props:{finish:r[2],cancel:r[3]}}),{c(){P(e.$$.fragment)},m(t,i){L(e,t,i),n=!0},p:Q,i(t){n||(_(e.$$.fragment,t),n=!0)},o(t){$(e.$$.fragment,t),n=!1},d(t){F(e,t)}}}function Oc(r){let e,n;return e=new Ns({props:{maptilerApiKey:r[0].maptilerApiKey,extendRoute:!1,finish:r[2],cancel:r[3]}}),{c(){P(e.$$.fragment)},m(t,i){L(e,t,i),n=!0},p(t,i){const o={};i&1&&(o.maptilerApiKey=t[0].maptilerApiKey),e.$set(o)},i(t){n||(_(e.$$.fragment,t),n=!0)},o(t){$(e.$$.fragment,t),n=!1},d(t){F(e,t)}}}function jc(r){let e,n;return e=new Cs({props:{editingExisting:!0,cancel:r[3]}}),{c(){P(e.$$.fragment)},m(t,i){L(e,t,i),n=!0},p:Q,i(t){n||(_(e.$$.fragment,t),n=!0)},o(t){$(e.$$.fragment,t),n=!1},d(t){F(e,t)}}}function Ic(r){let e,n,t,i;const o=[jc,Oc,Rc,Nc],s=[];function a(l,u){return l[1]=="point"?0:l[1]=="route"?1:l[1]=="freehand-polygon"?2:l[1]=="snapped-polygon"?3:-1}return~(e=a(r))&&(n=s[e]=o[e](r)),{c(){n&&n.c(),t=ce()},m(l,u){~e&&s[e].m(l,u),y(l,t,u),i=!0},p(l,[u]){let f=e;e=a(l),e===f?~e&&s[e].p(l,u):(n&&(se(),$(s[f],1,1,()=>{s[f]=null}),le()),~e?(n=s[e],n?n.p(l,u):(n=s[e]=o[e](l),n.c()),_(n,1),n.m(t.parentNode,t)):n=null)},i(l){i||(_(n),i=!0)},o(l){$(n),i=!1},d(l){l&&w(t),~e&&s[e].d(l)}}}function Bc(r,e,n){let t,i,o;K(r,pn,k=>n(7,t=k)),K(r,it,k=>n(8,i=k)),K(r,In,k=>n(9,o=k));let{cfg:s}=e,{gjSchemes:a}=e,{id:l}=e,u="",f=null;rt(()=>{let k=null;a.update(h=>(k=h.features.find(M=>M.id==l),k.properties.hide_while_editing=!0,h));let b=k;b.geometry.type=="LineString"?(i==null||i.editExistingRoute(b),i==null||i.addEventListenerSuccess(c),i==null||i.addEventListenerUpdated(p),i==null||i.addEventListenerFailure(m),n(1,u="route")):b.geometry.type=="Polygon"?b.properties.waypoints?(i==null||i.editExistingArea(b),i==null||i.addEventListenerSuccess(c),i==null||i.addEventListenerUpdated(p),i==null||i.addEventListenerFailure(m),n(1,u="snapped-polygon")):(t==null||t.editExisting(b),t==null||t.addEventListenerSuccess(c),t==null||t.addEventListenerUpdated(p),t==null||t.addEventListenerFailure(m),n(1,u="freehand-polygon")):b.geometry.type=="Point"&&(o==null||o.start(),o==null||o.addEventListenerSuccess(c),o==null||o.addEventListenerFailure(m),n(1,u="point"))}),Xe(()=>{o==null||o.stop(),o==null||o.clearEventListeners(),i==null||i.stop(),i==null||i.clearEventListeners(),t==null||t.stop(),t==null||t.clearEventListeners(),a.update(k=>{let b=k.features.find(h=>h.id==l);return b&&(delete b.properties.hide_while_editing,f&&g(b,f)),k})});function c(k){k.properties??(k.properties={}),f=k,pe.set({mode:"list"})}function p(k){f=k}function m(){f=null,pe.set({mode:"list"})}function g(k,b){k.geometry=b.geometry,b.properties.length_meters&&(k.properties.length_meters=b.properties.length_meters),b.properties.waypoints&&(k.properties.waypoints=b.properties.waypoints),s.updateFeature(k,b)}function v(){pe.set({mode:"list"})}function S(){f=null,pe.set({mode:"list"})}return r.$$set=k=>{"cfg"in k&&n(0,s=k.cfg),"gjSchemes"in k&&n(4,a=k.gjSchemes),"id"in k&&n(5,l=k.id)},[s,u,v,S,a,l]}class qc extends re{constructor(e){super(),ie(this,e,Bc,Ic,te,{cfg:0,gjSchemes:4,id:5})}}function Gc(r){let e,n,t;return{c(){e=q("input"),J(e,"class","govuk-file-upload"),J(e,"id","load-image"),J(e,"type","file")},m(i,o){y(i,e,o),r[6](e),n||(t=he(e,"change",r[3]),n=!0)},p:Q,d(i){i&&w(e),r[6](null),n=!1,t()}}}function so(r){let e,n,t,i,o,s,a,l,u,f;return{c(){e=q("div"),n=q("label"),t=q("input"),i=R(),o=q("br"),s=D(` - Opacity: `),a=D(r[1]),l=D("%"),J(t,"type","range"),J(t,"min","0"),J(t,"max","100")},m(c,p){y(c,e,p),G(e,n),G(n,t),Le(t,r[1]),G(n,i),G(n,o),G(n,s),G(n,a),G(n,l),u||(f=[he(t,"change",r[7]),he(t,"input",r[7])],u=!0)},p(c,p){p&2&&Le(t,c[1]),p&2&&be(a,c[1])},d(c){c&&w(e),u=!1,er(f)}}}function Tc(r){let e;return{c(){e=D("Save")},m(n,t){y(n,e,t)},d(n){n&&w(e)}}}function Uc(r){let e;return{c(){e=D("Delete")},m(n,t){y(n,e,t)},d(n){n&&w(e)}}}function Dc(r){let e;return{c(){e=q("p"),e.textContent=`Note this image isn't saved as part of this scheme. When you close - this page, it'll be lost.`},m(n,t){y(n,e,t)},p:Q,d(n){n&&w(e)}}}function zc(r){let e,n,t,i,o,s;return e=new _t({props:{$$slots:{default:[Tc]},$$scope:{ctx:r}}}),e.$on("click",r[8]),t=new bt({props:{disabled:!r[2],$$slots:{default:[Uc]},$$scope:{ctx:r}}}),t.$on("click",r[4]),o=new Rt({props:{$$slots:{default:[Dc]},$$scope:{ctx:r}}}),{c(){P(e.$$.fragment),n=R(),P(t.$$.fragment),i=R(),P(o.$$.fragment)},m(a,l){L(e,a,l),y(a,n,l),L(t,a,l),y(a,i,l),L(o,a,l),s=!0},p(a,l){const u={};l&512&&(u.$$scope={dirty:l,ctx:a}),e.$set(u);const f={};l&4&&(f.disabled=!a[2]),l&512&&(f.$$scope={dirty:l,ctx:a}),t.$set(f);const c={};l&512&&(c.$$scope={dirty:l,ctx:a}),o.$set(c)},i(a){s||(_(e.$$.fragment,a),_(t.$$.fragment,a),_(o.$$.fragment,a),s=!0)},o(a){$(e.$$.fragment,a),$(t.$$.fragment,a),$(o.$$.fragment,a),s=!1},d(a){a&&(w(n),w(i)),F(e,a),F(t,a),F(o,a)}}}function Jc(r){let e,n,t,i,o,s,a,l,u;n=new Ct({props:{label:"Load an image",id:"load-image",$$slots:{default:[Gc]},$$scope:{ctx:r}}});let f=r[2]&&so(r);return s=new Ke({props:{$$slots:{default:[zc]},$$scope:{ctx:r}}}),{c(){e=q("div"),P(n.$$.fragment),t=R(),f&&f.c(),i=R(),o=q("div"),P(s.$$.fragment),ge(o,"margin-left","auto"),ge(e,"display","flex")},m(c,p){y(c,e,p),L(n,e,null),G(e,t),f&&f.m(e,null),G(e,i),G(e,o),L(s,o,null),a=!0,l||(u=he(window,"keydown",r[5]),l=!0)},p(c,[p]){const m={};p&513&&(m.$$scope={dirty:p,ctx:c}),n.$set(m),c[2]?f?f.p(c,p):(f=so(c),f.c(),f.m(e,i)):f&&(f.d(1),f=null);const g={};p&516&&(g.$$scope={dirty:p,ctx:c}),s.$set(g)},i(c){a||(_(n.$$.fragment,c),_(s.$$.fragment,c),a=!0)},o(c){$(n.$$.fragment,c),$(s.$$.fragment,c),a=!1},d(c){c&&w(e),F(n),f&&f.d(),F(s),l=!1,u()}}}function Yc(r,e,n){let t,i;K(r,Nn,p=>n(1,t=p)),K(r,An,p=>n(2,i=p));let o;async function s(p){let m=await o.files[0].arrayBuffer(),g=new Blob([new Uint8Array(m)]);je(An,i=URL.createObjectURL(g),i)}function a(){je(An,i=null,i),je(Nn,t=100,t)}function l(p){p.key=="Escape"&&(p.stopPropagation(),pe.set({mode:"list"}))}function u(p){V[p?"unshift":"push"](()=>{o=p,n(0,o)})}function f(){t=hl(this.value),Nn.set(t)}return[o,t,i,s,a,l,u,f,()=>pe.set({mode:"list"})]}class Xc extends re{constructor(e){super(),ie(this,e,Yc,Jc,te,{})}}function Wc(r){let e,n;return e=new Cs({props:{editingExisting:!1,cancel:r[0]}}),{c(){P(e.$$.fragment)},m(t,i){L(e,t,i),n=!0},p:Q,i(t){n||(_(e.$$.fragment,t),n=!0)},o(t){$(e.$$.fragment,t),n=!1},d(t){F(e,t)}}}function Kc(r,e,n){let t,i;K(r,ct,u=>n(3,t=u)),K(r,In,u=>n(4,i=u));let{cfg:o}=e,{gjSchemes:s}=e;rt(()=>{i.start(),i.addEventListenerSuccess(a),i.addEventListenerFailure(l)}),Xe(()=>{i.stop(),i.clearEventListeners()});function a(u){u.properties||(u.properties={});let f=u;f.properties={...f.properties,...t},s.update(c=>(f.id=_n(c),f.properties.scheme_reference=nr(c),o.newPointFeature(f),c.features.push(f),c)),pe.set({mode:"list"})}function l(){pe.set({mode:"list"})}return r.$$set=u=>{"cfg"in u&&n(1,o=u.cfg),"gjSchemes"in u&&n(2,s=u.gjSchemes)},[l,o,s]}class Hc extends re{constructor(e){super(),ie(this,e,Kc,Wc,te,{cfg:1,gjSchemes:2})}}function Zc(r){let e,n;return e=new As({props:{finish:r[1],cancel:r[0]}}),{c(){P(e.$$.fragment)},m(t,i){L(e,t,i),n=!0},p:Q,i(t){n||(_(e.$$.fragment,t),n=!0)},o(t){$(e.$$.fragment,t),n=!1},d(t){F(e,t)}}}function Vc(r,e,n){let t,i;K(r,pn,f=>n(4,t=f)),K(r,ct,f=>n(5,i=f));let{cfg:o}=e,{gjSchemes:s}=e;rt(()=>{t.startNew(),t.addEventListenerSuccess(a),t.addEventListenerFailure(l)}),Xe(()=>{t.stop(),t.clearEventListeners()});function a(f){f.properties||(f.properties={});let c=f;c.properties={...c.properties,...i},s.update(p=>(c.id=_n(p),c.properties.scheme_reference=nr(p),o.newPolygonFeature(c),p.features.push(c),p)),pe.set({mode:"list"})}function l(){pe.set({mode:"list"})}function u(){t.finish()}return r.$$set=f=>{"cfg"in f&&n(2,o=f.cfg),"gjSchemes"in f&&n(3,s=f.gjSchemes)},[l,u,o,s]}class Qc extends re{constructor(e){super(),ie(this,e,Vc,Zc,te,{cfg:2,gjSchemes:3})}}function xc(r){let e,n;return e=new Ns({props:{maptilerApiKey:r[0].maptilerApiKey,extendRoute:!0,finish:r[2],cancel:r[1]}}),{c(){P(e.$$.fragment)},m(t,i){L(e,t,i),n=!0},p(t,[i]){const o={};i&1&&(o.maptilerApiKey=t[0].maptilerApiKey),e.$set(o)},i(t){n||(_(e.$$.fragment,t),n=!0)},o(t){$(e.$$.fragment,t),n=!1},d(t){F(e,t)}}}function ep(r,e,n){let t,i;K(r,it,f=>n(4,t=f)),K(r,ct,f=>n(5,i=f));let{cfg:o}=e,{gjSchemes:s}=e;rt(()=>{t.startRoute(),t.addEventListenerSuccess(a),t.addEventListenerFailure(l)}),Xe(()=>{t.stop(),t.clearEventListeners()});function a(f){let c=f;c.properties={...c.properties,...i},s.update(p=>(c.id=_n(p),c.properties.scheme_reference=nr(p),o.newLineStringFeature(c),p.features.push(c),p)),pe.set({mode:"list"})}function l(){pe.set({mode:"list"})}function u(){t.finish()}return r.$$set=f=>{"cfg"in f&&n(0,o=f.cfg),"gjSchemes"in f&&n(3,s=f.gjSchemes)},[o,l,u,s]}class tp extends re{constructor(e){super(),ie(this,e,ep,xc,te,{cfg:0,gjSchemes:3})}}var np=Object.defineProperty,vt=(r,e)=>np(r,"name",{value:e,configurable:!0});function Wt(r){if(!r)throw new Error("coord is required");if(!Array.isArray(r)){if(r.type==="Feature"&&r.geometry!==null&&r.geometry.type==="Point")return[...r.geometry.coordinates];if(r.type==="Point")return[...r.coordinates]}if(Array.isArray(r)&&r.length>=2&&!Array.isArray(r[0])&&!Array.isArray(r[1]))return[...r];throw new Error("coord must be GeoJSON Point or an Array of numbers")}vt(Wt,"getCoord");function Os(r){if(Array.isArray(r))return r;if(r.type==="Feature"){if(r.geometry!==null)return r.geometry.coordinates}else if(r.coordinates)return r.coordinates;throw new Error("coords must be GeoJSON Feature, Geometry Object or an Array")}vt(Os,"getCoords");function js(r){if(r.length>1&&ni(r[0])&&ni(r[1]))return!0;if(Array.isArray(r[0])&&r[0].length)return js(r[0]);throw new Error("coordinates must only contain numbers")}vt(js,"containsNumber");function rp(r,e,n){if(!e||!n)throw new Error("type and name required");if(!r||r.type!==e)throw new Error("Invalid input to "+n+": must be a "+e+", given "+r.type)}vt(rp,"geojsonType");function ip(r,e,n){if(!r)throw new Error("No feature passed");if(!n)throw new Error(".featureOf() requires a name");if(!r||r.type!=="Feature"||!r.geometry)throw new Error("Invalid input to "+n+", Feature with geometry required");if(!r.geometry||r.geometry.type!==e)throw new Error("Invalid input to "+n+": must be a "+e+", given "+r.geometry.type)}vt(ip,"featureOf");function op(r,e,n){if(!r)throw new Error("No featureCollection passed");if(!n)throw new Error(".collectionOf() requires a name");if(!r||r.type!=="FeatureCollection")throw new Error("Invalid input to "+n+", FeatureCollection required");for(const t of r.features){if(!t||t.type!=="Feature"||!t.geometry)throw new Error("Invalid input to "+n+", Feature with geometry required");if(!t.geometry||t.geometry.type!==e)throw new Error("Invalid input to "+n+": must be a "+e+", given "+t.geometry.type)}}vt(op,"collectionOf");function sp(r){return r.type==="Feature"?r.geometry:r}vt(sp,"getGeom");function lp(r,e){return r.type==="FeatureCollection"?"FeatureCollection":r.type==="GeometryCollection"?"GeometryCollection":r.type==="Feature"&&r.geometry!==null?r.geometry.type:r.type}vt(lp,"getType");var ap=Object.defineProperty,Is=(r,e)=>ap(r,"name",{value:e,configurable:!0});function Zr(r,e,n={}){if(n.final===!0)return Bs(r,e);const t=Wt(r),i=Wt(e),o=De(t[0]),s=De(i[0]),a=De(t[1]),l=De(i[1]),u=Math.sin(s-o)*Math.cos(l),f=Math.cos(a)*Math.sin(l)-Math.sin(a)*Math.cos(l)*Math.cos(s-o);return gr(Math.atan2(u,f))}Is(Zr,"bearing");function Bs(r,e){let n=Zr(e,r);return n=(n+180)%360,n}Is(Bs,"calculateFinalBearing");var up=Object.defineProperty,fp=(r,e)=>up(r,"name",{value:e,configurable:!0});function Tt(r,e,n={}){var t=Wt(r),i=Wt(e),o=De(i[1]-t[1]),s=De(i[0]-t[0]),a=De(t[1]),l=De(i[1]),u=Math.pow(Math.sin(o/2),2)+Math.pow(Math.sin(s/2),2)*Math.cos(a)*Math.cos(l);return _l(2*Math.atan2(Math.sqrt(u),Math.sqrt(1-u)),n.units)}fp(Tt,"distance");var cp=Object.defineProperty,pp=(r,e)=>cp(r,"name",{value:e,configurable:!0});function Ir(r,e,n,t={}){const i=Wt(r),o=De(i[0]),s=De(i[1]),a=De(n),l=bl(e,t.units),u=Math.asin(Math.sin(s)*Math.cos(l)+Math.cos(s)*Math.sin(l)*Math.cos(a)),f=o+Math.atan2(Math.sin(a)*Math.sin(l)*Math.cos(s),Math.cos(l)-Math.sin(s)*Math.sin(u)),c=gr(f),p=gr(u);return Te([c,p],t.properties)}pp(Ir,"destination");class qs{constructor(e=[],n=mp){if(this.data=e,this.length=this.data.length,this.compare=n,this.length>0)for(let t=(this.length>>1)-1;t>=0;t--)this._down(t)}push(e){this.data.push(e),this.length++,this._up(this.length-1)}pop(){if(this.length===0)return;const e=this.data[0],n=this.data.pop();return this.length--,this.length>0&&(this.data[0]=n,this._down(0)),e}peek(){return this.data[0]}_up(e){const{data:n,compare:t}=this,i=n[e];for(;e>0;){const o=e-1>>1,s=n[o];if(t(i,s)>=0)break;n[e]=s,e=o}n[e]=i}_down(e){const{data:n,compare:t}=this,i=this.length>>1,o=n[e];for(;e=0)break;n[e]=a,e=s}n[e]=o}}function mp(r,e){return re?1:0}function Gs(r,e){return r.p.x>e.p.x?1:r.p.xe.p.y?1:-1:1}function dp(r,e){return r.rightSweepEvent.p.x>e.rightSweepEvent.p.x?1:r.rightSweepEvent.p.x0?(f.isLeftEndpoint=!0,u.isLeftEndpoint=!1):(u.isLeftEndpoint=!0,f.isLeftEndpoint=!1),e.push(u),e.push(f),s=a,Ln=Ln+1}}Mn=Mn+1}class hp{constructor(e){this.leftSweepEvent=e,this.rightSweepEvent=e.otherEvent}}function _p(r,e){if(r===null||e===null||r.leftSweepEvent.ringId===e.leftSweepEvent.ringId&&(r.rightSweepEvent.isSamePoint(e.leftSweepEvent)||r.rightSweepEvent.isSamePoint(e.leftSweepEvent)||r.rightSweepEvent.isSamePoint(e.rightSweepEvent)||r.leftSweepEvent.isSamePoint(e.leftSweepEvent)||r.leftSweepEvent.isSamePoint(e.rightSweepEvent)))return!1;const n=r.leftSweepEvent.p.x,t=r.leftSweepEvent.p.y,i=r.rightSweepEvent.p.x,o=r.rightSweepEvent.p.y,s=e.leftSweepEvent.p.x,a=e.leftSweepEvent.p.y,l=e.rightSweepEvent.p.x,u=e.rightSweepEvent.p.y,f=(u-a)*(i-n)-(l-s)*(o-t),c=(l-s)*(t-a)-(u-a)*(n-s),p=(i-n)*(t-a)-(o-t)*(n-s);if(f===0)return!1;const m=c/f,g=p/f;if(m>=0&&m<=1&&g>=0&&g<=1){const v=n+m*(i-n),S=t+m*(o-t);return[v,S]}return!1}function bp(r,e){e=e||!1;const n=[],t=new qs([],dp);for(;r.length;){const i=r.pop();if(i.isLeftEndpoint){const o=new hp(i);for(let s=0;s$p(r,"name",{value:e,configurable:!0}),wp=vp;function Ts(r,e,n={}){const{removeDuplicates:t=!0,ignoreSelfIntersections:i=!1}=n;let o=[];r.type==="FeatureCollection"?o=o.concat(r.features):r.type==="Feature"?o.push(r):(r.type==="LineString"||r.type==="Polygon"||r.type==="MultiLineString"||r.type==="MultiPolygon")&&o.push(Bn(r)),e.type==="FeatureCollection"?o=o.concat(e.features):e.type==="Feature"?o.push(e):(e.type==="LineString"||e.type==="Polygon"||e.type==="MultiLineString"||e.type==="MultiPolygon")&&o.push(Bn(e));const s=wp(ri(o),i);let a=[];if(t){const l={};s.forEach(u=>{const f=u.join(",");l[f]||(l[f]=!0,a.push(u))})}else a=s;return ri(a.map(l=>Te(l)))}yp(Ts,"lineIntersect");var kp=Object.defineProperty,Me=(r,e)=>kp(r,"name",{value:e,configurable:!0});function vn(r,e,n){if(r!==null)for(var t,i,o,s,a,l,u,f=0,c=0,p,m=r.type,g=m==="FeatureCollection",v=m==="Feature",S=g?r.features.length:1,k=0;kl||g>u||v>f){a=c,l=t,u=g,f=v,o=0;return}var S=pt([a,c],n.properties);if(e(S,t,i,v,o)===!1)return!1;o++,a=c})===!1)return!1}}})}Me(zs,"segmentEach");function Cp(r,e,n){var t=n,i=!1;return zs(r,function(o,s,a,l,u){i===!1&&n===void 0?t=o:t=e(t,o,s,a,l,u),i=!0}),t}Me(Cp,"segmentReduce");function Js(r,e){if(!r)throw new Error("geojson is required");$n(r,function(n,t,i){if(n.geometry!==null){var o=n.geometry.type,s=n.geometry.coordinates;switch(o){case"LineString":if(e(n,t,i,0,0)===!1)return!1;break;case"Polygon":for(var a=0;ae in r?Ys(r,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):r[e]=n,$t=(r,e)=>{for(var n in e||(e={}))Ip.call(e,n)&&fo(r,n,e[n]);if(uo)for(var n of uo(e))Bp.call(e,n)&&fo(r,n,e[n]);return r},yt=(r,e)=>Op(r,jp(e)),qp=(r,e)=>Ys(r,"name",{value:e,configurable:!0});function Xs(r,e,n={}){if(!r||!e)throw new Error("lines and pt are required arguments");let t=Te([1/0,1/0],{dist:1/0,index:-1,location:-1}),i=0;return $n(r,function(o){const s=Os(o);for(let a=0;a0&&v.features[0]&&(S=yt($t({},v.features[0]),{properties:{dist:Tt(e,v.features[0],n),location:i+Tt(l,v.features[0],n)}})),l.properties.distClick + to cancel`},m(n,t){y(n,e,t)},p:Q,d(n){n&&w(e)}}}function Cc(r){let e,n,t,i,o,s,a,l;return e=new _t({props:{$$slots:{default:[kc]},$$scope:{ctx:r}}}),e.$on("click",function(){Lt(r[0])&&r[0].apply(this,arguments)}),t=new _e({props:{disabled:r[2]==0,$$slots:{default:[Mc]},$$scope:{ctx:r}}}),t.$on("click",r[3]),o=new _e({props:{$$slots:{default:[Pc]},$$scope:{ctx:r}}}),o.$on("click",function(){Lt(r[1])&&r[1].apply(this,arguments)}),a=new Rt({props:{$$slots:{default:[Lc]},$$scope:{ctx:r}}}),{c(){P(e.$$.fragment),n=R(),P(t.$$.fragment),i=R(),P(o.$$.fragment),s=R(),P(a.$$.fragment)},m(u,f){L(e,u,f),y(u,n,f),L(t,u,f),y(u,i,f),L(o,u,f),y(u,s,f),L(a,u,f),l=!0},p(u,f){r=u;const c={};f&32&&(c.$$scope={dirty:f,ctx:r}),e.$set(c);const p={};f&4&&(p.disabled=r[2]==0),f&36&&(p.$$scope={dirty:f,ctx:r}),t.$set(p);const m={};f&32&&(m.$$scope={dirty:f,ctx:r}),o.$set(m);const g={};f&32&&(g.$$scope={dirty:f,ctx:r}),a.$set(g)},i(u){l||(b(e.$$.fragment,u),b(t.$$.fragment,u),b(o.$$.fragment,u),b(a.$$.fragment,u),l=!0)},o(u){$(e.$$.fragment,u),$(t.$$.fragment,u),$(o.$$.fragment,u),$(a.$$.fragment,u),l=!1},d(u){u&&(w(n),w(i),w(s)),C(e,u),C(t,u),C(o,u),C(a,u)}}}function Fc(r){let e,n,t;return n=new He({props:{$$slots:{default:[Cc]},$$scope:{ctx:r}}}),{c(){e=q("div"),P(n.$$.fragment),ge(e,"float","right")},m(i,o){y(i,e,o),L(n,e,null),t=!0},p(i,[o]){const s={};o&39&&(s.$$scope={dirty:o,ctx:i}),n.$set(s)},i(i){t||(b(n.$$.fragment,i),t=!0)},o(i){$(n.$$.fragment,i),t=!1},d(i){i&&w(e),C(n)}}}function Ac(r,e,n){let t,i;W(r,ot,l=>n(4,t=l)),W(r,Hr,l=>n(2,i=l));let{finish:o}=e,{cancel:s}=e;function a(){t.undo()}return r.$$set=l=>{"finish"in l&&n(0,o=l.finish),"cancel"in l&&n(1,s=l.cancel)},[o,s,i,a]}class Rs extends re{constructor(e){super(),ie(this,e,Ac,Fc,te,{finish:0,cancel:1})}}function Nc(r){let e,n;return e=new Rs({props:{finish:r[2],cancel:r[3]}}),{c(){P(e.$$.fragment)},m(t,i){L(e,t,i),n=!0},p:Q,i(t){n||(b(e.$$.fragment,t),n=!0)},o(t){$(e.$$.fragment,t),n=!1},d(t){C(e,t)}}}function Rc(r){let e,n;return e=new As({props:{finish:r[2],cancel:r[3]}}),{c(){P(e.$$.fragment)},m(t,i){L(e,t,i),n=!0},p:Q,i(t){n||(b(e.$$.fragment,t),n=!0)},o(t){$(e.$$.fragment,t),n=!1},d(t){C(e,t)}}}function Oc(r){let e,n;return e=new Ns({props:{maptilerApiKey:r[0].maptilerApiKey,extendRoute:!1,finish:r[2],cancel:r[3]}}),{c(){P(e.$$.fragment)},m(t,i){L(e,t,i),n=!0},p(t,i){const o={};i&1&&(o.maptilerApiKey=t[0].maptilerApiKey),e.$set(o)},i(t){n||(b(e.$$.fragment,t),n=!0)},o(t){$(e.$$.fragment,t),n=!1},d(t){C(e,t)}}}function jc(r){let e,n;return e=new Fs({props:{editingExisting:!0,cancel:r[3]}}),{c(){P(e.$$.fragment)},m(t,i){L(e,t,i),n=!0},p:Q,i(t){n||(b(e.$$.fragment,t),n=!0)},o(t){$(e.$$.fragment,t),n=!1},d(t){C(e,t)}}}function Ic(r){let e,n,t,i;const o=[jc,Oc,Rc,Nc],s=[];function a(l,u){return l[1]=="point"?0:l[1]=="route"?1:l[1]=="freehand-polygon"?2:l[1]=="snapped-polygon"?3:-1}return~(e=a(r))&&(n=s[e]=o[e](r)),{c(){n&&n.c(),t=ce()},m(l,u){~e&&s[e].m(l,u),y(l,t,u),i=!0},p(l,[u]){let f=e;e=a(l),e===f?~e&&s[e].p(l,u):(n&&(se(),$(s[f],1,1,()=>{s[f]=null}),le()),~e?(n=s[e],n?n.p(l,u):(n=s[e]=o[e](l),n.c()),b(n,1),n.m(t.parentNode,t)):n=null)},i(l){i||(b(n),i=!0)},o(l){$(n),i=!1},d(l){l&&w(t),~e&&s[e].d(l)}}}function Bc(r,e,n){let t,i,o,s;W(r,Ge,_=>n(7,t=_)),W(r,pn,_=>n(8,i=_)),W(r,ot,_=>n(9,o=_)),W(r,In,_=>n(10,s=_));let{cfg:a}=e,{gjSchemes:l}=e,{id:u}=e,f="",c=null;it(()=>{let _=null;l.update(E=>(_=E.features.find(d=>d.id==u),_.properties.hide_while_editing=!0,E));let h=_;h.geometry.type=="LineString"?(o==null||o.editExistingRoute(h),o==null||o.addEventListenerSuccess(p),o==null||o.addEventListenerUpdated(m),o==null||o.addEventListenerFailure(g),n(1,f="route")):h.geometry.type=="Polygon"?h.properties.waypoints?(o==null||o.editExistingArea(h),o==null||o.addEventListenerSuccess(p),o==null||o.addEventListenerUpdated(m),o==null||o.addEventListenerFailure(g),n(1,f="snapped-polygon")):(i==null||i.editExisting(h),i==null||i.addEventListenerSuccess(p),i==null||i.addEventListenerUpdated(m),i==null||i.addEventListenerFailure(g),n(1,f="freehand-polygon")):h.geometry.type=="Point"&&(s==null||s.start(),s==null||s.addEventListenerSuccess(p),s==null||s.addEventListenerFailure(g),n(1,f="point"))}),We(()=>{s==null||s.stop(),s==null||s.clearEventListeners(),o==null||o.stop(),o==null||o.clearEventListeners(),i==null||i.stop(),i==null||i.clearEventListeners(),l.update(_=>{let h=_.features.find(E=>E.id==u);return h&&(delete h.properties.hide_while_editing,c&&v(h,c)),_})});function p(_){_.properties??(_.properties={}),c=_,pe.set({mode:"list"})}function m(_){c=_}function g(){c=null,pe.set({mode:"list"})}function v(_,h){_.geometry=h.geometry,_.properties={...t},h.properties.length_meters&&(_.properties.length_meters=h.properties.length_meters),h.properties.waypoints&&(_.properties.waypoints=h.properties.waypoints),a.updateFeature(_,h)}function k(){pe.set({mode:"list"})}function M(){c=null,pe.set({mode:"list"})}return r.$$set=_=>{"cfg"in _&&n(0,a=_.cfg),"gjSchemes"in _&&n(4,l=_.gjSchemes),"id"in _&&n(5,u=_.id)},[a,f,k,M,l,u]}class qc extends re{constructor(e){super(),ie(this,e,Bc,Ic,te,{cfg:0,gjSchemes:4,id:5})}}function Gc(r){let e,n,t;return{c(){e=q("input"),J(e,"class","govuk-file-upload"),J(e,"id","load-image"),J(e,"type","file")},m(i,o){y(i,e,o),r[6](e),n||(t=he(e,"change",r[3]),n=!0)},p:Q,d(i){i&&w(e),r[6](null),n=!1,t()}}}function so(r){let e,n,t,i,o,s,a,l,u,f;return{c(){e=q("div"),n=q("label"),t=q("input"),i=R(),o=q("br"),s=z(` + Opacity: `),a=z(r[1]),l=z("%"),J(t,"type","range"),J(t,"min","0"),J(t,"max","100")},m(c,p){y(c,e,p),G(e,n),G(n,t),Le(t,r[1]),G(n,i),G(n,o),G(n,s),G(n,a),G(n,l),u||(f=[he(t,"change",r[7]),he(t,"input",r[7])],u=!0)},p(c,p){p&2&&Le(t,c[1]),p&2&&be(a,c[1])},d(c){c&&w(e),u=!1,er(f)}}}function Tc(r){let e;return{c(){e=z("Save")},m(n,t){y(n,e,t)},d(n){n&&w(e)}}}function Dc(r){let e;return{c(){e=z("Delete")},m(n,t){y(n,e,t)},d(n){n&&w(e)}}}function Uc(r){let e;return{c(){e=q("p"),e.textContent=`Note this image isn't saved as part of this scheme. When you close + this page, it'll be lost.`},m(n,t){y(n,e,t)},p:Q,d(n){n&&w(e)}}}function zc(r){let e,n,t,i,o,s;return e=new _t({props:{$$slots:{default:[Tc]},$$scope:{ctx:r}}}),e.$on("click",r[8]),t=new bt({props:{disabled:!r[2],$$slots:{default:[Dc]},$$scope:{ctx:r}}}),t.$on("click",r[4]),o=new Rt({props:{$$slots:{default:[Uc]},$$scope:{ctx:r}}}),{c(){P(e.$$.fragment),n=R(),P(t.$$.fragment),i=R(),P(o.$$.fragment)},m(a,l){L(e,a,l),y(a,n,l),L(t,a,l),y(a,i,l),L(o,a,l),s=!0},p(a,l){const u={};l&512&&(u.$$scope={dirty:l,ctx:a}),e.$set(u);const f={};l&4&&(f.disabled=!a[2]),l&512&&(f.$$scope={dirty:l,ctx:a}),t.$set(f);const c={};l&512&&(c.$$scope={dirty:l,ctx:a}),o.$set(c)},i(a){s||(b(e.$$.fragment,a),b(t.$$.fragment,a),b(o.$$.fragment,a),s=!0)},o(a){$(e.$$.fragment,a),$(t.$$.fragment,a),$(o.$$.fragment,a),s=!1},d(a){a&&(w(n),w(i)),C(e,a),C(t,a),C(o,a)}}}function Jc(r){let e,n,t,i,o,s,a,l,u;n=new Ft({props:{label:"Load an image",id:"load-image",$$slots:{default:[Gc]},$$scope:{ctx:r}}});let f=r[2]&&so(r);return s=new He({props:{$$slots:{default:[zc]},$$scope:{ctx:r}}}),{c(){e=q("div"),P(n.$$.fragment),t=R(),f&&f.c(),i=R(),o=q("div"),P(s.$$.fragment),ge(o,"margin-left","auto"),ge(e,"display","flex")},m(c,p){y(c,e,p),L(n,e,null),G(e,t),f&&f.m(e,null),G(e,i),G(e,o),L(s,o,null),a=!0,l||(u=he(window,"keydown",r[5]),l=!0)},p(c,[p]){const m={};p&513&&(m.$$scope={dirty:p,ctx:c}),n.$set(m),c[2]?f?f.p(c,p):(f=so(c),f.c(),f.m(e,i)):f&&(f.d(1),f=null);const g={};p&516&&(g.$$scope={dirty:p,ctx:c}),s.$set(g)},i(c){a||(b(n.$$.fragment,c),b(s.$$.fragment,c),a=!0)},o(c){$(n.$$.fragment,c),$(s.$$.fragment,c),a=!1},d(c){c&&w(e),C(n),f&&f.d(),C(s),l=!1,u()}}}function Yc(r,e,n){let t,i;W(r,Nn,p=>n(1,t=p)),W(r,An,p=>n(2,i=p));let o;async function s(p){let m=await o.files[0].arrayBuffer(),g=new Blob([new Uint8Array(m)]);Ne(An,i=URL.createObjectURL(g),i)}function a(){Ne(An,i=null,i),Ne(Nn,t=100,t)}function l(p){p.key=="Escape"&&(p.stopPropagation(),pe.set({mode:"list"}))}function u(p){V[p?"unshift":"push"](()=>{o=p,n(0,o)})}function f(){t=hl(this.value),Nn.set(t)}return[o,t,i,s,a,l,u,f,()=>pe.set({mode:"list"})]}class Xc extends re{constructor(e){super(),ie(this,e,Yc,Jc,te,{})}}function Wc(r){let e,n;return e=new Fs({props:{editingExisting:!1,cancel:r[0]}}),{c(){P(e.$$.fragment)},m(t,i){L(e,t,i),n=!0},p:Q,i(t){n||(b(e.$$.fragment,t),n=!0)},o(t){$(e.$$.fragment,t),n=!1},d(t){C(e,t)}}}function Kc(r,e,n){let t,i;W(r,Ge,u=>n(3,t=u)),W(r,In,u=>n(4,i=u));let{cfg:o}=e,{gjSchemes:s}=e;it(()=>{i.start(),i.addEventListenerSuccess(a),i.addEventListenerFailure(l)}),We(()=>{i.stop(),i.clearEventListeners()});function a(u){u.properties||(u.properties={});let f=u;f.properties={...f.properties,...t},s.update(c=>(f.id=_n(c),f.properties.scheme_reference=nr(c),o.newPointFeature(f),c.features.push(f),c)),pe.set({mode:"list"})}function l(){pe.set({mode:"list"})}return r.$$set=u=>{"cfg"in u&&n(1,o=u.cfg),"gjSchemes"in u&&n(2,s=u.gjSchemes)},[l,o,s]}class Hc extends re{constructor(e){super(),ie(this,e,Kc,Wc,te,{cfg:1,gjSchemes:2})}}function Zc(r){let e,n;return e=new As({props:{finish:r[1],cancel:r[0]}}),{c(){P(e.$$.fragment)},m(t,i){L(e,t,i),n=!0},p:Q,i(t){n||(b(e.$$.fragment,t),n=!0)},o(t){$(e.$$.fragment,t),n=!1},d(t){C(e,t)}}}function Vc(r,e,n){let t,i;W(r,pn,f=>n(4,t=f)),W(r,Ge,f=>n(5,i=f));let{cfg:o}=e,{gjSchemes:s}=e;it(()=>{t.startNew(),t.addEventListenerSuccess(a),t.addEventListenerFailure(l)}),We(()=>{t.stop(),t.clearEventListeners()});function a(f){f.properties||(f.properties={});let c=f;c.properties={...c.properties,...i},s.update(p=>(c.id=_n(p),c.properties.scheme_reference=nr(p),o.newPolygonFeature(c),p.features.push(c),p)),pe.set({mode:"list"})}function l(){pe.set({mode:"list"})}function u(){t.finish()}return r.$$set=f=>{"cfg"in f&&n(2,o=f.cfg),"gjSchemes"in f&&n(3,s=f.gjSchemes)},[l,u,o,s]}class Qc extends re{constructor(e){super(),ie(this,e,Vc,Zc,te,{cfg:2,gjSchemes:3})}}function xc(r){let e,n;return e=new Ns({props:{maptilerApiKey:r[0].maptilerApiKey,extendRoute:!0,finish:r[2],cancel:r[1]}}),{c(){P(e.$$.fragment)},m(t,i){L(e,t,i),n=!0},p(t,[i]){const o={};i&1&&(o.maptilerApiKey=t[0].maptilerApiKey),e.$set(o)},i(t){n||(b(e.$$.fragment,t),n=!0)},o(t){$(e.$$.fragment,t),n=!1},d(t){C(e,t)}}}function ep(r,e,n){let t,i;W(r,ot,f=>n(4,t=f)),W(r,Ge,f=>n(5,i=f));let{cfg:o}=e,{gjSchemes:s}=e;it(()=>{t.startRoute(),t.addEventListenerSuccess(a),t.addEventListenerFailure(l)}),We(()=>{t.stop(),t.clearEventListeners()});function a(f){let c=f;c.properties={...c.properties,...i},s.update(p=>(c.id=_n(p),c.properties.scheme_reference=nr(p),o.newLineStringFeature(c),p.features.push(c),p)),pe.set({mode:"list"})}function l(){pe.set({mode:"list"})}function u(){t.finish()}return r.$$set=f=>{"cfg"in f&&n(0,o=f.cfg),"gjSchemes"in f&&n(3,s=f.gjSchemes)},[o,l,u,s]}class tp extends re{constructor(e){super(),ie(this,e,ep,xc,te,{cfg:0,gjSchemes:3})}}var np=Object.defineProperty,vt=(r,e)=>np(r,"name",{value:e,configurable:!0});function Wt(r){if(!r)throw new Error("coord is required");if(!Array.isArray(r)){if(r.type==="Feature"&&r.geometry!==null&&r.geometry.type==="Point")return[...r.geometry.coordinates];if(r.type==="Point")return[...r.coordinates]}if(Array.isArray(r)&&r.length>=2&&!Array.isArray(r[0])&&!Array.isArray(r[1]))return[...r];throw new Error("coord must be GeoJSON Point or an Array of numbers")}vt(Wt,"getCoord");function Os(r){if(Array.isArray(r))return r;if(r.type==="Feature"){if(r.geometry!==null)return r.geometry.coordinates}else if(r.coordinates)return r.coordinates;throw new Error("coords must be GeoJSON Feature, Geometry Object or an Array")}vt(Os,"getCoords");function js(r){if(r.length>1&&ni(r[0])&&ni(r[1]))return!0;if(Array.isArray(r[0])&&r[0].length)return js(r[0]);throw new Error("coordinates must only contain numbers")}vt(js,"containsNumber");function rp(r,e,n){if(!e||!n)throw new Error("type and name required");if(!r||r.type!==e)throw new Error("Invalid input to "+n+": must be a "+e+", given "+r.type)}vt(rp,"geojsonType");function ip(r,e,n){if(!r)throw new Error("No feature passed");if(!n)throw new Error(".featureOf() requires a name");if(!r||r.type!=="Feature"||!r.geometry)throw new Error("Invalid input to "+n+", Feature with geometry required");if(!r.geometry||r.geometry.type!==e)throw new Error("Invalid input to "+n+": must be a "+e+", given "+r.geometry.type)}vt(ip,"featureOf");function op(r,e,n){if(!r)throw new Error("No featureCollection passed");if(!n)throw new Error(".collectionOf() requires a name");if(!r||r.type!=="FeatureCollection")throw new Error("Invalid input to "+n+", FeatureCollection required");for(const t of r.features){if(!t||t.type!=="Feature"||!t.geometry)throw new Error("Invalid input to "+n+", Feature with geometry required");if(!t.geometry||t.geometry.type!==e)throw new Error("Invalid input to "+n+": must be a "+e+", given "+t.geometry.type)}}vt(op,"collectionOf");function sp(r){return r.type==="Feature"?r.geometry:r}vt(sp,"getGeom");function lp(r,e){return r.type==="FeatureCollection"?"FeatureCollection":r.type==="GeometryCollection"?"GeometryCollection":r.type==="Feature"&&r.geometry!==null?r.geometry.type:r.type}vt(lp,"getType");var ap=Object.defineProperty,Is=(r,e)=>ap(r,"name",{value:e,configurable:!0});function Zr(r,e,n={}){if(n.final===!0)return Bs(r,e);const t=Wt(r),i=Wt(e),o=ze(t[0]),s=ze(i[0]),a=ze(t[1]),l=ze(i[1]),u=Math.sin(s-o)*Math.cos(l),f=Math.cos(a)*Math.sin(l)-Math.sin(a)*Math.cos(l)*Math.cos(s-o);return gr(Math.atan2(u,f))}Is(Zr,"bearing");function Bs(r,e){let n=Zr(e,r);return n=(n+180)%360,n}Is(Bs,"calculateFinalBearing");var up=Object.defineProperty,fp=(r,e)=>up(r,"name",{value:e,configurable:!0});function Tt(r,e,n={}){var t=Wt(r),i=Wt(e),o=ze(i[1]-t[1]),s=ze(i[0]-t[0]),a=ze(t[1]),l=ze(i[1]),u=Math.pow(Math.sin(o/2),2)+Math.pow(Math.sin(s/2),2)*Math.cos(a)*Math.cos(l);return _l(2*Math.atan2(Math.sqrt(u),Math.sqrt(1-u)),n.units)}fp(Tt,"distance");var cp=Object.defineProperty,pp=(r,e)=>cp(r,"name",{value:e,configurable:!0});function Ir(r,e,n,t={}){const i=Wt(r),o=ze(i[0]),s=ze(i[1]),a=ze(n),l=bl(e,t.units),u=Math.asin(Math.sin(s)*Math.cos(l)+Math.cos(s)*Math.sin(l)*Math.cos(a)),f=o+Math.atan2(Math.sin(a)*Math.sin(l)*Math.cos(s),Math.cos(l)-Math.sin(s)*Math.sin(u)),c=gr(f),p=gr(u);return De([c,p],t.properties)}pp(Ir,"destination");class qs{constructor(e=[],n=mp){if(this.data=e,this.length=this.data.length,this.compare=n,this.length>0)for(let t=(this.length>>1)-1;t>=0;t--)this._down(t)}push(e){this.data.push(e),this.length++,this._up(this.length-1)}pop(){if(this.length===0)return;const e=this.data[0],n=this.data.pop();return this.length--,this.length>0&&(this.data[0]=n,this._down(0)),e}peek(){return this.data[0]}_up(e){const{data:n,compare:t}=this,i=n[e];for(;e>0;){const o=e-1>>1,s=n[o];if(t(i,s)>=0)break;n[e]=s,e=o}n[e]=i}_down(e){const{data:n,compare:t}=this,i=this.length>>1,o=n[e];for(;e=0)break;n[e]=a,e=s}n[e]=o}}function mp(r,e){return re?1:0}function Gs(r,e){return r.p.x>e.p.x?1:r.p.xe.p.y?1:-1:1}function dp(r,e){return r.rightSweepEvent.p.x>e.rightSweepEvent.p.x?1:r.rightSweepEvent.p.x0?(f.isLeftEndpoint=!0,u.isLeftEndpoint=!1):(u.isLeftEndpoint=!0,f.isLeftEndpoint=!1),e.push(u),e.push(f),s=a,Ln=Ln+1}}Mn=Mn+1}class hp{constructor(e){this.leftSweepEvent=e,this.rightSweepEvent=e.otherEvent}}function _p(r,e){if(r===null||e===null||r.leftSweepEvent.ringId===e.leftSweepEvent.ringId&&(r.rightSweepEvent.isSamePoint(e.leftSweepEvent)||r.rightSweepEvent.isSamePoint(e.leftSweepEvent)||r.rightSweepEvent.isSamePoint(e.rightSweepEvent)||r.leftSweepEvent.isSamePoint(e.leftSweepEvent)||r.leftSweepEvent.isSamePoint(e.rightSweepEvent)))return!1;const n=r.leftSweepEvent.p.x,t=r.leftSweepEvent.p.y,i=r.rightSweepEvent.p.x,o=r.rightSweepEvent.p.y,s=e.leftSweepEvent.p.x,a=e.leftSweepEvent.p.y,l=e.rightSweepEvent.p.x,u=e.rightSweepEvent.p.y,f=(u-a)*(i-n)-(l-s)*(o-t),c=(l-s)*(t-a)-(u-a)*(n-s),p=(i-n)*(t-a)-(o-t)*(n-s);if(f===0)return!1;const m=c/f,g=p/f;if(m>=0&&m<=1&&g>=0&&g<=1){const v=n+m*(i-n),k=t+m*(o-t);return[v,k]}return!1}function bp(r,e){e=e||!1;const n=[],t=new qs([],dp);for(;r.length;){const i=r.pop();if(i.isLeftEndpoint){const o=new hp(i);for(let s=0;s$p(r,"name",{value:e,configurable:!0}),wp=vp;function Ts(r,e,n={}){const{removeDuplicates:t=!0,ignoreSelfIntersections:i=!1}=n;let o=[];r.type==="FeatureCollection"?o=o.concat(r.features):r.type==="Feature"?o.push(r):(r.type==="LineString"||r.type==="Polygon"||r.type==="MultiLineString"||r.type==="MultiPolygon")&&o.push(Bn(r)),e.type==="FeatureCollection"?o=o.concat(e.features):e.type==="Feature"?o.push(e):(e.type==="LineString"||e.type==="Polygon"||e.type==="MultiLineString"||e.type==="MultiPolygon")&&o.push(Bn(e));const s=wp(ri(o),i);let a=[];if(t){const l={};s.forEach(u=>{const f=u.join(",");l[f]||(l[f]=!0,a.push(u))})}else a=s;return ri(a.map(l=>De(l)))}yp(Ts,"lineIntersect");var kp=Object.defineProperty,Me=(r,e)=>kp(r,"name",{value:e,configurable:!0});function vn(r,e,n){if(r!==null)for(var t,i,o,s,a,l,u,f=0,c=0,p,m=r.type,g=m==="FeatureCollection",v=m==="Feature",k=g?r.features.length:1,M=0;Ml||g>u||v>f){a=c,l=t,u=g,f=v,o=0;return}var k=pt([a,c],n.properties);if(e(k,t,i,v,o)===!1)return!1;o++,a=c})===!1)return!1}}})}Me(zs,"segmentEach");function Fp(r,e,n){var t=n,i=!1;return zs(r,function(o,s,a,l,u){i===!1&&n===void 0?t=o:t=e(t,o,s,a,l,u),i=!0}),t}Me(Fp,"segmentReduce");function Js(r,e){if(!r)throw new Error("geojson is required");$n(r,function(n,t,i){if(n.geometry!==null){var o=n.geometry.type,s=n.geometry.coordinates;switch(o){case"LineString":if(e(n,t,i,0,0)===!1)return!1;break;case"Polygon":for(var a=0;ae in r?Ys(r,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):r[e]=n,$t=(r,e)=>{for(var n in e||(e={}))Ip.call(e,n)&&fo(r,n,e[n]);if(uo)for(var n of uo(e))Bp.call(e,n)&&fo(r,n,e[n]);return r},yt=(r,e)=>Op(r,jp(e)),qp=(r,e)=>Ys(r,"name",{value:e,configurable:!0});function Xs(r,e,n={}){if(!r||!e)throw new Error("lines and pt are required arguments");let t=De([1/0,1/0],{dist:1/0,index:-1,location:-1}),i=0;return $n(r,function(o){const s=Os(o);for(let a=0;a0&&v.features[0]&&(k=yt($t({},v.features[0]),{properties:{dist:Tt(e,v.features[0],n),location:i+Tt(l,v.features[0],n)}})),l.properties.distClick on a route to split it
  • Click on the map or press Escape - to cancel
  • `},m(n,t){y(n,e,t)},p:Q,d(n){n&&w(e)}}}function zp(r){let e,n,t,i,o,s,a,l,u,f,c;return e=new vl({}),e.$on("mousemove",r[3]),e.$on("click",r[4]),t=new Mt({props:{data:r[2],$$slots:{default:[Tp]},$$scope:{ctx:r}}}),s=new _t({props:{$$slots:{default:[Up]},$$scope:{ctx:r}}}),s.$on("click",r[7]),l=new Rt({props:{$$slots:{default:[Dp]},$$scope:{ctx:r}}}),{c(){P(e.$$.fragment),n=R(),P(t.$$.fragment),i=R(),o=q("div"),P(s.$$.fragment),a=R(),P(l.$$.fragment),ge(o,"float","right")},m(p,m){L(e,p,m),y(p,n,m),L(t,p,m),y(p,i,m),y(p,o,m),L(s,o,null),G(o,a),L(l,o,null),u=!0,f||(c=he(window,"keydown",r[5]),f=!0)},p(p,[m]){const g={};m&4&&(g.data=p[2]),m&4097&&(g.$$scope={dirty:m,ctx:p}),t.$set(g);const v={};m&4096&&(v.$$scope={dirty:m,ctx:p}),s.$set(v);const S={};m&4096&&(S.$$scope={dirty:m,ctx:p}),l.$set(S)},i(p){u||(_(e.$$.fragment,p),_(t.$$.fragment,p),_(s.$$.fragment,p),_(l.$$.fragment,p),u=!0)},o(p){$(e.$$.fragment,p),$(t.$$.fragment,p),$(s.$$.fragment,p),$(l.$$.fragment,p),u=!1},d(p){p&&(w(n),w(i),w(o)),F(e,p),F(t,p),F(s),F(l),f=!1,c()}}}const co=10,Jp=30;function Yp(r,e,n){let t,i=Q,o=()=>(i(),i=We(l,k=>n(9,t=k)),l),s;K(r,xe,k=>n(10,s=k)),r.$$.on_destroy.push(()=>i());let{cfg:a}=e,{gjSchemes:l}=e;o(),rt(()=>{s&&(s.getCanvas().style.cursor=`url(${Fs}), crosshair`)}),Xe(()=>{s&&(s.getCanvas().style.cursor="inherit")});let u=null,f=null,c=Jt();function p(k){if(!s)return;n(6,u=null),f=null;let b=v(k.detail.lngLat.toArray());const h=[k.detail.point.x-Jp,k.detail.point.y],M=s.unproject(k.detail.point).distanceTo(s.unproject(h))/1e3;let d=[];for(let[E,N]of t.features.entries())if(N.geometry.type=="LineString"){let j=Gp(N.geometry,b,{units:"kilometers"});j.properties.dist!=null&&j.properties.dist<=M&&d.push([E,j.geometry.coordinates,j.properties.dist])}d.sort((E,N)=>E[2]-N[2]),d.length>0&&(n(6,u=v(d[0][1])),f=d[0][0])}function m(){if(f==null){pe.set({mode:"list"});return}let k=wu(t.features[f],u);if(k!=null){let[b,h]=k;l.update(M=>(b.id=M.features[f].id,h.id=_n(M),M.features.splice(f,1,b,h),M))}n(6,u=null),f=null}function g(k){k.key=="Escape"&&(k.stopPropagation(),pe.set({mode:"list"}))}function v(k){return{type:"Feature",properties:{},geometry:{type:"Point",coordinates:zo(k)}}}const S=()=>pe.set({mode:"list"});return r.$$set=k=>{"cfg"in k&&n(0,a=k.cfg),"gjSchemes"in k&&o(n(1,l=k.gjSchemes))},r.$$.update=()=>{if(r.$$.dirty&64){let k=Jt();u&&k.features.push(u),n(2,c=k)}},[a,l,c,p,m,g,u,S]}class Xp extends re{constructor(e){super(),ie(this,e,Yp,zp,te,{cfg:0,gjSchemes:1})}}function Wp(r){let e,n;return e=new Rs({props:{finish:r[1],cancel:r[0]}}),{c(){P(e.$$.fragment)},m(t,i){L(e,t,i),n=!0},p:Q,i(t){n||(_(e.$$.fragment,t),n=!0)},o(t){$(e.$$.fragment,t),n=!1},d(t){F(e,t)}}}function Kp(r,e,n){let t,i;K(r,it,f=>n(4,t=f)),K(r,ct,f=>n(5,i=f));let{cfg:o}=e,{gjSchemes:s}=e;rt(()=>{t.startArea(),t.addEventListenerSuccess(a),t.addEventListenerFailure(l)}),Xe(()=>{t.stop(),t.clearEventListeners()});function a(f){let c=f;c.properties={...c.properties,...i},s.update(p=>(c.id=_n(p),c.properties.scheme_reference=nr(p),o.newPolygonFeature(c),p.features.push(c),p)),pe.set({mode:"list"})}function l(){pe.set({mode:"list"})}function u(){t.finish()}return r.$$set=f=>{"cfg"in f&&n(2,o=f.cfg),"gjSchemes"in f&&n(3,s=f.gjSchemes)},[l,u,o,s]}class Hp extends re{constructor(e){super(),ie(this,e,Kp,Wp,te,{cfg:2,gjSchemes:3})}}function Zp(r){let e,n;return e=new Ye({props:{errorMessage:"Failed to load route snapper"}}),{c(){P(e.$$.fragment)},m(t,i){L(e,t,i),n=!0},p:Q,i(t){n||(_(e.$$.fragment,t),n=!0)},o(t){$(e.$$.fragment,t),n=!1},d(t){F(e,t)}}}function Vp(r){let e,n,t;return{c(){e=q("label"),e.textContent="Route data unpacking",n=R(),t=q("progress"),J(e,"for","route-unpacking"),J(t,"id","route-unpacking"),J(t,"class","svelte-q3473n")},m(i,o){y(i,e,o),y(i,n,o),y(i,t,o)},p:Q,i:Q,o:Q,d(i){i&&(w(e),w(n),w(t))}}}function Qp(r){let e,n,t;return{c(){e=q("label"),e.textContent="Route tool loading",n=R(),t=q("progress"),J(e,"for","route-loading"),J(t,"id","route-loading"),t.value=r[0],J(t,"class","svelte-q3473n")},m(i,o){y(i,e,o),y(i,n,o),y(i,t,o)},p(i,o){o&1&&(t.value=i[0])},i:Q,o:Q,d(i){i&&(w(e),w(n),w(t))}}}function xp(r){let e,n,t,i;const o=[Qp,Vp,Zp],s=[];function a(l,u){return!l[1]&&!l[2]&&!l[3]?0:l[3]&&!l[1]&&!l[2]?1:l[2]?2:-1}return~(e=a(r))&&(n=s[e]=o[e](r)),{c(){n&&n.c(),t=ce()},m(l,u){~e&&s[e].m(l,u),y(l,t,u),i=!0},p(l,[u]){let f=e;e=a(l),e===f?~e&&s[e].p(l,u):(n&&(se(),$(s[f],1,1,()=>{s[f]=null}),le()),~e?(n=s[e],n?n.p(l,u):(n=s[e]=o[e](l),n.c()),_(n,1),n.m(t.parentNode,t)):n=null)},i(l){i||(_(n),i=!0)},o(l){$(n),i=!1},d(l){l&&w(t),~e&&s[e].d(l)}}}function em(r,e,n){let t,{map:i}=e,{url:o}=e,s=0,a=!1,l=!1;return rt(async()=>{await ys(),console.log(`Grabbing ${o}`);try{const u=await Mu(o,f=>{n(0,s=f)});it.set(new Eu(i,u,Ps,Ls,Hr)),n(0,s=100),n(1,a=!0)}catch(u){console.log(`Route tool broke: ${u}`),n(2,l=!0)}}),r.$$set=u=>{"map"in u&&n(4,i=u.map),"url"in u&&n(5,o=u.url)},r.$$.update=()=>{r.$$.dirty&1&&n(3,t=s>=100)},[s,a,l,t,i,o]}class tm extends re{constructor(e){super(),ie(this,e,em,xp,te,{map:4,url:5})}}function nm(r){let e,n,t,i,o;const s=r[4].default,a=Kt(s,r,r[3],null);return{c(){e=q("button"),a&&a.c(),J(e,"type","button"),J(e,"class","govuk-button govuk-button--secondary svelte-11kph2l"),J(e,"data-module","govuk-button"),e.disabled=n=r[1]||r[2].mode!="list",ii(e,"focused",r[2]==r[0]),ge(e,"margin-bottom",r[2].mode=="list"?"0px":void 0)},m(l,u){y(l,e,u),a&&a.m(e,null),t=!0,i||(o=he(e,"click",r[5]),i=!0)},p(l,[u]){a&&a.p&&(!t||u&8)&&Ht(a,s,l,l[3],t?Vt(s,l[3],u,null):Zt(l[3]),null),(!t||u&6&&n!==(n=l[1]||l[2].mode!="list"))&&(e.disabled=n),(!t||u&5)&&ii(e,"focused",l[2]==l[0]),u&4&&ge(e,"margin-bottom",l[2].mode=="list"?"0px":void 0)},i(l){t||(_(a,l),t=!0)},o(l){$(a,l),t=!1},d(l){l&&w(e),a&&a.d(l),i=!1,o()}}}function rm(r,e,n){let t;K(r,pe,u=>n(2,t=u));let{$$slots:i={},$$scope:o}=e,{setMode:s}=e,{disabled:a=!1}=e;const l=()=>pe.set(s);return r.$$set=u=>{"setMode"in u&&n(0,s=u.setMode),"disabled"in u&&n(1,a=u.disabled),"$$scope"in u&&n(3,o=u.$$scope)},[s,a,t,o,i,l]}class wt extends re{constructor(e){super(),ie(this,e,rm,nm,te,{setMode:0,disabled:1})}}function po(r){let e,n;return e=new tm({props:{map:r[5],url:r[2]}}),{c(){P(e.$$.fragment)},m(t,i){L(e,t,i),n=!0},p(t,i){const o={};i&32&&(o.map=t[5]),i&4&&(o.url=t[2]),e.$set(o)},i(t){n||(_(e.$$.fragment,t),n=!0)},o(t){$(e.$$.fragment,t),n=!1},d(t){F(e,t)}}}function im(r){let e,n,t;return{c(){e=q("img"),t=D(` - New point`),ot(e.src,n=Df)||J(e,"src",n),J(e,"alt","New point")},m(i,o){y(i,e,o),y(i,t,o)},p:Q,d(i){i&&(w(e),w(t))}}}function om(r){let e,n,t;return{c(){e=q("img"),t=D(` - New route`),ot(e.src,n=Yf)||J(e,"src",n),J(e,"alt","New route")},m(i,o){y(i,e,o),y(i,t,o)},p:Q,d(i){i&&(w(e),w(t))}}}function sm(r){let e,n,t;return{c(){e=q("img"),t=D(` - New polygon (freehand)`),ot(e.src,n=zf)||J(e,"src",n),J(e,"alt","New polygon (freehand)")},m(i,o){y(i,e,o),y(i,t,o)},p:Q,d(i){i&&(w(e),w(t))}}}function lm(r){let e,n,t;return{c(){e=q("img"),t=D(` - New polygon (snapped)`),ot(e.src,n=Jf)||J(e,"src",n),J(e,"alt","New polygon (snapped)")},m(i,o){y(i,e,o),y(i,t,o)},p:Q,d(i){i&&(w(e),w(t))}}}function am(r){let e,n,t;return{c(){e=q("img"),t=D(` - Split route`),ot(e.src,n=Fs)||J(e,"src",n),J(e,"alt","Split route")},m(i,o){y(i,e,o),y(i,t,o)},p:Q,d(i){i&&(w(e),w(t))}}}function um(r){let e,n,t;return{c(){e=q("img"),t=D(` - Georeference image`),ot(e.src,n=Uf)||J(e,"src",n),J(e,"alt","Georeference image")},m(i,o){y(i,e,o),y(i,t,o)},p:Q,d(i){i&&(w(e),w(t))}}}function fm(r){let e,n,t;return{c(){e=q("img"),t=D(` - StreetView`),ot(e.src,n=Xf)||J(e,"src",n),J(e,"alt","StreetView")},m(i,o){y(i,e,o),y(i,t,o)},p:Q,d(i){i&&(w(e),w(t))}}}function cm(r){let e,n;return e=new Tf({props:{cfg:r[0]}}),{c(){P(e.$$.fragment)},m(t,i){L(e,t,i),n=!0},p(t,i){const o={};i&1&&(o.cfg=t[0]),e.$set(o)},i(t){n||(_(e.$$.fragment,t),n=!0)},o(t){$(e.$$.fragment,t),n=!1},d(t){F(e,t)}}}function pm(r){let e,n;return e=new Xc({}),{c(){P(e.$$.fragment)},m(t,i){L(e,t,i),n=!0},p:Q,i(t){n||(_(e.$$.fragment,t),n=!0)},o(t){$(e.$$.fragment,t),n=!1},d(t){F(e,t)}}}function mm(r){let e,n;return e=new Xp({props:{cfg:r[0],gjSchemes:r[1]}}),{c(){P(e.$$.fragment)},m(t,i){L(e,t,i),n=!0},p(t,i){const o={};i&1&&(o.cfg=t[0]),i&2&&(o.gjSchemes=t[1]),e.$set(o)},i(t){n||(_(e.$$.fragment,t),n=!0)},o(t){$(e.$$.fragment,t),n=!1},d(t){F(e,t)}}}function dm(r){let e,n;return e=new Hp({props:{cfg:r[0],gjSchemes:r[1]}}),{c(){P(e.$$.fragment)},m(t,i){L(e,t,i),n=!0},p(t,i){const o={};i&1&&(o.cfg=t[0]),i&2&&(o.gjSchemes=t[1]),e.$set(o)},i(t){n||(_(e.$$.fragment,t),n=!0)},o(t){$(e.$$.fragment,t),n=!1},d(t){F(e,t)}}}function gm(r){let e,n;return e=new Qc({props:{cfg:r[0],gjSchemes:r[1]}}),{c(){P(e.$$.fragment)},m(t,i){L(e,t,i),n=!0},p(t,i){const o={};i&1&&(o.cfg=t[0]),i&2&&(o.gjSchemes=t[1]),e.$set(o)},i(t){n||(_(e.$$.fragment,t),n=!0)},o(t){$(e.$$.fragment,t),n=!1},d(t){F(e,t)}}}function hm(r){let e,n;return e=new tp({props:{cfg:r[0],gjSchemes:r[1]}}),{c(){P(e.$$.fragment)},m(t,i){L(e,t,i),n=!0},p(t,i){const o={};i&1&&(o.cfg=t[0]),i&2&&(o.gjSchemes=t[1]),e.$set(o)},i(t){n||(_(e.$$.fragment,t),n=!0)},o(t){$(e.$$.fragment,t),n=!1},d(t){F(e,t)}}}function _m(r){let e,n;return e=new Hc({props:{cfg:r[0],gjSchemes:r[1]}}),{c(){P(e.$$.fragment)},m(t,i){L(e,t,i),n=!0},p(t,i){const o={};i&1&&(o.cfg=t[0]),i&2&&(o.gjSchemes=t[1]),e.$set(o)},i(t){n||(_(e.$$.fragment,t),n=!0)},o(t){$(e.$$.fragment,t),n=!1},d(t){F(e,t)}}}function bm(r){let e,n;return e=new qc({props:{cfg:r[0],gjSchemes:r[1],id:r[7].id}}),{c(){P(e.$$.fragment)},m(t,i){L(e,t,i),n=!0},p(t,i){const o={};i&1&&(o.cfg=t[0]),i&2&&(o.gjSchemes=t[1]),i&128&&(o.id=t[7].id),e.$set(o)},i(t){n||(_(e.$$.fragment,t),n=!0)},o(t){$(e.$$.fragment,t),n=!1},d(t){F(e,t)}}}function vm(r){let e,n,t,i,o,s,a,l,u,f,c,p,m,g,v,S,k,b,h,M,d,E,N;e=new ff({props:{cfg:r[0],gjSchemes:r[1]}});let j=r[5]&&po(r);a=new wt({props:{setMode:{mode:"new-point"},disabled:!r[4],$$slots:{default:[im]},$$scope:{ctx:r}}}),u=new wt({props:{setMode:{mode:"new-route"},disabled:!r[6],$$slots:{default:[om]},$$scope:{ctx:r}}}),c=new wt({props:{setMode:{mode:"new-freehand-polygon"},disabled:!r[3],$$slots:{default:[sm]},$$scope:{ctx:r}}}),m=new wt({props:{setMode:{mode:"new-snapped-polygon"},disabled:!r[6],$$slots:{default:[lm]},$$scope:{ctx:r}}}),v=new wt({props:{setMode:{mode:"split-route"},$$slots:{default:[am]},$$scope:{ctx:r}}}),k=new wt({props:{setMode:{mode:"set-image"},$$slots:{default:[um]},$$scope:{ctx:r}}}),h=new wt({props:{setMode:{mode:"streetview"},$$slots:{default:[fm]},$$scope:{ctx:r}}});const U=[bm,_m,hm,gm,dm,mm,pm,cm],B=[];function O(C,A){return C[7].mode=="edit"?0:C[7].mode=="new-point"?1:C[7].mode=="new-route"?2:C[7].mode=="new-freehand-polygon"?3:C[7].mode=="new-snapped-polygon"?4:C[7].mode=="split-route"?5:C[7].mode=="set-image"?6:C[7].mode=="streetview"?7:-1}return~(d=O(r))&&(E=B[d]=U[d](r)),{c(){P(e.$$.fragment),n=R(),t=q("div"),i=q("div"),j&&j.c(),o=R(),s=q("div"),P(a.$$.fragment),l=R(),P(u.$$.fragment),f=R(),P(c.$$.fragment),p=R(),P(m.$$.fragment),g=R(),P(v.$$.fragment),S=R(),P(k.$$.fragment),b=R(),P(h.$$.fragment),M=R(),E&&E.c(),ge(i,"visibility",r[7].mode=="list"?"visible":"hidden"),J(s,"class","toolbar svelte-ovanu5"),J(t,"class","top govuk-prose svelte-ovanu5")},m(C,A){L(e,C,A),y(C,n,A),y(C,t,A),G(t,i),j&&j.m(i,null),G(t,o),G(t,s),L(a,s,null),G(s,l),L(u,s,null),G(s,f),L(c,s,null),G(s,p),L(m,s,null),G(s,g),L(v,s,null),G(s,S),L(k,s,null),G(s,b),L(h,s,null),G(t,M),~d&&B[d].m(t,null),N=!0},p(C,[A]){const I={};A&1&&(I.cfg=C[0]),A&2&&(I.gjSchemes=C[1]),e.$set(I),C[5]?j?(j.p(C,A),A&32&&_(j,1)):(j=po(C),j.c(),_(j,1),j.m(i,null)):j&&(se(),$(j,1,1,()=>{j=null}),le()),A&128&&ge(i,"visibility",C[7].mode=="list"?"visible":"hidden");const W={};A&16&&(W.disabled=!C[4]),A&256&&(W.$$scope={dirty:A,ctx:C}),a.$set(W);const z={};A&64&&(z.disabled=!C[6]),A&256&&(z.$$scope={dirty:A,ctx:C}),u.$set(z);const ee={};A&8&&(ee.disabled=!C[3]),A&256&&(ee.$$scope={dirty:A,ctx:C}),c.$set(ee);const T={};A&64&&(T.disabled=!C[6]),A&256&&(T.$$scope={dirty:A,ctx:C}),m.$set(T);const fe={};A&256&&(fe.$$scope={dirty:A,ctx:C}),v.$set(fe);const me={};A&256&&(me.$$scope={dirty:A,ctx:C}),k.$set(me);const ve={};A&256&&(ve.$$scope={dirty:A,ctx:C}),h.$set(ve);let $e=d;d=O(C),d===$e?~d&&B[d].p(C,A):(E&&(se(),$(B[$e],1,1,()=>{B[$e]=null}),le()),~d?(E=B[d],E?E.p(C,A):(E=B[d]=U[d](C),E.c()),_(E,1),E.m(t,null)):E=null)},i(C){N||(_(e.$$.fragment,C),_(j),_(a.$$.fragment,C),_(u.$$.fragment,C),_(c.$$.fragment,C),_(m.$$.fragment,C),_(v.$$.fragment,C),_(k.$$.fragment,C),_(h.$$.fragment,C),_(E),N=!0)},o(C){$(e.$$.fragment,C),$(j),$(a.$$.fragment,C),$(u.$$.fragment,C),$(c.$$.fragment,C),$(m.$$.fragment,C),$(v.$$.fragment,C),$(k.$$.fragment,C),$(h.$$.fragment,C),$(E),N=!1},d(C){C&&(w(n),w(t)),F(e,C),j&&j.d(),F(a),F(u),F(c),F(m),F(v),F(k),F(h),~d&&B[d].d()}}}function $m(r,e,n){let t,i,o,s,a;K(r,it,c=>n(6,t=c)),K(r,pn,c=>n(3,i=c)),K(r,In,c=>n(4,o=c)),K(r,xe,c=>n(5,s=c)),K(r,pe,c=>n(7,a=c));let{cfg:l}=e,{gjSchemes:u}=e,{routeSnapperUrl:f}=e;return Xe(()=>{o==null||o.tearDown(),i==null||i.tearDown(),t==null||t.tearDown()}),r.$$set=c=>{"cfg"in c&&n(0,l=c.cfg),"gjSchemes"in c&&n(1,u=c.gjSchemes),"routeSnapperUrl"in c&&n(2,f=c.routeSnapperUrl)},r.$$.update=()=>{r.$$.dirty&48&&s&&!o&&In.set(new Pa(s)),r.$$.dirty&40&&s&&!i&&pn.set(new iu(s))},[l,u,f,i,o,s,t,a]}class ym extends re{constructor(e){super(),ie(this,e,$m,vm,te,{cfg:0,gjSchemes:1,routeSnapperUrl:2})}}const wm="/atip/move_draw_controls/assets/delete-3c023172.svg",km="/atip/move_draw_controls/assets/save-74d8f3c2.svg";function mo(r){let e,n;return e=new _e({props:{disabled:!r[2],$$slots:{default:[Sm]},$$scope:{ctx:r}}}),e.$on("click",r[7]),{c(){P(e.$$.fragment)},m(t,i){L(e,t,i),n=!0},p(t,i){const o={};i&4&&(o.disabled=!t[2]),i&4096&&(o.$$scope={dirty:i,ctx:t}),e.$set(o)},i(t){n||(_(e.$$.fragment,t),n=!0)},o(t){$(e.$$.fragment,t),n=!1},d(t){F(e,t)}}}function Sm(r){let e;return{c(){e=D("Auto-fill")},m(n,t){y(n,e,t)},d(n){n&&w(e)}}}function Em(r){let e,n,t,i,o,s,a=r[0].length_meters&&mo(r);return{c(){e=q("input"),n=R(),a&&a.c(),t=ce(),J(e,"type","text"),J(e,"class","govuk-input"),J(e,"id",r[5])},m(l,u){y(l,e,u),Le(e,r[0].name),y(l,n,u),a&&a.m(l,u),y(l,t,u),i=!0,o||(s=he(e,"input",r[6]),o=!0)},p(l,u){u&1&&e.value!==l[0].name&&Le(e,l[0].name),l[0].length_meters?a?(a.p(l,u),u&1&&_(a,1)):(a=mo(l),a.c(),_(a,1),a.m(t.parentNode,t)):a&&(se(),$(a,1,1,()=>{a=null}),le())},i(l){i||(_(a),i=!0)},o(l){$(a),i=!1},d(l){l&&(w(e),w(n),w(t)),a&&a.d(l),o=!1,s()}}}function go(r){let e,n,t=qn(r[0].length_meters)+"",i;return{c(){e=q("p"),n=D("Length: "),i=D(t)},m(o,s){y(o,e,s),G(e,n),G(e,i)},p(o,s){s&1&&t!==(t=qn(o[0].length_meters)+"")&&be(i,t)},d(o){o&&w(e)}}}function Mm(r){let e,n,t,i,o,s,a,l,u,f,c,p,m;e=new Ct({props:{label:"Name",id:r[5],$$slots:{default:[Em]},$$scope:{ctx:r}}});function g(d){r[9](d)}let v={label:"Scheme",choices:Object.values(r[3].schemes).map(r[8])};r[0].scheme_reference!==void 0&&(v.value=r[0].scheme_reference),t=new rr({props:v}),V.push(()=>x(t,"value",g));function S(d){r[10](d)}let k={label:"Type",choices:[["area","Area"],["route","Route"],["crossing","Crossing"],["other","Other"]],inlineSmall:!0,required:!0};r[0].intervention_type!==void 0&&(k.value=r[0].intervention_type),s=new Pt({props:k}),V.push(()=>x(s,"value",S));function b(d){r[11](d)}let h={label:"Description"};r[0].description!==void 0&&(h.value=r[0].description),u=new Ur({props:h}),V.push(()=>x(u,"value",b));let M=r[0].length_meters&&go(r);return{c(){P(e.$$.fragment),n=R(),P(t.$$.fragment),o=R(),P(s.$$.fragment),l=R(),P(u.$$.fragment),c=R(),M&&M.c(),p=ce()},m(d,E){L(e,d,E),y(d,n,E),L(t,d,E),y(d,o,E),L(s,d,E),y(d,l,E),L(u,d,E),y(d,c,E),M&&M.m(d,E),y(d,p,E),m=!0},p(d,[E]){const N={};E&4101&&(N.$$scope={dirty:E,ctx:d}),e.$set(N);const j={};E&8&&(j.choices=Object.values(d[3].schemes).map(d[8])),!i&&E&1&&(i=!0,j.value=d[0].scheme_reference,ne(()=>i=!1)),t.$set(j);const U={};!a&&E&1&&(a=!0,U.value=d[0].intervention_type,ne(()=>a=!1)),s.$set(U);const B={};!f&&E&1&&(f=!0,B.value=d[0].description,ne(()=>f=!1)),u.$set(B),d[0].length_meters?M?M.p(d,E):(M=go(d),M.c(),M.m(p.parentNode,p)):M&&(M.d(1),M=null)},i(d){m||(_(e.$$.fragment,d),_(t.$$.fragment,d),_(s.$$.fragment,d),_(u.$$.fragment,d),m=!0)},o(d){$(e.$$.fragment,d),$(t.$$.fragment,d),$(s.$$.fragment,d),$(u.$$.fragment,d),m=!1},d(d){d&&(w(n),w(o),w(l),w(c),w(p)),F(e,d),F(t,d),F(s,d),F(u,d),M&&M.d(d)}}}function Pm(r,e,n){let t,i,o=Q,s=()=>(o(),o=We(a,k=>n(3,i=k)),a);K(r,it,k=>n(2,t=k)),r.$$.on_destroy.push(()=>o());let{gjSchemes:a}=e;s();let{props:l}=e;function u(){try{n(0,l.name=t.inner.routeNameForWaypoints(l.waypoints),l)}catch(k){window.alert(`Couldn't auto-name route: ${k}`)}}let f=At();function c(){l.name=this.value,n(0,l)}const p=()=>u(),m=k=>[k.scheme_reference,Qr(k)];function g(k){r.$$.not_equal(l.scheme_reference,k)&&(l.scheme_reference=k,n(0,l))}function v(k){r.$$.not_equal(l.intervention_type,k)&&(l.intervention_type=k,n(0,l))}function S(k){r.$$.not_equal(l.description,k)&&(l.description=k,n(0,l))}return r.$$set=k=>{"gjSchemes"in k&&s(n(1,a=k.gjSchemes)),"props"in k&&n(0,l=k.props)},[l,a,t,i,u,f,c,p,m,g,v,S]}class Lm extends re{constructor(e){super(),ie(this,e,Pm,Mm,te,{gjSchemes:1,props:0})}}function Fm(r){let e,n,t;function i(s){r[2](s)}let o={label:r[1],choices:[st("New segregated cycling facility"),st("New junction treatment"),st("New permanent footway"),["New shared use facilities","New shared use (walking and cycling) facilities"],["Improvements to existing route","Improvements to make an existing walking/cycle route safer"],["Area-wide traffic management","Area-wide traffic management (including by TROs - both permanent and experimental)"],["Bus priority measures","Bus priority measures that also enable active travel (for example, bus gates)"],["Secure cycle parking","Provision of secure cycle parking facilities"],st("New road crossings"),st("Restriction or reduction of car parking availability"),st("School streets"),st("Quiet mixed traffic streets"),st("Traffic free routes"),st("Not specified in LCWIP")],emptyOption:!0};return r[0]!==void 0&&(o.value=r[0]),e=new rr({props:o}),V.push(()=>x(e,"value",i)),{c(){P(e.$$.fragment)},m(s,a){L(e,s,a),t=!0},p(s,[a]){const l={};a&2&&(l.label=s[1]),!n&&a&1&&(n=!0,l.value=s[0],ne(()=>n=!1)),e.$set(l)},i(s){t||(_(e.$$.fragment,s),t=!0)},o(s){$(e.$$.fragment,s),t=!1},d(s){F(e,s)}}}function st(r){return[r,r]}function Cm(r,e,n){let{label:t}=e,{value:i}=e;function o(s){i=s,n(0,i)}return r.$$set=s=>{"label"in s&&n(1,t=s.label),"value"in s&&n(0,i=s.value)},[i,t,o]}class Ws extends re{constructor(e){super(),ie(this,e,Cm,Fm,te,{label:1,value:0})}}function Am(r){let e,n,t,i,o,s,a,l,u,f,c,p,m,g,v,S,k,b;function h(A){r[3](A)}let M={label:"Status",choices:[["","Unknown"],["aspiration","Aspiration"],["planned","Planned"],["in development","In development"],["in construction","In construction"],["completed","Completed"]],inlineSmall:!0,required:r[1]};r[0].status!==void 0&&(M.value=r[0].status),i=new Pt({props:M}),V.push(()=>x(i,"value",h));function d(A){r[4](A)}let E={label:"Timescale",choices:[["","Unknown"],["short","Short (1-3 years)"],["medium","Medium (3-6 years)"],["long","Long (6-10 years)"]],inlineSmall:!0,required:r[1]};r[0].timescale!==void 0&&(E.value=r[0].timescale),a=new Pt({props:E}),V.push(()=>x(a,"value",d));function N(A){r[5](A)}let j={label:"Estimated completion year (if known)",width:4,min:2010,max:2100};r[0].timescale_year!==void 0&&(j.value=r[0].timescale_year),f=new sr({props:j}),V.push(()=>x(f,"value",N));function U(A){r[6](A)}let B={label:"What year was this scheme most recently published?",width:4,min:2010,max:2100};r[0].year_published!==void 0&&(B.value=r[0].year_published),m=new sr({props:B}),V.push(()=>x(m,"value",U));function O(A){r[7](A)}let C={label:"What year was this scheme most recently consulted on?",width:4,min:2010,max:2100};return r[0].year_consulted!==void 0&&(C.value=r[0].year_consulted),S=new sr({props:C}),V.push(()=>x(S,"value",O)),{c(){e=q("fieldset"),n=q("legend"),n.textContent="Timing and status",t=R(),P(i.$$.fragment),s=R(),P(a.$$.fragment),u=R(),P(f.$$.fragment),p=R(),P(m.$$.fragment),v=R(),P(S.$$.fragment),J(n,"class","govuk-fieldset__legend"),J(e,"class","govuk-fieldset svelte-1bxyfcq")},m(A,I){y(A,e,I),G(e,n),G(e,t),L(i,e,null),G(e,s),L(a,e,null),G(e,u),L(f,e,null),G(e,p),L(m,e,null),G(e,v),L(S,e,null),b=!0},p(A,[I]){const W={};I&2&&(W.required=A[1]),!o&&I&1&&(o=!0,W.value=A[0].status,ne(()=>o=!1)),i.$set(W);const z={};I&2&&(z.required=A[1]),!l&&I&1&&(l=!0,z.value=A[0].timescale,ne(()=>l=!1)),a.$set(z);const ee={};!c&&I&1&&(c=!0,ee.value=A[0].timescale_year,ne(()=>c=!1)),f.$set(ee);const T={};!g&&I&1&&(g=!0,T.value=A[0].year_published,ne(()=>g=!1)),m.$set(T);const fe={};!k&&I&1&&(k=!0,fe.value=A[0].year_consulted,ne(()=>k=!1)),S.$set(fe)},i(A){b||(_(i.$$.fragment,A),_(a.$$.fragment,A),_(f.$$.fragment,A),_(m.$$.fragment,A),_(S.$$.fragment,A),b=!0)},o(A){$(i.$$.fragment,A),$(a.$$.fragment,A),$(f.$$.fragment,A),$(m.$$.fragment,A),$(S.$$.fragment,A),b=!1},d(A){A&&w(e),F(i),F(a),F(f),F(m),F(S)}}}function Nm(r,e,n){let{data:t}=e,{required:i}=e,{onUpdate:o}=e;function s(p){o()}function a(p){r.$$.not_equal(t.status,p)&&(t.status=p,n(0,t))}function l(p){r.$$.not_equal(t.timescale,p)&&(t.timescale=p,n(0,t))}function u(p){r.$$.not_equal(t.timescale_year,p)&&(t.timescale_year=p,n(0,t))}function f(p){r.$$.not_equal(t.year_published,p)&&(t.year_published=p,n(0,t))}function c(p){r.$$.not_equal(t.year_consulted,p)&&(t.year_consulted=p,n(0,t))}return r.$$set=p=>{"data"in p&&n(0,t=p.data),"required"in p&&n(1,i=p.required),"onUpdate"in p&&n(2,o=p.onUpdate)},r.$$.update=()=>{r.$$.dirty&1&&s()},[t,i,o,a,l,u,f,c]}class Ks extends re{constructor(e){super(),ie(this,e,Nm,Am,te,{data:0,required:1,onUpdate:2})}}function ho(r,e,n){const t=r.slice();return t[9]=e[n],t[10]=e,t[11]=n,t}function Rm(r){let e;return{c(){e=D("Is the development fully funded?")},m(n,t){y(n,e,t)},d(n){n&&w(e)}}}function Om(r){let e;return{c(){e=D("Is the construction fully funded?")},m(n,t){y(n,e,t)},d(n){n&&w(e)}}}function jm(r){let e,n,t;function i(s){r[6](s,r[9])}let o={$$slots:{default:[Im]},$$scope:{ctx:r}};return r[0].funding_sources[r[9]]!==void 0&&(o.checked=r[0].funding_sources[r[9]]),e=new Ft({props:o}),V.push(()=>x(e,"checked",i)),{c(){P(e.$$.fragment)},m(s,a){L(e,s,a),t=!0},p(s,a){r=s;const l={};a&4096&&(l.$$scope={dirty:a,ctx:r}),!n&&a&3&&(n=!0,l.checked=r[0].funding_sources[r[9]],ne(()=>n=!1)),e.$set(l)},i(s){t||(_(e.$$.fragment,s),t=!0)},o(s){$(e.$$.fragment,s),t=!1},d(s){F(e,s)}}}function Im(r){let e=r[9].toUpperCase()+"",n,t;return{c(){n=D(e),t=R()},m(i,o){y(i,n,o),y(i,t,o)},p:Q,d(i){i&&(w(n),w(t))}}}function _o(r){let e,n,t=r[9]!="other"&&jm(r);return{c(){t&&t.c(),e=ce()},m(i,o){t&&t.m(i,o),y(i,e,o),n=!0},p(i,o){i[9]!="other"&&t.p(i,o)},i(i){n||(_(t),n=!0)},o(i){$(t),n=!1},d(i){i&&w(e),t&&t.d(i)}}}function Bm(r){let e,n,t=Ie(r[1]),i=[];for(let s=0;s$(i[s],1,1,()=>{i[s]=null});return{c(){for(let s=0;sx(i,"value",M));function E(C){r[4](C)}let N={$$slots:{default:[Rm]},$$scope:{ctx:r}};r[0].development_funded!==void 0&&(N.checked=r[0].development_funded),a=new Ft({props:N}),V.push(()=>x(a,"checked",E));function j(C){r[5](C)}let U={$$slots:{default:[Om]},$$scope:{ctx:r}};r[0].construction_funded!==void 0&&(U.checked=r[0].construction_funded),f=new Ft({props:U}),V.push(()=>x(f,"checked",j)),v=new Ko({props:{$$slots:{default:[Bm]},$$scope:{ctx:r}}});function B(C){r[7](C)}let O={label:"Other funding sources"};return r[0].funding_sources.other!==void 0&&(O.value=r[0].funding_sources.other),k=new ir({props:O}),V.push(()=>x(k,"value",B)),{c(){e=q("fieldset"),n=q("legend"),n.textContent="Budget",t=R(),P(i.$$.fragment),s=R(),P(a.$$.fragment),u=R(),P(f.$$.fragment),p=R(),m=q("p"),m.textContent="Funding sources",g=R(),P(v.$$.fragment),S=R(),P(k.$$.fragment),J(n,"class","govuk-fieldset__legend"),J(e,"class","govuk-fieldset svelte-1bxyfcq")},m(C,A){y(C,e,A),G(e,n),G(e,t),L(i,e,null),G(e,s),L(a,e,null),G(e,u),L(f,e,null),G(e,p),G(e,m),G(e,g),L(v,e,null),G(e,S),L(k,e,null),h=!0},p(C,[A]){const I={};!o&&A&1&&(o=!0,I.value=C[0].budget,ne(()=>o=!1)),i.$set(I);const W={};A&4096&&(W.$$scope={dirty:A,ctx:C}),!l&&A&1&&(l=!0,W.checked=C[0].development_funded,ne(()=>l=!1)),a.$set(W);const z={};A&4096&&(z.$$scope={dirty:A,ctx:C}),!c&&A&1&&(c=!0,z.checked=C[0].construction_funded,ne(()=>c=!1)),f.$set(z);const ee={};A&4097&&(ee.$$scope={dirty:A,ctx:C}),v.$set(ee);const T={};!b&&A&1&&(b=!0,T.value=C[0].funding_sources.other,ne(()=>b=!1)),k.$set(T)},i(C){h||(_(i.$$.fragment,C),_(a.$$.fragment,C),_(f.$$.fragment,C),_(v.$$.fragment,C),_(k.$$.fragment,C),h=!0)},o(C){$(i.$$.fragment,C),$(a.$$.fragment,C),$(f.$$.fragment,C),$(v.$$.fragment,C),$(k.$$.fragment,C),h=!1},d(C){C&&w(e),F(i),F(a),F(f),F(v),F(k)}}}function Gm(r,e,n){let{data:t}=e,{onUpdate:i}=e;function o(p){i()}let s=["atf2","atf3","atf4","atf4e","crsts","luf"];function a(p){r.$$.not_equal(t.budget,p)&&(t.budget=p,n(0,t))}function l(p){r.$$.not_equal(t.development_funded,p)&&(t.development_funded=p,n(0,t))}function u(p){r.$$.not_equal(t.construction_funded,p)&&(t.construction_funded=p,n(0,t))}function f(p,m){r.$$.not_equal(t.funding_sources[m],p)&&(t.funding_sources[m]=p,n(0,t))}function c(p){r.$$.not_equal(t.funding_sources.other,p)&&(t.funding_sources.other=p,n(0,t))}return r.$$set=p=>{"data"in p&&n(0,t=p.data),"onUpdate"in p&&n(2,i=p.onUpdate)},r.$$.update=()=>{r.$$.dirty&1&&o()},[t,s,i,a,l,u,f,c]}class Hs extends re{constructor(e){super(),ie(this,e,Gm,qm,te,{data:0,onUpdate:2})}}function bo(r){let e,n;return e=new _e({props:{disabled:!r[2],$$slots:{default:[Tm]},$$scope:{ctx:r}}}),e.$on("click",r[8]),{c(){P(e.$$.fragment)},m(t,i){L(e,t,i),n=!0},p(t,i){const o={};i&4&&(o.disabled=!t[2]),i&65536&&(o.$$scope={dirty:i,ctx:t}),e.$set(o)},i(t){n||(_(e.$$.fragment,t),n=!0)},o(t){$(e.$$.fragment,t),n=!1},d(t){F(e,t)}}}function Tm(r){let e;return{c(){e=D("Auto-fill with street names")},m(n,t){y(n,e,t)},d(n){n&&w(e)}}}function Um(r){let e,n,t,i,o,s,a,l,u=r[0].length_meters&&bo(r);return{c(){e=q("div"),e.textContent="Use the name from the LCWIP if possible",n=R(),t=q("input"),i=R(),u&&u.c(),o=ce(),J(e,"class","govuk-hint"),J(t,"type","text"),J(t,"class","govuk-input"),J(t,"id",r[6])},m(f,c){y(f,e,c),y(f,n,c),y(f,t,c),Le(t,r[0].name),y(f,i,c),u&&u.m(f,c),y(f,o,c),s=!0,a||(l=he(t,"input",r[7]),a=!0)},p(f,c){c&1&&t.value!==f[0].name&&Le(t,f[0].name),f[0].length_meters?u?(u.p(f,c),c&1&&_(u,1)):(u=bo(f),u.c(),_(u,1),u.m(o.parentNode,o)):u&&(se(),$(u,1,1,()=>{u=null}),le())},i(f){s||(_(u),s=!0)},o(f){$(u),s=!1},d(f){f&&(w(e),w(n),w(t),w(i),w(o)),u&&u.d(f),a=!1,l()}}}function vo(r){let e,n,t=qn(r[0].length_meters)+"",i;return{c(){e=q("p"),n=D("Length: "),i=D(t)},m(o,s){y(o,e,s),G(e,n),G(e,i)},p(o,s){s&1&&t!==(t=qn(o[0].length_meters)+"")&&be(i,t)},d(o){o&&w(e)}}}function $o(r){let e,n,t,i,o,s,a,l,u,f,c,p,m,g;function v(E){r[12](E)}let S={label:"Type"};r[0].pipeline.atf4_type!==void 0&&(S.value=r[0].pipeline.atf4_type),e=new Ws({props:S}),V.push(()=>x(e,"value",v));function k(E){r[13](E)}let b={label:"Accuracy of mapped data",choices:[["high","High"],["medium","Medium"],["low","Low"]],required:!0,inlineSmall:!0};r[0].pipeline.accuracy!==void 0&&(b.value=r[0].pipeline.accuracy),i=new Pt({props:b}),V.push(()=>x(i,"value",k));function h(E){r[14](E)}let M={$$slots:{default:[Dm]},$$scope:{ctx:r}};r[0].pipeline.is_alternative!==void 0&&(M.checked=r[0].pipeline.is_alternative),a=new Ft({props:M}),V.push(()=>x(a,"checked",h));let d=r[4]&&r[0].is_coverage_polygon!==void 0&&yo(r);return c=new Ks({props:{data:r[0].pipeline,required:!1,onUpdate:Ym}}),m=new Hs({props:{data:r[0].pipeline,onUpdate:Xm}}),{c(){P(e.$$.fragment),t=R(),P(i.$$.fragment),s=R(),P(a.$$.fragment),u=R(),d&&d.c(),f=R(),P(c.$$.fragment),p=R(),P(m.$$.fragment)},m(E,N){L(e,E,N),y(E,t,N),L(i,E,N),y(E,s,N),L(a,E,N),y(E,u,N),d&&d.m(E,N),y(E,f,N),L(c,E,N),y(E,p,N),L(m,E,N),g=!0},p(E,N){const j={};!n&&N&1&&(n=!0,j.value=E[0].pipeline.atf4_type,ne(()=>n=!1)),e.$set(j);const U={};!o&&N&1&&(o=!0,U.value=E[0].pipeline.accuracy,ne(()=>o=!1)),i.$set(U);const B={};N&65536&&(B.$$scope={dirty:N,ctx:E}),!l&&N&1&&(l=!0,B.checked=E[0].pipeline.is_alternative,ne(()=>l=!1)),a.$set(B),E[4]&&E[0].is_coverage_polygon!==void 0?d?(d.p(E,N),N&1&&_(d,1)):(d=yo(E),d.c(),_(d,1),d.m(f.parentNode,f)):d&&(se(),$(d,1,1,()=>{d=null}),le());const O={};N&1&&(O.data=E[0].pipeline),c.$set(O);const C={};N&1&&(C.data=E[0].pipeline),m.$set(C)},i(E){g||(_(e.$$.fragment,E),_(i.$$.fragment,E),_(a.$$.fragment,E),_(d),_(c.$$.fragment,E),_(m.$$.fragment,E),g=!0)},o(E){$(e.$$.fragment,E),$(i.$$.fragment,E),$(a.$$.fragment,E),$(d),$(c.$$.fragment,E),$(m.$$.fragment,E),g=!1},d(E){E&&(w(t),w(s),w(u),w(f),w(p)),F(e,E),F(i,E),F(a,E),d&&d.d(E),F(c,E),F(m,E)}}}function Dm(r){let e;return{c(){e=D("Is this an alternative route and not the default option?")},m(n,t){y(n,e,t)},d(n){n&&w(e)}}}function yo(r){let e,n,t;function i(s){r[15](s)}let o={$$slots:{default:[zm]},$$scope:{ctx:r}};return r[0].is_coverage_polygon!==void 0&&(o.checked=r[0].is_coverage_polygon),e=new Ft({props:o}),V.push(()=>x(e,"checked",i)),{c(){P(e.$$.fragment)},m(s,a){L(e,s,a),t=!0},p(s,a){const l={};a&65536&&(l.$$scope={dirty:a,ctx:s}),!n&&a&1&&(n=!0,l.checked=s[0].is_coverage_polygon,ne(()=>n=!1)),e.$set(l)},i(s){t||(_(e.$$.fragment,s),t=!0)},o(s){$(e.$$.fragment,s),t=!1},d(s){F(e,s)}}}function zm(r){let e;return{c(){e=D(`Does this polygon show the coverage of the scheme? (All area considered - while making the scheme)`)},m(n,t){y(n,e,t)},d(n){n&&w(e)}}}function Jm(r){let e,n,t,i,o,s,a,l,u,f,c;e=new Ct({props:{label:"Name",id:r[6],$$slots:{default:[Um]},$$scope:{ctx:r}}});function p(b){r[10](b)}let m={label:"Scheme",choices:Object.values(r[3].schemes).map(r[9])};r[0].scheme_reference!==void 0&&(m.value=r[0].scheme_reference),t=new rr({props:m}),V.push(()=>x(t,"value",p));function g(b){r[11](b)}let v={label:"Description"};r[0].description!==void 0&&(v.value=r[0].description),s=new Ur({props:v}),V.push(()=>x(s,"value",g));let S=r[0].length_meters&&vo(r),k=r[0].pipeline&&$o(r);return{c(){P(e.$$.fragment),n=R(),P(t.$$.fragment),o=R(),P(s.$$.fragment),l=R(),S&&S.c(),u=R(),k&&k.c(),f=ce()},m(b,h){L(e,b,h),y(b,n,h),L(t,b,h),y(b,o,h),L(s,b,h),y(b,l,h),S&&S.m(b,h),y(b,u,h),k&&k.m(b,h),y(b,f,h),c=!0},p(b,[h]){const M={};h&65541&&(M.$$scope={dirty:h,ctx:b}),e.$set(M);const d={};h&8&&(d.choices=Object.values(b[3].schemes).map(b[9])),!i&&h&1&&(i=!0,d.value=b[0].scheme_reference,ne(()=>i=!1)),t.$set(d);const E={};!a&&h&1&&(a=!0,E.value=b[0].description,ne(()=>a=!1)),s.$set(E),b[0].length_meters?S?S.p(b,h):(S=vo(b),S.c(),S.m(u.parentNode,u)):S&&(S.d(1),S=null),b[0].pipeline?k?(k.p(b,h),h&1&&_(k,1)):(k=$o(b),k.c(),_(k,1),k.m(f.parentNode,f)):k&&(se(),$(k,1,1,()=>{k=null}),le())},i(b){c||(_(e.$$.fragment,b),_(t.$$.fragment,b),_(s.$$.fragment,b),_(k),c=!0)},o(b){$(e.$$.fragment,b),$(t.$$.fragment,b),$(s.$$.fragment,b),$(k),c=!1},d(b){b&&(w(n),w(o),w(l),w(u),w(f)),F(e,b),F(t,b),F(s,b),S&&S.d(b),k&&k.d(b)}}}const Ym=()=>{},Xm=()=>{};function Wm(r,e,n){let t,i,o=Q,s=()=>(o(),o=We(a,d=>n(3,i=d)),a);K(r,it,d=>n(2,t=d)),r.$$.on_destroy.push(()=>o());let{gjSchemes:a}=e;s();let{props:l}=e;l.pipeline||(l.pipeline={atf4_type:"",accuracy:"",is_alternative:!1,development_funded:!1,construction_funded:!1,funding_sources:xn(),status:"",timescale:""}),l.is_coverage_polygon||(l.is_coverage_polygon=!1);const u=(i.features.filter(d=>d.properties.is_coverage_polygon).length==0||l.is_coverage_polygon===!0)&&l.intervention_type==="area";function f(){try{n(0,l.name=t.inner.routeNameForWaypoints(l.waypoints),l)}catch(d){window.alert(`Couldn't auto-name route: ${d}`)}}let c=At();function p(){l.name=this.value,n(0,l)}const m=()=>f(),g=d=>[d.scheme_reference,Qr(d)];function v(d){r.$$.not_equal(l.scheme_reference,d)&&(l.scheme_reference=d,n(0,l))}function S(d){r.$$.not_equal(l.description,d)&&(l.description=d,n(0,l))}function k(d){r.$$.not_equal(l.pipeline.atf4_type,d)&&(l.pipeline.atf4_type=d,n(0,l))}function b(d){r.$$.not_equal(l.pipeline.accuracy,d)&&(l.pipeline.accuracy=d,n(0,l))}function h(d){r.$$.not_equal(l.pipeline.is_alternative,d)&&(l.pipeline.is_alternative=d,n(0,l))}function M(d){r.$$.not_equal(l.is_coverage_polygon,d)&&(l.is_coverage_polygon=d,n(0,l))}return r.$$set=d=>{"gjSchemes"in d&&s(n(1,a=d.gjSchemes)),"props"in d&&n(0,l=d.props)},[l,a,t,i,u,f,c,p,m,g,v,S,k,b,h,M]}class Km extends re{constructor(e){super(),ie(this,e,Wm,Jm,te,{gjSchemes:1,props:0})}}function wo(r,e,n){const t=r.slice();return t[9]=e[n][0],t[10]=e[n][1],t}function ko(r){let e,n;return e=new _e({props:{$$slots:{default:[Hm]},$$scope:{ctx:r}}}),e.$on("click",r[6]),{c(){P(e.$$.fragment)},m(t,i){L(e,t,i),n=!0},p(t,i){const o={};i&8192&&(o.$$scope={dirty:i,ctx:t}),e.$set(o)},i(t){n||(_(e.$$.fragment,t),n=!0)},o(t){$(e.$$.fragment,t),n=!1},d(t){F(e,t)}}}function Hm(r){let e;return{c(){e=D("Handle extra GeoJSON properties")},m(n,t){y(n,e,t)},d(n){n&&w(e)}}}function So(r){let e,n,t=r[9]+"",i,o,s=JSON.stringify(r[10])+"",a,l;return{c(){e=q("li"),n=q("b"),i=D(t),o=D(` - = `),a=D(s),l=R()},m(u,f){y(u,e,f),G(e,n),G(n,i),G(e,o),G(e,a),G(e,l)},p(u,f){f&2&&t!==(t=u[9]+"")&&be(i,t),f&2&&s!==(s=JSON.stringify(u[10])+"")&&be(a,s)},d(u){u&&w(e)}}}function Zm(r){let e;return{c(){e=D("Remove these properties")},m(n,t){y(n,e,t)},d(n){n&&w(e)}}}function Vm(r){let e;return{c(){e=D("Cancel")},m(n,t){y(n,e,t)},d(n){n&&w(e)}}}function Qm(r){let e,n,t,i;return e=new bt({props:{$$slots:{default:[Zm]},$$scope:{ctx:r}}}),e.$on("click",r[2]),t=new _e({props:{$$slots:{default:[Vm]},$$scope:{ctx:r}}}),t.$on("click",r[7]),{c(){P(e.$$.fragment),n=R(),P(t.$$.fragment)},m(o,s){L(e,o,s),y(o,n,s),L(t,o,s),i=!0},p(o,s){const a={};s&8192&&(a.$$scope={dirty:s,ctx:o}),e.$set(a);const l={};s&8192&&(l.$$scope={dirty:s,ctx:o}),t.$set(l)},i(o){i||(_(e.$$.fragment,o),_(t.$$.fragment,o),i=!0)},o(o){$(e.$$.fragment,o),$(t.$$.fragment,o),i=!1},d(o){o&&w(n),F(e,o),F(t,o)}}}function xm(r){let e,n,t,i,o,s,a=Ie(Object.entries(r[1])),l=[];for(let u=0;u0,n,t,i,o,s=e&&ko(r);function a(u){r[8](u)}let l={title:"This imported GeoJSON feature has unexpected properties",$$slots:{default:[xm]},$$scope:{ctx:r}};return r[0]!==void 0&&(l.open=r[0]),t=new Nt({props:l}),V.push(()=>x(t,"open",a)),{c(){s&&s.c(),n=R(),P(t.$$.fragment)},m(u,f){s&&s.m(u,f),y(u,n,f),L(t,u,f),o=!0},p(u,[f]){f&2&&(e=Object.entries(u[1]).length>0),e?s?(s.p(u,f),f&2&&_(s,1)):(s=ko(u),s.c(),_(s,1),s.m(n.parentNode,n)):s&&(se(),$(s,1,1,()=>{s=null}),le());const c={};f&8195&&(c.$$scope={dirty:f,ctx:u}),!i&&f&1&&(i=!0,c.open=u[0],ne(()=>i=!1)),t.$set(c)},i(u){o||(_(s),_(t.$$.fragment,u),o=!0)},o(u){$(s),$(t.$$.fragment,u),o=!1},d(u){u&&w(n),s&&s.d(u),F(t,u)}}}function td(r,e,n){let t,{gjSchemes:i}=e,{id:o}=e,{props:s}=e,a=!1;function l(){n(0,a=!1),i.update(p=>{let m=p.features.find(g=>g.id==o);for(let g of Object.keys(t))delete m.properties[g];return p})}const u=()=>n(0,a=!0),f=()=>n(0,a=!1);function c(p){a=p,n(0,a)}return r.$$set=p=>{"gjSchemes"in p&&n(3,i=p.gjSchemes),"id"in p&&n(4,o=p.id),"props"in p&&n(5,s=p.props)},r.$$.update=()=>{r.$$.dirty&32&&n(1,t=Vs(s))},[a,t,l,i,o,s,u,f,c]}class nd extends re{constructor(e){super(),ie(this,e,td,ed,te,{gjSchemes:3,id:4,props:5})}}function Eo(r){let e,n;return e=new nd({props:{gjSchemes:r[1],id:r[2],props:r[0]}}),{c(){P(e.$$.fragment)},m(t,i){L(e,t,i),n=!0},p(t,i){const o={};i&2&&(o.gjSchemes=t[1]),i&4&&(o.id=t[2]),i&1&&(o.props=t[0]),e.$set(o)},i(t){n||(_(e.$$.fragment,t),n=!0)},o(t){$(e.$$.fragment,t),n=!1},d(t){F(e,t)}}}function rd(r){let e,n,t;function i(s){r[6](s)}let o={gjSchemes:r[1]};return r[0]!==void 0&&(o.props=r[0]),e=new Km({props:o}),V.push(()=>x(e,"props",i)),{c(){P(e.$$.fragment)},m(s,a){L(e,s,a),t=!0},p(s,a){const l={};a&2&&(l.gjSchemes=s[1]),!n&&a&1&&(n=!0,l.props=s[0],ne(()=>n=!1)),e.$set(l)},i(s){t||(_(e.$$.fragment,s),t=!0)},o(s){$(e.$$.fragment,s),t=!1},d(s){F(e,s)}}}function id(r){let e,n,t;function i(s){r[5](s)}let o={gjSchemes:r[1]};return r[0]!==void 0&&(o.props=r[0]),e=new Lm({props:o}),V.push(()=>x(e,"props",i)),{c(){P(e.$$.fragment)},m(s,a){L(e,s,a),t=!0},p(s,a){const l={};a&2&&(l.gjSchemes=s[1]),!n&&a&1&&(n=!0,l.props=s[0],ne(()=>n=!1)),e.$set(l)},i(s){t||(_(e.$$.fragment,s),t=!0)},o(s){$(e.$$.fragment,s),t=!1},d(s){F(e,s)}}}function od(r){let e,n,t,i,o,s=r[2]!=null&&Eo(r);const a=[id,rd],l=[];function u(f,c){return f[3]=="v1"?0:f[3]=="pipeline"?1:-1}return~(n=u(r))&&(t=l[n]=a[n](r)),{c(){s&&s.c(),e=R(),t&&t.c(),i=ce()},m(f,c){s&&s.m(f,c),y(f,e,c),~n&&l[n].m(f,c),y(f,i,c),o=!0},p(f,[c]){f[2]!=null?s?(s.p(f,c),c&4&&_(s,1)):(s=Eo(f),s.c(),_(s,1),s.m(e.parentNode,e)):s&&(se(),$(s,1,1,()=>{s=null}),le());let p=n;n=u(f),n===p?~n&&l[n].p(f,c):(t&&(se(),$(l[p],1,1,()=>{l[p]=null}),le()),~n?(t=l[n],t?t.p(f,c):(t=l[n]=a[n](f),t.c()),_(t,1),t.m(i.parentNode,i)):t=null)},i(f){o||(_(s),_(t),o=!0)},o(f){$(s),$(t),o=!1},d(f){f&&(w(e),w(i)),s&&s.d(f),~n&&l[n].d(f)}}}function sd(r,e,n){let t;K(r,Qe,f=>n(3,t=f));let{cfg:i}=e,{gjSchemes:o}=e,{id:s}=e,{props:a}=e;function l(f){a=f,n(0,a)}function u(f){a=f,n(0,a)}return r.$$set=f=>{"cfg"in f&&n(4,i=f.cfg),"gjSchemes"in f&&n(1,o=f.gjSchemes),"id"in f&&n(2,s=f.id),"props"in f&&n(0,a=f.props)},[a,o,s,t,i,l,u]}let ld=class extends re{constructor(e){super(),ie(this,e,sd,od,te,{cfg:4,gjSchemes:1,id:2,props:0})}};function ad(r){let e;return{c(){e=D("Scheme details")},m(n,t){y(n,e,t)},d(n){n&&w(e)}}}function ud(r){let e;return{c(){e=D("Save")},m(n,t){y(n,e,t)},d(n){n&&w(e)}}}function fd(r){let e,n,t,i,o;function s(l){r[6](l)}let a={label:"Scheme name",required:!0};return r[3].schemes[r[1]].scheme_name!==void 0&&(a.value=r[3].schemes[r[1]].scheme_name),e=new ir({props:a}),V.push(()=>x(e,"value",s)),i=new _t({props:{$$slots:{default:[ud]},$$scope:{ctx:r}}}),i.$on("click",r[7]),{c(){P(e.$$.fragment),t=R(),P(i.$$.fragment)},m(l,u){L(e,l,u),y(l,t,u),L(i,l,u),o=!0},p(l,u){const f={};!n&&u&10&&(n=!0,f.value=l[3].schemes[l[1]].scheme_name,ne(()=>n=!1)),e.$set(f);const c={};u&512&&(c.$$scope={dirty:u,ctx:l}),i.$set(c)},i(l){o||(_(e.$$.fragment,l),_(i.$$.fragment,l),o=!0)},o(l){$(e.$$.fragment,l),$(i.$$.fragment,l),o=!1},d(l){l&&w(t),F(e,l),F(i,l)}}}function cd(r){let e,n,t,i,o,s,a;e=new _e({props:{$$slots:{default:[ad]},$$scope:{ctx:r}}}),e.$on("click",r[5]);function l(f){r[8](f)}let u={title:"Scheme details",$$slots:{default:[fd]},$$scope:{ctx:r}};return r[2]!==void 0&&(u.open=r[2]),t=new Nt({props:u}),V.push(()=>x(t,"open",l)),{c(){P(e.$$.fragment),n=R(),P(t.$$.fragment)},m(f,c){L(e,f,c),y(f,n,c),L(t,f,c),o=!0,s||(a=he(window,"keydown",r[4]),s=!0)},p(f,[c]){const p={};c&512&&(p.$$scope={dirty:c,ctx:f}),e.$set(p);const m={};c&526&&(m.$$scope={dirty:c,ctx:f}),!i&&c&4&&(i=!0,m.open=f[2],ne(()=>i=!1)),t.$set(m)},i(f){o||(_(e.$$.fragment,f),_(t.$$.fragment,f),o=!0)},o(f){$(e.$$.fragment,f),$(t.$$.fragment,f),o=!1},d(f){f&&w(n),F(e,f),F(t,f),s=!1,a()}}}function pd(r,e,n){let t,i=Q,o=()=>(i(),i=We(s,g=>n(3,t=g)),s);r.$$.on_destroy.push(()=>i());let{gjSchemes:s}=e;o();let{scheme_reference:a}=e,l=!1;function u(g){l&&g.key=="Escape"&&(g.stopPropagation(),n(2,l=!1))}const f=()=>n(2,l=!0);function c(g){r.$$.not_equal(t.schemes[a].scheme_name,g)&&(t.schemes[a].scheme_name=g,s.set(t))}const p=()=>n(2,l=!1);function m(g){l=g,n(2,l)}return r.$$set=g=>{"gjSchemes"in g&&o(n(0,s=g.gjSchemes)),"scheme_reference"in g&&n(1,a=g.scheme_reference)},[s,a,l,t,u,f,c,p,m]}class md extends re{constructor(e){super(),ie(this,e,pd,cd,te,{gjSchemes:0,scheme_reference:1})}}function dd(r){let e;return{c(){e=D("Scheme details")},m(n,t){y(n,e,t)},d(n){n&&w(e)}}}function gd(r){let e;return{c(){e=D("Save")},m(n,t){y(n,e,t)},d(n){n&&w(e)}}}function hd(r){let e,n,t,i,o,s,a,l,u,f,c,p,m,g,v,S,k,b,h,M,d;function E(I){r[9](I)}let N={label:"Scheme name",required:!0};r[6].schemes[r[1]].scheme_name!==void 0&&(N.value=r[6].schemes[r[1]].scheme_name),e=new ir({props:N}),V.push(()=>x(e,"value",E));function j(I){r[10](I)}let U={label:"Scheme type",choices:[["cycling route","Cycling route"],["walking route","Walking route"],["shared-use route","Shared-use route"],["cycling and walking route","Cycling and walking route, not shared use"],["area-based scheme","Area-based scheme"],["intersection","Intersection/junction scheme"]],inlineSmall:!0,required:!0};r[3].scheme_type!==void 0&&(U.value=r[3].scheme_type),a=new Pt({props:U}),V.push(()=>x(a,"value",j));function B(I){r[11](I)}let O={label:"Type of the main intervention"};r[3].atf4_lead_type!==void 0&&(O.value=r[3].atf4_lead_type),f=new Ws({props:O}),V.push(()=>x(f,"value",B));function C(I){r[12](I)}let A={label:"Scheme description (150 words max)"};return r[3].scheme_description!==void 0&&(A.value=r[3].scheme_description),m=new Ur({props:A}),V.push(()=>x(m,"value",C)),S=new Ks({props:{data:r[3],required:!0,onUpdate:r[13]}}),b=new Hs({props:{data:r[3],onUpdate:r[14]}}),M=new _t({props:{$$slots:{default:[gd]},$$scope:{ctx:r}}}),M.$on("click",r[15]),{c(){P(e.$$.fragment),t=R(),i=q("fieldset"),o=q("legend"),o.textContent="Basic information",s=R(),P(a.$$.fragment),u=R(),P(f.$$.fragment),p=R(),P(m.$$.fragment),v=R(),P(S.$$.fragment),k=R(),P(b.$$.fragment),h=R(),P(M.$$.fragment),J(o,"class","govuk-fieldset__legend"),J(i,"class","govuk-fieldset svelte-1bxyfcq")},m(I,W){L(e,I,W),y(I,t,W),y(I,i,W),G(i,o),G(i,s),L(a,i,null),G(i,u),L(f,i,null),G(i,p),L(m,i,null),y(I,v,W),L(S,I,W),y(I,k,W),L(b,I,W),y(I,h,W),L(M,I,W),d=!0},p(I,W){const z={};!n&&W&66&&(n=!0,z.value=I[6].schemes[I[1]].scheme_name,ne(()=>n=!1)),e.$set(z);const ee={};!l&&W&8&&(l=!0,ee.value=I[3].scheme_type,ne(()=>l=!1)),a.$set(ee);const T={};!c&&W&8&&(c=!0,T.value=I[3].atf4_lead_type,ne(()=>c=!1)),f.$set(T);const fe={};!g&&W&8&&(g=!0,fe.value=I[3].scheme_description,ne(()=>g=!1)),m.$set(fe);const me={};W&8&&(me.data=I[3]),W&16&&(me.onUpdate=I[13]),S.$set(me);const ve={};W&8&&(ve.data=I[3]),W&16&&(ve.onUpdate=I[14]),b.$set(ve);const $e={};W&524288&&($e.$$scope={dirty:W,ctx:I}),M.$set($e)},i(I){d||(_(e.$$.fragment,I),_(a.$$.fragment,I),_(f.$$.fragment,I),_(m.$$.fragment,I),_(S.$$.fragment,I),_(b.$$.fragment,I),_(M.$$.fragment,I),d=!0)},o(I){$(e.$$.fragment,I),$(a.$$.fragment,I),$(f.$$.fragment,I),$(m.$$.fragment,I),$(S.$$.fragment,I),$(b.$$.fragment,I),$(M.$$.fragment,I),d=!1},d(I){I&&(w(t),w(i),w(v),w(k),w(h)),F(e,I),F(a),F(f),F(m),F(S,I),F(b,I),F(M,I)}}}function _d(r){let e,n,t,i,o,s,a,l,u;e=new Ye({props:{errorMessage:r[5]}}),t=new _e({props:{$$slots:{default:[dd]},$$scope:{ctx:r}}}),t.$on("click",r[8]);function f(p){r[16](p)}let c={title:"Scheme details",$$slots:{default:[hd]},$$scope:{ctx:r}};return r[2]!==void 0&&(c.open=r[2]),o=new Nt({props:c}),V.push(()=>x(o,"open",f)),{c(){P(e.$$.fragment),n=R(),P(t.$$.fragment),i=R(),P(o.$$.fragment)},m(p,m){L(e,p,m),y(p,n,m),L(t,p,m),y(p,i,m),L(o,p,m),a=!0,l||(u=he(window,"keydown",r[7]),l=!0)},p(p,[m]){const g={};m&32&&(g.errorMessage=p[5]),e.$set(g);const v={};m&524288&&(v.$$scope={dirty:m,ctx:p}),t.$set(v);const S={};m&524382&&(S.$$scope={dirty:m,ctx:p}),!s&&m&4&&(s=!0,S.open=p[2],ne(()=>s=!1)),o.$set(S)},i(p){a||(_(e.$$.fragment,p),_(t.$$.fragment,p),_(o.$$.fragment,p),a=!0)},o(p){$(e.$$.fragment,p),$(t.$$.fragment,p),$(o.$$.fragment,p),a=!1},d(p){p&&(w(n),w(i)),F(e,p),F(t,p),F(o,p),l=!1,u()}}}function bd(r,e,n){let t,i,o=Q,s=()=>(o(),o=We(a,j=>n(6,i=j)),a);r.$$.on_destroy.push(()=>o());let{gjSchemes:a}=e;s();let{scheme_reference:l}=e,u=!1,f=i.schemes[l].pipeline,c=0;function p(j,U){return f.scheme_type&&f.status&&f.timescale?"":"Missing some required data"}function m(j){u&&j.key=="Escape"&&(j.stopPropagation(),n(2,u=!1))}function g(){je(a,i.schemes[l].pipeline=f,i),a.set(i)}const v=()=>n(2,u=!0);function S(j){r.$$.not_equal(i.schemes[l].scheme_name,j)&&(i.schemes[l].scheme_name=j,a.set(i))}function k(j){r.$$.not_equal(f.scheme_type,j)&&(f.scheme_type=j,n(3,f))}function b(j){r.$$.not_equal(f.atf4_lead_type,j)&&(f.atf4_lead_type=j,n(3,f))}function h(j){r.$$.not_equal(f.scheme_description,j)&&(f.scheme_description=j,n(3,f))}const M=()=>n(4,c++,c),d=()=>n(4,c++,c),E=()=>n(2,u=!1);function N(j){u=j,n(2,u)}return r.$$set=j=>{"gjSchemes"in j&&s(n(0,a=j.gjSchemes)),"scheme_reference"in j&&n(1,l=j.scheme_reference)},r.$$.update=()=>{r.$$.dirty&24&&n(5,t=p()),r.$$.dirty&4&&(u||g())},[a,l,u,f,c,t,i,m,v,S,k,b,h,M,d,E,N]}class vd extends re{constructor(e){super(),ie(this,e,bd,_d,te,{gjSchemes:0,scheme_reference:1})}}function $d(r){let e,n;return e=new md({props:{gjSchemes:r[0],scheme_reference:r[1]}}),{c(){P(e.$$.fragment)},m(t,i){L(e,t,i),n=!0},p(t,i){const o={};i&1&&(o.gjSchemes=t[0]),i&2&&(o.scheme_reference=t[1]),e.$set(o)},i(t){n||(_(e.$$.fragment,t),n=!0)},o(t){$(e.$$.fragment,t),n=!1},d(t){F(e,t)}}}function yd(r){let e,n;return e=new vd({props:{gjSchemes:r[0],scheme_reference:r[1]}}),{c(){P(e.$$.fragment)},m(t,i){L(e,t,i),n=!0},p(t,i){const o={};i&1&&(o.gjSchemes=t[0]),i&2&&(o.scheme_reference=t[1]),e.$set(o)},i(t){n||(_(e.$$.fragment,t),n=!0)},o(t){$(e.$$.fragment,t),n=!1},d(t){F(e,t)}}}function wd(r){let e,n,t,i;const o=[yd,$d],s=[];function a(l,u){return l[2]=="pipeline"?0:1}return e=a(r),n=s[e]=o[e](r),{c(){n.c(),t=ce()},m(l,u){s[e].m(l,u),y(l,t,u),i=!0},p(l,[u]){let f=e;e=a(l),e===f?s[e].p(l,u):(se(),$(s[f],1,1,()=>{s[f]=null}),le(),n=s[e],n?n.p(l,u):(n=s[e]=o[e](l),n.c()),_(n,1),n.m(t.parentNode,t))},i(l){i||(_(n),i=!0)},o(l){$(n),i=!1},d(l){l&&w(t),s[e].d(l)}}}function kd(r,e,n){let t;K(r,Qe,s=>n(2,t=s));let{gjSchemes:i}=e,{scheme_reference:o}=e;return r.$$set=s=>{"gjSchemes"in s&&n(0,i=s.gjSchemes),"scheme_reference"in s&&n(1,o=s.scheme_reference)},[i,o,t]}class Sd extends re{constructor(e){super(),ie(this,e,kd,wd,te,{gjSchemes:0,scheme_reference:1})}}let Ue={interventionName:Md,schemeName:Qr,backfill:On,initializeEmptyScheme:Ed,interventionWarning:Pd,editFeatureForm:ld,editSchemeForm:Sd,newPointFeature:r=>{r.properties.intervention_type="other"},newPolygonFeature:r=>{r.properties.intervention_type="area",r.properties.is_coverage_polygon=!1},newLineStringFeature:r=>{r.properties.intervention_type="route",r.properties.route_name&&!r.properties.name&&Et(Qe)!="pipeline"&&(r.properties.name=r.properties.route_name),delete r.properties.route_name},updateFeature:(r,e)=>{e.properties.route_name&&!r.properties.name&&Et(Qe)!="pipeline"&&(r.properties.name=e.properties.route_name)},maptilerApiKey:"MZEJTanw3WpxRvt7qDfo",getStreetViewRoadLayerNames:r=>jl(r,Et(hr)),layerZorder:Il};function On(r){var t,i,o,s,a,l,u,f;let e=Et(Qe),n=1;for(let c of r.features)c.properties||(c.properties={name:"",scheme_reference:"",description:"",intervention_type:"other",is_coverage_polygon:!1}),e=="pipeline"&&!c.properties.intervention_type&&(c.properties.intervention_type=new Map([["LineString","route"],["Polygon","area"]]).get(c.geometry.type)??"other"),c.geometry.type=="LineString"&&!c.properties.length_meters&&(c.properties.length_meters=Bl(c,{units:"kilometers"})*1e3),c.id=n++;if(!r.schemes){let c=At();r.schemes={},r.schemes[c]={scheme_reference:c,color:si()},r.scheme_name&&(r.schemes[c].scheme_name=r.scheme_name,delete r.scheme_name),r.pipeline&&(r.schemes[c].pipeline=r.pipeline,delete r.pipeline);for(let p of r.features)p.properties.scheme_reference=c}for(let c of Object.values(r.schemes)){let p=c;if(p.color??(p.color=si()),e=="pipeline"){p.pipeline??(p.pipeline=Zs()),(t=p.pipeline).development_funded??(t.development_funded=!1),(i=p.pipeline).construction_funded??(i.construction_funded=!1),(o=p.pipeline).funding_sources??(o.funding_sources=xn()),delete p.pipeline.budget_funded,delete p.pipeline.budget_unfunded,delete p.pipeline.funding_source,delete p.pipeline.funded;for(let m of r.features)m.properties.pipeline&&((s=m.properties.pipeline).development_funded??(s.development_funded=!1),(a=m.properties.pipeline).construction_funded??(a.construction_funded=!1),(l=m.properties.pipeline).funding_sources??(l.funding_sources=xn()),(u=m.properties.pipeline).status??(u.status=""),(f=m.properties.pipeline).timescale??(f.timescale=""))}}return r}function Ed(r){let e=r;return Et(Qe)=="pipeline"&&(e.pipeline=Zs()),e}function Zs(){return{scheme_type:"",atf4_lead_type:"",scheme_description:"",status:"",timescale:"",development_funded:!1,construction_funded:!1,funding_sources:xn()}}function xn(){return{atf2:!1,atf3:!1,atf4:!1,atf4e:!1,crsts:!1,luf:!1,other:""}}function Md(r){if(r.properties.name)return r.properties.name;var e=r.properties.intervention_type;return e=="other"&&(r.geometry.type=="Point"?e="point":r.geometry.type=="LineString"?e="line":e="polygon"),`Untitled ${e}`}function Qr(r){return r.scheme_name??"Untitled scheme"}function Pd(r){var t;let e=Et(Qe);if(!r.properties.name)return"No name";if(!new Set(["route","area","crossing","other"]).has(r.properties.intervention_type))return"No intervention type";if(e=="pipeline"&&!((t=r.properties.pipeline)!=null&&t.accuracy))return"Accuracy not specified";let n=Vs(r.properties);return Object.entries(n).length>0?`Extra GeoJSON properties: ${Object.keys(n).join(", ")}`:null}function Vs(r){let e=Et(Qe),n=JSON.parse(JSON.stringify(r));for(let t of["name","description","intervention_type","length_meters","waypoints","hide_while_editing","is_coverage_polygon","scheme_reference"])delete n[t];if(e=="pipeline"&&n.pipeline){for(let t of["atf4_type","accuracy","is_alternative","budget","development_funded","construction_funded","funding_sources","status","timescale","timescale_year","year_published","year_consulted"])delete n.pipeline[t];Object.entries(n.pipeline).length==0&&delete n.pipeline}return n}function Mo(r,e,n){const t=r.slice();return t[8]=e[n],t}function Ld(r){let e;return{c(){e=D("Delete all sketch data from browser")},m(n,t){y(n,e,t)},d(n){n&&w(e)}}}function Po(r){let e,n,t,i,o=Ie(r[1].storedStrings),s=[];for(let l=0;l$(s[l],1,1,()=>{s[l]=null});return{c(){e=q("p"),e.textContent=`Otherwise here is a breakdown of what is currently stored locally. You can - delete individual items (normally storage quota is 5MB or 10MB):`,n=R();for(let l=0;l{i=null}),le());const l={};a&2050&&(l.$$scope={dirty:a,ctx:r}),n.$set(l)},i(s){t||(_(i),_(n.$$.fragment,s),t=!0)},o(s){$(i),$(n.$$.fragment,s),t=!1},d(s){s&&w(e),i&&i.d(s),F(n,s)}}}function Cd(r){var p;let e,n=((p=r[1])==null?void 0:p.message)+"",t,i,o,s,a,l,u,f;a=new bt({props:{$$slots:{default:[Ld]},$$scope:{ctx:r}}}),a.$on("click",r[4]);let c=r[1]&&Po(r);return{c(){e=q("p"),t=D(n),i=R(),o=q("p"),o.textContent=`If you have saved your work locally to a geojson file recently, you can + to cancel`},m(n,t){y(n,e,t)},p:Q,d(n){n&&w(e)}}}function zp(r){let e,n,t,i,o,s,a,l,u,f,c;return e=new vl({}),e.$on("mousemove",r[3]),e.$on("click",r[4]),t=new Mt({props:{data:r[2],$$slots:{default:[Tp]},$$scope:{ctx:r}}}),s=new _t({props:{$$slots:{default:[Dp]},$$scope:{ctx:r}}}),s.$on("click",r[7]),l=new Rt({props:{$$slots:{default:[Up]},$$scope:{ctx:r}}}),{c(){P(e.$$.fragment),n=R(),P(t.$$.fragment),i=R(),o=q("div"),P(s.$$.fragment),a=R(),P(l.$$.fragment),ge(o,"float","right")},m(p,m){L(e,p,m),y(p,n,m),L(t,p,m),y(p,i,m),y(p,o,m),L(s,o,null),G(o,a),L(l,o,null),u=!0,f||(c=he(window,"keydown",r[5]),f=!0)},p(p,[m]){const g={};m&4&&(g.data=p[2]),m&4097&&(g.$$scope={dirty:m,ctx:p}),t.$set(g);const v={};m&4096&&(v.$$scope={dirty:m,ctx:p}),s.$set(v);const k={};m&4096&&(k.$$scope={dirty:m,ctx:p}),l.$set(k)},i(p){u||(b(e.$$.fragment,p),b(t.$$.fragment,p),b(s.$$.fragment,p),b(l.$$.fragment,p),u=!0)},o(p){$(e.$$.fragment,p),$(t.$$.fragment,p),$(s.$$.fragment,p),$(l.$$.fragment,p),u=!1},d(p){p&&(w(n),w(i),w(o)),C(e,p),C(t,p),C(s),C(l),f=!1,c()}}}const co=10,Jp=30;function Yp(r,e,n){let t,i=Q,o=()=>(i(),i=Ke(l,M=>n(9,t=M)),l),s;W(r,et,M=>n(10,s=M)),r.$$.on_destroy.push(()=>i());let{cfg:a}=e,{gjSchemes:l}=e;o(),it(()=>{s&&(s.getCanvas().style.cursor=`url(${Cs}), crosshair`)}),We(()=>{s&&(s.getCanvas().style.cursor="inherit")});let u=null,f=null,c=Jt();function p(M){if(!s)return;n(6,u=null),f=null;let _=v(M.detail.lngLat.toArray());const h=[M.detail.point.x-Jp,M.detail.point.y],E=s.unproject(M.detail.point).distanceTo(s.unproject(h))/1e3;let d=[];for(let[S,N]of t.features.entries())if(N.geometry.type=="LineString"){let j=Gp(N.geometry,_,{units:"kilometers"});j.properties.dist!=null&&j.properties.dist<=E&&d.push([S,j.geometry.coordinates,j.properties.dist])}d.sort((S,N)=>S[2]-N[2]),d.length>0&&(n(6,u=v(d[0][1])),f=d[0][0])}function m(){if(f==null){pe.set({mode:"list"});return}let M=wu(t.features[f],u);if(M!=null){let[_,h]=M;l.update(E=>(_.id=E.features[f].id,h.id=_n(E),E.features.splice(f,1,_,h),E))}n(6,u=null),f=null}function g(M){M.key=="Escape"&&(M.stopPropagation(),pe.set({mode:"list"}))}function v(M){return{type:"Feature",properties:{},geometry:{type:"Point",coordinates:zo(M)}}}const k=()=>pe.set({mode:"list"});return r.$$set=M=>{"cfg"in M&&n(0,a=M.cfg),"gjSchemes"in M&&o(n(1,l=M.gjSchemes))},r.$$.update=()=>{if(r.$$.dirty&64){let M=Jt();u&&M.features.push(u),n(2,c=M)}},[a,l,c,p,m,g,u,k]}class Xp extends re{constructor(e){super(),ie(this,e,Yp,zp,te,{cfg:0,gjSchemes:1})}}function Wp(r){let e,n;return e=new Rs({props:{finish:r[1],cancel:r[0]}}),{c(){P(e.$$.fragment)},m(t,i){L(e,t,i),n=!0},p:Q,i(t){n||(b(e.$$.fragment,t),n=!0)},o(t){$(e.$$.fragment,t),n=!1},d(t){C(e,t)}}}function Kp(r,e,n){let t,i;W(r,ot,f=>n(4,t=f)),W(r,Ge,f=>n(5,i=f));let{cfg:o}=e,{gjSchemes:s}=e;it(()=>{t.startArea(),t.addEventListenerSuccess(a),t.addEventListenerFailure(l)}),We(()=>{t.stop(),t.clearEventListeners()});function a(f){let c=f;c.properties={...c.properties,...i},s.update(p=>(c.id=_n(p),c.properties.scheme_reference=nr(p),o.newPolygonFeature(c),p.features.push(c),p)),pe.set({mode:"list"})}function l(){pe.set({mode:"list"})}function u(){t.finish()}return r.$$set=f=>{"cfg"in f&&n(2,o=f.cfg),"gjSchemes"in f&&n(3,s=f.gjSchemes)},[l,u,o,s]}class Hp extends re{constructor(e){super(),ie(this,e,Kp,Wp,te,{cfg:2,gjSchemes:3})}}function Zp(r){let e,n;return e=new Xe({props:{errorMessage:"Failed to load route snapper"}}),{c(){P(e.$$.fragment)},m(t,i){L(e,t,i),n=!0},p:Q,i(t){n||(b(e.$$.fragment,t),n=!0)},o(t){$(e.$$.fragment,t),n=!1},d(t){C(e,t)}}}function Vp(r){let e,n,t;return{c(){e=q("label"),e.textContent="Route data unpacking",n=R(),t=q("progress"),J(e,"for","route-unpacking"),J(t,"id","route-unpacking"),J(t,"class","svelte-q3473n")},m(i,o){y(i,e,o),y(i,n,o),y(i,t,o)},p:Q,i:Q,o:Q,d(i){i&&(w(e),w(n),w(t))}}}function Qp(r){let e,n,t;return{c(){e=q("label"),e.textContent="Route tool loading",n=R(),t=q("progress"),J(e,"for","route-loading"),J(t,"id","route-loading"),t.value=r[0],J(t,"class","svelte-q3473n")},m(i,o){y(i,e,o),y(i,n,o),y(i,t,o)},p(i,o){o&1&&(t.value=i[0])},i:Q,o:Q,d(i){i&&(w(e),w(n),w(t))}}}function xp(r){let e,n,t,i;const o=[Qp,Vp,Zp],s=[];function a(l,u){return!l[1]&&!l[2]&&!l[3]?0:l[3]&&!l[1]&&!l[2]?1:l[2]?2:-1}return~(e=a(r))&&(n=s[e]=o[e](r)),{c(){n&&n.c(),t=ce()},m(l,u){~e&&s[e].m(l,u),y(l,t,u),i=!0},p(l,[u]){let f=e;e=a(l),e===f?~e&&s[e].p(l,u):(n&&(se(),$(s[f],1,1,()=>{s[f]=null}),le()),~e?(n=s[e],n?n.p(l,u):(n=s[e]=o[e](l),n.c()),b(n,1),n.m(t.parentNode,t)):n=null)},i(l){i||(b(n),i=!0)},o(l){$(n),i=!1},d(l){l&&w(t),~e&&s[e].d(l)}}}function em(r,e,n){let t,{map:i}=e,{url:o}=e,s=0,a=!1,l=!1;return it(async()=>{await ys(),console.log(`Grabbing ${o}`);try{const u=await Mu(o,f=>{n(0,s=f)});ot.set(new Eu(i,u,Ps,Ls,Hr)),n(0,s=100),n(1,a=!0)}catch(u){console.log(`Route tool broke: ${u}`),n(2,l=!0)}}),r.$$set=u=>{"map"in u&&n(4,i=u.map),"url"in u&&n(5,o=u.url)},r.$$.update=()=>{r.$$.dirty&1&&n(3,t=s>=100)},[s,a,l,t,i,o]}class tm extends re{constructor(e){super(),ie(this,e,em,xp,te,{map:4,url:5})}}function nm(r){let e,n,t,i,o;const s=r[4].default,a=Kt(s,r,r[3],null);return{c(){e=q("button"),a&&a.c(),J(e,"type","button"),J(e,"class","govuk-button govuk-button--secondary svelte-11kph2l"),J(e,"data-module","govuk-button"),e.disabled=n=r[1]||r[2].mode!="list",ii(e,"focused",r[2]==r[0]),ge(e,"margin-bottom",r[2].mode=="list"?"0px":void 0)},m(l,u){y(l,e,u),a&&a.m(e,null),t=!0,i||(o=he(e,"click",r[5]),i=!0)},p(l,[u]){a&&a.p&&(!t||u&8)&&Ht(a,s,l,l[3],t?Vt(s,l[3],u,null):Zt(l[3]),null),(!t||u&6&&n!==(n=l[1]||l[2].mode!="list"))&&(e.disabled=n),(!t||u&5)&&ii(e,"focused",l[2]==l[0]),u&4&&ge(e,"margin-bottom",l[2].mode=="list"?"0px":void 0)},i(l){t||(b(a,l),t=!0)},o(l){$(a,l),t=!1},d(l){l&&w(e),a&&a.d(l),i=!1,o()}}}function rm(r,e,n){let t;W(r,pe,u=>n(2,t=u));let{$$slots:i={},$$scope:o}=e,{setMode:s}=e,{disabled:a=!1}=e;const l=()=>pe.set(s);return r.$$set=u=>{"setMode"in u&&n(0,s=u.setMode),"disabled"in u&&n(1,a=u.disabled),"$$scope"in u&&n(3,o=u.$$scope)},[s,a,t,o,i,l]}class wt extends re{constructor(e){super(),ie(this,e,rm,nm,te,{setMode:0,disabled:1})}}function po(r){let e,n;return e=new tm({props:{map:r[5],url:r[2]}}),{c(){P(e.$$.fragment)},m(t,i){L(e,t,i),n=!0},p(t,i){const o={};i&32&&(o.map=t[5]),i&4&&(o.url=t[2]),e.$set(o)},i(t){n||(b(e.$$.fragment,t),n=!0)},o(t){$(e.$$.fragment,t),n=!1},d(t){C(e,t)}}}function im(r){let e,n,t;return{c(){e=q("img"),t=z(` + New point`),st(e.src,n=Uf)||J(e,"src",n),J(e,"alt","New point")},m(i,o){y(i,e,o),y(i,t,o)},p:Q,d(i){i&&(w(e),w(t))}}}function om(r){let e,n,t;return{c(){e=q("img"),t=z(` + New route`),st(e.src,n=Yf)||J(e,"src",n),J(e,"alt","New route")},m(i,o){y(i,e,o),y(i,t,o)},p:Q,d(i){i&&(w(e),w(t))}}}function sm(r){let e,n,t;return{c(){e=q("img"),t=z(` + New polygon (freehand)`),st(e.src,n=zf)||J(e,"src",n),J(e,"alt","New polygon (freehand)")},m(i,o){y(i,e,o),y(i,t,o)},p:Q,d(i){i&&(w(e),w(t))}}}function lm(r){let e,n,t;return{c(){e=q("img"),t=z(` + New polygon (snapped)`),st(e.src,n=Jf)||J(e,"src",n),J(e,"alt","New polygon (snapped)")},m(i,o){y(i,e,o),y(i,t,o)},p:Q,d(i){i&&(w(e),w(t))}}}function am(r){let e,n,t;return{c(){e=q("img"),t=z(` + Split route`),st(e.src,n=Cs)||J(e,"src",n),J(e,"alt","Split route")},m(i,o){y(i,e,o),y(i,t,o)},p:Q,d(i){i&&(w(e),w(t))}}}function um(r){let e,n,t;return{c(){e=q("img"),t=z(` + Georeference image`),st(e.src,n=Df)||J(e,"src",n),J(e,"alt","Georeference image")},m(i,o){y(i,e,o),y(i,t,o)},p:Q,d(i){i&&(w(e),w(t))}}}function fm(r){let e,n,t;return{c(){e=q("img"),t=z(` + StreetView`),st(e.src,n=Xf)||J(e,"src",n),J(e,"alt","StreetView")},m(i,o){y(i,e,o),y(i,t,o)},p:Q,d(i){i&&(w(e),w(t))}}}function cm(r){let e,n;return e=new Tf({props:{cfg:r[0]}}),{c(){P(e.$$.fragment)},m(t,i){L(e,t,i),n=!0},p(t,i){const o={};i&1&&(o.cfg=t[0]),e.$set(o)},i(t){n||(b(e.$$.fragment,t),n=!0)},o(t){$(e.$$.fragment,t),n=!1},d(t){C(e,t)}}}function pm(r){let e,n;return e=new Xc({}),{c(){P(e.$$.fragment)},m(t,i){L(e,t,i),n=!0},p:Q,i(t){n||(b(e.$$.fragment,t),n=!0)},o(t){$(e.$$.fragment,t),n=!1},d(t){C(e,t)}}}function mm(r){let e,n;return e=new Xp({props:{cfg:r[0],gjSchemes:r[1]}}),{c(){P(e.$$.fragment)},m(t,i){L(e,t,i),n=!0},p(t,i){const o={};i&1&&(o.cfg=t[0]),i&2&&(o.gjSchemes=t[1]),e.$set(o)},i(t){n||(b(e.$$.fragment,t),n=!0)},o(t){$(e.$$.fragment,t),n=!1},d(t){C(e,t)}}}function dm(r){let e,n;return e=new Hp({props:{cfg:r[0],gjSchemes:r[1]}}),{c(){P(e.$$.fragment)},m(t,i){L(e,t,i),n=!0},p(t,i){const o={};i&1&&(o.cfg=t[0]),i&2&&(o.gjSchemes=t[1]),e.$set(o)},i(t){n||(b(e.$$.fragment,t),n=!0)},o(t){$(e.$$.fragment,t),n=!1},d(t){C(e,t)}}}function gm(r){let e,n;return e=new Qc({props:{cfg:r[0],gjSchemes:r[1]}}),{c(){P(e.$$.fragment)},m(t,i){L(e,t,i),n=!0},p(t,i){const o={};i&1&&(o.cfg=t[0]),i&2&&(o.gjSchemes=t[1]),e.$set(o)},i(t){n||(b(e.$$.fragment,t),n=!0)},o(t){$(e.$$.fragment,t),n=!1},d(t){C(e,t)}}}function hm(r){let e,n;return e=new tp({props:{cfg:r[0],gjSchemes:r[1]}}),{c(){P(e.$$.fragment)},m(t,i){L(e,t,i),n=!0},p(t,i){const o={};i&1&&(o.cfg=t[0]),i&2&&(o.gjSchemes=t[1]),e.$set(o)},i(t){n||(b(e.$$.fragment,t),n=!0)},o(t){$(e.$$.fragment,t),n=!1},d(t){C(e,t)}}}function _m(r){let e,n;return e=new Hc({props:{cfg:r[0],gjSchemes:r[1]}}),{c(){P(e.$$.fragment)},m(t,i){L(e,t,i),n=!0},p(t,i){const o={};i&1&&(o.cfg=t[0]),i&2&&(o.gjSchemes=t[1]),e.$set(o)},i(t){n||(b(e.$$.fragment,t),n=!0)},o(t){$(e.$$.fragment,t),n=!1},d(t){C(e,t)}}}function bm(r){let e,n;return e=new qc({props:{cfg:r[0],gjSchemes:r[1],id:r[7].id}}),{c(){P(e.$$.fragment)},m(t,i){L(e,t,i),n=!0},p(t,i){const o={};i&1&&(o.cfg=t[0]),i&2&&(o.gjSchemes=t[1]),i&128&&(o.id=t[7].id),e.$set(o)},i(t){n||(b(e.$$.fragment,t),n=!0)},o(t){$(e.$$.fragment,t),n=!1},d(t){C(e,t)}}}function vm(r){let e,n,t,i,o,s,a,l,u,f,c,p,m,g,v,k,M,_,h,E,d,S,N;e=new ff({props:{cfg:r[0],gjSchemes:r[1]}});let j=r[5]&&po(r);a=new wt({props:{setMode:{mode:"new-point"},disabled:!r[4],$$slots:{default:[im]},$$scope:{ctx:r}}}),u=new wt({props:{setMode:{mode:"new-route"},disabled:!r[6],$$slots:{default:[om]},$$scope:{ctx:r}}}),c=new wt({props:{setMode:{mode:"new-freehand-polygon"},disabled:!r[3],$$slots:{default:[sm]},$$scope:{ctx:r}}}),m=new wt({props:{setMode:{mode:"new-snapped-polygon"},disabled:!r[6],$$slots:{default:[lm]},$$scope:{ctx:r}}}),v=new wt({props:{setMode:{mode:"split-route"},$$slots:{default:[am]},$$scope:{ctx:r}}}),M=new wt({props:{setMode:{mode:"set-image"},$$slots:{default:[um]},$$scope:{ctx:r}}}),h=new wt({props:{setMode:{mode:"streetview"},$$slots:{default:[fm]},$$scope:{ctx:r}}});const U=[bm,_m,hm,gm,dm,mm,pm,cm],B=[];function O(F,A){return F[7].mode=="edit"?0:F[7].mode=="new-point"?1:F[7].mode=="new-route"?2:F[7].mode=="new-freehand-polygon"?3:F[7].mode=="new-snapped-polygon"?4:F[7].mode=="split-route"?5:F[7].mode=="set-image"?6:F[7].mode=="streetview"?7:-1}return~(d=O(r))&&(S=B[d]=U[d](r)),{c(){P(e.$$.fragment),n=R(),t=q("div"),i=q("div"),j&&j.c(),o=R(),s=q("div"),P(a.$$.fragment),l=R(),P(u.$$.fragment),f=R(),P(c.$$.fragment),p=R(),P(m.$$.fragment),g=R(),P(v.$$.fragment),k=R(),P(M.$$.fragment),_=R(),P(h.$$.fragment),E=R(),S&&S.c(),ge(i,"visibility",r[7].mode=="list"?"visible":"hidden"),J(s,"class","toolbar svelte-ovanu5"),J(t,"class","top govuk-prose svelte-ovanu5")},m(F,A){L(e,F,A),y(F,n,A),y(F,t,A),G(t,i),j&&j.m(i,null),G(t,o),G(t,s),L(a,s,null),G(s,l),L(u,s,null),G(s,f),L(c,s,null),G(s,p),L(m,s,null),G(s,g),L(v,s,null),G(s,k),L(M,s,null),G(s,_),L(h,s,null),G(t,E),~d&&B[d].m(t,null),N=!0},p(F,[A]){const I={};A&1&&(I.cfg=F[0]),A&2&&(I.gjSchemes=F[1]),e.$set(I),F[5]?j?(j.p(F,A),A&32&&b(j,1)):(j=po(F),j.c(),b(j,1),j.m(i,null)):j&&(se(),$(j,1,1,()=>{j=null}),le()),A&128&&ge(i,"visibility",F[7].mode=="list"?"visible":"hidden");const K={};A&16&&(K.disabled=!F[4]),A&256&&(K.$$scope={dirty:A,ctx:F}),a.$set(K);const T={};A&64&&(T.disabled=!F[6]),A&256&&(T.$$scope={dirty:A,ctx:F}),u.$set(T);const ee={};A&8&&(ee.disabled=!F[3]),A&256&&(ee.$$scope={dirty:A,ctx:F}),c.$set(ee);const D={};A&64&&(D.disabled=!F[6]),A&256&&(D.$$scope={dirty:A,ctx:F}),m.$set(D);const fe={};A&256&&(fe.$$scope={dirty:A,ctx:F}),v.$set(fe);const me={};A&256&&(me.$$scope={dirty:A,ctx:F}),M.$set(me);const ve={};A&256&&(ve.$$scope={dirty:A,ctx:F}),h.$set(ve);let $e=d;d=O(F),d===$e?~d&&B[d].p(F,A):(S&&(se(),$(B[$e],1,1,()=>{B[$e]=null}),le()),~d?(S=B[d],S?S.p(F,A):(S=B[d]=U[d](F),S.c()),b(S,1),S.m(t,null)):S=null)},i(F){N||(b(e.$$.fragment,F),b(j),b(a.$$.fragment,F),b(u.$$.fragment,F),b(c.$$.fragment,F),b(m.$$.fragment,F),b(v.$$.fragment,F),b(M.$$.fragment,F),b(h.$$.fragment,F),b(S),N=!0)},o(F){$(e.$$.fragment,F),$(j),$(a.$$.fragment,F),$(u.$$.fragment,F),$(c.$$.fragment,F),$(m.$$.fragment,F),$(v.$$.fragment,F),$(M.$$.fragment,F),$(h.$$.fragment,F),$(S),N=!1},d(F){F&&(w(n),w(t)),C(e,F),j&&j.d(),C(a),C(u),C(c),C(m),C(v),C(M),C(h),~d&&B[d].d()}}}function $m(r,e,n){let t,i,o,s,a;W(r,ot,c=>n(6,t=c)),W(r,pn,c=>n(3,i=c)),W(r,In,c=>n(4,o=c)),W(r,et,c=>n(5,s=c)),W(r,pe,c=>n(7,a=c));let{cfg:l}=e,{gjSchemes:u}=e,{routeSnapperUrl:f}=e;return We(()=>{o==null||o.tearDown(),i==null||i.tearDown(),t==null||t.tearDown()}),r.$$set=c=>{"cfg"in c&&n(0,l=c.cfg),"gjSchemes"in c&&n(1,u=c.gjSchemes),"routeSnapperUrl"in c&&n(2,f=c.routeSnapperUrl)},r.$$.update=()=>{r.$$.dirty&48&&s&&!o&&In.set(new Pa(s)),r.$$.dirty&40&&s&&!i&&pn.set(new iu(s))},[l,u,f,i,o,s,t,a]}class ym extends re{constructor(e){super(),ie(this,e,$m,vm,te,{cfg:0,gjSchemes:1,routeSnapperUrl:2})}}const wm="/atip/move_draw_controls/assets/delete-3c023172.svg",km="/atip/move_draw_controls/assets/save-74d8f3c2.svg";function mo(r){let e,n;return e=new _e({props:{disabled:!r[2],$$slots:{default:[Sm]},$$scope:{ctx:r}}}),e.$on("click",r[7]),{c(){P(e.$$.fragment)},m(t,i){L(e,t,i),n=!0},p(t,i){const o={};i&4&&(o.disabled=!t[2]),i&4096&&(o.$$scope={dirty:i,ctx:t}),e.$set(o)},i(t){n||(b(e.$$.fragment,t),n=!0)},o(t){$(e.$$.fragment,t),n=!1},d(t){C(e,t)}}}function Sm(r){let e;return{c(){e=z("Auto-fill")},m(n,t){y(n,e,t)},d(n){n&&w(e)}}}function Em(r){let e,n,t,i,o,s,a=r[0].length_meters&&mo(r);return{c(){e=q("input"),n=R(),a&&a.c(),t=ce(),J(e,"type","text"),J(e,"class","govuk-input"),J(e,"id",r[5])},m(l,u){y(l,e,u),Le(e,r[0].name),y(l,n,u),a&&a.m(l,u),y(l,t,u),i=!0,o||(s=he(e,"input",r[6]),o=!0)},p(l,u){u&1&&e.value!==l[0].name&&Le(e,l[0].name),l[0].length_meters?a?(a.p(l,u),u&1&&b(a,1)):(a=mo(l),a.c(),b(a,1),a.m(t.parentNode,t)):a&&(se(),$(a,1,1,()=>{a=null}),le())},i(l){i||(b(a),i=!0)},o(l){$(a),i=!1},d(l){l&&(w(e),w(n),w(t)),a&&a.d(l),o=!1,s()}}}function go(r){let e,n,t=qn(r[0].length_meters)+"",i;return{c(){e=q("p"),n=z("Length: "),i=z(t)},m(o,s){y(o,e,s),G(e,n),G(e,i)},p(o,s){s&1&&t!==(t=qn(o[0].length_meters)+"")&&be(i,t)},d(o){o&&w(e)}}}function Mm(r){let e,n,t,i,o,s,a,l,u,f,c,p,m;e=new Ft({props:{label:"Name",id:r[5],$$slots:{default:[Em]},$$scope:{ctx:r}}});function g(d){r[9](d)}let v={label:"Scheme",choices:Object.values(r[3].schemes).map(r[8])};r[0].scheme_reference!==void 0&&(v.value=r[0].scheme_reference),t=new rr({props:v}),V.push(()=>x(t,"value",g));function k(d){r[10](d)}let M={label:"Type",choices:[["area","Area"],["route","Route"],["crossing","Crossing"],["other","Other"]],inlineSmall:!0,required:!0};r[0].intervention_type!==void 0&&(M.value=r[0].intervention_type),s=new Pt({props:M}),V.push(()=>x(s,"value",k));function _(d){r[11](d)}let h={label:"Description"};r[0].description!==void 0&&(h.value=r[0].description),u=new Dr({props:h}),V.push(()=>x(u,"value",_));let E=r[0].length_meters&&go(r);return{c(){P(e.$$.fragment),n=R(),P(t.$$.fragment),o=R(),P(s.$$.fragment),l=R(),P(u.$$.fragment),c=R(),E&&E.c(),p=ce()},m(d,S){L(e,d,S),y(d,n,S),L(t,d,S),y(d,o,S),L(s,d,S),y(d,l,S),L(u,d,S),y(d,c,S),E&&E.m(d,S),y(d,p,S),m=!0},p(d,[S]){const N={};S&4101&&(N.$$scope={dirty:S,ctx:d}),e.$set(N);const j={};S&8&&(j.choices=Object.values(d[3].schemes).map(d[8])),!i&&S&1&&(i=!0,j.value=d[0].scheme_reference,ne(()=>i=!1)),t.$set(j);const U={};!a&&S&1&&(a=!0,U.value=d[0].intervention_type,ne(()=>a=!1)),s.$set(U);const B={};!f&&S&1&&(f=!0,B.value=d[0].description,ne(()=>f=!1)),u.$set(B),d[0].length_meters?E?E.p(d,S):(E=go(d),E.c(),E.m(p.parentNode,p)):E&&(E.d(1),E=null)},i(d){m||(b(e.$$.fragment,d),b(t.$$.fragment,d),b(s.$$.fragment,d),b(u.$$.fragment,d),m=!0)},o(d){$(e.$$.fragment,d),$(t.$$.fragment,d),$(s.$$.fragment,d),$(u.$$.fragment,d),m=!1},d(d){d&&(w(n),w(o),w(l),w(c),w(p)),C(e,d),C(t,d),C(s,d),C(u,d),E&&E.d(d)}}}function Pm(r,e,n){let t,i,o=Q,s=()=>(o(),o=Ke(a,M=>n(3,i=M)),a);W(r,ot,M=>n(2,t=M)),r.$$.on_destroy.push(()=>o());let{gjSchemes:a}=e;s();let{props:l}=e;function u(){try{n(0,l.name=t.inner.routeNameForWaypoints(l.waypoints),l)}catch(M){window.alert(`Couldn't auto-name route: ${M}`)}}let f=At();function c(){l.name=this.value,n(0,l)}const p=()=>u(),m=M=>[M.scheme_reference,Qr(M)];function g(M){r.$$.not_equal(l.scheme_reference,M)&&(l.scheme_reference=M,n(0,l))}function v(M){r.$$.not_equal(l.intervention_type,M)&&(l.intervention_type=M,n(0,l))}function k(M){r.$$.not_equal(l.description,M)&&(l.description=M,n(0,l))}return r.$$set=M=>{"gjSchemes"in M&&s(n(1,a=M.gjSchemes)),"props"in M&&n(0,l=M.props)},[l,a,t,i,u,f,c,p,m,g,v,k]}class Lm extends re{constructor(e){super(),ie(this,e,Pm,Mm,te,{gjSchemes:1,props:0})}}function Cm(r){let e,n,t;function i(s){r[2](s)}let o={label:r[1],choices:[lt("New segregated cycling facility"),lt("New junction treatment"),lt("New permanent footway"),["New shared use facilities","New shared use (walking and cycling) facilities"],["Improvements to existing route","Improvements to make an existing walking/cycle route safer"],["Area-wide traffic management","Area-wide traffic management (including by TROs - both permanent and experimental)"],["Bus priority measures","Bus priority measures that also enable active travel (for example, bus gates)"],["Secure cycle parking","Provision of secure cycle parking facilities"],lt("New road crossings"),lt("Restriction or reduction of car parking availability"),lt("School streets"),lt("Quiet mixed traffic streets"),lt("Traffic free routes"),lt("Not specified in LCWIP")],emptyOption:!0};return r[0]!==void 0&&(o.value=r[0]),e=new rr({props:o}),V.push(()=>x(e,"value",i)),{c(){P(e.$$.fragment)},m(s,a){L(e,s,a),t=!0},p(s,[a]){const l={};a&2&&(l.label=s[1]),!n&&a&1&&(n=!0,l.value=s[0],ne(()=>n=!1)),e.$set(l)},i(s){t||(b(e.$$.fragment,s),t=!0)},o(s){$(e.$$.fragment,s),t=!1},d(s){C(e,s)}}}function lt(r){return[r,r]}function Fm(r,e,n){let{label:t}=e,{value:i}=e;function o(s){i=s,n(0,i)}return r.$$set=s=>{"label"in s&&n(1,t=s.label),"value"in s&&n(0,i=s.value)},[i,t,o]}class Ws extends re{constructor(e){super(),ie(this,e,Fm,Cm,te,{label:1,value:0})}}function Am(r){let e,n,t,i,o,s,a,l,u,f,c,p,m,g,v,k,M,_;function h(A){r[3](A)}let E={label:"Status",choices:[["","Unknown"],["aspiration","Aspiration"],["planned","Planned"],["in development","In development"],["in construction","In construction"],["completed","Completed"]],inlineSmall:!0,required:r[1]};r[0].status!==void 0&&(E.value=r[0].status),i=new Pt({props:E}),V.push(()=>x(i,"value",h));function d(A){r[4](A)}let S={label:"Timescale",choices:[["","Unknown"],["short","Short (1-3 years)"],["medium","Medium (3-6 years)"],["long","Long (6-10 years)"]],inlineSmall:!0,required:r[1]};r[0].timescale!==void 0&&(S.value=r[0].timescale),a=new Pt({props:S}),V.push(()=>x(a,"value",d));function N(A){r[5](A)}let j={label:"Estimated completion year (if known)",width:4,min:2010,max:2100};r[0].timescale_year!==void 0&&(j.value=r[0].timescale_year),f=new sr({props:j}),V.push(()=>x(f,"value",N));function U(A){r[6](A)}let B={label:"What year was this scheme most recently published?",width:4,min:2010,max:2100};r[0].year_published!==void 0&&(B.value=r[0].year_published),m=new sr({props:B}),V.push(()=>x(m,"value",U));function O(A){r[7](A)}let F={label:"What year was this scheme most recently consulted on?",width:4,min:2010,max:2100};return r[0].year_consulted!==void 0&&(F.value=r[0].year_consulted),k=new sr({props:F}),V.push(()=>x(k,"value",O)),{c(){e=q("fieldset"),n=q("legend"),n.textContent="Timing and status",t=R(),P(i.$$.fragment),s=R(),P(a.$$.fragment),u=R(),P(f.$$.fragment),p=R(),P(m.$$.fragment),v=R(),P(k.$$.fragment),J(n,"class","govuk-fieldset__legend"),J(e,"class","govuk-fieldset svelte-1bxyfcq")},m(A,I){y(A,e,I),G(e,n),G(e,t),L(i,e,null),G(e,s),L(a,e,null),G(e,u),L(f,e,null),G(e,p),L(m,e,null),G(e,v),L(k,e,null),_=!0},p(A,[I]){const K={};I&2&&(K.required=A[1]),!o&&I&1&&(o=!0,K.value=A[0].status,ne(()=>o=!1)),i.$set(K);const T={};I&2&&(T.required=A[1]),!l&&I&1&&(l=!0,T.value=A[0].timescale,ne(()=>l=!1)),a.$set(T);const ee={};!c&&I&1&&(c=!0,ee.value=A[0].timescale_year,ne(()=>c=!1)),f.$set(ee);const D={};!g&&I&1&&(g=!0,D.value=A[0].year_published,ne(()=>g=!1)),m.$set(D);const fe={};!M&&I&1&&(M=!0,fe.value=A[0].year_consulted,ne(()=>M=!1)),k.$set(fe)},i(A){_||(b(i.$$.fragment,A),b(a.$$.fragment,A),b(f.$$.fragment,A),b(m.$$.fragment,A),b(k.$$.fragment,A),_=!0)},o(A){$(i.$$.fragment,A),$(a.$$.fragment,A),$(f.$$.fragment,A),$(m.$$.fragment,A),$(k.$$.fragment,A),_=!1},d(A){A&&w(e),C(i),C(a),C(f),C(m),C(k)}}}function Nm(r,e,n){let{data:t}=e,{required:i}=e,{onUpdate:o}=e;function s(p){o()}function a(p){r.$$.not_equal(t.status,p)&&(t.status=p,n(0,t))}function l(p){r.$$.not_equal(t.timescale,p)&&(t.timescale=p,n(0,t))}function u(p){r.$$.not_equal(t.timescale_year,p)&&(t.timescale_year=p,n(0,t))}function f(p){r.$$.not_equal(t.year_published,p)&&(t.year_published=p,n(0,t))}function c(p){r.$$.not_equal(t.year_consulted,p)&&(t.year_consulted=p,n(0,t))}return r.$$set=p=>{"data"in p&&n(0,t=p.data),"required"in p&&n(1,i=p.required),"onUpdate"in p&&n(2,o=p.onUpdate)},r.$$.update=()=>{r.$$.dirty&1&&s()},[t,i,o,a,l,u,f,c]}class Ks extends re{constructor(e){super(),ie(this,e,Nm,Am,te,{data:0,required:1,onUpdate:2})}}function ho(r,e,n){const t=r.slice();return t[9]=e[n],t[10]=e,t[11]=n,t}function Rm(r){let e;return{c(){e=z("Is the development fully funded?")},m(n,t){y(n,e,t)},d(n){n&&w(e)}}}function Om(r){let e;return{c(){e=z("Is the construction fully funded?")},m(n,t){y(n,e,t)},d(n){n&&w(e)}}}function jm(r){let e,n,t;function i(s){r[6](s,r[9])}let o={$$slots:{default:[Im]},$$scope:{ctx:r}};return r[0].funding_sources[r[9]]!==void 0&&(o.checked=r[0].funding_sources[r[9]]),e=new Ct({props:o}),V.push(()=>x(e,"checked",i)),{c(){P(e.$$.fragment)},m(s,a){L(e,s,a),t=!0},p(s,a){r=s;const l={};a&4096&&(l.$$scope={dirty:a,ctx:r}),!n&&a&3&&(n=!0,l.checked=r[0].funding_sources[r[9]],ne(()=>n=!1)),e.$set(l)},i(s){t||(b(e.$$.fragment,s),t=!0)},o(s){$(e.$$.fragment,s),t=!1},d(s){C(e,s)}}}function Im(r){let e=r[9].toUpperCase()+"",n,t;return{c(){n=z(e),t=R()},m(i,o){y(i,n,o),y(i,t,o)},p:Q,d(i){i&&(w(n),w(t))}}}function _o(r){let e,n,t=r[9]!="other"&&jm(r);return{c(){t&&t.c(),e=ce()},m(i,o){t&&t.m(i,o),y(i,e,o),n=!0},p(i,o){i[9]!="other"&&t.p(i,o)},i(i){n||(b(t),n=!0)},o(i){$(t),n=!1},d(i){i&&w(e),t&&t.d(i)}}}function Bm(r){let e,n,t=Ie(r[1]),i=[];for(let s=0;s$(i[s],1,1,()=>{i[s]=null});return{c(){for(let s=0;sx(i,"value",E));function S(F){r[4](F)}let N={$$slots:{default:[Rm]},$$scope:{ctx:r}};r[0].development_funded!==void 0&&(N.checked=r[0].development_funded),a=new Ct({props:N}),V.push(()=>x(a,"checked",S));function j(F){r[5](F)}let U={$$slots:{default:[Om]},$$scope:{ctx:r}};r[0].construction_funded!==void 0&&(U.checked=r[0].construction_funded),f=new Ct({props:U}),V.push(()=>x(f,"checked",j)),v=new Ko({props:{$$slots:{default:[Bm]},$$scope:{ctx:r}}});function B(F){r[7](F)}let O={label:"Other funding sources"};return r[0].funding_sources.other!==void 0&&(O.value=r[0].funding_sources.other),M=new ir({props:O}),V.push(()=>x(M,"value",B)),{c(){e=q("fieldset"),n=q("legend"),n.textContent="Budget",t=R(),P(i.$$.fragment),s=R(),P(a.$$.fragment),u=R(),P(f.$$.fragment),p=R(),m=q("p"),m.textContent="Funding sources",g=R(),P(v.$$.fragment),k=R(),P(M.$$.fragment),J(n,"class","govuk-fieldset__legend"),J(e,"class","govuk-fieldset svelte-1bxyfcq")},m(F,A){y(F,e,A),G(e,n),G(e,t),L(i,e,null),G(e,s),L(a,e,null),G(e,u),L(f,e,null),G(e,p),G(e,m),G(e,g),L(v,e,null),G(e,k),L(M,e,null),h=!0},p(F,[A]){const I={};!o&&A&1&&(o=!0,I.value=F[0].budget,ne(()=>o=!1)),i.$set(I);const K={};A&4096&&(K.$$scope={dirty:A,ctx:F}),!l&&A&1&&(l=!0,K.checked=F[0].development_funded,ne(()=>l=!1)),a.$set(K);const T={};A&4096&&(T.$$scope={dirty:A,ctx:F}),!c&&A&1&&(c=!0,T.checked=F[0].construction_funded,ne(()=>c=!1)),f.$set(T);const ee={};A&4097&&(ee.$$scope={dirty:A,ctx:F}),v.$set(ee);const D={};!_&&A&1&&(_=!0,D.value=F[0].funding_sources.other,ne(()=>_=!1)),M.$set(D)},i(F){h||(b(i.$$.fragment,F),b(a.$$.fragment,F),b(f.$$.fragment,F),b(v.$$.fragment,F),b(M.$$.fragment,F),h=!0)},o(F){$(i.$$.fragment,F),$(a.$$.fragment,F),$(f.$$.fragment,F),$(v.$$.fragment,F),$(M.$$.fragment,F),h=!1},d(F){F&&w(e),C(i),C(a),C(f),C(v),C(M)}}}function Gm(r,e,n){let{data:t}=e,{onUpdate:i}=e;function o(p){i()}let s=["atf2","atf3","atf4","atf4e","crsts","luf"];function a(p){r.$$.not_equal(t.budget,p)&&(t.budget=p,n(0,t))}function l(p){r.$$.not_equal(t.development_funded,p)&&(t.development_funded=p,n(0,t))}function u(p){r.$$.not_equal(t.construction_funded,p)&&(t.construction_funded=p,n(0,t))}function f(p,m){r.$$.not_equal(t.funding_sources[m],p)&&(t.funding_sources[m]=p,n(0,t))}function c(p){r.$$.not_equal(t.funding_sources.other,p)&&(t.funding_sources.other=p,n(0,t))}return r.$$set=p=>{"data"in p&&n(0,t=p.data),"onUpdate"in p&&n(2,i=p.onUpdate)},r.$$.update=()=>{r.$$.dirty&1&&o()},[t,s,i,a,l,u,f,c]}class Hs extends re{constructor(e){super(),ie(this,e,Gm,qm,te,{data:0,onUpdate:2})}}function bo(r){let e,n;return e=new _e({props:{disabled:!r[2],$$slots:{default:[Tm]},$$scope:{ctx:r}}}),e.$on("click",r[8]),{c(){P(e.$$.fragment)},m(t,i){L(e,t,i),n=!0},p(t,i){const o={};i&4&&(o.disabled=!t[2]),i&65536&&(o.$$scope={dirty:i,ctx:t}),e.$set(o)},i(t){n||(b(e.$$.fragment,t),n=!0)},o(t){$(e.$$.fragment,t),n=!1},d(t){C(e,t)}}}function Tm(r){let e;return{c(){e=z("Auto-fill with street names")},m(n,t){y(n,e,t)},d(n){n&&w(e)}}}function Dm(r){let e,n,t,i,o,s,a,l,u=r[0].length_meters&&bo(r);return{c(){e=q("div"),e.textContent="Use the name from the LCWIP if possible",n=R(),t=q("input"),i=R(),u&&u.c(),o=ce(),J(e,"class","govuk-hint"),J(t,"type","text"),J(t,"class","govuk-input"),J(t,"id",r[6])},m(f,c){y(f,e,c),y(f,n,c),y(f,t,c),Le(t,r[0].name),y(f,i,c),u&&u.m(f,c),y(f,o,c),s=!0,a||(l=he(t,"input",r[7]),a=!0)},p(f,c){c&1&&t.value!==f[0].name&&Le(t,f[0].name),f[0].length_meters?u?(u.p(f,c),c&1&&b(u,1)):(u=bo(f),u.c(),b(u,1),u.m(o.parentNode,o)):u&&(se(),$(u,1,1,()=>{u=null}),le())},i(f){s||(b(u),s=!0)},o(f){$(u),s=!1},d(f){f&&(w(e),w(n),w(t),w(i),w(o)),u&&u.d(f),a=!1,l()}}}function vo(r){let e,n,t=qn(r[0].length_meters)+"",i;return{c(){e=q("p"),n=z("Length: "),i=z(t)},m(o,s){y(o,e,s),G(e,n),G(e,i)},p(o,s){s&1&&t!==(t=qn(o[0].length_meters)+"")&&be(i,t)},d(o){o&&w(e)}}}function $o(r){let e,n,t,i,o,s,a,l,u,f,c,p,m,g;function v(S){r[12](S)}let k={label:"Type"};r[0].pipeline.atf4_type!==void 0&&(k.value=r[0].pipeline.atf4_type),e=new Ws({props:k}),V.push(()=>x(e,"value",v));function M(S){r[13](S)}let _={label:"Accuracy of mapped data",choices:[["high","High"],["medium","Medium"],["low","Low"]],required:!0,inlineSmall:!0};r[0].pipeline.accuracy!==void 0&&(_.value=r[0].pipeline.accuracy),i=new Pt({props:_}),V.push(()=>x(i,"value",M));function h(S){r[14](S)}let E={$$slots:{default:[Um]},$$scope:{ctx:r}};r[0].pipeline.is_alternative!==void 0&&(E.checked=r[0].pipeline.is_alternative),a=new Ct({props:E}),V.push(()=>x(a,"checked",h));let d=r[4]&&r[0].is_coverage_polygon!==void 0&&yo(r);return c=new Ks({props:{data:r[0].pipeline,required:!1,onUpdate:Ym}}),m=new Hs({props:{data:r[0].pipeline,onUpdate:Xm}}),{c(){P(e.$$.fragment),t=R(),P(i.$$.fragment),s=R(),P(a.$$.fragment),u=R(),d&&d.c(),f=R(),P(c.$$.fragment),p=R(),P(m.$$.fragment)},m(S,N){L(e,S,N),y(S,t,N),L(i,S,N),y(S,s,N),L(a,S,N),y(S,u,N),d&&d.m(S,N),y(S,f,N),L(c,S,N),y(S,p,N),L(m,S,N),g=!0},p(S,N){const j={};!n&&N&1&&(n=!0,j.value=S[0].pipeline.atf4_type,ne(()=>n=!1)),e.$set(j);const U={};!o&&N&1&&(o=!0,U.value=S[0].pipeline.accuracy,ne(()=>o=!1)),i.$set(U);const B={};N&65536&&(B.$$scope={dirty:N,ctx:S}),!l&&N&1&&(l=!0,B.checked=S[0].pipeline.is_alternative,ne(()=>l=!1)),a.$set(B),S[4]&&S[0].is_coverage_polygon!==void 0?d?(d.p(S,N),N&1&&b(d,1)):(d=yo(S),d.c(),b(d,1),d.m(f.parentNode,f)):d&&(se(),$(d,1,1,()=>{d=null}),le());const O={};N&1&&(O.data=S[0].pipeline),c.$set(O);const F={};N&1&&(F.data=S[0].pipeline),m.$set(F)},i(S){g||(b(e.$$.fragment,S),b(i.$$.fragment,S),b(a.$$.fragment,S),b(d),b(c.$$.fragment,S),b(m.$$.fragment,S),g=!0)},o(S){$(e.$$.fragment,S),$(i.$$.fragment,S),$(a.$$.fragment,S),$(d),$(c.$$.fragment,S),$(m.$$.fragment,S),g=!1},d(S){S&&(w(t),w(s),w(u),w(f),w(p)),C(e,S),C(i,S),C(a,S),d&&d.d(S),C(c,S),C(m,S)}}}function Um(r){let e;return{c(){e=z("Is this an alternative route and not the default option?")},m(n,t){y(n,e,t)},d(n){n&&w(e)}}}function yo(r){let e,n,t;function i(s){r[15](s)}let o={$$slots:{default:[zm]},$$scope:{ctx:r}};return r[0].is_coverage_polygon!==void 0&&(o.checked=r[0].is_coverage_polygon),e=new Ct({props:o}),V.push(()=>x(e,"checked",i)),{c(){P(e.$$.fragment)},m(s,a){L(e,s,a),t=!0},p(s,a){const l={};a&65536&&(l.$$scope={dirty:a,ctx:s}),!n&&a&1&&(n=!0,l.checked=s[0].is_coverage_polygon,ne(()=>n=!1)),e.$set(l)},i(s){t||(b(e.$$.fragment,s),t=!0)},o(s){$(e.$$.fragment,s),t=!1},d(s){C(e,s)}}}function zm(r){let e;return{c(){e=z(`Does this polygon show the coverage of the scheme? (All area considered + while making the scheme)`)},m(n,t){y(n,e,t)},d(n){n&&w(e)}}}function Jm(r){let e,n,t,i,o,s,a,l,u,f,c;e=new Ft({props:{label:"Name",id:r[6],$$slots:{default:[Dm]},$$scope:{ctx:r}}});function p(_){r[10](_)}let m={label:"Scheme",choices:Object.values(r[3].schemes).map(r[9])};r[0].scheme_reference!==void 0&&(m.value=r[0].scheme_reference),t=new rr({props:m}),V.push(()=>x(t,"value",p));function g(_){r[11](_)}let v={label:"Description"};r[0].description!==void 0&&(v.value=r[0].description),s=new Dr({props:v}),V.push(()=>x(s,"value",g));let k=r[0].length_meters&&vo(r),M=r[0].pipeline&&$o(r);return{c(){P(e.$$.fragment),n=R(),P(t.$$.fragment),o=R(),P(s.$$.fragment),l=R(),k&&k.c(),u=R(),M&&M.c(),f=ce()},m(_,h){L(e,_,h),y(_,n,h),L(t,_,h),y(_,o,h),L(s,_,h),y(_,l,h),k&&k.m(_,h),y(_,u,h),M&&M.m(_,h),y(_,f,h),c=!0},p(_,[h]){const E={};h&65541&&(E.$$scope={dirty:h,ctx:_}),e.$set(E);const d={};h&8&&(d.choices=Object.values(_[3].schemes).map(_[9])),!i&&h&1&&(i=!0,d.value=_[0].scheme_reference,ne(()=>i=!1)),t.$set(d);const S={};!a&&h&1&&(a=!0,S.value=_[0].description,ne(()=>a=!1)),s.$set(S),_[0].length_meters?k?k.p(_,h):(k=vo(_),k.c(),k.m(u.parentNode,u)):k&&(k.d(1),k=null),_[0].pipeline?M?(M.p(_,h),h&1&&b(M,1)):(M=$o(_),M.c(),b(M,1),M.m(f.parentNode,f)):M&&(se(),$(M,1,1,()=>{M=null}),le())},i(_){c||(b(e.$$.fragment,_),b(t.$$.fragment,_),b(s.$$.fragment,_),b(M),c=!0)},o(_){$(e.$$.fragment,_),$(t.$$.fragment,_),$(s.$$.fragment,_),$(M),c=!1},d(_){_&&(w(n),w(o),w(l),w(u),w(f)),C(e,_),C(t,_),C(s,_),k&&k.d(_),M&&M.d(_)}}}const Ym=()=>{},Xm=()=>{};function Wm(r,e,n){let t,i,o=Q,s=()=>(o(),o=Ke(a,d=>n(3,i=d)),a);W(r,ot,d=>n(2,t=d)),r.$$.on_destroy.push(()=>o());let{gjSchemes:a}=e;s();let{props:l}=e;l.pipeline||(l.pipeline={atf4_type:"",accuracy:"",is_alternative:!1,development_funded:!1,construction_funded:!1,funding_sources:xn(),status:"",timescale:""}),l.is_coverage_polygon||(l.is_coverage_polygon=!1);const u=(i.features.filter(d=>d.properties.is_coverage_polygon).length==0||l.is_coverage_polygon===!0)&&l.intervention_type==="area";function f(){try{n(0,l.name=t.inner.routeNameForWaypoints(l.waypoints),l)}catch(d){window.alert(`Couldn't auto-name route: ${d}`)}}let c=At();function p(){l.name=this.value,n(0,l)}const m=()=>f(),g=d=>[d.scheme_reference,Qr(d)];function v(d){r.$$.not_equal(l.scheme_reference,d)&&(l.scheme_reference=d,n(0,l))}function k(d){r.$$.not_equal(l.description,d)&&(l.description=d,n(0,l))}function M(d){r.$$.not_equal(l.pipeline.atf4_type,d)&&(l.pipeline.atf4_type=d,n(0,l))}function _(d){r.$$.not_equal(l.pipeline.accuracy,d)&&(l.pipeline.accuracy=d,n(0,l))}function h(d){r.$$.not_equal(l.pipeline.is_alternative,d)&&(l.pipeline.is_alternative=d,n(0,l))}function E(d){r.$$.not_equal(l.is_coverage_polygon,d)&&(l.is_coverage_polygon=d,n(0,l))}return r.$$set=d=>{"gjSchemes"in d&&s(n(1,a=d.gjSchemes)),"props"in d&&n(0,l=d.props)},[l,a,t,i,u,f,c,p,m,g,v,k,M,_,h,E]}class Km extends re{constructor(e){super(),ie(this,e,Wm,Jm,te,{gjSchemes:1,props:0})}}function wo(r,e,n){const t=r.slice();return t[9]=e[n][0],t[10]=e[n][1],t}function ko(r){let e,n;return e=new _e({props:{$$slots:{default:[Hm]},$$scope:{ctx:r}}}),e.$on("click",r[6]),{c(){P(e.$$.fragment)},m(t,i){L(e,t,i),n=!0},p(t,i){const o={};i&8192&&(o.$$scope={dirty:i,ctx:t}),e.$set(o)},i(t){n||(b(e.$$.fragment,t),n=!0)},o(t){$(e.$$.fragment,t),n=!1},d(t){C(e,t)}}}function Hm(r){let e;return{c(){e=z("Handle extra GeoJSON properties")},m(n,t){y(n,e,t)},d(n){n&&w(e)}}}function So(r){let e,n,t=r[9]+"",i,o,s=JSON.stringify(r[10])+"",a,l;return{c(){e=q("li"),n=q("b"),i=z(t),o=z(` + = `),a=z(s),l=R()},m(u,f){y(u,e,f),G(e,n),G(n,i),G(e,o),G(e,a),G(e,l)},p(u,f){f&2&&t!==(t=u[9]+"")&&be(i,t),f&2&&s!==(s=JSON.stringify(u[10])+"")&&be(a,s)},d(u){u&&w(e)}}}function Zm(r){let e;return{c(){e=z("Remove these properties")},m(n,t){y(n,e,t)},d(n){n&&w(e)}}}function Vm(r){let e;return{c(){e=z("Cancel")},m(n,t){y(n,e,t)},d(n){n&&w(e)}}}function Qm(r){let e,n,t,i;return e=new bt({props:{$$slots:{default:[Zm]},$$scope:{ctx:r}}}),e.$on("click",r[2]),t=new _e({props:{$$slots:{default:[Vm]},$$scope:{ctx:r}}}),t.$on("click",r[7]),{c(){P(e.$$.fragment),n=R(),P(t.$$.fragment)},m(o,s){L(e,o,s),y(o,n,s),L(t,o,s),i=!0},p(o,s){const a={};s&8192&&(a.$$scope={dirty:s,ctx:o}),e.$set(a);const l={};s&8192&&(l.$$scope={dirty:s,ctx:o}),t.$set(l)},i(o){i||(b(e.$$.fragment,o),b(t.$$.fragment,o),i=!0)},o(o){$(e.$$.fragment,o),$(t.$$.fragment,o),i=!1},d(o){o&&w(n),C(e,o),C(t,o)}}}function xm(r){let e,n,t,i,o,s,a=Ie(Object.entries(r[1])),l=[];for(let u=0;u0,n,t,i,o,s=e&&ko(r);function a(u){r[8](u)}let l={title:"This imported GeoJSON feature has unexpected properties",$$slots:{default:[xm]},$$scope:{ctx:r}};return r[0]!==void 0&&(l.open=r[0]),t=new Nt({props:l}),V.push(()=>x(t,"open",a)),{c(){s&&s.c(),n=R(),P(t.$$.fragment)},m(u,f){s&&s.m(u,f),y(u,n,f),L(t,u,f),o=!0},p(u,[f]){f&2&&(e=Object.entries(u[1]).length>0),e?s?(s.p(u,f),f&2&&b(s,1)):(s=ko(u),s.c(),b(s,1),s.m(n.parentNode,n)):s&&(se(),$(s,1,1,()=>{s=null}),le());const c={};f&8195&&(c.$$scope={dirty:f,ctx:u}),!i&&f&1&&(i=!0,c.open=u[0],ne(()=>i=!1)),t.$set(c)},i(u){o||(b(s),b(t.$$.fragment,u),o=!0)},o(u){$(s),$(t.$$.fragment,u),o=!1},d(u){u&&w(n),s&&s.d(u),C(t,u)}}}function td(r,e,n){let t,{gjSchemes:i}=e,{id:o}=e,{props:s}=e,a=!1;function l(){n(0,a=!1),i.update(p=>{let m=p.features.find(g=>g.id==o);for(let g of Object.keys(t))delete m.properties[g];return p})}const u=()=>n(0,a=!0),f=()=>n(0,a=!1);function c(p){a=p,n(0,a)}return r.$$set=p=>{"gjSchemes"in p&&n(3,i=p.gjSchemes),"id"in p&&n(4,o=p.id),"props"in p&&n(5,s=p.props)},r.$$.update=()=>{r.$$.dirty&32&&n(1,t=Vs(s))},[a,t,l,i,o,s,u,f,c]}class nd extends re{constructor(e){super(),ie(this,e,td,ed,te,{gjSchemes:3,id:4,props:5})}}function Eo(r){let e,n;return e=new nd({props:{gjSchemes:r[1],id:r[2],props:r[0]}}),{c(){P(e.$$.fragment)},m(t,i){L(e,t,i),n=!0},p(t,i){const o={};i&2&&(o.gjSchemes=t[1]),i&4&&(o.id=t[2]),i&1&&(o.props=t[0]),e.$set(o)},i(t){n||(b(e.$$.fragment,t),n=!0)},o(t){$(e.$$.fragment,t),n=!1},d(t){C(e,t)}}}function rd(r){let e,n,t;function i(s){r[6](s)}let o={gjSchemes:r[1]};return r[0]!==void 0&&(o.props=r[0]),e=new Km({props:o}),V.push(()=>x(e,"props",i)),{c(){P(e.$$.fragment)},m(s,a){L(e,s,a),t=!0},p(s,a){const l={};a&2&&(l.gjSchemes=s[1]),!n&&a&1&&(n=!0,l.props=s[0],ne(()=>n=!1)),e.$set(l)},i(s){t||(b(e.$$.fragment,s),t=!0)},o(s){$(e.$$.fragment,s),t=!1},d(s){C(e,s)}}}function id(r){let e,n,t;function i(s){r[5](s)}let o={gjSchemes:r[1]};return r[0]!==void 0&&(o.props=r[0]),e=new Lm({props:o}),V.push(()=>x(e,"props",i)),{c(){P(e.$$.fragment)},m(s,a){L(e,s,a),t=!0},p(s,a){const l={};a&2&&(l.gjSchemes=s[1]),!n&&a&1&&(n=!0,l.props=s[0],ne(()=>n=!1)),e.$set(l)},i(s){t||(b(e.$$.fragment,s),t=!0)},o(s){$(e.$$.fragment,s),t=!1},d(s){C(e,s)}}}function od(r){let e,n,t,i,o,s=r[2]!=null&&Eo(r);const a=[id,rd],l=[];function u(f,c){return f[3]=="v1"?0:f[3]=="pipeline"?1:-1}return~(n=u(r))&&(t=l[n]=a[n](r)),{c(){s&&s.c(),e=R(),t&&t.c(),i=ce()},m(f,c){s&&s.m(f,c),y(f,e,c),~n&&l[n].m(f,c),y(f,i,c),o=!0},p(f,[c]){f[2]!=null?s?(s.p(f,c),c&4&&b(s,1)):(s=Eo(f),s.c(),b(s,1),s.m(e.parentNode,e)):s&&(se(),$(s,1,1,()=>{s=null}),le());let p=n;n=u(f),n===p?~n&&l[n].p(f,c):(t&&(se(),$(l[p],1,1,()=>{l[p]=null}),le()),~n?(t=l[n],t?t.p(f,c):(t=l[n]=a[n](f),t.c()),b(t,1),t.m(i.parentNode,i)):t=null)},i(f){o||(b(s),b(t),o=!0)},o(f){$(s),$(t),o=!1},d(f){f&&(w(e),w(i)),s&&s.d(f),~n&&l[n].d(f)}}}function sd(r,e,n){let t;W(r,xe,f=>n(3,t=f));let{cfg:i}=e,{gjSchemes:o}=e,{id:s}=e,{props:a}=e;function l(f){a=f,n(0,a)}function u(f){a=f,n(0,a)}return r.$$set=f=>{"cfg"in f&&n(4,i=f.cfg),"gjSchemes"in f&&n(1,o=f.gjSchemes),"id"in f&&n(2,s=f.id),"props"in f&&n(0,a=f.props)},[a,o,s,t,i,l,u]}let ld=class extends re{constructor(e){super(),ie(this,e,sd,od,te,{cfg:4,gjSchemes:1,id:2,props:0})}};function ad(r){let e;return{c(){e=z("Scheme details")},m(n,t){y(n,e,t)},d(n){n&&w(e)}}}function ud(r){let e;return{c(){e=z("Save")},m(n,t){y(n,e,t)},d(n){n&&w(e)}}}function fd(r){let e,n,t,i,o;function s(l){r[6](l)}let a={label:"Scheme name",required:!0};return r[3].schemes[r[1]].scheme_name!==void 0&&(a.value=r[3].schemes[r[1]].scheme_name),e=new ir({props:a}),V.push(()=>x(e,"value",s)),i=new _t({props:{$$slots:{default:[ud]},$$scope:{ctx:r}}}),i.$on("click",r[7]),{c(){P(e.$$.fragment),t=R(),P(i.$$.fragment)},m(l,u){L(e,l,u),y(l,t,u),L(i,l,u),o=!0},p(l,u){const f={};!n&&u&10&&(n=!0,f.value=l[3].schemes[l[1]].scheme_name,ne(()=>n=!1)),e.$set(f);const c={};u&512&&(c.$$scope={dirty:u,ctx:l}),i.$set(c)},i(l){o||(b(e.$$.fragment,l),b(i.$$.fragment,l),o=!0)},o(l){$(e.$$.fragment,l),$(i.$$.fragment,l),o=!1},d(l){l&&w(t),C(e,l),C(i,l)}}}function cd(r){let e,n,t,i,o,s,a;e=new _e({props:{$$slots:{default:[ad]},$$scope:{ctx:r}}}),e.$on("click",r[5]);function l(f){r[8](f)}let u={title:"Scheme details",$$slots:{default:[fd]},$$scope:{ctx:r}};return r[2]!==void 0&&(u.open=r[2]),t=new Nt({props:u}),V.push(()=>x(t,"open",l)),{c(){P(e.$$.fragment),n=R(),P(t.$$.fragment)},m(f,c){L(e,f,c),y(f,n,c),L(t,f,c),o=!0,s||(a=he(window,"keydown",r[4]),s=!0)},p(f,[c]){const p={};c&512&&(p.$$scope={dirty:c,ctx:f}),e.$set(p);const m={};c&526&&(m.$$scope={dirty:c,ctx:f}),!i&&c&4&&(i=!0,m.open=f[2],ne(()=>i=!1)),t.$set(m)},i(f){o||(b(e.$$.fragment,f),b(t.$$.fragment,f),o=!0)},o(f){$(e.$$.fragment,f),$(t.$$.fragment,f),o=!1},d(f){f&&w(n),C(e,f),C(t,f),s=!1,a()}}}function pd(r,e,n){let t,i=Q,o=()=>(i(),i=Ke(s,g=>n(3,t=g)),s);r.$$.on_destroy.push(()=>i());let{gjSchemes:s}=e;o();let{scheme_reference:a}=e,l=!1;function u(g){l&&g.key=="Escape"&&(g.stopPropagation(),n(2,l=!1))}const f=()=>n(2,l=!0);function c(g){r.$$.not_equal(t.schemes[a].scheme_name,g)&&(t.schemes[a].scheme_name=g,s.set(t))}const p=()=>n(2,l=!1);function m(g){l=g,n(2,l)}return r.$$set=g=>{"gjSchemes"in g&&o(n(0,s=g.gjSchemes)),"scheme_reference"in g&&n(1,a=g.scheme_reference)},[s,a,l,t,u,f,c,p,m]}class md extends re{constructor(e){super(),ie(this,e,pd,cd,te,{gjSchemes:0,scheme_reference:1})}}function dd(r){let e;return{c(){e=z("Scheme details")},m(n,t){y(n,e,t)},d(n){n&&w(e)}}}function gd(r){let e;return{c(){e=z("Save")},m(n,t){y(n,e,t)},d(n){n&&w(e)}}}function hd(r){let e,n,t,i,o,s,a,l,u,f,c,p,m,g,v,k,M,_,h,E,d;function S(I){r[9](I)}let N={label:"Scheme name",required:!0};r[6].schemes[r[1]].scheme_name!==void 0&&(N.value=r[6].schemes[r[1]].scheme_name),e=new ir({props:N}),V.push(()=>x(e,"value",S));function j(I){r[10](I)}let U={label:"Scheme type",choices:[["cycling route","Cycling route"],["walking route","Walking route"],["shared-use route","Shared-use route"],["cycling and walking route","Cycling and walking route, not shared use"],["area-based scheme","Area-based scheme"],["intersection","Intersection/junction scheme"]],inlineSmall:!0,required:!0};r[3].scheme_type!==void 0&&(U.value=r[3].scheme_type),a=new Pt({props:U}),V.push(()=>x(a,"value",j));function B(I){r[11](I)}let O={label:"Type of the main intervention"};r[3].atf4_lead_type!==void 0&&(O.value=r[3].atf4_lead_type),f=new Ws({props:O}),V.push(()=>x(f,"value",B));function F(I){r[12](I)}let A={label:"Scheme description (150 words max)"};return r[3].scheme_description!==void 0&&(A.value=r[3].scheme_description),m=new Dr({props:A}),V.push(()=>x(m,"value",F)),k=new Ks({props:{data:r[3],required:!0,onUpdate:r[13]}}),_=new Hs({props:{data:r[3],onUpdate:r[14]}}),E=new _t({props:{$$slots:{default:[gd]},$$scope:{ctx:r}}}),E.$on("click",r[15]),{c(){P(e.$$.fragment),t=R(),i=q("fieldset"),o=q("legend"),o.textContent="Basic information",s=R(),P(a.$$.fragment),u=R(),P(f.$$.fragment),p=R(),P(m.$$.fragment),v=R(),P(k.$$.fragment),M=R(),P(_.$$.fragment),h=R(),P(E.$$.fragment),J(o,"class","govuk-fieldset__legend"),J(i,"class","govuk-fieldset svelte-1bxyfcq")},m(I,K){L(e,I,K),y(I,t,K),y(I,i,K),G(i,o),G(i,s),L(a,i,null),G(i,u),L(f,i,null),G(i,p),L(m,i,null),y(I,v,K),L(k,I,K),y(I,M,K),L(_,I,K),y(I,h,K),L(E,I,K),d=!0},p(I,K){const T={};!n&&K&66&&(n=!0,T.value=I[6].schemes[I[1]].scheme_name,ne(()=>n=!1)),e.$set(T);const ee={};!l&&K&8&&(l=!0,ee.value=I[3].scheme_type,ne(()=>l=!1)),a.$set(ee);const D={};!c&&K&8&&(c=!0,D.value=I[3].atf4_lead_type,ne(()=>c=!1)),f.$set(D);const fe={};!g&&K&8&&(g=!0,fe.value=I[3].scheme_description,ne(()=>g=!1)),m.$set(fe);const me={};K&8&&(me.data=I[3]),K&16&&(me.onUpdate=I[13]),k.$set(me);const ve={};K&8&&(ve.data=I[3]),K&16&&(ve.onUpdate=I[14]),_.$set(ve);const $e={};K&524288&&($e.$$scope={dirty:K,ctx:I}),E.$set($e)},i(I){d||(b(e.$$.fragment,I),b(a.$$.fragment,I),b(f.$$.fragment,I),b(m.$$.fragment,I),b(k.$$.fragment,I),b(_.$$.fragment,I),b(E.$$.fragment,I),d=!0)},o(I){$(e.$$.fragment,I),$(a.$$.fragment,I),$(f.$$.fragment,I),$(m.$$.fragment,I),$(k.$$.fragment,I),$(_.$$.fragment,I),$(E.$$.fragment,I),d=!1},d(I){I&&(w(t),w(i),w(v),w(M),w(h)),C(e,I),C(a),C(f),C(m),C(k,I),C(_,I),C(E,I)}}}function _d(r){let e,n,t,i,o,s,a,l,u;e=new Xe({props:{errorMessage:r[5]}}),t=new _e({props:{$$slots:{default:[dd]},$$scope:{ctx:r}}}),t.$on("click",r[8]);function f(p){r[16](p)}let c={title:"Scheme details",$$slots:{default:[hd]},$$scope:{ctx:r}};return r[2]!==void 0&&(c.open=r[2]),o=new Nt({props:c}),V.push(()=>x(o,"open",f)),{c(){P(e.$$.fragment),n=R(),P(t.$$.fragment),i=R(),P(o.$$.fragment)},m(p,m){L(e,p,m),y(p,n,m),L(t,p,m),y(p,i,m),L(o,p,m),a=!0,l||(u=he(window,"keydown",r[7]),l=!0)},p(p,[m]){const g={};m&32&&(g.errorMessage=p[5]),e.$set(g);const v={};m&524288&&(v.$$scope={dirty:m,ctx:p}),t.$set(v);const k={};m&524382&&(k.$$scope={dirty:m,ctx:p}),!s&&m&4&&(s=!0,k.open=p[2],ne(()=>s=!1)),o.$set(k)},i(p){a||(b(e.$$.fragment,p),b(t.$$.fragment,p),b(o.$$.fragment,p),a=!0)},o(p){$(e.$$.fragment,p),$(t.$$.fragment,p),$(o.$$.fragment,p),a=!1},d(p){p&&(w(n),w(i)),C(e,p),C(t,p),C(o,p),l=!1,u()}}}function bd(r,e,n){let t,i,o=Q,s=()=>(o(),o=Ke(a,j=>n(6,i=j)),a);r.$$.on_destroy.push(()=>o());let{gjSchemes:a}=e;s();let{scheme_reference:l}=e,u=!1,f=i.schemes[l].pipeline,c=0;function p(j,U){return f.scheme_type&&f.status&&f.timescale?"":"Missing some required data"}function m(j){u&&j.key=="Escape"&&(j.stopPropagation(),n(2,u=!1))}function g(){Ne(a,i.schemes[l].pipeline=f,i),a.set(i)}const v=()=>n(2,u=!0);function k(j){r.$$.not_equal(i.schemes[l].scheme_name,j)&&(i.schemes[l].scheme_name=j,a.set(i))}function M(j){r.$$.not_equal(f.scheme_type,j)&&(f.scheme_type=j,n(3,f))}function _(j){r.$$.not_equal(f.atf4_lead_type,j)&&(f.atf4_lead_type=j,n(3,f))}function h(j){r.$$.not_equal(f.scheme_description,j)&&(f.scheme_description=j,n(3,f))}const E=()=>n(4,c++,c),d=()=>n(4,c++,c),S=()=>n(2,u=!1);function N(j){u=j,n(2,u)}return r.$$set=j=>{"gjSchemes"in j&&s(n(0,a=j.gjSchemes)),"scheme_reference"in j&&n(1,l=j.scheme_reference)},r.$$.update=()=>{r.$$.dirty&24&&n(5,t=p()),r.$$.dirty&4&&(u||g())},[a,l,u,f,c,t,i,m,v,k,M,_,h,E,d,S,N]}class vd extends re{constructor(e){super(),ie(this,e,bd,_d,te,{gjSchemes:0,scheme_reference:1})}}function $d(r){let e,n;return e=new md({props:{gjSchemes:r[0],scheme_reference:r[1]}}),{c(){P(e.$$.fragment)},m(t,i){L(e,t,i),n=!0},p(t,i){const o={};i&1&&(o.gjSchemes=t[0]),i&2&&(o.scheme_reference=t[1]),e.$set(o)},i(t){n||(b(e.$$.fragment,t),n=!0)},o(t){$(e.$$.fragment,t),n=!1},d(t){C(e,t)}}}function yd(r){let e,n;return e=new vd({props:{gjSchemes:r[0],scheme_reference:r[1]}}),{c(){P(e.$$.fragment)},m(t,i){L(e,t,i),n=!0},p(t,i){const o={};i&1&&(o.gjSchemes=t[0]),i&2&&(o.scheme_reference=t[1]),e.$set(o)},i(t){n||(b(e.$$.fragment,t),n=!0)},o(t){$(e.$$.fragment,t),n=!1},d(t){C(e,t)}}}function wd(r){let e,n,t,i;const o=[yd,$d],s=[];function a(l,u){return l[2]=="pipeline"?0:1}return e=a(r),n=s[e]=o[e](r),{c(){n.c(),t=ce()},m(l,u){s[e].m(l,u),y(l,t,u),i=!0},p(l,[u]){let f=e;e=a(l),e===f?s[e].p(l,u):(se(),$(s[f],1,1,()=>{s[f]=null}),le(),n=s[e],n?n.p(l,u):(n=s[e]=o[e](l),n.c()),b(n,1),n.m(t.parentNode,t))},i(l){i||(b(n),i=!0)},o(l){$(n),i=!1},d(l){l&&w(t),s[e].d(l)}}}function kd(r,e,n){let t;W(r,xe,s=>n(2,t=s));let{gjSchemes:i}=e,{scheme_reference:o}=e;return r.$$set=s=>{"gjSchemes"in s&&n(0,i=s.gjSchemes),"scheme_reference"in s&&n(1,o=s.scheme_reference)},[i,o,t]}class Sd extends re{constructor(e){super(),ie(this,e,kd,wd,te,{gjSchemes:0,scheme_reference:1})}}let Ue={interventionName:Md,schemeName:Qr,backfill:On,initializeEmptyScheme:Ed,interventionWarning:Pd,editFeatureForm:ld,editSchemeForm:Sd,newPointFeature:r=>{r.properties.intervention_type="other"},newPolygonFeature:r=>{r.properties.intervention_type="area",r.properties.is_coverage_polygon=!1},newLineStringFeature:r=>{r.properties.intervention_type="route",r.properties.route_name&&!r.properties.name&&Et(xe)!="pipeline"&&(r.properties.name=r.properties.route_name),delete r.properties.route_name},updateFeature:(r,e)=>{e.properties.route_name&&!r.properties.name&&Et(xe)!="pipeline"&&(r.properties.name=e.properties.route_name)},maptilerApiKey:"MZEJTanw3WpxRvt7qDfo",getStreetViewRoadLayerNames:r=>jl(r,Et(hr)),layerZorder:Il};function On(r){var t,i,o,s,a,l,u,f;let e=Et(xe),n=1;for(let c of r.features)c.properties||(c.properties={name:"",scheme_reference:"",description:"",intervention_type:"other",is_coverage_polygon:!1}),e=="pipeline"&&!c.properties.intervention_type&&(c.properties.intervention_type=new Map([["LineString","route"],["Polygon","area"]]).get(c.geometry.type)??"other"),c.geometry.type=="LineString"&&!c.properties.length_meters&&(c.properties.length_meters=Bl(c,{units:"kilometers"})*1e3),c.id=n++;if(!r.schemes){let c=At();r.schemes={},r.schemes[c]={scheme_reference:c,color:si()},r.scheme_name&&(r.schemes[c].scheme_name=r.scheme_name,delete r.scheme_name),r.pipeline&&(r.schemes[c].pipeline=r.pipeline,delete r.pipeline);for(let p of r.features)p.properties.scheme_reference=c}for(let c of Object.values(r.schemes)){let p=c;if(p.color??(p.color=si()),e=="pipeline"){p.pipeline??(p.pipeline=Zs()),(t=p.pipeline).development_funded??(t.development_funded=!1),(i=p.pipeline).construction_funded??(i.construction_funded=!1),(o=p.pipeline).funding_sources??(o.funding_sources=xn()),delete p.pipeline.budget_funded,delete p.pipeline.budget_unfunded,delete p.pipeline.funding_source,delete p.pipeline.funded;for(let m of r.features)m.properties.pipeline&&((s=m.properties.pipeline).development_funded??(s.development_funded=!1),(a=m.properties.pipeline).construction_funded??(a.construction_funded=!1),(l=m.properties.pipeline).funding_sources??(l.funding_sources=xn()),(u=m.properties.pipeline).status??(u.status=""),(f=m.properties.pipeline).timescale??(f.timescale=""))}}return r}function Ed(r){let e=r;return Et(xe)=="pipeline"&&(e.pipeline=Zs()),e}function Zs(){return{scheme_type:"",atf4_lead_type:"",scheme_description:"",status:"",timescale:"",development_funded:!1,construction_funded:!1,funding_sources:xn()}}function xn(){return{atf2:!1,atf3:!1,atf4:!1,atf4e:!1,crsts:!1,luf:!1,other:""}}function Md(r){if(r.properties.name)return r.properties.name;var e=r.properties.intervention_type;return e=="other"&&(r.geometry.type=="Point"?e="point":r.geometry.type=="LineString"?e="line":e="polygon"),`Untitled ${e}`}function Qr(r){return r.scheme_name??"Untitled scheme"}function Pd(r){var t;let e=Et(xe);if(!r.properties.name)return"No name";if(!new Set(["route","area","crossing","other"]).has(r.properties.intervention_type))return"No intervention type";if(e=="pipeline"&&!((t=r.properties.pipeline)!=null&&t.accuracy))return"Accuracy not specified";let n=Vs(r.properties);return Object.entries(n).length>0?`Extra GeoJSON properties: ${Object.keys(n).join(", ")}`:null}function Vs(r){let e=Et(xe),n=JSON.parse(JSON.stringify(r));for(let t of["name","description","intervention_type","length_meters","waypoints","hide_while_editing","is_coverage_polygon","scheme_reference"])delete n[t];if(e=="pipeline"&&n.pipeline){for(let t of["atf4_type","accuracy","is_alternative","budget","development_funded","construction_funded","funding_sources","status","timescale","timescale_year","year_published","year_consulted"])delete n.pipeline[t];Object.entries(n.pipeline).length==0&&delete n.pipeline}return n}function Mo(r,e,n){const t=r.slice();return t[8]=e[n],t}function Ld(r){let e;return{c(){e=z("Delete all sketch data from browser")},m(n,t){y(n,e,t)},d(n){n&&w(e)}}}function Po(r){let e,n,t,i,o=Ie(r[1].storedStrings),s=[];for(let l=0;l$(s[l],1,1,()=>{s[l]=null});return{c(){e=q("p"),e.textContent=`Otherwise here is a breakdown of what is currently stored locally. You can + delete individual items (normally storage quota is 5MB or 10MB):`,n=R();for(let l=0;l{i=null}),le());const l={};a&2050&&(l.$$scope={dirty:a,ctx:r}),n.$set(l)},i(s){t||(b(i),b(n.$$.fragment,s),t=!0)},o(s){$(i),$(n.$$.fragment,s),t=!1},d(s){s&&w(e),i&&i.d(s),C(n,s)}}}function Fd(r){var p;let e,n=((p=r[1])==null?void 0:p.message)+"",t,i,o,s,a,l,u,f;a=new bt({props:{$$slots:{default:[Ld]},$$scope:{ctx:r}}}),a.$on("click",r[4]);let c=r[1]&&Po(r);return{c(){e=q("p"),t=z(n),i=R(),o=q("p"),o.textContent=`If you have saved your work locally to a geojson file recently, you can delete all files stored in the browser for all authorities to free up space. - Be sure that you're not losing anything important before doing this!`,s=R(),P(a.$$.fragment),l=R(),c&&c.c(),u=ce()},m(m,g){y(m,e,g),G(e,t),y(m,i,g),y(m,o,g),y(m,s,g),L(a,m,g),y(m,l,g),c&&c.m(m,g),y(m,u,g),f=!0},p(m,g){var S;(!f||g&2)&&n!==(n=((S=m[1])==null?void 0:S.message)+"")&&be(t,n);const v={};g&2048&&(v.$$scope={dirty:g,ctx:m}),a.$set(v),m[1]?c?(c.p(m,g),g&2&&_(c,1)):(c=Po(m),c.c(),_(c,1),c.m(u.parentNode,u)):c&&(se(),$(c,1,1,()=>{c=null}),le())},i(m){f||(_(a.$$.fragment,m),_(c),f=!0)},o(m){$(a.$$.fragment,m),$(c),f=!1},d(m){m&&(w(e),w(i),w(o),w(s),w(l),w(u)),F(a,m),c&&c.d(m)}}}function Ad(r){let e,n,t;function i(s){r[7](s)}let o={title:"Local Storage Quota Exceeded",$$slots:{default:[Cd]},$$scope:{ctx:r}};return r[0]!==void 0&&(o.open=r[0]),e=new Nt({props:o}),V.push(()=>x(e,"open",i)),{c(){P(e.$$.fragment)},m(s,a){L(e,s,a),t=!0},p(s,[a]){const l={};a&2054&&(l.$$scope={dirty:a,ctx:s}),!n&&a&1&&(n=!0,l.open=s[0],ne(()=>n=!1)),e.$set(l)},i(s){t||(_(e.$$.fragment,s),t=!0)},o(s){$(e.$$.fragment,s),t=!1},d(s){F(e,s)}}}function Nd(r,e,n){let{show:t}=e,{setStorageError:i}=e,{clearCurrentSketch:o}=e,{currentAuthority:s}=e;function a(c){let p=$l(c);i&&n(1,i.storedStrings=p,i),c===s&&o()}function l(){o(),yl(),n(0,t=!1),n(1,i=void 0)}const u=c=>a(c.key);function f(c){t=c,n(0,t)}return r.$$set=c=>{"show"in c&&n(0,t=c.show),"setStorageError"in c&&n(1,i=c.setStorageError),"clearCurrentSketch"in c&&n(5,o=c.clearCurrentSketch),"currentAuthority"in c&&n(2,s=c.currentAuthority)},[t,i,s,a,l,o,u,f]}class Rd extends re{constructor(e){super(),ie(this,e,Nd,Ad,te,{show:0,setStorageError:1,clearCurrentSketch:5,currentAuthority:2})}}function Co(r){let e,n;return e=new ql({props:{label:"Manage files",$$slots:{default:[Ud]},$$scope:{ctx:r}}}),{c(){P(e.$$.fragment)},m(t,i){L(e,t,i),n=!0},p(t,i){const o={};i&2097164&&(o.$$scope={dirty:i,ctx:t}),e.$set(o)},i(t){n||(_(e.$$.fragment,t),n=!0)},o(t){$(e.$$.fragment,t),n=!1},d(t){F(e,t)}}}function Od(r){let e,n,t;return{c(){e=q("img"),t=D(` - Save`),ot(e.src,n=km)||J(e,"src",n),J(e,"alt","Save as GeoJSON file")},m(i,o){y(i,e,o),y(i,t,o)},p:Q,d(i){i&&(w(e),w(t))}}}function jd(r){let e,n,t;return{c(){e=q("img"),t=D(` - Clear all`),ot(e.src,n=wm)||J(e,"src",n),J(e,"alt","Clear all")},m(i,o){y(i,e,o),y(i,t,o)},p:Q,d(i){i&&(w(e),w(t))}}}function Id(r){let e,n,t,i;return e=new _e({props:{$$slots:{default:[Od]},$$scope:{ctx:r}}}),e.$on("click",r[8]),t=new bt({props:{$$slots:{default:[jd]},$$scope:{ctx:r}}}),t.$on("click",r[14]),{c(){P(e.$$.fragment),n=R(),P(t.$$.fragment)},m(o,s){L(e,o,s),y(o,n,s),L(t,o,s),i=!0},p(o,s){const a={};s&2097152&&(a.$$scope={dirty:s,ctx:o}),e.$set(a);const l={};s&2097152&&(l.$$scope={dirty:s,ctx:o}),t.$set(l)},i(o){i||(_(e.$$.fragment,o),_(t.$$.fragment,o),i=!0)},o(o){$(e.$$.fragment,o),$(t.$$.fragment,o),i=!1},d(o){o&&w(n),F(e,o),F(t,o)}}}function Bd(r){let e;return{c(){e=D("Clear all work")},m(n,t){y(n,e,t)},d(n){n&&w(e)}}}function qd(r){let e;return{c(){e=D("Cancel")},m(n,t){y(n,e,t)},d(n){n&&w(e)}}}function Gd(r){let e,n,t,i;return e=new bt({props:{$$slots:{default:[Bd]},$$scope:{ctx:r}}}),e.$on("click",r[7]),t=new _e({props:{$$slots:{default:[qd]},$$scope:{ctx:r}}}),t.$on("click",r[15]),{c(){P(e.$$.fragment),n=R(),P(t.$$.fragment)},m(o,s){L(e,o,s),y(o,n,s),L(t,o,s),i=!0},p(o,s){const a={};s&2097152&&(a.$$scope={dirty:s,ctx:o}),e.$set(a);const l={};s&2097152&&(l.$$scope={dirty:s,ctx:o}),t.$set(l)},i(o){i||(_(e.$$.fragment,o),_(t.$$.fragment,o),i=!0)},o(o){$(e.$$.fragment,o),$(t.$$.fragment,o),i=!1},d(o){o&&w(n),F(e,o),F(t,o)}}}function Td(r){let e,n,t,i;return t=new Ke({props:{$$slots:{default:[Gd]},$$scope:{ctx:r}}}),{c(){e=q("p"),e.textContent="This will delete everything for all schemes.",n=R(),P(t.$$.fragment)},m(o,s){y(o,e,s),y(o,n,s),L(t,o,s),i=!0},p(o,s){const a={};s&2097160&&(a.$$scope={dirty:s,ctx:o}),t.$set(a)},i(o){i||(_(t.$$.fragment,o),i=!0)},o(o){$(t.$$.fragment,o),i=!1},d(o){o&&(w(e),w(n)),F(t,o)}}}function Ud(r){let e,n,t,i,o,s,a,l,u;e=new Xo({props:{label:"Load GeoJSON file",onLoad:r[9]}}),t=new Ke({props:{$$slots:{default:[Id]},$$scope:{ctx:r}}}),o=new Ye({props:{errorMessage:r[2]}});function f(p){r[16](p)}let c={title:"Would you like to clear your work?",displayEscapeButton:!1,$$slots:{default:[Td]},$$scope:{ctx:r}};return r[3]!==void 0&&(c.open=r[3]),a=new Nt({props:c}),V.push(()=>x(a,"open",f)),{c(){P(e.$$.fragment),n=R(),P(t.$$.fragment),i=R(),P(o.$$.fragment),s=R(),P(a.$$.fragment)},m(p,m){L(e,p,m),y(p,n,m),L(t,p,m),y(p,i,m),L(o,p,m),y(p,s,m),L(a,p,m),u=!0},p(p,m){const g={};m&2097160&&(g.$$scope={dirty:m,ctx:p}),t.$set(g);const v={};m&4&&(v.errorMessage=p[2]),o.$set(v);const S={};m&2097160&&(S.$$scope={dirty:m,ctx:p}),!l&&m&8&&(l=!0,S.open=p[3],ne(()=>l=!1)),a.$set(S)},i(p){u||(_(e.$$.fragment,p),_(t.$$.fragment,p),_(o.$$.fragment,p),_(a.$$.fragment,p),u=!0)},o(p){$(e.$$.fragment,p),$(t.$$.fragment,p),$(o.$$.fragment,p),$(a.$$.fragment,p),u=!1},d(p){p&&(w(n),w(i),w(s)),F(e,p),F(t,p),F(o,p),F(a,p)}}}function Dd(r){let e,n,t,i,o,s=r[6].mode=="list"&&Co(r);function a(f){r[17](f)}function l(f){r[18](f)}let u={clearCurrentSketch:r[7],currentAuthority:r[1]};return r[4]!==void 0&&(u.show=r[4]),r[5]!==void 0&&(u.setStorageError=r[5]),n=new Rd({props:u}),V.push(()=>x(n,"show",a)),V.push(()=>x(n,"setStorageError",l)),{c(){s&&s.c(),e=R(),P(n.$$.fragment)},m(f,c){s&&s.m(f,c),y(f,e,c),L(n,f,c),o=!0},p(f,[c]){f[6].mode=="list"?s?(s.p(f,c),c&64&&_(s,1)):(s=Co(f),s.c(),_(s,1),s.m(e.parentNode,e)):s&&(se(),$(s,1,1,()=>{s=null}),le());const p={};c&2&&(p.currentAuthority=f[1]),!t&&c&16&&(t=!0,p.show=f[4],ne(()=>t=!1)),!i&&c&32&&(i=!0,p.setStorageError=f[5],ne(()=>i=!1)),n.$set(p)},i(f){o||(_(s),_(n.$$.fragment,f),o=!0)},o(f){$(s),$(n.$$.fragment,f),o=!1},d(f){f&&w(e),s&&s.d(f),F(n,f)}}}function zd(r,e){var n=document.createElement("a");n.setAttribute("href","data:text/plain;charset=utf-8, "+encodeURIComponent(e)),n.setAttribute("download",r),document.body.appendChild(n),n.click(),document.body.removeChild(n)}function Jd(r,e,n){let t,i=Q,o=()=>(i(),i=We(u,B=>n(13,t=B)),u),s,a;K(r,pe,B=>n(6,s=B)),K(r,Qe,B=>n(19,a=B)),r.$$.on_destroy.push(()=>i());let{cfg:l}=e,{gjSchemes:u}=e;o();let{authorityName:f}=e,c="",p=f;a!="v1"&&(p+=`_${a}`);let m=!1,g=!1;rt(async()=>{let O=new URLSearchParams(window.location.search).get("geojsonUrl"),C=window.localStorage.getItem(p);if(O){console.log(`Loading GeoJSON from ${O}`);try{let I=await(await fetch(O)).text();u.set(On(JSON.parse(I)))}catch(A){console.log(`Failed to load from URL: ${A}`)}}else if(C)try{u.set(On(JSON.parse(C)))}catch(A){console.log(`Failed to load from local storage: ${A}`)}n(12,m=!0)});let v=!1,S;function k(){n(3,g=!1),u.update(B=>{let O=Tr(l);return O.origin=B.origin,O.authority=B.authority,O}),on.set(null),ln.set(new Set),je(pe,s.mode="list",s)}function b(){const B=JSON.parse(JSON.stringify(t));for(let O of B.features)delete O.properties.hide_while_editing;return B}function h(){let B=b();B.authority=f,B.origin="atip-v2",zd(`${p}.geojson`,JSON.stringify(B,null," "))}function M(B,O){try{u.set(On(JSON.parse(O))),n(2,c="")}catch(C){n(2,c=`Couldn't load scheme from a file: ${C}`)}}const d=()=>n(3,g=!0),E=()=>n(3,g=!1);function N(B){g=B,n(3,g)}function j(B){v=B,n(4,v),n(12,m),n(13,t),n(11,p)}function U(B){S=B,n(5,S),n(12,m),n(13,t),n(11,p)}return r.$$set=B=>{"cfg"in B&&n(10,l=B.cfg),"gjSchemes"in B&&o(n(0,u=B.gjSchemes)),"authorityName"in B&&n(1,f=B.authorityName)},r.$$.update=()=>{if(r.$$.dirty&14336&&m&&t){console.log("GJ changed, saving to local storage");const B=wl(p,JSON.stringify(b()));B.isQuotaError&&(n(4,v=!0),n(5,S=B))}},[u,f,c,g,v,S,s,k,h,M,l,p,m,t,d,E,N,j,U]}class Yd extends re{constructor(e){super(),ie(this,e,Jd,Dd,te,{cfg:10,gjSchemes:0,authorityName:1})}}function Xd(r){let e;return{c(){e=q("div"),e.innerHTML=`

    Saving files

    ATIP does not send any data over the network or store your data in the + Be sure that you're not losing anything important before doing this!`,s=R(),P(a.$$.fragment),l=R(),c&&c.c(),u=ce()},m(m,g){y(m,e,g),G(e,t),y(m,i,g),y(m,o,g),y(m,s,g),L(a,m,g),y(m,l,g),c&&c.m(m,g),y(m,u,g),f=!0},p(m,g){var k;(!f||g&2)&&n!==(n=((k=m[1])==null?void 0:k.message)+"")&&be(t,n);const v={};g&2048&&(v.$$scope={dirty:g,ctx:m}),a.$set(v),m[1]?c?(c.p(m,g),g&2&&b(c,1)):(c=Po(m),c.c(),b(c,1),c.m(u.parentNode,u)):c&&(se(),$(c,1,1,()=>{c=null}),le())},i(m){f||(b(a.$$.fragment,m),b(c),f=!0)},o(m){$(a.$$.fragment,m),$(c),f=!1},d(m){m&&(w(e),w(i),w(o),w(s),w(l),w(u)),C(a,m),c&&c.d(m)}}}function Ad(r){let e,n,t;function i(s){r[7](s)}let o={title:"Local Storage Quota Exceeded",$$slots:{default:[Fd]},$$scope:{ctx:r}};return r[0]!==void 0&&(o.open=r[0]),e=new Nt({props:o}),V.push(()=>x(e,"open",i)),{c(){P(e.$$.fragment)},m(s,a){L(e,s,a),t=!0},p(s,[a]){const l={};a&2054&&(l.$$scope={dirty:a,ctx:s}),!n&&a&1&&(n=!0,l.open=s[0],ne(()=>n=!1)),e.$set(l)},i(s){t||(b(e.$$.fragment,s),t=!0)},o(s){$(e.$$.fragment,s),t=!1},d(s){C(e,s)}}}function Nd(r,e,n){let{show:t}=e,{setStorageError:i}=e,{clearCurrentSketch:o}=e,{currentAuthority:s}=e;function a(c){let p=$l(c);i&&n(1,i.storedStrings=p,i),c===s&&o()}function l(){o(),yl(),n(0,t=!1),n(1,i=void 0)}const u=c=>a(c.key);function f(c){t=c,n(0,t)}return r.$$set=c=>{"show"in c&&n(0,t=c.show),"setStorageError"in c&&n(1,i=c.setStorageError),"clearCurrentSketch"in c&&n(5,o=c.clearCurrentSketch),"currentAuthority"in c&&n(2,s=c.currentAuthority)},[t,i,s,a,l,o,u,f]}class Rd extends re{constructor(e){super(),ie(this,e,Nd,Ad,te,{show:0,setStorageError:1,clearCurrentSketch:5,currentAuthority:2})}}function Fo(r){let e,n;return e=new ql({props:{label:"Manage files",$$slots:{default:[Dd]},$$scope:{ctx:r}}}),{c(){P(e.$$.fragment)},m(t,i){L(e,t,i),n=!0},p(t,i){const o={};i&2097164&&(o.$$scope={dirty:i,ctx:t}),e.$set(o)},i(t){n||(b(e.$$.fragment,t),n=!0)},o(t){$(e.$$.fragment,t),n=!1},d(t){C(e,t)}}}function Od(r){let e,n,t;return{c(){e=q("img"),t=z(` + Save`),st(e.src,n=km)||J(e,"src",n),J(e,"alt","Save as GeoJSON file")},m(i,o){y(i,e,o),y(i,t,o)},p:Q,d(i){i&&(w(e),w(t))}}}function jd(r){let e,n,t;return{c(){e=q("img"),t=z(` + Clear all`),st(e.src,n=wm)||J(e,"src",n),J(e,"alt","Clear all")},m(i,o){y(i,e,o),y(i,t,o)},p:Q,d(i){i&&(w(e),w(t))}}}function Id(r){let e,n,t,i;return e=new _e({props:{$$slots:{default:[Od]},$$scope:{ctx:r}}}),e.$on("click",r[8]),t=new bt({props:{$$slots:{default:[jd]},$$scope:{ctx:r}}}),t.$on("click",r[14]),{c(){P(e.$$.fragment),n=R(),P(t.$$.fragment)},m(o,s){L(e,o,s),y(o,n,s),L(t,o,s),i=!0},p(o,s){const a={};s&2097152&&(a.$$scope={dirty:s,ctx:o}),e.$set(a);const l={};s&2097152&&(l.$$scope={dirty:s,ctx:o}),t.$set(l)},i(o){i||(b(e.$$.fragment,o),b(t.$$.fragment,o),i=!0)},o(o){$(e.$$.fragment,o),$(t.$$.fragment,o),i=!1},d(o){o&&w(n),C(e,o),C(t,o)}}}function Bd(r){let e;return{c(){e=z("Clear all work")},m(n,t){y(n,e,t)},d(n){n&&w(e)}}}function qd(r){let e;return{c(){e=z("Cancel")},m(n,t){y(n,e,t)},d(n){n&&w(e)}}}function Gd(r){let e,n,t,i;return e=new bt({props:{$$slots:{default:[Bd]},$$scope:{ctx:r}}}),e.$on("click",r[7]),t=new _e({props:{$$slots:{default:[qd]},$$scope:{ctx:r}}}),t.$on("click",r[15]),{c(){P(e.$$.fragment),n=R(),P(t.$$.fragment)},m(o,s){L(e,o,s),y(o,n,s),L(t,o,s),i=!0},p(o,s){const a={};s&2097152&&(a.$$scope={dirty:s,ctx:o}),e.$set(a);const l={};s&2097152&&(l.$$scope={dirty:s,ctx:o}),t.$set(l)},i(o){i||(b(e.$$.fragment,o),b(t.$$.fragment,o),i=!0)},o(o){$(e.$$.fragment,o),$(t.$$.fragment,o),i=!1},d(o){o&&w(n),C(e,o),C(t,o)}}}function Td(r){let e,n,t,i;return t=new He({props:{$$slots:{default:[Gd]},$$scope:{ctx:r}}}),{c(){e=q("p"),e.textContent="This will delete everything for all schemes.",n=R(),P(t.$$.fragment)},m(o,s){y(o,e,s),y(o,n,s),L(t,o,s),i=!0},p(o,s){const a={};s&2097160&&(a.$$scope={dirty:s,ctx:o}),t.$set(a)},i(o){i||(b(t.$$.fragment,o),i=!0)},o(o){$(t.$$.fragment,o),i=!1},d(o){o&&(w(e),w(n)),C(t,o)}}}function Dd(r){let e,n,t,i,o,s,a,l,u;e=new Xo({props:{label:"Load GeoJSON file",onLoad:r[9]}}),t=new He({props:{$$slots:{default:[Id]},$$scope:{ctx:r}}}),o=new Xe({props:{errorMessage:r[2]}});function f(p){r[16](p)}let c={title:"Would you like to clear your work?",displayEscapeButton:!1,$$slots:{default:[Td]},$$scope:{ctx:r}};return r[3]!==void 0&&(c.open=r[3]),a=new Nt({props:c}),V.push(()=>x(a,"open",f)),{c(){P(e.$$.fragment),n=R(),P(t.$$.fragment),i=R(),P(o.$$.fragment),s=R(),P(a.$$.fragment)},m(p,m){L(e,p,m),y(p,n,m),L(t,p,m),y(p,i,m),L(o,p,m),y(p,s,m),L(a,p,m),u=!0},p(p,m){const g={};m&2097160&&(g.$$scope={dirty:m,ctx:p}),t.$set(g);const v={};m&4&&(v.errorMessage=p[2]),o.$set(v);const k={};m&2097160&&(k.$$scope={dirty:m,ctx:p}),!l&&m&8&&(l=!0,k.open=p[3],ne(()=>l=!1)),a.$set(k)},i(p){u||(b(e.$$.fragment,p),b(t.$$.fragment,p),b(o.$$.fragment,p),b(a.$$.fragment,p),u=!0)},o(p){$(e.$$.fragment,p),$(t.$$.fragment,p),$(o.$$.fragment,p),$(a.$$.fragment,p),u=!1},d(p){p&&(w(n),w(i),w(s)),C(e,p),C(t,p),C(o,p),C(a,p)}}}function Ud(r){let e,n,t,i,o,s=(r[6].mode=="list"||r[6].mode=="split-route"||r[6].mode=="set-image"||r[6].mode=="streetview")&&Fo(r);function a(f){r[17](f)}function l(f){r[18](f)}let u={clearCurrentSketch:r[7],currentAuthority:r[1]};return r[4]!==void 0&&(u.show=r[4]),r[5]!==void 0&&(u.setStorageError=r[5]),n=new Rd({props:u}),V.push(()=>x(n,"show",a)),V.push(()=>x(n,"setStorageError",l)),{c(){s&&s.c(),e=R(),P(n.$$.fragment)},m(f,c){s&&s.m(f,c),y(f,e,c),L(n,f,c),o=!0},p(f,[c]){f[6].mode=="list"||f[6].mode=="split-route"||f[6].mode=="set-image"||f[6].mode=="streetview"?s?(s.p(f,c),c&64&&b(s,1)):(s=Fo(f),s.c(),b(s,1),s.m(e.parentNode,e)):s&&(se(),$(s,1,1,()=>{s=null}),le());const p={};c&2&&(p.currentAuthority=f[1]),!t&&c&16&&(t=!0,p.show=f[4],ne(()=>t=!1)),!i&&c&32&&(i=!0,p.setStorageError=f[5],ne(()=>i=!1)),n.$set(p)},i(f){o||(b(s),b(n.$$.fragment,f),o=!0)},o(f){$(s),$(n.$$.fragment,f),o=!1},d(f){f&&w(e),s&&s.d(f),C(n,f)}}}function zd(r,e){var n=document.createElement("a");n.setAttribute("href","data:text/plain;charset=utf-8, "+encodeURIComponent(e)),n.setAttribute("download",r),document.body.appendChild(n),n.click(),document.body.removeChild(n)}function Jd(r,e,n){let t,i=Q,o=()=>(i(),i=Ke(u,B=>n(13,t=B)),u),s,a;W(r,pe,B=>n(6,s=B)),W(r,xe,B=>n(19,a=B)),r.$$.on_destroy.push(()=>i());let{cfg:l}=e,{gjSchemes:u}=e;o();let{authorityName:f}=e,c="",p=f;a!="v1"&&(p+=`_${a}`);let m=!1,g=!1;it(async()=>{let O=new URLSearchParams(window.location.search).get("geojsonUrl"),F=window.localStorage.getItem(p);if(O){console.log(`Loading GeoJSON from ${O}`);try{let I=await(await fetch(O)).text();u.set(On(JSON.parse(I)))}catch(A){console.log(`Failed to load from URL: ${A}`)}}else if(F)try{u.set(On(JSON.parse(F)))}catch(A){console.log(`Failed to load from local storage: ${A}`)}n(12,m=!0)});let v=!1,k;function M(){n(3,g=!1),u.update(B=>{let O=Tr(l);return O.origin=B.origin,O.authority=B.authority,O}),on.set(null),ln.set(new Set),Ne(pe,s.mode="list",s)}function _(){const B=JSON.parse(JSON.stringify(t));for(let O of B.features)delete O.properties.hide_while_editing;return B}function h(){let B=_();B.authority=f,B.origin="atip-v2",zd(`${p}.geojson`,JSON.stringify(B,null," "))}function E(B,O){try{u.set(On(JSON.parse(O))),n(2,c="")}catch(F){n(2,c=`Couldn't load scheme from a file: ${F}`)}}const d=()=>n(3,g=!0),S=()=>n(3,g=!1);function N(B){g=B,n(3,g)}function j(B){v=B,n(4,v),n(12,m),n(13,t),n(11,p)}function U(B){k=B,n(5,k),n(12,m),n(13,t),n(11,p)}return r.$$set=B=>{"cfg"in B&&n(10,l=B.cfg),"gjSchemes"in B&&o(n(0,u=B.gjSchemes)),"authorityName"in B&&n(1,f=B.authorityName)},r.$$.update=()=>{if(r.$$.dirty&14336&&m&&t){console.log("GJ changed, saving to local storage");const B=wl(p,JSON.stringify(_()));B.isQuotaError&&(n(4,v=!0),n(5,k=B))}},[u,f,c,g,v,k,s,M,h,E,l,p,m,t,d,S,N,j,U]}class Yd extends re{constructor(e){super(),ie(this,e,Jd,Ud,te,{cfg:10,gjSchemes:0,authorityName:1})}}function Xd(r){let e;return{c(){e=q("div"),e.innerHTML=`

    Saving files

    ATIP does not send any data over the network or store your data in the cloud. The current file you're editing will be saved in your browser's local storage and automatically resume when you return to the page. Click Edit scheme , then @@ -76,5 +76,5 @@ and limitations under the License. or Load from GeoJSON to save or load a file to your computer. You can share these files with others - to collaborate on designs.

    `,J(e,"class","govuk-prose")},m(n,t){y(n,e,t)},p:Q,d(n){n&&w(e)}}}function Wd(r){let e,n,t;function i(s){r[1](s)}let o={title:"Instructions",$$slots:{default:[Xd]},$$scope:{ctx:r}};return r[0]!==void 0&&(o.open=r[0]),e=new Nt({props:o}),V.push(()=>x(e,"open",i)),{c(){P(e.$$.fragment)},m(s,a){L(e,s,a),t=!0},p(s,[a]){const l={};a&4&&(l.$$scope={dirty:a,ctx:s}),!n&&a&1&&(n=!0,l.open=s[0],ne(()=>n=!1)),e.$set(l)},i(s){t||(_(e.$$.fragment,s),t=!0)},o(s){$(e.$$.fragment,s),t=!1},d(s){F(e,s)}}}function Kd(r,e,n){let{open:t}=e;function i(o){t=o,n(0,t)}return r.$$set=o=>{"open"in o&&n(0,t=o.open)},[t,i]}class Hd extends re{constructor(e){super(),ie(this,e,Kd,Wd,te,{open:0})}}function Zd(r){let e;return{c(){e=D("Delete")},m(n,t){y(n,e,t)},d(n){n&&w(e)}}}function Vd(r){let e,n,t=r[0].interventionName(r[3])+"",i,o,s,a,l,u,f,c,p,m,g,v;s=new bt({props:{$$slots:{default:[Zd]},$$scope:{ctx:r}}}),s.$on("click",r[5]),l=new Ye({props:{errorMessage:r[0].interventionWarning(r[3])}});function S(h){r[6](h)}var k=r[0].editFeatureForm;function b(h,M){let d={cfg:h[0],gjSchemes:h[1],id:h[2]};return h[3].properties!==void 0&&(d.props=h[3].properties),{props:d}}return k&&(f=zt(k,b(r)),V.push(()=>x(f,"props",S))),{c(){e=q("h2"),n=D("Editing "),i=D(t),o=R(),P(s.$$.fragment),a=R(),P(l.$$.fragment),u=R(),f&&P(f.$$.fragment),p=ce()},m(h,M){y(h,e,M),G(e,n),G(e,i),y(h,o,M),L(s,h,M),y(h,a,M),L(l,h,M),y(h,u,M),f&&L(f,h,M),y(h,p,M),m=!0,g||(v=he(window,"keydown",r[4]),g=!0)},p(h,[M]){(!m||M&9)&&t!==(t=h[0].interventionName(h[3])+"")&&be(i,t);const d={};M&512&&(d.$$scope={dirty:M,ctx:h}),s.$set(d);const E={};if(M&9&&(E.errorMessage=h[0].interventionWarning(h[3])),l.$set(E),M&1&&k!==(k=h[0].editFeatureForm)){if(f){se();const N=f;$(N.$$.fragment,1,0,()=>{F(N,1)}),le()}k?(f=zt(k,b(h)),V.push(()=>x(f,"props",S)),P(f.$$.fragment),_(f.$$.fragment,1),L(f,p.parentNode,p)):f=null}else if(k){const N={};M&1&&(N.cfg=h[0]),M&2&&(N.gjSchemes=h[1]),M&4&&(N.id=h[2]),!c&&M&8&&(c=!0,N.props=h[3].properties,ne(()=>c=!1)),f.$set(N)}},i(h){m||(_(s.$$.fragment,h),_(l.$$.fragment,h),f&&_(f.$$.fragment,h),m=!0)},o(h){$(s.$$.fragment,h),$(l.$$.fragment,h),f&&$(f.$$.fragment,h),m=!1},d(h){h&&(w(e),w(o),w(a),w(u),w(p)),F(s,h),F(l,h),f&&F(f,h),g=!1,v()}}}function Qd(r,e,n){let t,i=Q,o=()=>(i(),i=We(a,g=>n(7,t=g)),a);r.$$.on_destroy.push(()=>i());let{cfg:s}=e,{gjSchemes:a}=e;o();let{id:l}=e,u=t.features.find(g=>g.id==l);function f(g){a.set(t)}function c(g){if(g.key=="Delete"){const v=g.target.tagName;if(v=="INPUT"||v=="TEXTAREA")return;g.stopPropagation(),oi(a,l)}}const p=()=>oi(a,l);function m(g){r.$$.not_equal(u.properties,g)&&(u.properties=g,n(3,u))}return r.$$set=g=>{"cfg"in g&&n(0,s=g.cfg),"gjSchemes"in g&&o(n(1,a=g.gjSchemes)),"id"in g&&n(2,l=g.id)},r.$$.update=()=>{r.$$.dirty&8&&f()},[s,a,l,u,c,p,m]}class xd extends re{constructor(e){super(),ie(this,e,Qd,Vd,te,{cfg:0,gjSchemes:1,id:2})}}const eg="/atip/move_draw_controls/assets/delete-3c023172.svg";function Ao(r,e,n){const t=r.slice();t[29]=e[n];const i=t[0].interventionWarning(t[29]);return t[30]=i,t}function tg(r){let e,n,t;return{c(){e=q("img"),t=D(` - Delete`),ot(e.src,n=eg)||J(e,"src",n),J(e,"alt","Delete scheme")},m(i,o){y(i,e,o),y(i,t,o)},p:Q,d(i){i&&(w(e),w(t))}}}function ng(r){let e;return{c(){e=D("Show")},m(n,t){y(n,e,t)},d(n){n&&w(e)}}}function rg(r){let e,n;return e=new Ye({props:{errorMessage:"There's a problem with "+r[8]+" interventions below"}}),{c(){P(e.$$.fragment)},m(t,i){L(e,t,i),n=!0},p(t,i){const o={};i[0]&256&&(o.errorMessage="There's a problem with "+t[8]+" interventions below"),e.$set(o)},i(t){n||(_(e.$$.fragment,t),n=!0)},o(t){$(e.$$.fragment,t),n=!1},d(t){F(e,t)}}}function ig(r){let e,n;return e=new Ye({props:{errorMessage:"There's a problem with one intervention below"}}),{c(){P(e.$$.fragment)},m(t,i){L(e,t,i),n=!0},p:Q,i(t){n||(_(e.$$.fragment,t),n=!0)},o(t){$(e.$$.fragment,t),n=!1},d(t){F(e,t)}}}function No(r){let e,n;return e=new Ho({props:{text:r[30]}}),{c(){P(e.$$.fragment)},m(t,i){L(e,t,i),n=!0},p(t,i){const o={};i[0]&13&&(o.text=t[30]),e.$set(o)},i(t){n||(_(e.$$.fragment,t),n=!0)},o(t){$(e.$$.fragment,t),n=!1},d(t){F(e,t)}}}function Ro(r,e){let n,t,i,o=e[0].interventionName(e[29])+"",s,a,l,u,f,c=e[30]&&No(e);function p(...v){return e[20](e[29],...v)}function m(){return e[21](e[29])}function g(){return e[22](e[29])}return{key:r,first:null,c(){n=q("li"),t=q("a"),c&&c.c(),i=R(),s=D(o),a=R(),J(t,"href","#"),this.first=n},m(v,S){y(v,n,S),G(n,t),c&&c.m(t,null),G(t,i),G(t,s),G(n,a),l=!0,u||(f=[he(t,"click",p),he(t,"mouseenter",m),he(t,"mouseleave",g)],u=!0)},p(v,S){e=v,e[30]?c?(c.p(e,S),S[0]&13&&_(c,1)):(c=No(e),c.c(),_(c,1),c.m(t,i)):c&&(se(),$(c,1,1,()=>{c=null}),le()),(!l||S[0]&13)&&o!==(o=e[0].interventionName(e[29])+"")&&be(s,o)},i(v){l||(_(c),l=!0)},o(v){$(c),l=!1},d(v){v&&w(n),c&&c.d(),u=!1,er(f)}}}function Oo(r){let e,n,t,i,o=r[7]==1?"intervention":"interventions",s,a,l,u,f,c;function p(g){r[23](g)}let m={label:"Move interventions to another scheme",choices:r[13]()};return r[5]!==void 0&&(m.value=r[5]),u=new rr({props:m}),V.push(()=>x(u,"value",p)),u.$on("change",r[12]),{c(){e=q("p"),n=D("Do you want to first move "),t=D(r[7]),i=R(),s=D(o),a=D(" to another scheme?"),l=R(),P(u.$$.fragment)},m(g,v){y(g,e,v),G(e,n),G(e,t),G(e,i),G(e,s),G(e,a),y(g,l,v),L(u,g,v),c=!0},p(g,v){(!c||v[0]&128)&&be(t,g[7]),(!c||v[0]&128)&&o!==(o=g[7]==1?"intervention":"interventions")&&be(s,o);const S={};!f&&v[0]&32&&(f=!0,S.value=g[5],ne(()=>f=!1)),u.$set(S)},i(g){c||(_(u.$$.fragment,g),c=!0)},o(g){$(u.$$.fragment,g),c=!1},d(g){g&&(w(e),w(l)),F(u,g)}}}function og(r){let e;return{c(){e=D("Delete scheme")},m(n,t){y(n,e,t)},d(n){n&&w(e)}}}function sg(r){let e;return{c(){e=D("Cancel")},m(n,t){y(n,e,t)},d(n){n&&w(e)}}}function lg(r){let e,n,t,i;return e=new bt({props:{$$slots:{default:[og]},$$scope:{ctx:r}}}),e.$on("click",r[11]),t=new _e({props:{$$slots:{default:[sg]},$$scope:{ctx:r}}}),t.$on("click",r[24]),{c(){P(e.$$.fragment),n=R(),P(t.$$.fragment)},m(o,s){L(e,o,s),y(o,n,s),L(t,o,s),i=!0},p(o,s){const a={};s[0]&67108864&&(a.$$scope={dirty:s,ctx:o}),e.$set(a);const l={};s[0]&67108864&&(l.$$scope={dirty:s,ctx:o}),t.$set(l)},i(o){i||(_(e.$$.fragment,o),_(t.$$.fragment,o),i=!0)},o(o){$(e.$$.fragment,o),$(t.$$.fragment,o),i=!1},d(o){o&&w(n),F(e,o),F(t,o)}}}function ag(r){let e=r[7]>0&&r[13]().length>0,n,t,i,o=e&&Oo(r);return t=new Ke({props:{$$slots:{default:[lg]},$$scope:{ctx:r}}}),{c(){o&&o.c(),n=R(),P(t.$$.fragment)},m(s,a){o&&o.m(s,a),y(s,n,a),L(t,s,a),i=!0},p(s,a){a[0]&128&&(e=s[7]>0&&s[13]().length>0),e?o?(o.p(s,a),a[0]&128&&_(o,1)):(o=Oo(s),o.c(),_(o,1),o.m(n.parentNode,n)):o&&(se(),$(o,1,1,()=>{o=null}),le());const l={};a[0]&67108880&&(l.$$scope={dirty:a,ctx:s}),t.$set(l)},i(s){i||(_(o),_(t.$$.fragment,s),i=!0)},o(s){$(o),$(t.$$.fragment,s),i=!1},d(s){s&&w(n),o&&o.d(s),F(t,s)}}}function ug(r){let e,n=r[0].schemeName(r[3].schemes[r[2]])+"",t,i,o,s,a,l,u,f,c,p,m,g,v,S,k,b,h=[],M=new Map,d,E,N,j,U,B;a=new bt({props:{$$slots:{default:[tg]},$$scope:{ctx:r}}}),a.$on("click",r[17]);function O(Y){r[18](Y)}let C={$$slots:{default:[ng]},$$scope:{ctx:r}};r[6]!==void 0&&(C.checked=r[6]),u=new Ft({props:C}),V.push(()=>x(u,"checked",O)),u.$on("change",r[14]);const A=r[15].default,I=Kt(A,r,r[26],null);var W=r[0].editSchemeForm;function z(Y,Z){return{props:{gjSchemes:Y[1],scheme_reference:Y[2]}}}W&&(m=zt(W,z(r)));const ee=[ig,rg],T=[];function fe(Y,Z){return Y[8]==1?0:Y[8]>0?1:-1}~(v=fe(r))&&(S=T[v]=ee[v](r));let me=Ie(r[3].features.filter(r[19]));const ve=Y=>Y[29].id;for(let Y=0;Yx(E,"open",$e)),{c(){e=q("h3"),t=D(n),i=R(),o=q("input"),s=R(),P(a.$$.fragment),l=R(),P(u.$$.fragment),c=R(),I&&I.c(),p=R(),m&&P(m.$$.fragment),g=R(),S&&S.c(),k=R(),b=q("ol");for(let Y=0;Yf=!1)),u.$set(H),I&&I.p&&(!j||Z[0]&67108864)&&Ht(I,A,Y,Y[26],j?Vt(A,Y[26],Z,null):Zt(Y[26]),null),Z[0]&1&&W!==(W=Y[0].editSchemeForm)){if(m){se();const Pe=m;$(Pe.$$.fragment,1,0,()=>{F(Pe,1)}),le()}W?(m=zt(W,z(Y)),P(m.$$.fragment),_(m.$$.fragment,1),L(m,g.parentNode,g)):m=null}else if(W){const Pe={};Z[0]&2&&(Pe.gjSchemes=Y[1]),Z[0]&4&&(Pe.scheme_reference=Y[2]),m.$set(Pe)}let ke=v;v=fe(Y),v===ke?~v&&T[v].p(Y,Z):(S&&(se(),$(T[ke],1,1,()=>{T[ke]=null}),le()),~v?(S=T[v],S?S.p(Y,Z):(S=T[v]=ee[v](Y),S.c()),_(S,1),S.m(k.parentNode,k)):S=null),Z[0]&1549&&(me=Ie(Y[3].features.filter(Y[19])),se(),h=Br(h,Z,ve,1,Y,me,M,b,qr,Ro,null,Ao),le());const It={};Z[0]&67109040&&(It.$$scope={dirty:Z,ctx:Y}),!N&&Z[0]&16&&(N=!0,It.open=Y[4],ne(()=>N=!1)),E.$set(It)},i(Y){if(!j){_(a.$$.fragment,Y),_(u.$$.fragment,Y),_(I,Y),m&&_(m.$$.fragment,Y),_(S);for(let Z=0;Z(a(),a=We(m,T=>n(3,s=T)),m),u;K(r,ln,T=>n(27,o=T)),K(r,xe,T=>n(28,u=T)),r.$$.on_destroy.push(()=>a());let{$$slots:f={},$$scope:c}=e,{cfg:p}=e,{gjSchemes:m}=e;l();let{scheme_reference:g}=e,v=!1;Xe(()=>{on.set(null)});function S(T,fe){T.preventDefault();let me=s.features.find(ve=>ve.id==fe);me.geometry.type=="Point"?u==null||u.flyTo({center:me.geometry.coordinates,duration:500}):u==null||u.fitBounds(Wo(me),{padding:200,duration:500}),pe.set({mode:"edit",id:fe})}function k(T){on.update(fe=>fe==T?null:fe)}function b(){m.update(T=>(T.features=T.features.filter(fe=>fe.properties.scheme_reference!=g),delete T.schemes[g],Object.keys(T.schemes).length==0&&(T=Tr(p)),T)),ln.update(T=>(T.delete(g),T)),n(4,v=!1)}let h="";function M(){h&&m.update(T=>{for(let fe of T.features)fe.properties.scheme_reference==g&&(fe.properties.scheme_reference=h);return T})}function d(){return Object.values(s.schemes).filter(T=>T.scheme_reference!=g).map(T=>[T.scheme_reference,p.schemeName(T)])}let E=!o.has(g);function N(){ln.update(T=>(E?T.delete(g):T.add(g),T))}function j(){s.schemes[g].color=this.value,m.set(s)}const U=()=>n(4,v=!0);function B(T){E=T,n(6,E)}const O=T=>T.properties.scheme_reference==g,C=(T,fe)=>S(fe,T.id),A=T=>on.set(T.id),I=T=>k(T.id);function W(T){h=T,n(5,h)}const z=()=>n(4,v=!1);function ee(T){v=T,n(4,v)}return r.$$set=T=>{"cfg"in T&&n(0,p=T.cfg),"gjSchemes"in T&&l(n(1,m=T.gjSchemes)),"scheme_reference"in T&&n(2,g=T.scheme_reference),"$$scope"in T&&n(26,c=T.$$scope)},r.$$.update=()=>{r.$$.dirty[0]&13&&n(8,t=s.features.filter(T=>T.properties.scheme_reference==g&&p.interventionWarning(T)!=null).length),r.$$.dirty[0]&12&&n(7,i=s.features.filter(T=>T.properties.scheme_reference==g).length)},[p,m,g,s,v,h,E,i,t,S,k,b,M,d,N,f,j,U,B,O,C,A,I,W,z,ee,c]}class cg extends re{constructor(e){super(),ie(this,e,fg,ug,te,{cfg:0,gjSchemes:1,scheme_reference:2},null,[-1,-1])}}function jo(r,e,n){const t=r.slice();return t[9]=e[n],t[11]=n,t}function pg(r){let e;return{c(){e=D("Add new blank scheme")},m(n,t){y(n,e,t)},d(n){n&&w(e)}}}function Io(r){let e,n,t,i;function o(){return r[7](r[9])}e=new _e({props:{disabled:r[11]==0,$$slots:{default:[mg]},$$scope:{ctx:r}}}),e.$on("click",o);function s(){return r[8](r[9])}return t=new _e({props:{disabled:r[11]==Object.keys(r[3].schemes).length-1,$$slots:{default:[dg]},$$scope:{ctx:r}}}),t.$on("click",s),{c(){P(e.$$.fragment),n=R(),P(t.$$.fragment)},m(a,l){L(e,a,l),y(a,n,l),L(t,a,l),i=!0},p(a,l){r=a;const u={};l&8&&(u.disabled=r[11]==0),l&4096&&(u.$$scope={dirty:l,ctx:r}),e.$set(u);const f={};l&8&&(f.disabled=r[11]==Object.keys(r[3].schemes).length-1),l&4096&&(f.$$scope={dirty:l,ctx:r}),t.$set(f)},i(a){i||(_(e.$$.fragment,a),_(t.$$.fragment,a),i=!0)},o(a){$(e.$$.fragment,a),$(t.$$.fragment,a),i=!1},d(a){a&&w(n),F(e,a),F(t,a)}}}function mg(r){let e;return{c(){e=D("Move up")},m(n,t){y(n,e,t)},d(n){n&&w(e)}}}function dg(r){let e;return{c(){e=D("Move down")},m(n,t){y(n,e,t)},d(n){n&&w(e)}}}function gg(r){let e=Object.keys(r[3].schemes).length>1,n,t,i=e&&Io(r);return{c(){i&&i.c(),n=ce()},m(o,s){i&&i.m(o,s),y(o,n,s),t=!0},p(o,s){s&8&&(e=Object.keys(o[3].schemes).length>1),e?i?(i.p(o,s),s&8&&_(i,1)):(i=Io(o),i.c(),_(i,1),i.m(n.parentNode,n)):i&&(se(),$(i,1,1,()=>{i=null}),le())},i(o){t||(_(i),t=!0)},o(o){$(i),t=!1},d(o){o&&w(n),i&&i.d(o)}}}function Bo(r,e){let n,t,i,o,s;return t=new cg({props:{cfg:e[0],gjSchemes:e[1],scheme_reference:e[9],$$slots:{default:[gg]},$$scope:{ctx:e}}}),{key:r,first:null,c(){n=ce(),P(t.$$.fragment),i=R(),o=q("hr"),this.first=n},m(a,l){y(a,n,l),L(t,a,l),y(a,i,l),y(a,o,l),s=!0},p(a,l){e=a;const u={};l&1&&(u.cfg=e[0]),l&2&&(u.gjSchemes=e[1]),l&8&&(u.scheme_reference=e[9]),l&4104&&(u.$$scope={dirty:l,ctx:e}),t.$set(u)},i(a){s||(_(t.$$.fragment,a),s=!0)},o(a){$(t.$$.fragment,a),s=!1},d(a){a&&(w(n),w(i),w(o)),F(t,a)}}}function hg(r){let e,n,t,i,o,s,a,l,u=[],f=new Map,c,p;e=new _e({props:{$$slots:{default:[pg]},$$scope:{ctx:r}}}),e.$on("click",r[4]),t=new Xo({props:{label:"Add scheme from file",onLoad:r[5]}}),o=new Ye({props:{errorMessage:r[2]}});let m=Ie(Object.keys(r[3].schemes));const g=v=>v[9];for(let v=0;v{n[t]=e[t]}),n}function vg(r,e,n){let t,i=Q,o=()=>(i(),i=We(a,g=>n(3,t=g)),a);r.$$.on_destroy.push(()=>i());let{cfg:s}=e,{gjSchemes:a}=e;o();function l(){kl(s,t),a.set(t)}let u="";function f(g,v){try{let S=s.backfill(JSON.parse(v));for(let b of Object.values(S.schemes)){if(b.scheme_reference in t.schemes)throw new Error("The file you're loading seems to contain duplicate data. Are you merging in the same file accidentally?");je(a,t.schemes[b.scheme_reference]=b,t)}je(a,t.features=t.features.concat(S.features),t);let k=1;t.features.forEach(b=>{b.id=k++}),a.set(t),n(2,u="")}catch(S){n(2,u=`Couldn't load scheme from a file: ${S}`)}}function c(g,v){const S=JSON.parse(JSON.stringify(Object.keys(t.schemes))),k=S.indexOf(g);if(k+v>=0&&k+vc(g,-1),m=g=>c(g,1);return r.$$set=g=>{"cfg"in g&&n(0,s=g.cfg),"gjSchemes"in g&&o(n(1,a=g.gjSchemes))},[s,a,u,t,l,f,c,p,m]}class $g extends re{constructor(e){super(),ie(this,e,vg,hg,te,{cfg:0,gjSchemes:1})}}function qo(r){let e,n,t,i,o,s,a,l,u,f,c,p,m,g,v,S,k,b;return e=new El({}),i=new Ml({}),v=new Ul({props:{boundaryGeojson:r[2]}}),k=new Ke({props:{$$slots:{default:[kg]},$$scope:{ctx:r}}}),{c(){P(e.$$.fragment),n=R(),t=q("div"),P(i.$$.fragment),o=R(),s=q("p"),s.textContent=`App version: ${Pl()}`,a=R(),l=q("div"),u=q("p"),u.textContent=`${r[12]()}`,f=R(),c=q("a"),p=D("Change area"),g=R(),P(v.$$.fragment),S=R(),P(k.$$.fragment),J(s,"class","svelte-1750ds5"),ge(t,"border-bottom","1px solid #b1b4b6"),J(t,"class","svelte-1750ds5"),J(u,"class","svelte-1750ds5"),J(c,"href",m=`index.html?schema=${r[4]}`),J(c,"class","svelte-1750ds5"),ge(l,"display","flex"),ge(l,"justify-content","space-between"),J(l,"class","svelte-1750ds5")},m(h,M){L(e,h,M),y(h,n,M),y(h,t,M),L(i,t,null),G(t,o),G(t,s),y(h,a,M),y(h,l,M),G(l,u),G(l,f),G(l,c),G(c,p),G(l,g),L(v,l,null),y(h,S,M),L(k,h,M),b=!0},p(h,M){(!b||M&16&&m!==(m=`index.html?schema=${h[4]}`))&&J(c,"href",m);const d={};M&4&&(d.boundaryGeojson=h[2]),v.$set(d);const E={};M&262144&&(E.$$scope={dirty:M,ctx:h}),k.$set(E)},i(h){b||(_(e.$$.fragment,h),_(i.$$.fragment,h),_(v.$$.fragment,h),_(k.$$.fragment,h),b=!0)},o(h){$(e.$$.fragment,h),$(i.$$.fragment,h),$(v.$$.fragment,h),$(k.$$.fragment,h),b=!1},d(h){h&&(w(n),w(t),w(a),w(l),w(S)),F(e,h),F(i),F(v),F(k,h)}}}function yg(r){let e;return{c(){e=D("About")},m(n,t){y(n,e,t)},d(n){n&&w(e)}}}function wg(r){let e;return{c(){e=D("Instructions")},m(n,t){y(n,e,t)},d(n){n&&w(e)}}}function kg(r){let e,n,t,i;return e=new _e({props:{$$slots:{default:[yg]},$$scope:{ctx:r}}}),e.$on("click",r[10]),t=new _e({props:{$$slots:{default:[wg]},$$scope:{ctx:r}}}),t.$on("click",r[11]),{c(){P(e.$$.fragment),n=R(),P(t.$$.fragment)},m(o,s){L(e,o,s),y(o,n,s),L(t,o,s),i=!0},p(o,s){const a={};s&262144&&(a.$$scope={dirty:s,ctx:o}),e.$set(a);const l={};s&262144&&(l.$$scope={dirty:s,ctx:o}),t.$set(l)},i(o){i||(_(e.$$.fragment,o),_(t.$$.fragment,o),i=!0)},o(o){$(e.$$.fragment,o),$(t.$$.fragment,o),i=!1},d(o){o&&w(n),F(e,o),F(t,o)}}}function Sg(r){let e,n;return e=new xd({props:{cfg:Ue,gjSchemes:r[7],id:r[3].id}}),{c(){P(e.$$.fragment)},m(t,i){L(e,t,i),n=!0},p(t,i){const o={};i&8&&(o.id=t[3].id),e.$set(o)},i(t){n||(_(e.$$.fragment,t),n=!0)},o(t){$(e.$$.fragment,t),n=!1},d(t){F(e,t)}}}function Eg(r){let e,n;return e=new Sf({props:{cfg:Ue,gjSchemes:r[7]}}),{c(){P(e.$$.fragment)},m(t,i){L(e,t,i),n=!0},p:Q,i(t){n||(_(e.$$.fragment,t),n=!0)},o(t){$(e.$$.fragment,t),n=!1},d(t){F(e,t)}}}function Mg(r){let e,n;return e=new $g({props:{cfg:Ue,gjSchemes:r[7]}}),{c(){P(e.$$.fragment)},m(t,i){L(e,t,i),n=!0},p:Q,i(t){n||(_(e.$$.fragment,t),n=!0)},o(t){$(e.$$.fragment,t),n=!1},d(t){F(e,t)}}}function Go(r){let e;return{c(){e=q("hr"),J(e,"class","svelte-1750ds5")},m(n,t){y(n,e,t)},d(n){n&&w(e)}}}function To(r){let e,n,t,i,o,s,a,l,u,f,c,p;return e=new xu({props:{cfg:Ue,boundaryGeojson:r[2]}}),t=new yf({props:{cfg:Ue,gjSchemes:r[7]}}),o=new sf({props:{cfg:Ue}}),a=new ym({props:{cfg:Ue,gjSchemes:r[7],routeSnapperUrl:r[9]}}),u=new Of({props:{cfg:Ue}}),c=new Lf({props:{cfg:Ue}}),{c(){P(e.$$.fragment),n=R(),P(t.$$.fragment),i=R(),P(o.$$.fragment),s=R(),P(a.$$.fragment),l=R(),P(u.$$.fragment),f=R(),P(c.$$.fragment)},m(m,g){L(e,m,g),y(m,n,g),L(t,m,g),y(m,i,g),L(o,m,g),y(m,s,g),L(a,m,g),y(m,l,g),L(u,m,g),y(m,f,g),L(c,m,g),p=!0},p(m,g){const v={};g&4&&(v.boundaryGeojson=m[2]),e.$set(v)},i(m){p||(_(e.$$.fragment,m),_(t.$$.fragment,m),_(o.$$.fragment,m),_(a.$$.fragment,m),_(u.$$.fragment,m),_(c.$$.fragment,m),p=!0)},o(m){$(e.$$.fragment,m),$(t.$$.fragment,m),$(o.$$.fragment,m),$(a.$$.fragment,m),$(u.$$.fragment,m),$(c.$$.fragment,m),p=!1},d(m){m&&(w(n),w(i),w(s),w(l),w(f)),F(e,m),F(t,m),F(o,m),F(a,m),F(u,m),F(c,m)}}}function Pg(r){let e,n,t,i;e=new Dl({props:{position:"top-right"}});let o=r[6]&&To(r);return{c(){P(e.$$.fragment),n=R(),o&&o.c(),t=ce()},m(s,a){L(e,s,a),y(s,n,a),o&&o.m(s,a),y(s,t,a),i=!0},p(s,a){s[6]?o?(o.p(s,a),a&64&&_(o,1)):(o=To(s),o.c(),_(o,1),o.m(t.parentNode,t)):o&&(se(),$(o,1,1,()=>{o=null}),le())},i(s){i||(_(e.$$.fragment,s),_(o),i=!0)},o(s){$(e.$$.fragment,s),$(o),i=!1},d(s){s&&(w(n),w(t)),F(e,s),o&&o.d(s)}}}function Lg(r){let e,n,t,i,o,s,a,l,u,f,c,p,m,g,v,S,k,b,h,M,d,E;t=new Gl({});let N=r[3].mode=="list"&&qo(r);s=new Yd({props:{cfg:Ue,gjSchemes:r[7],authorityName:r[8]}});const j=[Mg,Eg,Sg],U=[];function B(z,ee){return z[3].mode=="list"?0:z[3].mode=="new-point"||z[3].mode=="new-freehand-polygon"||z[3].mode=="new-snapped-polygon"||z[3].mode=="new-route"?1:z[3].mode=="edit"?2:-1}~(l=B(r))&&(u=U[l]=j[l](r));let O=r[3].mode!="list"&&Go();p=new Tl({}),v=new Sl({props:{style:r[5],$$slots:{default:[Pg]},$$scope:{ctx:r}}});function C(z){r[14](z)}let A={};r[0]!==void 0&&(A.open=r[0]),k=new zl({props:A}),V.push(()=>x(k,"open",C));function I(z){r[15](z)}let W={};return r[1]!==void 0&&(W.open=r[1]),M=new Hd({props:W}),V.push(()=>x(M,"open",I)),{c(){e=q("div"),n=q("div"),P(t.$$.fragment),i=R(),N&&N.c(),o=R(),P(s.$$.fragment),a=R(),u&&u.c(),f=R(),O&&O.c(),c=R(),P(p.$$.fragment),m=R(),g=q("div"),P(v.$$.fragment),S=R(),P(k.$$.fragment),h=R(),P(M.$$.fragment),J(n,"class","sidebar govuk-prose svelte-1750ds5"),J(g,"class","main svelte-1750ds5"),J(e,"class","overall-layout svelte-1750ds5")},m(z,ee){y(z,e,ee),G(e,n),L(t,n,null),G(n,i),N&&N.m(n,null),G(n,o),L(s,n,null),G(n,a),~l&&U[l].m(n,null),G(n,f),O&&O.m(n,null),G(n,c),L(p,n,null),G(e,m),G(e,g),L(v,g,null),y(z,S,ee),L(k,z,ee),y(z,h,ee),L(M,z,ee),E=!0},p(z,[ee]){z[3].mode=="list"?N?(N.p(z,ee),ee&8&&_(N,1)):(N=qo(z),N.c(),_(N,1),N.m(n,o)):N&&(se(),$(N,1,1,()=>{N=null}),le());let T=l;l=B(z),l===T?~l&&U[l].p(z,ee):(u&&(se(),$(U[T],1,1,()=>{U[T]=null}),le()),~l?(u=U[l],u?u.p(z,ee):(u=U[l]=j[l](z),u.c()),_(u,1),u.m(n,f)):u=null),z[3].mode!="list"?O||(O=Go(),O.c(),O.m(n,c)):O&&(O.d(1),O=null);const fe={};ee&32&&(fe.style=z[5]),ee&262212&&(fe.$$scope={dirty:ee,ctx:z}),v.$set(fe);const me={};!b&&ee&1&&(b=!0,me.open=z[0],ne(()=>b=!1)),k.$set(me);const ve={};!d&&ee&2&&(d=!0,ve.open=z[1],ne(()=>d=!1)),M.$set(ve)},i(z){E||(_(t.$$.fragment,z),_(N),_(s.$$.fragment,z),_(u),_(p.$$.fragment,z),_(v.$$.fragment,z),_(k.$$.fragment,z),_(M.$$.fragment,z),E=!0)},o(z){$(t.$$.fragment,z),$(N),$(s.$$.fragment,z),$(u),$(p.$$.fragment,z),$(v.$$.fragment,z),$(k.$$.fragment,z),$(M.$$.fragment,z),E=!1},d(z){z&&(w(e),w(S),w(h)),F(t),N&&N.d(),F(s),~l&&U[l].d(),O&&O.d(),F(p),F(v),F(k,z),F(M,z)}}}function Fg(r,e,n){let t,i,o,s,a;K(r,Cl,d=>n(13,t=d)),K(r,pe,d=>n(3,i=d)),K(r,Qe,d=>n(4,o=d)),K(r,hr,d=>n(5,s=d)),K(r,xe,d=>n(6,a=d));let l=at(Tr(Ue)),u=!1,f=!1,c=new URLSearchParams(window.location.search),p=c.get("authority");hr.set(c.get("style")||"streets");let m=`https://atip.uk/route-snappers/v3/${p}.bin.gz`;function g(){n(0,u=!u),n(1,f=!1)}function v(){n(1,f=!f),n(0,u=!1)}let S;rt(async()=>{Ll(),n(2,S=await k())});async function k(){let d=await Fl();return d.features=d.features.filter(E=>E.properties.full_name==p),d.features.length===0&&(window.location.href=`index.html?error=Authority name not found: ${p}`),d}function b(){let d=p.split("_");if(d.length==2){if(d[0]=="LAD")return`${d[1]} (LAD)`;if(d[0]=="TA")return`${d[1]} (Transport Authority)`}return p}function h(d){u=d,n(0,u)}function M(d){f=d,n(1,f)}return r.$$.update=()=>{r.$$.dirty&8192&&t&&xe.set(t)},[u,f,S,i,o,s,a,l,p,m,g,v,b,t,h,M]}class Cg extends re{constructor(e){super(),ie(this,e,Fg,Lg,te,{})}}document.body.className+=" js-enabled"+("noModule"in HTMLScriptElement.prototype?" govuk-frontend-supported":"");new Cg({target:document.getElementById("app")}); + to collaborate on designs.

    `,J(e,"class","govuk-prose")},m(n,t){y(n,e,t)},p:Q,d(n){n&&w(e)}}}function Wd(r){let e,n,t;function i(s){r[1](s)}let o={title:"Instructions",$$slots:{default:[Xd]},$$scope:{ctx:r}};return r[0]!==void 0&&(o.open=r[0]),e=new Nt({props:o}),V.push(()=>x(e,"open",i)),{c(){P(e.$$.fragment)},m(s,a){L(e,s,a),t=!0},p(s,[a]){const l={};a&4&&(l.$$scope={dirty:a,ctx:s}),!n&&a&1&&(n=!0,l.open=s[0],ne(()=>n=!1)),e.$set(l)},i(s){t||(b(e.$$.fragment,s),t=!0)},o(s){$(e.$$.fragment,s),t=!1},d(s){C(e,s)}}}function Kd(r,e,n){let{open:t}=e;function i(o){t=o,n(0,t)}return r.$$set=o=>{"open"in o&&n(0,t=o.open)},[t,i]}class Hd extends re{constructor(e){super(),ie(this,e,Kd,Wd,te,{open:0})}}function Zd(r){let e;return{c(){e=z("Delete")},m(n,t){y(n,e,t)},d(n){n&&w(e)}}}function Vd(r){let e,n,t=r[0].interventionName(r[4])+"",i,o,s,a,l,u,f,c,p,m,g,v;s=new bt({props:{$$slots:{default:[Zd]},$$scope:{ctx:r}}}),s.$on("click",r[6]),l=new Xe({props:{errorMessage:r[0].interventionWarning(r[4])}});function k(h){r[7](h)}var M=r[0].editFeatureForm;function _(h,E){let d={cfg:h[0],gjSchemes:h[1],id:h[2]};return h[3]!==void 0&&(d.props=h[3]),{props:d}}return M&&(f=zt(M,_(r)),V.push(()=>x(f,"props",k))),{c(){e=q("h2"),n=z("Editing "),i=z(t),o=R(),P(s.$$.fragment),a=R(),P(l.$$.fragment),u=R(),f&&P(f.$$.fragment),p=ce()},m(h,E){y(h,e,E),G(e,n),G(e,i),y(h,o,E),L(s,h,E),y(h,a,E),L(l,h,E),y(h,u,E),f&&L(f,h,E),y(h,p,E),m=!0,g||(v=he(window,"keydown",r[5]),g=!0)},p(h,[E]){(!m||E&1)&&t!==(t=h[0].interventionName(h[4])+"")&&be(i,t);const d={};E&512&&(d.$$scope={dirty:E,ctx:h}),s.$set(d);const S={};if(E&1&&(S.errorMessage=h[0].interventionWarning(h[4])),l.$set(S),E&1&&M!==(M=h[0].editFeatureForm)){if(f){se();const N=f;$(N.$$.fragment,1,0,()=>{C(N,1)}),le()}M?(f=zt(M,_(h)),V.push(()=>x(f,"props",k)),P(f.$$.fragment),b(f.$$.fragment,1),L(f,p.parentNode,p)):f=null}else if(M){const N={};E&1&&(N.cfg=h[0]),E&2&&(N.gjSchemes=h[1]),E&4&&(N.id=h[2]),!c&&E&8&&(c=!0,N.props=h[3],ne(()=>c=!1)),f.$set(N)}},i(h){m||(b(s.$$.fragment,h),b(l.$$.fragment,h),f&&b(f.$$.fragment,h),m=!0)},o(h){$(s.$$.fragment,h),$(l.$$.fragment,h),f&&$(f.$$.fragment,h),m=!1},d(h){h&&(w(e),w(o),w(a),w(u),w(p)),C(s,h),C(l,h),f&&C(f,h),g=!1,v()}}}function Qd(r,e,n){let t,i,o=Q,s=()=>(o(),o=Ke(l,g=>n(8,i=g)),l);W(r,Ge,g=>n(3,t=g)),r.$$.on_destroy.push(()=>o());let{cfg:a}=e,{gjSchemes:l}=e;s();let{id:u}=e,f=i.features.find(g=>g.id==u);Ne(Ge,t=JSON.parse(JSON.stringify(f.properties)),t);function c(g){if(g.key=="Delete"){const v=g.target.tagName;if(v=="INPUT"||v=="TEXTAREA")return;g.stopPropagation(),oi(l,u)}}const p=()=>oi(l,u);function m(g){t=g,Ge.set(t)}return r.$$set=g=>{"cfg"in g&&n(0,a=g.cfg),"gjSchemes"in g&&s(n(1,l=g.gjSchemes)),"id"in g&&n(2,u=g.id)},[a,l,u,t,f,c,p,m]}class xd extends re{constructor(e){super(),ie(this,e,Qd,Vd,te,{cfg:0,gjSchemes:1,id:2})}}const eg="/atip/move_draw_controls/assets/delete-3c023172.svg";function Ao(r,e,n){const t=r.slice();t[29]=e[n];const i=t[0].interventionWarning(t[29]);return t[30]=i,t}function tg(r){let e,n,t;return{c(){e=q("img"),t=z(` + Delete`),st(e.src,n=eg)||J(e,"src",n),J(e,"alt","Delete scheme")},m(i,o){y(i,e,o),y(i,t,o)},p:Q,d(i){i&&(w(e),w(t))}}}function ng(r){let e;return{c(){e=z("Show")},m(n,t){y(n,e,t)},d(n){n&&w(e)}}}function rg(r){let e,n;return e=new Xe({props:{errorMessage:"There's a problem with "+r[8]+" interventions below"}}),{c(){P(e.$$.fragment)},m(t,i){L(e,t,i),n=!0},p(t,i){const o={};i[0]&256&&(o.errorMessage="There's a problem with "+t[8]+" interventions below"),e.$set(o)},i(t){n||(b(e.$$.fragment,t),n=!0)},o(t){$(e.$$.fragment,t),n=!1},d(t){C(e,t)}}}function ig(r){let e,n;return e=new Xe({props:{errorMessage:"There's a problem with one intervention below"}}),{c(){P(e.$$.fragment)},m(t,i){L(e,t,i),n=!0},p:Q,i(t){n||(b(e.$$.fragment,t),n=!0)},o(t){$(e.$$.fragment,t),n=!1},d(t){C(e,t)}}}function No(r){let e,n;return e=new Ho({props:{text:r[30]}}),{c(){P(e.$$.fragment)},m(t,i){L(e,t,i),n=!0},p(t,i){const o={};i[0]&13&&(o.text=t[30]),e.$set(o)},i(t){n||(b(e.$$.fragment,t),n=!0)},o(t){$(e.$$.fragment,t),n=!1},d(t){C(e,t)}}}function Ro(r,e){let n,t,i,o=e[0].interventionName(e[29])+"",s,a,l,u,f,c=e[30]&&No(e);function p(...v){return e[20](e[29],...v)}function m(){return e[21](e[29])}function g(){return e[22](e[29])}return{key:r,first:null,c(){n=q("li"),t=q("a"),c&&c.c(),i=R(),s=z(o),a=R(),J(t,"href","#"),this.first=n},m(v,k){y(v,n,k),G(n,t),c&&c.m(t,null),G(t,i),G(t,s),G(n,a),l=!0,u||(f=[he(t,"click",p),he(t,"mouseenter",m),he(t,"mouseleave",g)],u=!0)},p(v,k){e=v,e[30]?c?(c.p(e,k),k[0]&13&&b(c,1)):(c=No(e),c.c(),b(c,1),c.m(t,i)):c&&(se(),$(c,1,1,()=>{c=null}),le()),(!l||k[0]&13)&&o!==(o=e[0].interventionName(e[29])+"")&&be(s,o)},i(v){l||(b(c),l=!0)},o(v){$(c),l=!1},d(v){v&&w(n),c&&c.d(),u=!1,er(f)}}}function Oo(r){let e,n,t,i,o=r[7]==1?"intervention":"interventions",s,a,l,u,f,c;function p(g){r[23](g)}let m={label:"Move interventions to another scheme",choices:r[13]()};return r[5]!==void 0&&(m.value=r[5]),u=new rr({props:m}),V.push(()=>x(u,"value",p)),u.$on("change",r[12]),{c(){e=q("p"),n=z("Do you want to first move "),t=z(r[7]),i=R(),s=z(o),a=z(" to another scheme?"),l=R(),P(u.$$.fragment)},m(g,v){y(g,e,v),G(e,n),G(e,t),G(e,i),G(e,s),G(e,a),y(g,l,v),L(u,g,v),c=!0},p(g,v){(!c||v[0]&128)&&be(t,g[7]),(!c||v[0]&128)&&o!==(o=g[7]==1?"intervention":"interventions")&&be(s,o);const k={};!f&&v[0]&32&&(f=!0,k.value=g[5],ne(()=>f=!1)),u.$set(k)},i(g){c||(b(u.$$.fragment,g),c=!0)},o(g){$(u.$$.fragment,g),c=!1},d(g){g&&(w(e),w(l)),C(u,g)}}}function og(r){let e;return{c(){e=z("Delete scheme")},m(n,t){y(n,e,t)},d(n){n&&w(e)}}}function sg(r){let e;return{c(){e=z("Cancel")},m(n,t){y(n,e,t)},d(n){n&&w(e)}}}function lg(r){let e,n,t,i;return e=new bt({props:{$$slots:{default:[og]},$$scope:{ctx:r}}}),e.$on("click",r[11]),t=new _e({props:{$$slots:{default:[sg]},$$scope:{ctx:r}}}),t.$on("click",r[24]),{c(){P(e.$$.fragment),n=R(),P(t.$$.fragment)},m(o,s){L(e,o,s),y(o,n,s),L(t,o,s),i=!0},p(o,s){const a={};s[0]&67108864&&(a.$$scope={dirty:s,ctx:o}),e.$set(a);const l={};s[0]&67108864&&(l.$$scope={dirty:s,ctx:o}),t.$set(l)},i(o){i||(b(e.$$.fragment,o),b(t.$$.fragment,o),i=!0)},o(o){$(e.$$.fragment,o),$(t.$$.fragment,o),i=!1},d(o){o&&w(n),C(e,o),C(t,o)}}}function ag(r){let e=r[7]>0&&r[13]().length>0,n,t,i,o=e&&Oo(r);return t=new He({props:{$$slots:{default:[lg]},$$scope:{ctx:r}}}),{c(){o&&o.c(),n=R(),P(t.$$.fragment)},m(s,a){o&&o.m(s,a),y(s,n,a),L(t,s,a),i=!0},p(s,a){a[0]&128&&(e=s[7]>0&&s[13]().length>0),e?o?(o.p(s,a),a[0]&128&&b(o,1)):(o=Oo(s),o.c(),b(o,1),o.m(n.parentNode,n)):o&&(se(),$(o,1,1,()=>{o=null}),le());const l={};a[0]&67108880&&(l.$$scope={dirty:a,ctx:s}),t.$set(l)},i(s){i||(b(o),b(t.$$.fragment,s),i=!0)},o(s){$(o),$(t.$$.fragment,s),i=!1},d(s){s&&w(n),o&&o.d(s),C(t,s)}}}function ug(r){let e,n=r[0].schemeName(r[3].schemes[r[2]])+"",t,i,o,s,a,l,u,f,c,p,m,g,v,k,M,_,h=[],E=new Map,d,S,N,j,U,B;a=new bt({props:{$$slots:{default:[tg]},$$scope:{ctx:r}}}),a.$on("click",r[17]);function O(Y){r[18](Y)}let F={$$slots:{default:[ng]},$$scope:{ctx:r}};r[6]!==void 0&&(F.checked=r[6]),u=new Ct({props:F}),V.push(()=>x(u,"checked",O)),u.$on("change",r[14]);const A=r[15].default,I=Kt(A,r,r[26],null);var K=r[0].editSchemeForm;function T(Y,Z){return{props:{gjSchemes:Y[1],scheme_reference:Y[2]}}}K&&(m=zt(K,T(r)));const ee=[ig,rg],D=[];function fe(Y,Z){return Y[8]==1?0:Y[8]>0?1:-1}~(v=fe(r))&&(k=D[v]=ee[v](r));let me=Ie(r[3].features.filter(r[19]));const ve=Y=>Y[29].id;for(let Y=0;Yx(S,"open",$e)),{c(){e=q("h3"),t=z(n),i=R(),o=q("input"),s=R(),P(a.$$.fragment),l=R(),P(u.$$.fragment),c=R(),I&&I.c(),p=R(),m&&P(m.$$.fragment),g=R(),k&&k.c(),M=R(),_=q("ol");for(let Y=0;Yf=!1)),u.$set(H),I&&I.p&&(!j||Z[0]&67108864)&&Ht(I,A,Y,Y[26],j?Vt(A,Y[26],Z,null):Zt(Y[26]),null),Z[0]&1&&K!==(K=Y[0].editSchemeForm)){if(m){se();const Pe=m;$(Pe.$$.fragment,1,0,()=>{C(Pe,1)}),le()}K?(m=zt(K,T(Y)),P(m.$$.fragment),b(m.$$.fragment,1),L(m,g.parentNode,g)):m=null}else if(K){const Pe={};Z[0]&2&&(Pe.gjSchemes=Y[1]),Z[0]&4&&(Pe.scheme_reference=Y[2]),m.$set(Pe)}let ke=v;v=fe(Y),v===ke?~v&&D[v].p(Y,Z):(k&&(se(),$(D[ke],1,1,()=>{D[ke]=null}),le()),~v?(k=D[v],k?k.p(Y,Z):(k=D[v]=ee[v](Y),k.c()),b(k,1),k.m(M.parentNode,M)):k=null),Z[0]&1549&&(me=Ie(Y[3].features.filter(Y[19])),se(),h=Br(h,Z,ve,1,Y,me,E,_,qr,Ro,null,Ao),le());const It={};Z[0]&67109040&&(It.$$scope={dirty:Z,ctx:Y}),!N&&Z[0]&16&&(N=!0,It.open=Y[4],ne(()=>N=!1)),S.$set(It)},i(Y){if(!j){b(a.$$.fragment,Y),b(u.$$.fragment,Y),b(I,Y),m&&b(m.$$.fragment,Y),b(k);for(let Z=0;Z(a(),a=Ke(m,D=>n(3,s=D)),m),u;W(r,ln,D=>n(27,o=D)),W(r,et,D=>n(28,u=D)),r.$$.on_destroy.push(()=>a());let{$$slots:f={},$$scope:c}=e,{cfg:p}=e,{gjSchemes:m}=e;l();let{scheme_reference:g}=e,v=!1;We(()=>{on.set(null)});function k(D,fe){D.preventDefault();let me=s.features.find(ve=>ve.id==fe);me.geometry.type=="Point"?u==null||u.flyTo({center:me.geometry.coordinates,duration:500}):u==null||u.fitBounds(Wo(me),{padding:200,duration:500}),pe.set({mode:"edit",id:fe})}function M(D){on.update(fe=>fe==D?null:fe)}function _(){m.update(D=>(D.features=D.features.filter(fe=>fe.properties.scheme_reference!=g),delete D.schemes[g],Object.keys(D.schemes).length==0&&(D=Tr(p)),D)),ln.update(D=>(D.delete(g),D)),n(4,v=!1)}let h="";function E(){h&&m.update(D=>{for(let fe of D.features)fe.properties.scheme_reference==g&&(fe.properties.scheme_reference=h);return D})}function d(){return Object.values(s.schemes).filter(D=>D.scheme_reference!=g).map(D=>[D.scheme_reference,p.schemeName(D)])}let S=!o.has(g);function N(){ln.update(D=>(S?D.delete(g):D.add(g),D))}function j(){s.schemes[g].color=this.value,m.set(s)}const U=()=>n(4,v=!0);function B(D){S=D,n(6,S)}const O=D=>D.properties.scheme_reference==g,F=(D,fe)=>k(fe,D.id),A=D=>on.set(D.id),I=D=>M(D.id);function K(D){h=D,n(5,h)}const T=()=>n(4,v=!1);function ee(D){v=D,n(4,v)}return r.$$set=D=>{"cfg"in D&&n(0,p=D.cfg),"gjSchemes"in D&&l(n(1,m=D.gjSchemes)),"scheme_reference"in D&&n(2,g=D.scheme_reference),"$$scope"in D&&n(26,c=D.$$scope)},r.$$.update=()=>{r.$$.dirty[0]&13&&n(8,t=s.features.filter(D=>D.properties.scheme_reference==g&&p.interventionWarning(D)!=null).length),r.$$.dirty[0]&12&&n(7,i=s.features.filter(D=>D.properties.scheme_reference==g).length)},[p,m,g,s,v,h,S,i,t,k,M,_,E,d,N,f,j,U,B,O,F,A,I,K,T,ee,c]}class cg extends re{constructor(e){super(),ie(this,e,fg,ug,te,{cfg:0,gjSchemes:1,scheme_reference:2},null,[-1,-1])}}function jo(r,e,n){const t=r.slice();return t[9]=e[n],t[11]=n,t}function pg(r){let e;return{c(){e=z("Add new blank scheme")},m(n,t){y(n,e,t)},d(n){n&&w(e)}}}function Io(r){let e,n,t,i;function o(){return r[7](r[9])}e=new _e({props:{disabled:r[11]==0,$$slots:{default:[mg]},$$scope:{ctx:r}}}),e.$on("click",o);function s(){return r[8](r[9])}return t=new _e({props:{disabled:r[11]==Object.keys(r[3].schemes).length-1,$$slots:{default:[dg]},$$scope:{ctx:r}}}),t.$on("click",s),{c(){P(e.$$.fragment),n=R(),P(t.$$.fragment)},m(a,l){L(e,a,l),y(a,n,l),L(t,a,l),i=!0},p(a,l){r=a;const u={};l&8&&(u.disabled=r[11]==0),l&4096&&(u.$$scope={dirty:l,ctx:r}),e.$set(u);const f={};l&8&&(f.disabled=r[11]==Object.keys(r[3].schemes).length-1),l&4096&&(f.$$scope={dirty:l,ctx:r}),t.$set(f)},i(a){i||(b(e.$$.fragment,a),b(t.$$.fragment,a),i=!0)},o(a){$(e.$$.fragment,a),$(t.$$.fragment,a),i=!1},d(a){a&&w(n),C(e,a),C(t,a)}}}function mg(r){let e;return{c(){e=z("Move up")},m(n,t){y(n,e,t)},d(n){n&&w(e)}}}function dg(r){let e;return{c(){e=z("Move down")},m(n,t){y(n,e,t)},d(n){n&&w(e)}}}function gg(r){let e=Object.keys(r[3].schemes).length>1,n,t,i=e&&Io(r);return{c(){i&&i.c(),n=ce()},m(o,s){i&&i.m(o,s),y(o,n,s),t=!0},p(o,s){s&8&&(e=Object.keys(o[3].schemes).length>1),e?i?(i.p(o,s),s&8&&b(i,1)):(i=Io(o),i.c(),b(i,1),i.m(n.parentNode,n)):i&&(se(),$(i,1,1,()=>{i=null}),le())},i(o){t||(b(i),t=!0)},o(o){$(i),t=!1},d(o){o&&w(n),i&&i.d(o)}}}function Bo(r,e){let n,t,i,o,s;return t=new cg({props:{cfg:e[0],gjSchemes:e[1],scheme_reference:e[9],$$slots:{default:[gg]},$$scope:{ctx:e}}}),{key:r,first:null,c(){n=ce(),P(t.$$.fragment),i=R(),o=q("hr"),this.first=n},m(a,l){y(a,n,l),L(t,a,l),y(a,i,l),y(a,o,l),s=!0},p(a,l){e=a;const u={};l&1&&(u.cfg=e[0]),l&2&&(u.gjSchemes=e[1]),l&8&&(u.scheme_reference=e[9]),l&4104&&(u.$$scope={dirty:l,ctx:e}),t.$set(u)},i(a){s||(b(t.$$.fragment,a),s=!0)},o(a){$(t.$$.fragment,a),s=!1},d(a){a&&(w(n),w(i),w(o)),C(t,a)}}}function hg(r){let e,n,t,i,o,s,a,l,u=[],f=new Map,c,p;e=new _e({props:{$$slots:{default:[pg]},$$scope:{ctx:r}}}),e.$on("click",r[4]),t=new Xo({props:{label:"Add scheme from file",onLoad:r[5]}}),o=new Xe({props:{errorMessage:r[2]}});let m=Ie(Object.keys(r[3].schemes));const g=v=>v[9];for(let v=0;v{n[t]=e[t]}),n}function vg(r,e,n){let t,i=Q,o=()=>(i(),i=Ke(a,g=>n(3,t=g)),a);r.$$.on_destroy.push(()=>i());let{cfg:s}=e,{gjSchemes:a}=e;o();function l(){kl(s,t),a.set(t)}let u="";function f(g,v){try{let k=s.backfill(JSON.parse(v));for(let _ of Object.values(k.schemes)){if(_.scheme_reference in t.schemes)throw new Error("The file you're loading seems to contain duplicate data. Are you merging in the same file accidentally?");Ne(a,t.schemes[_.scheme_reference]=_,t)}Ne(a,t.features=t.features.concat(k.features),t);let M=1;t.features.forEach(_=>{_.id=M++}),a.set(t),n(2,u="")}catch(k){n(2,u=`Couldn't load scheme from a file: ${k}`)}}function c(g,v){const k=JSON.parse(JSON.stringify(Object.keys(t.schemes))),M=k.indexOf(g);if(M+v>=0&&M+vc(g,-1),m=g=>c(g,1);return r.$$set=g=>{"cfg"in g&&n(0,s=g.cfg),"gjSchemes"in g&&o(n(1,a=g.gjSchemes))},[s,a,u,t,l,f,c,p,m]}class $g extends re{constructor(e){super(),ie(this,e,vg,hg,te,{cfg:0,gjSchemes:1})}}function qo(r){let e,n,t,i,o,s,a,l,u,f,c,p,m,g,v,k,M,_;return e=new El({}),i=new Ml({}),v=new Dl({props:{boundaryGeojson:r[2]}}),M=new He({props:{$$slots:{default:[kg]},$$scope:{ctx:r}}}),{c(){P(e.$$.fragment),n=R(),t=q("div"),P(i.$$.fragment),o=R(),s=q("p"),s.textContent=`App version: ${Pl()}`,a=R(),l=q("div"),u=q("p"),u.textContent=`${r[12]()}`,f=R(),c=q("a"),p=z("Change area"),g=R(),P(v.$$.fragment),k=R(),P(M.$$.fragment),J(s,"class","svelte-1750ds5"),ge(t,"border-bottom","1px solid #b1b4b6"),J(t,"class","svelte-1750ds5"),J(u,"class","svelte-1750ds5"),J(c,"href",m=`index.html?schema=${r[4]}`),J(c,"class","svelte-1750ds5"),ge(l,"display","flex"),ge(l,"justify-content","space-between"),J(l,"class","svelte-1750ds5")},m(h,E){L(e,h,E),y(h,n,E),y(h,t,E),L(i,t,null),G(t,o),G(t,s),y(h,a,E),y(h,l,E),G(l,u),G(l,f),G(l,c),G(c,p),G(l,g),L(v,l,null),y(h,k,E),L(M,h,E),_=!0},p(h,E){(!_||E&16&&m!==(m=`index.html?schema=${h[4]}`))&&J(c,"href",m);const d={};E&4&&(d.boundaryGeojson=h[2]),v.$set(d);const S={};E&262144&&(S.$$scope={dirty:E,ctx:h}),M.$set(S)},i(h){_||(b(e.$$.fragment,h),b(i.$$.fragment,h),b(v.$$.fragment,h),b(M.$$.fragment,h),_=!0)},o(h){$(e.$$.fragment,h),$(i.$$.fragment,h),$(v.$$.fragment,h),$(M.$$.fragment,h),_=!1},d(h){h&&(w(n),w(t),w(a),w(l),w(k)),C(e,h),C(i),C(v),C(M,h)}}}function yg(r){let e;return{c(){e=z("About")},m(n,t){y(n,e,t)},d(n){n&&w(e)}}}function wg(r){let e;return{c(){e=z("Instructions")},m(n,t){y(n,e,t)},d(n){n&&w(e)}}}function kg(r){let e,n,t,i;return e=new _e({props:{$$slots:{default:[yg]},$$scope:{ctx:r}}}),e.$on("click",r[10]),t=new _e({props:{$$slots:{default:[wg]},$$scope:{ctx:r}}}),t.$on("click",r[11]),{c(){P(e.$$.fragment),n=R(),P(t.$$.fragment)},m(o,s){L(e,o,s),y(o,n,s),L(t,o,s),i=!0},p(o,s){const a={};s&262144&&(a.$$scope={dirty:s,ctx:o}),e.$set(a);const l={};s&262144&&(l.$$scope={dirty:s,ctx:o}),t.$set(l)},i(o){i||(b(e.$$.fragment,o),b(t.$$.fragment,o),i=!0)},o(o){$(e.$$.fragment,o),$(t.$$.fragment,o),i=!1},d(o){o&&w(n),C(e,o),C(t,o)}}}function Sg(r){let e,n;return e=new xd({props:{cfg:Ue,gjSchemes:r[7],id:r[3].id}}),{c(){P(e.$$.fragment)},m(t,i){L(e,t,i),n=!0},p(t,i){const o={};i&8&&(o.id=t[3].id),e.$set(o)},i(t){n||(b(e.$$.fragment,t),n=!0)},o(t){$(e.$$.fragment,t),n=!1},d(t){C(e,t)}}}function Eg(r){let e,n;return e=new Sf({props:{cfg:Ue,gjSchemes:r[7]}}),{c(){P(e.$$.fragment)},m(t,i){L(e,t,i),n=!0},p:Q,i(t){n||(b(e.$$.fragment,t),n=!0)},o(t){$(e.$$.fragment,t),n=!1},d(t){C(e,t)}}}function Mg(r){let e,n;return e=new $g({props:{cfg:Ue,gjSchemes:r[7]}}),{c(){P(e.$$.fragment)},m(t,i){L(e,t,i),n=!0},p:Q,i(t){n||(b(e.$$.fragment,t),n=!0)},o(t){$(e.$$.fragment,t),n=!1},d(t){C(e,t)}}}function Go(r){let e;return{c(){e=q("hr"),J(e,"class","svelte-1750ds5")},m(n,t){y(n,e,t)},d(n){n&&w(e)}}}function To(r){let e,n,t,i,o,s,a,l,u,f,c,p;return e=new xu({props:{cfg:Ue,boundaryGeojson:r[2]}}),t=new yf({props:{cfg:Ue,gjSchemes:r[7]}}),o=new sf({props:{cfg:Ue}}),a=new ym({props:{cfg:Ue,gjSchemes:r[7],routeSnapperUrl:r[9]}}),u=new Of({props:{cfg:Ue}}),c=new Lf({props:{cfg:Ue}}),{c(){P(e.$$.fragment),n=R(),P(t.$$.fragment),i=R(),P(o.$$.fragment),s=R(),P(a.$$.fragment),l=R(),P(u.$$.fragment),f=R(),P(c.$$.fragment)},m(m,g){L(e,m,g),y(m,n,g),L(t,m,g),y(m,i,g),L(o,m,g),y(m,s,g),L(a,m,g),y(m,l,g),L(u,m,g),y(m,f,g),L(c,m,g),p=!0},p(m,g){const v={};g&4&&(v.boundaryGeojson=m[2]),e.$set(v)},i(m){p||(b(e.$$.fragment,m),b(t.$$.fragment,m),b(o.$$.fragment,m),b(a.$$.fragment,m),b(u.$$.fragment,m),b(c.$$.fragment,m),p=!0)},o(m){$(e.$$.fragment,m),$(t.$$.fragment,m),$(o.$$.fragment,m),$(a.$$.fragment,m),$(u.$$.fragment,m),$(c.$$.fragment,m),p=!1},d(m){m&&(w(n),w(i),w(s),w(l),w(f)),C(e,m),C(t,m),C(o,m),C(a,m),C(u,m),C(c,m)}}}function Pg(r){let e,n,t,i;e=new Ul({props:{position:"top-right"}});let o=r[6]&&To(r);return{c(){P(e.$$.fragment),n=R(),o&&o.c(),t=ce()},m(s,a){L(e,s,a),y(s,n,a),o&&o.m(s,a),y(s,t,a),i=!0},p(s,a){s[6]?o?(o.p(s,a),a&64&&b(o,1)):(o=To(s),o.c(),b(o,1),o.m(t.parentNode,t)):o&&(se(),$(o,1,1,()=>{o=null}),le())},i(s){i||(b(e.$$.fragment,s),b(o),i=!0)},o(s){$(e.$$.fragment,s),$(o),i=!1},d(s){s&&(w(n),w(t)),C(e,s),o&&o.d(s)}}}function Lg(r){let e,n,t,i,o,s,a,l,u,f,c,p,m,g,v,k,M,_,h,E,d,S;t=new Gl({});let N=(r[3].mode=="list"||r[3].mode=="split-route"||r[3].mode=="set-image"||r[3].mode=="streetview")&&qo(r);s=new Yd({props:{cfg:Ue,gjSchemes:r[7],authorityName:r[8]}});const j=[Mg,Eg,Sg],U=[];function B(T,ee){return T[3].mode=="list"||T[3].mode=="split-route"||T[3].mode=="set-image"||T[3].mode=="streetview"?0:T[3].mode=="new-point"||T[3].mode=="new-freehand-polygon"||T[3].mode=="new-snapped-polygon"||T[3].mode=="new-route"?1:T[3].mode=="edit"?2:-1}~(l=B(r))&&(u=U[l]=j[l](r));let O=r[3].mode!="list"&&Go();p=new Tl({}),v=new Sl({props:{style:r[5],$$slots:{default:[Pg]},$$scope:{ctx:r}}});function F(T){r[14](T)}let A={};r[0]!==void 0&&(A.open=r[0]),M=new zl({props:A}),V.push(()=>x(M,"open",F));function I(T){r[15](T)}let K={};return r[1]!==void 0&&(K.open=r[1]),E=new Hd({props:K}),V.push(()=>x(E,"open",I)),{c(){e=q("div"),n=q("div"),P(t.$$.fragment),i=R(),N&&N.c(),o=R(),P(s.$$.fragment),a=R(),u&&u.c(),f=R(),O&&O.c(),c=R(),P(p.$$.fragment),m=R(),g=q("div"),P(v.$$.fragment),k=R(),P(M.$$.fragment),h=R(),P(E.$$.fragment),J(n,"class","sidebar govuk-prose svelte-1750ds5"),J(g,"class","main svelte-1750ds5"),J(e,"class","overall-layout svelte-1750ds5")},m(T,ee){y(T,e,ee),G(e,n),L(t,n,null),G(n,i),N&&N.m(n,null),G(n,o),L(s,n,null),G(n,a),~l&&U[l].m(n,null),G(n,f),O&&O.m(n,null),G(n,c),L(p,n,null),G(e,m),G(e,g),L(v,g,null),y(T,k,ee),L(M,T,ee),y(T,h,ee),L(E,T,ee),S=!0},p(T,[ee]){T[3].mode=="list"||T[3].mode=="split-route"||T[3].mode=="set-image"||T[3].mode=="streetview"?N?(N.p(T,ee),ee&8&&b(N,1)):(N=qo(T),N.c(),b(N,1),N.m(n,o)):N&&(se(),$(N,1,1,()=>{N=null}),le());let D=l;l=B(T),l===D?~l&&U[l].p(T,ee):(u&&(se(),$(U[D],1,1,()=>{U[D]=null}),le()),~l?(u=U[l],u?u.p(T,ee):(u=U[l]=j[l](T),u.c()),b(u,1),u.m(n,f)):u=null),T[3].mode!="list"?O||(O=Go(),O.c(),O.m(n,c)):O&&(O.d(1),O=null);const fe={};ee&32&&(fe.style=T[5]),ee&262212&&(fe.$$scope={dirty:ee,ctx:T}),v.$set(fe);const me={};!_&&ee&1&&(_=!0,me.open=T[0],ne(()=>_=!1)),M.$set(me);const ve={};!d&&ee&2&&(d=!0,ve.open=T[1],ne(()=>d=!1)),E.$set(ve)},i(T){S||(b(t.$$.fragment,T),b(N),b(s.$$.fragment,T),b(u),b(p.$$.fragment,T),b(v.$$.fragment,T),b(M.$$.fragment,T),b(E.$$.fragment,T),S=!0)},o(T){$(t.$$.fragment,T),$(N),$(s.$$.fragment,T),$(u),$(p.$$.fragment,T),$(v.$$.fragment,T),$(M.$$.fragment,T),$(E.$$.fragment,T),S=!1},d(T){T&&(w(e),w(k),w(h)),C(t),N&&N.d(),C(s),~l&&U[l].d(),O&&O.d(),C(p),C(v),C(M,T),C(E,T)}}}function Cg(r,e,n){let t,i,o,s,a;W(r,Fl,d=>n(13,t=d)),W(r,pe,d=>n(3,i=d)),W(r,xe,d=>n(4,o=d)),W(r,hr,d=>n(5,s=d)),W(r,et,d=>n(6,a=d));let l=ut(Tr(Ue)),u=!1,f=!1,c=new URLSearchParams(window.location.search),p=c.get("authority");hr.set(c.get("style")||"streets");let m=`https://atip.uk/route-snappers/v3/${p}.bin.gz`;function g(){n(0,u=!u),n(1,f=!1)}function v(){n(1,f=!f),n(0,u=!1)}let k;it(async()=>{Ll(),n(2,k=await M())});async function M(){let d=await Cl();return d.features=d.features.filter(S=>S.properties.full_name==p),d.features.length===0&&(window.location.href=`index.html?error=Authority name not found: ${p}`),d}function _(){let d=p.split("_");if(d.length==2){if(d[0]=="LAD")return`${d[1]} (LAD)`;if(d[0]=="TA")return`${d[1]} (Transport Authority)`}return p}function h(d){u=d,n(0,u)}function E(d){f=d,n(1,f)}return r.$$.update=()=>{r.$$.dirty&8192&&t&&et.set(t)},[u,f,k,i,o,s,a,l,p,m,g,v,_,t,h,E]}class Fg extends re{constructor(e){super(),ie(this,e,Cg,Lg,te,{})}}document.body.className+=" js-enabled"+("noModule"in HTMLScriptElement.prototype?" govuk-frontend-supported":"");new Fg({target:document.getElementById("app")}); diff --git a/move_draw_controls/scheme.html b/move_draw_controls/scheme.html index 482db063..9f10eb66 100644 --- a/move_draw_controls/scheme.html +++ b/move_draw_controls/scheme.html @@ -7,7 +7,7 @@ content="initial-scale=1,maximum-scale=1,user-scalable=no" /> ATIP v2 Scheme Sketcher - +