1"use strict";(globalThis.webpackChunkstec=globalThis.webpackChunkstec||[]).push([[4940],{1881:(e,t,a)=>{a.r(t),a.d(t,{default:()=>f});var n=a(41426),r=a(21067),c=a(26878),s=a.n(c),l=a(97011),o=a(11773),i=a(88905),u=a(52779),d=a(22819),m=a(8403),p=a(73772);const __=p.__,f=({coordinates:e,onChange:t,isOpen:a,onClose:c})=>{const p=(0,r.useSettingsAtt)("map__type"),f="gmap"===p?l.default:o.default;let g=e;return s().createElement(n.default,{isOpen:a,onClose:c},s().createElement(m.StecDiv,{className:"stec-find-on-map"},s().createElement(i.default,{mapProvider:p},s().createElement(f,{coordinates:e,onCoordinatesChange:e=>{g=e}})),s().createElement(d.default,null),s().createElement(u.default,{className:"green",label:__("Apply","stec"),onClick:()=>{t(g),c()}}),s().createElement(u.default,{className:"red",style:{marginLeft:6},label:__("Cancel","stec"),onClick:c})))}},11773:(e,t,a)=>{a.r(t),a.d(t,{default:()=>i});var n=a(32488),r=a(8403),c=a(73772),s=a(26878),l=a.n(s),o=a(60799);const __=c.__,i=({coordinates:e,onCoordinatesChange:t})=>{const[a,c]=(0,s.useState)(!1),[i,u]=(0,s.useState)(""),[d,m]=(0,s.useState)(!1),[p,f]=(0,s.useState)(!1),g=(0,s.useRef)(null);return(0,s.useEffect)((()=>{if(null!==g.current){if(!1===a){g.current.innerHTML="";const e=g.current.appendChild(document.createElement("div"));e.style.height=g.current.clientHeight+"px";const t=window.L.map(e,{zoomControl:!1}),a=window.L.tileLayer("https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",{attribution:['© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a>','<a href="https://wiki.osmfoundation.org/wiki/Privacy_Policy">Privacy Policy</a>'].join(" | ")});t.addLayer(a),t.setView([51.505,-.09],2),c(t)}return()=>{a&&(a.remove(),c(!1))}}}),[a]),(0,s.useEffect)((()=>{let e;return e=setTimeout((async()=>{if(i.length>2){f(!0);const e=await(async e=>{const t=`https://nominatim.openstreetmap.org/search?format=json&q=${e}&limit=1`,a=await fetch(t);if(a.ok){const e=await a.json();if(0===e.length)return null;const t=e[0],{lat:n,lon:r}=t;return{lat:n,lon:r}}return null})(i);if(f(!1),e){const{lat:t,lon:n}=e;a&&a.setView([t,n],15)}else o.toast.error(__("Location not found","stec"))}}),1e3),()=>{clearTimeout(e)}}),[a,i]),(0,s.useEffect)((()=>{if(!a)return;if(!d&&e)try{const t=e.split(","),n=parseFloat(t[0]),r=parseFloat(t[1]),c=window.L.marker([n,r]).addTo(a);m(c),a.setView([n,r],15)}catch(e){}const t=e=>{d&&d.remove();const t=window.L.marker(e.latlng).addTo(a);m(t)};return a.on("click",t),()=>{a.off("click",t)}}),[a,d,e]),(0,s.useEffect)((()=>{if(a&&d){const{lat:e,lng:a}=d.getLatLng();t(`${e},${a}`)}}),[a,d,t]),l().createElement(l().Fragment,null,l().createElement(n.UncontrolledInputText,{placeholder:__("Search Location","stec"),className:"stec-find-on-map-search",value:i,onChange:e=>{u(e)}}),l().createElement(r.StecDiv,{ref:g,style:{opacity:p?.5:1,height:500},className:"stec-find-on-map-container"}))}},15948:(e,t,a)=>{a.r(t),a.d(t,{default:()=>o});var n=a(52779),r=a(73772),c=a(26878),s=a.n(c),l=a(1881);const __=r.__,o=({coordinates:e,onChange:t})=>{const[a,r]=(0,c.useState)(!1);return s().createElement(s().Fragment,null,s().createElement(l.default,{isOpen:a,coordinates:e,onChange:t,onClose:()=>{r(!1)}}),s().createElement(n.default,{className:"blue",label:[s().createElement("i",{key:"icon",className:"fa-solid fa-map-marked-alt"}),__("Find on Map","stec")],onClick:()=>{r(!0)}}))}},54940:(e,t,a)=>{a.r(t),a.d(t,{UpsertForm:()=>A,default:()=>x});var n=a(52779),r=a(93699),c=a(85262),s=a(62552),l=a(32779),o=a(32488),i=a(39393),u=a(26524),d=a(48596),m=a(22819),p=a(98196),f=a(21067),g=a(91927),h=a(81148),y=a(6405),E=a(13328),R=a(8403),C=a(73772),w=a(26960),T=a(26878),b=a(60799),S=a(15948),v=a(80761);const __=C.__,_x=C._x,L=e=>{const{wasSubmitted:t,focusFieldsRef:a,postData:n}=e,{items:r,ready:c,error:s}=(0,E.usePermissions)();return!c||s?null:React.createElement(React.Fragment,null,React.createElement(E.WithMaybeDisplayPermissions,{type:"edit_permission"},React.createElement(m.default,null),React.createElement(l.UncontrolledInputSelect,{ref:e=>a.current.edit_permission=e,multiple:!0,title:__("Edit permission","stec"),options:r.filter((e=>"stec_public"!==e.value)),defaultValue:n.current.meta.edit_permission,description:__("Who can edit this location","stec"),required:!0,errorMessage:__("The edit permission cannot be empty","stec"),wasSubmitted:t,onChange:e=>{n.current.meta.edit_permission=e}})),React.createElement(E.WithMaybeDisplayPermissions,{type:"use_permission"},React.createElement(m.default,null),React.createElement(l.UncontrolledInputSelect,{ref:e=>a.current.use_permission=e,multiple:!0,title:__("Use permission","stec"),options:r,defaultValue:n.current.meta.use_permission,description:__("Who can add this location to their events","stec"),required:!0,errorMessage:__("The use permission cannot be empty","stec"),wasSubmitted:t,onChange:e=>{n.current.meta.use_permission=e}})))},_=e=>{const{focusFieldsRef:t,postData:a,wasSubmitted:n}=e,[r,c]=(0,T.useState)(0);return React.createElement(React.Fragment,null,React.createElement(o.UncontrolledInputText,{ref:e=>t.current.coordinates=e,key:r,className:"stec-input-coordinates",title:__("Coordinates","stec"),placeholder:__("Lng, Lat","stec"),description:__("Location coordinates in decimal format","stec"),required:!0,regex:(0,y.getRegexByType)("coordinates"),errorMessage:__("The location must have valid coordinates","stec"),defaultValue:a.current.meta.coordinates,wasSubmitted:n,onChange:e=>{a.current.meta.coordinates=e.replace(/\s/gi,"")}}),React.createElement(m.default,null),React.createElement(S.default,{coordinates:a.current.meta.coordinates,onChange:e=>{a.current.meta.coordinates=e,c((0,w.uniqueId)()),b.toast.success(__("Coordinates added","stec"))}}))},k=e=>{const{postData:t,focusFieldsRef:a,wasSubmitted:n}=e,[r,s]=(0,T.useState)(t.current.meta.type||"physical");return React.createElement(React.Fragment,null,React.createElement(l.InputSelect,{multiple:!1,value:r,title:__("Type","stec"),options:[{label:__("Physical location","stec"),value:"physical"},{label:__("Virtual location","stec"),value:"virtual"}],onChange:e=>{s(e),t.current.meta.type=e},description:__("Choose location type","stec")}),React.createElement(m.default,null),"physical"===r&&React.createElement(React.Fragment,null,React.createElement(o.UncontrolledInputText,{defaultValue:t.current.meta.country,title:__("Country","stec"),placeholder:__("Country name","stec"),onChange:e=>{t.current.meta.country=e},description:__("Country","stec")}),React.createElement(m.default,null),React.createElement(o.UncontrolledInputText,{defaultValue:t.current.meta.state,title:__("State/Province","stec"),placeholder:__("State/Province","stec"),onChange:e=>{t.current.meta.state=e},description:__("State or Province if applicable","stec")}),React.createElement(m.default,null),React.createElement(o.UncontrolledInputText,{defaultValue:t.current.meta.city,title:__("City","stec"),placeholder:__("City name","stec"),onChange:e=>{t.current.meta.city=e},description:__("City name if applicable","stec")}),React.createElement(m.default,null),React.createElement(o.UncontrolledInputText,{defaultValue:t.current.meta.postal_code,title:__("Postal code","stec"),placeholder:__("Postal code","stec"),onChange:e=>{t.current.meta.postal_code=e},description:__("Postal code if applicable","stec")}),React.createElement(m.default,null),React.createElement(o.UncontrolledInputText,{defaultValue:t.current.meta.address,title:__("Address","stec"),placeholder:__("Location address","stec"),onChange:e=>{t.current.meta.address=e},description:__("Address","stec")}),React.createElement(m.default,null),React.createElement(_,{wasSubmitted:n,focusFieldsRef:a,postData:t})),"virtual"===r&&React.createElement(React.Fragment,null,React.createElement(o.UncontrolledInputText,{defaultValue:t.current.meta.address,title:__("Address","stec"),placeholder:__("Location address","stec"),onChange:e=>{t.current.meta.address=e},description:__("Virtual location address (https://...)","stec")}),React.createElement(m.default,null),React.createElement(c.UncontrolledInputCheckbox,{title:__("Protected address","stec"),description:__("Only participants can view the address","stec"),defaultValue:t.current.meta.protected,onChange:e=>{t.current.meta.protected=e}})))};function A(e){const t=(0,f.useCaptcha)(),[a,c]=(0,T.useState)(!1),[l,g]=(0,T.useState)(0),E=(0,T.useRef)(!1),R=v.default,C=(0,T.useRef)((0,w.cloneDeep)(e.template?e.template:R)),S=(0,T.useRef)([]),_=(e,t=!0)=>{C.current=t?(0,w.cloneDeep)(e):e,g((0,w.uniqueId)())},A=C.current.id?[React.createElement("i",{key:"icon",className:"fa-solid fa-pen-to-square"}),__("Edit location","stec")]:[React.createElement("i",{key:"icon",className:"fa-solid fa-plus"}),__("Add new location","stec")];return React.createElement(d.default,{title:A,key:l},C.current.meta.anonymous&&React.createElement(React.Fragment,null,React.createElement(o.UncontrolledInputText,{title:__("Submitted by anonymous user","stec"),readOnly:!0,defaultValue:__("Yes","stec"),description:__("This item was submitted by anonymous user","stec")}),React.createElement(m.default,null)),React.createElement(h.default,{postData:C}),React.createElement(m.default,null),React.createElement(o.UncontrolledInputText,{ref:e=>S.current.name=e,title:__("Name","stec"),defaultValue:C.current.name,placeholder:__("Location name","stec"),description:__("Location display name","stec"),required:!0,regex:(0,y.getRegexByType)("title"),errorMessage:__("The location must have a name","stec"),wasSubmitted:a,onChange:e=>{C.current.name=e}}),React.createElement(m.default,null),React.createElement(o.UncontrolledInputText,{ref:e=>S.current.slug=e,title:__("Slug","stec"),defaultValue:C.current.slug,className:"stec-input-slug",placeholder:__("Location slug","stec"),description:__("Leave empty to auto-generate","stec"),required:!1,regex:(0,y.getRegexByType)("slug"),errorMessage:__("The location must have a valid slug","stec"),onChange:e=>{C.current.slug=e},wasSubmitted:a}),React.createElement(m.default,null),React.createElement(s.UncontrolledInputColor,{title:__("Color","stec"),defaultValue:C.current.meta.color,description:__("Location color","stec"),onChange:e=>{C.current.meta.color=e}}),React.createElement(m.default,null),React.createElement(i.UncontrolledInputTextarea,{ai:{display:!0,task:_x("Improve the content","AI Task About Location","stec")},title:__("Description","stec"),description:__("About this location","stec"),defaultValue:C.current.description,onChange:e=>{C.current.description=e}}),React.createElement(m.default,null),React.createElement(k,{postData:C,focusFieldsRef:S,wasSubmitted:a}),React.createElement(m.default,null),React.createElement(u.default,{defaultValue:C.current.meta.lang||"",onChange:e=>{C.current.meta.lang=e}}),!!STEC_VARIABLES?.current_user?.data?.id&&React.createElement(L,{postData:C,focusFieldsRef:S,wasSubmitted:a}),React.createElement(m.default,null),React.createElement(n.default,{label:C.current.id?__("Update","stec"):__("Create","stec",0),className:"green",onClick:()=>
1{if(!0!==E.current){if(c(!0),!1===(()=>{const e=[{id:"name",regex:(0,y.getRegexByType)("title"),meta:!1,errorMessage:__("The location must have a name","stec")},{id:"slug",regex:(0,y.getRegexByType)("slug"),meta:!1,errorMessage:__("The location must have a valid slug","stec")},{id:"use_permission",meta:!0,errorMessage:__("The use permission cannot be empty","stec")},{id:"edit_permission",meta:!0,errorMessage:__("The edit permission cannot be empty","stec")},{id:"coordinates",regex:(0,y.getRegexByType)("coordinates"),meta:!0,errorMessage:__("The location must have valid coordinates","stec"),condition:"physical"}];for(let t in e){const a=e[t],n=a.meta?C.current.meta[a.id]:C.current[a.id];if(a.condition&&"physical"===a.condition&&"physical"!==C.current.meta.type)continue;let r=!0;if(r=a.regex?new RegExp(a.regex).test(n):Array.isArray(n)?n.length>0:!(!n||""===n),!1===r)return S.current[a.id]&&S.current[a.id].focus(),b.toast.error(a.errorMessage),!1}return!0})())return!1;b.toast.promise(new Promise(((a,n)=>{E.current=!0,async function(){try{const r=await t.getToken();let c;c=C.current.id?await(0,p.newApiPut)({route:"LOCATIONS",args:C.current.id,data:C.current,includeResponseStatus:!0,errorMessage:"auto",headers:{"X-STEC-CAPTCHA-TOKEN":r}}):await(0,p.newApiPost)({route:"LOCATIONS",data:C.current,includeResponseStatus:!0,translateErrorCode:{term_exists:__("A location with this name already exists","stec")},errorMessage:"auto",headers:{"X-STEC-CAPTCHA-TOKEN":r}});const{status:s,data:l}=c;switch(s){case 201:return e.onLocationInserted&&e.onLocationInserted(l),_(l),(0,p.flushApiCache)({group:"taxonomy-stec_loc"}),a(__("Created","stec"));case 200:return _(l),e.onLocationInserted&&e.onLocationInserted(l),(0,p.flushApiCache)({group:"taxonomy-stec_loc"}),a(__("Updated","stec"));default:return n(__("Sorry, something went wrong","stec"))}}catch(e){return n(e.message)}}()})),{loading:__("Saving","stec"),success:e=>(E.current=!1,e),error:e=>(E.current=!1,e)})}else(0,b.toast)(__("Another action is in progress","stec"))}}),React.createElement(n.default,{label:__("Reset form","stec"),className:"yellow",style:{marginLeft:5},onClick:()=>{_(R),c(!1),(0,b.toast)(__("The form has been reset","stec"))}}),C.current.id&&React.createElement(r.default,{label:__("Delete","stec"),className:"red",style:{marginLeft:5},onClick:()=>{!0!==E.current?b.toast.promise(new Promise(((a,n)=>{E.current=!0,async function(){try{const n=await t.getToken();await(0,p.newApiDelete)({route:"LOCATIONS",args:C.current.id,headers:{"X-STEC-CAPTCHA-TOKEN":n},errorMessage:"auto"}),e.onLocationDeleted&&e.onLocationDeleted(C.current);const r=(0,w.cloneDeep)(C.current);return r.id="",_(r,!1),(0,p.flushApiCache)({group:"taxonomy-stec_loc"}),a(__("Deleted","stec"))}catch(e){return n(e.message)}}()})),{loading:__("Deleting","stec"),success:e=>(E.current=!1,e),error:e=>(E.current=!1,e)}):(0,b.toast)(__("Another action is in progress","stec"))}}),React.createElement(n.default,{label:__("Back","stec"),className:"blue",style:{marginLeft:5},onClick:()=>{const t=!C.current.id;e.onBack(t)}}),t.RenderCaptcha)}const x=function(){const{setActiveMenu:e,activeMenuParams:t}=(0,g.useDashboardMenu)(),a=a=>{let n=t.manageListQueryArgs||null;a&&(n=null),e({page:"locations-list",params:{initialQueryArgs:n}})};return React.createElement(React.Fragment,null,React.createElement(R.StecDiv,{className:"stec-dashboard-top-nav"},React.createElement(n.default,{className:"stcolor stec-dashboard-home-button",label:[React.createElement("i",{key:"icon",className:"fa-solid fa-home"}),__("Home","stec")],onClick:()=>{e({page:"home",params:{}})}}),React.createElement(n.default,{className:"blue",label:[React.createElement("i",{key:"icon",className:"fa-solid fa-list"}),__("Manage locations","stec")],onClick:a})),React.createElement(A,{template:t.template||!1,onBack:e=>{a(e)}}))}},80761:(e,t,a)=>{a.r(t),a.d(t,{default:()=>n});const n=void 0!==window.STEC_LOCATION_TEMPLATE?window.STEC_LOCATION_TEMPLATE:{name:"",slug:"",status:"publish",description:"",meta:{author:"",color:"#FFE59D",type:"physical",coordinates:"",country:"",state:"",city:"",address:"",postal_code:"",read_permission:["stec_public"],use_permission:["stec_private"],edit_permission:["stec_private"],protected:!1}}},88905:(e,t,a)=>{a.r(t),a.d(t,{default:()=>o});var n=a(21067),r=a(26878),c=a.n(r);const s=({children:e})=>(0,n.useRequestGoogleMapsLib)()?e:null,l=({children:e})=>(0,n.useRequestOpenStreetMapLib)()?e:null,o=({mapProvider:e,children:t})=>"gmap"===e?c().createElement(s,null,t):c().createElement(l,null,t)},97011:(e,t,a)=>{a.r(t),a.d(t,{default:()=>i});var n=a(32488),r=a(8403),c=a(73772),s=a(26878),l=a.n(s),o=a(60799);const __=c.__,i=({coordinates:e,onCoordinatesChange:t})=>
1{const[a,c]=(0,s.useState)(!1),[i,u]=(0,s.useState)(""),[d,m]=(0,s.useState)(!1),[p,f]=(0,s.useState)(!1),g=(0,s.useRef)(null);return(0,s.useEffect)((()=>{if(null!==g.current){if(!1===a){g.current.innerHTML="";g.current.appendChild(document.createElement("div")).style.height=g.current.clientHeight+"px";const e=new window.google.maps.Map(g.current,{mapId:`stec-map-${(new Date).getTime()}`,gestureHandling:"greedy",zoom:2,center:{lat:51.505,lng:-.09},streetViewControl:!1,mapTypeControl:!1,fullscreenControl:!1,clickableIcons:!1});c(e)}return()=>{a&&c(!1)}}}),[a]),(0,s.useEffect)((()=>{let e;return e=setTimeout((async()=>{if(i.length>2){f(!0);const e=await(async e=>{const t=`https://nominatim.openstreetmap.org/search?format=json&q=${e}&limit=1`,a=await fetch(t);if(a.ok){const e=await a.json();if(0===e.length)return null;const t=e[0],{lat:n,lon:r}=t;return{lat:n,lon:r}}return null})(i);if(f(!1),e){const{lat:t,lon:n}=e;a&&(a.panTo(new window.google.maps.LatLng(t,n)),a.setZoom(15))}else o.toast.error(__("Location not found","stec"))}}),1e3),()=>{clearTimeout(e)}}),[a,i]),(0,s.useEffect)((()=>{if(!a)return;const t=async()=>await google.maps.importLibrary("marker");!d&&e&&(async()=>{try{const{AdvancedMarkerElement:n}=await t(),r=e.split(","),c=parseFloat(r[0]),s=parseFloat(r[1]),l=new n({position:{lat:c,lng:s},map:a});m(l),a.setCenter({lat:c,lng:s}),a.setZoom(15)}catch(e){}})();return a.addListener("click",(async e=>{d&&d.setMap(null);const{AdvancedMarkerElement:n}=await t(),r=new n({position:e.latLng,map:a});m(r)})),()=>{google.maps.event.clearListeners(a,"click")}}),[a,d,e]),(0,s.useEffect)((()=>{if(a&&d){const e=d.position,{lat:a,lng:n}={lat:e.lat,lng:e.lng};t(`${a},${n}`)}}),[a,d,t]),l().createElement(l().Fragment,null,l().createElement(n.UncontrolledInputText,{placeholder:__("Search Location","stec"),className:"stec-find-on-map-search",value:i,onChange:e=>{u(e)}}),l().createElement(r.StecDiv,{ref:g,style:{opacity:p?.5:1,height:500},className:"stec-find-on-map-container"}))}}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.