You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2 lines
12 KiB

var R=Object.defineProperty;var B=(e,s,t)=>s in e?R(e,s,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[s]=t;var l=(e,s,t)=>B(e,typeof s!="symbol"?s+"":s,t);/* empty css */import{a as k}from"./leaflet-src-DKb5ysSI.js";import{V as N,f as $,e as E,y as I,C as P,_ as V,g,h as u,i as m,j as n,a3 as O,a0 as F,m as z,s as q,q as A,k as x,t as S,l as w,w as j,F as D,x as v,z as Z}from"./index-BLqts8WY.js";import{i as U,v as Q}from"./vue-leaflet.es-D17g3l39.js";import{Q as G}from"./QuickNav-DgCyvgDx.js";import{I as _}from"./InfiniteScroll-B5tl9k_n.js";import{P as H}from"./ProjectIcon-BlrP4rvy.js";import{O as J}from"./OnboardingDialog-CiAZLb6o.js";import{T as K}from"./TopMessage-BE0GBIgW.js";import{h as W,e as X,ao as Y,g as T,x as ee}from"./index-MyY_xqVN.js";import"./index-CsfPLOYu.js";var te=Object.defineProperty,se=Object.getOwnPropertyDescriptor,oe=(e,s,t,o)=>{for(var i=o>1?void 0:o?se(s,t):s,a=e.length-1,h;a>=0;a--)(h=e[a])&&(i=(o?h(s,t,i):h(i))||i);return o&&i&&te(s,t,i),i};let C=class extends N{constructor(){super(...arguments);l(this,"$notify");l(this,"activeDid","");l(this,"allContacts",[]);l(this,"allMyDids",[]);l(this,"apiServer","");l(this,"searchTerms","");l(this,"projects",[]);l(this,"isLoading",!1);l(this,"isLocalActive",!0);l(this,"isMappedActive",!1);l(this,"isRemoteActive",!1);l(this,"isSearchVisible",!0);l(this,"localCenterLat",0);l(this,"localCenterLong",0);l(this,"localCount",-1);l(this,"markers",{});l(this,"remoteCount",-1);l(this,"searchBox",null);l(this,"tempSearchBox",null);l(this,"zoomedSoDoNotMove",!1);l(this,"didInfo",W)}async mounted(){var o;const t=await $();if(this.activeDid=t.activeDid||"",this.apiServer=t.apiServer||"",this.searchBox=((o=t.searchBoxes)==null?void 0:o[0])||null,this.allContacts=await E.contacts.toArray(),this.allMyDids=await X(),this.searchTerms=this.$route.query.searchText||"",t.finishedOnboarding||this.$refs.onboardingDialog.open(Y.Discover),this.searchBox){await this.searchLocal();const i=this.searchBox.bbox;this.localCenterLat=(i.maxLat+i.minLat)/2,this.localCenterLong=(i.eastLong+i.westLong)/2}else this.isLocalActive=!1,this.isMappedActive=!1,this.isRemoteActive=!0,await this.searchAll()}resetCounts(){this.localCount=-1,this.remoteCount=-1}async searchSelected(){this.isLocalActive?await this.searchLocal():this.isMappedActive?(this.isRemoteActive=!0,await this.searchAll()):await this.searchAll()}async searchAll(t){this.resetCounts(),t||(this.projects=[]);let o="claimContents="+encodeURIComponent(this.searchTerms);t&&(o=o+`&beforeId=${t}`);try{this.isLoading=!0;const i=await fetch(this.apiServer+"/api/v2/report/plans?"+o,{method:"GET",headers:await T(this.activeDid)});if(i.status!==200){const c=await i.text();throw console.error("Problem with full search:",c),this.$notify({group:"alert",type:"danger",title:"Error",text:"There was a problem accessing the server. Try again later."},-1),c}const a=await i.json(),h=a.data;if(h){for(const c of h){const{name:p,description:r,handleId:b,image:L,issuerDid:y,rowid:f}=c;this.projects.push({name:p,description:r,handleId:b,image:L,issuerDid:y,rowid:f})}this.remoteCount=this.projects.length}else throw JSON.stringify(a)}catch(i){console.error("Error with feed load:",i),console.error("Error with feed load (error added): "+i),this.$notify({group:"alert",type:"danger",title:"Error",text:i.userMessage||"There was a problem retrieving projects."},-1)}finally{this.isLoading=!1}}async searchLocal(t){var h;this.resetCounts();const o=this.isMappedActive&&this.tempSearchBox||this.isLocalActive&&((h=this.searchBox)==null?void 0:h.bbox);if(!o){this.projects=[];return}t||(this.projects=[]);let a=["claimContents="+encodeURIComponent(this.searchTerms),"minLocLat="+o.minLat,"maxLocLat="+o.maxLat,"westLocLon="+o.westLong,"eastLocLon="+o.eastLong].join("&");t&&(a=a+`&beforeId=${t}`);try{this.isLoading=!0;const c=await fetch(this.apiServer+"/api/v2/report/plansByLocation?"+a,{method:"GET",headers:await T(this.activeDid)});if(c.status!==200){const r=await c.text();throw console.error("Problem with nearby search:",r),this.$notify({group:"ale