import{S as t,i as e,a as n,b as o,s as i,q as a,n as r,g as s,u as l,o as m,j as c,e as u,c as p,d,v as f,w as g,f as h,l as b,r as w}from"./index-6a7bc1e2.js";import{w as y}from"./index-4da4d0ce.js";import{getData as v,loadLocaleContent as x,sendData as k}from"../../../../../../../../../js/libraries/serverTools.js";import{addMarkersEntries as j,translate as S}from"../../../../../../../../../js/libraries/mapTools.js";import"../../../../../../../../../js/components/map-component.js";import"../../../../../../../../../js/components/select-component.js";function z(t){let e,n,i,a,r,l,m,c,y,v,x,k,j,L,S,z,C,T,N,O,H,M,A,$,q,E,J,U,D,I,R,G,K,P,Q,V,Y,_,B,F,W,X,Z;return{c(){e=u("div"),n=u("div"),i=u("h1"),i.textContent="Add a Commune",a=p(),r=u("img"),m=p(),c=u("p"),c.textContent="If there are no communes near you who you can join and you want to start your own then do the following:",y=p(),v=u("ol"),v.innerHTML="
Click on the map to show us where you are located; \n Add a way to contact you or leave blank for a pin to point to our discord; \n Press "Submit" to add yourself to our map; \n Verify yourself by having a chat with us at our Discord server to show on the map;",x=p(),k=u("div"),j=u("label"),j.textContent="Location:",L=p(),S=u("div"),z=u("input"),C=p(),T=u("div"),N=p(),O=u("div"),H=u("label"),H.textContent="Contact:",M=p(),A=u("div"),$=u("input"),q=p(),E=u("div"),J=p(),U=u("div"),D=u("label"),D.textContent="Status:",I=p(),R=u("div"),G=u("select-component"),K=p(),P=u("div"),Q=p(),V=u("button"),V.textContent="Submit",Y=p(),_=u("p"),B=p(),F=u("map-component"),d(r,"id","communes-img"),f(r.src,l="/img/common/communes.svg")||d(r,"src","/img/common/communes.svg"),d(r,"alt","communes"),d(c,"class","description"),d(j,"for","address-input"),d(z,"id","address-input"),d(z,"type","text"),z.readOnly=!0,d(T,"class","ghost-input"),d(S,"class","input-wrapper"),d(k,"id","address-input-wrapper"),d(k,"class","input-label-wrapper"),d(H,"for","contact-input"),d($,"id","contact-input"),d($,"type","text"),d(E,"class","ghost-input"),d(A,"class","input-wrapper"),d(O,"class","input-label-wrapper"),d(D,"for","contact-input"),g(G,"id","status-input"),g(G,"options",["forming","growing","not growing"]),d(P,"class","ghost-input"),d(R,"class","input-wrapper"),d(U,"id","status-input-wrapper"),d(U,"class","input-label-wrapper"),d(V,"id","submit-button"),d(_,"id","confirmation-msg"),g(F,"id","map"),g(F,"callback",W=t[17]),d(n,"id","text-container"),d(e,"id","container")},m(s,l){o(s,e,l),h(e,n),h(n,i),h(n,a),h(n,r),h(n,m),h(n,c),h(n,y),h(n,v),h(n,x),h(n,k),h(k,j),h(k,L),h(k,S),h(S,z),t[11](z),h(S,C),h(S,T),h(n,N),h(n,O),h(O,H),h(O,M),h(O,A),h(A,$),t[13]($),h(A,q),h(A,E),h(n,J),h(n,U),h(U,D),h(U,I),h(U,R),h(R,G),t[15](G),h(R,K),h(R,P),h(n,Q),h(n,V),h(n,Y),h(n,_),t[16](_),h(n,B),h(n,F),X||(Z=[b(z,"input",t[12]),b($,"input",t[14]),b(V,"click",t[10])],X=!0)},p(t,e){32&e&&W!==(W=t[17])&&g(F,"callback",W)},d(n){n&&s(e),t[11](null),t[13](null),t[15](null),t[16](null),X=!1,w(Z)}}}function C(t){let e,n=3==t[4]&&z(t);return{c(){n&&n.c(),e=a()},m(t,i){n&&n.m(t,i),o(t,e,i)},p(t,o){3==t[4]?n?n.p(t,o):(n=z(t),n.c(),n.m(e.parentNode,e)):n&&(n.d(1),n=null)},d(t){n&&n.d(t),t&&s(e)}}}function T(t){let e,n=t[4],l=C(t);return{c(){l.c(),e=a(),this.c=r},m(t,n){l.m(t,n),o(t,e,n)},p(t,[o]){16&o&&i(n,n=t[4])?(l.d(1),l=C(t),l.c(),l.m(e.parentNode,e)):l.p(t,o)},i:r,o:r,d(t){t&&s(e),l.d(t)}}}function N(t){t.nextElementSibling.innerHTML=t.value}function O(t,e,n){let o,i,a=y(0);l(t,a,(t=>n(4,o=t)));let r,s,u=y({});l(t,u,(t=>n(5,i=t)));let p,d,f,g,h;v("/assets/communes.json",(t=>{r=JSON.parse(t),s={};for(let t of r){let e=t.country;null==t.contact&&(t.contact="https://discord.gg/Qk8KUk787z"),e in s?s[e].push(t):s[e]=[t]}a.update((t=>t+1))}));let b=0,w=0,z=function(t,e){let n=new L.Icon({iconUrl:"/img/common/markers/marker-black.png",shadowUrl:"https://cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.7/images/marker-shadow.png",iconSize:[25,41],iconAnchor:[12,41],popupAnchor:[1,-34],shadowSize:[41,41]});return L.marker([t,e],{icon:n})}(0,0);z.setOpacity(0);let C=x(u,"communes-component",a);function T(t,e,n){let o,i=""+e.Group+"
";for(let a of["location","members","contact"]){let r=e[a]+": ";if("contact"==a)i+=r+""+t.contact+"";else if("location"==a){let a,s=[t.country,t.state,t.town].filter((t=>null!=t&&null!=t));a="en"==n?s.map((t=>t)).join(", "):s.map((t=>S(e,t))).join(", "),i+=r+a+"
",o=[t.latitude,t.longitude]}else i+=r+t[a]+"
"}return{text:i,coordinates:o}}function O(t,e,o){let i=t([22,0],2);j(r,s,i,e,o,T,"green"),z.addTo(i),i.on("click",(function(t){let e=t.latlng.lat,o=t.latlng.lng;b=e,w=o,function(t,e,n){let o=L.latLng(e,n);t.setLatLng(o)}(z,e,o),z.setOpacity(1),v(`https://nominatim.openstreetmap.org/reverse?lat=${e}&lon=${o}&format=jsonv2`,(t=>{let e=(t=JSON.parse(t)).address,o=e.city||e.town||e.village||e.hamlet,i=e.state,a=e.country;null!=i?a+=", "+i:i="",null!=o?a+=", "+o:o="",n(1,d.value=a,d),N(d)})),function(t,e){v(`https://nominatim.openstreetmap.org/reverse?lat=${t}&lon=${e}&format=jsonv2&accept-language=en`,(t=>{let e=(t=JSON.parse(t)).address,n=e.city||e.town||e.village||e.hamlet,o=e.state,i=e.country;null!=o||(o=""),null!=n||(n=""),h=[i,o,n]}))}(e,o)}))}function H(t){!1!==t?(n(0,p.innerHTML="You have been added to our database! Now go to our Discord to verify yourself.",p),n(0,p.style.color="green",p)):(n(0,p.innerHTML="Something went wrong.",p),n(0,p.style.color="red",p))}x(u,"countries",a),m((()=>{}));return[p,d,f,g,o,i,a,u,C,O,function(){if(null!=h){let t={country:h[0],state:h[1],town:h[2],latitude:b,longitude:w,contact:f.value,status:g.value};""==t.state&&(t.state=null),""==t.town&&(t.town=null),""==t.contact&&(t.contact=null),k("/"+C+"/communes-add-post/",t,H)}},function(t){c[t?"unshift":"push"]((()=>{d=t,n(1,d)}))},()=>N(d),function(t){c[t?"unshift":"push"]((()=>{f=t,n(2,f)}))},()=>N(f),function(t){c[t?"unshift":"push"]((()=>{g=t,n(3,g)}))},function(t){c[t?"unshift":"push"]((()=>{p=t,n(0,p)}))},t=>O(t,i,C)]}class H extends t{constructor(t){super(),this.shadowRoot.innerHTML="",e(this,{target:this.shadowRoot,props:n(this.attributes),customElement:!0},O,T,i,{},null),t&&t.target&&o(t.target,this,t.anchor)}}customElements.define("communes-add-component",H);export{H as default};