1import{O as l,z as n,a0 as u,a1 as d,bM as T,aB as P,M as N,as as _,aJ as C,P as E,ay as k,bN as w,Z as B,b8 as O,b9 as A,bs as U,bO as D,ba as L,$ as M,S as V,at as R,bP as F,bQ as H,b5 as W,bR as Y}from"./index-CDp3i4jH.js";import{s as z}from"./inviteService-QTfn2BDS.js";import{l as K,b as Q}from"./index.es-Cr7ibLKg.js";const $=N("PlaceAutocomplete"),Z="AIzaSyBWgngKbiVCW1AC_K8QLQSUvsUWnGhTrfo";function q(e,a){const t=e.split(",")[0].trim();return a?`${t}, ${a}`:e}async function G({label:e="",value:a}){const t=a&&a.place_id;if(!t)return e;try{const[s]=await Q(t);return q(e,s&&s.formatted_address)}catch(s){return $.warn("place_geocode_failed",{error:s&&s.message}),e}}function J({value:e,onChange:a,placeholder:t}){const[s,i]=l.useState(null);return l.useEffect(()=>{var c;if(!((c=s==null?void 0:s.value)!=null&&c.place_id))return;let o=!0;return G(s).then(m=>{o&&a(m)}),()=>{o=!1}},[s,a]),n.jsx("div",{style:{width:"100%",paddingTop:8,paddingBottom:8},children:n.jsx(K,{apiKey:Z,selectProps:{value:s,onChange:i,placeholder:t||(e?void 0:"Search for a placeâ¦"),"aria-label":"place-input",noOptionsMessage:()=>"Type to search places",styles:{input:o=>({...o,color:"inherit"}),option:o=>({...o,color:"#000"}),singleValue:o=>({...o,color:"inherit"})}},autocompletionRequest:{componentRestrictions:{country:["us"]}}})})}function X({value:e,onChange:a,placeholder:t}){return n.jsx(P,{"aria-label":"place-input-manual",placeholder:t,value:e,onIonInput:s=>a(s.detail.value||"")})}function ee({value:e,onChange:a,placeholder:t}){const[s,i]=l.useState(!1);return n.jsxs(n.Fragment,{children:[n.jsxs(u,{children:[n.jsx(d,{position:"stacked",children:"Place"}),s?n.jsx(X,{value:e,onChange:a,placeholder:t}):n.jsx(J,{value:e,onChange:a,placeholder:t})]}),n.jsx(u,{lines:"none",button:!0,detail:!1,onClick:()=>{i(o=>!o),a("")},children:n.jsx(T,{slot:"start",color:"primary",children:s?"Search for a place instead":"Can't find it? Enter it manually"})})]})}function ne(){const e=new Date;return new Date(e.getTime()-e.getTimezoneOffset()*6e4).toISOString().slice(0,10)}function x(e,a=new Date){if(!e)return!1;const t=new Date(e);return Number.isNaN(t.getTime())?!1:t.getTime()<=a.getTime()}function te(e){return new Date(e).toISOString()}const j="activity",v="phone_call",ae=[{value:j,label:"In-person"},{value:v,label:"Phone call"}];function p(e){return e!==v}function se({targetUserId:e,proposedTime:a,inviteType:t,venueName:s,submitting:i}){return i||!e||!a||x(a)?!1:p(t)?s.trim().length>0:!0}const oe=({value:e,onChange:a})=>n.jsx(F,{value:e,onIonChange:t=>a(t.detail.value),children:ae.map(t=>n.jsx(H,{value:t.value,children:n.jsx(d,{children:t.label})},t.value))}),ie=({inviteType:e,proposedTime:a,setProposedTime:t,venueName:s,setVenueName:i})=>n.jsxs(W,{children:[n.jsxs(u,{children:[n.jsx(d,{position:"stacked",children:"When"}),n.jsx(Y,{presentation:"date-time",min:ne(),value:a||void 0,onIonChange:o=>t(String(o.detail.value||""))})]}),x(a)&&n.jsx(u,{lines:"none",children:n.jsx(d,{color:"danger",className:"ion-text-wrap",children:"That time has already passed â pick a later one."})}),p(e)&&n.jsx(ee,{value:s,onChange:i,placeholder:"e.g. Uchi or Zilker Park"})]});function ue(){const{targetUserId:e}=_(),a=C(),t=E(),[s]=k(),[i,o]=l.useState(j),[c,m]=l.useState(""),[f,h]=l.useState(""),[I,g]=l.useState(!1);if(!w(t==null?void 0:t.uid))return a.replace("/daily-checkin"),null;const S=se({targetUserId:e,proposedTime:c,inviteType:i,venueName:f,submitting:I}),y=r=>{o(r),p(r)||h("")},b=async()=>{g(!0);try{const r=await z({toUserId:e,inviteType:i,proposedTime:te(c),venueName:p(i)?f.trim():null});s({message:r!=null&&r.duplicate?"You already have an open invite to them.":"Invite sent!",duration:2200,color:"success"}),a.replace("/daily-checkin")}catch(r){s({message:(r==null?void 0:r.message)||"Could not send invite",duration:2600,color:"danger"})}finally{g(!1)}};return n.jsxs(B,{children:[n.jsx(O,{children:n.jsxs(A,{children:[n.jsx(U,{slot:"start",children:n.jsx(D,{defaultHref:"/"})}),n.jsx(L,{children:"Send an Invite"})]})}),n.jsxs(M,{className:"ion-padding",children:[n.jsx(oe,{value:i,onChange:y}),n.jsx(ie,{inviteType:i,proposedTime:c,setProposedTime:m,venueName:f,setVenueName:h}
1),n.jsx(V,{expand:"block",disabled:!S,onClick:b,className:"ion-margin-top",children:I?n.jsx(R,{name:"crescent"}):"Send Invite"})]})]})}export{se as canSubmitInvite,ue as default,x as isProposedTimeInPast,ne as localMinDate,te as toUtcInstant};
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.