1import{i as T,_ as P,a as m,o as l,d as h,b as a,t as u,F as y,x as k,q as I,p as N,m as v,n as D,r as B,L as le,y as w,z as de,f as me,s as U,e as W,B as A,j as x,D as ce,v as ue,k as ge,ak as V,al as he,c as _e}from"./index-B13lFBcW.js";import{b as K,a as pe,c as fe}from"./vuex.esm-bundler-CqCp6GMh.js";import"./lightbox-BXYppJlY.js";import{e as ye}from"./entrypoints/pdf.ts-DDuZt5yk.js";import{G as be,U as Ce,C as j,a as ke,b as Te,c as ve,d as we,e as Ie,D as Ee}from"./image-graph-BQmmBvgQ.js";import{g as J,j as C}from"./MeasurementPref-DNafZ4Io.js";import{b as z}from"./axios_client-7rBlZ4x9.js";import{O as H,S as Pe}from"./entrypoints/application.ts-L6JZLk2z.js";import{M as Me}from"./bootstrap.esm-QPF2KThC.js";import{L as Se}from"./LoadingDialog-CwfOgGh8.js";const d=e=>T.global.t(e),G={closed:()=>d("utils.rating_tag.closed"),private_property:()=>d("utils.rating_tag.private_property"),bad_condition:()=>d("utils.rating_tag.bad_condition"),poor_condition:()=>d("utils.rating_tag.poor_condition"),fair_condition:()=>d("utils.rating_tag.fair_condition"),good_condition:()=>d("utils.rating_tag.good_condition"),great_condition:()=>d("utils.rating_tag.great_condition"),wrong_route:()=>d("utils.rating_tag.wrong_route"),no_parking:()=>d("utils.rating_tag.no_parking"),has_parking:()=>d("utils.rating_tag.has_parking"),easy_to_park:()=>d("utils.rating_tag.easy_to_park"),hard_to_park:()=>d("utils.rating_tag.hard_to_park"),no_bathrooms:()=>d("utils.rating_tag.no_bathrooms"),has_bathroom:()=>d("utils.rating_tag.has_bathroom"),toilets_available:()=>d("utils.rating_tag.toilets_available"),tide_dependant:()=>d("utils.rating_tag.tide_dependant"),river_crossing:()=>d("utils.rating_tag.river_crossing"),snowy:()=>d("utils.rating_tag.snowy"),muddy:()=>d("utils.rating_tag.muddy"),boggy:()=>d("utils.rating_tag.boggy"),rocky:()=>d("utils.rating_tag.rocky"),overgrown:()=>d("utils.rating_tag.overgrown"),crowded:()=>d("utils.rating_tag.crowded"),no_crowds:()=>d("utils.rating_tag.no_crowds"),scenic_views:()=>d("utils.rating_tag.scenic_views"),great_views:()=>d("utils.rating_tag.great_views"),dog_friendly:()=>d("utils.rating_tag.dog_friendly"),family_friendly:()=>d("utils.rating_tag.family_friendly"),kid_friendly:()=>d("utils.rating_tag.kid_friendly"),stroller_friendly:()=>d("utils.rating_tag.stroller_friendly"),wheelchair_friendly:()=>d("utils.rating_tag.wheelchair_friendly"),paved:()=>d("utils.rating_tag.paved"),partially_paved:()=>d("utils.rating_tag.partially_paved"),city_walk:()=>d("utils.rating_tag.city_walk"),coastal_stroll:()=>d("utils.rating_tag.coastal_stroll"),desert_path:()=>d("utils.rating_tag.desert_path"),forest_bathing:()=>d("utils.rating_tag.forest_bathing"),mountain_views:()=>d("utils.rating_tag.mountain_views"),pub_walk:()=>d("utils.rating_tag.pub_walk"),rail_trail:()=>d("utils.rating_tag.rail_trail"),along_the_river:()=>d("utils.rating_tag.along_the_river"),lake_views:()=>d("utils.rating_tag.lake_views"),native_woods:()=>d("utils.rating_tag.native_woods"),bridges_to_cross:()=>d("utils.rating_tag.bridges_to_cross"),canyon_hike:()=>d("utils.rating_tag.canyon_hike"),caves_to_explore:()=>d("utils.rating_tag.caves_to_explore"),ancient_glaciers:()=>d("utils.rating_tag.ancient_glaciers"),historical_trail:()=>d("utils.rating_tag.historical_trail"),hot_springs:()=>d("utils.rating_tag.hot_springs"),rock_formations:()=>d("utils.rating_tag.rock_formations"),epic_photos:()=>d("utils.rating_tag.epic_photos"),waterfalls_trail:()=>d("utils.rating_tag.waterfalls_trail"),flowers_in_bloom:()=>d("utils.rating_tag.flowers_in_bloom"),wildlife_area:()=>d("utils.rating_tag.wildlife_area"),volcanic_features:()=>d("utils.rating_tag.volcanic_features"),lookout_towers:()=>d("utils.rating_tag.lookout_towers"),food:()=>d("utils.rating_tag.food"),coffee:()=>d("utils.rating_tag.coffee")},Oe={1:["closed","private_property","bad_condition","wrong_route","no_parking","no_bathrooms"],2:["no_parking","no_bathrooms","poor_condition","tide_dependant","boggy","overgrown"],3:["no_bathrooms","crowded","hard_to_park","fair_condition","muddy","overgrown"],4:["scenic_views","has_parking","good_condition","no_crowds","dog_friendly","has_bathroom"],5:["great_views","easy_to_park","great_condition","no_crowds","dog_friendly","has_bathroom"]}
1,Re=["tide_dependant","river_crossing","snowy","muddy","boggy","rocky","overgrown","no_parking","no_bathrooms","closed","private_property","wrong_route","bad_condition","hard_to_park"],Ne=["city_walk","coastal_stroll","desert_path","forest_bathing","mountain_views","pub_walk","rail_trail","along_the_river","lake_views","native_woods"],Le=["bridges_to_cross","canyon_hike","caves_to_explore","ancient_glaciers","historical_trail","hot_springs","rock_formations","epic_photos","waterfalls_trail","flowers_in_bloom","wildlife_area","volcanic_features","lookout_towers","scenic_views"],De=["dog_friendly","family_friendly","kid_friendly","stroller_friendly","wheelchair_friendly","paved","partially_paved","toilets_available"],Ue=["has_parking","food","coffee","has_bathroom","fair_condition","good_condition","great_condition"],Q=e=>{var t;return((t=G[e])==null?void 0:t.call(G))||e.replace(/_/g," ").replace(/\b\w/g,o=>o.toUpperCase())},S=e=>e.map(t=>({key:t,label:Q(t)})),X=e=>{if(!Number.isInteger(e)||e<1||e>5)return[];const t={id:"quick",title:null,tags:S(Oe[e])};return e<=3?[t,{id:"conditions",title:d("utils.rating_tag.conditions"),tags:S(Re)}]:[t,{id:"landscape",title:d("utils.rating_tag.landscape"),tags:S(Ne)},{id:"features",title:d("utils.rating_tag.features"),tags:S(Le)},{id:"suitability",title:d("utils.rating_tag.suitability"),tags:S(De)},{id:"conditions",title:d("utils.rating_tag.conditions"),tags:S(Ue)}]};function $e(e,t){if(!e)return t("comments.comment.distance_km",{distance:0});const o=Math.round(e);return o<1e3?t("comments.comment.distance_m",{distance:o}):t("comments.comment.distance_km",{distance:(Math.round(e/100)/10).toFixed(1)})}const Ae=J` 2 mutation CreateLike($like:CreateLikeInput!) { 3 createLike(input:$like) { 4 id 5 userId 6 likeableId 7 likeableType 8 user { 9 firebaseUserId 10 } 11 errors { 12 fieldName 13 errors 14 } 15 } 16 } 17`,Ge=J` 18 mutation DestroyLike($like:DestroyLikeInput!) { 19 destroyLike(input:$like) { 20 id 21 userId 22 likeableId 23 likeableType 24 errors { 25 fieldName 26 errors 27 } 28 } 29 } 30`,xe={props:{user:{type:Object,required:!1},likeable:{type:Object,required:!0},likeableType:{type:String,required:!0}},methods:{toggleLike(){if(!this.user)return window.onBoardingVue.launchFor(H.Likes),!1;this.likedByUser?this.destroyLike():this.createLike()},createLike(){const e={like:{likeableId:this.likeable.id,likeableType:this.likeableType}};C.request(Ae,e).then(t=>{const o=t.createLike;this.likeable.likes||this.$set(this.likeable,"likes",[]),this.likeable.likes.push(o)})},destroyLike(){const e=this.likeable.likes&&this.likeable.likes.find(o=>o.user.firebaseUserId==this.user.firebase_user_id);if(!e)return;const t={like:{id:e.id}};C.request(Ge,t).then(o=>{o.destroyLike.errors.length>0&&alert(o.destroyLike.errors);const n=o.destroyLike;this.likeable.likes&&(this.likeable.likes=this.likeable.likes.filter(r=>r.id!==n.id))})}},computed:{likedByUser(){return this.user?this.likeable.likes&&this.likeable.likes.some(e=>e.user.firebaseUserId===this.user.firebase_user_id):!1}}},He={key:0,class:"material-icons text-info mr-2"},Fe={key:1,class:"material-icons text-muted mr-1"};function qe(e,t,o,n,r,s){return l(),m("div",{class:"d-flex align-items-center likeable",style:{cursor:"pointer"},onClick:t[0]||(t[0]=(...i)=>s.toggleLike&&s.toggleLike(...i))},[s.likedByUser?(l(),m("span",He,"thumb_up")):h("",!0),s.likedByUser?h("",!0):(l(),m("span",Fe,"thumb_up_off_alt")),a("span",null,"("+u(o.likeable.likes?o.likeable.likes.length:0)+")",1)])}const Be=P(xe,[["render",qe]]),Ve={props:{photo:{type:Object,required:!0},index:{type:Number,required:!1,default:0},allPhotos:{type:Array,required:!1,default:()=>[]},title:{type:String,required:!0},fetchUnprocessed:{type:Boolean,required:!1,default:!1}},computed:{hiddenPhotos(){return this.index===0&&this.allPhotos.length>1?this.allPhotos.slice(1):[]}}},je=["href"],ze=["alt","title","src"],Ye=["href"];function We(e,t,o,n,r,s){return l(),m("a",{rel:"nofollow, noindex","data-lightbox":"images",href:o.photo.file.lgUrl,class:"photo-link"},[a("img",{loading:"lazy",decoding:"async",alt:o.title,title:o.title,class:"photo-image",src:o.photo.file.mdUrl},null,8,ze),o.index===0?(l(!0),m(y,{key:0},k(s.hiddenPhotos,(i,c)=>(l(),m("a",{key:`hidden-${i.id}`,rel:"nofollow, noindex","data-lightbox":"images",href:i.file.lgUrl,style:{display:"none",position:"absolute"}},null,8,Ye))),128)):h("",!0)],8,je)}
30const Ke=P(Ve,[["render",We],["__scopeId","data-v-0851465a"]]);function Je(e){var i;const t=document.createElement("div");t.className="flyover-fullscreen-overlay";const o=document.createElement("video");o.className="flyover-fullscreen-overlay__video",o.src=e,o.controls=!0,o.autoplay=!0,o.loop=!0,o.playsInline=!0;const n=document.createElement("button");n.className="flyover-fullscreen-overlay__close material-icons",n.setAttribute("aria-label",T.global.t("utils.open_flyover_video_fullscreen.close_video")),n.textContent="close";const r=()=>{var c;document.fullscreenElement&&((c=document.exitFullscreen)==null||c.call(document).catch(()=>{})),t.remove(),document.removeEventListener("keydown",s)},s=c=>{c.key==="Escape"&&r()};n.addEventListener("click",r),t.addEventListener("click",c=>{c.target===t&&r()}),document.addEventListener("keydown",s),t.appendChild(o),t.appendChild(n),document.body.appendChild(t),(i=t.requestFullscreen)==null||i.call(t).catch(()=>{}),o.play().catch(()=>{})}const Qe={props:{videoUrl:{type:String,required:!0}},computed:{posterSrc(){return`${this.videoUrl}#t=0.1`}},methods:{play(){Je(this.videoUrl)}}},Xe=["aria-label"],Ze=["src"];function et(e,t,o,n,r,s){return l(),m("button",{type:"button",class:"flyover-thumb","aria-label":e.$t("comments.comment_flyover_thumb.play_3d_flyover_video"),onClick:t[0]||(t[0]=(...i)=>s.play&&s.play(...i))},[a("video",{class:"flyover-thumb__poster",src:s.posterSrc,muted:"",playsinline:"",preload:"metadata"},null,8,Ze),t[1]||(t[1]=a("span",{class:"flyover-thumb__play material-icons"},"play_arrow",-1))],8,Xe)}const tt=P(Qe,[["render",et],["__scopeId","data-v-27a39e73"]]),$=4;function ot(e){var n;const t=(n=e==null?void 0:e.connectedRecording)==null?void 0:n.readyFlyoverVideoUrl;if(typeof t!="string")return null;const o=t.trim();return o.length>0?o:null}function F(e){const t=[],o=ot(e);return o&&t.push({kind:"flyover",videoUrl:o}),((e==null?void 0:e.images)??[]).forEach((n,r)=>{t.push({kind:"photo",photo:n,photoIndex:r})}),t}function nt(e,t=$){return F(e).slice(0,Math.max(0,t))}function st(e,t=$){return F(e).length>Math.max(0,t)}function it(e,t=$){const n=F(e).slice(Math.max(0,t)).find(r=>r.kind==="photo");return n?n.photoIndex:null}const rt={data(){return{previewTileCount:$}},components:{CommentPhoto:Ke,CommentFlyoverThumb:tt},props:{review:{type:Object,required:!0}},computed:{showMoreButton(){return st(this.review,this.previewTileCount)},allPhotos(){return this.review.images||[]},previewTiles(){return nt(this.review,this.previewTileCount)}},methods:{tileKey(e){return e.kind==="flyover"?"flyover":`photo-${e.photo.id}`},openLightboxAtFirstHidden(){const e=it(this.review,this.previewTileCount);if(e===null)return;const t=this.allPhotos[e];if(t){const o=document.querySelectorAll(`a[data-lightbox="images"][href="${t.file.lgUrl}"]`);o.length>0&&o[0].click()}}}},at={key:0,class:"loading-container"},lt={class:"ms-2"},dt={key:1,class:"photos-container"},mt={class:"image-set-scroll"},ct={class:"view-more-text"};function ut(e,t,o,n,r,s){const i=I("CommentFlyoverThumb"),c=I("CommentPhoto");return l(),m("div",null,[o.review.checkForPhotos?(l(),m("div",at,[t[1]||(t[1]=a("span",{class:"spinner-border spinner-border-sm"},null,-1)),a("span",lt,u(e.$t("comments.comment_photos.loading_images")),1)])):h("",!0),s.previewTiles.length?(l(),m("div",dt,[a("div",mt,[(l(!0),m(y,null,k(s.previewTiles,g=>(l(),m(y,{key:s.tileKey(g)},[g.kind==="flyover"?(l(),N(i,{key:0,"video-url":g.videoUrl},null,8,["video-url"])):(l(),N(c,{key:1,photo:g.photo,index:g.photoIndex,"all-photos":s.allPhotos,title:e.$t("comments.comment_photos.user_photo_number",{name:o.review.user.displayName||e.$t("shared.audits.user"),number:g.photoIndex+1})},null,8,["photo","index","all-photos","title"]))],64))),128)),s.showMoreButton?(l(),m("button",{key:0,class:"view-more-button",onClick:t[0]||(t[0]=(...g)=>s.openLightboxAtFirstHidden&&s.openLightboxAtFirstHidden(...g))},[a("span",ct,[v(u(e.$t("comments.comment_photos.view")),1),t[2]||(t[2]=a("br",null,null,-1)),v(u(e.$t("comments.comment_photos.more_count",{count_of:s.allPhotos.length})),1)])])):h("",!0)])])):h("",!0)])}const gt=P(rt,[["render",ut],["__scopeId","data-v-c08148d2"]]),ht={props:{rating:{type:Number,required:!0}}},_t={class:"comment-star-rating",style:{display:"inline-block"}};function pt(e,t,o,n,r,s){return l(),m("div",_t,[(l(),m(y,null,k(5,i=>a("span",{key:i,class:D(["comment-star",{"comment-star-filled":i<=o.rating}]),style:{"font-size":"1.2em","margin-right":"2px"}}," â
",2)),64))])}const ft=P(ht,[["render",pt],["__scopeId","data-v-8e4833e2"]]),L=(e,t={})=>T.global.t(e,t),yt={name:"CommentThread",components:{CommentLikeable:Be,CommentPhotos:gt,CommentStarRating:ft},props:{comment:{type:Object,required:!0},depth:{type:Number,default:0},maxDepth:{type:Number,default:4},currentUser:{type:Object,required:!0}},emits:["reply-posted","comment-updated","comment-deleted"],setup(e,{emit:t}){const o=B(!1),n=B(!1),r=le("store",null),s=w(()=>e.depth>0?20:0),i=w(()=>e.comment.depth!==void 0&&e.comment.depth!==null?Number(e.comment.depth):e.depth),c=w(()=>i.value>=e.maxDepth),g=w(()=>c.value?!1:e.comment.childComments&&e.comment.childComments.length>0||e.comment.hasChildren||e.comment.childCount>0),_=w(()=>{var b;return c.value?0:e.comment.childCount||((b=e.comment.childComments)==null?void 0:b.length)||0}),f=w(()=>c.value?[]:e.comment.childComments||[]),p=w(()=>e.currentUser&&e.comment.user&&e.currentUser.firebase_user_id===e.comment.user.firebaseUserId),M=w(()=>de(e.comment.createdAt).fromNow()),ee=w(()=>{var R;const b=((R=e.comment)==null?void 0:R.user)||{},O=b.firebaseUserId||b.firebase_user_id;return O?`/users/${O}/profile`:"#"}),te=()=>{c.value||(o.value=!0)},oe=()=>{if(!c.value){if(!e.currentUser){window.onBoardingVue&&typeof window.onBoardingVue.launchFor=="function"&&window.onBoardingVue.launchFor("Reviews");return}r&&r.dispatch("replyToComment",e.comment)}},ne=()=>
30{r&&r.dispatch("editComment",e.comment)},se=()=>{r?r.dispatch("destroyComment",e.comment):t("comment-deleted",e.comment.id)},ie=b=>Q(b),re=b=>$e(b,L),ae=b=>{if(!b)return L("comments.comment.duration_minutes",{minutes:0});const O=Math.floor(b/3600),R=Math.floor(b%3600/60);return O>0?L("comments.comment.duration_hours_minutes",{hours:O,minutes:R}):L("comments.comment.duration_minutes",{minutes:R})};return me(()=>{e.depth<2&&g.value&&(o.value=!0)}),{showChildren:o,children:f,isLoadingChildren:n,indentLevel:s,hasChildren:g,childCount:_,ownedByUser:p,createdAt:M,publicProfileUrl:ee,loadChildren:te,toggleReply:oe,editComment:ne,destroyComment:se,tagLabel:ie,formatDistance:re,formatDuration:ae,atMaxDepth:c}}},bt={class:"comment-thread"},Ct={class:"row"},kt={class:"col-12 d-flex gap-3"},Tt={class:"square",style:{width:"45px",height:"45px"}},vt=["alt","src"],wt={class:"d-flex justify-content-between w-100"},It={class:"d-flex flex-column justify-content-center"},Et={class:"m-0"},Pt=["href"],Mt={class:"text-muted"},St={class:"dropdown"},Ot={key:0,class:"btn btn-secondary dropdown-toggle p-0",type:"button",id:"dropdownMenuButton","data-bs-toggle":"dropdown","aria-haspopup":"true","aria-expanded":"false",style:{width:"30px",height:"30px !important"}},Rt={class:"dropdown-menu","aria-labelledby":"dropdownMenuButton"},Nt={key:0,class:"row mt-3"},Lt={class:"col-12"},Dt={style:{"white-space":"pre-line"}},Ut={key:1,class:"row mt-2"},$t={class:"col-12"},At={class:"row mt-2 mb-2"},Gt={class:"col-sm-1 d-flex align-items-center"},xt={key:0,class:"col-sm-2"},Ht={key:2,class:"row mt-3"},Ft={class:"col-12"},qt={class:"recording-attachment bg-dark rounded p-3"},Bt={class:"d-flex align-items-center"},Vt={class:"text-muted small"},jt={key:0},zt=["href"],Yt={key:0,class:"ml-3 mt-3"},Wt={key:1,class:"ml-3 mt-2"},Kt={key:0,class:"spinner-border spinner-border-sm mr-1"};function Jt(e,t,o,n,r,s){var f;const i=I("CommentStarRating"),c=I("CommentLikeable"),g=I("CommentPhotos"),_=I("CommentThread",!0);return l(),m("div",bt,[a("div",{class:"hike-comments__comment-card comment-card-js-component",style:W({marginLeft:n.indentLevel+"px"})},[t[11]||(t[11]=a("hr",{class:"my-4"},null,-1)),a("div",Ct,[a("div",kt,[a("div",Tt,[a("img",{loading:"lazy",decoding:"async",alt:e.$t("comments.comment.avatar_alt",{name:o.comment.user.displayName}),class:"rounded-circle mb-2 img-fluid",src:o.comment.user.avatar.smUrl},null,8,vt)]),a("div",wt,[a("div",It,[a("p",Et,[a("a",{href:n.publicProfileUrl,class:"comment-user-link"},[a("strong",null,u((f=o.comment.user)==null?void 0:f.displayName),1)],8,Pt),t[7]||(t[7]=a("span",null," - ",-1)),a("span",Mt,u(n.createdAt),1)]),o.comment.rating?(l(),N(i,{key:0,rating:o.comment.rating},null,8,["rating"])):h("",!0)]),a("div",St,[n.ownedByUser?(l(),m("button",Ot)):h("",!0),a("div",Rt,[a("button",{class:"dropdown-item btn btn-link btn-sm",onClick:t[0]||(t[0]=(...p)=>n.editComment&&n.editComment(...p))},u(e.$t("shared.edit")),1),a("button",{class:"dropdown-item btn btn-link btn-sm",onClick:t[1]||(t[1]=(...p)=>n.destroyComment&&n.destroyComment(...p))},u(e.$t("shared.delete")),1)])])])])]),o.comment.body?(l(),m("div",Nt,[a("div",Lt,[a("p",Dt,u(o.comment.body),1)])])):h("",!0),o.comment.tags&&o.comment.tags.length?(l(),m("div",Ut,[a("div",$t,[(l(!0),m(y,null,k(o.comment.tags,p=>(l(),m("span",{key:p,class:"badge card text-white comment-tag mr-2 mb-2 ml-0 mt-0"},u(n.tagLabel(p)),1))),128))])])):h("",!0),a("div",At,[a("div",Gt,[U(c,{likeable:o.comment,likeableType:"Comment",user:o.currentUser},null,8,["likeable","user"])]),n.atMaxDepth?h("",!0):(l(),m("div",xt,[a("button",{class:"btn btn-sm btn-link p-0",onClick:t[2]||(t[2]=(...p)=>n.toggleReply&&n.toggleReply(...p))},[t[8]||(t[8]=a("i",{class:"bi bi-reply"},null,-1)),v(" "+u(e.$t("comments.comment_thread.reply")),1)])])),t[9]||(t[9]=a("div",{class:"col-sm-4"},null,-1))]),U(g,{review:o.comment},null,8,["review"]),o.comment.connectedRecording?(l(),m("div",Ht,[a("div",Ft,[a("div",qt,[a("div",Bt,[t[10]||(t[10]=a("i",{class:"bi bi-geo-alt-fill text-primary me-2"},null,-1)),a("div",null,[a("strong",null,u(o.comment.connectedRecording.title||e.$t("shared.recording")),1),a("div",Vt,[v(u(n.formatDistance(o.comment.connectedRecording.distanceMeters))+" · "+u(n.formatDuration(o.c
30omment.connectedRecording.elapsedSeconds))+" ",1),o.comment.connectedRecording.user?(l(),m("span",jt," · "+u(e.$t("comments.comment.by_display_name",{display_name:o.comment.connectedRecording.user.displayName})),1)):h("",!0)])]),a("a",{href:`/recordings/users/${o.comment.connectedRecording.obfuscatedSlug}/map`,target:"_blank",class:"btn btn-sm btn-outline-primary ms-auto"},u(e.$t("comments.comment_thread.view_recording")),9,zt)])])])])):h("",!0)],4),n.showChildren&&n.children.length>0?(l(),m("div",Yt,[(l(!0),m(y,null,k(n.children,p=>(l(),N(_,{key:p.id,comment:p,depth:o.depth+1,"max-depth":o.maxDepth,"current-user":o.currentUser,onReplyPosted:t[3]||(t[3]=M=>e.$emit("reply-posted",M)),onCommentUpdated:t[4]||(t[4]=M=>e.$emit("comment-updated",M)),onCommentDeleted:t[5]||(t[5]=M=>e.$emit("comment-deleted",M))},null,8,["comment","depth","max-depth","current-user"]))),128))])):h("",!0),n.hasChildren&&!n.showChildren?(l(),m("div",Wt,[a("button",{class:"btn btn-sm btn-link",onClick:t[6]||(t[6]=(...p)=>n.loadChildren&&n.loadChildren(...p))},[n.isLoadingChildren?(l(),m("span",Kt)):h("",!0),v(" "+u(n.isLoadingChildren?e.$t("shared.loading"):n.childCount===1?e.$t("comments.comment_thread.show_one_reply"):e.$t("comments.comment_thread.show_replies",{count:n.childCount})),1)])])):h("",!0)])}const Qt=P(yt,[["render",Jt],["__scopeId","data-v-672916d0"]]),Xt={data(){return{bootstrapModal:null,hoveredRating:0,showAllTags:!1}},computed:{...K(["editingComment","files","photoUrls","uploadedImages","destroyingPhotoIds","clientId","loading","uploading","replyingToComment","selectedTags"]),tagSections(){return X(this.rating)},quickTags(){const e=this.tagSections.find(t=>t.id==="quick");return e?e.tags:[]},expandedTagSections(){return this.tagSections.filter(e=>e.id!=="quick")},hasExpandedTags(){return this.expandedTagSections.length>0},body:{get(){return this.$store.state.body},set(e){this.$store.dispatch("setBody",e)}},rating:{get(){return this.$store.state.rating},set(e){this.$store.dispatch("setRating",Number(e))}},showModal:{get(){return this.$store.state.showModal}},dialogTitle(){var e;return this.editingComment?this.$t("comments.comment_dialog.edit_comment"):this.replyingToComment?this.$t("comments.comment_dialog.reply_to",{name:((e=this.replyingToComment.user)==null?void 0:e.displayName)||this.$t("comments.comment_dialog.comment")}):this.$t("comments.comment_dialog.add_comment")},commentableName(){return this.$store.state.commentableType==="Recording"?"recording":"hike"},commentPlaceholder(){return this.commentableName==="recording"?this.$t("comments.comment_dialog.share_thoughts_recording"):this.$t("comments.comment_dialog.share_thoughts_hike")}},watch:{showModal(e){this.bootstrapModal&&(e?this.bootstrapModal.show():this.bootstrapModal.hide())},rating(){this.showAllTags=!1}},mounted(){const e=this.$refs.modalElement;this.bootstrapModal=new Me(e),this.handleModalHidden=()=>{this.showModal&&this.$store.dispatch("setShowModal",!1),this.resetFileInput()},this.handleModalShow=()=>{this.resetFileInput()},e.addEventListener("hidden.bs.modal",this.handleModalHidden),e.addEventListener("show.bs.modal",this.handleModalShow),this.showModal&&this.bootstrapModal.show()},beforeUnmount(){if(this.bootstrapModal){const e=this.$refs.modalElement;e&&this.handleModalHidden&&this.handleModalShow&&(e.removeEventListener("hidden.bs.modal",this.handleModalHidden),e.removeEventListener("show.bs.modal",this.handleModalShow)),this.bootstrapModal.dispose()}},methods:{resetFileInput(){const e=this.$refs.photosInput;e&&(e.value="")},destroyPhoto(e,t){this.$store.dispatch("destroyPhoto",{photo:e,commentId:this.editingComment.id})},removeFile(e,t){this.$store.dispatch("removeFile",e)},toggleTag(e){this.$store.dispatch("toggleTag",e)},submitComment(){this.$store.dispatch("submitComment")},closeModal(){this.$store.dispatch("setShowModal",!1)},async calculateMD5Base64(e){return new Promise((t,o)=>{const n=new FileReader;n.onload=r=>{const s=new Pe.ArrayBuffer;s.append(r.target.result);const i=s.end(),c=new Uint8Array(i.match(/.{2}/g).map(g=>parseInt(g,16)));t(btoa(String.fromCharCode(...c)))},n.onerror=o,n.readAsArrayBuffer(e)})},async fileInputEvent(){const e=this,t=Array.from(document.getElementById("photosInput").files);t.forEach(o=>{o.progress=0,e.files.push(o)});for(const o of t)try{this.$store.dispatch("setUploading",!0);const n=await this.calculateMD5Base64(o);o.progress=10,e.$forceUpdate();const r=await C.request(be,{input:{filename:o.name,byteSize:o.size,contentType:o.type||"image/jpeg",checksumBase64:n,serviceName:window.publicBucketService}}),{uploadUrl:s,headers:i,signedId:c}=r.generateDirectUpload;o.progress=20,e.$forceUpdate();const g=JSON.parse(i);console.log("Upload URL:",s),console.log("Upload headers:",g);const _=setInterval(()=>{const f=e.files.find(p=>p===o);f&&f.progress<85&&(f.progress+=5,e.$forceUpdate())},100);try{const f=await fetch(s,{method:"PUT",headers:{...g,"Content-Type":o.type||"image/jpeg"},body:o});if(clearInterval(_),!f.ok){const p=await f.text();throw console.error("Upload failed:",f.status,p),new Error(`Upload failed: ${f.statusText} - ${p}`)}}catch(f){throw clearInterval(_),f}o.progress=90,e.$forceUpdate(),o.signedId=c,o.uploadUrl=s,o.photoUrl=s.split("?")[0],e.photoUrls.push(o.photoUrl),e.$store.state.uploadedImages.push({f
30irebaseImageReference:c,signedId:c}),o.progress=100,e.$forceUpdate(),e.files.filter(f=>f.progress===100).length===e.files.length&&(this.$store.dispatch("setUploading",!1),document.getElementById("photosInput").value="")}catch(n){console.error("Upload error:",n),alert(this.$t("comments.comment_dialog.failed_to_upload_image"));const r=e.files.indexOf(o);r>-1&&e.files.splice(r,1),this.$store.dispatch("setUploading",!1)}}}},Zt={class:"modal fade",ref:"modalElement",id:"comment-modal",tabindex:"-1","aria-labelledby":"commentModalLabel","aria-hidden":"true"},eo={class:"modal-dialog"},to={class:"modal-content"},oo={class:"modal-header"},no={class:"modal-title",id:"commentModalLabel"},so=["aria-label"],io={class:"modal-body"},ro={key:0,class:"mb-3"},ao={id:"rating-label",class:"form-label d-block"},lo={class:"star-rating","aria-labelledby":"rating-label"},mo=["id","value","disabled"],co=["for","onMouseenter"],uo={class:"material-icons"},go={key:1,class:"mb-3"},ho={class:"rating-tags"},_o=["disabled","onClick"],po={class:"tag-section-title"},fo={class:"rating-tags"},yo=["disabled","onClick"],bo=["disabled"],Co={class:"mb-3"},ko={for:"input-2",class:"form-label"},To=["placeholder","disabled"],vo={class:"mb-3"},wo={for:"photosInput",class:"form-label"},Io=["disabled"],Eo={key:2,class:"mb-3"},Po={class:"form-label"},Mo=["src","alt"],So=["onClick"],Oo={key:0,class:"spinner-border spinner-border-sm me-1",role:"status","aria-hidden":"true"},Ro={key:1,class:"material-icons me-1 fs-6"},No={key:3,class:"mb-3"},Lo={class:"form-label"},Do={class:"col-5 d-flex align-items-center pe-2"},Uo=["title"],$o={class:"col-4 d-flex align-items-center justify-content-center px-2"},Ao={key:0,class:"progress w-100",style:{height:"10px"}},Go=["aria-valuenow"],xo=["alt","src"],Ho={class:"col-3 d-flex align-items-center justify-content-end ps-2"},Fo=["onClick"],qo={class:"d-flex justify-content-end"},Bo=["disabled"],Vo=["disabled"],jo={key:0,class:"spinner-border spinner-border-sm me-1",role:"status","aria-hidden":"true"};function zo(e,t,o,n,r,s){return l(),m("div",null,[a("div",Zt,[a("div",eo,[a("div",to,[a("div",oo,[a("h5",no,u(s.dialogTitle),1),a("button",{type:"button",class:"btn-close",onClick:t[0]||(t[0]=(...i)=>s.closeModal&&s.closeModal(...i)),"aria-label":e.$t("shared.close")},null,8,so)]),a("div",io,[a("form",{id:"comment-form",class:"p-3",onSubmit:t[7]||(t[7]=A((...i)=>s.submitComment&&s.submitComment(...i),["prevent"]))},[e.replyingToComment?h("",!0):(l(),m("div",ro,[a("label",ao,u(e.$t("comments.comment_dialog.rating")),1),a("div",lo,[(l(),m(y,null,k(5,i=>(l(),m(y,{key:i},[x(a("input",{type:"radio",class:"btn-check",name:"rating",id:"rating"+i,value:i,"onUpdate:modelValue":t[1]||(t[1]=c=>s.rating=c),disabled:e.loading||e.uploading,autocomplete:"off"},null,8,mo),[[ce,s.rating]]),a("label",{class:D(["btn btn-outline-warning star-label",{filled:s.rating>=i||r.hoveredRating>=i&&r.hoveredRating>0}]),for:"rating"+i,onMouseenter:c=>r.hoveredRating=i,onMouseleave:t[2]||(t[2]=c=>r.hoveredRating=0)},[a("i",uo,u(s.rating>=i||r.hoveredRating>=i&&r.hoveredRating>0?"star":"star_border"),1)],42,co)],64))),64))])])),!e.replyingToComment&&s.rating>0?(l(),m("div",go,[t[8]||(t[8]=a("label",{class:"form-label d-block"},[v("Tags "),a("span",{class:"text-muted fw-normal"},"(optional)")],-1)),a("div",ho,[(l(!0),m(y,null,k(s.quickTags,i=>(l(),m("button",{key:i.key,type:"button",class:D(["badge card text-white comment-tag tag-chip",{selected:e.selectedTags.includes(i.key)}]),disabled:e.loading||e.uploading,onClick:c=>s.toggleTag(i.key)},u(i.label),11,_o))),128))]),r.showAllTags?(l(!0),m(y,{key:0},k(s.expandedTagSections,i=>(l(),m("div",{class:"tag-section",key:i.id},[a("div",po,u(i.title),1),a("div",fo,[(l(!0),m(y,null,k(i.tags,c=>(l(),m("button",{key:c.key,type:"button",class:D(["badge card text-white comment-tag tag-chip",{selected:e.selectedTags.includes(c.key)}]),disabled:e.loading||e.uploading,onClick:g=>s.toggleTag(c.key)},u(c.label),11,yo))),128))])]))),128)):h("",!0),s.hasExpandedTags?(l(),m("button",{key:1,type:"button",class:"btn btn-sm btn-link p-0 mt-1 tag-more-toggle",disabled:e.loading||e.uploading,onClick:t[3]||(t[3]=i=>r.showAllTags=!r.showAllTags)},u(r.showAllTags?e.$t("comments.comment_dialog.less"):e.$t("shared.more")),9,bo)):h("",!0)])):h("",!0),a("div",Co,[a("label",ko,u(e.$t("comments.comment_dialog.comment")),1),x(a("textarea",{class:"form-control comment-textarea",id:"input-2","onUpdate:modelValue":t[4]||(t[4]=i=>s.body=i),placeholder:s.commentPlaceholder,rows:"3",style:{"max-height":"calc(1.5em * 6 + 0.75rem + 2px)","overflow-y":"auto"},disabled:e.loading||e.uploading},null,8,To),[[ue,s.body]])]),a("div",vo,[a("label",wo,u(e.$t("comments.comment_dialog.attach_a_photo")),1),a("input",{type:"file",class:"form-control file-input",id:"photosInput",multiple:"",disabled:e.loading||e.uploading,onChange:t[5]||
30(t[5]=(...i)=>s.fileInputEvent&&s.fileInputEvent(...i)),ref:"photosInput",accept:"image/jpeg, image/png"},null,40,Io)]),e.editingComment&&e.editingComment.images&&e.editingComment.images.length>0?(l(),m("div",Eo,[a("label",Po,u(e.$t("comments.comment_dialog.current_photos")),1),(l(!0),m(y,null,k(e.editingComment.images,i=>(l(),m("div",{key:i.id,class:"d-flex align-items-center mb-2"},[a("img",{src:i.file.lgUrl,alt:e.$t("comments.comment_dialog.comment_photo"),style:{width:"64px",height:"64px","object-fit":"cover","object-position":"center","margin-right":"10px",border:"1px solid #dee2e6"}},null,8,Mo),a("button",{onClick:A(c=>s.destroyPhoto(i),["prevent"]),class:"btn btn-sm btn-outline-danger d-flex align-items-center"},[e.destroyingPhotoIds.includes(i.id)?(l(),m("span",Oo)):(l(),m("span",Ro,"delete")),v(" "+u(e.$t("shared.delete")),1)],8,So)]))),128))])):h("",!0),e.files&&e.files.length>0?(l(),m("div",No,[a("label",Lo,u(e.$t("comments.comment_dialog.new_photos")),1),(l(!0),m(y,null,k(e.files,i=>(l(),m("div",{class:"card row g-0 m-0 mb-2 py-2 px-2 align-items-center photo-upload-item",style:{"flex-direction":"row"},key:i.firebaseRefFullPath},[a("div",Do,[a("small",{class:"text-truncate",title:i.name},u(i.name)+" - "+u(Math.round(i.progress))+"%",9,Uo)]),a("div",$o,[i.progress>0&&i.progress<100?(l(),m("div",Ao,[a("div",{class:"progress-bar",role:"progressbar",style:W({width:i.progress+"%"}),"aria-valuenow":i.progress,"aria-valuemin":"0","aria-valuemax":"100"},null,12,Go)])):h("",!0),i.photoUrl?(l(),m("img",{key:1,class:"square",alt:e.$t("comments.comment_dialog.uploaded_preview"),src:i.photoUrl,style:{width:"40px",height:"40px","object-fit":"cover",border:"1px solid #dee2e6"}},null,8,xo)):h("",!0)]),a("div",Ho,[a("button",{onClick:A(c=>s.removeFile(i),["prevent"]),class:"btn btn-sm btn-secondary d-flex align-items-center"},t[9]||(t[9]=[a("span",{class:"material-icons fs-6"},"delete",-1)]),8,Fo)])]))),128))])):h("",!0),a("div",qo,[a("button",{id:"resetButton",type:"button",class:"btn btn-secondary me-2",disabled:e.loading||e.uploading,onClick:t[6]||(t[6]=(...i)=>s.closeModal&&s.closeModal(...i))},u(e.$t("shared.cancel_2")),9,Bo),a("button",{id:"submit-button",type:"submit",class:"btn btn-primary",disabled:e.loading||e.uploading},[e.loading?(l(),m("span",jo)):h("",!0),v(" "+u(e.$t("comments.comment_dialog.submit")),1)],8,Vo)])],32)])])])],512)])}const Yo=P(Xt,[["render",zo]]),Wo={components:{LoadingDialog:Se,CommentThread:Qt,CommentDialog:Yo},setup(){V("graphClient",C);const e=he();e&&V("store",e.proxy.$store)},computed:{...K(["hike","user","error","orderings","showModal","newCommentLoading","loadingMoreComments","commentsPagination"]),...pe(["orderedComments"]),selectedOrder:{get(){return this.$store.state.selectedOrder},set(e){this.$store.dispatch("setSelectedOrder",e)}},commentableName(){return this.$store.state.commentableType==="Recording"?"recording":"hike"},commentButtonLabel(){return this.commentableName==="recording"?this.$t("comments.comment_on_this_recording"):this.$t("comments.comment_on_this_hike")},noCommentsMessage(){return this.commentableName==="recording"?this.$t("comments.be_first_to_comment_recording"):this.$t("comments.be_first_to_comment_hike")},hasMoreComments(){var e;return(e=this.commentsPagination)==null?void 0:e.hasNextPage}},methods:{addComment(){this.$store.dispatch("addComment",null)},async handleReplyPosted({parentCommentId:e,body:t}){console.log("[App.vue] handleReplyPosted received:",{parentCommentId:e,body:t}),console.log("[App.vue] parentCommentId type:",typeof e);try{await this.$store.dispatch("submitReply",{parentCommentId:e,body:t})}catch(o){console.error("Error posting reply:",o),alert(this.$t("comments.failed_to_post_reply"))}},handleCommentUpdated(e){console.log("Comment updated:",e),this.$store.dispatch("fetchHike")},handleCommentDeleted(e){const t=o=>{for(const n of o){if(n.id===e)return n;if(n.childComments){const r=t(n.childComments);if(r)return r}}return null};if(this.hike&&this.hike.comments){const o=t(this.hike.comments);o&&this.$store.dispatch("destroyComment",o)}}
30,loadMoreComments(){this.$store.dispatch("loadMoreComments")},orderLabel(e){switch(e){case"created":return this.$t("comments.order_created");case"rating":return this.$t("comments.order_rating");case"ranking":return this.$t("comments.order_ranking");default:return e}}},mounted(){this.$store.dispatch("fetchHike")}},Ko={key:0},Jo={class:"d-flex justify-content-between"},Qo={class:"d-flex justify-content-end p-3"},Xo=["value"],Zo={class:"hike-comments"},en={id:"comments_container"},tn={key:0,class:"text-center mt-4"},on=["disabled"],nn={key:0,class:"spinner-border spinner-border-sm mr-2"},sn={key:1,class:"d-flex align-items-center my-3 display-5"},rn={key:2},an={key:3},ln={class:"mt-3"};function dn(e,t,o,n,r,s){const i=I("CommentThread"),c=I("CommentDialog"),g=I("LoadingDialog");return l(),m("div",null,[e.hike?(l(),m("div",Ko,[a("div",Jo,[a("button",{onClick:t[0]||(t[0]=(..._)=>s.addComment&&s.addComment(..._)),class:"btn btn-secondary"},u(s.commentButtonLabel),1),a("span",Qo,[x(a("select",{class:"custom-select rounded-pill","onUpdate:modelValue":t[1]||(t[1]=_=>s.selectedOrder=_)},[(l(!0),m(y,null,k(e.orderings,_=>(l(),m("option",{key:_,value:_},u(e.$t("comments.sort_by_order",{order:s.orderLabel(_)})),9,Xo))),128))],512),[[ge,s.selectedOrder]])])]),a("div",Zo,[a("div",en,[(l(!0),m(y,null,k(e.orderedComments,_=>(l(),N(i,{key:_.id,comment:_,depth:0,"max-depth":4,"current-user":e.user,onReplyPosted:s.handleReplyPosted,onCommentUpdated:s.handleCommentUpdated,onCommentDeleted:s.handleCommentDeleted},null,8,["comment","current-user","onReplyPosted","onCommentUpdated","onCommentDeleted"]))),128))]),s.hasMoreComments?(l(),m("div",tn,[a("button",{class:"btn btn-outline-secondary",type:"button",disabled:e.loadingMoreComments,onClick:t[2]||(t[2]=(..._)=>s.loadMoreComments&&s.loadMoreComments(..._))},[e.loadingMoreComments?(l(),m("span",nn)):h("",!0),v(" "+u(e.loadingMoreComments?e.$t("shared.loading"):e.$t("comments.load_more_comments")),1)],8,on)])):h("",!0)])])):h("",!0),e.hike===null?(l(),m("p",sn,[t[3]||(t[3]=a("span",{class:"spinner-border spinner-border-md mr-2"},null,-1)),v(" "+u(e.$t("comments.loading_comments")),1)])):h("",!0),e.error?(l(),m("div",rn,u(e.error),1)):h("",!0),e.hike&&e.hike.comments&&e.hike.comments.length===0&&!e.showModal?(l(),m("div",an,[a("div",ln,[a("h4",null,[a("strong",null,u(e.$t("comments.no_comments_yet")),1)]),a("p",null,u(s.noCommentsMessage),1)])])):h("",!0),U(c,{ref:"commentDialog"},null,512),U(g,{"show-loading-dialog":e.newCommentLoading},null,8,["show-loading-dialog"])])}const mn=P(Wo,[["render",dn],["__scopeId","data-v-a7ccae01"]]),cn={ranking:"ranking_desc",created:"created_desc",rating:"rating_desc"},Y=e=>cn[e]||"ranking_desc",E=fe({state(){return{showModal:!1,loading:!1,newCommentLoading:!1,hikeId:window.hike_id,commentableType:window.commentable_type||"Hike",editingComment:null,user:window.user,hike:null,orderings:["created","rating","ranking"],selectedOrder:"ranking",body:"",rating:null,selectedTags:[],recordingId:null,uploading:!1,clientId:`client_${Math.random().toString(36).substr(2,9)}`,files:[],photoUrls:[],uploadedImages:[],destroyingPhotoIds:[],pollingInterval:3e3,error:null,replyingToComment:null,commentsPagination:{totalCount:0,totalPages:0,currentPage:1,perPage:10,hasNextPage:!1,hasPreviousPage:!1},commentsPerPage:10,loadingMoreComments:!1}},mutations:{SET_USER(e,t){e.user=t},SET_SHOW_MODAL(e,t){e.showModal=t},SET_LOADING(e,t){e.loading=t},SET_UPLOADING(e,t){e.uploading=t},SET_BODY(e,t){e.body=t},SET_RATING(e,t){e.rating=t;const o=new Set(X(t).flatMap(n=>n.tags.map(r=>r.key)));e.selectedTags=e.selectedTags.filter(n=>o.has(n))},SET_SELECTED_TAGS(e,t){e.selectedTags=Array.isArray(t)?[...t]:[]},TOGGLE_TAG(e,t){e.selectedTags.includes(t)?e.selectedTags=e.selectedTags.filter(o=>o!==t):e.selectedTags=[...e.selectedTags,t]},SET_RECORDING_ID(e,t){e.recordingId=t},REMOVE_FILE(e,t){e.files=e.files.filter(o=>o.firebaseRefFullPath!==t.firebaseRefFullPath)},ADD_DESTROYING_PHOTO_ID(e,t){e.destroyingPhotoIds.push(t)},REMOVE_DESTROYING_PHOTO_ID(e,t){e.destroyingPhotoIds=e.destroyingPhotoIds.filter(o=>o!==t)},REMOVE_EDITING_COMMENT_PHOTO(e,t){e.editingComment&&e.editingComment.images&&(e.editingComment.images=e.editingComment.images.filter(o=>o.id!==t))},RESET_COMMENT_FORM_STATE(e){e.body="",e.rating=null,e.selectedTags=[],e.recordingId=null,e.loading=!1,e.files=[],e.photoUrls=[],e.uploadedImages=[]},SET_HIKE(e,{commentable:t,comments:o,pagination:n}){t?e.hike={...t,comments:o||[]}:e.hike=null;const r=(n==null?void 0:n.perPage)||e.commentsPerPage,s=(n==null?void 0:n.totalCount)??(o?o.length:0),i=(n==null?void 0:n.totalPages)??(r>0?Math.max(1,Math.ceil(s/r)):1),c=(n==null?void 0:n.currentPage)??1;e.commentsPerPage=r,e.commentsPagination={totalCount:s,totalPages:i,currentPage:c,perPage:r,hasNextPage:(n==null?void 0:n.hasNextPage)??c<i,hasPreviousPage:(n==null?void 0:n.hasPreviousPage)??c>1},e.hike&&(e.hike.commentsCount=s)},SET_ERROR(e,t){e.error=t},SET_EDITING_COMMENT(e,t){if(e.editingComment=t,t){e.body=t.body,e.rating=t.rating||null,e.selectedTags=Array.isArray(t.tags)?[...t.tags]:[];const o=typeof t.commentableType=="string"?t.commentableType.toLowerCase():"",n=t.connectedRecordingId||null;e.recordingId=o==="recording"?null:n,e.photoUrls=[],e.files=[],e.uploadedImages=[]}},REMOVE_COMMENT_FROM_LIST(e,t){if(!e.hike||!e.hike.comments)return;let o=!1;const n=r=>r.filter(s=>String(s.id)===String(t)?(s.parentCommentId||(o=!0),!1):(s.childComments&&s.childComments.length>0&&(s.childComments=n(s.childComments)),!0));if(e.hike.comments=n(e.hike.comments),o){const r=Math.max(0,e.commentsPagination.totalCount-1),s=e.commentsPagination.perPage>0?Math.max(1,Math.ceil(r/e.commentsPagination.perPage)):e.commentsPagination.totalPages,i=Math.min(e.commentsPagination.currentPage,s);e.commentsPagination={...e.commentsPagination,totalCount:r,totalPages:s,currentPage:i,hasNextPage:i<s,hasPreviousPage:i>1},e.hike&&(e.hike.commentsCount=r)}},UPDATE_COMMENT_IN_LIST(e,t){if(e.hike&&e.hike.comments){const o=n=>n.map(r=>r.id===t.id?{...r,...t}:(r.childComments&&(r.childComments=o(r.childComments)),r));e.hike.comments=o(e.hike.comments)}},ADD_COMMENT_TO_LIST(e,t){if(!e.hike)return;const o={...t,childComments:t.childComments||[],childCount:t.childCount||0,hasChildren:t.hasChildren||(t.childComments||[]).length>0,likeCount:t.likeCount||(t.likes?t.likes.length:0)};if(e.hike.comments||(e.hike.comments=[]),o.parentCommentId){const n=r=>r.map(s=>{if(String(s.id)===String(o.parentCommentId)){s.childComments||(s.childComments=[]);const i=s.childComments.findIndex(c=>
30String(c.id)===String(o.id));i!==-1?s.childComments[i]=o:(s.childComments.unshift(o),s.childCount=(s.childCount||0)+1),s.hasChildren=!0}else s.childComments&&s.childComments.length>0&&(s.childComments=n(s.childComments));return s});e.hike.comments=n(e.hike.comments)}else{const n=e.hike.comments.findIndex(r=>String(r.id)===String(o.id));if(n!==-1)e.hike.comments[n]=o;else{e.hike.comments.unshift(o);const r=e.commentsPagination.totalCount+1,s=e.commentsPagination.perPage>0?Math.max(1,Math.ceil(r/e.commentsPagination.perPage)):e.commentsPagination.totalPages;e.commentsPagination={...e.commentsPagination,totalCount:r,totalPages:s,hasNextPage:e.commentsPagination.currentPage<s},e.hike.commentsCount=r}}},REMOVE_COMMENT_FROM_LIST(e,t){if(!e.hike||!e.hike.comments)return;const o=s=>s.filter(i=>String(i.id)===String(t)?!1:(i.childComments&&i.childComments.length>0&&(i.childComments=o(i.childComments),i.childCount=i.childComments.length,i.hasChildren=i.childComments.length>0),!0));e.hike.comments=o(e.hike.comments);const n=Math.max(0,e.commentsPagination.totalCount-1),r=e.commentsPagination.perPage>0?Math.max(1,Math.ceil(n/e.commentsPagination.perPage)):e.commentsPagination.totalPages;e.commentsPagination={...e.commentsPagination,totalCount:n,totalPages:r,hasNextPage:e.commentsPagination.currentPage<r}},APPEND_COMMENTS(e,{comments:t,pagination:o}){if(!e.hike)return;const n=new Set((e.hike.comments||[]).map(i=>String(i.id))),r=i=>({...i,childComments:i.childComments||[],childCount:i.childCount||0,hasChildren:i.hasChildren||(i.childComments||[]).length>0,likeCount:i.likeCount||(i.likes?i.likes.length:0)}),s=(t||[]).filter(i=>!n.has(String(i.id))).map(r);e.hike.comments=[...e.hike.comments||[],...s],o&&(e.commentsPagination={totalCount:o.totalCount,totalPages:o.totalPages,currentPage:o.currentPage,perPage:o.perPage,hasNextPage:o.hasNextPage,hasPreviousPage:o.hasPreviousPage},e.hike.commentsCount=o.totalCount)},SET_LOADING_MORE_COMMENTS(e,t){e.loadingMoreComments=t},UPDATE_PHOTO_IN_COMMENT(e,t){if(e.hike&&e.hike.comments){const o=e.hike.comments.find(n=>parseInt(n.id)===parseInt(t.recordId));if(o&&o.images){const n=o.images.findIndex(r=>parseInt(r.id)===parseInt(t.id));n!==-1&&o.images.splice(n,1,t)}}},SET_SELECTED_ORDER(e,t){e.selectedOrder=t},SET_REPLYING_TO_COMMENT(e,t){e.replyingToComment=t},SET_NEW_COMMENT_LOADING(e,t){e.newCommentLoading=t}},actions:{setUser({commit:e},t){e("SET_USER",t)},setShowModal({commit:e,dispatch:t},o){o?t("resetState"):e("SET_REPLYING_TO_COMMENT",null),e("SET_SHOW_MODAL",o)},setUploading({commit:e},t){e("SET_UPLOADING",t)},setBody({commit:e},t){e("SET_BODY",t)},setRating({commit:e},t){e("SET_RATING",t)},setSelectedTags({commit:e},t){e("SET_SELECTED_TAGS",t)},toggleTag({commit:e},t){e("TOGGLE_TAG",t)},setRecordingId({commit:e,state:t},o){if((typeof t.commentableType=="string"?t.commentableType.toLowerCase():"")==="recording"){e("SET_RECORDING_ID",null);return}e("SET_RECORDING_ID",o)},removeFile({commit:e},t){e("REMOVE_FILE",t)},resetState({commit:e}){e("RESET_COMMENT_FORM_STATE")},setSelectedOrder({commit:e,dispatch:t},o){e("SET_SELECTED_ORDER",o),t("fetchHike",{page:1})},destroyPhoto({commit:e,state:t},o){const n=o.photo||o;e("ADD_DESTROYING_PHOTO_ID",n.id),C.request(Ee,{image:{id:n.id}}).then(r=>{r&&r.destroyImage?e("REMOVE_EDITING_COMMENT_PHOTO",r.destroyImage.id):e("REMOVE_EDITING_COMMENT_PHOTO",n.id)}).catch(r=>{console.error("Error destroying photo:",r)}).finally(()=>{e("REMOVE_DESTROYING_PHOTO_ID",n.id)})},async fetchHike({state:e,commit:t,dispatch:o},{page:n=1}={}){var r,s,i;t("SET_LOADING",!0),t("SET_ERROR",null);try{let c,g;const _=Y(e.selectedOrder);e.commentableType==="Recording"?(c={page:n,perPage:e.commentsPerPage,sort:_,recordingId:e.hikeId},g=await C.request(ve,c),t("SET_HIKE",{commentable:g.recording,comments:((r=g.commentsConnection)==null?void 0:r.comments)||[],pagination:g.commentsConnection})):e.commentableType==="HikeList"?(c={page:n,perPage:e.commentsPerPage,sort:_,hikeListId:e.hikeId},g=await C.request(we,c),t("SET_HIKE",{commentable:g.hikeList,comments:((s=g.commentsConnection)==null?void 0:s.comments)||[],pagination:g.commentsConnection})):(c={page:n,perPage:e.commentsPerPage,sort:_,hikeId:e.hikeId},g=await C.request(Ie,c),t("SET_HIKE",{commentable:g.hike,comments:((i=g.commentsConnection)==null?void 0:i.comments)||[],pagination:g.commentsConnection})),o("checkCommentUrl")}catch(c){console.error("Error fetching hike data:",c),t("SET_ERROR",T.global.t("comments.main.error_fetching_data",{error:String(c)}))}finally{t("SET_LOADING",!1)}},async loadMoreComments({state:e,commit:t}){var n;if(!e.commentsPagination.hasNextPage||e.loadingMoreComments)return;const o=e.commentsPagination.currentPage+1;t("SET_LOADING_MORE_COMMENTS",!0),t("SET_ERROR",null);try{const r=await C.request(Te,{commentableType:e.commentableType,commentableId:e.hikeId,sort:Y(e.selectedOrder),page:o,perPage:e.commentsPerPage});t("APPEND_COMMENTS",{comments:((n=r.commentsConnection)==null?void 0:n.comments)||[],pagination:r.commentsConnection})}catch(r){console.error("Error loading more comments:",r),t("SET_ERROR",T.global.t("comments.main.failed_to_load_more",{error:String(r)}))}finally{t("SET_LOADING_MORE_COMMENTS",!1)}},checkCommentUrl({state:e,commit:t}){var r,s;const n=new URL(window.location.href).searchParams.get("editing_comment_id");if(n)if(e.user){if(t("SET_LOADING",!0),e.hike&&e.hike.comments){const i=e.hike.comments.find(c=>c.id===n);i?((r=i.user)==null?void 0:r.firebaseUserId)===((s=e.user)==null?void 0:s.firebaseUserId)?(t("SET_EDITING_COMMENT",i),t("SET_SHOW_MODAL",!0)):console.warn("Attempted to edit comment belonging to another user."):console.warn(`Comment with ID ${n} not found.`),t("SET_LOADING",!1)}}else window.onBoardingVue&&typeof window.onBoardingVue.launchFor=="function"?window.onBoardingVue.launchFor(H.ReviewUpdate):console.warn("onBoardingVue not available or launchFor method missing.")},destroyComment({state:e,commit:t},o){confirm(T.global.t("comments.main.confirm_delete_comment"))&&(t("ADD_DESTROYING_PHOTO_ID",o.id),console.log("[destroyComment] Attempting to delete comment ID:",o.id,"Type:",typeof o.id),C.request(ke,{id:o.id}).then(n=>
30{n.destroyComment.success?(console.log("[destroyComment] Successfully deleted comment ID:",o.id),t("REMOVE_COMMENT_FROM_LIST",o.id),e.editingComment&&e.editingComment.id===o.id&&(t("SET_SHOW_MODAL",!1),t("RESET_COMMENT_FORM_STATE"),t("SET_EDITING_COMMENT",null))):(console.error("[destroyComment] Failed to destroy comment:",n.destroyComment.errors),alert(T.global.t("comments.main.failed_to_delete_comment",{errors:n.destroyComment.errors.join(", ")})))}).catch(n=>{console.error("[destroyComment] Error destroying comment:",n),alert(T.global.t("comments.main.error_deleting_comment"))}).finally(()=>{t("REMOVE_DESTROYING_PHOTO_ID",o.id)}))},addComment({state:e,commit:t,dispatch:o},n=null){e.user?(t("SET_EDITING_COMMENT",null),t("SET_REPLYING_TO_COMMENT",n),o("resetState"),t("SET_SHOW_MODAL",!0)):window.onBoardingVue&&typeof window.onBoardingVue.launchFor=="function"?window.onBoardingVue.launchFor(H.Reviews):console.warn("onBoardingVue not available or launchFor method missing.")},replyToComment({dispatch:e},t){e("addComment",t)},async submitReply({state:e,commit:t},{parentCommentId:o,body:n}){try{const r={commentableId:e.hikeId,commentableType:e.commentableType,body:n,parentCommentId:o},i=(await C.request(j,r)).createComment;return t("ADD_COMMENT_TO_LIST",i),i}catch(r){throw console.error("Error submitting reply:",r),r}},editComment({commit:e},t){e("SET_EDITING_COMMENT",t),e("SET_SHOW_MODAL",!0)},updatePhoto({commit:e},t){e("UPDATE_PHOTO_IN_COMMENT",t)},async submitComment({state:e,commit:t,dispatch:o}){if(!e.loading){t("SET_NEW_COMMENT_LOADING",!0),t("SET_LOADING",!0);try{if(e.editingComment){const n=e.uploadedImages.map(c=>c.signedId||c.firebaseImageReference),r={id:e.editingComment.id,body:e.body,...e.rating!==null&&{rating:e.rating},...n.length>0&&{imageSignedIds:n},tagList:e.selectedTags},i=(await C.request(Ce,r)).updateComment.comment;t("UPDATE_COMMENT_IN_LIST",i)}else{const n=e.uploadedImages.map(_=>_.signedId||_.firebaseImageReference),s=(typeof e.commentableType=="string"?e.commentableType.toLowerCase():"")!=="recording"&&e.recordingId?e.recordingId:null,i={commentableId:e.hikeId,commentableType:e.commentableType,body:e.body,...e.rating!==null&&{rating:e.rating},...n.length>0&&{imageSignedIds:n},...e.selectedTags.length>0&&{tagList:e.selectedTags},...e.replyingToComment&&{parentCommentId:e.replyingToComment.id},...s?{connectedRecordingId:s}:{}},g=(await C.request(j,i)).createComment;g.fresh=!0,g.checkForPhotos=n.length>0,t("ADD_COMMENT_TO_LIST",g),t("SET_SELECTED_ORDER","created"),n.length>0&&setTimeout(()=>{o("fetchHike")},3e3)}t("SET_SHOW_MODAL",!1),o("resetState"),t("SET_EDITING_COMMENT",null),t("SET_REPLYING_TO_COMMENT",null)}catch(n){console.error("Error submitting comment:",n),t("SET_ERROR",T.global.t("comments.main.failed_to_submit_comment",{error:String(n)}))}finally{t("SET_LOADING",!1),t("SET_NEW_COMMENT_LOADING",!1)}}}},getters:{orderedComments:e=>!e.hike||!e.hike.comments?[]:e.hike.comments.filter(t=>!t.parentCommentId),allComments:e=>{if(!e.hike||!e.hike.comments)return[];const t=o=>o.reduce((n,r)=>(n.push(r),r.childComments&&n.push(...t(r.childComments)),n),[]);return t(e.hike.comments)},createGetHikeCommentsUrl:e=>{if(e.commentableType==="Recording"){const n='query GetRecordingComments($recordingId: ID!, $page: Int!, $perPage: Int!) { recording(id: $recordingId) { id title averageRating commentsCount ratingsCount } commentsConnection: comments(commentableType: "Recording", commentableId: $recordingId, page: $page, perPage: $perPage) { comments { id body bodyLocale rating createdAt updatedAt parentCommentId user { id firebaseUserId displayName avatar { lgUrl smUrl } } images { id file { id lgUrl smUrl mdUrl } } likes { id user { firebaseUserId } } childComments: paginatedChildComments { id body bodyLocale rating createdAt updatedAt parentCommentId user { id firebaseUserId displayName avatar { smUrl } } } } totalCount totalPages currentPage perPage hasNextPage hasPreviousPage } }',r={recordingId:e.hikeId,page:e.commentsPagination.currentPage,perPage:e.commentsPagination.perPage};return`/graphql?query=${encodeURIComponent(n)}&variables=${encodeURIComponent(JSON.stringify(r))}`}const t='query GetHikeComments($hikeId: ID!, $page: Int!, $perPage: Int!) { hike(id: $hikeId) { id name averageRating commentsCount ratingsCount } commentsConnection: comments(commentableType: "Hike", commentableId: $hikeId, page: $page, perPage: $perPage) { comments { id body bodyLocale rating createdAt updatedAt parentCommentId user { id firebaseUserId displayName avatar { lgUrl smUrl } } images { id file { id lgUrl smUrl mdUrl } } likes { id user { firebaseUserId } } childComments: paginatedChildComments { id body bodyLocale rating createdAt updatedAt parentCommentId user { id firebaseUserId displayName avatar { smUrl } } } } totalCount totalPages currentPage perPage hasNextPage hasPreviousPage } }',o={hikeId:e.hikeId,page:e.commentsPagination.currentPage,perPage:e.commentsPagination.perPage};return`/graphql?query=${encodeURIComponent(t)}&variables=${encodeURIComponent(JSON.stringify(o))}`},isLoading:e=>e.loading,getError:e=>e.error,isModalShown:e=>e.showModal}}),q=_e(mn);q.use(E);q.use(T);const un=()=>typeof E.state.commentableType=="string"&&E.state.commentableType.toLowerCase()==="recording",Z=e=>{const t=(e==null?void 0:e.detail)||{},{recordingId:o=null,parentComment:n=null}=t;setTimeout(()=>{E.dispatch("addComment",n??null),un()||E.dispatch("setRecordingId",o??null)},0)};window.__reviewsOpenCommentListener||(window.__reviewsOpenCommentListener=e=>{Z(e)},document.addEventListener("reviews:open-comment-dialog",window.__reviewsOpenCommentListener));window.openCommentDialog=Z;ye.on("user:updated",async()=>{console.log("User updated event received");try{if(!z){console.error("axiosClient is not initialized.");return}const t=(await z.get("/user/current")).data;window.user=t,E.dispatch("setUser",t),E.state.user&&E.dispatch("checkCommentUrl")}catch(e){console.error("Error fetching updated user:",e),E.commit("SET_ERROR",T.global.t("comments.main.failed_to_update_user",{error:String(e)}))}});q.mount("#comments");const vn=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));
30export{vn as m,Je as o}; 31//# sourceMappingURL=main-B7C62Ayj.js.map
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.