c)&&(f=v,c=v.lng),(p===!1||v.lng=0;c--)d=o[c].getLatLng(),s.push(d);return L.QuickHull.getConvexHull(s)}}),L.MarkerCluster.include({_2PI:Math.PI*2,_circleFootSeparation:25,_circleStartAngle:0,_spiralFootSeparation:28,_spiralLengthStart:11,_spiralLengthFactor:5,_circleSpiralSwitchover:9,spiderfy:function(){if(!(this._group._spiderfied===this||this._group._inZoomAnimation)){var o=this.getAllChildMarkers(null,!0),s=this._group,d=s._map,c=d.latLngToLayerPoint(this._latlng),p;this._group._unspiderfy(),this._group._spiderfied=this,this._group.options.spiderfyShapePositions?p=this._group.options.spiderfyShapePositions(o.length,c):o.length>=this._circleSpiralSwitchover?p=this._generatePointsSpiral(o.length,c):(c.y+=10,p=this._generatePointsCircle(o.length,c)),this._animationSpiderfy(o,p)}},unspiderfy:function(o){this._group._inZoomAnimation||(this._animationUnspiderfy(o),this._group._spiderfied=null)},_generatePointsCircle:function(o,s){var d=this._group.options.spiderfyDistanceMultiplier*this._circleFootSeparation*(2+o),c=d/this._2PI,p=this._2PI/o,m=[],g,f;for(c=Math.max(c,35),m.length=o,g=0;g=0;y--)y=0;m--)p=c[m],d.removeLayer(p),p._preSpiderfyLatlng&&(p.setLatLng(p._preSpiderfyLatlng),delete p._preSpiderfyLatlng),p.setZIndexOffset&&p.setZIndexOffset(0),p._spiderLeg&&(s.removeLayer(p._spiderLeg),delete p._spiderLeg);o.fire("unspiderfied",{cluster:this,markers:c}),o._ignoreMove=!1,o._spiderfied=null}}),L.MarkerClusterNonAnimated=L.MarkerCluster.extend({_animationSpiderfy:function(o,s){var d=this._group,c=d._map,p=d._featureGroup,m=this._group.options.spiderLegPolylineOptions,g,f,y,x;for(d._ignoreMove=!0,g=0;g=0;S--)M=p.layerPointToLatLng(s[S]),v=o[S],v._preSpiderfyLatlng=v._latlng,v.setLatLng(M),v.clusterShow&&v.clusterShow(),y&&(_=v._spiderLeg,w=_._path,w.style.strokeDashoffset=0,_.setStyle({opacity:k}));this.setOpacity(.3),c._ignoreMove=!1,setTimeout(function(){c._animationEnd(),c.fire("spiderfied",{cluster:d,markers:o})},200)},_animationUnspiderfy:function(o){var s=this,d=this._group,c=d._map,p=d._featureGroup,m=o?c._latLngToNewLayerPoint(this._latlng,o.zoom,o.center):c.latLngToLayerPoint(this._latlng),g=this.getAllChildMarkers(null,!0),f=L.Path.SVG,y,x,k,S,v,_;for(d._ignoreMove=!0,d._animationStart(),this.setOpacity(1),x=g.length-1;x>=0;x--)y=g[x],y._preSpiderfyLatlng&&(y.closePopup(),y.setLatLng(y._preSpiderfyLatlng),delete y._preSpiderfyLatlng,_=!0,y._setPos&&(y._setPos(m),_=!1),y.clusterHide&&(y.clusterHide(),_=!1),_&&p.removeLayer(y),f&&(k=y._spiderLeg,S=k._path,v=S.getTotalLength()+.1,S.style.strokeDashoffset=v,k.setStyle({opacity:0})));d._ignoreMove=!1,setTimeout(function(){var w=0;for(x=g.length-1;x>=0;x--)y=g[x],y._spiderLeg&&w++;for(x=g.length-1;x>=0;x--)y=g[x],y._spiderLeg&&(y.clusterShow&&y.clusterShow(),y.setZIndexOffset&&y.setZIndexOffset(0),w>1&&p.removeLayer(y),c.removeLayer(y._spiderLeg),delete y._spiderLeg);d._animationEnd(),d.fire("unspiderfied",{cluster:s,markers:g})},200)}}),L.MarkerClusterGroup.include({_spiderfied:null,unspiderfy:function(){this._unspiderfy.apply(this,arguments)},_spiderfierOnAdd:function(){this._map.on("click",this._unspiderfyWrapper,this),this._map.options.zoomAnimation&&this._map.on("zoomstart",this._unspiderfyZoomStart,this),this._map.on("zoomend",this._noanimationUnspiderfy,this),L.Browser.touch||this._map.getRenderer(this)},_spiderfierOnRemove:function(){this._map.off("click",this._unspiderfyWrapper,this),this._map.off("zoomstart",this._unspiderfyZoomStart,this),this._map.off("zoomanim",this._unspiderfyZoomAnim,this),this._map.off("zoomend",this._noanimationUnspiderfy,this),this._noanimationUnspiderfy()},_unspiderfyZoomStart:function(){this._map&&this._map.on("zoomanim",this._unspiderfyZoomAnim,this)},_unspiderfyZoomAnim:function(o){L.DomUtil.hasClass(this._map._mapPane,"leaflet-touching")||(this._map.off("zoomanim",this._unspiderfyZoomAnim,this),this._unspiderfy(o))},_unspiderfyWrapper:function(){this._unspiderfy()},_unspiderfy:function(o){this._spiderfied&&this._spiderfied.unspiderfy(o)},_noanimationUnspiderfy:function(){this._spiderfied&&this._spiderfied._noanimationUnspiderfy()},_unspiderfyLayer:function(o){o._spiderLeg&&(this._featureGroup.removeLayer(o),o.clusterShow&&o.clusterShow(),o.setZIndexOffset&&o.setZIndexOffset(0),this._map.removeLayer(o._spiderLeg),delete o._spiderLeg)}}),L.MarkerClusterGroup.include({refreshClusters:function(o){return o?o instanceof L.MarkerClusterGroup?o=o._topClusterLevel.getAllChildMarkers():o instanceof L.LayerGroup?o=o._layers:o instanceof L.MarkerCluster?o=o.getAllChildMarkers():o instanceof L.Marker&&(o=[o]):o=this._topClusterLevel.getAllChildMarkers(),this._flagParentsIconsNeedUpdate(o),this._refreshClustersIcons(),this.options.singleMarkerMode&&this._refreshSingleMarkerModeMarkers(o),this},_flagParentsIconsNeedUpdate:function(o){var s,d;for(s in o)for(d=o[s].__parent;d;)d._iconNeedsUpdate=!0,d=d.__parent},_refreshSingleMarkerModeMarkers:function(o){var s,d;for(s in o)d=o[s],this.hasLayer(d)&&d.setIcon(this._overrideMarkerIcon(d))}}),L.Marker.include({refreshIconOptions:function(o,s){var d=this.options.icon;return L.setOptions(d,o),this.setIcon(d),s&&this.__parent&&this.__parent._group.refreshClusters(this),this}}),a.MarkerClusterGroup=n,a.MarkerCluster=i,Object.defineProperty(a,"__esModule",{value:!0})})})(E0,E0.exports);const pI="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAABSCAMAAAAhFXfZAAAC91BMVEVMaXEzeak2f7I4g7g3g7cua5gzeKg8hJo3grY4g7c3grU0gLI2frE0daAubJc2gbQwd6QzeKk2gLMtd5sxdKIua5g1frA2f7IydaM0e6w2fq41fK01eqo3grgubJgta5cxdKI1f7AydaQydaMxc6EubJgvbJkwcZ4ubZkwcJwubZgubJcydqUydKIxapgubJctbJcubZcubJcvbJYubJcvbZkubJctbJctbZcubJg2f7AubJcrbZcubJcubJcua5g3grY0fq8ubJcubJdEkdEwhsw6i88vhswuhcsuhMtBjMgthMsrg8srgss6is8qgcs8i9A9iMYtg8spgcoogMo7hcMngMonf8olfso4gr8kfck5iM8jfMk4iM8he8k1fro7itAgesk2hs8eecgzfLcofssdeMg0hc4cd8g2hcsxeLQbdsgZdcgxeLImfcszhM0vda4xgckzhM4xg84wf8Yxgs4udKsvfcQucqhUndROmdM1fK0wcZ8vb5w0eqpQm9MzeKhXoNVcpdYydKNWn9VZotVKltJFjsIwcJ1Rms9OlslLmtH///8+kc9epdYzd6dbo9VHkMM2f7FHmNBClM8ydqVcpNY9hro3gLM9hLczealQmcw3fa46f7A8gLMxc6I3eagyc6FIldJMl9JSnNRSntNNl9JPnNJFi75UnM9ZodVKksg8kM45jc09e6ZHltFBk883gbRBh7pDk9EwcaBzn784g7dKkcY2i81Om9M7j85Llc81is09g7Q4grY/j9A0eqxKmdFFltBEjcXf6fFImdBCiLxJl9FGlNFBi78yiMxVndEvbpo6js74+vx+psPP3+o/ks5HkcpGmNCjwdZCkNDM3ehYoNJEls+lxNkxh8xHks0+jdC1zd5Lg6r+/v/H2ufz9/o3jM3t8/edvdM/k89Th61OiLBSjbZklbaTt9BfptdjmL1AicBHj8hGk9FAgK1dkLNTjLRekrdClc/k7fM0icy0y9tgp9c4jc2NtM9Dlc8zicxeXZn3AAAAQ3RSTlMAHDdTb4yPA+LtnEQmC4L2EmHqB7XA0d0sr478x4/Yd5i1zOfyPkf1sLVq4Nh3FvjxopQ2/STNuFzUwFIwxKaejILpIBEV9wAABhVJREFUeF6s1NdyFEcYBeBeoQIhRAkLlRDGrhIgY3BJL8CVeKzuyXFzzjkn5ZxzzuScg3PO8cKzu70JkO0LfxdTU//pM9vTu7Xgf6KqOVTb9X7toRrVEfBf1HTVjZccrT/2by1VV928Yty9ZbVuucdz90frG8DBjl9pVApbOstvmMuvVgaNXSfAAd6pGxpy6yxf5ph43pS/4f3uoaGm2rdu72S9xzOvMymkZFq/ptDrk90mhW7e4zl7HLzhxGWPR20xmSxJ/VqldG5m9XhaVOA1DadsNh3Pu5L2N6QtPO/32JpqQBVVk20oy/Pi2s23WEvyfHbe1thadVQttvm7Llf65gGmXK67XtupyoM7HQhmXdLS8oGWJNeOJ3C5fG5XCEJnkez3/oFdsvgJ4l2ANZwhrJKk/7OSXa+3Vw2WJMlKnGkobouYk6T0TyX30klOUnTD9HJ5qpckL3EW/w4XF3Xd0FGywXUrstrclVsqz5Pd/sXFYyDnPdrLcQODmGOK47IZb4CmibmMn+MYRzFZ5jg33ZL/EJrWcszHmANy3ARBK/IXtciJy8VsitPSdE3uuHxzougojcUdr8/32atnz/ev3f/K5wtpxUTpcaI45zusVDpYtZi+jg0oU9b3x74h7+n9ABvYEZeKaVq0sh0AtLKsFtqNBdeT0MrSzwwlq9+x6xAO4tgOtSzbCjrNQQiNvQUbUEubvzBUeGw26yDCsRHCoLkTHDa7IdOLIThs/gHvChszh2CimE8peRs47cxANI0lYNB5y1DljpOF0IhzBDPOZnDOqYYbeGKECbPzWnXludPphw5c2YBq5zlwXphIbO4VDCZ0gnPfUO1TwZoYwAs2ExPCedAu9DAjfQUjzITQb3jNj0KG2Sgt6BHaQUdYzWz+XmBktOHwanXjaSTcwwziBcuMOtwBmqPrTOxFQR/DRKKPqyur0aiW6cULYsx6tBm0jXpR/AUWR6HRq9WVW6MRhIq5jLyjbaCTDCijyYJNpCajdyobP/eTw0iexBAKkJ3gA5KcQb2zBXsIBckn+xVv8jkZSaEFHE+jFEleAEfayRU0MouNoBmB/L50Ai/HSLIHxcrpCvnhSQAuakKp2C/YbCylJjXRVy/z3+Kv/RrNcCo+WUzlVEhzKffnTQnxeN9fWF88fiNCUdSTsaufaChKWInHeysygfpIqagoakW+vV20J8uyl6TyNKEZWV4oRSPyCkWpgOLSbkCObT8o2r6tlG58HQquf6O0v50tB7JM7F4EORd2dx/K0w/KHsVkLPaoYrwgP/y7krr3SSMA4zj+OBgmjYkxcdIJQyQRKgg2viX9Hddi9UBb29LrKR7CVVEEEXWojUkXNyfTNDE14W9gbHJNuhjDettN3ZvbOvdOqCD3Jp/9l+/wJE+9PkYGjx/fqkys3S2rMozM/o2106rfMUINo6hVqz+eu/hd1c4xTg0TAfy5kV+4UG6+IthHTU9woWmxuKNbTfuCSfovBCxq7EtHqvYL4Sm6F8GVxsSXHMQ07TOi1DKtZxjWaaIyi4CXWjxPccUw8WVbMYY5wxC1mzEyXMJWkllpRloi+Kkoq69sxBTlElF6aAxYUbjXNlhlDZilDnM4U5SlN5biRsRHnbx3mbeWjEh4mEyiuJDl5XcWVmX5GvNkFgLWZM5qwsop4/AWfLhU1cR7k1VVvcYCWRkOI6Xy5gmnphCYIkvzuNYzHzosq2oNk2RtSs8khfUOfHIDgR6ysYBaMpl4uEgk2U/oJTs9AaTSwma7dT69geAE2ZpEjUsn2ieJNHeKfrI3EcAGJ2ZaNgVuC8EBctCLc57P5u5led6IOBkIYkuQMrmmjChs4VkfOerHqSBkPzZlhe06RslZ3zMjk2sscqKwY0RcjKK+LWbzd7KiHhkncs/siFJ+V5eXxD34B8nVuJEpGJNmxN2gH3vSvp7J70tF+D1Ej8qUJD1TkErAND2GZwTFg/LubvmgiBG3SOvdlsqFQrkEzJCL1rstlnVFROixZoDDSuXQFHESwVGlcuQcMb/b42NgjLowh5MTDFE3vNB5qStRIErdCQEh6pLPR92anSUb/wAIhldAaDMpGgAAAABJRU5ErkJggg==",mI=Object.freeze(Object.defineProperty({__proto__:null,default:pI},Symbol.toStringTag,{value:"Module"})),gI=rm(mI),hI="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABkAAAApCAYAAADAk4LOAAAFgUlEQVR4Aa1XA5BjWRTN2oW17d3YaZtr2962HUzbDNpjszW24mRt28p47v7zq/bXZtrp/lWnXr337j3nPCe85NcypgSFdugCpW5YoDAMRaIMqRi6aKq5E3YqDQO3qAwjVWrD8Ncq/RBpykd8oZUb/kaJutow8r1aP9II0WmLKLIsJyv1w/kqw9Ch2MYdB++12Onxee/QMwvf4/Dk/Lfp/i4nxTXtOoQ4pW5Aj7wpici1A9erdAN2OH64x8OSP9j3Ft3b7aWkTg/Fm91siTra0f9on5sQr9INejH6CUUUpavjFNq1B+Oadhxmnfa8RfEmN8VNAsQhPqF55xHkMzz3jSmChWU6f7/XZKNH+9+hBLOHYozuKQPxyMPUKkrX/K0uWnfFaJGS1QPRtZsOPtr3NsW0uyh6NNCOkU3Yz+bXbT3I8G3xE5EXLXtCXbbqwCO9zPQYPRTZ5vIDXD7U+w7rFDEoUUf7ibHIR4y6bLVPXrz8JVZEql13trxwue/uDivd3fkWRbS6/IA2bID4uk0UpF1N8qLlbBlXs4Ee7HLTfV1j54APvODnSfOWBqtKVvjgLKzF5YdEk5ewRkGlK0i33Eofffc7HT56jD7/6U+qH3Cx7SBLNntH5YIPvODnyfIXZYRVDPqgHtLs5ABHD3YzLuespb7t79FY34DjMwrVrcTuwlT55YMPvOBnRrJ4VXTdNnYug5ucHLBjEpt30701A3Ts+HEa73u6dT3FNWwflY86eMHPk+Yu+i6pzUpRrW7SNDg5JHR4KapmM5Wv2E8Tfcb1HoqqHMHU+uWDD7zg54mz5/2BSnizi9T1Dg4QQXLToGNCkb6tb1NU+QAlGr1++eADrzhn/u8Q2YZhQVlZ5+CAOtqfbhmaUCS1ezNFVm2imDbPmPng5wmz+gwh+oHDce0eUtQ6OGDIyR0uUhUsoO3vfDmmgOezH0mZN59x7MBi++WDL1g/eEiU3avlidO671bkLfwbw5XV2P8Pzo0ydy4t2/0eu33xYSOMOD8hTf4CrBtGMSoXfPLchX+J0ruSePw3LZeK0juPJbYzrhkH0io7B3k164hiGvawhOKMLkrQLyVpZg8rHFW7E2uHOL888IBPlNZ1FPzstSJM694fWr6RwpvcJK60+0HCILTBzZLFNdtAzJaohze60T8qBzyh5ZuOg5e7uwQppofEmf2++DYvmySqGBuKaicF1blQjhuHdvCIMvp8whTTfZzI7RldpwtSzL+F1+wkdZ2TBOW2gIF88PBTzD/gpeREAMEbxnJcaJHNHrpzji0gQCS6hdkEeYt9DF/2qPcEC8RM28Hwmr3sdNyht00byAut2k3gufWNtgtOEOFGUwcXWNDbdNbpgBGxEvKkOQsxivJx33iow0Vw5S6SVTrpVq11ysA2Rp7gTfPfktc6zhtXBBC+adRLshf6sG2RfHPZ5EAc4sVZ83yCN00Fk/4kggu40ZTvIEm5g24qtU4KjBrx/BTTH8ifVASAG7gKrnWxJDcU7x8X6Ecczhm3o6YicvsLXWfh3Ch1W0k8x0nXF+0fFxgt4phz8QvypiwCCFKMqXCnqXExjq10beH+UUA7+nG6mdG/Pu0f3LgFcGrl2s0kNNjpmoJ9o4B29CMO8dMT4Q5ox8uitF6fqsrJOr8qnwNbRzv6hSnG5wP+64C7h9lp30hKNtKdWjtdkbuPA19nJ7Tz3zR/ibgARbhb4AlhavcBebmTHcFl2fvYEnW0ox9xMxKBS8btJ+KiEbq9zA4RthQXDhPa0T9TEe69gWupwc6uBUphquXgf+/FrIjweHQS4/pduMe5ERUMHUd9xv8ZR98CxkS4F2n3EUrUZ10EYNw7BWm9x1GiPssi3GgiGRDKWRYZfXlON+dfNbM+GgIwYdwAAAAASUVORK5CYII=",fI=Object.freeze(Object.defineProperty({__proto__:null,default:hI},Symbol.toStringTag,{value:"Module"})),yI=rm(fI),vI="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACkAAAApCAQAAAACach9AAACMUlEQVR4Ae3ShY7jQBAE0Aoz/f9/HTMzhg1zrdKUrJbdx+Kd2nD8VNudfsL/Th///dyQN2TH6f3y/BGpC379rV+S+qqetBOxImNQXL8JCAr2V4iMQXHGNJxeCfZXhSRBcQMfvkOWUdtfzlLgAENmZDcmo2TVmt8OSM2eXxBp3DjHSMFutqS7SbmemzBiR+xpKCNUIRkdkkYxhAkyGoBvyQFEJEefwSmmvBfJuJ6aKqKWnAkvGZOaZXTUgFqYULWNSHUckZuR1HIIimUExutRxwzOLROIG4vKmCKQt364mIlhSyzAf1m9lHZHJZrlAOMMztRRiKimp/rpdJDc9Awry5xTZCte7FHtuS8wJgeYGrex28xNTd086Dik7vUMscQOa8y4DoGtCCSkAKlNwpgNtphjrC6MIHUkR6YWxxs6Sc5xqn222mmCRFzIt8lEdKx+ikCtg91qS2WpwVfBelJCiQJwvzixfI9cxZQWgiSJelKnwBElKYtDOb2MFbhmUigbReQBV0Cg4+qMXSxXSyGUn4UbF8l+7qdSGnTC0XLCmahIgUHLhLOhpVCtw4CzYXvLQWQbJNmxoCsOKAxSgBJno75avolkRw8iIAFcsdc02e9iyCd8tHwmeSSoKTowIgvscSGZUOA7PuCN5b2BX9mQM7S0wYhMNU74zgsPBj3HU7wguAfnxxjFQGBE6pwN+GjME9zHY7zGp8wVxMShYX9NXvEWD3HbwJf4giO4CFIQxXScH1/TM+04kkBiAAAAAElFTkSuQmCC",bI=Object.freeze(Object.defineProperty({__proto__:null,default:vI},Symbol.toStringTag,{value:"Module"})),xI=rm(bI);var Js=wr&&wr.__assign||function(){return Js=Object.assign||function(e){for(var t,a=1,n=arguments.length;a/g,">"):""}function EI(e,t,a){const n=a?44:36,i=a?"#111827":"white",o=a?3:2.5,s=a?"0 0 0 3px rgba(17,24,39,0.25), 0 4px 14px rgba(0,0,0,0.3)":"0 2px 8px rgba(0,0,0,0.22)",d=e.category_color||"#6b7280",c=e.category_icon||"📍";let p="";if(t&&t.length>0){const m=t.join(" · ");p=`${m}`}return e.image_url?$a.divIcon({className:"",html:`
+
+
})
+
+ ${p}
+
`,iconSize:[n,n],iconAnchor:[n/2,n/2],tooltipAnchor:[n/2+6,0]}):$a.divIcon({className:"",html:`
+ ${c}
+ ${p}
+
`,iconSize:[n,n],iconAnchor:[n/2,n/2],tooltipAnchor:[n/2+6,0]})}function AI({places:e,selectedPlaceId:t,dayPlaces:a,paddingOpts:n}){const i=Ro(),o=b.useRef(null);return b.useEffect(()=>{if(t&&t!==o.current){const s=e.find(d=>d.id===t);s!=null&&s.lat&&(s!=null&&s.lng)&&i.panTo([s.lat,s.lng],{animate:!0})}o.current=t},[t,e,i]),null}function NI({center:e,zoom:t}){const a=Ro(),n=b.useRef(e);return b.useEffect(()=>{(n.current[0]!==e[0]||n.current[1]!==e[1])&&(a.setView(e,t),n.current=e)},[e,t,a]),null}function RI({places:e,fitKey:t,paddingOpts:a}){const n=Ro(),i=b.useRef(-1);return b.useEffect(()=>{if(t!==i.current&&(i.current=t,e.length!==0))try{const o=$a.latLngBounds(e.map(s=>[s.lat,s.lng]));o.isValid()&&n.fitBounds(o,{...a,maxZoom:16,animate:!0})}catch{}},[t,e,a,n]),null}function MI({onClick:e}){const t=Ro();return b.useEffect(()=>{if(e)return t.on("click",e),()=>t.off("click",e)},[t,e]),null}function DI({onContextMenu:e}){const t=Ro();return b.useEffect(()=>{if(e)return t.on("contextmenu",e),()=>t.off("contextmenu",e)},[t,e]),null}function II({midpoint:e,walkingText:t,drivingText:a}){const n=Ro(),[i,o]=b.useState(n?n.getZoom()>=12:!1);if(b.useEffect(()=>{if(!n)return;const d=()=>o(n.getZoom()>=12);return d(),n.on("zoomend",d),()=>n.off("zoomend",d)},[n]),!i||!e)return null;const s=$a.divIcon({className:"route-info-pill",html:`
+
+
+ ${t}
+
+
|
+
+
+ ${a}
+
+
`,iconSize:[0,0],iconAnchor:[0,0]});return r.jsx(Jv,{position:e,icon:s,interactive:!1,zIndexOffset:2e3})}const rd=new Map,th=new Set;function LI(){const e=Ro(),[t,a]=b.useState(null),[n,i]=b.useState(0),[o,s]=b.useState(!1),d=b.useRef(null),c=b.useCallback(()=>{"geolocation"in navigator&&(s(!0),d.current=navigator.geolocation.watchPosition(f=>{const y=[f.coords.latitude,f.coords.longitude];a(y),i(f.coords.accuracy)},()=>s(!1),{enableHighAccuracy:!0,maximumAge:5e3}))},[]),p=b.useCallback(()=>{d.current!==null&&navigator.geolocation.clearWatch(d.current),d.current=null,s(!1),a(null)},[]),m=b.useCallback(()=>{o?p():c()},[o,c,p]),g=b.useRef(!1);return b.useEffect(()=>{t&&!g.current&&(e.setView(t,15),g.current=!0)},[t,e]),b.useEffect(()=>()=>{d.current!==null&&navigator.geolocation.clearWatch(d.current)},[]),r.jsxs(r.Fragment,{children:[r.jsx("div",{style:{position:"absolute",bottom:20,right:10,zIndex:1e3},children:r.jsx("button",{onClick:m,style:{width:36,height:36,borderRadius:"50%",border:"none",cursor:"pointer",background:o?"#3b82f6":"var(--bg-card, white)",color:o?"white":"var(--text-muted, #6b7280)",boxShadow:"0 2px 8px rgba(0,0,0,0.2)",display:"flex",alignItems:"center",justifyContent:"center",transition:"background 0.2s, color 0.2s"},children:r.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("circle",{cx:"12",cy:"12",r:"3"}),r.jsx("path",{d:"M12 2v4M12 18v4M2 12h4M18 12h4"})]})})}),t&&r.jsxs(r.Fragment,{children:[n<500&&r.jsx(lI,{center:t,radius:n,pathOptions:{color:"#3b82f6",fillColor:"#3b82f6",fillOpacity:.06,weight:.5,opacity:.3}}),r.jsx(dI,{center:t,radius:7,pathOptions:{color:"white",fillColor:"#3b82f6",fillOpacity:1,weight:2.5}})]}),t&&r.jsx("style",{children:`
+ @keyframes location-pulse {
+ 0% { transform: scale(1); opacity: 0.6; }
+ 100% { transform: scale(2.5); opacity: 0; }
+ }
+ `})]})}function FI({places:e=[],dayPlaces:t=[],route:a=null,routeSegments:n=[],selectedPlaceId:i=null,onMarkerClick:o,onMapClick:s,onMapContextMenu:d=null,center:c=[48.8566,2.3522],zoom:p=10,tileUrl:m="https://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}{r}.png",fitKey:g=0,dayOrderMap:f={},leftWidth:y=0,rightWidth:x=0,hasInspector:k=!1}){const S=b.useMemo(()=>{if(typeof window<"u"&&window.innerWidth<768)return{padding:[40,20]};const E=60,M=k?320:60,A=y+40,P=x+40;return{paddingTopLeft:[A,E],paddingBottomRight:[P,M]}},[y,x,k]),[v,_]=b.useState({});return b.useEffect(()=>{const w=e.filter(R=>{if(R.image_url)return!1;const $=R.google_place_id||R.osm_id||`${R.lat},${R.lng}`;if(!$)return!1;if(rd.has($)){const Y=rd.get($);return Y&&_(H=>H[$]===Y?H:{...H,[$]:Y}),!1}return!(th.has($)||!(R.google_place_id||R.osm_id)&&!(R.lat&&R.lng))});let E=0;const M=3;let A=0;const P=()=>{for(;E{Y.photoUrl?(rd.set($,Y.photoUrl),_(H=>({...H,[$]:Y.photoUrl}))):rd.set($,null)}).catch(()=>{rd.set($,null)}).finally(()=>{th.delete($),E--,P()})}};P()},[e]),r.jsxs(W_,{center:c,zoom:p,zoomControl:!1,className:"w-full h-full",style:{background:"#e5e7eb"},children:[r.jsx($_,{url:m,attribution:'© OpenStreetMap',maxZoom:19}),r.jsx(NI,{center:c,zoom:p}),r.jsx(RI,{places:t.length>0?t:e,fitKey:g,paddingOpts:S}),r.jsx(AI,{places:e,selectedPlaceId:i,dayPlaces:t,paddingOpts:S}),r.jsx(MI,{onClick:s}),r.jsx(DI,{onContextMenu:d}),r.jsx(LI,{}),r.jsx(zI,{chunkedLoading:!0,maxClusterRadius:30,disableClusteringAtZoom:11,spiderfyOnMaxZoom:!0,showCoverageOnHover:!1,zoomToBoundsOnClick:!0,singleMarkerMode:!0,iconCreateFunction:w=>{const E=w.getChildCount(),M=E<10?36:E<50?42:48;return $a.divIcon({html:`
+ ${E}
+
`,className:"marker-cluster-wrapper",iconSize:$a.point(M,M)})},children:e.map(w=>{const E=w.id===i,M=w.google_place_id||w.osm_id||`${w.lat},${w.lng}`,A=w.image_url||M&&v[M]||null,P=f[w.id]??null,R=EI({...w,image_url:A},P,E);return r.jsx(Jv,{position:[w.lat,w.lng],icon:R,eventHandlers:{click:()=>o&&o(w.id)},zIndexOffset:E?1e3:0,children:r.jsx(V_,{direction:"right",offset:[0,0],opacity:1,className:"map-tooltip",children:r.jsxs("div",{style:{fontFamily:"-apple-system, BlinkMacSystemFont, 'SF Pro Text', system-ui, sans-serif"},children:[r.jsx("div",{style:{fontWeight:600,fontSize:12,color:"var(--text-primary)",whiteSpace:"nowrap"},children:w.name}),w.category_name&&(()=>{const $=ci(w.category_icon);return r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:3,marginTop:1},children:[r.jsx($,{size:10,style:{color:w.category_color||"var(--text-muted)",flexShrink:0}}),r.jsx("span",{style:{fontSize:11,color:"var(--text-muted)"},children:w.category_name})]})})(),w.address&&r.jsx("div",{style:{fontSize:11,color:"var(--text-faint)",marginTop:2,maxWidth:180,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:w.address})]})})},w.id)})}),a&&a.length>1&&r.jsxs(r.Fragment,{children:[r.jsx(P0,{positions:a,color:"#111827",weight:3,opacity:.9,dashArray:"6, 5"}),n.map((w,E)=>r.jsx(II,{midpoint:w.mid,from:w.from,to:w.to,walkingText:w.walkingText,drivingText:w.drivingText},E))]}),e.map(w=>{if(!w.route_geometry)return null;try{const E=JSON.parse(w.route_geometry);return!E||E.length<2?null:r.jsx(P0,{positions:E,color:w.category_color||"#3b82f6",weight:3.5,opacity:.75},`gpx-${w.id}`)}catch{return null}})]})}const OI={FileText:Pa,Info:Im,Clock:Nn,MapPin:tn,Navigation:ps,Train:Ui,Plane:Or,Bus:jc,Car:Bi,Ship:Hi,Coffee:Rm,Ticket:kn,Star:si,Heart:Dm,Camera:Ir,Flag:Lv,Lightbulb:x_,AlertTriangle:li,ShoppingBag:Fv,Bookmark:u_};function BI(e){if(!_o)return"";const t=OI[e]||Pa;return _o(b.createElement(t,{size:14,strokeWidth:1.8,color:"#94a3b8"}))}const HI={flight:Or,train:Ui,bus:jc,car:Bi,cruise:Hi};function UI(e){if(!_o)return"";const t=HI[e]||kn;return _o(b.createElement(t,{size:14,strokeWidth:1.8,color:"#3b82f6"}))}const WI='',$I='',VI='';function ra(e){return e?String(e).replace(/&/g,"&").replace(//g,">").replace(/"/g,"""):""}function Gf(e){return e?e.startsWith("http://")||e.startsWith("https://")||e.startsWith("data:")?e:window.location.origin+(e.startsWith("/")?"":"/")+e:null}function A0(e){return e?e.startsWith("https://")||e.startsWith("http://")?e:/\.(jpe?g|png|webp|bmp|tiff?)(\?.*)?$/i.test(e)?Gf(e):null:null}let _o=null;async function KI(){_o||(_o=(await Hv(()=>Promise.resolve().then(()=>lW),void 0)).renderToStaticMarkup)}function qI(e,t="#6366f1",a=24){if(!_o)return"";const n=ci(e);return _o(b.createElement(n,{size:a,strokeWidth:1.8,color:"rgba(255,255,255,0.92)"}))}function GI(e,t){return e?new Date(e+"T00:00:00").toLocaleDateString(t,{weekday:"short",day:"numeric",month:"short"}):""}function ZI(e,t){const a=[...e].filter(o=>o.date).sort((o,s)=>o.day_number-s.day_number);if(!a.length)return null;const n=new Date(a[0].date+"T00:00:00"),i=new Date(a[a.length-1].date+"T00:00:00");return`${n.toLocaleDateString(t,{day:"numeric",month:"long"})} – ${i.toLocaleDateString(t,{day:"numeric",month:"long",year:"numeric"})}`}function YI(e,t,a){const n=(e[String(t)]||[]).reduce((i,o)=>{var s;return i+(parseFloat((s=o.place)==null?void 0:s.price)||0)},0);return n>0?`${n.toLocaleString(a)} EUR`:null}async function XI(e){const t={},a=Object.values(e).flatMap(o=>o.map(s=>s.place)).filter(Boolean),i=[...new Map(a.map(o=>[o.id,o])).values()].filter(o=>!o.image_url&&o.google_place_id);return await Promise.allSettled(i.map(async o=>{try{const s=await ko.placePhoto(o.google_place_id);s.photoUrl&&(t[o.id]=s.photoUrl)}catch{}})),t}async function JI({trip:e,days:t,places:a,assignments:n,categories:i,dayNotes:o,reservations:s=[],t:d,locale:c}){await KI();const p=c||void 0,m=d||(P=>P),g=[...t||[]].sort((P,R)=>P.day_number-R.day_number),f=ZI(g,p),y=A0(e==null?void 0:e.cover_image),x=await XI(n),k=new Set(Object.values(n||{}).flatMap(P=>P.map(R=>{var $;return($=R.place)==null?void 0:$.id})).filter(Boolean)).size,S=Object.values(n||{}).flatMap(P=>P).reduce((P,R)=>{var $;return P+(parseFloat(($=R.place)==null?void 0:$.price)||0)},0),v=g.map((P,R)=>{const $=n[String(P.id)]||[],I=(o||[]).filter(Q=>Q.day_id===P.id),Y=YI(n,P.id,p),H=new Set(["flight","train","bus","car","cruise"]),V=(s||[]).filter(Q=>!Q.reservation_time||!H.has(Q.type)?!1:P.date&&Q.reservation_time.split("T")[0]===P.date),X=[];$.forEach(Q=>X.push({type:"place",k:Q.order_index??Q.sort_order??0,data:Q})),I.forEach(Q=>X.push({type:"note",k:Q.sort_order??0,data:Q})),V.forEach(Q=>{const D=Q.day_plan_position??(X.length>0?Math.max(...X.map(J=>J.k))+.5:.5);X.push({type:"transport",k:D,data:Q})}),X.sort((Q,D)=>Q.k-D.k);let Z=0;const O=X.length===0?`${ra(m("dayplan.emptyDay"))}
`:X.map(Q=>{var oe,be;if(Q.type==="transport"){const Se=Q.data,je=typeof Se.metadata=="string"?JSON.parse(Se.metadata||"{}"):Se.metadata||{},we=UI(Se.type);let ce="";Se.type==="flight"?ce=[je.airline,je.flight_number,je.departure_airport&&je.arrival_airport?`${je.departure_airport} → ${je.arrival_airport}`:""].filter(Boolean).join(" · "):Se.type==="train"&&(ce=[je.train_number,je.platform?`Gl. ${je.platform}`:"",je.seat?`Seat ${je.seat}`:""].filter(Boolean).join(" · "));const le=(oe=Se.reservation_time)!=null&&oe.includes("T")?(be=Se.reservation_time.split("T")[1])==null?void 0:be.substring(0,5):"";return`
+
+
+
${we}
+
+
${ra(Se.title)}${le?` ${le}`:""}
+ ${ce?`
${ra(ce)}
`:""}
+ ${Se.confirmation_number?`
Code: ${ra(Se.confirmation_number)}
`:""}
+
+
`}if(Q.type==="note"){const Se=Q.data;return`
+
+
+
${BI(Se.icon)}
+
+
${ra(Se.text)}
+ ${Se.time?`
${ra(Se.time)}
`:""}
+
+
`}Z++;const D=Q.data.place;if(!D)return"";const J=i.find(Se=>Se.id===D.category_id),z=(J==null?void 0:J.color)||"#6366f1",W=A0(D.image_url),B=x[D.id]||null,C=W||B,U=qI(J==null?void 0:J.icon,z,24),q=C?`
`:`
+ ${U}
+
`,te=[D.place_time?`${$I}${ra(D.place_time)}`:"",D.price&&parseFloat(D.price)>0?`${VI}${Number(D.price).toLocaleString(p)} EUR`:""].filter(Boolean).join("");return`
+
+
+ ${q}
+
+
+ ${Z}
+ ${ra(D.name)}
+ ${J?`${ra(J.name)}`:""}
+
+ ${D.address?`
${WI}${ra(D.address)}
`:""}
+ ${D.description?`
${ra(D.description)}
`:""}
+ ${te?`
${te}
`:""}
+ ${D.notes?`
${ra(D.notes)}
`:""}
+
+
`}).join("");return`
+ `}).join(""),_=`
+
+
+
+
+${ra((e==null?void 0:e.title)||m("pdf.travelPlan"))}
+
+
+
+
+
+
+
+
+
+
+ ${y?`
`:""}
+
+
+
+ ${y?`
`:'
'}
+
${ra(m("pdf.travelPlan"))}
+
${ra((e==null?void 0:e.title)||"My Trip")}
+ ${e!=null&&e.description?`
${ra(e.description)}
`:""}
+ ${f?`
${f}
`:""}
+
+
+
+
${g.length}
+
${ra(m("dashboard.days"))}
+
+
+
${(a==null?void 0:a.length)||0}
+
${ra(m("dashboard.places"))}
+
+
+
${k}
+
${ra(m("pdf.planned"))}
+
+ ${S>0?`
+
${S.toLocaleString(p)}
+
${ra(m("pdf.costLabel"))}
+
`:""}
+
+
+
+
+
+${v}
+
+`,w=document.createElement("div");w.id="pdf-preview-overlay",w.style.cssText="position:fixed;inset:0;background:rgba(0,0,0,0.7);z-index:9999;display:flex;align-items:center;justify-content:center;padding:8px;",w.onclick=P=>{P.target===w&&w.remove()};const E=document.createElement("div");E.style.cssText="width:100%;max-width:1000px;height:95vh;background:var(--bg-card);border-radius:12px;overflow:hidden;display:flex;flex-direction:column;box-shadow:0 20px 60px rgba(0,0,0,0.3);";const M=document.createElement("div");M.style.cssText="display:flex;align-items:center;justify-content:space-between;padding:10px 16px;border-bottom:1px solid var(--border-primary);flex-shrink:0;",M.innerHTML=`
+ ${ra((e==null?void 0:e.title)||m("pdf.travelPlan"))}
+
+
+
+
+ `;const A=document.createElement("iframe");A.style.cssText="flex:1;width:100%;border:none;",A.sandbox="allow-same-origin allow-modals",A.srcdoc=_,E.appendChild(M),E.appendChild(A),w.appendChild(E),document.body.appendChild(w),M.querySelector("#pdf-close-btn").onclick=()=>w.remove(),M.querySelector("#pdf-print-btn").onclick=()=>{var P;(P=A.contentWindow)==null||P.print()}}const QI="https://router.project-osrm.org/route/v1";function e4(e){const t=e.filter(n=>n.lat&&n.lng);return t.length===0?null:t.length===1?`https://www.google.com/maps/search/?api=1&query=${t[0].lat},${t[0].lng}`:`https://www.google.com/maps/dir/${t.map(n=>`${n.lat},${n.lng}`).join("/")}`}function t4(e){const t=e.filter(o=>o.lat&&o.lng);if(t.length<=2)return e;const a=new Set,n=[];let i=t[0];for(a.add(0),n.push(i);n.length`${c.lng},${c.lat}`).join(";"),n=`${QI}/driving/${a}?overview=false&geometries=geojson&steps=false&annotations=distance,duration`,i=await fetch(n,{signal:t});if(!i.ok)throw new Error("Route could not be calculated");const o=await i.json();if(o.code!=="Ok"||!((d=o.routes)!=null&&d[0]))throw new Error("No route found");return o.routes[0].legs.map((c,p)=>{const m=[e[p].lat,e[p].lng],g=[e[p+1].lat,e[p+1].lng],f=[(m[0]+g[0])/2,(m[1]+g[1])/2],y=c.distance/(5e3/3600);return{mid:f,from:m,to:g,walkingText:N0(y),drivingText:N0(c.duration)}})}function N0(e){const t=Math.floor(e/3600),a=Math.floor(e%3600/60);return t>0?`${t} h ${a} min`:`${a} min`}const uu=new Map,pu=new Set,Qs=new Map;function R0(e,t){const a=Qs.get(e);a&&(a.forEach(n=>n(t)),Qs.delete(e))}const tb=Ka.memo(function({place:t,size:a=32,category:n}){const[i,o]=b.useState(t.image_url||null);b.useEffect(()=>{if(t.image_url){o(t.image_url);return}const m=t.google_place_id||t.osm_id;if(!m&&!(t.lat&&t.lng)){o(null);return}const g=m||`${t.lat},${t.lng}`;if(uu.has(g)){const f=uu.get(g);f&&o(f);return}if(pu.has(g)){Qs.has(g)||Qs.set(g,new Set);const f=y=>{y&&o(y)};return Qs.get(g).add(f),()=>{var y;(y=Qs.get(g))==null||y.delete(f)}}pu.add(g),ko.placePhoto(m||`coords:${t.lat}:${t.lng}`,t.lat,t.lng,t.name).then(f=>{const y=f.photoUrl||null;uu.set(g,y),y&&o(y),R0(g,y),pu.delete(g)}).catch(()=>{uu.set(g,null),R0(g,null),pu.delete(g)})},[t.id,t.image_url,t.google_place_id,t.osm_id]);const s=(n==null?void 0:n.color)||"#6366f1",d=ci(n==null?void 0:n.icon),c=Math.round(a*.46),p={width:a,height:a,borderRadius:"50%",overflow:"hidden",flexShrink:0,backgroundColor:s,display:"flex",alignItems:"center",justifyContent:"center"};return i?r.jsx("div",{style:p,children:r.jsx("img",{src:i,alt:t.name,loading:"lazy",style:{width:"100%",height:"100%",objectFit:"cover"},onError:()=>o(null)})}):r.jsx("div",{style:p,children:r.jsx(d,{size:c,strokeWidth:1.8,color:"rgba(255,255,255,0.92)"})})});function q_(){const[e,t]=b.useState(null);return{menu:e,open:(i,o)=>{i.preventDefault(),i.stopPropagation(),t({x:i.clientX,y:i.clientY,items:o})},close:()=>t(null)}}function G_({menu:e,onClose:t}){const a=b.useRef(null);return b.useEffect(()=>{if(!e)return;const n=()=>t();return document.addEventListener("click",n),document.addEventListener("contextmenu",n),()=>{document.removeEventListener("click",n),document.removeEventListener("contextmenu",n)}},[e,t]),b.useEffect(()=>{if(!e||!a.current)return;const n=a.current,i=n.getBoundingClientRect();let{x:o,y:s}=e;o+i.width>window.innerWidth-8&&(o=window.innerWidth-i.width-8),s+i.height>window.innerHeight-8&&(s=window.innerHeight-i.height-8),(o!==e.x||s!==e.y)&&(n.style.left=`${o}px`,n.style.top=`${s}px`)},[e]),e?Vt.createPortal(r.jsxs("div",{ref:a,style:{position:"fixed",left:e.x,top:e.y,zIndex:999999,background:"var(--bg-card)",borderRadius:10,padding:"4px",border:"1px solid var(--border-primary)",boxShadow:"0 8px 30px rgba(0,0,0,0.15)",backdropFilter:"blur(20px)",WebkitBackdropFilter:"blur(20px)",minWidth:160,fontFamily:"-apple-system, BlinkMacSystemFont, 'SF Pro Text', system-ui, sans-serif",animation:"ctxIn 0.1s ease-out"},children:[e.items.filter(Boolean).map((n,i)=>{if(n.divider)return r.jsx("div",{style:{height:1,background:"var(--border-faint)",margin:"3px 6px"}},i);const o=n.icon;return r.jsxs("button",{onClick:()=>{var s;(s=n.onClick)==null||s.call(n),t()},style:{display:"flex",alignItems:"center",gap:8,width:"100%",padding:"7px 10px",borderRadius:7,border:"none",background:"none",cursor:"pointer",fontFamily:"inherit",fontSize:12,fontWeight:500,textAlign:"left",color:n.danger?"#ef4444":"var(--text-primary)",transition:"background 0.1s"},onMouseEnter:s=>s.currentTarget.style.background=n.danger?"rgba(239,68,68,0.08)":"var(--bg-hover)",onMouseLeave:s=>s.currentTarget.style.background="none",children:[o&&r.jsx(o,{size:13,style:{flexShrink:0,color:n.danger?"#ef4444":"var(--text-faint)"}}),r.jsx("span",{children:n.label})]},i)}),r.jsx("style",{children:"@keyframes ctxIn { from { opacity: 0; transform: scale(0.95) } to { opacity: 1; transform: scale(1) } }"})]}),document.body):null}const n4={Clear:Rl,Clouds:Nm,Rain:Iv,Drizzle:g_,Thunderstorm:h_,Snow:f_,Mist:is,Fog:is,Haze:is};function M0({main:e,size:t=13}){const a=n4[e]||Nm;return r.jsx(a,{size:t,strokeWidth:1.8})}function r4(e){try{const t=sessionStorage.getItem(e);return t===null?void 0:JSON.parse(t)}catch{return}}function D0(e,t){try{sessionStorage.setItem(e,JSON.stringify(t))}catch{}}function i4({lat:e,lng:t,date:a,compact:n=!1}){const[i,o]=b.useState(null),[s,d]=b.useState(!1),[c,p]=b.useState(!1),m=ta(S=>S.settings.temperature_unit)==="fahrenheit";if(b.useEffect(()=>{if(!e||!t||!a)return;const S=Math.round(e*100)/100,v=Math.round(t*100)/100,_=`weather_${S}_${v}_${a}`,w=r4(_);if(w!==void 0){if(w===null)p(!0);else if(w.type==="climate"){o(w),Np.get(e,t,a).then(E=>{!E.error&&E.temp!==void 0&&E.type==="forecast"&&(D0(_,E),o(E))}).catch(()=>{});return}else{o(w);return}return}d(!0),Np.get(e,t,a).then(E=>{E.error||E.temp===void 0?p(!0):(D0(_,E),o(E))}).catch(()=>{p(!0)}).finally(()=>d(!1))},[e,t,a]),!e||!t)return null;const g={fontFamily:"-apple-system, BlinkMacSystemFont, 'SF Pro Text', system-ui, sans-serif"};if(s)return r.jsx("span",{style:{fontSize:11,color:"#d1d5db",...g},children:"…"});if(c||!i)return r.jsx("span",{style:{fontSize:11,color:"#9ca3af",...g},children:"—"});const f=i.temp,y=f!==void 0?Math.round(m?f*9/5+32:f):null,x=m?"°F":"°C",k=i.type==="climate";return n?r.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:3,fontSize:11,color:k?"#a1a1aa":"#6b7280",...g},children:[r.jsx(M0,{main:i.main,size:12}),y!==null&&r.jsxs("span",{children:[k?"Ø ":"",y,x]})]}):r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,fontSize:13,color:k?"#71717a":"#374151",background:"rgba(0,0,0,0.04)",borderRadius:8,padding:"5px 10px",...g},children:[r.jsx(M0,{main:i.main,size:15}),y!==null&&r.jsxs("span",{style:{fontWeight:500},children:[k?"Ø ":"",y,x]}),i.description&&r.jsx("span",{style:{fontSize:11,color:"#9ca3af",textTransform:"capitalize"},children:i.description})]})}const o4=new Set(["JPY","KRW","VND","CLP","ISK","HUF"]);function el(e){return o4.has(e.toUpperCase())?0:2}function s4(e,t,a){if(!e)return null;const n={weekday:"short",day:"numeric",month:"short"};return new Date(e+"T00:00:00").toLocaleDateString(t,n)}function I0(e,t,a){if(!e)return"";try{const n=e.split(":"),i=Number(n[0])||0,o=Number(n[1])||0;if(isNaN(i))return e;if(a==="12h"){const d=i>=12?"PM":"AM";return`${i===0?12:i>12?i-12:i}:${String(o).padStart(2,"0")} ${d}`}const s=`${String(i).padStart(2,"0")}:${String(o).padStart(2,"0")}`;return t!=null&&t.startsWith("de")?`${s} Uhr`:s}catch{return e}}function l4(e,t,a){const i=(t[String(e)]||[]).reduce((o,s)=>{var d;return o+(parseFloat(((d=s.place)==null?void 0:d.price)||"")||0)},0);return i>0?`${i.toFixed(0)} ${a}`:null}function d4(e){const[t,a]=b.useState({}),n=b.useRef(null),i=Rn(),o=ya(),s=i.dayNotes||{},d=(y,x,k)=>{const S=x(y),v=S.length>0?Math.max(...S.map(_=>_.sortKey)):-1;a(_=>({..._,[y]:{mode:"add",text:"",time:"",icon:"FileText",sortOrder:v+1}})),k==null||k(y),setTimeout(()=>{var _;return(_=n.current)==null?void 0:_.focus()},50)},c=(y,x)=>{a(k=>({...k,[y]:{mode:"edit",noteId:x.id,text:x.text,time:x.time||"",icon:x.icon||"FileText"}})),setTimeout(()=>{var k;return(k=n.current)==null?void 0:k.focus()},50)},p=y=>{a(x=>{const k={...x};return delete k[y],k})};return{noteUi:t,setNoteUi:a,noteInputRef:n,dayNotes:s,openAddNote:d,openEditNote:c,cancelNote:p,saveNote:async y=>{var k;const x=t[y];if((k=x==null?void 0:x.text)!=null&&k.trim())try{x.mode==="add"?await i.addDayNote(e,y,{text:x.text.trim(),time:x.time||null,icon:x.icon||"FileText",sort_order:x.sortOrder}):await i.updateDayNote(e,y,x.noteId,{text:x.text.trim(),time:x.time||null,icon:x.icon||"FileText"}),p(y)}catch(S){o.error(S instanceof Error?S.message:"Unknown error")}},deleteNote:async(y,x)=>{try{await i.deleteDayNote(e,y,x)}catch(k){o.error(k instanceof Error?k.message:"Unknown error")}},moveNote:async(y,x,k,S)=>{const v=S(y),_=v.findIndex(E=>E.type==="note"&&E.data.id===x);if(_===-1)return;let w;if(k==="up"){if(_===0)return;w=_>=2?(v[_-2].sortKey+v[_-1].sortKey)/2:v[_-1].sortKey-1}else{if(_>=v.length-1)return;w=_[e,t]));function u4(e){return c4[e]||Pa}function L0({tripId:e,trip:t,days:a,places:n,categories:i,assignments:o,selectedDayId:s,selectedPlaceId:d,selectedAssignmentId:c,onSelectDay:p,onPlaceClick:m,onDayDetail:g,accommodations:f=[],onReorder:y,onUpdateDayTitle:x,onRouteCalculated:k,onAssignToDay:S,onRemoveAssignment:v,onEditPlace:_,onDeletePlace:w,reservations:E=[],onAddReservation:M,onNavigateToFiles:A}){const P=ya(),{t:R,language:$,locale:I}=ot(),Y=q_(),H=ta(N=>N.settings.time_format)||"24h",V=Rn(),{noteUi:X,setNoteUi:Z,noteInputRef:O,dayNotes:Q,openAddNote:D,openEditNote:J,cancelNote:z,saveNote:W,deleteNote:B,moveNote:C}=d4(e),[U,q]=b.useState(()=>{try{const N=sessionStorage.getItem(`day-expanded-${e}`);if(N)return new Set(JSON.parse(N))}catch{}return new Set(a.map(N=>N.id))}),[te,oe]=b.useState(null),[be,Se]=b.useState(""),[je,we]=b.useState(!1),[ce,le]=b.useState(null),[K,de]=b.useState(null),[_e,pe]=b.useState(new Set),[Ae,He]=b.useState(null),[ze,Ye]=b.useState(null),G=b.useRef(null),ve=N=>{G.current=N,Ye(N)},[Pe,ye]=b.useState(null),[ne,fe]=b.useState(null),[Ee,Oe]=b.useState(null),[Ke,dt]=b.useState(null),Wt=b.useRef(null),Be=b.useRef(null),Gt=b.useRef(new Set),Kt=(t==null?void 0:t.currency)||"EUR",Lt=N=>{const se=N==null?void 0:N.dataTransfer;if(Be.current)return{placeId:"",assignmentId:Be.current.assignmentId||"",noteId:Be.current.noteId||"",fromDayId:parseInt(Be.current.fromDayId)||0};const he=window.__dragData||{};return{placeId:(se==null?void 0:se.getData("placeId"))||he.placeId||"",assignmentId:"",noteId:"",fromDayId:0}},Ce=Ka.useRef(a.length);b.useEffect(()=>{a.length>Ce.current&&q(N=>{const se=new Set(N);a.forEach(he=>{N.has(he.id)||se.add(he.id)});try{sessionStorage.setItem(`day-expanded-${e}`,JSON.stringify([...se]))}catch{}return se}),Ce.current=a.length},[a.length,e]),b.useEffect(()=>{te&&Wt.current&&Wt.current.focus()},[te]),b.useEffect(()=>{const N=()=>{de(null),ve(null),ye(null),Be.current=null,window.__dragData=null};return document.addEventListener("dragend",N),()=>document.removeEventListener("dragend",N)},[]);const De=(N,se)=>{se.stopPropagation(),q(he=>{const ee=new Set(he);ee.has(N)?ee.delete(N):ee.add(N);try{sessionStorage.setItem(`day-expanded-${e}`,JSON.stringify([...ee]))}catch{}return ee})},Qe=new Set(["flight","train","bus","car","cruise"]),ft=N=>{const se=a.find(he=>he.id===N);return se!=null&&se.date?E.filter(he=>!he.reservation_time||!Qe.has(he.type)?!1:he.reservation_time.split("T")[0]===se.date):[]},Et=N=>(o[String(N)]||[]).slice().sort((se,he)=>se.order_index-he.order_index),pt=N=>{if(!N)return null;if(N.includes("T")){const[he,ee]=N.split("T")[1].split(":").map(Number);return he*60+ee}const se=N.split(":").map(Number);return se.length>=2&&!isNaN(se[0])&&!isNaN(se[1])?se[0]*60+se[1]:null},Zt=(N,se)=>{var ge;const he=pt(N.reservation_time)??0;let ee=-1;for(const Me of se){const $e=pt((ge=Me.place)==null?void 0:ge.place_time);$e!==null&&$e<=he&&(ee=Me.order_index)}return ee>=0?ee+.5:se.length+.5},jn=N=>{const se=Et(N),ee=ft(N).filter($e=>$e.day_plan_position==null&&!Gt.current.has($e.id));if(ee.length===0)return;const Me=[...ee].sort(($e,ct)=>(pt($e.reservation_time)??0)-(pt(ct.reservation_time)??0)).map(($e,ct)=>({id:$e.id,day_plan_position:Zt($e,se)+ct*.01}));for(const $e of Me){Gt.current.add($e.id);const ct=E.find(bt=>bt.id===$e.id);ct&&(ct.day_plan_position=$e.day_plan_position)}eo.updatePositions(e,Me).catch(()=>{})},ga=N=>{var Ve,yt,wt;const se=Et(N),he=(Q[String(N)]||[]).slice().sort((Te,We)=>Te.sort_order-We.sort_order),ee=ft(N);ee.some(Te=>Te.day_plan_position==null)&&jn(N);const ge=se.filter(Te=>{var We;return pt((We=Te.place)==null?void 0:We.place_time)!==null}),$e=[...se.filter(Te=>{var We;return pt((We=Te.place)==null?void 0:We.place_time)===null}).map(Te=>({type:"place",sortKey:Te.order_index,data:Te})),...he.map(Te=>({type:"note",sortKey:Te.sort_order,data:Te}))].sort((Te,We)=>Te.sortKey-We.sortKey),ct=[...ge.map(Te=>{var We;return{type:"place",data:Te,minutes:pt((We=Te.place)==null?void 0:We.place_time)}}),...ee.map(Te=>({type:"transport",data:Te,minutes:pt(Te.reservation_time)??0}))].sort((Te,We)=>Te.minutes-We.minutes);if(ct.length===0)return $e;if($e.length===0)return ct.map((Te,We)=>({...Te,sortKey:We}));const bt=[...$e];for(let Te=0;Te0?Math.max(...bt.map(nt=>nt.sortKey)):0,ha=ht===-1/0?it+.5+Te*.01:ht+.01+Te*.001;bt.push({type:We.type,sortKey:ha,data:We.data})}return bt.sort((Te,We)=>Te.sortKey-We.sortKey)},Ot=(N,se)=>{se==null||se.stopPropagation(),D(N,ga,he=>{U.has(he)||q(ee=>new Set([...ee,he]))})},Xt=(N,se,he)=>{he==null||he.stopPropagation(),J(N,se)},Za=async(N,se,he)=>{he==null||he.stopPropagation(),await B(N,se)},It=async(N,se)=>{const he=[],ee=[],ge=[];let Me=0,$e=0;for(;$e0?Me-1:-1;ct.forEach((Ve,yt)=>{const wt=bt+(yt+1)/(ct.length+1);Ve.type==="note"?ee.push({id:Ve.data.id,sort_order:wt}):Ve.type==="transport"&&ge.push({id:Ve.data.id,day_plan_position:wt})})}try{he.length&&await y(N,he);for(const ct of ee)await V.updateDayNote(e,N,ct.id,{sort_order:ct.sort_order});if(ge.length){for(const ct of ge){const bt=E.find(Ve=>Ve.id===ct.id);bt&&(bt.day_plan_position=ct.day_plan_position)}await eo.updatePositions(e,ge)}}catch(ct){P.error(ct instanceof Error?ct.message:"Unknown error")}},re=async(N,se,he,ee,ge,Me=!1)=>{var Te,We;if(se==="transport"){P.error(R("dayplan.cannotReorderTransport")),de(null),ve(null),Be.current=null;return}const $e=ga(N);if(se==="place"){const Ge=$e.find(it=>it.type==="place"&&it.data.id===he),ht=pt((We=(Te=Ge==null?void 0:Ge.data)==null?void 0:Te.place)==null?void 0:We.place_time);if(Ge&&ht!==null){const it=$e.findIndex(nt=>nt.type===se&&nt.data.id===he),ha=$e.findIndex(nt=>nt.type===ee&&nt.data.id===ge);if(it!==-1&&ha!==-1){const nt=[...$e],[rt]=nt.splice(it,1);let Nt=nt.findIndex(Ne=>Ne.type===ee&&Ne.data.id===ge);Nt===-1&&(Nt=nt.length),Me&&(Nt+=1),nt.splice(Nt,0,rt);const Ua=nt.map(Ne=>{var vt,Xe,mt;return Ne.type==="transport"?pt((vt=Ne.data)==null?void 0:vt.reservation_time):Ne.type==="place"?pt((mt=(Xe=Ne.data)==null?void 0:Xe.place)==null?void 0:mt.place_time):null}).filter(Ne=>Ne!==null);if(!Ua.every((Ne,vt)=>vt===0||Ne>=Ua[vt-1])){const Ne=Ge.data.place.place_time,vt=Ne.includes(":")?Ne.substring(0,5):Ne;dt({dayId:N,fromType:se,fromId:he,toType:ee,toId:ge,insertAfter:Me,time:vt}),de(null),ve(null),Be.current=null;return}}}}const ct=$e.findIndex(Ge=>Ge.type===se&&Ge.data.id===he),bt=$e.findIndex(Ge=>Ge.type===ee&&Ge.data.id===ge);if(ct===-1||bt===-1||ct===bt){de(null),ve(null),Be.current=null;return}const Ve=[...$e],[yt]=Ve.splice(ct,1);let wt=Ve.findIndex(Ge=>Ge.type===ee&&Ge.data.id===ge);wt===-1&&(wt=Ve.length),Me&&(wt+=1),Ve.splice(wt,0,yt),await It(N,Ve),de(null),ve(null),Be.current=null},Ie=async()=>{if(!Ke)return;const N={...Ke},{dayId:se,fromId:he,reorderIds:ee,fromType:ge,toType:Me,toId:$e,insertAfter:ct}=N;dt(null);try{await ti.updateTime(e,he,{place_time:null,end_time:null});const Ve=String(se),yt={...o};yt[Ve]&&(yt[Ve]=yt[Ve].map(wt=>wt.id===he?{...wt,place:{...wt.place,place_time:null,end_time:null}}:wt),V.setAssignments(yt))}catch(Ve){P.error(Ve instanceof Error?Ve.message:"Unknown error");return}const bt=ga(se);if(ee){const Ve=[];let yt=0;for(const wt of bt)if(wt.type==="place"){const Te=ee[yt++],We=bt.find(Ge=>Ge.type==="place"&&Ge.data.id===Te);We&&Ve.push(We)}else Ve.push(wt);await It(se,Ve);return}if(ge&&Me){const Ve=bt.findIndex(Ge=>Ge.type===ge&&Ge.data.id===he),yt=bt.findIndex(Ge=>Ge.type===Me&&Ge.data.id===$e);if(Ve===-1||yt===-1||Ve===yt)return;const wt=[...bt],[Te]=wt.splice(Ve,1);let We=wt.findIndex(Ge=>Ge.type===Me&&Ge.data.id===$e);We===-1&&(We=wt.length),ct&&(We+=1),wt.splice(We,0,Te),await It(se,wt)}},At=async(N,se,he)=>{await C(N,se,he,ga)},va=(N,se)=>{se.stopPropagation(),Se(N.title||""),oe(N.id)},ba=async N=>{oe(null),await(x==null?void 0:x(N,be.trim()))},Ue=N=>{pe(se=>{const he=new Set(se);return he.has(N)?he.delete(N):he.add(N),he})},Xn=async()=>{if(!s)return;const N=Et(s);if(N.length<3)return;const se=new Map,he=[];N.forEach((Ve,yt)=>{_e.has(Ve.id)?se.set(yt,Ve):he.push(Ve)});const ee=he.filter(Ve=>{var yt,wt;return((yt=Ve.place)==null?void 0:yt.lat)&&((wt=Ve.place)==null?void 0:wt.lng)}),ge=he.filter(Ve=>{var yt,wt;return!((yt=Ve.place)!=null&&yt.lat)||!((wt=Ve.place)!=null&&wt.lng)}),$e=[...ee.length>=2?t4(ee.map(Ve=>({...Ve.place,_assignmentId:Ve.id}))).map(Ve=>ee.find(yt=>yt.id===Ve._assignmentId)).filter(Boolean):ee,...ge],ct=new Array(N.length);se.forEach((Ve,yt)=>{ct[yt]=Ve});let bt=0;for(let Ve=0;VeVe.id)),P.success(R("dayplan.toast.routeOptimized"))},_n=()=>{if(!s)return;const N=Et(s),se=e4(N.map(he=>he.place).filter(he=>(he==null?void 0:he.lat)&&(he==null?void 0:he.lng)));se?window.open(se,"_blank"):P.error(R("dayplan.toast.noGeoPlaces"))},an=(N,se)=>{N.preventDefault(),N.stopPropagation(),ye(null);const{placeId:he,assignmentId:ee,noteId:ge,fromDayId:Me}=Lt(N);he?S==null||S(parseInt(he),se):ee&&Me!==se?V.moveAssignment(e,Number(ee),Me,se).catch($e=>P.error($e instanceof Error?$e.message:"Unknown error")):ge&&Me!==se&&V.moveDayNote(e,Me,se,Number(ge)).catch($e=>P.error($e instanceof Error?$e.message:"Unknown error")),de(null),ve(null),Be.current=null,window.__dragData=null},Ea=a.reduce((N,se)=>{const he=o[String(se.id)]||[];return N+he.reduce((ee,ge)=>{var Me;return ee+(parseFloat((Me=ge.place)==null?void 0:Me.price)||0)},0)},0),ja=Object.values(o).flatMap(N=>N).find(N=>{var se,he;return((se=N.place)==null?void 0:se.lat)&&((he=N.place)==null?void 0:he.lng)})||(n||[]).find(N=>N.lat&&N.lng);return r.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",position:"relative",fontFamily:"-apple-system, BlinkMacSystemFont, 'SF Pro Text', system-ui, sans-serif"},children:[r.jsx("div",{style:{padding:"16px 16px 12px",borderBottom:"1px solid var(--border-faint)",flexShrink:0},children:r.jsxs("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:8},children:[r.jsxs("div",{style:{flex:1,minWidth:0},children:[r.jsx("div",{style:{fontWeight:600,fontSize:14,color:"var(--text-primary)",lineHeight:"1.3"},children:t==null?void 0:t.title}),((t==null?void 0:t.start_date)||(t==null?void 0:t.end_date))&&r.jsxs("div",{style:{fontSize:11,color:"var(--text-faint)",marginTop:3},children:[[t.start_date,t.end_date].filter(Boolean).map(N=>new Date(N+"T00:00:00").toLocaleDateString(I,{day:"numeric",month:"short"})).join(" – "),a.length>0&&` · ${a.length} ${R("dayplan.days")}`]})]}),r.jsxs("button",{onClick:async()=>{const N=Object.entries(Q).flatMap(([se,he])=>he.map(ee=>({...ee,day_id:Number(se)})));try{await JI({trip:t,days:a,places:n,assignments:o,categories:i,dayNotes:N,reservations:E,t:R,locale:I})}catch(se){console.error("PDF error:",se),P.error(R("dayplan.pdfError")+": "+((se==null?void 0:se.message)||String(se)))}},title:R("dayplan.pdfTooltip"),style:{flexShrink:0,display:"flex",alignItems:"center",gap:5,padding:"5px 10px",borderRadius:8,border:"none",background:"var(--accent)",color:"var(--accent-text)",fontSize:11,fontWeight:500,cursor:"pointer",fontFamily:"inherit"},children:[r.jsx(m0,{size:13,strokeWidth:2}),R("dayplan.pdf")]}),r.jsxs("button",{onClick:async()=>{try{const N=await fetch(`/api/trips/${e}/export.ics`,{headers:{Authorization:`Bearer ${localStorage.getItem("auth_token")}`}});if(!N.ok)throw new Error;const se=await N.blob(),he=URL.createObjectURL(se),ee=document.createElement("a");ee.href=he,ee.download=`${(t==null?void 0:t.title)||"trip"}.ics`,ee.click(),URL.revokeObjectURL(he)}catch{P.error("ICS export failed")}},title:R("dayplan.icsTooltip"),style:{flexShrink:0,display:"flex",alignItems:"center",gap:5,padding:"5px 10px",borderRadius:8,border:"1px solid var(--border-primary)",background:"none",color:"var(--text-muted)",fontSize:11,fontWeight:500,cursor:"pointer",fontFamily:"inherit"},children:[r.jsx(m0,{size:13,strokeWidth:2}),"ICS"]})]})}),r.jsx("div",{className:"scroll-container",style:{flex:1,overflowY:"auto",minHeight:0,scrollbarWidth:"thin",scrollbarColor:"var(--scrollbar-thumb) transparent"},children:a.map((N,se)=>{const he=s===N.id,ee=U.has(N.id),ge=Et(N.id),Me=l4(N.id,o,Kt),$e=s4(N.date,I),ct=ge.find(Te=>{var We,Ge;return((We=Te.place)==null?void 0:We.lat)&&((Ge=Te.place)==null?void 0:Ge.lng)}),bt=Pe===N.id,Ve=ga(N.id),yt=X[N.id],wt=Ve.filter(Te=>Te.type==="place");return r.jsxs("div",{style:{borderBottom:"1px solid var(--border-faint)"},children:[r.jsxs("div",{onClick:()=>{p(N.id),g&&g(N)},onDragOver:Te=>{Te.preventDefault(),ye(N.id)},onDragLeave:Te=>{Te.currentTarget.contains(Te.relatedTarget)||ye(null)},onDrop:Te=>an(Te,N.id),style:{display:"flex",alignItems:"center",gap:10,padding:"11px 14px 11px 16px",cursor:"pointer",background:bt?"rgba(17,24,39,0.07)":he?"var(--bg-tertiary)":"transparent",transition:"background 0.12s",userSelect:"none",outline:bt?"2px dashed rgba(17,24,39,0.25)":"none",outlineOffset:-2,borderRadius:bt?8:0},onMouseEnter:Te=>{!he&&!bt&&(Te.currentTarget.style.background="var(--bg-tertiary)")},onMouseLeave:Te=>{he||(Te.currentTarget.style.background=bt?"rgba(17,24,39,0.07)":"transparent")},children:[r.jsx("div",{style:{width:26,height:26,borderRadius:"50%",flexShrink:0,background:he?"var(--accent)":"var(--bg-hover)",color:he?"var(--accent-text)":"var(--text-muted)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:11,fontWeight:700},children:se+1}),r.jsxs("div",{style:{flex:1,minWidth:0},children:[te===N.id?r.jsx("input",{ref:Wt,value:be,onChange:Te=>Se(Te.target.value),onBlur:()=>ba(N.id),onKeyDown:Te=>{Te.key==="Enter"&&ba(N.id),Te.key==="Escape"&&oe(null)},onClick:Te=>Te.stopPropagation(),style:{width:"100%",border:"none",outline:"none",fontSize:13,fontWeight:600,color:"var(--text-primary)",background:"transparent",padding:0,fontFamily:"inherit",borderBottom:"1.5px solid var(--text-primary)"}}):r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:5,minWidth:0},children:[r.jsx("span",{style:{fontSize:14,fontWeight:600,color:"var(--text-primary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flexShrink:1,minWidth:0},children:N.title||R("dayplan.dayN",{n:se+1})}),r.jsx("button",{onClick:Te=>va(N,Te),style:{flexShrink:0,background:"none",border:"none",padding:"4px",cursor:"pointer",opacity:.35,display:"flex",alignItems:"center"},children:r.jsx(sn,{size:15,strokeWidth:1.8,color:"var(--text-secondary)"})}),(()=>{const Te=f.filter(We=>N.id>=We.start_day_id&&N.id<=We.end_day_id).sort((We,Ge)=>{const ht=We.end_day_id===N.id&&We.start_day_id!==N.id,it=Ge.end_day_id===N.id&&Ge.start_day_id!==N.id,ha=We.start_day_id===N.id,nt=Ge.start_day_id===N.id;return ht&&!it?-1:!ht&&it||ha&&!nt?1:!ha&&nt?-1:0});return Te.length===0?null:Te.map(We=>{const Ge=We.start_day_id===N.id,ht=We.end_day_id===N.id,it=ht&&!Ge?"rgba(239,68,68,0.08)":Ge?"rgba(34,197,94,0.08)":"var(--bg-secondary)",ha=ht&&!Ge?"rgba(239,68,68,0.2)":Ge?"rgba(34,197,94,0.2)":"var(--border-primary)",nt=ht&&!Ge?"#ef4444":Ge?"#22c55e":"var(--text-muted)";return r.jsxs("span",{onClick:rt=>{rt.stopPropagation(),m(We.place_id)},style:{display:"inline-flex",alignItems:"center",gap:3,padding:"2px 7px",borderRadius:5,background:it,border:`1px solid ${ha}`,flexShrink:1,minWidth:0,maxWidth:"40%",cursor:"pointer"},children:[r.jsx(Rr,{size:8,style:{color:nt,flexShrink:0}}),r.jsx("span",{style:{fontSize:9,color:"var(--text-muted)",fontWeight:600,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:We.place_name})]},We.id)})})()]}),r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginTop:2,flexWrap:"wrap"},children:[$e&&r.jsx("span",{style:{fontSize:11,color:"var(--text-faint)"},children:$e}),Me&&r.jsx("span",{style:{fontSize:11,color:"#059669"},children:Me}),N.date&&ja&&r.jsx("span",{style:{width:1,height:10,background:"var(--text-faint)",opacity:.3,flexShrink:0}}),N.date&&ja&&(()=>{var Ge,ht;const Te=(ct==null?void 0:ct.place.lat)??((Ge=ja==null?void 0:ja.place)==null?void 0:Ge.lat)??(ja==null?void 0:ja.lat),We=(ct==null?void 0:ct.place.lng)??((ht=ja==null?void 0:ja.place)==null?void 0:ht.lng)??(ja==null?void 0:ja.lng);return r.jsx(i4,{lat:Te,lng:We,date:N.date,compact:!0})})()]})]}),r.jsx("button",{onClick:Te=>Ot(N.id,Te),title:R("dayplan.addNote"),style:{flexShrink:0,background:"none",border:"none",padding:6,cursor:"pointer",display:"flex",alignItems:"center",color:"var(--text-faint)"},onMouseEnter:Te=>Te.currentTarget.style.color="var(--text-primary)",onMouseLeave:Te=>Te.currentTarget.style.color="var(--text-faint)",children:r.jsx(Pa,{size:16,strokeWidth:2})}),r.jsx("button",{onClick:Te=>De(N.id,Te),style:{flexShrink:0,background:"none",border:"none",padding:6,cursor:"pointer",display:"flex",alignItems:"center",color:"var(--text-faint)"},children:ee?r.jsx(en,{size:18,strokeWidth:2}):r.jsx(Ao,{size:18,strokeWidth:2})})]}),ee&&r.jsxs("div",{style:{background:"var(--bg-hover)",paddingTop:6},onDragOver:Te=>{Te.preventDefault();const We=G.current;K&&(!We||We.startsWith("end-"))&&ve(`end-${N.id}`)},onDrop:Te=>{var rt,Nt,Ua;Te.preventDefault(),Te.stopPropagation();const{placeId:We,assignmentId:Ge,noteId:ht,fromDayId:it}=Lt(Te);if((rt=G.current)!=null&&rt.startsWith("transport-")){const Wa=Number(G.current.replace("transport-",""));We?S==null||S(parseInt(We),N.id):Ge&&it!==N.id?V.moveAssignment(e,Number(Ge),it,N.id).catch(Ne=>P.error(Ne instanceof Error?Ne.message:"Unknown error")):Ge?re(N.id,"place",Number(Ge),"transport",Wa):ht&&it!==N.id?V.moveDayNote(e,it,N.id,Number(ht)).catch(Ne=>P.error(Ne instanceof Error?Ne.message:"Unknown error")):ht&&re(N.id,"note",Number(ht),"transport",Wa),de(null),ve(null),Be.current=null,window.__dragData=null;return}if(!Ge&&!ht&&!We){Be.current=null,window.__dragData=null;return}if(We){S==null||S(parseInt(We),N.id),ve(null),window.__dragData=null;return}if(Ge&&it!==N.id){V.moveAssignment(e,Number(Ge),it,N.id).catch(Wa=>P.error(Wa instanceof Error?Wa.message:"Unknown error")),de(null),ve(null),Be.current=null;return}if(ht&&it!==N.id){V.moveDayNote(e,it,N.id,Number(ht)).catch(Wa=>P.error(Wa instanceof Error?Wa.message:"Unknown error")),de(null),ve(null),Be.current=null;return}const ha=ga(N.id);if(ha.length===0)return;const nt=ha[ha.length-1];Ge&&String((Nt=nt==null?void 0:nt.data)==null?void 0:Nt.id)!==Ge?re(N.id,"place",Number(Ge),nt.type,nt.data.id,!0):ht&&String((Ua=nt==null?void 0:nt.data)==null?void 0:Ua.id)!==ht&&re(N.id,"note",Number(ht),nt.type,nt.data.id,!0)},children:[Ve.length===0&&!yt?r.jsx("div",{onDragOver:Te=>{Te.preventDefault(),ye(N.id)},onDrop:Te=>an(Te,N.id),style:{padding:"16px",textAlign:"center",borderRadius:8,background:Pe===N.id?"rgba(17,24,39,0.05)":"transparent",border:Pe===N.id?"2px dashed rgba(17,24,39,0.2)":"2px dashed transparent"},children:r.jsx("span",{style:{fontSize:12,color:"var(--text-faint)"},children:R("dayplan.emptyDay")})}):Ve.map((Te,We)=>{var Nt,Ua,Wa;const Ge=Te.type==="transport"?`transport-${Te.data.id}`:Te.type==="place"?`place-${Te.data.id}`:`note-${Te.data.id}`,ht=(!!K||!!ze)&&ze===Ge;if(Te.type==="place"){const Ne=Te.data,vt=Ne.place;if(!vt)return null;const Xe=i.find(tt=>tt.id===vt.category_id),mt=c?Ne.id===c:vt.id===d,Wr=K===Ne.id,Aa=ne===Ne.id;wt.findIndex(tt=>tt.data.id===Ne.id);const qt=tt=>{const zt=ga(N.id),Yt=zt.findIndex(Na=>Na.type==="place"&&Na.data.id===Ne.id);if(Yt===-1)return;const $t=tt==="up"?Yt-1:Yt+1;if($t<0||$t>=zt.length)return;const Ya=[...zt];[Ya[Yt],Ya[$t]]=[Ya[$t],Ya[Yt]];const Cr=vt.place_time;if(pt(Cr)!==null){const Na=Ya.map(mn=>{var Ia,ks,ws;return mn.type==="transport"?pt((Ia=mn.data)==null?void 0:Ia.reservation_time):mn.type==="place"?pt((ws=(ks=mn.data)==null?void 0:ks.place)==null?void 0:ws.place_time):null}).filter(mn=>mn!==null);if(!Na.every((mn,Ia)=>Ia===0||mn>=Na[Ia-1])){const mn=Cr.includes(":")?Cr.substring(0,5):Cr;dt({dayId:N.id,fromId:Ne.id,time:mn,reorderIds:Ya.filter(Ia=>Ia.type==="place").map(Ia=>Ia.data.id)});return}}It(N.id,Ya)},$r=tt=>{tt.stopPropagation(),qt("up")},da=tt=>{tt.stopPropagation(),qt("down")};return r.jsxs(Ka.Fragment,{children:[ht&&r.jsx("div",{style:{height:2,background:"var(--text-primary)",borderRadius:1,margin:"2px 8px"}}),r.jsxs("div",{draggable:!0,onDragStart:tt=>{tt.dataTransfer.setData("assignmentId",String(Ne.id)),tt.dataTransfer.setData("fromDayId",String(N.id)),tt.dataTransfer.effectAllowed="move",Be.current={assignmentId:String(Ne.id),fromDayId:String(N.id)},de(Ne.id)},onDragOver:tt=>{tt.preventDefault(),tt.stopPropagation(),ye(null),ze!==`place-${Ne.id}`&&ve(`place-${Ne.id}`)},onDrop:tt=>{var Cr;tt.preventDefault(),tt.stopPropagation();const{placeId:zt,assignmentId:Yt,noteId:$t,fromDayId:Ya}=Lt(tt);if(zt){const Na=wt.findIndex(Cn=>Cn.data.id===Ne.id);S==null||S(parseInt(zt),N.id,Na>=0?Na:void 0),ve(null),window.__dragData=null}else if(Yt&&Ya!==N.id){const Na=Et(N.id).findIndex(Cn=>Cn.id===Ne.id);V.moveAssignment(e,Number(Yt),Ya,N.id,Na).catch(Cn=>P.error(Cn instanceof Error?Cn.message:"Unknown error")),de(null),ve(null),Be.current=null}else if(Yt)re(N.id,"place",Number(Yt),"place",Ne.id);else if($t&&Ya!==N.id){const Na=ga(N.id),Cn=Na.findIndex(Ia=>Ia.type==="place"&&Ia.data.id===Ne.id),mn=Cn<=0?(((Cr=Na[0])==null?void 0:Cr.sortKey)??0)-1:(Na[Cn-1].sortKey+Na[Cn].sortKey)/2;V.moveDayNote(e,Ya,N.id,Number($t),mn).catch(Ia=>P.error(Ia instanceof Error?Ia.message:"Unknown error")),de(null),ve(null),Be.current=null}else $t&&re(N.id,"note",Number($t),"place",Ne.id)},onDragEnd:()=>{de(null),ye(null),ve(null),Be.current=null},onClick:()=>{m(mt?null:vt.id,mt?null:Ne.id),mt||p(N.id,!0)},onContextMenu:tt=>Y.open(tt,[_&&{label:R("common.edit"),icon:sn,onClick:()=>_(vt,Ne.id)},v&&{label:R("planner.removeFromDay"),icon:_t,onClick:()=>v(N.id,Ne.id)},vt.website&&{label:R("inspector.website"),icon:xn,onClick:()=>window.open(vt.website,"_blank")},vt.lat&&vt.lng&&{label:"Google Maps",icon:ps,onClick:()=>window.open(`https://www.google.com/maps/search/?api=1&query=${vt.lat},${vt.lng}`,"_blank")},{divider:!0},w&&{label:R("common.delete"),icon:_t,danger:!0,onClick:()=>w(vt.id)}]),onMouseEnter:()=>fe(Ne.id),onMouseLeave:()=>fe(null),style:{display:"flex",alignItems:"center",gap:8,padding:"7px 8px 7px 10px",cursor:"pointer",background:_e.has(Ne.id)?"rgba(220,38,38,0.08)":mt||Aa?"var(--bg-hover)":"transparent",borderLeft:_e.has(Ne.id)?"3px solid #dc2626":"3px solid transparent",transition:"background 0.15s, border-color 0.15s",opacity:Wr?.4:1},children:[r.jsx("div",{style:{flexShrink:0,color:"var(--text-faint)",display:"flex",alignItems:"center",opacity:Aa?1:.3,transition:"opacity 0.15s",cursor:"grab"},children:r.jsx(g0,{size:13,strokeWidth:1.8})}),r.jsxs("div",{onClick:tt=>{tt.stopPropagation(),Ue(Ne.id)},onMouseEnter:tt=>{tt.stopPropagation(),He(Ne.id)},onMouseLeave:()=>He(null),style:{position:"relative",flexShrink:0,cursor:"pointer"},children:[r.jsx(tb,{place:vt,category:Xe,size:28}),(Ae===Ne.id||_e.has(Ne.id))&&r.jsx("div",{style:{position:"absolute",inset:0,borderRadius:"50%",background:_e.has(Ne.id)?"rgba(220,38,38,0.6)":"rgba(220,38,38,0.4)",display:"flex",alignItems:"center",justifyContent:"center",transition:"background 0.15s"},children:r.jsx(Sl,{size:14,strokeWidth:2.5,style:{color:"white",filter:"drop-shadow(0 1px 2px rgba(0,0,0,0.3))"}})}),Ae===Ne.id&&r.jsx("div",{style:{position:"absolute",left:"100%",top:"50%",transform:"translateY(-50%)",marginLeft:8,whiteSpace:"nowrap",pointerEvents:"none",zIndex:50,background:"var(--bg-card, white)",color:"var(--text-primary, #111827)",fontSize:11,fontWeight:500,padding:"5px 10px",borderRadius:8,boxShadow:"0 4px 12px rgba(0,0,0,0.15)",border:"1px solid var(--border-faint, #e5e7eb)"},children:_e.has(Ne.id)?R("planner.clickToUnlock"):R("planner.keepPosition")})]}),r.jsxs("div",{style:{flex:1,minWidth:0},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4,overflow:"hidden"},children:[Xe&&(()=>{const tt=ci(Xe.icon);return r.jsx(tt,{size:10,strokeWidth:2,color:Xe.color||"var(--text-muted)",title:Xe.name,style:{flexShrink:0}})})(),r.jsx("span",{style:{fontSize:12.5,fontWeight:500,color:"var(--text-primary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",lineHeight:1.2},children:vt.name}),vt.place_time&&r.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:3,flexShrink:0,fontSize:10,color:"var(--text-faint)",fontWeight:400,marginLeft:6},children:[r.jsx(Nn,{size:9,strokeWidth:2}),I0(vt.place_time,I,H),vt.end_time?` – ${I0(vt.end_time,I,H)}`:""]})]}),(vt.description||vt.address||(Xe==null?void 0:Xe.name))&&r.jsx("div",{style:{marginTop:2},children:r.jsx("span",{style:{fontSize:10,color:"var(--text-faint)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",display:"block",lineHeight:1.2},children:vt.description||vt.address||(Xe==null?void 0:Xe.name)})}),(()=>{var Yt;const tt=E.find($t=>$t.assignment_id===Ne.id);if(!tt)return null;const zt=tt.status==="confirmed";return r.jsxs("div",{style:{marginTop:3,display:"inline-flex",alignItems:"center",gap:3,padding:"1px 6px",borderRadius:5,fontSize:9,fontWeight:600,background:zt?"rgba(22,163,74,0.1)":"rgba(217,119,6,0.1)",color:zt?"#16a34a":"#d97706"},children:[(()=>{const $t=ah[tt.type]||kn;return r.jsx($t,{size:8})})(),r.jsx("span",{className:"hidden sm:inline",children:R(zt?"planner.resConfirmed":"planner.resPending")}),((Yt=tt.reservation_time)==null?void 0:Yt.includes("T"))&&r.jsxs("span",{style:{fontWeight:400},children:[new Date(tt.reservation_time).toLocaleTimeString(I,{hour:"2-digit",minute:"2-digit",hour12:H==="12h"}),tt.reservation_end_time&&` – ${tt.reservation_end_time}`]}),(()=>{const $t=typeof tt.metadata=="string"?JSON.parse(tt.metadata||"{}"):tt.metadata||{};return $t?$t.airline&&$t.flight_number?r.jsxs("span",{style:{fontWeight:400},children:[$t.airline," ",$t.flight_number]}):$t.flight_number?r.jsx("span",{style:{fontWeight:400},children:$t.flight_number}):$t.train_number?r.jsx("span",{style:{fontWeight:400},children:$t.train_number}):null:null})()]})})(),((Nt=Ne.participants)==null?void 0:Nt.length)>0&&r.jsxs("div",{style:{marginTop:3,display:"flex",alignItems:"center",gap:-4},children:[Ne.participants.slice(0,5).map((tt,zt)=>{var Yt,$t;return r.jsx("div",{style:{width:16,height:16,borderRadius:"50%",background:"var(--bg-tertiary)",border:"1.5px solid var(--bg-card)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:7,fontWeight:700,color:"var(--text-muted)",marginLeft:zt>0?-4:0,flexShrink:0,overflow:"hidden"},children:tt.avatar?r.jsx("img",{src:`/uploads/avatars/${tt.avatar}`,style:{width:"100%",height:"100%",objectFit:"cover"}}):($t=(Yt=tt.username)==null?void 0:Yt[0])==null?void 0:$t.toUpperCase()},tt.user_id)}),Ne.participants.length>5&&r.jsxs("span",{style:{fontSize:8,color:"var(--text-faint)",marginLeft:2},children:["+",Ne.participants.length-5]})]})]}),r.jsxs("div",{className:"reorder-buttons",style:{flexShrink:0,display:"flex",gap:1,opacity:Aa?1:void 0,transition:"opacity 0.15s"},children:[r.jsx("button",{onClick:$r,disabled:We===0,style:{background:"none",border:"none",padding:"1px 2px",cursor:We===0?"default":"pointer",color:We===0?"var(--border-primary)":"var(--text-faint)",display:"flex",lineHeight:1},children:r.jsx(oi,{size:12,strokeWidth:2})}),r.jsx("button",{onClick:da,disabled:We===Ve.length-1,style:{background:"none",border:"none",padding:"1px 2px",cursor:We===Ve.length-1?"default":"pointer",color:We===Ve.length-1?"var(--border-primary)":"var(--text-faint)",display:"flex",lineHeight:1},children:r.jsx(en,{size:12,strokeWidth:2})})]})]})]},`place-${Ne.id}`)}if(Te.type==="transport"){const Ne=Te.data,vt=ah[Ne.type]||kn,Xe="#3b82f6",mt=typeof Ne.metadata=="string"?JSON.parse(Ne.metadata||"{}"):Ne.metadata||{},Wr=ne===`transport-${Ne.id}`;let Aa="";if(Ne.type==="flight"){const qt=[mt.airline,mt.flight_number].filter(Boolean);(mt.departure_airport||mt.arrival_airport)&&qt.push([mt.departure_airport,mt.arrival_airport].filter(Boolean).join(" → ")),Aa=qt.join(" · ")}else Ne.type==="train"&&(Aa=[mt.train_number,mt.platform?`Gl. ${mt.platform}`:"",mt.seat?`Sitz ${mt.seat}`:""].filter(Boolean).join(" · "));return r.jsxs(Ka.Fragment,{children:[ht&&r.jsx("div",{style:{height:2,background:"var(--text-primary)",borderRadius:1,margin:"2px 8px"}}),r.jsxs("div",{onClick:()=>Oe(Ne),onDragOver:qt=>{qt.preventDefault(),qt.stopPropagation(),ve(`transport-${Ne.id}`)},onDrop:qt=>{qt.preventDefault(),qt.stopPropagation();const{placeId:$r,assignmentId:da,noteId:tt,fromDayId:zt}=Lt(qt);$r?S==null||S(parseInt($r),N.id):da&&zt!==N.id?V.moveAssignment(e,Number(da),zt,N.id).catch(Yt=>P.error(Yt instanceof Error?Yt.message:"Unknown error")):da?re(N.id,"place",Number(da),"transport",Ne.id):tt&&zt!==N.id?V.moveDayNote(e,zt,N.id,Number(tt)).catch(Yt=>P.error(Yt instanceof Error?Yt.message:"Unknown error")):tt&&re(N.id,"note",Number(tt),"transport",Ne.id),de(null),ve(null),Be.current=null,window.__dragData=null},onMouseEnter:()=>fe(`transport-${Ne.id}`),onMouseLeave:()=>fe(null),style:{display:"flex",alignItems:"center",gap:8,padding:"7px 8px 7px 10px",margin:"1px 8px",borderRadius:6,border:`1px solid ${Xe}33`,background:Wr?`${Xe}12`:`${Xe}08`,cursor:"pointer",userSelect:"none",transition:"background 0.1s"},children:[r.jsx("div",{style:{width:28,height:28,flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"50%",background:`${Xe}18`},children:r.jsx(vt,{size:14,strokeWidth:1.8,color:Xe})}),r.jsxs("div",{style:{flex:1,minWidth:0},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4},children:[r.jsx("span",{style:{fontSize:12.5,fontWeight:500,color:"var(--text-primary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:Ne.title}),((Ua=Ne.reservation_time)==null?void 0:Ua.includes("T"))&&r.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:3,flexShrink:0,fontSize:10,color:"var(--text-faint)",fontWeight:400,marginLeft:6},children:[r.jsx(Nn,{size:9,strokeWidth:2}),new Date(Ne.reservation_time).toLocaleTimeString(I,{hour:"2-digit",minute:"2-digit",hour12:H==="12h"}),((Wa=Ne.reservation_end_time)==null?void 0:Wa.includes("T"))&&` – ${new Date(Ne.reservation_end_time).toLocaleTimeString(I,{hour:"2-digit",minute:"2-digit",hour12:H==="12h"})}`]})]}),Aa&&r.jsx("div",{style:{fontSize:10,color:"var(--text-faint)",marginTop:2,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:Aa})]})]})]},`transport-${Ne.id}`)}const it=Te.data,ha=ne===`note-${it.id}`,nt=u4(it.icon),rt=We;return r.jsxs(Ka.Fragment,{children:[ht&&r.jsx("div",{style:{height:2,background:"var(--text-primary)",borderRadius:1,margin:"2px 8px"}}),r.jsxs("div",{draggable:!0,onDragStart:Ne=>{Ne.dataTransfer.setData("noteId",String(it.id)),Ne.dataTransfer.setData("fromDayId",String(N.id)),Ne.dataTransfer.effectAllowed="move",Be.current={noteId:String(it.id),fromDayId:String(N.id)},de(`note-${it.id}`)},onDragEnd:()=>{de(null),ve(null),Be.current=null},onDragOver:Ne=>{Ne.preventDefault(),Ne.stopPropagation(),ze!==`note-${it.id}`&&ve(`note-${it.id}`)},onDrop:Ne=>{var Wr;Ne.preventDefault(),Ne.stopPropagation();const{noteId:vt,assignmentId:Xe,fromDayId:mt}=Lt(Ne);if(vt&&mt!==N.id){const Aa=ga(N.id),qt=Aa.findIndex(da=>da.type==="note"&&da.data.id===it.id),$r=qt<=0?(((Wr=Aa[0])==null?void 0:Wr.sortKey)??0)-1:(Aa[qt-1].sortKey+Aa[qt].sortKey)/2;V.moveDayNote(e,mt,N.id,Number(vt),$r).catch(da=>P.error(da instanceof Error?da.message:"Unknown error")),de(null),ve(null)}else if(vt&&vt!==String(it.id))re(N.id,"note",Number(vt),"note",it.id);else if(Xe&&mt!==N.id){const Aa=ga(N.id),qt=Aa.findIndex(da=>da.type==="note"&&da.data.id===it.id),$r=Aa.slice(0,qt).filter(da=>da.type==="place").length;V.moveAssignment(e,Number(Xe),mt,N.id,$r).catch(da=>P.error(da instanceof Error?da.message:"Unknown error")),de(null),ve(null)}else Xe&&re(N.id,"place",Number(Xe),"note",it.id)},onContextMenu:Ne=>Y.open(Ne,[{label:R("common.edit"),icon:sn,onClick:()=>Xt(N.id,it)},{divider:!0},{label:R("common.delete"),icon:_t,danger:!0,onClick:()=>Za(N.id,it.id)}]),onMouseEnter:()=>fe(`note-${it.id}`),onMouseLeave:()=>fe(null),style:{display:"flex",alignItems:"center",gap:8,padding:"7px 8px 7px 2px",margin:"1px 8px",borderRadius:6,border:"1px solid var(--border-faint)",background:"var(--bg-hover)",opacity:K===`note-${it.id}`?.4:1,transition:"background 0.1s",cursor:"grab",userSelect:"none"},children:[r.jsx("div",{style:{flexShrink:0,color:"var(--text-faint)",display:"flex",alignItems:"center",opacity:ha?1:.3,transition:"opacity 0.15s",cursor:"grab"},children:r.jsx(g0,{size:13,strokeWidth:1.8})}),r.jsx("div",{style:{width:28,height:28,flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"50%",background:"var(--bg-hover)",overflow:"hidden"},children:r.jsx(nt,{size:13,strokeWidth:1.8,color:"var(--text-muted)"})}),r.jsxs("div",{style:{flex:1,minWidth:0},children:[r.jsx("span",{style:{fontSize:12.5,fontWeight:500,color:"var(--text-primary)",wordBreak:"break-word"},children:it.text}),it.time&&r.jsx("div",{style:{fontSize:10.5,fontWeight:400,color:"var(--text-faint)",lineHeight:"1.3",marginTop:2,wordBreak:"break-word"},children:it.time})]}),r.jsxs("div",{className:"note-edit-buttons",style:{display:"flex",gap:1,flexShrink:0,opacity:ha?1:0,transition:"opacity 0.15s"},children:[r.jsx("button",{onClick:Ne=>Xt(N.id,it,Ne),style:{background:"none",border:"none",padding:2,cursor:"pointer",color:"var(--text-faint)",display:"flex"},children:r.jsx(sn,{size:10})}),r.jsx("button",{onClick:Ne=>Za(N.id,it.id,Ne),style:{background:"none",border:"none",padding:2,cursor:"pointer",color:"var(--text-faint)",display:"flex"},children:r.jsx(_t,{size:10})})]}),r.jsxs("div",{className:"reorder-buttons",style:{flexShrink:0,display:"flex",gap:1,opacity:ha?1:void 0,transition:"opacity 0.15s"},children:[r.jsx("button",{onClick:Ne=>{Ne.stopPropagation(),At(N.id,it.id,"up")},disabled:rt===0,style:{background:"none",border:"none",padding:"1px 2px",cursor:rt===0?"default":"pointer",color:rt===0?"var(--border-primary)":"var(--text-faint)",display:"flex",lineHeight:1},children:r.jsx(oi,{size:12,strokeWidth:2})}),r.jsx("button",{onClick:Ne=>{Ne.stopPropagation(),At(N.id,it.id,"down")},disabled:rt===Ve.length-1,style:{background:"none",border:"none",padding:"1px 2px",cursor:rt===Ve.length-1?"default":"pointer",color:rt===Ve.length-1?"var(--border-primary)":"var(--text-faint)",display:"flex",lineHeight:1},children:r.jsx(en,{size:12,strokeWidth:2})})]})]})]},`note-${it.id}`)}),r.jsx("div",{style:{minHeight:12,padding:"2px 8px"},onDragOver:Te=>{Te.preventDefault(),Te.stopPropagation(),ze!==`end-${N.id}`&&ve(`end-${N.id}`)},onDrop:Te=>{var rt,Nt;Te.preventDefault(),Te.stopPropagation();const{placeId:We,assignmentId:Ge,noteId:ht,fromDayId:it}=Lt(Te);if(We){S==null||S(parseInt(We),N.id),ve(null),window.__dragData=null;return}if(!Ge&&!ht){Be.current=null,window.__dragData=null;return}if(Ge&&it!==N.id){V.moveAssignment(e,Number(Ge),it,N.id).catch(Ua=>P.error(Ua instanceof Error?Ua.message:"Unknown error")),de(null),ve(null),Be.current=null;return}if(ht&&it!==N.id){V.moveDayNote(e,it,N.id,Number(ht)).catch(Ua=>P.error(Ua instanceof Error?Ua.message:"Unknown error")),de(null),ve(null),Be.current=null;return}const ha=ga(N.id);if(ha.length===0)return;const nt=ha[ha.length-1];Ge&&String((rt=nt==null?void 0:nt.data)==null?void 0:rt.id)!==Ge?re(N.id,"place",Number(Ge),nt.type,nt.data.id,!0):ht&&String((Nt=nt==null?void 0:nt.data)==null?void 0:Nt.id)!==ht&&re(N.id,"note",Number(ht),nt.type,nt.data.id,!0)},children:ze===`end-${N.id}`&&r.jsx("div",{style:{height:2,background:"var(--text-primary)",borderRadius:1}})}),he&&Et(N.id).length>=2&&r.jsxs("div",{style:{padding:"10px 16px 12px",borderTop:"1px solid var(--border-faint)",display:"flex",flexDirection:"column",gap:7},children:[ce&&r.jsxs("div",{style:{display:"flex",justifyContent:"center",gap:12,fontSize:12,color:"var(--text-secondary)",background:"var(--bg-hover)",borderRadius:8,padding:"5px 10px"},children:[r.jsx("span",{children:ce.distance}),r.jsx("span",{style:{color:"var(--text-faint)"},children:"·"}),r.jsx("span",{children:ce.duration})]}),r.jsxs("div",{style:{display:"flex",gap:6},children:[r.jsxs("button",{onClick:Xn,style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",gap:5,padding:"6px 0",fontSize:11,fontWeight:500,borderRadius:8,border:"none",background:"var(--bg-hover)",color:"var(--text-secondary)",cursor:"pointer",fontFamily:"inherit"},children:[r.jsx(Fm,{size:12,strokeWidth:2}),R("dayplan.optimize")]}),r.jsx("button",{onClick:_n,style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"6px 10px",fontSize:11,fontWeight:500,borderRadius:8,border:"1px solid var(--border-faint)",background:"transparent",color:"var(--text-secondary)",cursor:"pointer",fontFamily:"inherit"},children:r.jsx(xn,{size:12,strokeWidth:2})})]})]})]})]},N.id)})}),Object.entries(X).map(([N,se])=>{var he,ee;return se&&Vt.createPortal(r.jsx("div",{style:{position:"fixed",inset:0,zIndex:1e4,display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(0,0,0,0.3)",backdropFilter:"blur(3px)"},onClick:()=>z(Number(N)),children:r.jsxs("div",{style:{width:340,background:"var(--bg-card)",borderRadius:16,boxShadow:"0 16px 48px rgba(0,0,0,0.22)",padding:"22px 22px 18px",display:"flex",flexDirection:"column",gap:12},onClick:ge=>ge.stopPropagation(),children:[r.jsx("div",{style:{fontSize:14,fontWeight:600,color:"var(--text-primary)"},children:se.mode==="add"?R("dayplan.noteAdd"):R("dayplan.noteEdit")}),r.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:5},children:Z_.map(({id:ge,Icon:Me})=>r.jsx("button",{onClick:()=>Z($e=>({...$e,[N]:{...$e[N],icon:ge}})),title:ge,style:{width:45,height:45,borderRadius:8,border:se.icon===ge?"2px solid var(--text-primary)":"2px solid var(--border-faint)",background:se.icon===ge?"var(--bg-hover)":"transparent",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",padding:0},children:r.jsx(Me,{size:18,strokeWidth:1.8,color:se.icon===ge?"var(--text-primary)":"var(--text-muted)"})},ge))}),r.jsx("input",{ref:O,type:"text",value:se.text,onChange:ge=>Z(Me=>({...Me,[N]:{...Me[N],text:ge.target.value}})),onKeyDown:ge=>{ge.key==="Enter"&&(ge.preventDefault(),W(Number(N))),ge.key==="Escape"&&z(Number(N))},placeholder:R("dayplan.noteTitle"),style:{fontSize:13,fontWeight:500,border:"1px solid var(--border-primary)",borderRadius:8,padding:"8px 10px",fontFamily:"inherit",outline:"none",width:"100%",boxSizing:"border-box",color:"var(--text-primary)"}}),r.jsx("textarea",{value:se.time,maxLength:150,rows:3,onChange:ge=>Z(Me=>({...Me,[N]:{...Me[N],time:ge.target.value}})),onKeyDown:ge=>{ge.key==="Escape"&&z(Number(N))},placeholder:R("dayplan.noteSubtitle"),style:{fontSize:12,border:"1px solid var(--border-primary)",borderRadius:8,padding:"7px 10px",fontFamily:"inherit",outline:"none",width:"100%",boxSizing:"border-box",color:"var(--text-primary)",resize:"none",lineHeight:1.4}}),r.jsxs("div",{style:{textAlign:"right",fontSize:11,color:(((he=se.time)==null?void 0:he.length)||0)>=140?"#d97706":"var(--text-faint)",marginTop:-2},children:[((ee=se.time)==null?void 0:ee.length)||0,"/150"]}),r.jsxs("div",{style:{display:"flex",gap:8,justifyContent:"flex-end"},children:[r.jsx("button",{onClick:()=>z(Number(N)),style:{fontSize:12,background:"none",border:"1px solid var(--border-primary)",borderRadius:8,padding:"6px 14px",cursor:"pointer",color:"var(--text-muted)",fontFamily:"inherit"},children:R("common.cancel")}),r.jsx("button",{onClick:()=>W(Number(N)),style:{fontSize:12,background:"var(--accent)",color:"var(--accent-text)",border:"none",borderRadius:8,padding:"6px 16px",cursor:"pointer",fontWeight:600,fontFamily:"inherit"},children:se.mode==="add"?R("common.add"):R("common.save")})]})]})},N),document.body)}),Ke&&Vt.createPortal(r.jsx("div",{style:{position:"fixed",inset:0,zIndex:1e3,display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(0,0,0,0.3)",backdropFilter:"blur(3px)"},onClick:()=>dt(null),children:r.jsxs("div",{style:{width:340,background:"var(--bg-card)",borderRadius:16,boxShadow:"0 16px 48px rgba(0,0,0,0.22)",padding:"22px 22px 18px",display:"flex",flexDirection:"column",gap:12},onClick:N=>N.stopPropagation(),children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[r.jsx("div",{style:{width:36,height:36,flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"50%",background:"rgba(239,68,68,0.12)"},children:r.jsx(Nn,{size:18,strokeWidth:1.8,color:"#ef4444"})}),r.jsx("div",{style:{fontSize:14,fontWeight:600,color:"var(--text-primary)"},children:R("dayplan.confirmRemoveTimeTitle")})]}),r.jsx("div",{style:{fontSize:12.5,color:"var(--text-secondary)",lineHeight:1.5},children:R("dayplan.confirmRemoveTimeBody",{time:Ke.time})}),r.jsxs("div",{style:{display:"flex",gap:8,justifyContent:"flex-end",marginTop:4},children:[r.jsx("button",{onClick:()=>dt(null),style:{fontSize:12,background:"none",border:"1px solid var(--border-primary)",borderRadius:8,padding:"6px 14px",cursor:"pointer",color:"var(--text-muted)",fontFamily:"inherit"},children:R("common.cancel")}),r.jsx("button",{onClick:Ie,style:{fontSize:12,background:"#ef4444",color:"white",border:"none",borderRadius:8,padding:"6px 16px",cursor:"pointer",fontWeight:600,fontFamily:"inherit"},children:R("common.confirm")})]})]})}),document.body),Ee&&Vt.createPortal(r.jsx("div",{style:{position:"fixed",inset:0,zIndex:1e3,display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(0,0,0,0.3)",backdropFilter:"blur(3px)"},onClick:()=>Oe(null),children:r.jsx("div",{style:{width:380,maxHeight:"80vh",overflowY:"auto",background:"var(--bg-card)",borderRadius:16,boxShadow:"0 16px 48px rgba(0,0,0,0.22)",padding:"22px 22px 18px",display:"flex",flexDirection:"column",gap:14},onClick:N=>N.stopPropagation(),children:(()=>{var $e,ct;const N=Ee,se=ah[N.type]||kn,ee={flight:"#3b82f6",train:"#06b6d4",bus:"#f59e0b",car:"#6b7280",cruise:"#0ea5e9"}[N.type]||"var(--text-muted)",ge=typeof N.metadata=="string"?JSON.parse(N.metadata||"{}"):N.metadata||{},Me=[];return N.type==="flight"?(ge.airline&&Me.push({label:R("reservations.meta.airline"),value:ge.airline}),ge.flight_number&&Me.push({label:R("reservations.meta.flightNumber"),value:ge.flight_number}),ge.departure_airport&&Me.push({label:R("reservations.meta.from"),value:ge.departure_airport}),ge.arrival_airport&&Me.push({label:R("reservations.meta.to"),value:ge.arrival_airport}),ge.seat&&Me.push({label:R("reservations.meta.seat"),value:ge.seat})):N.type==="train"&&(ge.train_number&&Me.push({label:R("reservations.meta.trainNumber"),value:ge.train_number}),ge.platform&&Me.push({label:R("reservations.meta.platform"),value:ge.platform}),ge.seat&&Me.push({label:R("reservations.meta.seat"),value:ge.seat})),N.confirmation_number&&Me.push({label:R("reservations.confirmationCode"),value:N.confirmation_number,sensitive:!0}),N.location&&Me.push({label:R("reservations.locationAddress"),value:N.location}),r.jsxs(r.Fragment,{children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[r.jsx("div",{style:{width:36,height:36,flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"50%",background:`${ee}18`},children:r.jsx(se,{size:18,strokeWidth:1.8,color:ee})}),r.jsxs("div",{style:{flex:1},children:[r.jsx("div",{style:{fontSize:15,fontWeight:600,color:"var(--text-primary)"},children:N.title}),r.jsxs("div",{style:{fontSize:11,color:"var(--text-faint)",marginTop:2},children:[($e=N.reservation_time)!=null&&$e.includes("T")?new Date(N.reservation_time).toLocaleString(I,{weekday:"short",day:"numeric",month:"short",hour:"2-digit",minute:"2-digit",hour12:H==="12h"}):N.reservation_time?new Date(N.reservation_time+"T00:00:00").toLocaleDateString(I,{weekday:"short",day:"numeric",month:"short"}):"",((ct=N.reservation_end_time)==null?void 0:ct.includes("T"))&&` – ${new Date(N.reservation_end_time).toLocaleTimeString(I,{hour:"2-digit",minute:"2-digit",hour12:H==="12h"})}`]})]}),r.jsx("div",{style:{padding:"3px 8px",borderRadius:6,fontSize:10,fontWeight:600,background:N.status==="confirmed"?"rgba(22,163,74,0.1)":"rgba(217,119,6,0.1)",color:N.status==="confirmed"?"#16a34a":"#d97706"},children:(N.status==="confirmed"?R("planner.resConfirmed"):R("planner.resPending")).replace(/\s*·\s*$/,"")})]}),Me.length>0&&r.jsx("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:8},children:Me.map((bt,Ve)=>{const yt=bt.sensitive&&ta.getState().settings.blur_booking_codes;return r.jsxs("div",{style:{padding:"8px 10px",background:"var(--bg-tertiary)",borderRadius:8},children:[r.jsx("div",{style:{fontSize:9,fontWeight:600,color:"var(--text-faint)",textTransform:"uppercase",letterSpacing:"0.03em",marginBottom:3},children:bt.label}),r.jsx("div",{onMouseEnter:wt=>{yt&&(wt.currentTarget.style.filter="none")},onMouseLeave:wt=>{yt&&(wt.currentTarget.style.filter="blur(5px)")},onClick:wt=>{if(yt){const Te=wt.currentTarget;Te.style.filter=Te.style.filter==="none"?"blur(5px)":"none"}},style:{fontSize:12,fontWeight:500,color:"var(--text-primary)",wordBreak:"break-word",filter:yt?"blur(5px)":"none",transition:"filter 0.2s",cursor:yt?"pointer":"default",userSelect:yt?"none":"auto"},children:bt.value})]},Ve)})}),N.notes&&r.jsxs("div",{style:{padding:"8px 10px",background:"var(--bg-tertiary)",borderRadius:8},children:[r.jsx("div",{style:{fontSize:9,fontWeight:600,color:"var(--text-faint)",textTransform:"uppercase",letterSpacing:"0.03em",marginBottom:3},children:R("reservations.notes")}),r.jsx("div",{style:{fontSize:12,color:"var(--text-primary)",whiteSpace:"pre-wrap",wordBreak:"break-word"},children:N.notes})]}),(()=>{const bt=(V.files||[]).filter(Ve=>!Ve.deleted_at&&(Ve.reservation_id===N.id||Ve.linked_reservation_ids&&Ve.linked_reservation_ids.includes(N.id)));return bt.length===0?null:r.jsxs("div",{children:[r.jsx("div",{style:{fontSize:9,fontWeight:600,color:"var(--text-faint)",textTransform:"uppercase",letterSpacing:"0.03em",marginBottom:6},children:R("files.title")}),r.jsx("div",{style:{display:"flex",flexDirection:"column",gap:4},children:bt.map(Ve=>r.jsxs("div",{onClick:()=>{Oe(null),A==null||A()},style:{display:"flex",alignItems:"center",gap:8,padding:"6px 10px",background:"var(--bg-tertiary)",borderRadius:8,cursor:"pointer",transition:"background 0.1s"},onMouseEnter:yt=>yt.currentTarget.style.background="var(--bg-hover)",onMouseLeave:yt=>yt.currentTarget.style.background="var(--bg-tertiary)",children:[r.jsx(Pa,{size:14,style:{color:"var(--text-muted)",flexShrink:0}}),r.jsx("span",{style:{flex:1,fontSize:12,fontWeight:500,color:"var(--text-primary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:Ve.original_name}),r.jsx(xn,{size:11,style:{color:"var(--text-faint)",flexShrink:0}})]},Ve.id))})]})})(),r.jsx("div",{style:{textAlign:"right"},children:r.jsx("button",{onClick:()=>Oe(null),style:{fontSize:12,background:"var(--accent)",color:"var(--accent-text)",border:"none",borderRadius:8,padding:"6px 16px",cursor:"pointer",fontWeight:600,fontFamily:"inherit"},children:R("common.close")})})]})})()})}),document.body),Ea>0&&r.jsxs("div",{style:{flexShrink:0,padding:"10px 16px",borderTop:"1px solid var(--border-faint)",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[r.jsx("span",{style:{fontSize:11,color:"var(--text-faint)"},children:R("dayplan.totalCost")}),r.jsxs("span",{style:{fontSize:13,fontWeight:600,color:"var(--text-primary)"},children:[Ea.toFixed(el(Kt))," ",Kt]})]}),r.jsx(G_,{menu:Y.menu,onClose:Y.close})]})}function F0({tripId:e,places:t,categories:a,assignments:n,selectedDayId:i,selectedPlaceId:o,onPlaceClick:s,onAddPlace:d,onAssignToDay:c,onEditPlace:p,onDeletePlace:m,days:g,isMobile:f,onCategoryFilterChange:y}){const{t:x}=ot(),k=ya(),S=q_(),v=b.useRef(null),_=Rn(),w=async D=>{var z,W,B;const J=(z=D.target.files)==null?void 0:z[0];if(J){D.target.value="";try{const C=await io.importGpx(e,J);await _.loadTrip(e),k.success(x("places.gpxImported",{count:C.count}))}catch(C){k.error(((B=(W=C==null?void 0:C.response)==null?void 0:W.data)==null?void 0:B.error)||x("places.gpxError"))}}},[E,M]=b.useState(""),[A,P]=b.useState("all"),[R,$]=b.useState(new Set),I=D=>{$(J=>{const z=new Set(J);return z.has(D)?z.delete(D):z.add(D),y==null||y(z.size===1?[...z][0]:""),z})},[Y,H]=b.useState(null),[V,X]=b.useState(!1),Z=new Set(Object.values(n).flatMap(D=>D.map(J=>{var z;return(z=J.place)==null?void 0:z.id}).filter(Boolean))),O=b.useMemo(()=>t.filter(D=>!(A==="unplanned"&&Z.has(D.id)||R.size>0&&!R.has(String(D.category_id))||E&&!D.name.toLowerCase().includes(E.toLowerCase())&&!(D.address||"").toLowerCase().includes(E.toLowerCase()))),[t,A,R,E,Z.size]),Q=D=>i&&(n[String(i)]||[]).some(J=>{var z;return((z=J.place)==null?void 0:z.id)===D});return r.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",fontFamily:"-apple-system, BlinkMacSystemFont, 'SF Pro Text', system-ui, sans-serif"},children:[r.jsxs("div",{style:{padding:"14px 16px 10px",borderBottom:"1px solid var(--border-faint)",flexShrink:0},children:[r.jsxs("button",{onClick:d,style:{display:"flex",alignItems:"center",justifyContent:"center",gap:6,width:"100%",padding:"8px 12px",borderRadius:12,border:"none",background:"var(--accent)",color:"var(--accent-text)",fontSize:13,fontWeight:500,cursor:"pointer",fontFamily:"inherit",marginBottom:10},children:[r.jsx(Ft,{size:14,strokeWidth:2})," ",x("places.addPlace")]}),r.jsx("input",{ref:v,type:"file",accept:".gpx",style:{display:"none"},onChange:w}),r.jsxs("button",{onClick:()=>{var D;return(D=v.current)==null?void 0:D.click()},style:{display:"flex",alignItems:"center",justifyContent:"center",gap:5,width:"100%",padding:"5px 12px",borderRadius:8,marginBottom:10,border:"1px dashed var(--border-primary)",background:"none",color:"var(--text-faint)",fontSize:11,fontWeight:500,cursor:"pointer",fontFamily:"inherit"},children:[r.jsx(So,{size:11,strokeWidth:2})," ",x("places.importGpx")]}),r.jsx("div",{style:{display:"flex",gap:4,marginBottom:8},children:[{id:"all",label:x("places.all")},{id:"unplanned",label:x("places.unplanned")}].map(D=>r.jsx("button",{onClick:()=>P(D.id),style:{padding:"4px 10px",borderRadius:20,border:"none",cursor:"pointer",fontSize:11,fontWeight:500,fontFamily:"inherit",background:A===D.id?"var(--accent)":"var(--bg-tertiary)",color:A===D.id?"var(--accent-text)":"var(--text-muted)"},children:D.label},D.id))}),r.jsxs("div",{style:{position:"relative"},children:[r.jsx(Om,{size:13,strokeWidth:1.8,color:"var(--text-faint)",style:{position:"absolute",left:10,top:"50%",transform:"translateY(-50%)",pointerEvents:"none"}}),r.jsx("input",{type:"text",value:E,onChange:D=>M(D.target.value),placeholder:x("places.search"),style:{width:"100%",padding:"7px 30px 7px 30px",borderRadius:10,border:"none",background:"var(--bg-tertiary)",fontSize:12,color:"var(--text-primary)",outline:"none",fontFamily:"inherit",boxSizing:"border-box"}}),E&&r.jsx("button",{onClick:()=>M(""),style:{position:"absolute",right:8,top:"50%",transform:"translateY(-50%)",background:"none",border:"none",cursor:"pointer",padding:0,display:"flex"},children:r.jsx(gt,{size:12,strokeWidth:2,color:"var(--text-faint)"})})]}),a.length>0&&(()=>{var J;const D=R.size===0?x("places.allCategories"):R.size===1?((J=a.find(z=>R.has(String(z.id))))==null?void 0:J.name)||x("places.allCategories"):`${R.size} ${x("places.categoriesSelected")}`;return r.jsxs("div",{style:{marginTop:6,position:"relative"},children:[r.jsxs("button",{onClick:()=>X(z=>!z),style:{width:"100%",display:"flex",alignItems:"center",justifyContent:"space-between",padding:"6px 10px",borderRadius:8,border:"1px solid var(--border-primary)",background:"var(--bg-card)",fontSize:12,color:"var(--text-primary)",cursor:"pointer",fontFamily:"inherit"},children:[r.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:D}),r.jsx(en,{size:12,style:{flexShrink:0,color:"var(--text-faint)",transform:V?"rotate(180deg)":"none",transition:"transform 0.15s"}})]}),V&&r.jsxs("div",{style:{position:"absolute",top:"100%",left:0,right:0,zIndex:50,marginTop:4,background:"var(--bg-card)",border:"1px solid var(--border-primary)",borderRadius:10,boxShadow:"0 4px 16px rgba(0,0,0,0.12)",padding:4,maxHeight:200,overflowY:"auto"},children:[a.map(z=>{const W=R.has(String(z.id)),B=ci(z.icon);return r.jsxs("button",{onClick:()=>I(String(z.id)),style:{display:"flex",alignItems:"center",gap:8,width:"100%",padding:"6px 10px",borderRadius:6,border:"none",cursor:"pointer",background:W?"var(--bg-hover)":"transparent",fontFamily:"inherit",fontSize:12,color:"var(--text-primary)",textAlign:"left"},children:[r.jsx("div",{style:{width:16,height:16,borderRadius:4,flexShrink:0,border:W?"none":"1.5px solid var(--border-primary)",background:W?z.color||"var(--accent)":"transparent",display:"flex",alignItems:"center",justifyContent:"center"},children:W&&r.jsx(Ga,{size:10,strokeWidth:3,color:"white"})}),r.jsx(B,{size:12,strokeWidth:2,color:z.color||"var(--text-muted)"}),r.jsx("span",{style:{flex:1},children:z.name})]},z.id)}),R.size>0&&r.jsxs("button",{onClick:()=>{$(new Set),y==null||y("")},style:{display:"flex",alignItems:"center",justifyContent:"center",gap:4,width:"100%",padding:"6px 10px",borderRadius:6,border:"none",cursor:"pointer",background:"transparent",fontFamily:"inherit",fontSize:11,color:"var(--text-faint)",marginTop:2,borderTop:"1px solid var(--border-faint)"},children:[r.jsx(gt,{size:10})," ",x("places.clearFilter")]})]})]})})()]}),r.jsx("div",{style:{padding:"6px 16px",flexShrink:0},children:r.jsx("span",{style:{fontSize:11,color:"var(--text-faint)"},children:O.length===1?x("places.countSingular"):x("places.count",{count:O.length})})}),r.jsx("div",{style:{flex:1,overflowY:"auto",minHeight:0},children:O.length===0?r.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",padding:"40px 16px",gap:8},children:[r.jsx("span",{style:{fontSize:13,color:"var(--text-faint)"},children:x(A==="unplanned"?"places.allPlanned":"places.noneFound")}),r.jsx("button",{onClick:d,style:{fontSize:12,color:"var(--text-primary)",background:"none",border:"none",cursor:"pointer",textDecoration:"underline",fontFamily:"inherit"},children:x("places.addPlace")})]}):O.map(D=>{const J=a.find(B=>B.id===D.category_id),z=D.id===o,W=Q(D.id);return Z.has(D.id),r.jsxs("div",{draggable:!0,onDragStart:B=>{B.dataTransfer.setData("placeId",String(D.id)),B.dataTransfer.effectAllowed="copy",window.__dragData={placeId:String(D.id)}},onClick:()=>{f&&(g==null?void 0:g.length)>0?H(D):s(z?null:D.id)},onContextMenu:B=>S.open(B,[p&&{label:x("common.edit"),icon:sn,onClick:()=>p(D)},i&&{label:x("planner.addToDay"),icon:Nl,onClick:()=>c(D.id,i)},D.website&&{label:x("inspector.website"),icon:xn,onClick:()=>window.open(D.website,"_blank")},D.lat&&D.lng&&{label:"Google Maps",icon:ps,onClick:()=>window.open(`https://www.google.com/maps/search/?api=1&query=${D.lat},${D.lng}`,"_blank")},{divider:!0},m&&{label:x("common.delete"),icon:_t,danger:!0,onClick:()=>m(D.id)}]),style:{display:"flex",alignItems:"center",gap:10,padding:"9px 14px 9px 16px",cursor:"grab",background:z?"var(--border-faint)":"transparent",borderBottom:"1px solid var(--border-faint)",transition:"background 0.1s",contentVisibility:"auto",containIntrinsicSize:"0 52px"},onMouseEnter:B=>{z||(B.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:B=>{z||(B.currentTarget.style.background="transparent")},children:[r.jsx(tb,{place:D,category:J,size:34}),r.jsxs("div",{style:{flex:1,minWidth:0},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:5,overflow:"hidden"},children:[J&&(()=>{const B=ci(J.icon);return r.jsx(B,{size:11,strokeWidth:2,color:J.color||"#6366f1",style:{flexShrink:0},title:J.name})})(),r.jsx("span",{style:{fontSize:13,fontWeight:500,color:"var(--text-primary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",lineHeight:1.2},children:D.name})]}),(D.description||D.address||(J==null?void 0:J.name))&&r.jsx("div",{style:{marginTop:2},children:r.jsx("span",{style:{fontSize:11,color:"var(--text-faint)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",display:"block",lineHeight:1.2},children:D.description||D.address||(J==null?void 0:J.name)})})]}),r.jsx("div",{style:{flexShrink:0,display:"flex",alignItems:"center"},children:!W&&i&&r.jsx("button",{onClick:B=>{B.stopPropagation(),c(D.id)},style:{display:"flex",alignItems:"center",justifyContent:"center",width:20,height:20,borderRadius:6,background:"var(--bg-hover)",border:"none",cursor:"pointer",color:"var(--text-faint)",padding:0,transition:"background 0.15s, color 0.15s"},onMouseEnter:B=>{B.currentTarget.style.background="var(--accent)",B.currentTarget.style.color="var(--accent-text)"},onMouseLeave:B=>{B.currentTarget.style.background="var(--bg-hover)",B.currentTarget.style.color="var(--text-faint)"},children:r.jsx(Ft,{size:12,strokeWidth:2.5})})})]},D.id)})}),Y&&(g==null?void 0:g.length)>0&&Vt.createPortal(r.jsx("div",{onClick:()=>H(null),style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.4)",zIndex:99999,display:"flex",alignItems:"flex-end",justifyContent:"center"},children:r.jsxs("div",{onClick:D=>D.stopPropagation(),style:{background:"var(--bg-card)",borderRadius:"20px 20px 0 0",width:"100%",maxWidth:500,maxHeight:"60vh",display:"flex",flexDirection:"column",overflow:"hidden",paddingBottom:"env(safe-area-inset-bottom)"},children:[r.jsxs("div",{style:{padding:"16px 20px 12px",borderBottom:"1px solid var(--border-secondary)"},children:[r.jsx("div",{style:{fontSize:15,fontWeight:700,color:"var(--text-primary)"},children:Y.name}),r.jsx("div",{style:{fontSize:12,color:"var(--text-faint)",marginTop:2},children:x("places.assignToDay")})]}),r.jsx("div",{style:{flex:1,overflowY:"auto",padding:"8px 12px 16px"},children:g.map((D,J)=>r.jsxs("button",{onClick:()=>{c(Y.id,D.id),H(null)},style:{display:"flex",alignItems:"center",gap:10,width:"100%",padding:"12px 14px",borderRadius:12,border:"none",cursor:"pointer",background:"transparent",fontFamily:"inherit",textAlign:"left",transition:"background 0.1s"},onMouseEnter:z=>z.currentTarget.style.background="var(--bg-hover)",onMouseLeave:z=>z.currentTarget.style.background="transparent",children:[r.jsx("div",{style:{width:32,height:32,borderRadius:"50%",background:"var(--bg-tertiary)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:13,fontWeight:700,color:"var(--text-primary)",flexShrink:0},children:J+1}),r.jsxs("div",{style:{flex:1,minWidth:0},children:[r.jsx("div",{style:{fontSize:13,fontWeight:600,color:"var(--text-primary)"},children:D.title||`${x("dayplan.dayN",{n:J+1})}`}),D.date&&r.jsx("div",{style:{fontSize:11,color:"var(--text-faint)"},children:new Date(D.date+"T00:00:00").toLocaleDateString()})]}),(n[String(D.id)]||[]).some(z=>{var W;return((W=z.place)==null?void 0:W.id)===Y.id})&&r.jsx("span",{style:{fontSize:11,color:"var(--text-faint)"},children:"✓"})]},D.id))})]})}),document.body),r.jsx(G_,{menu:S.menu,onClose:S.close})]})}const mu=new Map;function p4(e){try{const t=sessionStorage.getItem(e);return t?JSON.parse(t):void 0}catch{return}}function m4(e,t){try{sessionStorage.setItem(e,JSON.stringify(t))}catch{}}function g4(e,t,a){const[n,i]=b.useState(null),o=e||t,s=`gdetails_${o}_${a}`;return b.useEffect(()=>{if(!o){i(null);return}if(mu.has(s)){i(mu.get(s));return}const d=p4(s);if(d){mu.set(s,d),i(d);return}ko.details(o,a).then(c=>{mu.set(s,c.place),m4(s,c.place),i(c.place)}).catch(()=>{})},[o,a]),n}function h4(e){const a=(e?new Date(e+"T12:00:00"):new Date).getDay();return a===0?6:a-1}function O0(e,t){if(!e)return"";const a=/\d{1,2}:\d{2}\s*(AM|PM)/i.test(e);return t==="12h"&&!a?e.replace(/\s*Uhr/g,"").replace(/(\d{1,2}):(\d{2})/g,(n,i,o)=>{const s=parseInt(i);if(isNaN(s))return n;const d=s>=12?"PM":"AM";return`${s===0?12:s>12?s-12:s}:${o} ${d}`}):t!=="12h"&&a?e.replace(/(\d{1,2}):(\d{2})\s*(AM|PM)/gi,(n,i,o,s)=>{let d=parseInt(i);return s.toUpperCase()==="PM"&&d!==12&&(d+=12),s.toUpperCase()==="AM"&&d===12&&(d=0),`${String(d).padStart(2,"0")}:${o}`}):e}function B0(e,t,a){if(!e)return"";try{const n=e.split(":"),i=Number(n[0])||0,o=Number(n[1])||0;if(isNaN(i))return e;if(a==="12h"){const d=i>=12?"PM":"AM";return`${i===0?12:i>12?i-12:i}:${String(o).padStart(2,"0")} ${d}`}const s=`${String(i).padStart(2,"0")}:${String(o).padStart(2,"0")}`;return t!=null&&t.startsWith("de")?`${s} Uhr`:s}catch{return e}}function f4(e){return e?e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(1)} MB`:""}function y4({place:e,categories:t,days:a,selectedDayId:n,selectedAssignmentId:i,assignments:o,reservations:s=[],onClose:d,onEdit:c,onDelete:p,onAssignToDay:m,onRemoveAssignment:g,files:f,onFileUpload:y,tripMembers:x=[],onSetParticipants:k,onUpdatePlace:S,leftWidth:v=0,rightWidth:_=0}){const{t:w,locale:E,language:M}=ot(),A=ta(ce=>ce.settings.time_format)||"24h",[P,R]=b.useState(!1),[$,I]=b.useState(!1),[Y,H]=b.useState(!1),[V,X]=b.useState(!1),[Z,O]=b.useState(""),Q=b.useRef(null),D=b.useRef(null),J=g4(e==null?void 0:e.google_place_id,e==null?void 0:e.osm_id,M),z=()=>{S&&(O(e.name||""),X(!0),setTimeout(()=>{var ce;return(ce=Q.current)==null?void 0:ce.focus()},0))},W=()=>{if(!V)return;const ce=Z.trim();X(!1),!(!ce||ce===e.name)&&S(e.id,{name:ce})},B=ce=>{ce.key==="Enter"&&(ce.preventDefault(),W()),ce.key==="Escape"&&X(!1)};if(!e)return null;const C=t==null?void 0:t.find(ce=>ce.id===e.category_id),U=n?o[String(n)]||[]:[],q=n?U.find(ce=>{var le;return((le=ce.place)==null?void 0:le.id)===e.id}):null,te=(J==null?void 0:J.opening_hours)||null,oe=(J==null?void 0:J.open_now)??null,be=a==null?void 0:a.find(ce=>ce.id===n),Se=h4(be==null?void 0:be.date),je=(f||[]).filter(ce=>String(ce.place_id)===String(e.id)||(ce.linked_place_ids||[]).includes(e.id)),we=b.useCallback(async ce=>{const le=Array.from(ce.target.files||[]);if(!(!le.length||!y)){H(!0);try{for(const K of le){const de=new FormData;de.append("file",K),de.append("place_id",e.id),await y(de)}I(!0)}catch(K){console.error("Upload failed",K)}finally{H(!1),D.current&&(D.current.value="")}}},[y,e.id]);return r.jsx("div",{style:{position:"absolute",bottom:20,left:`calc(${v}px + (100% - ${v}px - ${_}px) / 2)`,transform:"translateX(-50%)",width:`min(800px, calc(100% - ${v}px - ${_}px - 32px))`,zIndex:50,fontFamily:"-apple-system, BlinkMacSystemFont, 'SF Pro Text', system-ui, sans-serif"},children:r.jsxs("div",{style:{background:"var(--bg-elevated)",backdropFilter:"blur(40px) saturate(180%)",WebkitBackdropFilter:"blur(40px) saturate(180%)",borderRadius:20,boxShadow:"0 8px 40px rgba(0,0,0,0.14), 0 0 0 1px rgba(0,0,0,0.06)",overflow:"hidden",maxHeight:"60vh",display:"flex",flexDirection:"column"},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:oe!==null?26:14,padding:oe!==null?"18px 16px 14px 28px":"18px 16px 14px",borderBottom:"1px solid var(--border-faint)"},children:[r.jsxs("div",{style:{position:"relative",flexShrink:0,marginBottom:oe!==null?8:0},children:[r.jsx("div",{style:{borderRadius:"50%",padding:2.5,background:oe===!0?"#22c55e":oe===!1?"#ef4444":"transparent"},children:r.jsx(tb,{place:e,category:C,size:52})}),oe!==null&&r.jsx("span",{style:{position:"absolute",bottom:-7,left:"50%",transform:"translateX(-50%)",fontSize:9,fontWeight:500,letterSpacing:"0.02em",color:"white",background:oe?"#16a34a":"#dc2626",padding:"1.5px 7px",borderRadius:99,whiteSpace:"nowrap",boxShadow:"0 1px 4px rgba(0,0,0,0.2)"},children:w(oe?"inspector.opened":"inspector.closed")})]}),r.jsxs("div",{style:{flex:1,minWidth:0},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,flexWrap:"wrap"},children:[V?r.jsx("input",{ref:Q,value:Z,onChange:ce=>O(ce.target.value),onBlur:W,onKeyDown:B,style:{fontWeight:600,fontSize:15,color:"var(--text-primary)",lineHeight:"1.3",background:"var(--bg-secondary)",border:"1px solid var(--border-primary)",borderRadius:6,padding:"1px 6px",fontFamily:"inherit",outline:"none",width:"100%"}}):r.jsx("span",{onDoubleClick:z,style:{fontWeight:600,fontSize:15,color:"var(--text-primary)",lineHeight:"1.3",cursor:S?"text":"default"},children:e.name}),C&&(()=>{const ce=ci(C.icon);return r.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:4,fontSize:11,fontWeight:500,color:C.color||"#6b7280",background:C.color?`${C.color}18`:"rgba(0,0,0,0.06)",border:`1px solid ${C.color?`${C.color}30`:"transparent"}`,padding:"2px 8px",borderRadius:99},children:[r.jsx(ce,{size:10}),r.jsx("span",{className:"hidden sm:inline",children:C.name})]})})()]}),e.address&&r.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:4,marginTop:6},children:[r.jsx(tn,{size:11,color:"var(--text-faint)",style:{flexShrink:0,marginTop:2}}),r.jsx("span",{style:{fontSize:12,color:"var(--text-muted)",lineHeight:"1.4",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",overflow:"hidden"},children:e.address})]}),e.place_time&&r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4,marginTop:3},children:[r.jsx(Nn,{size:10,color:"var(--text-faint)",style:{flexShrink:0}}),r.jsxs("span",{style:{fontSize:12,color:"var(--text-muted)"},children:[B0(e.place_time,E,A),e.end_time?` – ${B0(e.end_time,E,A)}`:""]})]}),e.lat&&e.lng&&r.jsxs("div",{className:"hidden sm:block",style:{fontSize:11,color:"var(--text-faint)",marginTop:4,fontVariantNumeric:"tabular-nums"},children:[Number(e.lat).toFixed(6),", ",Number(e.lng).toFixed(6)]})]}),r.jsx("button",{onClick:d,style:{width:28,height:28,borderRadius:"50%",background:"var(--bg-hover)",border:"none",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",flexShrink:0,alignSelf:"flex-start",transition:"background 0.15s"},onMouseEnter:ce=>ce.currentTarget.style.background="var(--bg-tertiary)",onMouseLeave:ce=>ce.currentTarget.style.background="var(--bg-hover)",children:r.jsx(gt,{size:14,strokeWidth:2,color:"var(--text-secondary)"})})]}),r.jsxs("div",{style:{overflowY:"auto",padding:"12px 16px",display:"flex",flexDirection:"column",gap:10},children:[r.jsxs("div",{className:"hidden sm:flex",style:{flexWrap:"wrap",gap:6,alignItems:"center"},children:[(J==null?void 0:J.rating)&&(()=>{const ce=(J.reviews||[]).find(le=>le.text&&le.text.length>5);return r.jsx(H0,{icon:r.jsx(si,{size:12,fill:"#facc15",color:"#facc15"}),text:r.jsxs(r.Fragment,{children:[J.rating.toFixed(1),J.rating_count?r.jsxs("span",{style:{opacity:.5},children:[" (",J.rating_count.toLocaleString(E),")"]}):"",ce&&r.jsxs("span",{className:"hidden md:inline",style:{opacity:.6,fontWeight:400,fontStyle:"italic",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[" · „",ce.text,'"']})]}),color:"var(--text-secondary)",bg:"var(--bg-hover)"})})(),e.price>0&&r.jsx(H0,{icon:r.jsx(IM,{size:12}),text:`${e.price} ${e.currency||"€"}`,color:"#059669",bg:"#ecfdf5"})]}),(e.phone||(J==null?void 0:J.phone))&&r.jsx("div",{style:{display:"flex",gap:12},children:r.jsxs("a",{href:`tel:${e.phone||J.phone}`,style:{display:"inline-flex",alignItems:"center",gap:4,fontSize:12,color:"var(--text-primary)",textDecoration:"none"},children:[r.jsx(iD,{size:12})," ",e.phone||J.phone]})}),(e.description||e.notes||(J==null?void 0:J.summary))&&r.jsx("div",{style:{background:"var(--bg-hover)",borderRadius:10,overflow:"hidden"},children:r.jsx("p",{style:{fontSize:12,color:"var(--text-muted)",margin:0,lineHeight:"1.5",padding:"8px 12px"},children:e.description||e.notes||(J==null?void 0:J.summary)})}),(()=>{const ce=i?s.find(Ae=>Ae.assignment_id===i):null,le=i?(o[String(n)]||[]).find(Ae=>Ae.id===i):null,K=(le==null?void 0:le.participants)||[],de=K.map(Ae=>Ae.user_id),_e=K.length===0,pe=i&&x.length>1;return!ce&&!pe?null:r.jsxs("div",{className:`grid ${ce&&pe?"grid-cols-1 sm:grid-cols-2":"grid-cols-1"} gap-2`,children:[ce&&(()=>{var He;const Ae=ce.status==="confirmed";return r.jsxs("div",{style:{borderRadius:12,overflow:"hidden",border:`1px solid ${Ae?"rgba(22,163,74,0.2)":"rgba(217,119,6,0.2)"}`},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"6px 10px",background:Ae?"rgba(22,163,74,0.08)":"rgba(217,119,6,0.08)"},children:[r.jsx("div",{style:{width:6,height:6,borderRadius:"50%",flexShrink:0,background:Ae?"#16a34a":"#d97706"}}),r.jsx("span",{style:{fontSize:10,fontWeight:700,color:Ae?"#16a34a":"#d97706"},children:w(Ae?"reservations.confirmed":"reservations.pending")}),r.jsx("span",{style:{flex:1}}),r.jsx("span",{style:{fontSize:11,fontWeight:600,color:"var(--text-primary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:ce.title})]}),r.jsxs("div",{style:{padding:"6px 10px",display:"flex",gap:12,flexWrap:"wrap"},children:[ce.reservation_time&&r.jsxs("div",{children:[r.jsx("div",{style:{fontSize:8,fontWeight:600,color:"var(--text-faint)",textTransform:"uppercase"},children:w("reservations.date")}),r.jsx("div",{style:{fontSize:10,fontWeight:500,color:"var(--text-primary)",marginTop:1},children:new Date(ce.reservation_time).toLocaleDateString(E,{weekday:"short",day:"numeric",month:"short"})})]}),((He=ce.reservation_time)==null?void 0:He.includes("T"))&&r.jsxs("div",{children:[r.jsx("div",{style:{fontSize:8,fontWeight:600,color:"var(--text-faint)",textTransform:"uppercase"},children:w("reservations.time")}),r.jsxs("div",{style:{fontSize:10,fontWeight:500,color:"var(--text-primary)",marginTop:1},children:[new Date(ce.reservation_time).toLocaleTimeString(E,{hour:"2-digit",minute:"2-digit",hour12:A==="12h"}),ce.reservation_end_time&&` – ${ce.reservation_end_time}`]})]}),ce.confirmation_number&&r.jsxs("div",{children:[r.jsx("div",{style:{fontSize:8,fontWeight:600,color:"var(--text-faint)",textTransform:"uppercase"},children:w("reservations.confirmationCode")}),r.jsx("div",{style:{fontSize:10,fontWeight:500,color:"var(--text-primary)",marginTop:1},children:ce.confirmation_number})]})]}),ce.notes&&r.jsx("div",{style:{padding:"0 10px 6px",fontSize:10,color:"var(--text-faint)",lineHeight:1.4},children:ce.notes}),(()=>{const ze=typeof ce.metadata=="string"?JSON.parse(ce.metadata||"{}"):ce.metadata||{};if(!ze||Object.keys(ze).length===0)return null;const Ye=[];return ze.airline&&ze.flight_number?Ye.push(`${ze.airline} ${ze.flight_number}`):ze.flight_number&&Ye.push(ze.flight_number),ze.departure_airport&&ze.arrival_airport&&Ye.push(`${ze.departure_airport} → ${ze.arrival_airport}`),ze.train_number&&Ye.push(ze.train_number),ze.platform&&Ye.push(`Gl. ${ze.platform}`),ze.check_in_time&&Ye.push(`Check-in ${ze.check_in_time}`),ze.check_out_time&&Ye.push(`Check-out ${ze.check_out_time}`),Ye.length===0?null:r.jsx("div",{style:{padding:"0 10px 6px",fontSize:10,color:"var(--text-muted)",fontWeight:500},children:Ye.join(" · ")})})()]})})(),pe&&r.jsx(v4,{tripMembers:x,participantIds:de,allJoined:_e,onSetParticipants:k,selectedAssignmentId:i,selectedDayId:n,t:w})]})})(),r.jsxs("div",{className:`grid grid-cols-1 ${(te==null?void 0:te.length)>0?"sm:grid-cols-2":""} gap-2`,children:[te&&te.length>0&&r.jsxs("div",{style:{background:"var(--bg-hover)",borderRadius:10,overflow:"hidden"},children:[r.jsxs("button",{onClick:()=>R(ce=>!ce),style:{width:"100%",display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 12px",background:"none",border:"none",cursor:"pointer",fontFamily:"inherit"},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[r.jsx(Nn,{size:13,color:"#9ca3af"}),r.jsx("span",{style:{fontSize:12,color:"var(--text-secondary)",fontWeight:500},children:P?w("inspector.openingHours"):O0(te[Se]||"",A)||w("inspector.showHours")})]}),P?r.jsx(oi,{size:13,color:"#9ca3af"}):r.jsx(en,{size:13,color:"#9ca3af"})]}),P&&r.jsx("div",{style:{padding:"0 12px 10px"},children:te.map((ce,le)=>r.jsx("div",{style:{fontSize:12,color:le===Se?"var(--text-primary)":"var(--text-muted)",fontWeight:le===Se?600:400,padding:"2px 0"},children:O0(ce,A)},le))})]}),e.route_geometry&&(()=>{try{const ce=JSON.parse(e.route_geometry);if(!ce||ce.length<2)return null;const le=ce[0].length>=3,K=ye=>ye*Math.PI/180;let de=0;for(let ye=1;yeAe&&(Ae=ne),ye>0){const fe=ne-ce[ye-1][2];fe>0?He+=fe:ze+=Math.abs(fe)}}const Ye=280,G=60,ve=le?ce.map(ye=>ye[2]):[];let Pe="";if(ve.length>1){const ye=Math.max(1,Math.floor(ve.length/Ye)),ne=ve.filter((Ke,dt)=>dt%ye===0),fe=Math.min(...ne),Oe=Math.max(...ne)-fe||1;Pe=ne.map((Ke,dt)=>{const Wt=dt/(ne.length-1)*Ye,Be=G-(Ke-fe)/Oe*(G-4)-2;return`${dt===0?"M":"L"}${Wt.toFixed(1)},${Be.toFixed(1)}`}).join(" ")}return r.jsxs("div",{style:{background:"var(--bg-hover)",borderRadius:10,padding:"10px 12px",display:"flex",flexDirection:"column",gap:8},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[r.jsx(kD,{size:13,color:"#9ca3af"}),r.jsx("span",{style:{fontSize:12,color:"var(--text-secondary)",fontWeight:500},children:w("inspector.trackStats")})]}),r.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:8},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4,fontSize:12,color:"var(--text-primary)",fontWeight:600},children:[r.jsx(tn,{size:12,color:"#3b82f6"}),_e<1?`${Math.round(de)} m`:`${_e.toFixed(1)} km`]}),le&&r.jsxs(r.Fragment,{children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4,fontSize:12,color:"var(--text-primary)",fontWeight:600},children:[r.jsx(Bf,{size:12,color:"#22c55e"}),Math.round(Ae)," m"]}),r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4,fontSize:12,color:"var(--text-primary)",fontWeight:600},children:[r.jsx(Bf,{size:12,color:"#ef4444"}),Math.round(pe)," m"]}),r.jsxs("div",{style:{fontSize:12,color:"var(--text-muted)"},children:["↑",Math.round(He)," m ↓",Math.round(ze)," m"]})]})]}),Pe&&r.jsxs("svg",{width:"100%",viewBox:`0 0 ${Ye} ${G}`,preserveAspectRatio:"none",style:{display:"block",borderRadius:6,background:"var(--bg-tertiary)"},children:[r.jsx("defs",{children:r.jsxs("linearGradient",{id:`ele-grad-${e.id}`,x1:"0",y1:"0",x2:"0",y2:"1",children:[r.jsx("stop",{offset:"0%",stopColor:"#3b82f6",stopOpacity:"0.25"}),r.jsx("stop",{offset:"100%",stopColor:"#3b82f6",stopOpacity:"0.02"})]})}),r.jsx("path",{d:`${Pe} L${Ye},${G} L0,${G} Z`,fill:`url(#ele-grad-${e.id})`}),r.jsx("path",{d:Pe,fill:"none",stroke:"#3b82f6",strokeWidth:"1.5",vectorEffect:"non-scaling-stroke"})]})]})}catch{return null}})(),(je.length>0||y)&&r.jsxs("div",{style:{background:"var(--bg-hover)",borderRadius:10,overflow:"hidden"},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"8px 12px",gap:6},children:[r.jsxs("button",{onClick:()=>I(ce=>!ce),style:{flex:1,display:"flex",alignItems:"center",gap:6,background:"none",border:"none",cursor:"pointer",padding:0,fontFamily:"inherit",textAlign:"left"},children:[r.jsx(Pa,{size:13,color:"#9ca3af"}),r.jsx("span",{style:{fontSize:12,color:"var(--text-secondary)",fontWeight:500},children:je.length>0?w("inspector.filesCount",{count:je.length}):w("inspector.files")}),$?r.jsx(oi,{size:12,color:"#9ca3af"}):r.jsx(en,{size:12,color:"#9ca3af"})]}),y&&r.jsxs("label",{style:{cursor:"pointer",display:"flex",alignItems:"center",gap:4,fontSize:11,color:"var(--text-muted)",padding:"2px 6px",borderRadius:6,background:"var(--bg-tertiary)"},children:[r.jsx("input",{ref:D,type:"file",multiple:!0,style:{display:"none"},onChange:we}),Y?r.jsx("span",{style:{fontSize:11},children:"…"}):r.jsxs(r.Fragment,{children:[r.jsx(So,{size:11,strokeWidth:2})," ",w("common.upload")]})]})]}),$&&je.length>0&&r.jsx("div",{style:{padding:"0 12px 10px",display:"flex",flexDirection:"column",gap:4},children:je.map(ce=>r.jsxs("a",{href:`/uploads/files/${ce.filename}`,target:"_blank",rel:"noopener noreferrer",style:{display:"flex",alignItems:"center",gap:8,textDecoration:"none",cursor:"pointer"},children:[(ce.mime_type||"").startsWith("image/")?r.jsx(y_,{size:12,color:"#6b7280"}):r.jsx(Ff,{size:12,color:"#6b7280"}),r.jsx("span",{style:{fontSize:12,color:"var(--text-secondary)",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:ce.original_name}),ce.file_size&&r.jsx("span",{style:{fontSize:11,color:"var(--text-faint)",flexShrink:0},children:f4(ce.file_size)})]},ce.id))})]})]})]}),r.jsxs("div",{style:{padding:"10px 16px",borderTop:"1px solid var(--border-faint)",display:"flex",gap:6,alignItems:"center",flexWrap:"wrap"},children:[n&&(q?r.jsx(Fo,{onClick:()=>g(n,q.id),variant:"ghost",icon:r.jsx(w_,{size:13}),label:r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"hidden sm:inline",children:w("inspector.removeFromDay")}),r.jsx("span",{className:"sm:hidden",children:"Remove"})]})}):r.jsx(Fo,{onClick:()=>m(e.id),variant:"primary",icon:r.jsx(Ft,{size:13}),label:w("inspector.addToDay")})),(J==null?void 0:J.google_maps_url)&&r.jsx(Fo,{onClick:()=>window.open(J.google_maps_url,"_blank"),variant:"ghost",icon:r.jsx(ps,{size:13}),label:r.jsx("span",{className:"hidden sm:inline",children:w("inspector.google")})}),!(J!=null&&J.google_maps_url)&&e.lat&&e.lng&&r.jsx(Fo,{onClick:()=>window.open(`https://www.google.com/maps/search/?api=1&query=${e.lat},${e.lng}`,"_blank"),variant:"ghost",icon:r.jsx(ps,{size:13}),label:r.jsx("span",{className:"hidden sm:inline",children:"Google Maps"})}),(e.website||(J==null?void 0:J.website))&&r.jsx(Fo,{onClick:()=>window.open(e.website||(J==null?void 0:J.website),"_blank"),variant:"ghost",icon:r.jsx(xn,{size:13}),label:r.jsx("span",{className:"hidden sm:inline",children:w("inspector.website")})}),r.jsx("div",{style:{flex:1}}),r.jsx(Fo,{onClick:c,variant:"ghost",icon:r.jsx(Ci,{size:13}),label:r.jsx("span",{className:"hidden sm:inline",children:w("common.edit")})}),r.jsx(Fo,{onClick:p,variant:"danger",icon:r.jsx(_t,{size:13}),label:r.jsx("span",{className:"hidden sm:inline",children:w("common.delete")})})]})]})})}function H0({icon:e,text:t,color:a="var(--text-secondary)",bg:n="var(--bg-hover)"}){return r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4,padding:"3px 9px",borderRadius:99,background:n,color:a,fontSize:12,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",minWidth:0},children:[r.jsx("span",{style:{flexShrink:0,display:"flex"},children:e}),r.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t})]})}function Fo({onClick:e,variant:t,icon:a,label:n}){const i={primary:{background:"var(--accent)",color:"var(--accent-text)",border:"none",hoverBg:"var(--text-secondary)"},ghost:{background:"var(--bg-hover)",color:"var(--text-secondary)",border:"none",hoverBg:"var(--bg-tertiary)"},danger:{background:"rgba(239,68,68,0.08)",color:"#dc2626",border:"none",hoverBg:"rgba(239,68,68,0.16)"}},o=i[t]||i.ghost;return r.jsxs("button",{onClick:e,style:{display:"flex",alignItems:"center",gap:5,padding:"6px 12px",borderRadius:10,minHeight:30,fontSize:12,fontWeight:500,cursor:"pointer",fontFamily:"inherit",transition:"background 0.15s, opacity 0.15s",background:o.background,color:o.color,border:o.border},onMouseEnter:s=>s.currentTarget.style.background=o.hoverBg,onMouseLeave:s=>s.currentTarget.style.background=o.background,children:[a,n]})}function v4({tripMembers:e,participantIds:t,allJoined:a,onSetParticipants:n,selectedAssignmentId:i,selectedDayId:o,t:s}){const[d,c]=Ka.useState(!1),[p,m]=Ka.useState(null),g=a?e:e.filter(k=>t.includes(k.id)),f=a?[]:e.filter(k=>!t.includes(k.id)),y=k=>{if(!n)return;let S;a?S=e.filter(v=>v.id!==k).map(v=>v.id):S=t.filter(v=>v!==k),S.length===e.length&&(S=[]),n(i,o,S)},x=k=>{if(!n)return;const S=[...t,k];S.length===e.length?n(i,o,[]):n(i,o,S),c(!1)};return r.jsxs("div",{style:{borderRadius:12,border:"1px solid var(--border-faint)",padding:"8px 10px"},children:[r.jsxs("div",{style:{fontSize:9,fontWeight:600,color:"var(--text-faint)",textTransform:"uppercase",letterSpacing:"0.03em",marginBottom:6,display:"flex",alignItems:"center",gap:4},children:[r.jsx(Ur,{size:10})," ",s("inspector.participants")]}),r.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:4,alignItems:"center"},children:[g.map(k=>{var _,w;const S=p===k.id,v=g.length>1;return r.jsxs("div",{onMouseEnter:()=>m(k.id),onMouseLeave:()=>m(null),onClick:()=>{v&&y(k.id)},style:{display:"flex",alignItems:"center",gap:4,padding:"2px 7px 2px 3px",borderRadius:99,border:`1.5px solid ${S&&v?"rgba(239,68,68,0.4)":"var(--accent)"}`,background:S&&v?"rgba(239,68,68,0.06)":"var(--bg-hover)",fontSize:10,fontWeight:500,color:S&&v?"#ef4444":"var(--text-primary)",cursor:v?"pointer":"default",transition:"all 0.15s"},children:[r.jsx("div",{style:{width:16,height:16,borderRadius:"50%",background:"var(--bg-tertiary)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:7,fontWeight:700,color:"var(--text-muted)",overflow:"hidden",flexShrink:0},children:k.avatar_url||k.avatar?r.jsx("img",{src:k.avatar_url||`/uploads/avatars/${k.avatar}`,style:{width:"100%",height:"100%",objectFit:"cover"}}):(w=(_=k.username)==null?void 0:_[0])==null?void 0:w.toUpperCase()}),r.jsx("span",{style:{textDecoration:S&&v?"line-through":"none"},children:k.username})]},k.id)}),f.length>0&&r.jsxs("div",{style:{position:"relative"},children:[r.jsx("button",{onClick:()=>c(!d),style:{width:22,height:22,borderRadius:"50%",border:"1.5px dashed var(--border-primary)",background:"none",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",color:"var(--text-faint)",fontSize:12,transition:"all 0.12s"},onMouseEnter:k=>{k.currentTarget.style.borderColor="var(--text-muted)",k.currentTarget.style.color="var(--text-primary)"},onMouseLeave:k=>{k.currentTarget.style.borderColor="var(--border-primary)",k.currentTarget.style.color="var(--text-faint)"},children:"+"}),d&&r.jsx("div",{style:{position:"absolute",top:26,left:0,zIndex:100,background:"var(--bg-card)",border:"1px solid var(--border-primary)",borderRadius:10,boxShadow:"0 4px 16px rgba(0,0,0,0.12)",padding:4,minWidth:140},children:f.map(k=>{var S,v;return r.jsxs("button",{onClick:()=>x(k.id),style:{display:"flex",alignItems:"center",gap:6,width:"100%",padding:"5px 8px",borderRadius:6,border:"none",background:"none",cursor:"pointer",fontFamily:"inherit",fontSize:11,color:"var(--text-primary)",textAlign:"left",transition:"background 0.1s"},onMouseEnter:_=>_.currentTarget.style.background="var(--bg-hover)",onMouseLeave:_=>_.currentTarget.style.background="none",children:[r.jsx("div",{style:{width:18,height:18,borderRadius:"50%",background:"var(--bg-tertiary)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:8,fontWeight:700,color:"var(--text-muted)",overflow:"hidden",flexShrink:0},children:k.avatar_url||k.avatar?r.jsx("img",{src:k.avatar_url||`/uploads/avatars/${k.avatar}`,style:{width:"100%",height:"100%",objectFit:"cover"}}):(v=(S=k.username)==null?void 0:S[0])==null?void 0:v.toUpperCase()}),k.username]},k.id)})})]})]})]})}const b4={flight:Or,hotel:Rr,restaurant:Cc,train:Ui,car:Bi,cruise:Hi,event:kn,tour:Ur,other:Pa},x4={flight:"#3b82f6",hotel:"#8b5cf6",restaurant:"#ef4444",train:"#06b6d4",car:"#6b7280",cruise:"#0ea5e9",event:"#f59e0b",tour:"#10b981",other:"#6b7280"},k4={Clear:Rl,Clouds:Nm,Rain:Iv,Drizzle:g_,Thunderstorm:h_,Snow:f_,Mist:is,Fog:is,Haze:is};function U0({main:e,size:t=14}){const a=k4[e]||Nm;return r.jsx(a,{size:t,strokeWidth:1.8})}function gu(e,t){return Math.round(t?e*9/5+32:e)}function w4(e,t){if(!e)return e;const[a,n]=e.split(":").map(Number);if(isNaN(a)||isNaN(n)||!t)return e;const i=a>=12?"PM":"AM";return`${a===0?12:a>12?a-12:a}:${String(n).padStart(2,"0")} ${i}`}function S4({day:e,days:t,places:a,categories:n=[],tripId:i,assignments:o,reservations:s=[],lat:d,lng:c,onClose:p,onAccommodationChange:m,leftWidth:g=0,rightWidth:f=0}){var be,Se,je,we,ce;const{t:y,language:x,locale:k}=ot(),S=ta(le=>le.settings.temperature_unit)==="fahrenheit",v=ta(le=>le.settings.time_format)==="12h",_=ta(le=>le.settings.blur_booking_codes),w=le=>w4(le,v),E=S?"°F":"°C",[M,A]=b.useState(null),[P,R]=b.useState(!1),[$,I]=b.useState(null),[Y,H]=b.useState([]),[V,X]=b.useState([]),[Z,O]=b.useState(!1),[Q,D]=b.useState({start:e==null?void 0:e.id,end:e==null?void 0:e.id}),[J,z]=b.useState(""),[W,B]=b.useState({check_in:"",check_out:"",confirmation:"",place_id:null});b.useEffect(()=>{if(!(e!=null&&e.date)||!d||!c){A(null);return}R(!0),Np.getDetailed(d,c,e.date,x).then(le=>A(le.error?null:le)).catch(()=>A(null)).finally(()=>R(!1))},[e==null?void 0:e.date,d,c,x]),b.useEffect(()=>{i&&ni.list(i).then(le=>{X(le.accommodations||[]);const K=(le.accommodations||[]).filter(de=>t.some(_e=>_e.id>=de.start_day_id&&_e.id<=de.end_day_id&&_e.id===(e==null?void 0:e.id)));H(K),I(K[0]||null)}).catch(()=>{})},[i,e==null?void 0:e.id]),b.useEffect(()=>{e&&D({start:e.id,end:e.id})},[e==null?void 0:e.id]);const C=le=>{B(K=>({...K,place_id:le}))},U=async()=>{if(W.place_id)try{const K=(await ni.create(i,{place_id:W.place_id,start_day_id:Q.start,end_day_id:Q.end,check_in:W.check_in||null,check_out:W.check_out||null,confirmation:W.confirmation||null})).accommodation,de=[...V,K];X(de),I(K),H(de.filter(_e=>t.some(pe=>pe.id>=_e.start_day_id&&pe.id<=_e.end_day_id&&pe.id===(e==null?void 0:e.id)))),O(!1),B({check_in:"",check_out:"",confirmation:"",place_id:null}),m==null||m()}catch{}},q=async()=>{if($)try{await ni.delete(i,$.id);const le=V.filter(K=>K.id!==$.id);X(le),H(le.filter(K=>t.some(de=>de.id>=K.start_day_id&&de.id<=K.end_day_id&&de.id===(e==null?void 0:e.id)))),I(null),m==null||m()}catch{}};if(!e)return null;const te=e.date?new Date(e.date+"T00:00:00").toLocaleDateString(Pm(x),{weekday:"long",day:"numeric",month:"long"}):null;a.filter(le=>le.lat&&le.lng);const oe={fontFamily:"-apple-system, BlinkMacSystemFont, 'SF Pro Text', system-ui, sans-serif"};return r.jsxs("div",{style:{position:"fixed",bottom:20,left:`calc(${g}px + (100vw - ${g}px - ${f}px) / 2)`,transform:"translateX(-50%)",width:`min(800px, calc(100vw - ${g}px - ${f}px - 32px))`,zIndex:50,...oe},children:[r.jsxs("div",{style:{background:"var(--bg-elevated)",backdropFilter:"blur(40px) saturate(180%)",WebkitBackdropFilter:"blur(40px) saturate(180%)",borderRadius:20,boxShadow:"0 8px 40px rgba(0,0,0,0.14), 0 0 0 1px rgba(0,0,0,0.06)",overflow:"hidden",maxHeight:"60vh",display:"flex",flexDirection:"column"},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:14,padding:"18px 16px 14px 20px",borderBottom:"1px solid var(--border-faint)"},children:[r.jsx("div",{style:{width:44,height:44,borderRadius:12,background:"var(--bg-secondary)",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:r.jsx(Ni,{size:20,style:{color:"var(--text-primary)"}})}),r.jsxs("div",{style:{flex:1,minWidth:0},children:[r.jsx("div",{style:{fontSize:15,fontWeight:700,color:"var(--text-primary)"},children:e.title||y("planner.dayN",{n:t.indexOf(e)+1||"?"})}),te&&r.jsx("div",{style:{fontSize:12,color:"var(--text-muted)",marginTop:1},children:te})]}),r.jsx("button",{onClick:p,style:{background:"var(--bg-secondary)",border:"none",borderRadius:10,width:32,height:32,display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",flexShrink:0},children:r.jsx(gt,{size:14,style:{color:"var(--text-muted)"}})})]}),r.jsxs("div",{style:{overflowY:"auto",padding:"14px 20px 18px"},children:[e.date&&d&&c&&(P?r.jsx("div",{style:{textAlign:"center",padding:16,color:"var(--text-faint)",fontSize:12},children:r.jsx("div",{style:{width:18,height:18,border:"2px solid var(--border-primary)",borderTopColor:"var(--text-primary)",borderRadius:"50%",animation:"spin 0.8s linear infinite",margin:"0 auto 6px"}})}):M?r.jsxs("div",{children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,marginBottom:10},children:[r.jsx("div",{style:{width:40,height:40,borderRadius:12,background:"var(--bg-secondary)",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:r.jsx(U0,{main:M.main,size:20})}),r.jsxs("div",{style:{flex:1,display:"flex",alignItems:"baseline",gap:6,flexWrap:"wrap"},children:[r.jsxs("span",{style:{fontSize:20,fontWeight:700,color:"var(--text-primary)",lineHeight:1},children:[M.type==="climate"?"Ø ":"",gu(M.temp,S),E]}),M.temp_max!=null&&r.jsxs("span",{style:{fontSize:12,color:"var(--text-faint)"},children:[gu(M.temp_min,S),"° / ",gu(M.temp_max,S),"°"]}),M.description&&r.jsx("span",{style:{fontSize:12,color:"var(--text-muted)",textTransform:"capitalize"},children:M.description})]})]}),r.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:6,marginBottom:M.hourly?10:0},children:[M.precipitation_probability_max!=null&&r.jsx(id,{icon:MM,value:`${M.precipitation_probability_max}%`}),M.precipitation_sum>0&&r.jsx(id,{icon:Iv,value:`${M.precipitation_sum.toFixed(1)} mm`}),M.wind_max!=null&&r.jsx(id,{icon:is,value:S?`${Math.round(M.wind_max*.621371)} mph`:`${Math.round(M.wind_max)} km/h`}),M.sunrise&&r.jsx(id,{icon:hD,value:M.sunrise}),M.sunset&&r.jsx(id,{icon:fD,value:M.sunset})]}),((be=M.hourly)==null?void 0:be.length)>0&&r.jsx("div",{style:{overflowX:"auto",margin:"0 -6px",padding:"0 6px 4px"},children:r.jsx("div",{style:{display:"inline-flex",gap:2},children:M.hourly.filter((le,K)=>K%2===0).map(le=>r.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:3,width:44,padding:"5px 2px",borderRadius:8,background:le.precipitation_probability>50?"rgba(59,130,246,0.07)":"transparent"},children:[r.jsx("span",{style:{fontSize:9,color:"var(--text-faint)",fontWeight:500},children:String(le.hour).padStart(2,"0")}),r.jsx(U0,{main:le.main,size:12}),r.jsxs("span",{style:{fontSize:10,fontWeight:600,color:"var(--text-primary)"},children:[gu(le.temp,S),"°"]}),le.precipitation_probability>0&&r.jsxs("span",{style:{fontSize:8,color:"#3b82f6",fontWeight:500},children:[le.precipitation_probability,"%"]})]},le.hour))})}),M.type==="climate"&&r.jsx("div",{style:{fontSize:10,color:"var(--text-faint)",marginTop:6,fontStyle:"italic"},children:y("day.climateHint")})]}):r.jsx("div",{style:{fontSize:12,color:"var(--text-faint)",textAlign:"center",padding:8},children:y("day.noWeather")})),(()=>{const le=o[String(e.id)]||[],K=s.filter(de=>le.some(_e=>_e.id===de.assignment_id));return K.length===0?null:r.jsxs("div",{style:{marginBottom:0},children:[e.date&&d&&c&&r.jsx("div",{style:{height:1,background:"var(--border-faint)",margin:"12px 0"}}),r.jsx("div",{style:{fontSize:11,fontWeight:600,color:"var(--text-faint)",textTransform:"uppercase",letterSpacing:"0.05em",marginBottom:6},children:y("day.reservations")}),r.jsx("div",{style:{display:"flex",flexDirection:"column",gap:4},children:K.map(de=>{var Ae;const _e=le.find(He=>He.id===de.assignment_id),pe=de.status==="confirmed";return r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"5px 10px",borderRadius:8,background:pe?"rgba(22,163,74,0.06)":"rgba(217,119,6,0.06)",border:`1px solid ${pe?"rgba(22,163,74,0.15)":"rgba(217,119,6,0.15)"}`},children:[(()=>{const He=b4[de.type]||Pa;return r.jsx(He,{size:12,style:{color:x4[de.type]||"var(--text-faint)",flexShrink:0}})})(),r.jsxs("div",{style:{flex:1,minWidth:0,display:"flex",alignItems:"center",gap:6,overflow:"hidden"},children:[r.jsx("span",{style:{fontSize:11,fontWeight:600,color:"var(--text-primary)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:de.title}),(_e==null?void 0:_e.place)&&r.jsxs("span",{style:{fontSize:9,color:"var(--text-faint)",whiteSpace:"nowrap"},children:["· ",_e.place.name]})]}),((Ae=de.reservation_time)==null?void 0:Ae.includes("T"))&&r.jsxs("span",{style:{fontSize:10,color:"var(--text-muted)",whiteSpace:"nowrap",flexShrink:0},children:[new Date(de.reservation_time).toLocaleTimeString(k,{hour:"2-digit",minute:"2-digit",hour12:v}),de.reservation_end_time&&` – ${w(de.reservation_end_time)}`]})]},de.id)})})]})})(),r.jsx("div",{style:{height:1,background:"var(--border-faint)",margin:"12px 0"}}),r.jsxs("div",{children:[r.jsx("div",{style:{fontSize:11,fontWeight:600,color:"var(--text-faint)",textTransform:"uppercase",letterSpacing:"0.05em",marginBottom:8},children:y("day.accommodation")}),Y.length>0?r.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[Y.map(le=>{const K=le.start_day_id===e.id,de=le.end_day_id===e.id,_e=K&&de?y("day.checkIn")+" & "+y("day.checkOut"):K?y("day.checkIn"):de?y("day.checkOut"):null,pe=s.find(He=>He.accommodation_id===le.id),Ae=(pe==null?void 0:pe.status)==="confirmed";return r.jsxs("div",{style:{borderRadius:12,background:"var(--bg-secondary)",overflow:"hidden"},children:[_e&&r.jsxs("div",{style:{padding:"4px 12px 0",display:"flex",alignItems:"center",gap:4},children:[K&&r.jsx(h0,{size:9,style:{color:"#22c55e"}}),de&&!K&&r.jsx(Ip,{size:9,style:{color:"#ef4444"}}),r.jsx("span",{style:{fontSize:9,fontWeight:700,textTransform:"uppercase",letterSpacing:"0.05em",color:de&&!K?"#ef4444":"#22c55e"},children:_e})]}),r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"8px 12px"},children:[r.jsx("div",{style:{width:36,height:36,borderRadius:10,background:"var(--bg-tertiary)",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:le.place_image?r.jsx("img",{src:le.place_image,style:{width:"100%",height:"100%",borderRadius:10,objectFit:"cover"}}):r.jsx(Rr,{size:16,style:{color:"var(--text-muted)"}})}),r.jsxs("div",{style:{flex:1,minWidth:0},children:[r.jsx("div",{style:{fontSize:13,fontWeight:600,color:"var(--text-primary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:le.place_name}),le.place_address&&r.jsx("div",{style:{fontSize:10,color:"var(--text-faint)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:le.place_address})]}),r.jsx("button",{onClick:()=>{I(le),B({check_in:le.check_in||"",check_out:le.check_out||"",confirmation:le.confirmation||"",place_id:le.place_id}),D({start:le.start_day_id,end:le.end_day_id}),O("edit")},style:{background:"none",border:"none",cursor:"pointer",padding:3,flexShrink:0},children:r.jsx(sn,{size:12,style:{color:"var(--text-faint)"}})}),r.jsx("button",{onClick:()=>{I(le),q()},style:{background:"none",border:"none",cursor:"pointer",padding:3,flexShrink:0},children:r.jsx(gt,{size:12,style:{color:"var(--text-faint)"}})})]}),r.jsxs("div",{style:{display:"flex",gap:0,margin:"0 12px 8px",borderRadius:10,overflow:"hidden",border:"1px solid var(--border-faint)"},children:[le.check_in&&r.jsxs("div",{style:{flex:1,padding:"8px 10px",borderRight:"1px solid var(--border-faint)",textAlign:"center"},children:[r.jsx("div",{style:{fontSize:12,fontWeight:700,color:"var(--text-primary)",lineHeight:1.2},children:w(le.check_in)}),r.jsxs("div",{style:{fontSize:9,color:"var(--text-faint)",fontWeight:500,marginTop:2,display:"flex",alignItems:"center",justifyContent:"center",gap:3},children:[r.jsx(h0,{size:8})," ",y("day.checkIn")]})]}),le.check_out&&r.jsxs("div",{style:{flex:1,padding:"8px 10px",borderRight:le.confirmation?"1px solid var(--border-faint)":"none",textAlign:"center"},children:[r.jsx("div",{style:{fontSize:12,fontWeight:700,color:"var(--text-primary)",lineHeight:1.2},children:w(le.check_out)}),r.jsxs("div",{style:{fontSize:9,color:"var(--text-faint)",fontWeight:500,marginTop:2,display:"flex",alignItems:"center",justifyContent:"center",gap:3},children:[r.jsx(Ip,{size:8})," ",y("day.checkOut")]})]}),le.confirmation&&r.jsxs("div",{style:{flex:1,padding:"8px 10px",textAlign:"center"},children:[r.jsx("div",{style:{fontSize:12,fontWeight:700,color:"var(--text-primary)",lineHeight:1.2},children:le.confirmation}),r.jsxs("div",{style:{fontSize:9,color:"var(--text-faint)",fontWeight:500,marginTop:2,display:"flex",alignItems:"center",justifyContent:"center",gap:3},children:[r.jsx(BM,{size:8})," ",y("day.confirmation")]})]})]}),pe&&r.jsxs("div",{style:{margin:"0 12px 8px",padding:"6px 10px",borderRadius:8,background:Ae?"rgba(22,163,74,0.06)":"rgba(217,119,6,0.06)",border:`1px solid ${Ae?"rgba(22,163,74,0.15)":"rgba(217,119,6,0.15)"}`,display:"flex",alignItems:"center",gap:8},children:[r.jsx("div",{style:{width:6,height:6,borderRadius:"50%",background:Ae?"#16a34a":"#d97706",flexShrink:0}}),r.jsxs("div",{style:{flex:1,minWidth:0},children:[r.jsx("div",{style:{fontSize:11,fontWeight:600,color:"var(--text-primary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:pe.title}),r.jsxs("div",{style:{fontSize:9,color:"var(--text-faint)",display:"flex",gap:6,marginTop:1},children:[r.jsx("span",{children:y(Ae?"reservations.confirmed":"reservations.pending")}),pe.confirmation_number&&r.jsxs("span",{onMouseEnter:He=>{_&&(He.currentTarget.style.filter="none")},onMouseLeave:He=>{_&&(He.currentTarget.style.filter="blur(4px)")},onClick:He=>{if(_){const ze=He.currentTarget;ze.style.filter=ze.style.filter==="none"?"blur(4px)":"none"}},style:{filter:_?"blur(4px)":"none",transition:"filter 0.2s",cursor:_?"pointer":"default"},children:["#",pe.confirmation_number]})]})]})]})]},le.id)}),r.jsxs("button",{onClick:()=>O(!0),style:{width:"100%",padding:8,border:"1.5px dashed var(--border-primary)",borderRadius:10,background:"none",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",gap:5,fontSize:10,color:"var(--text-faint)",fontFamily:"inherit"},children:[r.jsx(Rr,{size:10})," ",y("day.addAccommodation")]})]}):r.jsxs("button",{onClick:()=>O(!0),style:{width:"100%",padding:10,border:"1.5px dashed var(--border-primary)",borderRadius:10,background:"none",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",gap:5,fontSize:11,color:"var(--text-faint)",fontFamily:"inherit"},children:[r.jsx(Rr,{size:12})," ",y("day.addAccommodation")]}),Z&&Vt.createPortal(r.jsx("div",{style:{position:"fixed",inset:0,zIndex:99999,background:"rgba(0,0,0,0.4)",backdropFilter:"blur(4px)",display:"flex",alignItems:"center",justifyContent:"center",padding:16},onClick:()=>O(!1),children:r.jsxs("div",{onClick:le=>le.stopPropagation(),style:{width:"100%",maxWidth:900,borderRadius:16,overflow:"hidden",background:"var(--bg-card)",boxShadow:"0 20px 60px rgba(0,0,0,0.2)",...oe},children:[r.jsxs("div",{style:{padding:"16px 18px 12px",borderBottom:"1px solid var(--border-faint)",display:"flex",alignItems:"center",gap:10},children:[r.jsx(Rr,{size:16,style:{color:"var(--text-primary)"}}),r.jsx("span",{style:{fontSize:14,fontWeight:700,color:"var(--text-primary)",flex:1},children:y(Z==="edit"?"day.editAccommodation":"day.addAccommodation")}),r.jsx("button",{onClick:()=>O(!1),style:{background:"var(--bg-secondary)",border:"none",borderRadius:8,width:28,height:28,display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer"},children:r.jsx(gt,{size:12,style:{color:"var(--text-muted)"}})})]}),r.jsxs("div",{style:{padding:"12px 18px",borderBottom:"1px solid var(--border-faint)",background:"var(--bg-secondary)"},children:[r.jsx("div",{style:{fontSize:11,fontWeight:600,color:"var(--text-faint)",marginBottom:8,textTransform:"uppercase",letterSpacing:"0.04em"},children:y("day.hotelDayRange")}),r.jsxs("div",{style:{display:"flex",gap:8,alignItems:"center"},children:[r.jsx("div",{style:{flex:1,minWidth:0},children:r.jsx(ea,{value:Q.start,onChange:le=>D(K=>({start:le,end:Math.max(le,K.end)})),options:t.map((le,K)=>({value:le.id,label:`${le.title||y("planner.dayN",{n:K+1})}${le.date?` — ${new Date(le.date+"T00:00:00").toLocaleDateString(k,{day:"numeric",month:"short"})}`:""}`})),size:"sm"})}),r.jsx("span",{style:{fontSize:11,color:"var(--text-faint)",flexShrink:0},children:"→"}),r.jsx("div",{style:{flex:1,minWidth:0},children:r.jsx(ea,{value:Q.end,onChange:le=>D(K=>({start:Math.min(K.start,le),end:le})),options:t.map((le,K)=>({value:le.id,label:`${le.title||y("planner.dayN",{n:K+1})}${le.date?` — ${new Date(le.date+"T00:00:00").toLocaleDateString(k,{day:"numeric",month:"short"})}`:""}`})),size:"sm"})}),r.jsx("button",{onClick:()=>{var le,K;return D({start:(le=t[0])==null?void 0:le.id,end:(K=t[t.length-1])==null?void 0:K.id})},style:{padding:"6px 14px",borderRadius:8,border:"none",fontSize:11,fontWeight:600,cursor:"pointer",flexShrink:0,background:Q.start===((Se=t[0])==null?void 0:Se.id)&&Q.end===((je=t[t.length-1])==null?void 0:je.id)?"var(--text-primary)":"var(--bg-card)",color:Q.start===((we=t[0])==null?void 0:we.id)&&Q.end===((ce=t[t.length-1])==null?void 0:ce.id)?"var(--bg-card)":"var(--text-muted)"},children:y("day.allDays")})]})]}),r.jsxs("div",{style:{padding:"10px 18px",borderBottom:"1px solid var(--border-faint)",display:"flex",gap:8,flexWrap:"wrap"},children:[r.jsxs("div",{style:{flex:1,minWidth:100},children:[r.jsx("label",{style:{fontSize:9,fontWeight:600,color:"var(--text-faint)",textTransform:"uppercase",letterSpacing:"0.04em",display:"block",marginBottom:3},children:y("day.checkIn")}),r.jsx(oo,{value:W.check_in,onChange:le=>B(K=>({...K,check_in:le})),placeholder:"14:00"})]}),r.jsxs("div",{style:{flex:1,minWidth:100},children:[r.jsx("label",{style:{fontSize:9,fontWeight:600,color:"var(--text-faint)",textTransform:"uppercase",letterSpacing:"0.04em",display:"block",marginBottom:3},children:y("day.checkOut")}),r.jsx(oo,{value:W.check_out,onChange:le=>B(K=>({...K,check_out:le})),placeholder:"11:00"})]}),r.jsxs("div",{style:{flex:2,minWidth:120},children:[r.jsx("label",{style:{fontSize:9,fontWeight:600,color:"var(--text-faint)",textTransform:"uppercase",letterSpacing:"0.04em",display:"block",marginBottom:3},children:y("day.confirmation")}),r.jsx("input",{type:"text",value:W.confirmation,onChange:le=>B(K=>({...K,confirmation:le.target.value})),placeholder:"ABC-12345",style:{width:"100%",padding:"8px 10px",borderRadius:10,border:"1px solid var(--border-primary)",background:"var(--bg-card)",color:"var(--text-primary)",fontSize:13,fontFamily:"inherit",boxSizing:"border-box",height:38}})]})]}),n.length>0&&r.jsxs("div",{style:{padding:"8px 18px",borderBottom:"1px solid var(--border-faint)",display:"flex",gap:4,flexWrap:"wrap"},children:[r.jsx("button",{onClick:()=>z(""),style:{padding:"3px 10px",borderRadius:6,border:"none",fontSize:10,fontWeight:600,cursor:"pointer",background:J?"var(--bg-secondary)":"var(--text-primary)",color:J?"var(--text-muted)":"var(--bg-card)"},children:y("day.allDays")}),n.map(le=>r.jsx("button",{onClick:()=>z(le.id),style:{padding:"3px 10px",borderRadius:6,border:"none",fontSize:10,fontWeight:600,cursor:"pointer",background:J===le.id?le.color||"var(--text-primary)":"var(--bg-secondary)",color:J===le.id?"#fff":"var(--text-muted)"},children:le.name},le.id))]}),r.jsx("div",{style:{maxHeight:250,overflowY:"auto"},children:(()=>{const le=J?a.filter(K=>K.category_id===J):a;return le.length===0?r.jsx("div",{style:{padding:20,textAlign:"center",fontSize:12,color:"var(--text-faint)"},children:y("day.noPlacesForHotel")}):le.map(K=>r.jsxs("button",{onClick:()=>C(K.id),style:{display:"flex",alignItems:"center",gap:10,width:"100%",padding:"10px 18px",border:"none",borderBottom:"1px solid var(--border-faint)",background:W.place_id===K.id?"var(--bg-hover)":"none",cursor:"pointer",fontFamily:"inherit",textAlign:"left",transition:"background 0.1s",outline:W.place_id===K.id?"2px solid var(--accent)":"none",outlineOffset:-2,borderRadius:W.place_id===K.id?8:0},onMouseEnter:de=>{W.place_id!==K.id&&(de.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:de=>{W.place_id!==K.id&&(de.currentTarget.style.background="none")},children:[r.jsx("div",{style:{width:32,height:32,borderRadius:8,background:"var(--bg-secondary)",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:K.image_url?r.jsx("img",{src:K.image_url,style:{width:"100%",height:"100%",borderRadius:8,objectFit:"cover"}}):r.jsx(tn,{size:13,style:{color:"var(--text-faint)"}})}),r.jsxs("div",{style:{flex:1,minWidth:0},children:[r.jsx("div",{style:{fontSize:12,fontWeight:600,color:"var(--text-primary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:K.name}),K.address&&r.jsx("div",{style:{fontSize:10,color:"var(--text-faint)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:K.address})]})]},K.id))})()}),r.jsxs("div",{style:{padding:"12px 18px",borderTop:"1px solid var(--border-faint)",display:"flex",justifyContent:"flex-end",gap:8},children:[r.jsx("button",{onClick:()=>O(!1),style:{padding:"7px 16px",borderRadius:8,border:"1px solid var(--border-primary)",background:"none",fontSize:12,cursor:"pointer",fontFamily:"inherit",color:"var(--text-muted)"},children:y("common.cancel")}),r.jsx("button",{onClick:async()=>{Z==="edit"&&$?(await ni.update(i,$.id,{place_id:W.place_id,start_day_id:Q.start,end_day_id:Q.end,check_in:W.check_in||null,check_out:W.check_out||null,confirmation:W.confirmation||null}),O(!1),B({check_in:"",check_out:"",confirmation:"",place_id:null}),ni.list(i).then(le=>{const K=le.accommodations||[];X(K),H(K.filter(_e=>t.some(pe=>pe.id>=_e.start_day_id&&pe.id<=_e.end_day_id&&pe.id===(e==null?void 0:e.id))));const de=K.find(_e=>t.some(pe=>pe.id>=_e.start_day_id&&pe.id<=_e.end_day_id&&pe.id===(e==null?void 0:e.id)));I(de||null)}),m==null||m()):await U()},disabled:!W.place_id,style:{padding:"7px 20px",borderRadius:8,border:"none",fontSize:12,fontWeight:600,cursor:"pointer",fontFamily:"inherit",background:W.place_id?"var(--text-primary)":"var(--bg-tertiary)",color:W.place_id?"var(--bg-card)":"var(--text-faint)"},children:y("common.save")})]})]})}),document.body)]})]})]}),r.jsx("style",{children:"@keyframes spin { to { transform: rotate(360deg) } }"})]})}function id({icon:e,value:t}){return r.jsxs("div",{style:{display:"inline-flex",alignItems:"center",gap:4,padding:"4px 8px",borderRadius:8,background:"var(--bg-secondary)",fontSize:11,color:"var(--text-muted)"},children:[r.jsx(e,{size:11,style:{flexShrink:0,opacity:.6}}),r.jsx("span",{style:{fontWeight:500},children:t})]})}const nh={name:"",description:"",address:"",lat:"",lng:"",category_id:"",place_time:"",end_time:"",notes:"",transport_mode:"walking",website:""};function j4({isOpen:e,onClose:t,onSave:a,place:n,prefillCoords:i,tripId:o,categories:s,onCategoryCreated:d,assignmentId:c,dayAssignments:p=[]}){const[m,g]=b.useState(nh),[f,y]=b.useState(""),[x,k]=b.useState([]),[S,v]=b.useState(!1),[_,w]=b.useState(""),[E,M]=b.useState(!1),[A,P]=b.useState(!1),[R,$]=b.useState([]),I=b.useRef(null),Y=ya(),{t:H,language:V}=ot(),{hasMapsKey:X}=cn();b.useEffect(()=>{g(n?{name:n.name||"",description:n.description||"",address:n.address||"",lat:n.lat||"",lng:n.lng||"",category_id:n.category_id||"",place_time:n.place_time||"",end_time:n.end_time||"",notes:n.notes||"",transport_mode:n.transport_mode||"walking",website:n.website||""}:i?{...nh,lat:String(i.lat),lng:String(i.lng),name:i.name||"",address:i.address||""}:nh),$([])},[n,i,e]);const Z=(U,q)=>{g(te=>({...te,[U]:q}))},O=async()=>{if(f.trim()){v(!0);try{const U=f.trim();if(U.match(/^https?:\/\/(www\.)?(google\.[a-z.]+\/maps|maps\.google\.[a-z.]+|maps\.app\.goo\.gl|goo\.gl)/i)){const te=await ko.resolveUrl(U);if(te.lat&&te.lng){g(oe=>({...oe,name:te.name||oe.name,address:te.address||oe.address,lat:String(te.lat),lng:String(te.lng)})),k([]),y(""),Y.success(H("places.urlResolved"));return}}const q=await ko.search(f,V);k(q.places||[])}catch{Y.error(H("places.mapsSearchError"))}finally{v(!1)}}},Q=U=>{g(q=>({...q,name:U.name||q.name,address:U.address||q.address,lat:U.lat||q.lat,lng:U.lng||q.lng,google_place_id:U.google_place_id||q.google_place_id,osm_id:U.osm_id||q.osm_id,website:U.website||q.website,phone:U.phone||q.phone})),k([]),y("")},D=async()=>{if(_.trim())try{const U=await(d==null?void 0:d({name:_,color:"#6366f1",icon:"MapPin"}));U&&g(q=>({...q,category_id:U.id})),w(""),M(!1)}catch{Y.error(H("places.categoryCreateError"))}},J=U=>{const q=Array.from(U.target.files||[]);$(te=>[...te,...q]),U.target.value=""},z=U=>{$(q=>q.filter((te,oe)=>oe!==U))},W=U=>{var te;const q=(te=U.clipboardData)==null?void 0:te.items;if(q){for(const oe of Array.from(q))if(oe.type.startsWith("image/")||oe.type==="application/pdf"){U.preventDefault();const be=oe.getAsFile();be&&$(Se=>[...Se,be]);return}}},B=n&&m.place_time&&m.end_time&&m.place_time.length>=5&&m.end_time.length>=5&&m.end_time<=m.place_time,C=async U=>{if(U.preventDefault(),!m.name.trim()){Y.error(H("places.nameRequired"));return}P(!0);try{await a({...m,lat:m.lat?parseFloat(m.lat):null,lng:m.lng?parseFloat(m.lng):null,category_id:m.category_id||null,_pendingFiles:R.length>0?R:void 0}),t()}catch(q){Y.error(q instanceof Error?q.message:H("places.saveError"))}finally{P(!1)}};return r.jsx(zi,{isOpen:e,onClose:t,title:H(n?"places.editPlace":"places.addPlace"),size:"lg",children:r.jsxs("form",{onSubmit:C,className:"space-y-4",onPaste:W,children:[r.jsxs("div",{className:"bg-slate-50 rounded-xl p-3 border border-slate-200",children:[!X&&r.jsx("p",{className:"mb-2 text-xs",style:{color:"var(--text-faint)"},children:H("places.osmActive")}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx("input",{type:"text",value:f,onChange:U=>y(U.target.value),onKeyDown:U=>U.key==="Enter"&&(U.preventDefault(),O()),placeholder:H("places.mapsSearchPlaceholder"),className:"flex-1 border border-slate-200 rounded-lg px-3 py-1.5 text-sm focus:outline-none focus:ring-2 focus:ring-slate-400 bg-white"}),r.jsx("button",{type:"button",onClick:O,disabled:S,className:"bg-slate-900 text-white px-3 py-1.5 rounded-lg text-sm hover:bg-slate-700 disabled:opacity-60",children:S?"...":r.jsx(Om,{className:"w-4 h-4"})})]}),x.length>0&&r.jsx("div",{className:"bg-white rounded-lg border border-slate-200 overflow-hidden max-h-40 overflow-y-auto mt-2",children:x.map((U,q)=>r.jsxs("button",{type:"button",onClick:()=>Q(U),className:"w-full text-left px-3 py-2 hover:bg-slate-50 border-b border-slate-100 last:border-0",children:[r.jsx("div",{className:"font-medium text-sm",children:U.name}),r.jsx("div",{className:"text-xs text-slate-500 truncate",children:U.address})]},q))})]}),r.jsxs("div",{children:[r.jsxs("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:[H("places.formName")," *"]}),r.jsx("input",{type:"text",value:m.name,onChange:U=>Z("name",U.target.value),required:!0,placeholder:H("places.formNamePlaceholder"),className:"form-input"})]}),r.jsxs("div",{children:[r.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:H("places.formDescription")}),r.jsx("textarea",{value:m.description,onChange:U=>Z("description",U.target.value),rows:2,placeholder:H("places.formDescriptionPlaceholder"),className:"form-input",style:{resize:"none"}})]}),r.jsxs("div",{children:[r.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:H("places.formAddress")}),r.jsx("input",{type:"text",value:m.address,onChange:U=>Z("address",U.target.value),placeholder:H("places.formAddressPlaceholder"),className:"form-input"}),r.jsxs("div",{className:"grid grid-cols-2 gap-2 mt-2",children:[r.jsx("input",{type:"number",step:"any",value:m.lat,onChange:U=>Z("lat",U.target.value),onPaste:U=>{const te=U.clipboardData.getData("text").trim().match(/^(-?\d+\.?\d*)\s*[,;\s]\s*(-?\d+\.?\d*)$/);te&&(U.preventDefault(),Z("lat",te[1]),Z("lng",te[2]))},placeholder:H("places.formLat"),className:"form-input"}),r.jsx("input",{type:"number",step:"any",value:m.lng,onChange:U=>Z("lng",U.target.value),placeholder:H("places.formLng"),className:"form-input"})]})]}),r.jsxs("div",{children:[r.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:H("places.formCategory")}),E?r.jsxs("div",{className:"flex gap-2",children:[r.jsx("input",{type:"text",value:_,onChange:U=>w(U.target.value),placeholder:H("places.categoryNamePlaceholder"),className:"form-input",style:{flex:1}}),r.jsx("button",{type:"button",onClick:D,className:"bg-slate-900 text-white px-3 rounded-lg hover:bg-slate-700 text-sm",children:"OK"}),r.jsx("button",{type:"button",onClick:()=>M(!1),className:"text-gray-500 px-2 text-sm",children:H("common.cancel")})]}):r.jsx("div",{className:"flex gap-2",children:r.jsx(ea,{value:m.category_id,onChange:U=>Z("category_id",U),placeholder:H("places.noCategory"),options:[{value:"",label:H("places.noCategory")},...(s||[]).map(U=>({value:U.id,label:U.name}))],style:{flex:1},size:"sm"})})]}),n&&r.jsx(_4,{form:m,handleChange:Z,assignmentId:c,dayAssignments:p,hasTimeError:B,t:H}),r.jsxs("div",{children:[r.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:H("places.formWebsite")}),r.jsx("input",{type:"url",value:m.website,onChange:U=>Z("website",U.target.value),placeholder:"https://...",className:"form-input"})]}),r.jsxs("div",{className:"border border-gray-200 rounded-xl p-3 space-y-2",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("label",{className:"block text-sm font-medium text-gray-700",children:H("files.title")}),r.jsxs("button",{type:"button",onClick:()=>{var U;return(U=I.current)==null?void 0:U.click()},className:"flex items-center gap-1 text-xs text-slate-500 hover:text-slate-700 transition-colors",children:[r.jsx(Hf,{size:12})," ",H("files.attach")]})]}),r.jsx("input",{ref:I,type:"file",multiple:!0,style:{display:"none"},onChange:J}),R.length>0&&r.jsx("div",{className:"space-y-1",children:R.map((U,q)=>r.jsxs("div",{className:"flex items-center gap-2 px-2 py-1.5 rounded-lg bg-slate-50 text-xs",children:[r.jsx(Hf,{size:10,className:"text-slate-400 shrink-0"}),r.jsx("span",{className:"truncate flex-1 text-slate-600",children:U.name}),r.jsx("button",{type:"button",onClick:()=>z(q),className:"text-slate-400 hover:text-red-500 shrink-0",children:r.jsx(gt,{size:12})})]},q))}),R.length===0&&r.jsx("p",{className:"text-xs text-slate-400",children:H("files.pasteHint")})]}),r.jsxs("div",{className:"flex justify-end gap-3 pt-2 border-t border-gray-100",children:[r.jsx("button",{type:"button",onClick:t,className:"px-4 py-2 text-sm text-gray-600 hover:text-gray-900 border border-gray-200 rounded-lg hover:bg-gray-50",children:H("common.cancel")}),r.jsx("button",{type:"submit",disabled:A||B,className:"px-6 py-2 bg-slate-900 text-white text-sm rounded-lg hover:bg-slate-700 disabled:opacity-60 font-medium",children:H(A?"common.saving":n?"common.update":"common.add")})]})]})})}function _4({form:e,handleChange:t,assignmentId:a,dayAssignments:n,hasTimeError:i,t:o}){const s=b.useMemo(()=>{if(!a||!e.place_time||e.place_time.length<5)return[];const d=n.find(m=>m.id===a);if(!d)return[];const c=e.place_time,p=e.end_time&&e.end_time.length>=5?e.end_time:null;return n.filter(m=>{var v,_;if(m.id===a||m.day_id!==d.day_id)return!1;const g=(v=m.place)==null?void 0:v.place_time,f=(_=m.place)==null?void 0:_.end_time;if(!g)return!1;const y=c,x=p||c,k=g,S=f||g;return y<(S||"23:59")&&k<(x||"23:59")&&y!==S&&k!==x})},[a,n,e.place_time,e.end_time]);return r.jsxs("div",{children:[r.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[r.jsxs("div",{children:[r.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:o("places.startTime")}),r.jsx(oo,{value:e.place_time,onChange:d=>t("place_time",d)})]}),r.jsxs("div",{children:[r.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:o("places.endTime")}),r.jsx(oo,{value:e.end_time,onChange:d=>t("end_time",d)})]})]}),i&&r.jsxs("div",{className:"flex items-center gap-1.5 mt-2 px-2.5 py-1.5 rounded-lg text-xs",style:{background:"var(--bg-warning, #fef3c7)",color:"var(--text-warning, #92400e)"},children:[r.jsx(li,{size:13,className:"shrink-0"}),o("places.endTimeBeforeStart")]}),s.length>0&&r.jsxs("div",{className:"flex items-start gap-1.5 mt-2 px-2.5 py-1.5 rounded-lg text-xs",style:{background:"var(--bg-warning, #fef3c7)",color:"var(--text-warning, #92400e)"},children:[r.jsx(li,{size:13,className:"shrink-0 mt-0.5"}),r.jsxs("span",{children:[o("places.timeCollision")," ",s.map(d=>{var c;return(c=d.place)==null?void 0:c.name}).filter(Boolean).join(", ")]})]})]})}function C4({username:e,avatarUrl:t,size:a=32}){if(t)return r.jsx("img",{src:t,alt:"",style:{width:a,height:a,borderRadius:"50%",objectFit:"cover",flexShrink:0}});const n=(e||"?")[0].toUpperCase(),i=["#3b82f6","#8b5cf6","#ec4899","#10b981","#f59e0b","#ef4444","#06b6d4"],o=i[n.charCodeAt(0)%i.length];return r.jsx("div",{style:{width:a,height:a,borderRadius:"50%",background:o,display:"flex",alignItems:"center",justifyContent:"center",fontSize:a*.4,fontWeight:700,color:"white",flexShrink:0},children:n})}function z4({tripId:e,t}){const[a,n]=b.useState(null),[i,o]=b.useState(!0),[s,d]=b.useState(!1),[c,p]=b.useState({share_map:!0,share_bookings:!0,share_packing:!1,share_budget:!1,share_collab:!1}),m=ya();b.useEffect(()=>{Zs.getLink(e).then(S=>{n(S.token),S.token&&p({share_map:S.share_map??!0,share_bookings:S.share_bookings??!0,share_packing:S.share_packing??!1,share_budget:S.share_budget??!1,share_collab:S.share_collab??!1}),o(!1)}).catch(()=>o(!1))},[e]);const g=a?`${window.location.origin}/shared/${a}`:null,f=async()=>{try{const S=await Zs.createLink(e,c);n(S.token)}catch{m.error(t("share.createError"))}},y=async(S,v)=>{const _={...c,[S]:v};if(p(_),a)try{await Zs.createLink(e,_)}catch{}},x=async()=>{try{await Zs.deleteLink(e),n(null)}catch{}},k=()=>{g&&(navigator.clipboard.writeText(g),d(!0),setTimeout(()=>d(!1),2e3))};return i?null:r.jsxs("div",{children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:10},children:[r.jsx(wo,{size:14,style:{color:"var(--text-muted)"}}),r.jsx("span",{style:{fontSize:13,fontWeight:600,color:"var(--text-primary)"},children:t("share.linkTitle")})]}),r.jsx("p",{style:{fontSize:11,color:"var(--text-faint)",marginBottom:10,lineHeight:1.5},children:t("share.linkHint")}),r.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:6,marginBottom:12},children:[{key:"share_map",label:t("share.permMap"),always:!0},{key:"share_bookings",label:t("share.permBookings")},{key:"share_packing",label:t("share.permPacking")},{key:"share_budget",label:t("share.permBudget")},{key:"share_collab",label:t("share.permCollab")}].map(S=>r.jsxs("button",{onClick:()=>!S.always&&y(S.key,!c[S.key]),style:{display:"flex",alignItems:"center",gap:5,padding:"4px 10px",borderRadius:20,border:"1.5px solid",fontSize:11,fontWeight:500,cursor:S.always?"default":"pointer",fontFamily:"inherit",transition:"all 0.12s",background:c[S.key]?"var(--text-primary)":"transparent",borderColor:c[S.key]?"var(--text-primary)":"var(--border-primary)",color:c[S.key]?"var(--bg-primary)":"var(--text-muted)",opacity:S.always?.7:1},children:[c[S.key]?r.jsx(Ga,{size:10}):null,S.label]},S.key))}),g?r.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,padding:"8px 10px",background:"var(--bg-tertiary)",borderRadius:8,border:"1px solid var(--border-faint)"},children:[r.jsx("input",{type:"text",value:g,readOnly:!0,style:{flex:1,border:"none",background:"none",fontSize:11,color:"var(--text-primary)",outline:"none",fontFamily:"monospace"}}),r.jsx("button",{onClick:k,style:{display:"flex",alignItems:"center",gap:4,padding:"4px 8px",borderRadius:6,border:"none",background:s?"#16a34a":"var(--accent)",color:s?"white":"var(--accent-text)",fontSize:10,fontWeight:600,cursor:"pointer",fontFamily:"inherit",transition:"background 0.2s"},children:s?r.jsxs(r.Fragment,{children:[r.jsx(Ga,{size:10})," ",t("common.copied")]}):r.jsxs(r.Fragment,{children:[r.jsx(Ys,{size:10})," ",t("common.copy")]})})]}),r.jsxs("button",{onClick:x,style:{display:"flex",alignItems:"center",justifyContent:"center",gap:5,padding:"6px 0",borderRadius:8,border:"1px solid rgba(239,68,68,0.3)",background:"rgba(239,68,68,0.06)",color:"#ef4444",fontSize:11,fontWeight:500,cursor:"pointer",fontFamily:"inherit"},children:[r.jsx(_t,{size:11})," ",t("share.deleteLink")]})]}):r.jsxs("button",{onClick:f,style:{display:"flex",alignItems:"center",justifyContent:"center",gap:6,width:"100%",padding:"8px 0",borderRadius:8,border:"1px dashed var(--border-primary)",background:"none",color:"var(--text-muted)",fontSize:12,fontWeight:500,cursor:"pointer",fontFamily:"inherit"},children:[r.jsx(wo,{size:12})," ",t("share.createLink")]})]})}function T4({isOpen:e,onClose:t,tripId:a,tripTitle:n}){var Y,H,V;const[i,o]=b.useState(null),[s,d]=b.useState([]),[c,p]=b.useState(!1),[m,g]=b.useState(""),[f,y]=b.useState(!1),[x,k]=b.useState(null),S=ya(),{user:v}=cn(),{t:_}=ot();b.useEffect(()=>{e&&a&&(w(),E())},[e,a]);const w=async()=>{p(!0);try{const X=await Ba.getMembers(a);o(X)}catch{S.error(_("members.loadError"))}finally{p(!1)}},E=async()=>{try{const X=await jt.listUsers();d(X.users)}catch{}},M=async()=>{if(m){y(!0);try{const X=s.find(Z=>String(Z.id)===String(m));await Ba.addMember(a,X.username),g(""),await w(),S.success(`${X.username} ${_("members.added")}`)}catch(X){S.error(at(X,_("members.addError")))}finally{y(!1)}}},A=async(X,Z)=>{const O=_(Z?"members.confirmLeave":"members.confirmRemove");if(confirm(O)){k(X);try{await Ba.removeMember(a,X),Z?(t(),window.location.reload()):(await w(),S.success(_("members.removed")))}catch{S.error(_("members.removeError"))}finally{k(null)}}},P=new Set([(Y=i==null?void 0:i.owner)==null?void 0:Y.id,...((H=i==null?void 0:i.members)==null?void 0:H.map(X=>X.id))||[]]),R=s.filter(X=>!P.has(X.id)),$=((V=i==null?void 0:i.owner)==null?void 0:V.id)===(v==null?void 0:v.id),I=i?[{...i.owner,role:"owner"},...i.members]:[];return r.jsx(zi,{isOpen:e,onClose:t,title:_("members.shareTrip"),size:"3xl",children:r.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:24,fontFamily:"-apple-system, BlinkMacSystemFont, 'SF Pro Text', system-ui, sans-serif"},className:"share-modal-grid",children:[r.jsx("style",{children:"@media (max-width: 640px) { .share-modal-grid { grid-template-columns: 1fr !important; } }"}),r.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[r.jsxs("div",{style:{padding:"10px 14px",background:"var(--bg-secondary)",borderRadius:10,border:"1px solid var(--border-secondary)"},children:[r.jsx("div",{style:{fontSize:11,fontWeight:600,color:"var(--text-faint)",textTransform:"uppercase",letterSpacing:"0.05em",marginBottom:2},children:_("nav.trip")}),r.jsx("div",{style:{fontSize:14,fontWeight:600,color:"var(--text-primary)"},children:n})]}),r.jsxs("div",{children:[r.jsx("label",{style:{display:"block",fontSize:12,fontWeight:600,color:"var(--text-secondary)",marginBottom:8},children:_("members.inviteUser")}),r.jsxs("div",{style:{display:"flex",gap:8},children:[r.jsx(ea,{value:m,onChange:X=>g(X),placeholder:_("members.selectUser"),options:[{value:"",label:_("members.selectUser")},...R.map(X=>({value:X.id,label:X.username}))],searchable:!0,style:{flex:1},size:"sm"}),r.jsxs("button",{onClick:M,disabled:f||!m,style:{display:"flex",alignItems:"center",gap:5,padding:"8px 14px",background:"var(--accent)",color:"var(--accent-text)",border:"none",borderRadius:10,fontSize:13,fontWeight:600,cursor:f||!m?"default":"pointer",fontFamily:"inherit",opacity:f||!m?.4:1,flexShrink:0},children:[r.jsx(_c,{size:13})," ",f?"…":_("members.invite")]})]}),R.length===0&&s.length>0&&r.jsx("p",{style:{fontSize:11.5,color:"var(--text-faint)",margin:"6px 0 0"},children:_("members.allHaveAccess")})]}),r.jsxs("div",{children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:10},children:[r.jsx(Ur,{size:13,style:{color:"var(--text-faint)"}}),r.jsxs("span",{style:{fontSize:12,fontWeight:600,color:"var(--text-secondary)"},children:[_("members.access")," (",I.length," ",I.length===1?_("members.person"):_("members.persons"),")"]})]}),c?r.jsx("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[1,2].map(X=>r.jsx("div",{style:{height:48,background:"var(--bg-tertiary)",borderRadius:10,animation:"pulse 1.5s ease-in-out infinite"}},X))}):r.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:I.map(X=>{const Z=X.id===(v==null?void 0:v.id),O=$?X.role!=="owner":Z;return r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"8px 12px",borderRadius:10,background:"var(--bg-secondary)",border:"1px solid var(--border-secondary)"},children:[r.jsx(C4,{username:X.username,avatarUrl:X.avatar_url}),r.jsx("div",{style:{flex:1,minWidth:0},children:r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,flexWrap:"wrap"},children:[r.jsx("span",{style:{fontSize:13,fontWeight:600,color:"var(--text-primary)"},children:X.username}),Z&&r.jsxs("span",{style:{fontSize:10,color:"var(--text-faint)"},children:["(",_("members.you"),")"]}),X.role==="owner"&&r.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:3,fontSize:10,fontWeight:700,color:"#d97706",background:"#fef9c3",padding:"1px 6px",borderRadius:99},children:[r.jsx(NM,{size:9})," ",_("members.owner")]})]})}),O&&r.jsx("button",{onClick:()=>A(X.id,Z),disabled:x===X.id,title:_(Z?"members.leaveTrip":"members.removeAccess"),style:{background:"none",border:"none",cursor:"pointer",padding:"4px",borderRadius:6,display:"flex",color:"var(--text-faint)",opacity:x===X.id?.4:1},onMouseEnter:Q=>Q.currentTarget.style.color="#ef4444",onMouseLeave:Q=>Q.currentTarget.style.color="#9ca3af",children:Z?r.jsx(Ip,{size:14}):r.jsx(wD,{size:14})})]},X.id)})})]})]}),r.jsx("div",{style:{borderLeft:"1px solid var(--border-faint)",paddingLeft:24},children:r.jsx(z4,{tripId:a,t:_})}),r.jsx("style",{children:"@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.5} }"})]})})}const P4=[{value:"flight",labelKey:"reservations.type.flight",Icon:Or},{value:"hotel",labelKey:"reservations.type.hotel",Icon:Rr},{value:"restaurant",labelKey:"reservations.type.restaurant",Icon:Cc},{value:"train",labelKey:"reservations.type.train",Icon:Ui},{value:"car",labelKey:"reservations.type.car",Icon:Bi},{value:"cruise",labelKey:"reservations.type.cruise",Icon:Hi},{value:"event",labelKey:"reservations.type.event",Icon:kn},{value:"tour",labelKey:"reservations.type.tour",Icon:Ur},{value:"other",labelKey:"reservations.type.other",Icon:Pa}];function E4(e,t,a,n){const i=[];for(const o of e||[]){const s=((t==null?void 0:t[String(o.id)])||[]).slice().sort((m,g)=>m.order_index-g.order_index);if(s.length===0)continue;const d=o.title||a("dayplan.dayN",{n:o.day_number}),c=o.date?` · ${Zf(o.date,n)}`:"",p=`${d}${c}`;i.push({value:`_header_${o.id}`,label:p,disabled:!0,isHeader:!0});for(let m=0;mC.loadFiles),x=ya(),{t:k,locale:S}=ot(),v=b.useRef(null),[_,w]=b.useState({title:"",type:"other",status:"pending",reservation_time:"",reservation_end_time:"",location:"",confirmation_number:"",notes:"",assignment_id:"",accommodation_id:"",meta_airline:"",meta_flight_number:"",meta_departure_airport:"",meta_arrival_airport:"",meta_train_number:"",meta_platform:"",meta_seat:"",meta_check_in_time:"",meta_check_out_time:"",hotel_place_id:"",hotel_start_day:"",hotel_end_day:""}),[E,M]=b.useState(!1),[A,P]=b.useState(!1),[R,$]=b.useState([]),[I,Y]=b.useState(!1),[H,V]=b.useState([]),[X,Z]=b.useState([]),O=b.useMemo(()=>E4(i,s,k,S),[i,s,k,S]);b.useEffect(()=>{if(n){const C=typeof n.metadata=="string"?JSON.parse(n.metadata||"{}"):n.metadata||{};w({title:n.title||"",type:n.type||"other",status:n.status||"pending",reservation_time:n.reservation_time?n.reservation_time.slice(0,16):"",reservation_end_time:n.reservation_end_time||"",location:n.location||"",confirmation_number:n.confirmation_number||"",notes:n.notes||"",assignment_id:n.assignment_id||"",accommodation_id:n.accommodation_id||"",meta_airline:C.airline||"",meta_flight_number:C.flight_number||"",meta_departure_airport:C.departure_airport||"",meta_arrival_airport:C.arrival_airport||"",meta_train_number:C.train_number||"",meta_platform:C.platform||"",meta_seat:C.seat||"",meta_check_in_time:C.check_in_time||"",meta_check_out_time:C.check_out_time||"",hotel_place_id:(()=>{const U=g.find(q=>q.id==n.accommodation_id);return(U==null?void 0:U.place_id)||""})(),hotel_start_day:(()=>{const U=g.find(q=>q.id==n.accommodation_id);return(U==null?void 0:U.start_day_id)||""})(),hotel_end_day:(()=>{const U=g.find(q=>q.id==n.accommodation_id);return(U==null?void 0:U.end_day_id)||""})()})}else w({title:"",type:"other",status:"pending",reservation_time:"",reservation_end_time:"",location:"",confirmation_number:"",notes:"",assignment_id:"",accommodation_id:"",meta_airline:"",meta_flight_number:"",meta_departure_airport:"",meta_arrival_airport:"",meta_train_number:"",meta_platform:"",meta_seat:"",meta_check_in_time:"",meta_check_out_time:""}),$([])},[n,e,d]);const Q=(C,U)=>w(q=>({...q,[C]:U})),D=async C=>{if(C.preventDefault(),!!_.title.trim()){M(!0);try{const U={};_.type==="flight"?(_.meta_airline&&(U.airline=_.meta_airline),_.meta_flight_number&&(U.flight_number=_.meta_flight_number),_.meta_departure_airport&&(U.departure_airport=_.meta_departure_airport),_.meta_arrival_airport&&(U.arrival_airport=_.meta_arrival_airport)):_.type==="hotel"?(_.meta_check_in_time&&(U.check_in_time=_.meta_check_in_time),_.meta_check_out_time&&(U.check_out_time=_.meta_check_out_time)):_.type==="train"&&(_.meta_train_number&&(U.train_number=_.meta_train_number),_.meta_platform&&(U.platform=_.meta_platform),_.meta_seat&&(U.seat=_.meta_seat));const q={title:_.title,type:_.type,status:_.status,reservation_time:_.reservation_time,reservation_end_time:_.reservation_end_time,location:_.location,confirmation_number:_.confirmation_number,notes:_.notes,assignment_id:_.assignment_id||null,accommodation_id:_.type==="hotel"&&_.accommodation_id||null,metadata:Object.keys(U).length>0?U:null};_.type==="hotel"&&_.hotel_place_id&&_.hotel_start_day&&_.hotel_end_day&&(q.create_accommodation={place_id:_.hotel_place_id,start_day_id:_.hotel_start_day,end_day_id:_.hotel_end_day,check_in:_.meta_check_in_time||null,check_out:_.meta_check_out_time||null,confirmation:_.confirmation_number||null});const te=await a(q);if(!(n!=null&&n.id)&&(te!=null&&te.id)&&R.length>0)for(const oe of R){const be=new FormData;be.append("file",oe),be.append("reservation_id",te.id),be.append("description",_.title),await p(be)}}finally{M(!1)}}},J=async C=>{var q;const U=(q=C.target.files)==null?void 0:q[0];if(U)if(n!=null&&n.id){P(!0);try{const te=new FormData;te.append("file",U),te.append("reservation_id",n.id),te.append("description",n.title),await p(te),x.success(k("reservations.toast.fileUploaded"))}catch{x.error(k("reservations.toast.uploadError"))}finally{P(!1),C.target.value=""}}else $(te=>[...te,U]),C.target.value=""},z=n!=null&&n.id?c.filter(C=>C.reservation_id===n.id||H.includes(C.id)||C.linked_reservation_ids&&C.linked_reservation_ids.includes(n.id)):[],W={width:"100%",border:"1px solid var(--border-primary)",borderRadius:10,padding:"8px 12px",fontSize:13,fontFamily:"inherit",outline:"none",boxSizing:"border-box",color:"var(--text-primary)",background:"var(--bg-input)"},B={display:"block",fontSize:11,fontWeight:600,color:"var(--text-faint)",marginBottom:5,textTransform:"uppercase",letterSpacing:"0.03em"};return r.jsx(zi,{isOpen:e,onClose:t,title:k(n?"reservations.editTitle":"reservations.newTitle"),size:"2xl",children:r.jsxs("form",{onSubmit:D,style:{display:"flex",flexDirection:"column",gap:14},children:[r.jsxs("div",{children:[r.jsx("label",{style:B,children:k("reservations.bookingType")}),r.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:5},children:P4.map(({value:C,labelKey:U,Icon:q})=>r.jsxs("button",{type:"button",onClick:()=>Q("type",C),style:{display:"flex",alignItems:"center",gap:4,padding:"5px 10px",borderRadius:99,border:"1px solid",fontSize:11,fontWeight:500,cursor:"pointer",fontFamily:"inherit",transition:"all 0.12s",background:_.type===C?"var(--text-primary)":"var(--bg-card)",borderColor:_.type===C?"var(--text-primary)":"var(--border-primary)",color:_.type===C?"var(--bg-primary)":"var(--text-muted)"},children:[r.jsx(q,{size:11})," ",k(U)]},C))})]}),r.jsxs("div",{children:[r.jsxs("label",{style:B,children:[k("reservations.titleLabel")," *"]}),r.jsx("input",{type:"text",value:_.title,onChange:C=>Q("title",C.target.value),required:!0,placeholder:k("reservations.titlePlaceholder"),style:W})]}),_.type!=="hotel"&&r.jsxs("div",{style:{display:"flex",gap:8},children:[O.length>0&&r.jsxs("div",{style:{flex:1,minWidth:0},children:[r.jsxs("label",{style:B,children:[r.jsx(wo,{size:10,style:{display:"inline",verticalAlign:"-1px",marginRight:3}}),k("reservations.linkAssignment")]}),r.jsx(ea,{value:_.assignment_id,onChange:C=>{Q("assignment_id",C);const U=O.find(q=>q.value===C);U!=null&&U.dayDate&&w(q=>q.reservation_time?q:{...q,reservation_time:U.dayDate})},placeholder:k("reservations.pickAssignment"),options:[{value:"",label:k("reservations.noAssignment")},...O],searchable:!0,size:"sm"})]}),r.jsxs("div",{style:{flex:1,minWidth:0},children:[r.jsx("label",{style:B,children:k("reservations.date")}),r.jsx(Wf,{value:(()=>{const[C]=(_.reservation_time||"").split("T");return C||""})(),onChange:C=>{const[,U]=(_.reservation_time||"").split("T");Q("reservation_time",C?U?`${C}T${U}`:C:"")}})]})]}),r.jsxs("div",{style:{display:"flex",gap:8},children:[_.type!=="hotel"&&r.jsxs(r.Fragment,{children:[r.jsxs("div",{style:{flex:1,minWidth:0},children:[r.jsx("label",{style:B,children:k("reservations.startTime")}),r.jsx(oo,{value:(()=>{const[,C]=(_.reservation_time||"").split("T");return C||""})(),onChange:C=>{const[U]=(_.reservation_time||"").split("T"),q=U||new Date().toISOString().split("T")[0];Q("reservation_time",C?`${q}T${C}`:q)}})]}),r.jsxs("div",{style:{flex:1,minWidth:0},children:[r.jsx("label",{style:B,children:k("reservations.endTime")}),r.jsx(oo,{value:_.reservation_end_time,onChange:C=>Q("reservation_end_time",C)})]})]}),r.jsxs("div",{style:{flex:1,minWidth:0},children:[r.jsx("label",{style:B,children:k("reservations.status")}),r.jsx(ea,{value:_.status,onChange:C=>Q("status",C),options:[{value:"pending",label:k("reservations.pending")},{value:"confirmed",label:k("reservations.confirmed")}],size:"sm"})]})]}),r.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[r.jsxs("div",{children:[r.jsx("label",{style:B,children:k("reservations.locationAddress")}),r.jsx("input",{type:"text",value:_.location,onChange:C=>Q("location",C.target.value),placeholder:k("reservations.locationPlaceholder"),style:W})]}),r.jsxs("div",{children:[r.jsx("label",{style:B,children:k("reservations.confirmationCode")}),r.jsx("input",{type:"text",value:_.confirmation_number,onChange:C=>Q("confirmation_number",C.target.value),placeholder:k("reservations.confirmationPlaceholder"),style:W})]})]}),_.type==="flight"&&r.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3",children:[r.jsxs("div",{children:[r.jsx("label",{style:B,children:k("reservations.meta.airline")||"Airline"}),r.jsx("input",{type:"text",value:_.meta_airline,onChange:C=>Q("meta_airline",C.target.value),placeholder:"Lufthansa",style:W})]}),r.jsxs("div",{children:[r.jsx("label",{style:B,children:k("reservations.meta.flightNumber")||"Flight No."}),r.jsx("input",{type:"text",value:_.meta_flight_number,onChange:C=>Q("meta_flight_number",C.target.value),placeholder:"LH 123",style:W})]}),r.jsxs("div",{children:[r.jsx("label",{style:B,children:k("reservations.meta.from")||"From"}),r.jsx("input",{type:"text",value:_.meta_departure_airport,onChange:C=>Q("meta_departure_airport",C.target.value),placeholder:"FRA",style:W})]}),r.jsxs("div",{children:[r.jsx("label",{style:B,children:k("reservations.meta.to")||"To"}),r.jsx("input",{type:"text",value:_.meta_arrival_airport,onChange:C=>Q("meta_arrival_airport",C.target.value),placeholder:"NRT",style:W})]})]}),_.type==="hotel"&&r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-3",children:[r.jsxs("div",{children:[r.jsx("label",{style:B,children:k("reservations.meta.hotelPlace")}),r.jsx(ea,{value:_.hotel_place_id,onChange:C=>{Q("hotel_place_id",C);const U=o.find(q=>q.id===C);U&&(_.title||Q("title",U.name),!_.location&&U.address&&Q("location",U.address))},placeholder:k("reservations.meta.pickHotel"),options:[{value:"",label:"—"},...o.map(C=>({value:C.id,label:C.name}))],searchable:!0,size:"sm"})]}),r.jsxs("div",{children:[r.jsx("label",{style:B,children:k("reservations.meta.fromDay")}),r.jsx(ea,{value:_.hotel_start_day,onChange:C=>Q("hotel_start_day",C),placeholder:k("reservations.meta.selectDay"),options:i.map(C=>({value:C.id,label:C.title||`${k("dayplan.dayN",{n:C.day_number})}${C.date?` · ${Zf(C.date,S)}`:""}`})),size:"sm"})]}),r.jsxs("div",{children:[r.jsx("label",{style:B,children:k("reservations.meta.toDay")}),r.jsx(ea,{value:_.hotel_end_day,onChange:C=>Q("hotel_end_day",C),placeholder:k("reservations.meta.selectDay"),options:i.map(C=>({value:C.id,label:C.title||`${k("dayplan.dayN",{n:C.day_number})}${C.date?` · ${Zf(C.date,S)}`:""}`})),size:"sm"})]})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[r.jsxs("div",{children:[r.jsx("label",{style:B,children:k("reservations.meta.checkIn")}),r.jsx(oo,{value:_.meta_check_in_time,onChange:C=>Q("meta_check_in_time",C)})]}),r.jsxs("div",{children:[r.jsx("label",{style:B,children:k("reservations.meta.checkOut")}),r.jsx(oo,{value:_.meta_check_out_time,onChange:C=>Q("meta_check_out_time",C)})]})]})]}),_.type==="train"&&r.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[r.jsxs("div",{children:[r.jsx("label",{style:B,children:k("reservations.meta.trainNumber")||"Train No."}),r.jsx("input",{type:"text",value:_.meta_train_number,onChange:C=>Q("meta_train_number",C.target.value),placeholder:"ICE 123",style:W})]}),r.jsxs("div",{children:[r.jsx("label",{style:B,children:k("reservations.meta.platform")||"Platform"}),r.jsx("input",{type:"text",value:_.meta_platform,onChange:C=>Q("meta_platform",C.target.value),placeholder:"12",style:W})]}),r.jsxs("div",{children:[r.jsx("label",{style:B,children:k("reservations.meta.seat")||"Seat"}),r.jsx("input",{type:"text",value:_.meta_seat,onChange:C=>Q("meta_seat",C.target.value),placeholder:"42A",style:W})]})]}),r.jsxs("div",{children:[r.jsx("label",{style:B,children:k("reservations.notes")}),r.jsx("textarea",{value:_.notes,onChange:C=>Q("notes",C.target.value),rows:2,placeholder:k("reservations.notesPlaceholder"),style:{...W,resize:"none",lineHeight:1.5}})]}),r.jsxs("div",{children:[r.jsx("label",{style:B,children:k("files.title")}),r.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[z.map(C=>r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"5px 10px",background:"var(--bg-secondary)",borderRadius:8},children:[r.jsx(Pa,{size:12,style:{color:"var(--text-muted)",flexShrink:0}}),r.jsx("span",{style:{flex:1,fontSize:12,color:"var(--text-secondary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:C.original_name}),r.jsx("a",{href:C.url,target:"_blank",rel:"noreferrer",style:{color:"var(--text-faint)",display:"flex",flexShrink:0},children:r.jsx(xn,{size:11})}),r.jsx("button",{type:"button",onClick:async()=>{if(C.reservation_id===(n==null?void 0:n.id))try{await ie.put(`/trips/${f}/files/${C.id}`,{reservation_id:null})}catch{}try{const q=((await ie.get(`/trips/${f}/files/${C.id}/links`)).data.links||[]).find(te=>te.reservation_id===(n==null?void 0:n.id));q&&await ie.delete(`/trips/${f}/files/${C.id}/link/${q.id}`)}catch{}V(U=>U.filter(q=>q!==C.id)),f&&y(f)},style:{background:"none",border:"none",cursor:"pointer",color:"var(--text-faint)",display:"flex",padding:0,flexShrink:0},children:r.jsx(gt,{size:11})})]},C.id)),R.map((C,U)=>r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"5px 10px",background:"var(--bg-secondary)",borderRadius:8},children:[r.jsx(Pa,{size:12,style:{color:"var(--text-muted)",flexShrink:0}}),r.jsx("span",{style:{flex:1,fontSize:12,color:"var(--text-secondary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:C.name}),r.jsx("button",{type:"button",onClick:()=>$(q=>q.filter((te,oe)=>oe!==U)),style:{background:"none",border:"none",cursor:"pointer",color:"var(--text-faint)",display:"flex",padding:0,flexShrink:0},children:r.jsx(gt,{size:11})})]},U)),r.jsx("input",{ref:v,type:"file",accept:".pdf,.doc,.docx,.txt,image/*",style:{display:"none"},onChange:J}),r.jsxs("div",{style:{display:"flex",gap:6,flexWrap:"wrap"},children:[r.jsxs("button",{type:"button",onClick:()=>{var C;return(C=v.current)==null?void 0:C.click()},disabled:A,style:{display:"flex",alignItems:"center",gap:5,padding:"6px 10px",border:"1px dashed var(--border-primary)",borderRadius:8,background:"none",fontSize:11,color:"var(--text-faint)",cursor:A?"default":"pointer",fontFamily:"inherit"},children:[r.jsx(Hf,{size:11}),k(A?"reservations.uploading":"reservations.attachFile")]}),(n==null?void 0:n.id)&&c.filter(C=>!C.deleted_at&&!z.some(U=>U.id===C.id)).length>0&&r.jsxs("div",{style:{position:"relative"},children:[r.jsxs("button",{type:"button",onClick:()=>Y(C=>!C),style:{display:"flex",alignItems:"center",gap:5,padding:"6px 10px",border:"1px dashed var(--border-primary)",borderRadius:8,background:"none",fontSize:11,color:"var(--text-faint)",cursor:"pointer",fontFamily:"inherit"},children:[r.jsx(wo,{size:11})," ",k("reservations.linkExisting")]}),I&&r.jsx("div",{style:{position:"absolute",bottom:"100%",left:0,marginBottom:4,zIndex:50,background:"var(--bg-card)",border:"1px solid var(--border-primary)",borderRadius:10,boxShadow:"0 4px 16px rgba(0,0,0,0.12)",padding:4,minWidth:220,maxHeight:200,overflowY:"auto"},children:c.filter(C=>!C.deleted_at&&!z.some(U=>U.id===C.id)).map(C=>r.jsxs("button",{type:"button",onClick:async()=>{try{await ie.post(`/trips/${f}/files/${C.id}/link`,{reservation_id:n.id}),V(U=>[...U,C.id]),Y(!1),f&&y(f)}catch{}},style:{display:"flex",alignItems:"center",gap:8,width:"100%",padding:"6px 10px",background:"none",border:"none",cursor:"pointer",fontSize:12,fontFamily:"inherit",color:"var(--text-secondary)",borderRadius:7,textAlign:"left"},onMouseEnter:U=>U.currentTarget.style.background="var(--bg-tertiary)",onMouseLeave:U=>U.currentTarget.style.background="none",children:[r.jsx(Pa,{size:12,style:{color:"var(--text-faint)",flexShrink:0}}),r.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:C.original_name})]},C.id))})]})]})]})]}),r.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8,paddingTop:4,borderTop:"1px solid var(--border-secondary)"},children:[r.jsx("button",{type:"button",onClick:t,style:{padding:"8px 16px",borderRadius:10,border:"1px solid var(--border-primary)",background:"none",fontSize:12,cursor:"pointer",fontFamily:"inherit",color:"var(--text-muted)"},children:k("common.cancel")}),r.jsx("button",{type:"submit",disabled:E||!_.title.trim(),style:{padding:"8px 20px",borderRadius:10,border:"none",background:"var(--text-primary)",color:"var(--bg-primary)",fontSize:12,fontWeight:600,cursor:"pointer",fontFamily:"inherit",opacity:E||!_.title.trim()?.5:1},children:k(E?"common.saving":n?"common.update":"common.add")})]})]})})}function Zf(e,t){return e?new Date(e+"T00:00:00").toLocaleDateString(t||void 0,{day:"numeric",month:"short"}):""}function N4({tripId:e,startDate:t,endDate:a}){const{t:n}=ot(),i=cn(pe=>pe.user),[o,s]=b.useState(!1),[d,c]=b.useState(!0),[p,m]=b.useState([]),[g,f]=b.useState(!1),[y,x]=b.useState([]),[k,S]=b.useState(!1),[v,_]=b.useState(new Set),[w,E]=b.useState(!1),[M,A]=b.useState(!0),[P,R]=b.useState(""),[$,I]=b.useState(null),[Y,H]=b.useState(null),[V,X]=b.useState(null),[Z,O]=b.useState(!1);b.useEffect(()=>{D()},[e]),b.useEffect(()=>{const pe=()=>Q();return window.addEventListener("memories:updated",pe),()=>window.removeEventListener("memories:updated",pe)},[e]);const Q=async()=>{try{const pe=await ie.get(`/integrations/immich/trips/${e}/photos`);m(pe.data.photos||[])}catch{m([])}},D=async()=>{c(!0);try{const pe=await ie.get("/integrations/immich/status");s(pe.data.connected)}catch{s(!1)}await Q(),c(!1)},[J,z]=b.useState(!0),W=async()=>{f(!0),S(!0),_(new Set),z(!!(t&&a)),await B(!!(t&&a))},B=async pe=>{S(!0);try{const Ae=await ie.post("/integrations/immich/search",{from:pe&&t?t:void 0,to:pe&&a?a:void 0});x(Ae.data.assets||[])}catch{x([])}finally{S(!1)}},C=pe=>{_(Ae=>{const He=new Set(Ae);return He.has(pe)?He.delete(pe):He.add(pe),He})},U=()=>{v.size!==0&&E(!0)},q=async()=>{E(!1);try{await ie.post(`/integrations/immich/trips/${e}/photos`,{asset_ids:[...v],shared:!0}),f(!1),D()}catch{}},te=async pe=>{try{await ie.delete(`/integrations/immich/trips/${e}/photos/${pe}`),m(Ae=>Ae.filter(He=>He.immich_asset_id!==pe))}catch{}},oe=async(pe,Ae)=>{try{await ie.put(`/integrations/immich/trips/${e}/photos/${pe}/sharing`,{shared:Ae}),m(He=>He.map(ze=>ze.immich_asset_id===pe?{...ze,shared:Ae?1:0}:ze))}catch{}},be=cn(pe=>pe.token),Se=(pe,Ae)=>`/api/integrations/immich/assets/${pe}/thumbnail?userId=${Ae}&token=${be}`,je=(pe,Ae)=>`/api/integrations/immich/assets/${pe}/original?userId=${Ae}&token=${be}`,we=p.filter(pe=>pe.user_id===(i==null?void 0:i.id)),ce=p.filter(pe=>pe.user_id!==(i==null?void 0:i.id)&&pe.shared),le=[...we,...ce],K=[...new Set(le.map(pe=>pe.city).filter(Boolean))].sort(),de=le.filter(pe=>!P||pe.city===P).sort((pe,Ae)=>{const He=new Date(pe.added_at||0).getTime(),ze=new Date(Ae.added_at||0).getTime();return M?He-ze:ze-He}),_e={fontFamily:"-apple-system, BlinkMacSystemFont, 'SF Pro Text', system-ui, sans-serif"};if(d)return r.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%",..._e},children:r.jsx("div",{className:"w-8 h-8 border-2 rounded-full animate-spin",style:{borderColor:"var(--border-primary)",borderTopColor:"var(--text-primary)"}})});if(!o&&de.length===0)return r.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100%",padding:40,textAlign:"center",..._e},children:[r.jsx(Ir,{size:40,style:{color:"var(--text-faint)",marginBottom:12}}),r.jsx("h3",{style:{margin:"0 0 6px",fontSize:16,fontWeight:700,color:"var(--text-primary)"},children:n("memories.notConnected")}),r.jsx("p",{style:{margin:0,fontSize:13,color:"var(--text-muted)",maxWidth:300},children:n("memories.notConnectedHint")})]});if(g){const pe=new Set(p.filter(Ae=>Ae.user_id===(i==null?void 0:i.id)).map(Ae=>Ae.immich_asset_id));return r.jsxs(r.Fragment,{children:[r.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",..._e},children:[r.jsxs("div",{style:{padding:"14px 20px",borderBottom:"1px solid var(--border-secondary)"},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:10},children:[r.jsx("h3",{style:{margin:0,fontSize:15,fontWeight:700,color:"var(--text-primary)"},children:n("memories.selectPhotos")}),r.jsxs("div",{style:{display:"flex",gap:8},children:[r.jsx("button",{onClick:()=>f(!1),style:{padding:"7px 14px",borderRadius:10,border:"1px solid var(--border-primary)",background:"none",fontSize:12,cursor:"pointer",fontFamily:"inherit",color:"var(--text-muted)"},children:n("common.cancel")}),r.jsx("button",{onClick:U,disabled:v.size===0,style:{padding:"7px 14px",borderRadius:10,border:"none",fontSize:12,fontWeight:600,cursor:v.size>0?"pointer":"default",fontFamily:"inherit",background:v.size>0?"var(--text-primary)":"var(--border-primary)",color:v.size>0?"var(--bg-primary)":"var(--text-faint)"},children:v.size>0?n("memories.addSelected",{count:v.size}):n("memories.addPhotos")})]})]}),r.jsxs("div",{style:{display:"flex",gap:6},children:[t&&a&&r.jsxs("button",{onClick:()=>{J||(z(!0),B(!0))},style:{padding:"6px 14px",borderRadius:99,fontSize:12,fontWeight:600,cursor:"pointer",fontFamily:"inherit",border:"1px solid",transition:"all 0.15s",background:J?"var(--text-primary)":"var(--bg-card)",borderColor:J?"var(--text-primary)":"var(--border-primary)",color:J?"var(--bg-primary)":"var(--text-muted)"},children:[n("memories.tripDates")," (",t?new Date(t+"T12:00:00").toLocaleDateString(void 0,{day:"numeric",month:"short"}):""," — ",a?new Date(a+"T12:00:00").toLocaleDateString(void 0,{day:"numeric",month:"short",year:"numeric"}):"",")"]}),r.jsx("button",{onClick:()=>{(J||!t)&&(z(!1),B(!1))},style:{padding:"6px 14px",borderRadius:99,fontSize:12,fontWeight:600,cursor:"pointer",fontFamily:"inherit",border:"1px solid",transition:"all 0.15s",background:J?"var(--bg-card)":"var(--text-primary)",borderColor:J?"var(--border-primary)":"var(--text-primary)",color:J?"var(--text-muted)":"var(--bg-primary)"},children:n("memories.allPhotos")})]}),v.size>0&&r.jsxs("p",{style:{margin:"8px 0 0",fontSize:12,fontWeight:600,color:"var(--text-primary)"},children:[v.size," ",n("memories.selected")]})]}),r.jsx("div",{style:{flex:1,overflowY:"auto",padding:12},children:k?r.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:60},children:r.jsx("div",{className:"w-7 h-7 border-2 rounded-full animate-spin",style:{borderColor:"var(--border-primary)",borderTopColor:"var(--text-primary)"}})}):y.length===0?r.jsxs("div",{style:{textAlign:"center",padding:"60px 20px"},children:[r.jsx(Ir,{size:36,style:{color:"var(--text-faint)",margin:"0 auto 10px",display:"block"}}),r.jsx("p",{style:{fontSize:13,color:"var(--text-muted)",margin:0},children:n("memories.noPhotos")})]}):(()=>{const Ae={};for(const ze of y){const Ye=ze.takenAt?new Date(ze.takenAt):null,G=Ye?`${Ye.getFullYear()}-${String(Ye.getMonth()+1).padStart(2,"0")}`:"unknown";Ae[G]||(Ae[G]=[]),Ae[G].push(ze)}return Object.keys(Ae).sort().reverse().map(ze=>r.jsxs("div",{style:{marginBottom:16},children:[r.jsx("div",{style:{fontSize:12,fontWeight:700,color:"var(--text-muted)",marginBottom:6,paddingLeft:2},children:ze!=="unknown"?new Date(ze+"-15").toLocaleDateString(void 0,{month:"long",year:"numeric"}):"—"}),r.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(100px, 1fr))",gap:4},children:Ae[ze].map(Ye=>{const G=v.has(Ye.id),ve=pe.has(Ye.id);return r.jsxs("div",{onClick:()=>!ve&&C(Ye.id),style:{position:"relative",aspectRatio:"1",borderRadius:8,overflow:"hidden",cursor:ve?"default":"pointer",opacity:ve?.3:1,outline:G?"3px solid var(--text-primary)":"none",outlineOffset:-3},children:[r.jsx("img",{src:Se(Ye.id,i.id),alt:"",loading:"lazy",style:{width:"100%",height:"100%",objectFit:"cover"}}),G&&r.jsx("div",{style:{position:"absolute",top:4,right:4,width:22,height:22,borderRadius:"50%",background:"var(--text-primary)",display:"flex",alignItems:"center",justifyContent:"center"},children:r.jsx(Ga,{size:13,color:"var(--bg-primary)"})}),ve&&r.jsx("div",{style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(0,0,0,0.3)",fontSize:10,color:"white",fontWeight:600},children:n("memories.alreadyAdded")})]},Ye.id)})})]},ze))})()})]}),w&&r.jsx("div",{onClick:()=>E(!1),style:{position:"fixed",inset:0,zIndex:1e3,background:"rgba(0,0,0,0.4)",display:"flex",alignItems:"center",justifyContent:"center",padding:20},children:r.jsxs("div",{onClick:Ae=>Ae.stopPropagation(),style:{background:"var(--bg-card)",borderRadius:16,padding:24,maxWidth:360,width:"100%",boxShadow:"0 16px 48px rgba(0,0,0,0.2)",textAlign:"center"},children:[r.jsx(v0,{size:28,style:{color:"var(--text-primary)",marginBottom:12}}),r.jsx("h3",{style:{margin:"0 0 8px",fontSize:16,fontWeight:700,color:"var(--text-primary)"},children:n("memories.confirmShareTitle")}),r.jsx("p",{style:{margin:"0 0 20px",fontSize:13,color:"var(--text-muted)",lineHeight:1.5},children:n("memories.confirmShareHint",{count:v.size})}),r.jsxs("div",{style:{display:"flex",gap:8,justifyContent:"center"},children:[r.jsx("button",{onClick:()=>E(!1),style:{padding:"8px 20px",borderRadius:10,border:"1px solid var(--border-primary)",background:"none",fontSize:13,cursor:"pointer",fontFamily:"inherit",color:"var(--text-muted)"},children:n("common.cancel")}),r.jsx("button",{onClick:q,style:{padding:"8px 20px",borderRadius:10,border:"none",fontSize:13,fontWeight:600,cursor:"pointer",fontFamily:"inherit",background:"var(--text-primary)",color:"var(--bg-primary)"},children:n("memories.confirmShareButton")})]})]})})]})}return r.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",..._e},children:[r.jsx("div",{style:{padding:"16px 20px",borderBottom:"1px solid var(--border-secondary)",flexShrink:0},children:r.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[r.jsxs("div",{children:[r.jsx("h2",{style:{margin:0,fontSize:18,fontWeight:700,color:"var(--text-primary)"},children:n("memories.title")}),r.jsxs("p",{style:{margin:"2px 0 0",fontSize:12,color:"var(--text-faint)"},children:[de.length," ",n("memories.photosFound"),ce.length>0&&` · ${ce.length} ${n("memories.fromOthers")}`]})]}),o&&r.jsxs("button",{onClick:W,style:{display:"flex",alignItems:"center",gap:5,padding:"7px 14px",borderRadius:10,border:"none",background:"var(--text-primary)",color:"var(--bg-primary)",fontSize:12,fontWeight:600,cursor:"pointer",fontFamily:"inherit"},children:[r.jsx(Ft,{size:14})," ",n("memories.addPhotos")]})]})}),le.length>0&&r.jsxs("div",{style:{display:"flex",gap:6,padding:"8px 20px",borderBottom:"1px solid var(--border-secondary)",flexShrink:0,flexWrap:"wrap"},children:[r.jsxs("button",{onClick:()=>A(pe=>!pe),style:{display:"flex",alignItems:"center",gap:4,padding:"4px 10px",borderRadius:8,border:"1px solid var(--border-primary)",background:"var(--bg-card)",fontSize:11,cursor:"pointer",fontFamily:"inherit",color:"var(--text-muted)"},children:[r.jsx(bM,{size:11})," ",n(M?"memories.oldest":"memories.newest")]}),K.length>1&&r.jsxs("select",{value:P,onChange:pe=>R(pe.target.value),style:{padding:"4px 10px",borderRadius:8,border:"1px solid var(--border-primary)",background:"var(--bg-card)",fontSize:11,fontFamily:"inherit",color:"var(--text-muted)",cursor:"pointer",outline:"none"},children:[r.jsx("option",{value:"",children:n("memories.allLocations")}),K.map(pe=>r.jsx("option",{value:pe,children:pe},pe))]})]}),r.jsx("div",{style:{flex:1,overflowY:"auto",padding:12},children:de.length===0?r.jsxs("div",{style:{textAlign:"center",padding:"60px 20px"},children:[r.jsx(Ir,{size:40,style:{color:"var(--text-faint)",margin:"0 auto 12px",display:"block"}}),r.jsx("p",{style:{fontSize:14,fontWeight:600,color:"var(--text-secondary)",margin:"0 0 4px"},children:n("memories.noPhotos")}),r.jsx("p",{style:{fontSize:12,color:"var(--text-faint)",margin:"0 0 16px"},children:n("memories.noPhotosHint")}),r.jsxs("button",{onClick:W,style:{display:"inline-flex",alignItems:"center",gap:5,padding:"9px 18px",borderRadius:10,border:"none",background:"var(--text-primary)",color:"var(--bg-primary)",fontSize:13,fontWeight:600,cursor:"pointer",fontFamily:"inherit"},children:[r.jsx(Ft,{size:15})," ",n("memories.addPhotos")]})]}):r.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(130px, 1fr))",gap:6},children:de.map(pe=>{const Ae=pe.user_id===(i==null?void 0:i.id);return r.jsxs("div",{className:"group",style:{position:"relative",aspectRatio:"1",borderRadius:10,overflow:"visible",cursor:"pointer"},onClick:()=>{I(pe.immich_asset_id),H(pe.user_id),X(null),O(!0),ie.get(`/integrations/immich/assets/${pe.immich_asset_id}/info?userId=${pe.user_id}`).then(He=>X(He.data)).catch(()=>{}).finally(()=>O(!1))},children:[r.jsx("img",{src:Se(pe.immich_asset_id,pe.user_id),alt:"",loading:"lazy",style:{width:"100%",height:"100%",objectFit:"cover",borderRadius:10}}),!Ae&&r.jsxs("div",{className:"memories-avatar",style:{position:"absolute",bottom:6,left:6,zIndex:10},children:[r.jsx("div",{style:{width:22,height:22,borderRadius:"50%",background:`hsl(${pe.username.charCodeAt(0)*37%360}, 55%, 55%)`,display:"flex",alignItems:"center",justifyContent:"center",fontSize:10,fontWeight:700,color:"white",textTransform:"uppercase",border:"2px solid white",boxShadow:"0 1px 4px rgba(0,0,0,0.3)"},children:pe.username[0]}),r.jsx("div",{className:"memories-avatar-tooltip",style:{position:"absolute",bottom:"100%",left:"50%",transform:"translateX(-50%)",marginBottom:6,padding:"3px 8px",borderRadius:6,background:"var(--text-primary)",color:"var(--bg-primary)",fontSize:10,fontWeight:600,whiteSpace:"nowrap",pointerEvents:"none",opacity:0,transition:"opacity 0.15s"},children:pe.username})]}),Ae&&r.jsxs("div",{className:"opacity-0 group-hover:opacity-100",style:{position:"absolute",top:4,right:4,display:"flex",gap:3,transition:"opacity 0.15s"},children:[r.jsx("button",{onClick:He=>{He.stopPropagation(),oe(pe.immich_asset_id,!pe.shared)},title:pe.shared?n("memories.stopSharing"):n("memories.sharePhotos"),style:{width:26,height:26,borderRadius:"50%",border:"none",cursor:"pointer",background:"rgba(0,0,0,0.5)",backdropFilter:"blur(4px)",display:"flex",alignItems:"center",justifyContent:"center"},children:pe.shared?r.jsx(Mm,{size:12,color:"white"}):r.jsx(Dp,{size:12,color:"white"})}),r.jsx("button",{onClick:He=>{He.stopPropagation(),te(pe.immich_asset_id)},style:{width:26,height:26,borderRadius:"50%",border:"none",cursor:"pointer",background:"rgba(0,0,0,0.5)",backdropFilter:"blur(4px)",display:"flex",alignItems:"center",justifyContent:"center"},children:r.jsx(gt,{size:12,color:"white"})})]}),Ae&&!pe.shared&&r.jsxs("div",{style:{position:"absolute",bottom:6,right:6,padding:"2px 6px",borderRadius:6,background:"rgba(0,0,0,0.5)",backdropFilter:"blur(4px)",fontSize:9,color:"rgba(255,255,255,0.7)",fontWeight:500},children:[r.jsx(Dp,{size:9,style:{display:"inline",verticalAlign:"-1px",marginRight:3}}),n("memories.private")]})]},pe.immich_asset_id)})})}),r.jsx("style",{children:`
+ .memories-avatar:hover .memories-avatar-tooltip { opacity: 1 !important; }
+ `}),w&&r.jsx("div",{onClick:()=>E(!1),style:{position:"fixed",inset:0,zIndex:1e3,background:"rgba(0,0,0,0.4)",display:"flex",alignItems:"center",justifyContent:"center",padding:20},children:r.jsxs("div",{onClick:pe=>pe.stopPropagation(),style:{background:"var(--bg-card)",borderRadius:16,padding:24,maxWidth:360,width:"100%",boxShadow:"0 16px 48px rgba(0,0,0,0.2)",textAlign:"center"},children:[r.jsx(v0,{size:28,style:{color:"var(--text-primary)",marginBottom:12}}),r.jsx("h3",{style:{margin:"0 0 8px",fontSize:16,fontWeight:700,color:"var(--text-primary)"},children:n("memories.confirmShareTitle")}),r.jsx("p",{style:{margin:"0 0 20px",fontSize:13,color:"var(--text-muted)",lineHeight:1.5},children:n("memories.confirmShareHint",{count:v.size})}),r.jsxs("div",{style:{display:"flex",gap:8,justifyContent:"center"},children:[r.jsx("button",{onClick:()=>E(!1),style:{padding:"8px 20px",borderRadius:10,border:"1px solid var(--border-primary)",background:"none",fontSize:13,cursor:"pointer",fontFamily:"inherit",color:"var(--text-muted)"},children:n("common.cancel")}),r.jsx("button",{onClick:q,style:{padding:"8px 20px",borderRadius:10,border:"none",fontSize:13,fontWeight:600,cursor:"pointer",fontFamily:"inherit",background:"var(--text-primary)",color:"var(--bg-primary)"},children:n("memories.confirmShareButton")})]})]})}),$&&Y&&r.jsxs("div",{onClick:()=>{I(null),H(null)},style:{position:"absolute",inset:0,zIndex:100,background:"rgba(0,0,0,0.92)",display:"flex",alignItems:"center",justifyContent:"center"},children:[r.jsx("button",{onClick:()=>{I(null),H(null)},style:{position:"absolute",top:16,right:16,width:40,height:40,borderRadius:"50%",background:"rgba(255,255,255,0.1)",border:"none",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center"},children:r.jsx(gt,{size:20,color:"white"})}),r.jsxs("div",{onClick:pe=>pe.stopPropagation(),style:{display:"flex",gap:16,alignItems:"flex-start",justifyContent:"center",padding:20,width:"100%",height:"100%"},children:[r.jsx("img",{src:je($,Y),alt:"",style:{maxWidth:V?"calc(100% - 280px)":"100%",maxHeight:"100%",objectFit:"contain",borderRadius:10,cursor:"default"}}),V&&r.jsxs("div",{style:{width:240,flexShrink:0,borderRadius:16,padding:18,background:"rgba(255,255,255,0.08)",backdropFilter:"blur(20px)",WebkitBackdropFilter:"blur(20px)",border:"1px solid rgba(255,255,255,0.12)",color:"white",display:"flex",flexDirection:"column",gap:14,maxHeight:"100%",overflowY:"auto"},children:[V.takenAt&&r.jsxs("div",{children:[r.jsx("div",{style:{fontSize:9,fontWeight:700,textTransform:"uppercase",letterSpacing:"0.08em",color:"rgba(255,255,255,0.4)",marginBottom:3},children:"Date"}),r.jsx("div",{style:{fontSize:13,fontWeight:600},children:new Date(V.takenAt).toLocaleDateString(void 0,{day:"numeric",month:"long",year:"numeric"})}),r.jsx("div",{style:{fontSize:11,color:"rgba(255,255,255,0.5)"},children:new Date(V.takenAt).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"})})]}),(V.city||V.country)&&r.jsxs("div",{children:[r.jsxs("div",{style:{fontSize:9,fontWeight:700,textTransform:"uppercase",letterSpacing:"0.08em",color:"rgba(255,255,255,0.4)",marginBottom:3},children:[r.jsx(tn,{size:9,style:{display:"inline",verticalAlign:"-1px",marginRight:3}}),"Location"]}),r.jsx("div",{style:{fontSize:13,fontWeight:600},children:[V.city,V.state,V.country].filter(Boolean).join(", ")})]}),V.camera&&r.jsxs("div",{children:[r.jsx("div",{style:{fontSize:9,fontWeight:700,textTransform:"uppercase",letterSpacing:"0.08em",color:"rgba(255,255,255,0.4)",marginBottom:3},children:"Camera"}),r.jsx("div",{style:{fontSize:12,fontWeight:500},children:V.camera}),V.lens&&r.jsx("div",{style:{fontSize:11,color:"rgba(255,255,255,0.5)",marginTop:2},children:V.lens})]}),(V.focalLength||V.aperture||V.iso)&&r.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:8},children:[V.focalLength&&r.jsxs("div",{children:[r.jsx("div",{style:{fontSize:9,color:"rgba(255,255,255,0.4)",textTransform:"uppercase",letterSpacing:"0.05em"},children:"Focal"}),r.jsx("div",{style:{fontSize:13,fontWeight:700},children:V.focalLength})]}),V.aperture&&r.jsxs("div",{children:[r.jsx("div",{style:{fontSize:9,color:"rgba(255,255,255,0.4)",textTransform:"uppercase",letterSpacing:"0.05em"},children:"Aperture"}),r.jsx("div",{style:{fontSize:13,fontWeight:700},children:V.aperture})]}),V.shutter&&r.jsxs("div",{children:[r.jsx("div",{style:{fontSize:9,color:"rgba(255,255,255,0.4)",textTransform:"uppercase",letterSpacing:"0.05em"},children:"Shutter"}),r.jsx("div",{style:{fontSize:13,fontWeight:700},children:V.shutter})]}),V.iso&&r.jsxs("div",{children:[r.jsx("div",{style:{fontSize:9,color:"rgba(255,255,255,0.4)",textTransform:"uppercase",letterSpacing:"0.05em"},children:"ISO"}),r.jsx("div",{style:{fontSize:13,fontWeight:700},children:V.iso})]})]}),(V.width||V.fileName)&&r.jsxs("div",{style:{borderTop:"1px solid rgba(255,255,255,0.08)",paddingTop:10},children:[V.width&&V.height&&r.jsxs("div",{style:{fontSize:11,color:"rgba(255,255,255,0.4)",marginBottom:3},children:[V.width," × ",V.height]}),V.fileSize&&r.jsxs("div",{style:{fontSize:11,color:"rgba(255,255,255,0.4)"},children:[(V.fileSize/1024/1024).toFixed(1)," MB"]})]})]}),Z&&r.jsx("div",{style:{width:240,display:"flex",alignItems:"center",justifyContent:"center"},children:r.jsx("div",{className:"w-6 h-6 border-2 rounded-full animate-spin",style:{borderColor:"rgba(255,255,255,0.2)",borderTopColor:"white"}})})]})]})]})}const rh=[{value:"flight",labelKey:"reservations.type.flight",Icon:Or,color:"#3b82f6"},{value:"hotel",labelKey:"reservations.type.hotel",Icon:Rr,color:"#8b5cf6"},{value:"restaurant",labelKey:"reservations.type.restaurant",Icon:Cc,color:"#ef4444"},{value:"train",labelKey:"reservations.type.train",Icon:Ui,color:"#06b6d4"},{value:"car",labelKey:"reservations.type.car",Icon:Bi,color:"#6b7280"},{value:"cruise",labelKey:"reservations.type.cruise",Icon:Hi,color:"#0ea5e9"},{value:"event",labelKey:"reservations.type.event",Icon:kn,color:"#f59e0b"},{value:"tour",labelKey:"reservations.type.tour",Icon:Ur,color:"#10b981"},{value:"other",labelKey:"reservations.type.other",Icon:Pa,color:"#6b7280"}];function R4(e){return rh.find(t=>t.value===e)||rh[rh.length-1]}function M4(e,t){const a={};for(const n of e||[]){const i=((t==null?void 0:t[String(n.id)])||[]).slice().sort((o,s)=>o.order_index-s.order_index);for(const o of i)o.place&&(a[o.id]={dayNumber:n.day_number,dayTitle:n.title,dayDate:n.date,placeName:o.place.name,startTime:o.place.place_time,endTime:o.place.end_time})}return a}function W0({r:e,tripId:t,onEdit:a,onDelete:n,files:i=[],onNavigateToFiles:o,assignmentLookup:s}){var I;const{toggleReservationStatus:d}=Rn(),c=ya(),{t:p,locale:m}=ot(),g=ta(Y=>Y.settings.time_format)||"24h",f=ta(Y=>Y.settings.blur_booking_codes),[y,x]=b.useState(!1),k=R4(e.type),S=k.Icon,v=e.status==="confirmed",_=i.filter(Y=>Y.reservation_id===e.id||(Y.linked_reservation_ids||[]).includes(e.id)),w=e.assignment_id?s[e.assignment_id]:null,[E,M]=b.useState(!1),A=async()=>{try{await d(t,e.id)}catch{c.error(p("reservations.toast.updateError"))}},P=async()=>{M(!1);try{await n(e.id)}catch{c.error(p("reservations.toast.deleteError"))}},R=Y=>new Date(Y).toLocaleDateString(m,{weekday:"short",day:"numeric",month:"short"}),$=Y=>new Date(Y).toLocaleTimeString(m,{hour:"2-digit",minute:"2-digit",hour12:g==="12h"});return r.jsxs("div",{style:{borderRadius:12,overflow:"hidden",border:`1px solid ${v?"rgba(22,163,74,0.2)":"rgba(217,119,6,0.2)"}`},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"8px 12px",background:v?"rgba(22,163,74,0.06)":"rgba(217,119,6,0.06)"},children:[r.jsx("div",{style:{width:7,height:7,borderRadius:"50%",flexShrink:0,background:v?"#16a34a":"#d97706"}}),r.jsx("button",{onClick:A,style:{fontSize:10,fontWeight:700,color:v?"#16a34a":"#d97706",background:"none",border:"none",cursor:"pointer",padding:0,fontFamily:"inherit"},children:p(v?"reservations.confirmed":"reservations.pending")}),r.jsx("div",{style:{width:1,height:10,background:"var(--border-faint)"}}),r.jsx(S,{size:11,style:{color:k.color,flexShrink:0}}),r.jsx("span",{style:{fontSize:10,color:"var(--text-faint)"},children:p(k.labelKey)}),r.jsx("span",{style:{flex:1}}),r.jsx("span",{style:{fontSize:12,fontWeight:700,color:"var(--text-primary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.title}),r.jsx("button",{onClick:()=>a(e),title:p("common.edit"),style:{padding:3,background:"none",border:"none",cursor:"pointer",color:"var(--text-faint)",display:"flex",flexShrink:0},onMouseEnter:Y=>Y.currentTarget.style.color="var(--text-primary)",onMouseLeave:Y=>Y.currentTarget.style.color="var(--text-faint)",children:r.jsx(sn,{size:11})}),r.jsx("button",{onClick:()=>M(!0),title:p("common.delete"),style:{padding:3,background:"none",border:"none",cursor:"pointer",color:"var(--text-faint)",display:"flex",flexShrink:0},onMouseEnter:Y=>Y.currentTarget.style.color="#ef4444",onMouseLeave:Y=>Y.currentTarget.style.color="var(--text-faint)",children:r.jsx(_t,{size:11})})]}),(e.reservation_time||e.confirmation_number||e.location||w||e.metadata)&&r.jsxs("div",{style:{padding:"8px 12px",display:"flex",flexDirection:"column",gap:6},children:[(e.reservation_time||e.confirmation_number)&&r.jsxs("div",{style:{display:"flex",gap:0,borderRadius:8,overflow:"hidden",background:"var(--bg-secondary)",boxShadow:"0 1px 6px rgba(0,0,0,0.08)"},children:[e.reservation_time&&r.jsxs("div",{style:{flex:1,padding:"5px 10px",textAlign:"center",borderRight:"1px solid var(--border-faint)"},children:[r.jsx("div",{style:{fontSize:9,fontWeight:600,color:"var(--text-faint)",textTransform:"uppercase",letterSpacing:"0.03em"},children:p("reservations.date")}),r.jsx("div",{style:{fontSize:11,fontWeight:600,color:"var(--text-primary)",marginTop:1},children:R(e.reservation_time)})]}),((I=e.reservation_time)==null?void 0:I.includes("T"))&&r.jsxs("div",{style:{flex:1,padding:"5px 10px",textAlign:"center",borderRight:"1px solid var(--border-faint)"},children:[r.jsx("div",{style:{fontSize:9,fontWeight:600,color:"var(--text-faint)",textTransform:"uppercase",letterSpacing:"0.03em"},children:p("reservations.time")}),r.jsxs("div",{style:{fontSize:11,fontWeight:600,color:"var(--text-primary)",marginTop:1},children:[$(e.reservation_time),e.reservation_end_time?` – ${e.reservation_end_time}`:""]})]}),e.confirmation_number&&r.jsxs("div",{style:{flex:1,padding:"5px 10px",textAlign:"center"},children:[r.jsx("div",{style:{fontSize:9,fontWeight:600,color:"var(--text-faint)",textTransform:"uppercase",letterSpacing:"0.03em"},children:p("reservations.confirmationCode")}),r.jsx("div",{onMouseEnter:()=>f&&x(!0),onMouseLeave:()=>f&&x(!1),onClick:()=>f&&x(Y=>!Y),style:{fontSize:11,fontWeight:600,color:"var(--text-primary)",marginTop:1,filter:f&&!y?"blur(5px)":"none",cursor:f?"pointer":"default",transition:"filter 0.2s"},children:e.confirmation_number})]})]}),(()=>{const Y=typeof e.metadata=="string"?JSON.parse(e.metadata||"{}"):e.metadata||{};if(!Y||Object.keys(Y).length===0)return null;const H=[];return Y.airline&&H.push({label:p("reservations.meta.airline"),value:Y.airline}),Y.flight_number&&H.push({label:p("reservations.meta.flightNumber"),value:Y.flight_number}),Y.departure_airport&&H.push({label:p("reservations.meta.from"),value:Y.departure_airport}),Y.arrival_airport&&H.push({label:p("reservations.meta.to"),value:Y.arrival_airport}),Y.train_number&&H.push({label:p("reservations.meta.trainNumber"),value:Y.train_number}),Y.platform&&H.push({label:p("reservations.meta.platform"),value:Y.platform}),Y.seat&&H.push({label:p("reservations.meta.seat"),value:Y.seat}),Y.check_in_time&&H.push({label:p("reservations.meta.checkIn"),value:Y.check_in_time}),Y.check_out_time&&H.push({label:p("reservations.meta.checkOut"),value:Y.check_out_time}),H.length===0?null:r.jsx("div",{style:{display:"flex",gap:0,borderRadius:8,overflow:"hidden",background:"var(--bg-secondary)",boxShadow:"0 1px 6px rgba(0,0,0,0.08)"},children:H.map((V,X)=>r.jsxs("div",{style:{flex:1,padding:"5px 10px",textAlign:"center",borderRight:X0&&r.jsxs("div",{style:{padding:"0 12px 8px"},children:[r.jsx("div",{style:{fontSize:9,fontWeight:600,color:"var(--text-faint)",textTransform:"uppercase",letterSpacing:"0.03em",marginBottom:3},children:p("files.title")}),r.jsx("div",{style:{padding:"4px 8px",borderRadius:7,background:"var(--bg-secondary)",display:"flex",flexDirection:"column",gap:3},children:_.map(Y=>r.jsxs("a",{href:Y.url,target:"_blank",rel:"noreferrer",style:{display:"flex",alignItems:"center",gap:4,textDecoration:"none",cursor:"pointer"},children:[r.jsx(Pa,{size:9,style:{color:"var(--text-faint)",flexShrink:0}}),r.jsx("span",{style:{fontSize:10,color:"var(--text-muted)",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:Y.original_name})]},Y.id))})]}),E&&Vt.createPortal(r.jsx("div",{style:{position:"fixed",inset:0,zIndex:1e3,display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(0,0,0,0.3)",backdropFilter:"blur(3px)"},onClick:()=>M(!1),children:r.jsxs("div",{style:{width:340,background:"var(--bg-card)",borderRadius:16,boxShadow:"0 16px 48px rgba(0,0,0,0.22)",padding:"22px 22px 18px",display:"flex",flexDirection:"column",gap:12},onClick:Y=>Y.stopPropagation(),children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[r.jsx("div",{style:{width:36,height:36,flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"50%",background:"rgba(239,68,68,0.12)"},children:r.jsx(_t,{size:18,strokeWidth:1.8,color:"#ef4444"})}),r.jsx("div",{style:{fontSize:14,fontWeight:600,color:"var(--text-primary)"},children:p("reservations.confirm.deleteTitle")})]}),r.jsx("div",{style:{fontSize:12.5,color:"var(--text-secondary)",lineHeight:1.5},children:p("reservations.confirm.deleteBody",{name:e.title})}),r.jsxs("div",{style:{display:"flex",gap:8,justifyContent:"flex-end",marginTop:4},children:[r.jsx("button",{onClick:()=>M(!1),style:{fontSize:12,background:"none",border:"1px solid var(--border-primary)",borderRadius:8,padding:"6px 14px",cursor:"pointer",color:"var(--text-muted)",fontFamily:"inherit"},children:p("common.cancel")}),r.jsx("button",{onClick:P,style:{fontSize:12,background:"#ef4444",color:"white",border:"none",borderRadius:8,padding:"6px 16px",cursor:"pointer",fontWeight:600,fontFamily:"inherit"},children:p("common.confirm")})]})]})}),document.body)]})}function $0({title:e,count:t,children:a,defaultOpen:n=!0,accent:i}){const[o,s]=b.useState(n);return r.jsxs("div",{style:{marginBottom:16},children:[r.jsxs("button",{onClick:()=>s(d=>!d),style:{display:"flex",alignItems:"center",gap:8,width:"100%",background:"none",border:"none",cursor:"pointer",padding:"4px 0",marginBottom:8,fontFamily:"inherit"},children:[o?r.jsx(en,{size:14,style:{color:"var(--text-faint)"}}):r.jsx(Ao,{size:14,style:{color:"var(--text-faint)"}}),r.jsx("span",{style:{fontWeight:700,fontSize:12,color:"var(--text-primary)",textTransform:"uppercase",letterSpacing:"0.03em"},children:e}),r.jsx("span",{style:{fontSize:10,fontWeight:700,padding:"1px 7px",borderRadius:99,background:i==="green"?"rgba(22,163,74,0.1)":"var(--bg-tertiary)",color:i==="green"?"#16a34a":"var(--text-faint)"},children:t})]}),o&&r.jsx("div",{style:{display:"flex",flexDirection:"column",gap:8},children:a})]})}function D4({tripId:e,reservations:t,days:a,assignments:n,files:i=[],onAdd:o,onEdit:s,onDelete:d,onNavigateToFiles:c}){const{t:p,locale:m}=ot(),[g,f]=b.useState(()=>!localStorage.getItem("hideReservationHint")),y=b.useMemo(()=>M4(a,n),[a,n]),x=t.filter(v=>v.status!=="confirmed"),k=t.filter(v=>v.status==="confirmed"),S=t.length;return r.jsxs("div",{style:{height:"100%",display:"flex",flexDirection:"column",fontFamily:"-apple-system, BlinkMacSystemFont, 'SF Pro Text', system-ui, sans-serif"},children:[r.jsxs("div",{style:{padding:"20px 24px 16px",borderBottom:"1px solid var(--border-faint)",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[r.jsxs("div",{children:[r.jsx("h2",{style:{margin:0,fontSize:18,fontWeight:700,color:"var(--text-primary)"},children:p("reservations.title")}),r.jsx("p",{style:{margin:"2px 0 0",fontSize:12,color:"var(--text-faint)"},children:S===0?p("reservations.empty"):p("reservations.summary",{confirmed:k.length,pending:x.length})})]}),r.jsxs("button",{onClick:o,style:{display:"flex",alignItems:"center",gap:5,padding:"7px 14px",borderRadius:99,border:"none",background:"var(--accent)",color:"var(--accent-text)",fontSize:12,fontWeight:600,cursor:"pointer",fontFamily:"inherit"},children:[r.jsx(Ft,{size:13})," ",r.jsx("span",{className:"hidden sm:inline",children:p("reservations.addManual")})]})]}),r.jsx("div",{style:{flex:1,overflowY:"auto",padding:"16px 24px"},children:S===0?r.jsxs("div",{style:{textAlign:"center",padding:"60px 20px"},children:[r.jsx(c_,{size:36,style:{color:"var(--text-faint)",display:"block",margin:"0 auto 12px"}}),r.jsx("p",{style:{fontSize:14,fontWeight:600,color:"var(--text-secondary)",margin:"0 0 4px"},children:p("reservations.empty")}),r.jsx("p",{style:{fontSize:12,color:"var(--text-faint)",margin:0},children:p("reservations.emptyHint")})]}):r.jsxs(r.Fragment,{children:[x.length>0&&r.jsx($0,{title:p("reservations.pending"),count:x.length,accent:"gray",children:r.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-3",children:x.map(v=>r.jsx(W0,{r:v,tripId:e,onEdit:s,onDelete:d,files:i,onNavigateToFiles:c,assignmentLookup:y},v.id))})}),k.length>0&&r.jsx($0,{title:p("reservations.confirmed"),count:k.length,accent:"green",children:r.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-3",children:k.map(v=>r.jsx(W0,{r:v,tripId:e,onEdit:s,onDelete:d,files:i,onNavigateToFiles:c,assignmentLookup:y},v.id))})})]})})]})}const hu=["#3b82f6","#a855f7","#ec4899","#22c55e","#f97316","#06b6d4","#ef4444","#eab308","#8b5cf6","#14b8a6"];function Yf(e,t){const a=t?t.indexOf(e):-1;if(a>=0)return hu[a%hu.length];let n=0;for(let i=0;iM(t,e.id,!e.checked),Y=async()=>{if(!p.trim()){c(!1),m(e.name);return}try{await A(t,e.id,{name:p.trim()}),c(!1)}catch{R.error($("packing.toast.saveError"))}},H=async()=>{try{await P(t,e.id)}catch{R.error($("packing.toast.deleteError"))}},V=async O=>{if(x(!1),O!==e.category)try{await A(t,e.id,{category:O})}catch{R.error($("common.error"))}};return r.jsxs("div",{className:"group",onMouseEnter:()=>f(!0),onMouseLeave:()=>{f(!1),x(!1),S(!1)},style:{display:"flex",alignItems:"center",gap:8,padding:"6px 10px",borderRadius:10,position:"relative",background:g?"var(--bg-secondary)":"transparent",transition:"background 0.1s"},children:[r.jsx("button",{onClick:I,style:{flexShrink:0,background:"none",border:"none",cursor:"pointer",padding:0,display:"flex",color:e.checked?"#10b981":"var(--text-faint)",transition:"color 0.15s"},children:e.checked?r.jsx(p_,{size:18}):r.jsx(mD,{size:18})}),d?r.jsx("input",{type:"text",value:p,autoFocus:!0,onChange:O=>m(O.target.value),onBlur:Y,onKeyDown:O=>{O.key==="Enter"&&Y(),O.key==="Escape"&&(c(!1),m(e.name))},style:{flex:1,fontSize:13.5,padding:"2px 8px",borderRadius:6,border:"1px solid var(--border-primary)",outline:"none",fontFamily:"inherit"}}):r.jsx("span",{onClick:()=>!e.checked&&c(!0),style:{flex:1,fontSize:13.5,cursor:e.checked?"default":"text",color:e.checked?"var(--text-faint)":"var(--text-primary)",textDecoration:e.checked?"line-through":"none"},children:e.name}),i&&r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,flexShrink:0},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:2,border:"1px solid var(--border-primary)",borderRadius:8,padding:"3px 6px",background:"transparent"},children:[r.jsx("input",{type:"text",inputMode:"numeric",value:e.weight_grams??"",onChange:async O=>{const Q=O.target.value.replace(/[^0-9]/g,""),D=Q===""?null:parseInt(Q);try{await A(t,e.id,{weight_grams:D})}catch{}},placeholder:"—",style:{width:36,border:"none",fontSize:12,textAlign:"right",fontFamily:"inherit",outline:"none",color:"var(--text-secondary)",background:"transparent",padding:0}}),r.jsx("span",{style:{fontSize:10,color:"var(--text-faint)",userSelect:"none"},children:"g"})]}),r.jsxs("div",{style:{position:"relative"},children:[r.jsx("button",{onClick:()=>S(O=>!O),style:{width:22,height:22,borderRadius:"50%",cursor:"pointer",padding:0,display:"flex",alignItems:"center",justifyContent:"center",border:e.bag_id?`2.5px solid ${((X=o.find(O=>O.id===e.bag_id))==null?void 0:X.color)||"var(--border-primary)"}`:"2px dashed var(--border-primary)",background:e.bag_id?`${((Z=o.find(O=>O.id===e.bag_id))==null?void 0:Z.color)||"var(--border-primary)"}30`:"transparent"},children:!e.bag_id&&r.jsx(rc,{size:9,style:{color:"var(--text-faint)"}})}),k&&r.jsxs("div",{style:{position:"absolute",right:0,top:"100%",marginTop:4,zIndex:50,background:"var(--bg-card)",border:"1px solid var(--border-primary)",borderRadius:10,boxShadow:"0 4px 16px rgba(0,0,0,0.12)",padding:4,minWidth:160},children:[e.bag_id&&r.jsxs("button",{onClick:async()=>{S(!1);try{await A(t,e.id,{bag_id:null})}catch{}},style:{display:"flex",alignItems:"center",gap:7,width:"100%",padding:"6px 10px",background:"none",border:"none",cursor:"pointer",fontSize:12,fontFamily:"inherit",color:"var(--text-faint)",borderRadius:7},children:[r.jsx("span",{style:{width:10,height:10,borderRadius:"50%",border:"2px dashed var(--border-primary)"}}),$("packing.noBag")]}),o.map(O=>r.jsxs("button",{onClick:async()=>{S(!1);try{await A(t,e.id,{bag_id:O.id})}catch{}},style:{display:"flex",alignItems:"center",gap:7,width:"100%",padding:"6px 10px",background:e.bag_id===O.id?"var(--bg-tertiary)":"none",border:"none",cursor:"pointer",fontSize:12,fontFamily:"inherit",color:"var(--text-secondary)",borderRadius:7},onMouseEnter:Q=>{e.bag_id!==O.id&&(Q.currentTarget.style.background="var(--bg-tertiary)")},onMouseLeave:Q=>{e.bag_id!==O.id&&(Q.currentTarget.style.background="none")},children:[r.jsx("span",{style:{width:10,height:10,borderRadius:"50%",background:O.color,flexShrink:0}}),O.name]},O.id)),o.length>0&&r.jsx("div",{style:{height:1,background:"var(--bg-tertiary)",margin:"4px 0"}}),r.jsx("div",{style:{padding:"4px 6px"},children:v?r.jsxs("div",{style:{display:"flex",gap:4},children:[r.jsx("input",{autoFocus:!0,value:w,onChange:O=>E(O.target.value),onKeyDown:async O=>{if(O.key==="Enter"&&w.trim()){const Q=await s(w.trim());if(Q)try{await A(t,e.id,{bag_id:Q.id})}catch{}E(""),_(!1),S(!1)}O.key==="Escape"&&(_(!1),E(""))},placeholder:$("packing.bagName"),style:{flex:1,padding:"4px 8px",borderRadius:6,border:"1px solid var(--border-primary)",fontSize:11,fontFamily:"inherit",outline:"none"}}),r.jsx("button",{onClick:async()=>{if(w.trim()){const O=await s(w.trim());if(O)try{await A(t,e.id,{bag_id:O.id})}catch{}E(""),_(!1),S(!1)}},style:{padding:"3px 6px",borderRadius:6,border:"none",background:"var(--text-primary)",color:"var(--bg-primary)",cursor:"pointer",display:"flex",alignItems:"center"},children:r.jsx(Ft,{size:11})})]}):r.jsxs("button",{onClick:()=>_(!0),style:{display:"flex",alignItems:"center",gap:5,width:"100%",padding:"5px 6px",background:"none",border:"none",cursor:"pointer",fontSize:11,fontFamily:"inherit",color:"var(--text-faint)",borderRadius:7},onMouseEnter:O=>O.currentTarget.style.color="var(--text-secondary)",onMouseLeave:O=>O.currentTarget.style.color="var(--text-faint)",children:[r.jsx(Ft,{size:11})," ",$("packing.addBag")]})})]})]})]}),r.jsxs("div",{className:"sm:opacity-0 sm:group-hover:opacity-100",style:{display:"flex",gap:2,alignItems:"center",transition:"opacity 0.12s",flexShrink:0},children:[r.jsxs("div",{style:{position:"relative"},children:[r.jsx("button",{onClick:()=>x(O=>!O),title:$("packing.changeCategory"),style:{background:"none",border:"none",cursor:"pointer",padding:"3px 5px",borderRadius:6,display:"flex",alignItems:"center",color:"var(--text-faint)",fontSize:10,gap:2},children:r.jsx("span",{style:{width:7,height:7,borderRadius:"50%",background:Yf(e.category||$("packing.defaultCategory"),a),display:"inline-block"}})}),y&&r.jsx("div",{style:{position:"absolute",right:0,top:"100%",zIndex:50,background:"var(--bg-card)",border:"1px solid var(--border-primary)",borderRadius:10,boxShadow:"0 4px 16px rgba(0,0,0,0.1)",padding:4,minWidth:140},children:a.map(O=>r.jsxs("button",{onClick:()=>V(O),style:{display:"flex",alignItems:"center",gap:7,width:"100%",padding:"6px 10px",background:O===(e.category||$("packing.defaultCategory"))?"var(--bg-tertiary)":"none",border:"none",cursor:"pointer",fontSize:12.5,fontFamily:"inherit",color:"var(--text-secondary)",borderRadius:7,textAlign:"left"},children:[r.jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:Yf(O,a),flexShrink:0}}),O]},O))})]}),r.jsx("button",{onClick:()=>c(!0),title:$("common.rename"),style:{background:"none",border:"none",cursor:"pointer",padding:"3px 4px",borderRadius:6,display:"flex",color:"var(--text-faint)"},onMouseEnter:O=>O.currentTarget.style.color="var(--text-secondary)",onMouseLeave:O=>O.currentTarget.style.color="var(--text-faint)",children:r.jsx(sn,{size:13})}),r.jsx("button",{onClick:H,title:$("common.delete"),style:{background:"none",border:"none",cursor:"pointer",padding:"3px 4px",borderRadius:6,display:"flex",color:"var(--text-faint)"},onMouseEnter:O=>O.currentTarget.style.color="#ef4444",onMouseLeave:O=>O.currentTarget.style.color="var(--text-faint)",children:r.jsx(_t,{size:13})})]})]})}function L4({kategorie:e,items:t,tripId:a,allCategories:n,onRename:i,onDeleteAll:o,onAddItem:s,assignees:d,tripMembers:c,onSetAssignees:p,bagTrackingEnabled:m,bags:g,onCreateBag:f}){const[y,x]=b.useState(!0),[k,S]=b.useState(!1),[v,_]=b.useState(e),[w,E]=b.useState(!1),[M,A]=b.useState(!1),[P,R]=b.useState(!1),[$,I]=b.useState(""),Y=b.useRef(null),H=b.useRef(null),{togglePackingItem:V}=Rn(),X=ya(),{t:Z}=ot();b.useEffect(()=>{if(!M)return;const C=U=>{H.current&&!H.current.contains(U.target)&&A(!1)};return document.addEventListener("mousedown",C),()=>document.removeEventListener("mousedown",C)},[M]);const O=t.filter(C=>C.checked).length,Q=O===t.length,D=Yf(e,n),J=async()=>{const C=v.trim();if(!C||C===e){S(!1),_(e);return}try{await i(e,C),S(!1)}catch{X.error(Z("packing.toast.renameError"))}},z=async()=>{for(const C of Array.from(t))C.checked||await V(a,C.id,!0)},W=async()=>{for(const C of Array.from(t))C.checked&&await V(a,C.id,!1)},B=async()=>{await o(t),E(!1)};return r.jsxs("div",{style:{marginBottom:6,background:"var(--bg-card)",borderRadius:14,border:"1px solid var(--border-secondary)",overflow:"visible"},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"10px 12px",borderBottom:y?"1px solid var(--border-secondary)":"none"},children:[r.jsx("button",{onClick:()=>x(C=>!C),style:{background:"none",border:"none",cursor:"pointer",padding:0,display:"flex",color:"var(--text-faint)",flexShrink:0},children:y?r.jsx(en,{size:15}):r.jsx(Ao,{size:15})}),r.jsx("span",{style:{width:10,height:10,borderRadius:"50%",background:D,flexShrink:0}}),k?r.jsx("input",{autoFocus:!0,value:v,onChange:C=>_(C.target.value),onBlur:J,onKeyDown:C=>{C.key==="Enter"&&J(),C.key==="Escape"&&(S(!1),_(e))},style:{flex:1,fontSize:12.5,fontWeight:600,border:"none",borderBottom:"2px solid var(--text-primary)",outline:"none",background:"transparent",fontFamily:"inherit",color:"var(--text-primary)",padding:"0 2px"}}):r.jsx("span",{style:{fontSize:12.5,fontWeight:700,color:"var(--text-secondary)",textTransform:"uppercase",letterSpacing:"0.04em"},children:e}),r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:3,flex:1,minWidth:0,marginLeft:4},children:[d.map(C=>r.jsxs("div",{style:{position:"relative"},onClick:U=>{U.stopPropagation(),p(e,d.filter(q=>q.user_id!==C.user_id).map(q=>q.user_id))},children:[r.jsx("div",{className:"assignee-chip",style:{width:22,height:22,borderRadius:"50%",flexShrink:0,cursor:"pointer",background:`hsl(${C.username.charCodeAt(0)*37%360}, 55%, 55%)`,display:"flex",alignItems:"center",justifyContent:"center",fontSize:10,fontWeight:700,color:"white",textTransform:"uppercase",border:"2px solid var(--bg-card)",transition:"opacity 0.15s"},children:C.username[0]}),r.jsx("div",{className:"assignee-tooltip",style:{position:"absolute",top:"100%",left:"50%",transform:"translateX(-50%)",marginTop:6,padding:"3px 8px",borderRadius:6,zIndex:60,background:"var(--text-primary)",color:"var(--bg-primary)",fontSize:10,fontWeight:600,whiteSpace:"nowrap",pointerEvents:"none",opacity:0,transition:"opacity 0.15s"},children:C.username})]},C.user_id)),r.jsxs("div",{ref:H,style:{position:"relative"},children:[r.jsx("button",{onClick:C=>{C.stopPropagation(),A(U=>!U)},style:{width:20,height:20,borderRadius:"50%",border:"1.5px dashed var(--border-primary)",background:"none",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",color:"var(--text-faint)",flexShrink:0,padding:0,transition:"all 0.15s"},onMouseEnter:C=>{C.currentTarget.style.borderColor="var(--text-muted)",C.currentTarget.style.color="var(--text-muted)"},onMouseLeave:C=>{C.currentTarget.style.borderColor="var(--border-primary)",C.currentTarget.style.color="var(--text-faint)"},children:r.jsx(_c,{size:10})}),M&&r.jsxs("div",{style:{position:"absolute",left:0,top:"100%",marginTop:4,zIndex:50,background:"var(--bg-card)",border:"1px solid var(--border-primary)",borderRadius:10,boxShadow:"0 4px 16px rgba(0,0,0,0.12)",padding:4,minWidth:160},children:[c.map(C=>{const U=d.some(q=>q.user_id===C.id);return r.jsxs("button",{onClick:q=>{q.stopPropagation();const te=U?d.filter(oe=>oe.user_id!==C.id).map(oe=>oe.user_id):[...d.map(oe=>oe.user_id),C.id];p(e,te)},style:{display:"flex",alignItems:"center",gap:8,width:"100%",padding:"6px 10px",borderRadius:8,border:"none",cursor:"pointer",background:U?"var(--bg-hover)":"transparent",fontFamily:"inherit",fontSize:12,color:"var(--text-primary)",transition:"background 0.1s"},onMouseEnter:q=>{U||(q.currentTarget.style.background="var(--bg-tertiary)")},onMouseLeave:q=>{U||(q.currentTarget.style.background="transparent")},children:[r.jsx("div",{style:{width:20,height:20,borderRadius:"50%",flexShrink:0,background:`hsl(${C.username.charCodeAt(0)*37%360}, 55%, 55%)`,display:"flex",alignItems:"center",justifyContent:"center",fontSize:10,fontWeight:700,color:"white",textTransform:"uppercase"},children:C.username[0]}),r.jsx("span",{style:{flex:1},children:C.username}),U&&r.jsx(Ga,{size:12,style:{color:"var(--text-muted)"}})]},C.id)}),c.length===0&&r.jsx("div",{style:{padding:"8px 10px",fontSize:11,color:"var(--text-faint)"},children:Z("packing.noMembers")})]})]})]}),r.jsxs("span",{style:{fontSize:11,fontWeight:600,padding:"1px 8px",borderRadius:99,background:Q?"rgba(22,163,74,0.12)":"var(--bg-tertiary)",color:Q?"#16a34a":"var(--text-muted)"},children:[O,"/",t.length]}),r.jsxs("div",{style:{position:"relative"},children:[r.jsx("button",{onClick:()=>E(C=>!C),style:{background:"none",border:"none",cursor:"pointer",padding:"2px 4px",borderRadius:6,display:"flex",color:"var(--text-faint)"},onMouseEnter:C=>C.currentTarget.style.color="var(--text-secondary)",onMouseLeave:C=>C.currentTarget.style.color="var(--text-faint)",children:r.jsx(XM,{size:15})}),w&&r.jsxs("div",{style:{position:"absolute",right:0,top:"100%",zIndex:50,background:"var(--bg-card)",border:"1px solid var(--border-primary)",borderRadius:10,boxShadow:"0 4px 16px rgba(0,0,0,0.1)",padding:4,minWidth:170},onMouseLeave:()=>E(!1),children:[r.jsx(fu,{icon:r.jsx(sn,{size:13}),label:Z("packing.menuRename"),onClick:()=>{S(!0),E(!1)}}),r.jsx(fu,{icon:r.jsx(CM,{size:13}),label:Z("packing.menuCheckAll"),onClick:()=>{z(),E(!1)}}),r.jsx(fu,{icon:r.jsx(Fm,{size:13}),label:Z("packing.menuUncheckAll"),onClick:()=>{W(),E(!1)}}),r.jsx("div",{style:{height:1,background:"var(--bg-tertiary)",margin:"4px 0"}}),r.jsx(fu,{icon:r.jsx(_t,{size:13}),label:Z("packing.menuDeleteCat"),danger:!0,onClick:B})]})]})]}),y&&r.jsxs("div",{style:{padding:"4px 4px 6px"},children:[t.map(C=>r.jsx(I4,{item:C,tripId:a,categories:n,onCategoryChange:()=>{},bagTrackingEnabled:m,bags:g,onCreateBag:f},C.id)),P?r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,padding:"4px 8px"},children:[r.jsx("input",{ref:Y,autoFocus:!0,value:$,onChange:C=>I(C.target.value),onKeyDown:C=>{C.key==="Enter"&&$.trim()&&(s(e,$.trim()),I(""),setTimeout(()=>{var U;return(U=Y.current)==null?void 0:U.focus()},30)),C.key==="Escape"&&(R(!1),I(""))},placeholder:Z("packing.addItemPlaceholder"),style:{flex:1,padding:"6px 10px",borderRadius:8,border:"1px solid var(--border-primary)",fontSize:12.5,fontFamily:"inherit",outline:"none",color:"var(--text-primary)",background:"var(--bg-input)"}}),r.jsx("button",{onClick:()=>{$.trim()&&(s(e,$.trim()),I(""),setTimeout(()=>{var C;return(C=Y.current)==null?void 0:C.focus()},30))},disabled:!$.trim(),style:{padding:"5px 8px",borderRadius:8,border:"none",background:$.trim()?"var(--text-primary)":"var(--border-primary)",color:"var(--bg-primary)",cursor:$.trim()?"pointer":"default",display:"flex"},children:r.jsx(Ft,{size:14})}),r.jsx("button",{onClick:()=>{R(!1),I("")},style:{background:"none",border:"none",cursor:"pointer",padding:2,display:"flex",color:"var(--text-faint)"},children:r.jsx(gt,{size:14})})]}):r.jsxs("button",{onClick:()=>{R(!0),setTimeout(()=>{var C;return(C=Y.current)==null?void 0:C.focus()},30)},style:{display:"flex",alignItems:"center",gap:5,padding:"5px 10px",margin:"2px 4px",borderRadius:8,border:"none",background:"none",cursor:"pointer",fontSize:12,color:"var(--text-faint)",fontFamily:"inherit"},onMouseEnter:C=>C.currentTarget.style.color="var(--text-secondary)",onMouseLeave:C=>C.currentTarget.style.color="var(--text-faint)",children:[r.jsx(Ft,{size:12})," ",Z("packing.addItem")]})]})]})}function fu({icon:e,label:t,onClick:a,danger:n}){return r.jsxs("button",{onClick:a,style:{display:"flex",alignItems:"center",gap:8,width:"100%",padding:"7px 10px",background:"none",border:"none",cursor:"pointer",fontSize:12.5,fontFamily:"inherit",borderRadius:7,textAlign:"left",color:n?"#ef4444":"var(--text-secondary)"},onMouseEnter:i=>i.currentTarget.style.background=n?"#fef2f2":"var(--bg-tertiary)",onMouseLeave:i=>i.currentTarget.style.background="none",children:[e,t]})}function F4({tripId:e,items:t}){const[a,n]=b.useState("alle"),[i,o]=b.useState(!1),[s,d]=b.useState(""),{addPackingItem:c,updatePackingItem:p,deletePackingItem:m}=Rn(),g=ya(),{t:f}=ot(),[y,x]=b.useState([]),[k,S]=b.useState({});b.useEffect(()=>{Ba.getMembers(e).then(G=>{const ve=[];G.owner&&ve.push({id:G.owner.id,username:G.owner.username,avatar:G.owner.avatar_url}),G.members&&ve.push(...G.members.map(Pe=>({id:Pe.id,username:Pe.username,avatar:Pe.avatar_url}))),x(ve)}).catch(()=>{}),Un.getCategoryAssignees(e).then(G=>{S(G.assignees||{})}).catch(()=>{})},[e]);const v=async(G,ve)=>{try{const Pe=await Un.setCategoryAssignees(e,G,ve);S(ye=>({...ye,[G]:Pe.assignees||[]}))}catch{g.error(f("packing.toast.saveError"))}},_=b.useMemo(()=>{const G=[];for(const ve of t){const Pe=ve.category||f("packing.defaultCategory");G.includes(Pe)||G.push(Pe)}return G},[t,f]),w=b.useMemo(()=>{const G=t.filter(Pe=>a==="offen"?!Pe.checked:a==="erledigt"?Pe.checked:!0),ve={};for(const Pe of G){const ye=Pe.category||f("packing.defaultCategory");ve[ye]||(ve[ye]=[]),ve[ye].push(Pe)}return ve},[t,a,f]),E=t.filter(G=>G.checked).length,M=t.length>0?Math.round(E/t.length*100):0,A=async(G,ve)=>{try{await c(e,{name:ve,category:G})}catch{g.error(f("packing.toast.addError"))}},P=async()=>{if(!s.trim())return;let G=s.trim();for(;_.includes(G);)G+="";try{await c(e,{name:"...",category:G}),d(""),o(!1)}catch{g.error(f("packing.toast.addError"))}},R=async(G,ve)=>{const Pe=t.filter(ye=>(ye.category||f("packing.defaultCategory"))===G);for(const ye of Pe)await p(e,ye.id,{category:ve})},$=async G=>{for(const ve of G)try{await m(e,ve.id)}catch{}},I=async()=>{if(confirm(f("packing.confirm.clearChecked",{count:E})))for(const G of t.filter(ve=>ve.checked))try{await m(e,G.id)}catch{}},[Y,H]=b.useState(!1),[V,X]=b.useState([]),[Z,O]=b.useState(""),[Q,D]=b.useState(!1),[J,z]=b.useState(!1);b.useEffect(()=>{Rt.getBagTracking().then(G=>{H(G.enabled),G.enabled&&Un.listBags(e).then(ve=>X(ve.bags||[])).catch(()=>{})}).catch(()=>{})},[e]);const W=["#6366f1","#ec4899","#f97316","#10b981","#06b6d4","#8b5cf6","#ef4444","#f59e0b"],B=async()=>{if(Z.trim())try{const G=await Un.createBag(e,{name:Z.trim(),color:W[V.length%W.length]});X(ve=>[...ve,G.bag]),O(""),D(!1)}catch{g.error(f("packing.toast.saveError"))}},C=async G=>{try{const ve=await Un.createBag(e,{name:G,color:W[V.length%W.length]});return X(Pe=>[...Pe,ve.bag]),ve.bag}catch{g.error(f("packing.toast.saveError"));return}},U=async G=>{try{await Un.deleteBag(e,G),X(ve=>ve.filter(Pe=>Pe.id!==G))}catch{g.error(f("packing.toast.deleteError"))}},[q,te]=b.useState([]),[oe,be]=b.useState(!1),[Se,je]=b.useState(!1),[we,ce]=b.useState(!1),[le,K]=b.useState(""),de=b.useRef(null),_e=b.useRef(null);b.useEffect(()=>{Rt.packingTemplates().then(G=>te(G.templates||[])).catch(()=>{})},[e]),b.useEffect(()=>{if(!oe)return;const G=ve=>{_e.current&&!_e.current.contains(ve.target)&&be(!1)};return document.addEventListener("mousedown",G),()=>document.removeEventListener("mousedown",G)},[oe]);const pe=async G=>{je(!0);try{const ve=await Un.applyTemplate(e,G);g.success(f("packing.templateApplied",{count:ve.count})),be(!1),window.location.reload()}catch{g.error(f("packing.templateError"))}finally{je(!1)}},Ae=G=>G.split(`
+`).map(ve=>ve.trim()).filter(Boolean).map(ve=>{var ye;const Pe=ve.split(/[,;\t]/).map(ne=>ne.trim());if(Pe.length>=2){const ne=Pe[0],fe=Pe[1],Ee=Pe[2]||void 0,Oe=Pe[3]||void 0,Ke=((ye=Pe[4])==null?void 0:ye.toLowerCase())==="checked"||Pe[4]==="1";return{name:fe,category:ne,weight_grams:Ee,bag:Oe,checked:Ke}}return{name:Pe[0],category:void 0,weight_grams:void 0,bag:void 0,checked:!1}}).filter(ve=>ve.name),He=async()=>{const G=Ae(le);if(G.length===0){g.error(f("packing.importEmpty"));return}try{const ve=await Un.bulkImport(e,G);g.success(f("packing.importSuccess",{count:ve.count})),K(""),ce(!1),window.location.reload()}catch{g.error(f("packing.importError"))}},ze=G=>{var ye;const ve=(ye=G.target.files)==null?void 0:ye[0];if(!ve)return;G.target.value="";const Pe=new FileReader;Pe.onload=()=>{typeof Pe.result=="string"&&K(Pe.result)},Pe.readAsText(ve)},Ye={fontFamily:"-apple-system, BlinkMacSystemFont, 'SF Pro Text', system-ui, sans-serif"};return r.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",...Ye},children:[r.jsxs("div",{style:{padding:"20px 24px 16px",borderBottom:"1px solid rgba(0,0,0,0.06)",flexShrink:0},children:[r.jsxs("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",marginBottom:14},children:[r.jsxs("div",{children:[r.jsx("h2",{style:{margin:0,fontSize:18,fontWeight:700,color:"var(--text-primary)"},children:f("packing.title")}),r.jsx("p",{style:{margin:"2px 0 0",fontSize:12.5,color:"var(--text-faint)"},children:t.length===0?f("packing.empty"):f("packing.progress",{packed:E,total:t.length,percent:M})})]}),r.jsxs("div",{style:{display:"flex",gap:6},children:[E>0&&r.jsxs("button",{onClick:I,style:{fontSize:11.5,padding:"5px 10px",borderRadius:99,border:"1px solid rgba(239,68,68,0.3)",background:"rgba(239,68,68,0.1)",color:"#ef4444",cursor:"pointer",fontFamily:"inherit"},children:[r.jsx("span",{className:"hidden sm:inline",children:f("packing.clearChecked",{count:E})}),r.jsx("span",{className:"sm:hidden",children:f("packing.clearCheckedShort",{count:E})})]}),r.jsxs("button",{onClick:()=>ce(!0),style:{display:"flex",alignItems:"center",gap:5,padding:"5px 11px",borderRadius:99,border:"1px solid var(--border-primary)",fontSize:12,fontWeight:500,cursor:"pointer",fontFamily:"inherit",background:"var(--bg-card)",color:"var(--text-muted)"},children:[r.jsx(So,{size:12})," ",r.jsx("span",{className:"hidden sm:inline",children:f("packing.import")})]}),q.length>0&&r.jsxs("div",{ref:_e,style:{position:"relative"},children:[r.jsxs("button",{onClick:()=>be(G=>!G),disabled:Se,style:{display:"flex",alignItems:"center",gap:5,padding:"5px 11px",borderRadius:99,border:"1px solid",fontSize:12,fontWeight:500,cursor:"pointer",fontFamily:"inherit",background:oe?"var(--text-primary)":"var(--bg-card)",borderColor:oe?"var(--text-primary)":"var(--border-primary)",color:oe?"var(--bg-primary)":"var(--text-muted)"},children:[r.jsx(rc,{size:12})," ",r.jsx("span",{className:"hidden sm:inline",children:f("packing.applyTemplate")}),r.jsx("span",{className:"sm:hidden",children:f("packing.template")})]}),oe&&r.jsx("div",{style:{position:"absolute",right:0,top:"100%",marginTop:6,zIndex:50,background:"var(--bg-card)",border:"1px solid var(--border-primary)",borderRadius:10,boxShadow:"0 4px 16px rgba(0,0,0,0.12)",padding:4,minWidth:200},children:q.map(G=>r.jsxs("button",{onClick:()=>pe(G.id),style:{display:"flex",alignItems:"center",gap:8,width:"100%",padding:"8px 12px",borderRadius:8,border:"none",cursor:"pointer",background:"transparent",fontFamily:"inherit",fontSize:12,color:"var(--text-primary)",transition:"background 0.1s"},onMouseEnter:ve=>ve.currentTarget.style.background="var(--bg-tertiary)",onMouseLeave:ve=>ve.currentTarget.style.background="transparent",children:[r.jsx(rc,{size:13,style:{color:"var(--text-faint)"}}),r.jsxs("div",{style:{flex:1,textAlign:"left"},children:[r.jsx("div",{style:{fontWeight:600},children:G.name}),r.jsxs("div",{style:{fontSize:10,color:"var(--text-faint)"},children:[G.item_count," ",f("admin.packingTemplates.items")]})]})]},G.id))})]}),Y&&r.jsxs("button",{onClick:()=>z(!0),className:"xl:!hidden",style:{display:"flex",alignItems:"center",gap:5,padding:"5px 11px",borderRadius:99,border:"1px solid",fontSize:12,fontWeight:500,cursor:"pointer",fontFamily:"inherit",background:J?"var(--text-primary)":"var(--bg-card)",borderColor:J?"var(--text-primary)":"var(--border-primary)",color:J?"var(--bg-primary)":"var(--text-muted)"},children:[r.jsx(Lp,{size:12})," ",f("packing.bags")]})]})]}),t.length>0&&r.jsxs("div",{style:{marginBottom:14},children:[r.jsx("div",{style:{height:5,background:"var(--bg-tertiary)",borderRadius:99,overflow:"hidden"},children:r.jsx("div",{style:{height:"100%",borderRadius:99,transition:"width 0.4s ease",background:M===100?"#10b981":"linear-gradient(90deg, var(--text-primary) 0%, var(--text-muted) 100%)",width:`${M}%`}})}),M===100&&r.jsx("p",{style:{fontSize:11.5,color:"#10b981",marginTop:4,fontWeight:600,margin:"4px 0 0"},children:f("packing.allPacked")})]}),i?r.jsxs("div",{style:{display:"flex",gap:6},children:[r.jsx("input",{autoFocus:!0,type:"text",value:s,onChange:G=>d(G.target.value),onKeyDown:G=>{G.key==="Enter"&&P(),G.key==="Escape"&&(o(!1),d(""))},placeholder:f("packing.newCategoryPlaceholder"),style:{flex:1,padding:"8px 12px",borderRadius:10,border:"1px solid var(--border-primary)",fontSize:13.5,fontFamily:"inherit",outline:"none",color:"var(--text-primary)"}}),r.jsx("button",{onClick:P,disabled:!s.trim(),style:{padding:"8px 12px",borderRadius:10,border:"none",background:s.trim()?"var(--text-primary)":"var(--border-primary)",color:"var(--bg-primary)",cursor:s.trim()?"pointer":"default",display:"flex",alignItems:"center"},children:r.jsx(Ga,{size:16})}),r.jsx("button",{onClick:()=>{o(!1),d("")},style:{padding:"8px 12px",borderRadius:10,border:"1px solid var(--border-primary)",background:"none",cursor:"pointer",display:"flex",alignItems:"center",color:"var(--text-faint)"},children:r.jsx(gt,{size:16})})]}):r.jsxs("button",{onClick:()=>o(!0),style:{display:"flex",alignItems:"center",gap:6,width:"100%",padding:"9px 14px",borderRadius:10,border:"1px dashed var(--border-primary)",background:"none",cursor:"pointer",fontSize:13,color:"var(--text-faint)",fontFamily:"inherit",transition:"all 0.15s"},onMouseEnter:G=>{G.currentTarget.style.borderColor="var(--text-muted)",G.currentTarget.style.color="var(--text-secondary)"},onMouseLeave:G=>{G.currentTarget.style.borderColor="var(--border-primary)",G.currentTarget.style.color="var(--text-faint)"},children:[r.jsx(v_,{size:14})," ",f("packing.addCategory")]})]}),t.length>0&&r.jsx("div",{style:{display:"flex",gap:4,padding:"10px 16px 0",flexShrink:0},children:[["alle",f("packing.filterAll")],["offen",f("packing.filterOpen")],["erledigt",f("packing.filterDone")]].map(([G,ve])=>r.jsx("button",{onClick:()=>n(G),style:{padding:"4px 12px",borderRadius:99,border:"none",cursor:"pointer",fontSize:12,fontFamily:"inherit",fontWeight:a===G?600:400,background:a===G?"var(--text-primary)":"transparent",color:a===G?"var(--bg-primary)":"var(--text-muted)"},children:ve},G))}),r.jsxs("div",{style:{flex:1,display:"flex",overflow:"hidden"},children:[r.jsx("div",{style:{flex:1,overflowY:"auto",padding:"10px 12px 16px"},children:t.length===0?r.jsxs("div",{style:{textAlign:"center",padding:"60px 20px"},children:[r.jsx(Lp,{size:40,style:{color:"var(--text-faint)",display:"block",margin:"0 auto 10px"}}),r.jsx("p",{style:{fontSize:14,fontWeight:600,color:"var(--text-secondary)",margin:"0 0 4px"},children:f("packing.emptyTitle")}),r.jsx("p",{style:{fontSize:13,color:"var(--text-faint)",margin:0},children:f("packing.emptyHint")})]}):Object.keys(w).length===0?r.jsx("div",{style:{textAlign:"center",padding:"40px 20px",color:"var(--text-faint)"},children:r.jsx("p",{style:{fontSize:13,margin:0},children:f("packing.emptyFiltered")})}):r.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-2",children:Object.entries(w).map(([G,ve])=>r.jsx(L4,{kategorie:G,items:ve,tripId:e,allCategories:_,onRename:R,onDeleteAll:$,onAddItem:A,assignees:k[G]||[],tripMembers:y,onSetAssignees:v,bagTrackingEnabled:Y,bags:V,onCreateBag:C},G))})}),Y&&V.length>0&&r.jsxs("div",{className:"hidden xl:block",style:{width:260,borderLeft:"1px solid var(--border-secondary)",overflowY:"auto",padding:16,flexShrink:0},children:[r.jsx("div",{style:{fontSize:11,fontWeight:700,textTransform:"uppercase",letterSpacing:"0.05em",color:"var(--text-faint)",marginBottom:12},children:f("packing.bags")}),V.map(G=>{const ve=t.filter(fe=>fe.bag_id===G.id),Pe=ve.reduce((fe,Ee)=>fe+(Ee.weight_grams||0),0),ye=G.weight_limit_grams||Math.max(...V.map(fe=>t.filter(Ee=>Ee.bag_id===fe.id).reduce((Ee,Oe)=>Ee+(Oe.weight_grams||0),0)),1),ne=Math.min(100,Math.round(Pe/ye*100));return r.jsxs("div",{style:{marginBottom:14},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:4},children:[r.jsx("span",{style:{width:10,height:10,borderRadius:"50%",background:G.color,flexShrink:0}}),r.jsx("span",{style:{flex:1,fontSize:12,fontWeight:600,color:"var(--text-secondary)"},children:G.name}),r.jsx("span",{style:{fontSize:11,color:"var(--text-faint)",fontWeight:500},children:Pe>=1e3?`${(Pe/1e3).toFixed(1)} kg`:`${Pe} g`}),r.jsx("button",{onClick:()=>U(G.id),style:{background:"none",border:"none",cursor:"pointer",padding:2,color:"var(--text-faint)",display:"flex"},children:r.jsx(gt,{size:11})})]}),r.jsx("div",{style:{height:6,background:"var(--bg-tertiary)",borderRadius:99,overflow:"hidden"},children:r.jsx("div",{style:{height:"100%",borderRadius:99,background:G.color,width:`${ne}%`,transition:"width 0.3s"}})}),r.jsxs("div",{style:{fontSize:10,color:"var(--text-faint)",marginTop:2},children:[ve.length," ",f("admin.packingTemplates.items")]})]},G.id)}),(()=>{const G=t.filter(Pe=>!Pe.bag_id),ve=G.reduce((Pe,ye)=>Pe+(ye.weight_grams||0),0);return G.length===0?null:r.jsxs("div",{style:{marginBottom:14,opacity:.6},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:4},children:[r.jsx("span",{style:{width:10,height:10,borderRadius:"50%",border:"2px dashed var(--border-primary)",flexShrink:0}}),r.jsx("span",{style:{flex:1,fontSize:12,fontWeight:600,color:"var(--text-faint)"},children:f("packing.noBag")}),r.jsx("span",{style:{fontSize:11,color:"var(--text-faint)"},children:ve>=1e3?`${(ve/1e3).toFixed(1)} kg`:`${ve} g`})]}),r.jsxs("div",{style:{fontSize:10,color:"var(--text-faint)"},children:[G.length," ",f("admin.packingTemplates.items")]})]})})(),r.jsx("div",{style:{borderTop:"1px solid var(--border-secondary)",paddingTop:10,marginTop:6},children:r.jsxs("div",{style:{display:"flex",justifyContent:"space-between",fontSize:12,fontWeight:700,color:"var(--text-primary)"},children:[r.jsx("span",{children:f("packing.totalWeight")}),r.jsx("span",{children:(()=>{const G=t.reduce((ve,Pe)=>ve+(Pe.weight_grams||0),0);return G>=1e3?`${(G/1e3).toFixed(1)} kg`:`${G} g`})()})]})}),Q?r.jsxs("div",{style:{display:"flex",gap:4,marginTop:12},children:[r.jsx("input",{autoFocus:!0,value:Z,onChange:G=>O(G.target.value),onKeyDown:G=>{G.key==="Enter"&&B(),G.key==="Escape"&&(D(!1),O(""))},placeholder:f("packing.bagName"),style:{flex:1,padding:"5px 8px",borderRadius:8,border:"1px solid var(--border-primary)",fontSize:11,fontFamily:"inherit",outline:"none"}}),r.jsx("button",{onClick:B,style:{padding:"4px 8px",borderRadius:8,border:"none",background:"var(--text-primary)",color:"var(--bg-primary)",cursor:"pointer",display:"flex",alignItems:"center"},children:r.jsx(Ft,{size:12})})]}):r.jsxs("button",{onClick:()=>D(!0),style:{display:"flex",alignItems:"center",gap:4,marginTop:12,padding:"5px 8px",borderRadius:8,border:"1px dashed var(--border-primary)",background:"none",cursor:"pointer",fontSize:11,color:"var(--text-faint)",fontFamily:"inherit",width:"100%"},children:[r.jsx(Ft,{size:11})," ",f("packing.addBag")]})]})]}),J&&Y&&r.jsx("div",{style:{position:"fixed",inset:0,zIndex:100,background:"rgba(0,0,0,0.3)",display:"flex",alignItems:"center",justifyContent:"center",padding:20},onClick:()=>z(!1),children:r.jsxs("div",{style:{background:"var(--bg-card)",borderRadius:16,width:"100%",maxWidth:360,maxHeight:"80vh",overflow:"auto",padding:20,boxShadow:"0 16px 48px rgba(0,0,0,0.15)"},onClick:G=>G.stopPropagation(),children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:16},children:[r.jsx("h3",{style:{margin:0,fontSize:16,fontWeight:700,color:"var(--text-primary)"},children:f("packing.bags")}),r.jsx("button",{onClick:()=>z(!1),style:{background:"none",border:"none",cursor:"pointer",color:"var(--text-faint)",display:"flex"},children:r.jsx(gt,{size:18})})]}),V.map(G=>{const ve=t.filter(fe=>fe.bag_id===G.id),Pe=ve.reduce((fe,Ee)=>fe+(Ee.weight_grams||0),0),ye=Math.max(...V.map(fe=>t.filter(Ee=>Ee.bag_id===fe.id).reduce((Ee,Oe)=>Ee+(Oe.weight_grams||0),0)),1),ne=Math.min(100,Math.round(Pe/ye*100));return r.jsxs("div",{style:{marginBottom:16},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:6},children:[r.jsx("span",{style:{width:12,height:12,borderRadius:"50%",background:G.color,flexShrink:0}}),r.jsx("span",{style:{flex:1,fontSize:14,fontWeight:600,color:"var(--text-primary)"},children:G.name}),r.jsx("span",{style:{fontSize:13,color:"var(--text-muted)",fontWeight:500},children:Pe>=1e3?`${(Pe/1e3).toFixed(1)} kg`:`${Pe} g`}),r.jsx("button",{onClick:()=>U(G.id),style:{background:"none",border:"none",cursor:"pointer",padding:2,color:"var(--text-faint)",display:"flex"},children:r.jsx(_t,{size:13})})]}),r.jsx("div",{style:{height:8,background:"var(--bg-tertiary)",borderRadius:99,overflow:"hidden"},children:r.jsx("div",{style:{height:"100%",borderRadius:99,background:G.color,width:`${ne}%`,transition:"width 0.3s"}})}),r.jsxs("div",{style:{fontSize:11,color:"var(--text-faint)",marginTop:3},children:[ve.length," ",f("admin.packingTemplates.items")]})]},G.id)}),(()=>{const G=t.filter(Pe=>!Pe.bag_id),ve=G.reduce((Pe,ye)=>Pe+(ye.weight_grams||0),0);return G.length===0?null:r.jsxs("div",{style:{marginBottom:16,opacity:.6},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:6},children:[r.jsx("span",{style:{width:12,height:12,borderRadius:"50%",border:"2px dashed var(--border-primary)",flexShrink:0}}),r.jsx("span",{style:{flex:1,fontSize:14,fontWeight:600,color:"var(--text-faint)"},children:f("packing.noBag")}),r.jsx("span",{style:{fontSize:13,color:"var(--text-faint)"},children:ve>=1e3?`${(ve/1e3).toFixed(1)} kg`:`${ve} g`})]}),r.jsxs("div",{style:{fontSize:11,color:"var(--text-faint)"},children:[G.length," ",f("admin.packingTemplates.items")]})]})})(),r.jsx("div",{style:{borderTop:"1px solid var(--border-secondary)",paddingTop:12,marginTop:8},children:r.jsxs("div",{style:{display:"flex",justifyContent:"space-between",fontSize:14,fontWeight:700,color:"var(--text-primary)"},children:[r.jsx("span",{children:f("packing.totalWeight")}),r.jsx("span",{children:(()=>{const G=t.reduce((ve,Pe)=>ve+(Pe.weight_grams||0),0);return G>=1e3?`${(G/1e3).toFixed(1)} kg`:`${G} g`})()})]})}),Q?r.jsxs("div",{style:{display:"flex",gap:6,marginTop:14},children:[r.jsx("input",{autoFocus:!0,value:Z,onChange:G=>O(G.target.value),onKeyDown:G=>{G.key==="Enter"&&B(),G.key==="Escape"&&(D(!1),O(""))},placeholder:f("packing.bagName"),style:{flex:1,padding:"8px 12px",borderRadius:10,border:"1px solid var(--border-primary)",fontSize:13,fontFamily:"inherit",outline:"none"}}),r.jsx("button",{onClick:B,disabled:!Z.trim(),style:{padding:"8px 12px",borderRadius:10,border:"none",background:Z.trim()?"var(--text-primary)":"var(--border-primary)",color:"var(--bg-primary)",cursor:Z.trim()?"pointer":"default",display:"flex",alignItems:"center"},children:r.jsx(Ft,{size:14})})]}):r.jsxs("button",{onClick:()=>D(!0),style:{display:"flex",alignItems:"center",gap:6,marginTop:14,padding:"9px 14px",borderRadius:10,border:"1px dashed var(--border-primary)",background:"none",cursor:"pointer",fontSize:13,color:"var(--text-faint)",fontFamily:"inherit",width:"100%",transition:"all 0.15s"},onMouseEnter:G=>{G.currentTarget.style.borderColor="var(--text-muted)",G.currentTarget.style.color="var(--text-secondary)"},onMouseLeave:G=>{G.currentTarget.style.borderColor="var(--border-primary)",G.currentTarget.style.color="var(--text-faint)"},children:[r.jsx(Ft,{size:14})," ",f("packing.addBag")]})]})}),r.jsx("style",{children:`
+ .assignee-chip:hover + .assignee-tooltip { opacity: 1 !important; }
+ .assignee-chip:hover { opacity: 0.7; }
+ `}),we&&Vt.createPortal(r.jsx("div",{style:{position:"fixed",inset:0,zIndex:1e3,display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(0,0,0,0.3)",backdropFilter:"blur(3px)"},onClick:()=>ce(!1),children:r.jsxs("div",{style:{width:420,maxHeight:"80vh",background:"var(--bg-card)",borderRadius:16,boxShadow:"0 16px 48px rgba(0,0,0,0.22)",padding:"22px 22px 18px",display:"flex",flexDirection:"column",gap:14},onClick:G=>G.stopPropagation(),children:[r.jsx("div",{style:{fontSize:15,fontWeight:600,color:"var(--text-primary)"},children:f("packing.importTitle")}),r.jsx("div",{style:{fontSize:12,color:"var(--text-faint)",lineHeight:1.5},children:f("packing.importHint")}),r.jsx("textarea",{value:le,onChange:G=>K(G.target.value),rows:10,placeholder:f("packing.importPlaceholder"),style:{width:"100%",border:"1px solid var(--border-primary)",borderRadius:10,padding:"10px 12px",fontSize:13,fontFamily:"monospace",outline:"none",boxSizing:"border-box",color:"var(--text-primary)",background:"var(--bg-input)",resize:"vertical",lineHeight:1.5}}),r.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[r.jsxs("div",{children:[r.jsx("input",{ref:de,type:"file",accept:".csv,.txt",style:{display:"none"},onChange:ze}),r.jsxs("button",{onClick:()=>{var G;return(G=de.current)==null?void 0:G.click()},style:{display:"flex",alignItems:"center",gap:5,padding:"5px 10px",border:"1px dashed var(--border-primary)",borderRadius:8,background:"none",fontSize:11,color:"var(--text-faint)",cursor:"pointer",fontFamily:"inherit"},children:[r.jsx(So,{size:11})," ",f("packing.importCsv")]})]}),r.jsxs("div",{style:{display:"flex",gap:8},children:[r.jsx("button",{onClick:()=>ce(!1),style:{fontSize:12,background:"none",border:"1px solid var(--border-primary)",borderRadius:8,padding:"6px 14px",cursor:"pointer",color:"var(--text-muted)",fontFamily:"inherit"},children:f("common.cancel")}),r.jsx("button",{onClick:He,disabled:!le.trim(),style:{fontSize:12,background:"var(--accent)",color:"var(--accent-text)",border:"none",borderRadius:8,padding:"6px 16px",cursor:"pointer",fontWeight:600,fontFamily:"inherit",opacity:le.trim()?1:.5},children:f("packing.importAction",{count:Ae(le).length})})]})]})]})}),document.body)]})}var Y_={exports:{}},O4="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED",B4=O4,H4=B4;function X_(){}function J_(){}J_.resetWarningCache=X_;var U4=function(){function e(n,i,o,s,d,c){if(c!==H4){var p=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw p.name="Invariant Violation",p}}e.isRequired=e;function t(){return e}var a={array:e,bigint:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:J_,resetWarningCache:X_};return a.PropTypes=a,a};Y_.exports=U4();var W4=Y_.exports;const Qt=gs(W4);function bs(e,t,a,n){function i(o){return o instanceof a?o:new a(function(s){s(o)})}return new(a||(a=Promise))(function(o,s){function d(m){try{p(n.next(m))}catch(g){s(g)}}function c(m){try{p(n.throw(m))}catch(g){s(g)}}function p(m){m.done?o(m.value):i(m.value).then(d,c)}p((n=n.apply(e,t||[])).next())})}const $4=new Map([["1km","application/vnd.1000minds.decision-model+xml"],["3dml","text/vnd.in3d.3dml"],["3ds","image/x-3ds"],["3g2","video/3gpp2"],["3gp","video/3gp"],["3gpp","video/3gpp"],["3mf","model/3mf"],["7z","application/x-7z-compressed"],["7zip","application/x-7z-compressed"],["123","application/vnd.lotus-1-2-3"],["aab","application/x-authorware-bin"],["aac","audio/x-acc"],["aam","application/x-authorware-map"],["aas","application/x-authorware-seg"],["abw","application/x-abiword"],["ac","application/vnd.nokia.n-gage.ac+xml"],["ac3","audio/ac3"],["acc","application/vnd.americandynamics.acc"],["ace","application/x-ace-compressed"],["acu","application/vnd.acucobol"],["acutc","application/vnd.acucorp"],["adp","audio/adpcm"],["aep","application/vnd.audiograph"],["afm","application/x-font-type1"],["afp","application/vnd.ibm.modcap"],["ahead","application/vnd.ahead.space"],["ai","application/pdf"],["aif","audio/x-aiff"],["aifc","audio/x-aiff"],["aiff","audio/x-aiff"],["air","application/vnd.adobe.air-application-installer-package+zip"],["ait","application/vnd.dvb.ait"],["ami","application/vnd.amiga.ami"],["amr","audio/amr"],["apk","application/vnd.android.package-archive"],["apng","image/apng"],["appcache","text/cache-manifest"],["application","application/x-ms-application"],["apr","application/vnd.lotus-approach"],["arc","application/x-freearc"],["arj","application/x-arj"],["asc","application/pgp-signature"],["asf","video/x-ms-asf"],["asm","text/x-asm"],["aso","application/vnd.accpac.simply.aso"],["asx","video/x-ms-asf"],["atc","application/vnd.acucorp"],["atom","application/atom+xml"],["atomcat","application/atomcat+xml"],["atomdeleted","application/atomdeleted+xml"],["atomsvc","application/atomsvc+xml"],["atx","application/vnd.antix.game-component"],["au","audio/x-au"],["avi","video/x-msvideo"],["avif","image/avif"],["aw","application/applixware"],["azf","application/vnd.airzip.filesecure.azf"],["azs","application/vnd.airzip.filesecure.azs"],["azv","image/vnd.airzip.accelerator.azv"],["azw","application/vnd.amazon.ebook"],["b16","image/vnd.pco.b16"],["bat","application/x-msdownload"],["bcpio","application/x-bcpio"],["bdf","application/x-font-bdf"],["bdm","application/vnd.syncml.dm+wbxml"],["bdoc","application/x-bdoc"],["bed","application/vnd.realvnc.bed"],["bh2","application/vnd.fujitsu.oasysprs"],["bin","application/octet-stream"],["blb","application/x-blorb"],["blorb","application/x-blorb"],["bmi","application/vnd.bmi"],["bmml","application/vnd.balsamiq.bmml+xml"],["bmp","image/bmp"],["book","application/vnd.framemaker"],["box","application/vnd.previewsystems.box"],["boz","application/x-bzip2"],["bpk","application/octet-stream"],["bpmn","application/octet-stream"],["bsp","model/vnd.valve.source.compiled-map"],["btif","image/prs.btif"],["buffer","application/octet-stream"],["bz","application/x-bzip"],["bz2","application/x-bzip2"],["c","text/x-c"],["c4d","application/vnd.clonk.c4group"],["c4f","application/vnd.clonk.c4group"],["c4g","application/vnd.clonk.c4group"],["c4p","application/vnd.clonk.c4group"],["c4u","application/vnd.clonk.c4group"],["c11amc","application/vnd.cluetrust.cartomobile-config"],["c11amz","application/vnd.cluetrust.cartomobile-config-pkg"],["cab","application/vnd.ms-cab-compressed"],["caf","audio/x-caf"],["cap","application/vnd.tcpdump.pcap"],["car","application/vnd.curl.car"],["cat","application/vnd.ms-pki.seccat"],["cb7","application/x-cbr"],["cba","application/x-cbr"],["cbr","application/x-cbr"],["cbt","application/x-cbr"],["cbz","application/x-cbr"],["cc","text/x-c"],["cco","application/x-cocoa"],["cct","application/x-director"],["ccxml","application/ccxml+xml"],["cdbcmsg","application/vnd.contact.cmsg"],["cda","application/x-cdf"],["cdf","application/x-netcdf"],["cdfx","application/cdfx+xml"],["cdkey","application/vnd.mediastation.cdkey"],["cdmia","application/cdmi-capability"],["cdmic","application/cdmi-container"],["cdmid","application/cdmi-domain"],["cdmio","application/cdmi-object"],["cdmiq","application/cdmi-queue"],["cdr","application/cdr"],["cdx","chemical/x-cdx"],["cdxml","application/vnd.chemdraw+xml"],["cdy","application/vnd.cinderella"],["cer","application/pkix-cert"],["cfs","application/x-cfs-compressed"],["cgm","image/cgm"],["chat","application/x-chat"],["chm","application/vnd.ms-htmlhelp"],["chrt","application/vnd.kde.kchart"],["cif","chemical/x-cif"],["cii","application/vnd.anser-web-certificate-issue-initiation"],["cil","application/vnd.ms-artgalry"],["cjs","application/node"],["cla","application/vnd.claymore"],["class","application/octet-stream"],["clkk","application/vnd.crick.clicker.keyboard"],["clkp","application/vnd.crick.clicker.palette"],["clkt","application/vnd.crick.clicker.template"],["clkw","application/vnd.crick.clicker.wordbank"],["clkx","application/vnd.crick.clicker"],["clp","application/x-msclip"],["cmc","application/vnd.cosmocaller"],["cmdf","chemical/x-cmdf"],["cml","chemical/x-cml"],["cmp","application/vnd.yellowriver-custom-menu"],["cmx","image/x-cmx"],["cod","application/vnd.rim.cod"],["coffee","text/coffeescript"],["com","application/x-msdownload"],["conf","text/plain"],["cpio","application/x-cpio"],["cpp","text/x-c"],["cpt","application/mac-compactpro"],["crd","application/x-mscardfile"],["crl","application/pkix-crl"],["crt","application/x-x509-ca-cert"],["crx","application/x-chrome-extension"],["cryptonote","application/vnd.rig.cryptonote"],["csh","application/x-csh"],["csl","application/vnd.citationstyles.style+xml"],["csml","chemical/x-csml"],["csp","application/vnd.commonspace"],["csr","application/octet-stream"],["css","text/css"],["cst","application/x-director"],["csv","text/csv"],["cu","application/cu-seeme"],["curl","text/vnd.curl"],["cww","application/prs.cww"],["cxt","application/x-director"],["cxx","text/x-c"],["dae","model/vnd.collada+xml"],["daf","application/vnd.mobius.daf"],["dart","application/vnd.dart"],["dataless","application/vnd.fdsn.seed"],["davmount","application/davmount+xml"],["dbf","application/vnd.dbf"],["dbk","application/docbook+xml"],["dcr","application/x-director"],["dcurl","text/vnd.curl.dcurl"],["dd2","application/vnd.oma.dd2+xml"],["ddd","application/vnd.fujixerox.ddd"],["ddf","application/vnd.syncml.dmddf+xml"],["dds","image/vnd.ms-dds"],["deb","application/x-debian-package"],["def","text/plain"],["deploy","application/octet-stream"],["der","application/x-x509-ca-cert"],["dfac","application/vnd.dreamfactory"],["dgc","application/x-dgc-compressed"],["dic","text/x-c"],["dir","application/x-director"],["dis","application/vnd.mobius.dis"],["disposition-notification","message/disposition-notification"],["dist","application/octet-stream"],["distz","application/octet-stream"],["djv","image/vnd.djvu"],["djvu","image/vnd.djvu"],["dll","application/octet-stream"],["dmg","application/x-apple-diskimage"],["dmn","application/octet-stream"],["dmp","application/vnd.tcpdump.pcap"],["dms","application/octet-stream"],["dna","application/vnd.dna"],["doc","application/msword"],["docm","application/vnd.ms-word.template.macroEnabled.12"],["docx","application/vnd.openxmlformats-officedocument.wordprocessingml.document"],["dot","application/msword"],["dotm","application/vnd.ms-word.template.macroEnabled.12"],["dotx","application/vnd.openxmlformats-officedocument.wordprocessingml.template"],["dp","application/vnd.osgi.dp"],["dpg","application/vnd.dpgraph"],["dra","audio/vnd.dra"],["drle","image/dicom-rle"],["dsc","text/prs.lines.tag"],["dssc","application/dssc+der"],["dtb","application/x-dtbook+xml"],["dtd","application/xml-dtd"],["dts","audio/vnd.dts"],["dtshd","audio/vnd.dts.hd"],["dump","application/octet-stream"],["dvb","video/vnd.dvb.file"],["dvi","application/x-dvi"],["dwd","application/atsc-dwd+xml"],["dwf","model/vnd.dwf"],["dwg","image/vnd.dwg"],["dxf","image/vnd.dxf"],["dxp","application/vnd.spotfire.dxp"],["dxr","application/x-director"],["ear","application/java-archive"],["ecelp4800","audio/vnd.nuera.ecelp4800"],["ecelp7470","audio/vnd.nuera.ecelp7470"],["ecelp9600","audio/vnd.nuera.ecelp9600"],["ecma","application/ecmascript"],["edm","application/vnd.novadigm.edm"],["edx","application/vnd.novadigm.edx"],["efif","application/vnd.picsel"],["ei6","application/vnd.pg.osasli"],["elc","application/octet-stream"],["emf","image/emf"],["eml","message/rfc822"],["emma","application/emma+xml"],["emotionml","application/emotionml+xml"],["emz","application/x-msmetafile"],["eol","audio/vnd.digital-winds"],["eot","application/vnd.ms-fontobject"],["eps","application/postscript"],["epub","application/epub+zip"],["es","application/ecmascript"],["es3","application/vnd.eszigno3+xml"],["esa","application/vnd.osgi.subsystem"],["esf","application/vnd.epson.esf"],["et3","application/vnd.eszigno3+xml"],["etx","text/x-setext"],["eva","application/x-eva"],["evy","application/x-envoy"],["exe","application/octet-stream"],["exi","application/exi"],["exp","application/express"],["exr","image/aces"],["ext","application/vnd.novadigm.ext"],["ez","application/andrew-inset"],["ez2","application/vnd.ezpix-album"],["ez3","application/vnd.ezpix-package"],["f","text/x-fortran"],["f4v","video/mp4"],["f77","text/x-fortran"],["f90","text/x-fortran"],["fbs","image/vnd.fastbidsheet"],["fcdt","application/vnd.adobe.formscentral.fcdt"],["fcs","application/vnd.isac.fcs"],["fdf","application/vnd.fdf"],["fdt","application/fdt+xml"],["fe_launch","application/vnd.denovo.fcselayout-link"],["fg5","application/vnd.fujitsu.oasysgp"],["fgd","application/x-director"],["fh","image/x-freehand"],["fh4","image/x-freehand"],["fh5","image/x-freehand"],["fh7","image/x-freehand"],["fhc","image/x-freehand"],["fig","application/x-xfig"],["fits","image/fits"],["flac","audio/x-flac"],["fli","video/x-fli"],["flo","application/vnd.micrografx.flo"],["flv","video/x-flv"],["flw","application/vnd.kde.kivio"],["flx","text/vnd.fmi.flexstor"],["fly","text/vnd.fly"],["fm","application/vnd.framemaker"],["fnc","application/vnd.frogans.fnc"],["fo","application/vnd.software602.filler.form+xml"],["for","text/x-fortran"],["fpx","image/vnd.fpx"],["frame","application/vnd.framemaker"],["fsc","application/vnd.fsc.weblaunch"],["fst","image/vnd.fst"],["ftc","application/vnd.fluxtime.clip"],["fti","application/vnd.anser-web-funds-transfer-initiation"],["fvt","video/vnd.fvt"],["fxp","application/vnd.adobe.fxp"],["fxpl","application/vnd.adobe.fxp"],["fzs","application/vnd.fuzzysheet"],["g2w","application/vnd.geoplan"],["g3","image/g3fax"],["g3w","application/vnd.geospace"],["gac","application/vnd.groove-account"],["gam","application/x-tads"],["gbr","application/rpki-ghostbusters"],["gca","application/x-gca-compressed"],["gdl","model/vnd.gdl"],["gdoc","application/vnd.google-apps.document"],["geo","application/vnd.dynageo"],["geojson","application/geo+json"],["gex","application/vnd.geometry-explorer"],["ggb","application/vnd.geogebra.file"],["ggt","application/vnd.geogebra.tool"],["ghf","application/vnd.groove-help"],["gif","image/gif"],["gim","application/vnd.groove-identity-message"],["glb","model/gltf-binary"],["gltf","model/gltf+json"],["gml","application/gml+xml"],["gmx","application/vnd.gmx"],["gnumeric","application/x-gnumeric"],["gpg","application/gpg-keys"],["gph","application/vnd.flographit"],["gpx","application/gpx+xml"],["gqf","application/vnd.grafeq"],["gqs","application/vnd.grafeq"],["gram","application/srgs"],["gramps","application/x-gramps-xml"],["gre","application/vnd.geometry-explorer"],["grv","application/vnd.groove-injector"],["grxml","application/srgs+xml"],["gsf","application/x-font-ghostscript"],["gsheet","application/vnd.google-apps.spreadsheet"],["gslides","application/vnd.google-apps.presentation"],["gtar","application/x-gtar"],["gtm","application/vnd.groove-tool-message"],["gtw","model/vnd.gtw"],["gv","text/vnd.graphviz"],["gxf","application/gxf"],["gxt","application/vnd.geonext"],["gz","application/gzip"],["gzip","application/gzip"],["h","text/x-c"],["h261","video/h261"],["h263","video/h263"],["h264","video/h264"],["hal","application/vnd.hal+xml"],["hbci","application/vnd.hbci"],["hbs","text/x-handlebars-template"],["hdd","application/x-virtualbox-hdd"],["hdf","application/x-hdf"],["heic","image/heic"],["heics","image/heic-sequence"],["heif","image/heif"],["heifs","image/heif-sequence"],["hej2","image/hej2k"],["held","application/atsc-held+xml"],["hh","text/x-c"],["hjson","application/hjson"],["hlp","application/winhlp"],["hpgl","application/vnd.hp-hpgl"],["hpid","application/vnd.hp-hpid"],["hps","application/vnd.hp-hps"],["hqx","application/mac-binhex40"],["hsj2","image/hsj2"],["htc","text/x-component"],["htke","application/vnd.kenameaapp"],["htm","text/html"],["html","text/html"],["hvd","application/vnd.yamaha.hv-dic"],["hvp","application/vnd.yamaha.hv-voice"],["hvs","application/vnd.yamaha.hv-script"],["i2g","application/vnd.intergeo"],["icc","application/vnd.iccprofile"],["ice","x-conference/x-cooltalk"],["icm","application/vnd.iccprofile"],["ico","image/x-icon"],["ics","text/calendar"],["ief","image/ief"],["ifb","text/calendar"],["ifm","application/vnd.shana.informed.formdata"],["iges","model/iges"],["igl","application/vnd.igloader"],["igm","application/vnd.insors.igm"],["igs","model/iges"],["igx","application/vnd.micrografx.igx"],["iif","application/vnd.shana.informed.interchange"],["img","application/octet-stream"],["imp","application/vnd.accpac.simply.imp"],["ims","application/vnd.ms-ims"],["in","text/plain"],["ini","text/plain"],["ink","application/inkml+xml"],["inkml","application/inkml+xml"],["install","application/x-install-instructions"],["iota","application/vnd.astraea-software.iota"],["ipfix","application/ipfix"],["ipk","application/vnd.shana.informed.package"],["irm","application/vnd.ibm.rights-management"],["irp","application/vnd.irepository.package+xml"],["iso","application/x-iso9660-image"],["itp","application/vnd.shana.informed.formtemplate"],["its","application/its+xml"],["ivp","application/vnd.immervision-ivp"],["ivu","application/vnd.immervision-ivu"],["jad","text/vnd.sun.j2me.app-descriptor"],["jade","text/jade"],["jam","application/vnd.jam"],["jar","application/java-archive"],["jardiff","application/x-java-archive-diff"],["java","text/x-java-source"],["jhc","image/jphc"],["jisp","application/vnd.jisp"],["jls","image/jls"],["jlt","application/vnd.hp-jlyt"],["jng","image/x-jng"],["jnlp","application/x-java-jnlp-file"],["joda","application/vnd.joost.joda-archive"],["jp2","image/jp2"],["jpe","image/jpeg"],["jpeg","image/jpeg"],["jpf","image/jpx"],["jpg","image/jpeg"],["jpg2","image/jp2"],["jpgm","video/jpm"],["jpgv","video/jpeg"],["jph","image/jph"],["jpm","video/jpm"],["jpx","image/jpx"],["js","application/javascript"],["json","application/json"],["json5","application/json5"],["jsonld","application/ld+json"],["jsonl","application/jsonl"],["jsonml","application/jsonml+json"],["jsx","text/jsx"],["jxr","image/jxr"],["jxra","image/jxra"],["jxrs","image/jxrs"],["jxs","image/jxs"],["jxsc","image/jxsc"],["jxsi","image/jxsi"],["jxss","image/jxss"],["kar","audio/midi"],["karbon","application/vnd.kde.karbon"],["kdb","application/octet-stream"],["kdbx","application/x-keepass2"],["key","application/x-iwork-keynote-sffkey"],["kfo","application/vnd.kde.kformula"],["kia","application/vnd.kidspiration"],["kml","application/vnd.google-earth.kml+xml"],["kmz","application/vnd.google-earth.kmz"],["kne","application/vnd.kinar"],["knp","application/vnd.kinar"],["kon","application/vnd.kde.kontour"],["kpr","application/vnd.kde.kpresenter"],["kpt","application/vnd.kde.kpresenter"],["kpxx","application/vnd.ds-keypoint"],["ksp","application/vnd.kde.kspread"],["ktr","application/vnd.kahootz"],["ktx","image/ktx"],["ktx2","image/ktx2"],["ktz","application/vnd.kahootz"],["kwd","application/vnd.kde.kword"],["kwt","application/vnd.kde.kword"],["lasxml","application/vnd.las.las+xml"],["latex","application/x-latex"],["lbd","application/vnd.llamagraphics.life-balance.desktop"],["lbe","application/vnd.llamagraphics.life-balance.exchange+xml"],["les","application/vnd.hhe.lesson-player"],["less","text/less"],["lgr","application/lgr+xml"],["lha","application/octet-stream"],["link66","application/vnd.route66.link66+xml"],["list","text/plain"],["list3820","application/vnd.ibm.modcap"],["listafp","application/vnd.ibm.modcap"],["litcoffee","text/coffeescript"],["lnk","application/x-ms-shortcut"],["log","text/plain"],["lostxml","application/lost+xml"],["lrf","application/octet-stream"],["lrm","application/vnd.ms-lrm"],["ltf","application/vnd.frogans.ltf"],["lua","text/x-lua"],["luac","application/x-lua-bytecode"],["lvp","audio/vnd.lucent.voice"],["lwp","application/vnd.lotus-wordpro"],["lzh","application/octet-stream"],["m1v","video/mpeg"],["m2a","audio/mpeg"],["m2v","video/mpeg"],["m3a","audio/mpeg"],["m3u","text/plain"],["m3u8","application/vnd.apple.mpegurl"],["m4a","audio/x-m4a"],["m4p","application/mp4"],["m4s","video/iso.segment"],["m4u","application/vnd.mpegurl"],["m4v","video/x-m4v"],["m13","application/x-msmediaview"],["m14","application/x-msmediaview"],["m21","application/mp21"],["ma","application/mathematica"],["mads","application/mads+xml"],["maei","application/mmt-aei+xml"],["mag","application/vnd.ecowin.chart"],["maker","application/vnd.framemaker"],["man","text/troff"],["manifest","text/cache-manifest"],["map","application/json"],["mar","application/octet-stream"],["markdown","text/markdown"],["mathml","application/mathml+xml"],["mb","application/mathematica"],["mbk","application/vnd.mobius.mbk"],["mbox","application/mbox"],["mc1","application/vnd.medcalcdata"],["mcd","application/vnd.mcd"],["mcurl","text/vnd.curl.mcurl"],["md","text/markdown"],["mdb","application/x-msaccess"],["mdi","image/vnd.ms-modi"],["mdx","text/mdx"],["me","text/troff"],["mesh","model/mesh"],["meta4","application/metalink4+xml"],["metalink","application/metalink+xml"],["mets","application/mets+xml"],["mfm","application/vnd.mfmp"],["mft","application/rpki-manifest"],["mgp","application/vnd.osgeo.mapguide.package"],["mgz","application/vnd.proteus.magazine"],["mid","audio/midi"],["midi","audio/midi"],["mie","application/x-mie"],["mif","application/vnd.mif"],["mime","message/rfc822"],["mj2","video/mj2"],["mjp2","video/mj2"],["mjs","application/javascript"],["mk3d","video/x-matroska"],["mka","audio/x-matroska"],["mkd","text/x-markdown"],["mks","video/x-matroska"],["mkv","video/x-matroska"],["mlp","application/vnd.dolby.mlp"],["mmd","application/vnd.chipnuts.karaoke-mmd"],["mmf","application/vnd.smaf"],["mml","text/mathml"],["mmr","image/vnd.fujixerox.edmics-mmr"],["mng","video/x-mng"],["mny","application/x-msmoney"],["mobi","application/x-mobipocket-ebook"],["mods","application/mods+xml"],["mov","video/quicktime"],["movie","video/x-sgi-movie"],["mp2","audio/mpeg"],["mp2a","audio/mpeg"],["mp3","audio/mpeg"],["mp4","video/mp4"],["mp4a","audio/mp4"],["mp4s","application/mp4"],["mp4v","video/mp4"],["mp21","application/mp21"],["mpc","application/vnd.mophun.certificate"],["mpd","application/dash+xml"],["mpe","video/mpeg"],["mpeg","video/mpeg"],["mpg","video/mpeg"],["mpg4","video/mp4"],["mpga","audio/mpeg"],["mpkg","application/vnd.apple.installer+xml"],["mpm","application/vnd.blueice.multipass"],["mpn","application/vnd.mophun.application"],["mpp","application/vnd.ms-project"],["mpt","application/vnd.ms-project"],["mpy","application/vnd.ibm.minipay"],["mqy","application/vnd.mobius.mqy"],["mrc","application/marc"],["mrcx","application/marcxml+xml"],["ms","text/troff"],["mscml","application/mediaservercontrol+xml"],["mseed","application/vnd.fdsn.mseed"],["mseq","application/vnd.mseq"],["msf","application/vnd.epson.msf"],["msg","application/vnd.ms-outlook"],["msh","model/mesh"],["msi","application/x-msdownload"],["msl","application/vnd.mobius.msl"],["msm","application/octet-stream"],["msp","application/octet-stream"],["msty","application/vnd.muvee.style"],["mtl","model/mtl"],["mts","model/vnd.mts"],["mus","application/vnd.musician"],["musd","application/mmt-usd+xml"],["musicxml","application/vnd.recordare.musicxml+xml"],["mvb","application/x-msmediaview"],["mvt","application/vnd.mapbox-vector-tile"],["mwf","application/vnd.mfer"],["mxf","application/mxf"],["mxl","application/vnd.recordare.musicxml"],["mxmf","audio/mobile-xmf"],["mxml","application/xv+xml"],["mxs","application/vnd.triscape.mxs"],["mxu","video/vnd.mpegurl"],["n-gage","application/vnd.nokia.n-gage.symbian.install"],["n3","text/n3"],["nb","application/mathematica"],["nbp","application/vnd.wolfram.player"],["nc","application/x-netcdf"],["ncx","application/x-dtbncx+xml"],["nfo","text/x-nfo"],["ngdat","application/vnd.nokia.n-gage.data"],["nitf","application/vnd.nitf"],["nlu","application/vnd.neurolanguage.nlu"],["nml","application/vnd.enliven"],["nnd","application/vnd.noblenet-directory"],["nns","application/vnd.noblenet-sealer"],["nnw","application/vnd.noblenet-web"],["npx","image/vnd.net-fpx"],["nq","application/n-quads"],["nsc","application/x-conference"],["nsf","application/vnd.lotus-notes"],["nt","application/n-triples"],["ntf","application/vnd.nitf"],["numbers","application/x-iwork-numbers-sffnumbers"],["nzb","application/x-nzb"],["oa2","application/vnd.fujitsu.oasys2"],["oa3","application/vnd.fujitsu.oasys3"],["oas","application/vnd.fujitsu.oasys"],["obd","application/x-msbinder"],["obgx","application/vnd.openblox.game+xml"],["obj","model/obj"],["oda","application/oda"],["odb","application/vnd.oasis.opendocument.database"],["odc","application/vnd.oasis.opendocument.chart"],["odf","application/vnd.oasis.opendocument.formula"],["odft","application/vnd.oasis.opendocument.formula-template"],["odg","application/vnd.oasis.opendocument.graphics"],["odi","application/vnd.oasis.opendocument.image"],["odm","application/vnd.oasis.opendocument.text-master"],["odp","application/vnd.oasis.opendocument.presentation"],["ods","application/vnd.oasis.opendocument.spreadsheet"],["odt","application/vnd.oasis.opendocument.text"],["oga","audio/ogg"],["ogex","model/vnd.opengex"],["ogg","audio/ogg"],["ogv","video/ogg"],["ogx","application/ogg"],["omdoc","application/omdoc+xml"],["onepkg","application/onenote"],["onetmp","application/onenote"],["onetoc","application/onenote"],["onetoc2","application/onenote"],["opf","application/oebps-package+xml"],["opml","text/x-opml"],["oprc","application/vnd.palm"],["opus","audio/ogg"],["org","text/x-org"],["osf","application/vnd.yamaha.openscoreformat"],["osfpvg","application/vnd.yamaha.openscoreformat.osfpvg+xml"],["osm","application/vnd.openstreetmap.data+xml"],["otc","application/vnd.oasis.opendocument.chart-template"],["otf","font/otf"],["otg","application/vnd.oasis.opendocument.graphics-template"],["oth","application/vnd.oasis.opendocument.text-web"],["oti","application/vnd.oasis.opendocument.image-template"],["otp","application/vnd.oasis.opendocument.presentation-template"],["ots","application/vnd.oasis.opendocument.spreadsheet-template"],["ott","application/vnd.oasis.opendocument.text-template"],["ova","application/x-virtualbox-ova"],["ovf","application/x-virtualbox-ovf"],["owl","application/rdf+xml"],["oxps","application/oxps"],["oxt","application/vnd.openofficeorg.extension"],["p","text/x-pascal"],["p7a","application/x-pkcs7-signature"],["p7b","application/x-pkcs7-certificates"],["p7c","application/pkcs7-mime"],["p7m","application/pkcs7-mime"],["p7r","application/x-pkcs7-certreqresp"],["p7s","application/pkcs7-signature"],["p8","application/pkcs8"],["p10","application/x-pkcs10"],["p12","application/x-pkcs12"],["pac","application/x-ns-proxy-autoconfig"],["pages","application/x-iwork-pages-sffpages"],["pas","text/x-pascal"],["paw","application/vnd.pawaafile"],["pbd","application/vnd.powerbuilder6"],["pbm","image/x-portable-bitmap"],["pcap","application/vnd.tcpdump.pcap"],["pcf","application/x-font-pcf"],["pcl","application/vnd.hp-pcl"],["pclxl","application/vnd.hp-pclxl"],["pct","image/x-pict"],["pcurl","application/vnd.curl.pcurl"],["pcx","image/x-pcx"],["pdb","application/x-pilot"],["pde","text/x-processing"],["pdf","application/pdf"],["pem","application/x-x509-user-cert"],["pfa","application/x-font-type1"],["pfb","application/x-font-type1"],["pfm","application/x-font-type1"],["pfr","application/font-tdpfr"],["pfx","application/x-pkcs12"],["pgm","image/x-portable-graymap"],["pgn","application/x-chess-pgn"],["pgp","application/pgp"],["php","application/x-httpd-php"],["php3","application/x-httpd-php"],["php4","application/x-httpd-php"],["phps","application/x-httpd-php-source"],["phtml","application/x-httpd-php"],["pic","image/x-pict"],["pkg","application/octet-stream"],["pki","application/pkixcmp"],["pkipath","application/pkix-pkipath"],["pkpass","application/vnd.apple.pkpass"],["pl","application/x-perl"],["plb","application/vnd.3gpp.pic-bw-large"],["plc","application/vnd.mobius.plc"],["plf","application/vnd.pocketlearn"],["pls","application/pls+xml"],["pm","application/x-perl"],["pml","application/vnd.ctc-posml"],["png","image/png"],["pnm","image/x-portable-anymap"],["portpkg","application/vnd.macports.portpkg"],["pot","application/vnd.ms-powerpoint"],["potm","application/vnd.ms-powerpoint.presentation.macroEnabled.12"],["potx","application/vnd.openxmlformats-officedocument.presentationml.template"],["ppa","application/vnd.ms-powerpoint"],["ppam","application/vnd.ms-powerpoint.addin.macroEnabled.12"],["ppd","application/vnd.cups-ppd"],["ppm","image/x-portable-pixmap"],["pps","application/vnd.ms-powerpoint"],["ppsm","application/vnd.ms-powerpoint.slideshow.macroEnabled.12"],["ppsx","application/vnd.openxmlformats-officedocument.presentationml.slideshow"],["ppt","application/powerpoint"],["pptm","application/vnd.ms-powerpoint.presentation.macroEnabled.12"],["pptx","application/vnd.openxmlformats-officedocument.presentationml.presentation"],["pqa","application/vnd.palm"],["prc","application/x-pilot"],["pre","application/vnd.lotus-freelance"],["prf","application/pics-rules"],["provx","application/provenance+xml"],["ps","application/postscript"],["psb","application/vnd.3gpp.pic-bw-small"],["psd","application/x-photoshop"],["psf","application/x-font-linux-psf"],["pskcxml","application/pskc+xml"],["pti","image/prs.pti"],["ptid","application/vnd.pvi.ptid1"],["pub","application/x-mspublisher"],["pvb","application/vnd.3gpp.pic-bw-var"],["pwn","application/vnd.3m.post-it-notes"],["pya","audio/vnd.ms-playready.media.pya"],["pyv","video/vnd.ms-playready.media.pyv"],["qam","application/vnd.epson.quickanime"],["qbo","application/vnd.intu.qbo"],["qfx","application/vnd.intu.qfx"],["qps","application/vnd.publishare-delta-tree"],["qt","video/quicktime"],["qwd","application/vnd.quark.quarkxpress"],["qwt","application/vnd.quark.quarkxpress"],["qxb","application/vnd.quark.quarkxpress"],["qxd","application/vnd.quark.quarkxpress"],["qxl","application/vnd.quark.quarkxpress"],["qxt","application/vnd.quark.quarkxpress"],["ra","audio/x-realaudio"],["ram","audio/x-pn-realaudio"],["raml","application/raml+yaml"],["rapd","application/route-apd+xml"],["rar","application/x-rar"],["ras","image/x-cmu-raster"],["rcprofile","application/vnd.ipunplugged.rcprofile"],["rdf","application/rdf+xml"],["rdz","application/vnd.data-vision.rdz"],["relo","application/p2p-overlay+xml"],["rep","application/vnd.businessobjects"],["res","application/x-dtbresource+xml"],["rgb","image/x-rgb"],["rif","application/reginfo+xml"],["rip","audio/vnd.rip"],["ris","application/x-research-info-systems"],["rl","application/resource-lists+xml"],["rlc","image/vnd.fujixerox.edmics-rlc"],["rld","application/resource-lists-diff+xml"],["rm","audio/x-pn-realaudio"],["rmi","audio/midi"],["rmp","audio/x-pn-realaudio-plugin"],["rms","application/vnd.jcp.javame.midlet-rms"],["rmvb","application/vnd.rn-realmedia-vbr"],["rnc","application/relax-ng-compact-syntax"],["rng","application/xml"],["roa","application/rpki-roa"],["roff","text/troff"],["rp9","application/vnd.cloanto.rp9"],["rpm","audio/x-pn-realaudio-plugin"],["rpss","application/vnd.nokia.radio-presets"],["rpst","application/vnd.nokia.radio-preset"],["rq","application/sparql-query"],["rs","application/rls-services+xml"],["rsa","application/x-pkcs7"],["rsat","application/atsc-rsat+xml"],["rsd","application/rsd+xml"],["rsheet","application/urc-ressheet+xml"],["rss","application/rss+xml"],["rtf","text/rtf"],["rtx","text/richtext"],["run","application/x-makeself"],["rusd","application/route-usd+xml"],["rv","video/vnd.rn-realvideo"],["s","text/x-asm"],["s3m","audio/s3m"],["saf","application/vnd.yamaha.smaf-audio"],["sass","text/x-sass"],["sbml","application/sbml+xml"],["sc","application/vnd.ibm.secure-container"],["scd","application/x-msschedule"],["scm","application/vnd.lotus-screencam"],["scq","application/scvp-cv-request"],["scs","application/scvp-cv-response"],["scss","text/x-scss"],["scurl","text/vnd.curl.scurl"],["sda","application/vnd.stardivision.draw"],["sdc","application/vnd.stardivision.calc"],["sdd","application/vnd.stardivision.impress"],["sdkd","application/vnd.solent.sdkm+xml"],["sdkm","application/vnd.solent.sdkm+xml"],["sdp","application/sdp"],["sdw","application/vnd.stardivision.writer"],["sea","application/octet-stream"],["see","application/vnd.seemail"],["seed","application/vnd.fdsn.seed"],["sema","application/vnd.sema"],["semd","application/vnd.semd"],["semf","application/vnd.semf"],["senmlx","application/senml+xml"],["sensmlx","application/sensml+xml"],["ser","application/java-serialized-object"],["setpay","application/set-payment-initiation"],["setreg","application/set-registration-initiation"],["sfd-hdstx","application/vnd.hydrostatix.sof-data"],["sfs","application/vnd.spotfire.sfs"],["sfv","text/x-sfv"],["sgi","image/sgi"],["sgl","application/vnd.stardivision.writer-global"],["sgm","text/sgml"],["sgml","text/sgml"],["sh","application/x-sh"],["shar","application/x-shar"],["shex","text/shex"],["shf","application/shf+xml"],["shtml","text/html"],["sid","image/x-mrsid-image"],["sieve","application/sieve"],["sig","application/pgp-signature"],["sil","audio/silk"],["silo","model/mesh"],["sis","application/vnd.symbian.install"],["sisx","application/vnd.symbian.install"],["sit","application/x-stuffit"],["sitx","application/x-stuffitx"],["siv","application/sieve"],["skd","application/vnd.koan"],["skm","application/vnd.koan"],["skp","application/vnd.koan"],["skt","application/vnd.koan"],["sldm","application/vnd.ms-powerpoint.slide.macroenabled.12"],["sldx","application/vnd.openxmlformats-officedocument.presentationml.slide"],["slim","text/slim"],["slm","text/slim"],["sls","application/route-s-tsid+xml"],["slt","application/vnd.epson.salt"],["sm","application/vnd.stepmania.stepchart"],["smf","application/vnd.stardivision.math"],["smi","application/smil"],["smil","application/smil"],["smv","video/x-smv"],["smzip","application/vnd.stepmania.package"],["snd","audio/basic"],["snf","application/x-font-snf"],["so","application/octet-stream"],["spc","application/x-pkcs7-certificates"],["spdx","text/spdx"],["spf","application/vnd.yamaha.smaf-phrase"],["spl","application/x-futuresplash"],["spot","text/vnd.in3d.spot"],["spp","application/scvp-vp-response"],["spq","application/scvp-vp-request"],["spx","audio/ogg"],["sql","application/x-sql"],["src","application/x-wais-source"],["srt","application/x-subrip"],["sru","application/sru+xml"],["srx","application/sparql-results+xml"],["ssdl","application/ssdl+xml"],["sse","application/vnd.kodak-descriptor"],["ssf","application/vnd.epson.ssf"],["ssml","application/ssml+xml"],["sst","application/octet-stream"],["st","application/vnd.sailingtracker.track"],["stc","application/vnd.sun.xml.calc.template"],["std","application/vnd.sun.xml.draw.template"],["stf","application/vnd.wt.stf"],["sti","application/vnd.sun.xml.impress.template"],["stk","application/hyperstudio"],["stl","model/stl"],["stpx","model/step+xml"],["stpxz","model/step-xml+zip"],["stpz","model/step+zip"],["str","application/vnd.pg.format"],["stw","application/vnd.sun.xml.writer.template"],["styl","text/stylus"],["stylus","text/stylus"],["sub","text/vnd.dvb.subtitle"],["sus","application/vnd.sus-calendar"],["susp","application/vnd.sus-calendar"],["sv4cpio","application/x-sv4cpio"],["sv4crc","application/x-sv4crc"],["svc","application/vnd.dvb.service"],["svd","application/vnd.svd"],["svg","image/svg+xml"],["svgz","image/svg+xml"],["swa","application/x-director"],["swf","application/x-shockwave-flash"],["swi","application/vnd.aristanetworks.swi"],["swidtag","application/swid+xml"],["sxc","application/vnd.sun.xml.calc"],["sxd","application/vnd.sun.xml.draw"],["sxg","application/vnd.sun.xml.writer.global"],["sxi","application/vnd.sun.xml.impress"],["sxm","application/vnd.sun.xml.math"],["sxw","application/vnd.sun.xml.writer"],["t","text/troff"],["t3","application/x-t3vm-image"],["t38","image/t38"],["taglet","application/vnd.mynfc"],["tao","application/vnd.tao.intent-module-archive"],["tap","image/vnd.tencent.tap"],["tar","application/x-tar"],["tcap","application/vnd.3gpp2.tcap"],["tcl","application/x-tcl"],["td","application/urc-targetdesc+xml"],["teacher","application/vnd.smart.teacher"],["tei","application/tei+xml"],["teicorpus","application/tei+xml"],["tex","application/x-tex"],["texi","application/x-texinfo"],["texinfo","application/x-texinfo"],["text","text/plain"],["tfi","application/thraud+xml"],["tfm","application/x-tex-tfm"],["tfx","image/tiff-fx"],["tga","image/x-tga"],["tgz","application/x-tar"],["thmx","application/vnd.ms-officetheme"],["tif","image/tiff"],["tiff","image/tiff"],["tk","application/x-tcl"],["tmo","application/vnd.tmobile-livetv"],["toml","application/toml"],["torrent","application/x-bittorrent"],["tpl","application/vnd.groove-tool-template"],["tpt","application/vnd.trid.tpt"],["tr","text/troff"],["tra","application/vnd.trueapp"],["trig","application/trig"],["trm","application/x-msterminal"],["ts","video/mp2t"],["tsd","application/timestamped-data"],["tsv","text/tab-separated-values"],["ttc","font/collection"],["ttf","font/ttf"],["ttl","text/turtle"],["ttml","application/ttml+xml"],["twd","application/vnd.simtech-mindmapper"],["twds","application/vnd.simtech-mindmapper"],["txd","application/vnd.genomatix.tuxedo"],["txf","application/vnd.mobius.txf"],["txt","text/plain"],["u8dsn","message/global-delivery-status"],["u8hdr","message/global-headers"],["u8mdn","message/global-disposition-notification"],["u8msg","message/global"],["u32","application/x-authorware-bin"],["ubj","application/ubjson"],["udeb","application/x-debian-package"],["ufd","application/vnd.ufdl"],["ufdl","application/vnd.ufdl"],["ulx","application/x-glulx"],["umj","application/vnd.umajin"],["unityweb","application/vnd.unity"],["uoml","application/vnd.uoml+xml"],["uri","text/uri-list"],["uris","text/uri-list"],["urls","text/uri-list"],["usdz","model/vnd.usdz+zip"],["ustar","application/x-ustar"],["utz","application/vnd.uiq.theme"],["uu","text/x-uuencode"],["uva","audio/vnd.dece.audio"],["uvd","application/vnd.dece.data"],["uvf","application/vnd.dece.data"],["uvg","image/vnd.dece.graphic"],["uvh","video/vnd.dece.hd"],["uvi","image/vnd.dece.graphic"],["uvm","video/vnd.dece.mobile"],["uvp","video/vnd.dece.pd"],["uvs","video/vnd.dece.sd"],["uvt","application/vnd.dece.ttml+xml"],["uvu","video/vnd.uvvu.mp4"],["uvv","video/vnd.dece.video"],["uvva","audio/vnd.dece.audio"],["uvvd","application/vnd.dece.data"],["uvvf","application/vnd.dece.data"],["uvvg","image/vnd.dece.graphic"],["uvvh","video/vnd.dece.hd"],["uvvi","image/vnd.dece.graphic"],["uvvm","video/vnd.dece.mobile"],["uvvp","video/vnd.dece.pd"],["uvvs","video/vnd.dece.sd"],["uvvt","application/vnd.dece.ttml+xml"],["uvvu","video/vnd.uvvu.mp4"],["uvvv","video/vnd.dece.video"],["uvvx","application/vnd.dece.unspecified"],["uvvz","application/vnd.dece.zip"],["uvx","application/vnd.dece.unspecified"],["uvz","application/vnd.dece.zip"],["vbox","application/x-virtualbox-vbox"],["vbox-extpack","application/x-virtualbox-vbox-extpack"],["vcard","text/vcard"],["vcd","application/x-cdlink"],["vcf","text/x-vcard"],["vcg","application/vnd.groove-vcard"],["vcs","text/x-vcalendar"],["vcx","application/vnd.vcx"],["vdi","application/x-virtualbox-vdi"],["vds","model/vnd.sap.vds"],["vhd","application/x-virtualbox-vhd"],["vis","application/vnd.visionary"],["viv","video/vnd.vivo"],["vlc","application/videolan"],["vmdk","application/x-virtualbox-vmdk"],["vob","video/x-ms-vob"],["vor","application/vnd.stardivision.writer"],["vox","application/x-authorware-bin"],["vrml","model/vrml"],["vsd","application/vnd.visio"],["vsf","application/vnd.vsf"],["vss","application/vnd.visio"],["vst","application/vnd.visio"],["vsw","application/vnd.visio"],["vtf","image/vnd.valve.source.texture"],["vtt","text/vtt"],["vtu","model/vnd.vtu"],["vxml","application/voicexml+xml"],["w3d","application/x-director"],["wad","application/x-doom"],["wadl","application/vnd.sun.wadl+xml"],["war","application/java-archive"],["wasm","application/wasm"],["wav","audio/x-wav"],["wax","audio/x-ms-wax"],["wbmp","image/vnd.wap.wbmp"],["wbs","application/vnd.criticaltools.wbs+xml"],["wbxml","application/wbxml"],["wcm","application/vnd.ms-works"],["wdb","application/vnd.ms-works"],["wdp","image/vnd.ms-photo"],["weba","audio/webm"],["webapp","application/x-web-app-manifest+json"],["webm","video/webm"],["webmanifest","application/manifest+json"],["webp","image/webp"],["wg","application/vnd.pmi.widget"],["wgt","application/widget"],["wks","application/vnd.ms-works"],["wm","video/x-ms-wm"],["wma","audio/x-ms-wma"],["wmd","application/x-ms-wmd"],["wmf","image/wmf"],["wml","text/vnd.wap.wml"],["wmlc","application/wmlc"],["wmls","text/vnd.wap.wmlscript"],["wmlsc","application/vnd.wap.wmlscriptc"],["wmv","video/x-ms-wmv"],["wmx","video/x-ms-wmx"],["wmz","application/x-msmetafile"],["woff","font/woff"],["woff2","font/woff2"],["word","application/msword"],["wpd","application/vnd.wordperfect"],["wpl","application/vnd.ms-wpl"],["wps","application/vnd.ms-works"],["wqd","application/vnd.wqd"],["wri","application/x-mswrite"],["wrl","model/vrml"],["wsc","message/vnd.wfa.wsc"],["wsdl","application/wsdl+xml"],["wspolicy","application/wspolicy+xml"],["wtb","application/vnd.webturbo"],["wvx","video/x-ms-wvx"],["x3d","model/x3d+xml"],["x3db","model/x3d+fastinfoset"],["x3dbz","model/x3d+binary"],["x3dv","model/x3d-vrml"],["x3dvz","model/x3d+vrml"],["x3dz","model/x3d+xml"],["x32","application/x-authorware-bin"],["x_b","model/vnd.parasolid.transmit.binary"],["x_t","model/vnd.parasolid.transmit.text"],["xaml","application/xaml+xml"],["xap","application/x-silverlight-app"],["xar","application/vnd.xara"],["xav","application/xcap-att+xml"],["xbap","application/x-ms-xbap"],["xbd","application/vnd.fujixerox.docuworks.binder"],["xbm","image/x-xbitmap"],["xca","application/xcap-caps+xml"],["xcs","application/calendar+xml"],["xdf","application/xcap-diff+xml"],["xdm","application/vnd.syncml.dm+xml"],["xdp","application/vnd.adobe.xdp+xml"],["xdssc","application/dssc+xml"],["xdw","application/vnd.fujixerox.docuworks"],["xel","application/xcap-el+xml"],["xenc","application/xenc+xml"],["xer","application/patch-ops-error+xml"],["xfdf","application/vnd.adobe.xfdf"],["xfdl","application/vnd.xfdl"],["xht","application/xhtml+xml"],["xhtml","application/xhtml+xml"],["xhvml","application/xv+xml"],["xif","image/vnd.xiff"],["xl","application/excel"],["xla","application/vnd.ms-excel"],["xlam","application/vnd.ms-excel.addin.macroEnabled.12"],["xlc","application/vnd.ms-excel"],["xlf","application/xliff+xml"],["xlm","application/vnd.ms-excel"],["xls","application/vnd.ms-excel"],["xlsb","application/vnd.ms-excel.sheet.binary.macroEnabled.12"],["xlsm","application/vnd.ms-excel.sheet.macroEnabled.12"],["xlsx","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"],["xlt","application/vnd.ms-excel"],["xltm","application/vnd.ms-excel.template.macroEnabled.12"],["xltx","application/vnd.openxmlformats-officedocument.spreadsheetml.template"],["xlw","application/vnd.ms-excel"],["xm","audio/xm"],["xml","application/xml"],["xns","application/xcap-ns+xml"],["xo","application/vnd.olpc-sugar"],["xop","application/xop+xml"],["xpi","application/x-xpinstall"],["xpl","application/xproc+xml"],["xpm","image/x-xpixmap"],["xpr","application/vnd.is-xpr"],["xps","application/vnd.ms-xpsdocument"],["xpw","application/vnd.intercon.formnet"],["xpx","application/vnd.intercon.formnet"],["xsd","application/xml"],["xsl","application/xml"],["xslt","application/xslt+xml"],["xsm","application/vnd.syncml+xml"],["xspf","application/xspf+xml"],["xul","application/vnd.mozilla.xul+xml"],["xvm","application/xv+xml"],["xvml","application/xv+xml"],["xwd","image/x-xwindowdump"],["xyz","chemical/x-xyz"],["xz","application/x-xz"],["yaml","text/yaml"],["yang","application/yang"],["yin","application/yin+xml"],["yml","text/yaml"],["ymp","text/x-suse-ymp"],["z","application/x-compress"],["z1","application/x-zmachine"],["z2","application/x-zmachine"],["z3","application/x-zmachine"],["z4","application/x-zmachine"],["z5","application/x-zmachine"],["z6","application/x-zmachine"],["z7","application/x-zmachine"],["z8","application/x-zmachine"],["zaz","application/vnd.zzazz.deck+xml"],["zip","application/zip"],["zir","application/vnd.zul"],["zirz","application/vnd.zul"],["zmm","application/vnd.handheld-entertainment+xml"],["zsh","text/x-scriptzsh"]]);function jl(e,t,a){const n=V4(e),{webkitRelativePath:i}=e,o=typeof t=="string"?t:typeof i=="string"&&i.length>0?i:`./${e.name}`;return typeof n.path!="string"&&V0(n,"path",o),V0(n,"relativePath",o),n}function V4(e){const{name:t}=e;if(t&&t.lastIndexOf(".")!==-1&&!e.type){const n=t.split(".").pop().toLowerCase(),i=$4.get(n);i&&Object.defineProperty(e,"type",{value:i,writable:!1,configurable:!1,enumerable:!0})}return e}function V0(e,t,a){Object.defineProperty(e,t,{value:a,writable:!1,configurable:!1,enumerable:!0})}const K4=[".DS_Store","Thumbs.db"];function q4(e){return bs(this,void 0,void 0,function*(){return Op(e)&&G4(e.dataTransfer)?J4(e.dataTransfer,e.type):Z4(e)?Y4(e):Array.isArray(e)&&e.every(t=>"getFile"in t&&typeof t.getFile=="function")?X4(e):[]})}function G4(e){return Op(e)}function Z4(e){return Op(e)&&Op(e.target)}function Op(e){return typeof e=="object"&&e!==null}function Y4(e){return Xf(e.target.files).map(t=>jl(t))}function X4(e){return bs(this,void 0,void 0,function*(){return(yield Promise.all(e.map(a=>a.getFile()))).map(a=>jl(a))})}function J4(e,t){return bs(this,void 0,void 0,function*(){if(e.items){const a=Xf(e.items).filter(i=>i.kind==="file");if(t!=="drop")return a;const n=yield Promise.all(a.map(Q4));return K0(Q_(n))}return K0(Xf(e.files).map(a=>jl(a)))})}function K0(e){return e.filter(t=>K4.indexOf(t.name)===-1)}function Xf(e){if(e===null)return[];const t=[];for(let a=0;a[...t,...Array.isArray(a)?Q_(a):[a]],[])}function q0(e,t){return bs(this,void 0,void 0,function*(){var a;if(globalThis.isSecureContext&&typeof e.getAsFileSystemHandle=="function"){const o=yield e.getAsFileSystemHandle();if(o===null)throw new Error(`${e} is not a File`);if(o!==void 0){const s=yield o.getFile();return s.handle=o,jl(s)}}const n=e.getAsFile();if(!n)throw new Error(`${e} is not a File`);return jl(n,(a=t==null?void 0:t.fullPath)!==null&&a!==void 0?a:void 0)})}function eL(e){return bs(this,void 0,void 0,function*(){return e.isDirectory?eC(e):tL(e)})}function eC(e){const t=e.createReader();return new Promise((a,n)=>{const i=[];function o(){t.readEntries(s=>bs(this,void 0,void 0,function*(){if(s.length){const d=Promise.all(s.map(eL));i.push(d),o()}else try{const d=yield Promise.all(i);a(d)}catch(d){n(d)}}),s=>{n(s)})}o()})}function tL(e){return bs(this,void 0,void 0,function*(){return new Promise((t,a)=>{e.file(n=>{const i=jl(n,e.fullPath);t(i)},n=>{a(n)})})})}var ih=function(e,t){if(e&&t){var a=Array.isArray(t)?t:t.split(",");if(a.length===0)return!0;var n=e.name||"",i=(e.type||"").toLowerCase(),o=i.replace(/\/.*$/,"");return a.some(function(s){var d=s.trim().toLowerCase();return d.charAt(0)==="."?n.toLowerCase().endsWith(d):d.endsWith("/*")?o===d.replace(/\/.*$/,""):i===d})}return!0};function G0(e){return rL(e)||nL(e)||aC(e)||aL()}function aL(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
+In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function nL(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function rL(e){if(Array.isArray(e))return Jf(e)}function Z0(e,t){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),a.push.apply(a,n)}return a}function Y0(e){for(var t=1;te.length)&&(t=e.length);for(var a=0,n=new Array(t);a0&&arguments[0]!==void 0?arguments[0]:"",a=t.split(","),n=a.length>1?"one of ".concat(a.join(", ")):a[0];return{code:dL,message:"File type must be ".concat(n)}},X0=function(t){return{code:cL,message:"File is larger than ".concat(t," ").concat(t===1?"byte":"bytes")}},J0=function(t){return{code:uL,message:"File is smaller than ".concat(t," ").concat(t===1?"byte":"bytes")}},gL={code:pL,message:"Too many files"};function hL(e){return e.type===""&&typeof e.getAsFile=="function"}function nC(e,t){var a=e.type==="application/x-moz-file"||lL(e,t)||hL(e);return[a,a?null:mL(t)]}function rC(e,t,a){if($o(e.size))if($o(t)&&$o(a)){if(e.size>a)return[!1,X0(a)];if(e.sizea)return[!1,X0(a)]}return[!0,null]}function $o(e){return e!=null}function fL(e){var t=e.files,a=e.accept,n=e.minSize,i=e.maxSize,o=e.multiple,s=e.maxFiles,d=e.validator;return!o&&t.length>1||o&&s>=1&&t.length>s?!1:t.every(function(c){var p=nC(c,a),m=oc(p,1),g=m[0],f=rC(c,n,i),y=oc(f,1),x=y[0],k=d?d(c):null;return g&&x&&!k})}function Bp(e){return typeof e.isPropagationStopped=="function"?e.isPropagationStopped():typeof e.cancelBubble<"u"?e.cancelBubble:!1}function od(e){return e.dataTransfer?Array.prototype.some.call(e.dataTransfer.types,function(t){return t==="Files"||t==="application/x-moz-file"}):!!e.target&&!!e.target.files}function Q0(e){e.preventDefault()}function yL(e){return e.indexOf("MSIE")!==-1||e.indexOf("Trident/")!==-1}function vL(e){return e.indexOf("Edge/")!==-1}function bL(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:window.navigator.userAgent;return yL(e)||vL(e)}function Zr(){for(var e=arguments.length,t=new Array(e),a=0;a1?i-1:0),s=1;se.length)&&(t=e.length);for(var a=0,n=new Array(t);a=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}function DL(e,t){if(e==null)return{};var a={},n=Object.keys(e),i,o;for(o=0;o=0)&&(a[i]=e[i]);return a}var ab=b.forwardRef(function(e,t){var a=e.children,n=Hp(e,_L),i=dC(n),o=i.open,s=Hp(i,CL);return b.useImperativeHandle(t,function(){return{open:o}},[o]),Ka.createElement(b.Fragment,null,a(ua(ua({},s),{},{open:o})))});ab.displayName="Dropzone";var lC={disabled:!1,getFilesFromEvent:q4,maxSize:1/0,minSize:0,multiple:!0,maxFiles:0,preventDropOnDocument:!0,noClick:!1,noKeyboard:!1,noDrag:!1,noDragEventsBubbling:!1,validator:null,useFsAccessApi:!1,autoFocus:!1};ab.defaultProps=lC;ab.propTypes={children:Qt.func,accept:Qt.objectOf(Qt.arrayOf(Qt.string)),multiple:Qt.bool,preventDropOnDocument:Qt.bool,noClick:Qt.bool,noKeyboard:Qt.bool,noDrag:Qt.bool,noDragEventsBubbling:Qt.bool,minSize:Qt.number,maxSize:Qt.number,maxFiles:Qt.number,disabled:Qt.bool,getFilesFromEvent:Qt.func,onFileDialogCancel:Qt.func,onFileDialogOpen:Qt.func,useFsAccessApi:Qt.bool,autoFocus:Qt.bool,onDragEnter:Qt.func,onDragLeave:Qt.func,onDragOver:Qt.func,onDrop:Qt.func,onDropAccepted:Qt.func,onDropRejected:Qt.func,onError:Qt.func,validator:Qt.func};var ty={isFocused:!1,isFileDialogActive:!1,isDragActive:!1,isDragAccept:!1,isDragReject:!1,isDragGlobal:!1,acceptedFiles:[],fileRejections:[]};function dC(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=ua(ua({},lC),e),a=t.accept,n=t.disabled,i=t.getFilesFromEvent,o=t.maxSize,s=t.minSize,d=t.multiple,c=t.maxFiles,p=t.onDragEnter,m=t.onDragLeave,g=t.onDragOver,f=t.onDrop,y=t.onDropAccepted,x=t.onDropRejected,k=t.onFileDialogCancel,S=t.onFileDialogOpen,v=t.useFsAccessApi,_=t.autoFocus,w=t.preventDropOnDocument,E=t.noClick,M=t.noKeyboard,A=t.noDrag,P=t.noDragEventsBubbling,R=t.onError,$=t.validator,I=b.useMemo(function(){return wL(a)},[a]),Y=b.useMemo(function(){return kL(a)},[a]),H=b.useMemo(function(){return typeof S=="function"?S:a1},[S]),V=b.useMemo(function(){return typeof k=="function"?k:a1},[k]),X=b.useRef(null),Z=b.useRef(null),O=b.useReducer(IL,ty),Q=oh(O,2),D=Q[0],J=Q[1],z=D.isFocused,W=D.isFileDialogActive,B=b.useRef(typeof window<"u"&&window.isSecureContext&&v&&xL()),C=function(){!B.current&&W&&setTimeout(function(){if(Z.current){var ne=Z.current.files;ne.length||(J({type:"closeDialog"}),V())}},300)};b.useEffect(function(){return window.addEventListener("focus",C,!1),function(){window.removeEventListener("focus",C,!1)}},[Z,W,V,B]);var U=b.useRef([]),q=b.useRef([]),te=function(ne){X.current&&X.current.contains(ne.target)||(ne.preventDefault(),U.current=[])};b.useEffect(function(){return w&&(document.addEventListener("dragover",Q0,!1),document.addEventListener("drop",te,!1)),function(){w&&(document.removeEventListener("dragover",Q0),document.removeEventListener("drop",te))}},[X,w]),b.useEffect(function(){var ye=function(Ke){q.current=[].concat(e1(q.current),[Ke.target]),od(Ke)&&J({isDragGlobal:!0,type:"setDragGlobal"})},ne=function(Ke){q.current=q.current.filter(function(dt){return dt!==Ke.target&&dt!==null}),!(q.current.length>0)&&J({isDragGlobal:!1,type:"setDragGlobal"})},fe=function(){q.current=[],J({isDragGlobal:!1,type:"setDragGlobal"})},Ee=function(){q.current=[],J({isDragGlobal:!1,type:"setDragGlobal"})};return document.addEventListener("dragenter",ye,!1),document.addEventListener("dragleave",ne,!1),document.addEventListener("dragend",fe,!1),document.addEventListener("drop",Ee,!1),function(){document.removeEventListener("dragenter",ye),document.removeEventListener("dragleave",ne),document.removeEventListener("dragend",fe),document.removeEventListener("drop",Ee)}},[X]),b.useEffect(function(){return!n&&_&&X.current&&X.current.focus(),function(){}},[X,_,n]);var oe=b.useCallback(function(ye){R?R(ye):console.error(ye)},[R]),be=b.useCallback(function(ye){ye.preventDefault(),ye.persist(),Ye(ye),U.current=[].concat(e1(U.current),[ye.target]),od(ye)&&Promise.resolve(i(ye)).then(function(ne){if(!(Bp(ye)&&!P)){var fe=ne.length,Ee=fe>0&&fL({files:ne,accept:I,minSize:s,maxSize:o,multiple:d,maxFiles:c,validator:$}),Oe=fe>0&&!Ee;J({isDragAccept:Ee,isDragReject:Oe,isDragActive:!0,type:"setDraggedFiles"}),p&&p(ye)}}).catch(function(ne){return oe(ne)})},[i,p,oe,P,I,s,o,d,c,$]),Se=b.useCallback(function(ye){ye.preventDefault(),ye.persist(),Ye(ye);var ne=od(ye);if(ne&&ye.dataTransfer)try{ye.dataTransfer.dropEffect="copy"}catch{}return ne&&g&&g(ye),!1},[g,P]),je=b.useCallback(function(ye){ye.preventDefault(),ye.persist(),Ye(ye);var ne=U.current.filter(function(Ee){return X.current&&X.current.contains(Ee)}),fe=ne.indexOf(ye.target);fe!==-1&&ne.splice(fe,1),U.current=ne,!(ne.length>0)&&(J({type:"setDraggedFiles",isDragActive:!1,isDragAccept:!1,isDragReject:!1}),od(ye)&&m&&m(ye))},[X,m,P]),we=b.useCallback(function(ye,ne){var fe=[],Ee=[];ye.forEach(function(Oe){var Ke=nC(Oe,I),dt=oh(Ke,2),Wt=dt[0],Be=dt[1],Gt=rC(Oe,s,o),Kt=oh(Gt,2),Lt=Kt[0],Ce=Kt[1],De=$?$(Oe):null;if(Wt&&Lt&&!De)fe.push(Oe);else{var Qe=[Be,Ce];De&&(Qe=Qe.concat(De)),Ee.push({file:Oe,errors:Qe.filter(function(ft){return ft})})}}),(!d&&fe.length>1||d&&c>=1&&fe.length>c)&&(fe.forEach(function(Oe){Ee.push({file:Oe,errors:[gL]})}),fe.splice(0)),J({acceptedFiles:fe,fileRejections:Ee,isDragReject:Ee.length>0,type:"setFiles"}),f&&f(fe,Ee,ne),Ee.length>0&&x&&x(Ee,ne),fe.length>0&&y&&y(fe,ne)},[J,d,I,s,o,c,f,y,x,$]),ce=b.useCallback(function(ye){ye.preventDefault(),ye.persist(),Ye(ye),U.current=[],od(ye)&&Promise.resolve(i(ye)).then(function(ne){Bp(ye)&&!P||we(ne,ye)}).catch(function(ne){return oe(ne)}),J({type:"reset"})},[i,we,oe,P]),le=b.useCallback(function(){if(B.current){J({type:"openDialog"}),H();var ye={multiple:d,types:Y};window.showOpenFilePicker(ye).then(function(ne){return i(ne)}).then(function(ne){we(ne,null),J({type:"closeDialog"})}).catch(function(ne){SL(ne)?(V(ne),J({type:"closeDialog"})):jL(ne)?(B.current=!1,Z.current?(Z.current.value=null,Z.current.click()):oe(new Error("Cannot open the file picker because the https://developer.mozilla.org/en-US/docs/Web/API/File_System_Access_API is not supported and no was provided."))):oe(ne)});return}Z.current&&(J({type:"openDialog"}),H(),Z.current.value=null,Z.current.click())},[J,H,V,v,we,oe,Y,d]),K=b.useCallback(function(ye){!X.current||!X.current.isEqualNode(ye.target)||(ye.key===" "||ye.key==="Enter"||ye.keyCode===32||ye.keyCode===13)&&(ye.preventDefault(),le())},[X,le]),de=b.useCallback(function(){J({type:"focus"})},[]),_e=b.useCallback(function(){J({type:"blur"})},[]),pe=b.useCallback(function(){E||(bL()?setTimeout(le,0):le())},[E,le]),Ae=function(ne){return n?null:ne},He=function(ne){return M?null:Ae(ne)},ze=function(ne){return A?null:Ae(ne)},Ye=function(ne){P&&ne.stopPropagation()},G=b.useMemo(function(){return function(){var ye=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},ne=ye.refKey,fe=ne===void 0?"ref":ne,Ee=ye.role,Oe=ye.onKeyDown,Ke=ye.onFocus,dt=ye.onBlur,Wt=ye.onClick,Be=ye.onDragEnter,Gt=ye.onDragOver,Kt=ye.onDragLeave,Lt=ye.onDrop,Ce=Hp(ye,zL);return ua(ua(ey({onKeyDown:He(Zr(Oe,K)),onFocus:He(Zr(Ke,de)),onBlur:He(Zr(dt,_e)),onClick:Ae(Zr(Wt,pe)),onDragEnter:ze(Zr(Be,be)),onDragOver:ze(Zr(Gt,Se)),onDragLeave:ze(Zr(Kt,je)),onDrop:ze(Zr(Lt,ce)),role:typeof Ee=="string"&&Ee!==""?Ee:"presentation"},fe,X),!n&&!M?{tabIndex:0}:{}),Ce)}},[X,K,de,_e,pe,be,Se,je,ce,M,A,n]),ve=b.useCallback(function(ye){ye.stopPropagation()},[]),Pe=b.useMemo(function(){return function(){var ye=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},ne=ye.refKey,fe=ne===void 0?"ref":ne,Ee=ye.onChange,Oe=ye.onClick,Ke=Hp(ye,TL),dt=ey({accept:I,multiple:d,type:"file",style:{border:0,clip:"rect(0, 0, 0, 0)",clipPath:"inset(50%)",height:"1px",margin:"0 -1px -1px 0",overflow:"hidden",padding:0,position:"absolute",width:"1px",whiteSpace:"nowrap"},onChange:Ae(Zr(Ee,ce)),onClick:Ae(Zr(Oe,ve)),tabIndex:-1},fe,Z);return ua(ua({},dt),Ke)}},[Z,a,d,ce,n]);return ua(ua({},D),{},{isFocused:z&&!n,getRootProps:G,getInputProps:Pe,rootRef:X,inputRef:Z,open:Ae(le)})}function IL(e,t){switch(t.type){case"focus":return ua(ua({},e),{},{isFocused:!0});case"blur":return ua(ua({},e),{},{isFocused:!1});case"openDialog":return ua(ua({},ty),{},{isFileDialogActive:!0});case"closeDialog":return ua(ua({},e),{},{isFileDialogActive:!1});case"setDraggedFiles":return ua(ua({},e),{},{isDragActive:t.isDragActive,isDragAccept:t.isDragAccept,isDragReject:t.isDragReject});case"setFiles":return ua(ua({},e),{},{acceptedFiles:t.acceptedFiles,fileRejections:t.fileRejections,isDragReject:t.isDragReject});case"setDragGlobal":return ua(ua({},e),{},{isDragGlobal:t.isDragGlobal});case"reset":return ua({},ty);default:return e}}function a1(){}function qu(e){return e?e.startsWith("image/"):!1}function LL(e){return e?e==="application/pdf"?Pa:qu(e)?y_:Ff:Ff}function FL(e){return e?e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(1)} MB`:""}function OL(e,t){if(!e)return"";try{return new Date(e).toLocaleDateString(t,{day:"2-digit",month:"2-digit",year:"numeric"})}catch{return""}}function BL({file:e,onClose:t}){const{t:a}=ot();return r.jsx("div",{style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.88)",zIndex:2e3,display:"flex",alignItems:"center",justifyContent:"center"},onClick:t,children:r.jsxs("div",{style:{position:"relative",maxWidth:"90vw",maxHeight:"90vh"},onClick:n=>n.stopPropagation(),children:[r.jsx("img",{src:e.url,alt:e.original_name,style:{maxWidth:"90vw",maxHeight:"90vh",objectFit:"contain",borderRadius:8,display:"block"}}),r.jsxs("div",{style:{position:"absolute",top:-40,left:0,right:0,display:"flex",alignItems:"center",justifyContent:"space-between",padding:"0 4px"},children:[r.jsx("span",{style:{fontSize:12,color:"rgba(255,255,255,0.7)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:"80%"},children:e.original_name}),r.jsxs("div",{style:{display:"flex",gap:8},children:[r.jsx("a",{href:e.url,target:"_blank",rel:"noreferrer",style:{color:"rgba(255,255,255,0.7)",display:"flex"},title:a("files.openTab"),children:r.jsx(xn,{size:16})}),r.jsx("button",{onClick:t,style:{background:"none",border:"none",cursor:"pointer",color:"rgba(255,255,255,0.7)",display:"flex",padding:0},children:r.jsx(gt,{size:18})})]})]})]})})}function sh({icon:e,label:t}){return r.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:4,fontSize:10.5,color:"#4b5563",background:"var(--bg-tertiary)",border:"1px solid var(--border-primary)",borderRadius:6,padding:"2px 7px",fontWeight:500,maxWidth:"100%",overflow:"hidden"},children:[r.jsx(e,{size:10,style:{flexShrink:0,color:"var(--text-muted)"}}),r.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t})]})}function HL({name:e,avatarUrl:t,size:a=20}){var p;const[n,i]=b.useState(!1),[o,s]=b.useState({top:0,left:0}),d=b.useRef(null),c=()=>{if(d.current){const m=d.current.getBoundingClientRect();s({top:m.top-6,left:m.left+m.width/2})}i(!0)};return r.jsxs(r.Fragment,{children:[r.jsx("div",{ref:d,onMouseEnter:c,onMouseLeave:()=>i(!1),style:{width:a,height:a,borderRadius:"50%",border:"1.5px solid var(--border-primary)",background:"var(--bg-tertiary)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:a*.4,fontWeight:700,color:"var(--text-muted)",overflow:"hidden",flexShrink:0,cursor:"default"},children:t?r.jsx("img",{src:t,style:{width:"100%",height:"100%",objectFit:"cover"}}):(p=e==null?void 0:e[0])==null?void 0:p.toUpperCase()}),n&&Vt.createPortal(r.jsx("div",{style:{position:"fixed",top:o.top,left:o.left,transform:"translate(-50%, -100%)",background:"var(--bg-elevated)",color:"var(--text-primary)",fontSize:11,fontWeight:500,padding:"3px 8px",borderRadius:6,boxShadow:"0 2px 8px rgba(0,0,0,0.15)",whiteSpace:"nowrap",zIndex:9999,pointerEvents:"none"},children:e}),document.body)]})}function cC({files:e=[],onUpload:t,onDelete:a,onUpdate:n,places:i,days:o=[],assignments:s={},reservations:d=[],tripId:c,allowedFileTypes:p}){var ce,le;const[m,g]=b.useState(!1),[f,y]=b.useState("all"),[x,k]=b.useState(null),[S,v]=b.useState(!1),[_,w]=b.useState([]),[E,M]=b.useState(!1),A=ya(),{t:P,locale:R}=ot(),$=b.useCallback(async()=>{M(!0);try{const K=await fn.list(c,!0);w(K.files||[])}catch{}M(!1)},[c]),I=b.useCallback(()=>{S||$(),v(K=>!K)},[S,$]),Y=b.useCallback(async()=>{n&&n(0,{})},[n]),H=async K=>{try{await fn.toggleStar(c,K),Y()}catch{}},V=async K=>{try{await fn.restore(c,K),w(de=>de.filter(_e=>_e.id!==K)),Y(),A.success(P("files.toast.restored"))}catch{A.error(P("files.toast.restoreError"))}},X=async K=>{if(confirm(P("files.confirm.permanentDelete")))try{await fn.permanentDelete(c,K),w(de=>de.filter(_e=>_e.id!==K)),A.success(P("files.toast.deleted"))}catch{A.error(P("files.toast.deleteError"))}},Z=async()=>{if(confirm(P("files.confirm.emptyTrash")))try{await fn.emptyTrash(c),w([]),A.success(P("files.toast.trashEmptied")||"Trash emptied")}catch{A.error(P("files.toast.deleteError"))}},[O,Q]=b.useState([]),D=b.useCallback(async K=>{if(K.length===0)return;g(!0);const de=[];try{for(const pe of K){const Ae=new FormData;Ae.append("file",pe);const He=await t(Ae),ze=(He==null?void 0:He.file)||He;ze!=null&&ze.id&&de.push(ze.id)}A.success(P("files.uploaded",{count:K.length}));const _e=de[de.length-1];_e&&(i.length>0||d.length>0)&&be(_e)}catch{A.error(P("files.uploadError"))}finally{g(!1)}},[t,A,P,i,d]),{getRootProps:J,getInputProps:z,isDragActive:W}=dC({onDrop:D,maxSize:50*1024*1024,noClick:!1}),B=b.useCallback(K=>{var pe;const de=(pe=K.clipboardData)==null?void 0:pe.items;if(!de)return;const _e=[];for(const Ae of Array.from(de))if(Ae.kind==="file"){const He=Ae.getAsFile();He&&_e.push(He)}_e.length>0&&(K.preventDefault(),D(_e))},[D]),C=e.filter(K=>f==="starred"?!!K.starred:f==="pdf"?K.mime_type==="application/pdf":f==="image"?qu(K.mime_type):f==="doc"?(K.mime_type||"").includes("word")||(K.mime_type||"").includes("excel")||(K.mime_type||"").includes("text"):f==="collab"?!!K.note_id:!0),U=async K=>{try{await a(K),A.success(P("files.toast.trashed")||"Moved to trash")}catch{A.error(P("files.toast.deleteError"))}},[q,te]=b.useState(null),[oe,be]=b.useState(null),Se=async(K,de)=>{try{await fn.update(c,K,de),Y()}catch{A.error(P("files.toast.assignError"))}},je=K=>{qu(K.mime_type)?k(K):te(K)},we=(K,de=!1)=>{var Ye;LL(K.mime_type);const _e=new Set;K.place_id&&_e.add(K.place_id);for(const G of K.linked_place_ids||[])_e.add(G);const pe=[..._e].map(G=>i==null?void 0:i.find(ve=>ve.id===G)).filter(Boolean),Ae=new Set;K.reservation_id&&Ae.add(K.reservation_id);for(const G of K.linked_reservation_ids||[])Ae.add(G);const He=[...Ae].map(G=>d==null?void 0:d.find(ve=>ve.id===G)).filter(Boolean),ze=K.url||((Ye=K.filename)!=null&&Ye.startsWith("files/")?`/uploads/${K.filename}`:`/uploads/files/${K.filename}`);return r.jsxs("div",{style:{background:"var(--bg-card)",border:"1px solid var(--border-primary)",borderRadius:12,padding:"10px 12px",display:"flex",alignItems:"flex-start",gap:10,transition:"border-color 0.12s",opacity:de?.7:1},onMouseEnter:G=>G.currentTarget.style.borderColor="var(--text-faint)",onMouseLeave:G=>G.currentTarget.style.borderColor="var(--border-primary)",className:"group",children:[r.jsx("div",{onClick:()=>!de&&je({...K,url:ze}),style:{flexShrink:0,width:36,height:36,borderRadius:8,background:"var(--bg-tertiary)",display:"flex",alignItems:"center",justifyContent:"center",cursor:de?"default":"pointer",overflow:"hidden"},children:qu(K.mime_type)?r.jsx("img",{src:ze,alt:"",style:{width:"100%",height:"100%",objectFit:"cover"}}):(()=>{var Pe;const G=((Pe=(K.original_name||"").split(".").pop())==null?void 0:Pe.toUpperCase())||"?",ve=K.mime_type==="application/pdf";return r.jsx("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",width:"100%",height:"100%",background:ve?"#ef44441a":"var(--bg-tertiary)"},children:r.jsx("span",{style:{fontSize:9,fontWeight:700,color:ve?"#ef4444":"var(--text-muted)",letterSpacing:.3},children:G})})})()}),r.jsxs("div",{style:{flex:1,minWidth:0},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:5},children:[K.uploaded_by_name&&r.jsx(HL,{name:K.uploaded_by_name,avatarUrl:K.uploaded_by_avatar,size:20}),!de&&K.starred?r.jsx(si,{size:12,fill:"#facc15",color:"#facc15",style:{flexShrink:0}}):null,r.jsx("span",{onClick:()=>!de&&je({...K,url:ze}),style:{fontWeight:500,fontSize:13,color:"var(--text-primary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",cursor:de?"default":"pointer"},children:K.original_name})]}),K.description&&r.jsx("p",{style:{fontSize:11.5,color:"var(--text-faint)",margin:"2px 0 0",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:K.description}),r.jsxs("div",{style:{display:"flex",alignItems:"center",flexWrap:"wrap",gap:6,marginTop:4},children:[K.file_size&&r.jsx("span",{style:{fontSize:11,color:"var(--text-faint)"},children:FL(K.file_size)}),r.jsx("span",{style:{fontSize:11,color:"var(--text-faint)"},children:OL(K.created_at,R)}),pe.map(G=>r.jsx(sh,{icon:tn,label:`${P("files.sourcePlan")} · ${G.name}`},G.id)),He.map(G=>r.jsx(sh,{icon:kn,label:`${P("files.sourceBooking")} · ${G.title||P("files.sourceBooking")}`},G.id)),K.note_id&&r.jsx(sh,{icon:Ov,label:P("files.sourceCollab")||"Collab Notes"})]})]}),r.jsx("div",{className:"file-actions",style:{display:"flex",gap:2,flexShrink:0},children:de?r.jsxs(r.Fragment,{children:[r.jsx("button",{onClick:()=>V(K.id),title:P("files.restore")||"Restore",style:{padding:6,background:"none",border:"none",cursor:"pointer",color:"var(--text-faint)",borderRadius:6,display:"flex"},onMouseEnter:G=>G.currentTarget.style.color="#22c55e",onMouseLeave:G=>G.currentTarget.style.color="var(--text-faint)",children:r.jsx(Fm,{size:14})}),r.jsx("button",{onClick:()=>X(K.id),title:P("common.delete"),style:{padding:6,background:"none",border:"none",cursor:"pointer",color:"var(--text-faint)",borderRadius:6,display:"flex"},onMouseEnter:G=>G.currentTarget.style.color="#ef4444",onMouseLeave:G=>G.currentTarget.style.color="var(--text-faint)",children:r.jsx(_t,{size:14})})]}):r.jsxs(r.Fragment,{children:[r.jsx("button",{onClick:()=>H(K.id),title:K.starred?P("files.unstar")||"Unstar":P("files.star")||"Star",style:{padding:6,background:"none",border:"none",cursor:"pointer",color:K.starred?"#facc15":"var(--text-faint)",borderRadius:6,display:"flex"},onMouseEnter:G=>{K.starred||(G.currentTarget.style.color="#facc15")},onMouseLeave:G=>{K.starred||(G.currentTarget.style.color="var(--text-faint)")},children:r.jsx(si,{size:14,fill:K.starred?"#facc15":"none"})}),r.jsx("button",{onClick:()=>be(K.id),title:P("files.assign")||"Assign",style:{padding:6,background:"none",border:"none",cursor:"pointer",color:"var(--text-faint)",borderRadius:6,display:"flex"},onMouseEnter:G=>G.currentTarget.style.color="var(--text-primary)",onMouseLeave:G=>G.currentTarget.style.color="var(--text-faint)",children:r.jsx(sn,{size:14})}),r.jsx("button",{onClick:()=>je({...K,url:ze}),title:P("common.open"),style:{padding:6,background:"none",border:"none",cursor:"pointer",color:"var(--text-faint)",borderRadius:6,display:"flex"},onMouseEnter:G=>G.currentTarget.style.color="var(--text-primary)",onMouseLeave:G=>G.currentTarget.style.color="var(--text-faint)",children:r.jsx(xn,{size:14})}),r.jsx("button",{onClick:()=>U(K.id),title:P("common.delete"),style:{padding:6,background:"none",border:"none",cursor:"pointer",color:"var(--text-faint)",borderRadius:6,display:"flex"},onMouseEnter:G=>G.currentTarget.style.color="#ef4444",onMouseLeave:G=>G.currentTarget.style.color="var(--text-faint)",children:r.jsx(_t,{size:14})})]})})]},K.id)};return r.jsxs("div",{className:"flex flex-col h-full",style:{fontFamily:"-apple-system, BlinkMacSystemFont, 'SF Pro Text', system-ui, sans-serif"},onPaste:B,tabIndex:-1,children:[x&&r.jsx(BL,{file:x,onClose:()=>k(null)}),oe&&Vt.createPortal(r.jsx("div",{style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.5)",zIndex:5e3,display:"flex",alignItems:"center",justifyContent:"center"},onClick:()=>be(null),children:r.jsxs("div",{style:{background:"var(--bg-card)",borderRadius:16,boxShadow:"0 20px 60px rgba(0,0,0,0.2)",width:"min(600px, calc(100vw - 32px))",maxHeight:"70vh",overflow:"hidden",display:"flex",flexDirection:"column"},onClick:K=>K.stopPropagation(),children:[r.jsxs("div",{style:{padding:"16px 20px 12px",borderBottom:"1px solid var(--border-primary)",display:"flex",alignItems:"center",justifyContent:"space-between",gap:12},children:[r.jsxs("div",{style:{flex:1,minWidth:0},children:[r.jsx("div",{style:{fontSize:15,fontWeight:600,color:"var(--text-primary)"},children:P("files.assignTitle")}),r.jsx("div",{style:{fontSize:12,color:"var(--text-faint)",marginTop:2,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:((ce=e.find(K=>K.id===oe))==null?void 0:ce.original_name)||""})]}),r.jsx("button",{onClick:()=>be(null),style:{background:"none",border:"none",cursor:"pointer",color:"var(--text-faint)",padding:4,display:"flex",flexShrink:0},children:r.jsx(gt,{size:18})})]}),r.jsxs("div",{style:{padding:"8px 12px 0"},children:[r.jsx("div",{style:{fontSize:11,fontWeight:600,color:"var(--text-faint)",padding:"0 2px 4px",textTransform:"uppercase",letterSpacing:.5},children:P("files.noteLabel")||"Note"}),r.jsx("input",{type:"text",placeholder:P("files.notePlaceholder"),defaultValue:((le=e.find(K=>K.id===oe))==null?void 0:le.description)||"",onBlur:K=>{const de=K.target.value.trim(),_e=e.find(pe=>pe.id===oe);_e&&de!==(_e.description||"")&&Se(_e.id,{description:de})},onKeyDown:K=>{K.key==="Enter"&&K.target.blur()},style:{width:"100%",padding:"7px 10px",fontSize:13,borderRadius:8,border:"1px solid var(--border-primary)",background:"var(--bg-secondary)",color:"var(--text-primary)",fontFamily:"inherit",outline:"none"}})]}),r.jsx("div",{style:{overflowY:"auto",padding:8},children:(()=>{const K=e.find(G=>G.id===oe);if(!K)return null;const de=new Set,_e=[];for(const G of o){const Pe=(s[String(G.id)]||[]).map(ye=>i.find(ne=>{var fe;return ne.id===((fe=ye.place)==null?void 0:fe.id)||ne.id===ye.place_id})).filter(Boolean);Pe.length>0&&(_e.push({day:G,dayPlaces:Pe}),Pe.forEach(ye=>de.add(ye.id)))}const pe=i.filter(G=>!de.has(G.id)),Ae=G=>{const ve=K.place_id===G.id||(K.linked_place_ids||[]).includes(G.id);return r.jsxs("button",{onClick:async()=>{if(ve)if(K.place_id===G.id)await Se(K.id,{place_id:null});else try{const ye=((await fn.getLinks(c,K.id)).links||[]).find(ne=>ne.place_id===G.id);ye&&await fn.removeLink(c,K.id,ye.id),Y()}catch{}else if(!K.place_id)await Se(K.id,{place_id:G.id});else try{await fn.addLink(c,K.id,{place_id:G.id}),Y()}catch{}},style:{width:"100%",textAlign:"left",padding:"6px 10px 6px 20px",background:ve?"var(--bg-hover)":"none",border:"none",cursor:"pointer",fontSize:13,color:"var(--text-primary)",borderRadius:8,fontFamily:"inherit",fontWeight:ve?600:400,display:"flex",alignItems:"center",gap:6},onMouseEnter:Pe=>Pe.currentTarget.style.background="var(--bg-hover)",onMouseLeave:Pe=>Pe.currentTarget.style.background=ve?"var(--bg-hover)":"transparent",children:[r.jsx(tn,{size:12,style:{flexShrink:0,color:"var(--text-muted)"}}),r.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:G.name}),ve&&r.jsx(Ga,{size:14,style:{marginLeft:"auto",flexShrink:0,color:"var(--accent)"}})]},G.id)},He=i.length>0&&r.jsxs("div",{style:{flex:1,minWidth:0},children:[r.jsx("div",{style:{fontSize:11,fontWeight:600,color:"var(--text-faint)",padding:"8px 10px 4px",textTransform:"uppercase",letterSpacing:.5},children:P("files.assignPlace")}),_e.map(({day:G,dayPlaces:ve})=>r.jsxs("div",{children:[r.jsx("div",{style:{fontSize:11,fontWeight:600,color:"var(--text-muted)",padding:"8px 10px 2px"},children:G.title||`${P("dayplan.dayN",{n:G.day_number})}${G.date?` · ${G.date}`:""}`}),ve.map(Ae)]},G.id)),pe.length>0&&r.jsxs("div",{children:[_e.length>0&&r.jsx("div",{style:{fontSize:11,fontWeight:600,color:"var(--text-muted)",padding:"8px 10px 2px"},children:P("files.unassigned")}),pe.map(Ae)]})]}),ze=d.length>0&&r.jsxs("div",{style:{flex:1,minWidth:0},children:[r.jsx("div",{style:{fontSize:11,fontWeight:600,color:"var(--text-faint)",padding:"8px 10px 4px",textTransform:"uppercase",letterSpacing:.5},children:P("files.assignBooking")}),d.map(G=>{const ve=K.reservation_id===G.id||(K.linked_reservation_ids||[]).includes(G.id);return r.jsxs("button",{onClick:async()=>{if(ve)if(K.reservation_id===G.id)await Se(K.id,{reservation_id:null});else try{const ye=((await fn.getLinks(c,K.id)).links||[]).find(ne=>ne.reservation_id===G.id);ye&&await fn.removeLink(c,K.id,ye.id),Y()}catch{}else if(!K.reservation_id)await Se(K.id,{reservation_id:G.id});else try{await fn.addLink(c,K.id,{reservation_id:G.id}),Y()}catch{}},style:{width:"100%",textAlign:"left",padding:"6px 10px 6px 20px",background:ve?"var(--bg-hover)":"none",border:"none",cursor:"pointer",fontSize:13,color:"var(--text-primary)",borderRadius:8,fontFamily:"inherit",fontWeight:ve?600:400,display:"flex",alignItems:"center",gap:6},onMouseEnter:Pe=>Pe.currentTarget.style.background="var(--bg-hover)",onMouseLeave:Pe=>Pe.currentTarget.style.background=ve?"var(--bg-hover)":"transparent",children:[r.jsx(kn,{size:12,style:{flexShrink:0,color:"var(--text-muted)"}}),r.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:G.title||G.name}),ve&&r.jsx(Ga,{size:14,style:{marginLeft:"auto",flexShrink:0,color:"var(--accent)"}})]},G.id)})]}),Ye=He&&ze;return r.jsxs("div",{className:Ye?"md:flex":"",children:[r.jsx("div",{className:Ye?"md:w-1/2":"",style:{overflowY:"auto",maxHeight:"55vh",paddingRight:Ye?6:0},children:He}),Ye&&r.jsx("div",{className:"hidden md:block",style:{width:1,background:"var(--border-primary)",flexShrink:0}}),Ye&&r.jsx("div",{className:"block md:hidden",style:{height:1,background:"var(--border-primary)",margin:"8px 0"}}),r.jsx("div",{className:Ye?"md:w-1/2":"",style:{overflowY:"auto",maxHeight:"55vh",paddingLeft:Ye?6:0},children:ze})]})})()})]})}),document.body),q&&Vt.createPortal(r.jsx("div",{style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.85)",zIndex:1e4,display:"flex",alignItems:"center",justifyContent:"center",padding:16},onClick:()=>te(null),children:r.jsxs("div",{style:{width:"100%",maxWidth:950,height:"94vh",background:"var(--bg-card)",borderRadius:12,overflow:"hidden",display:"flex",flexDirection:"column",boxShadow:"0 20px 60px rgba(0,0,0,0.3)"},onClick:K=>K.stopPropagation(),children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"10px 16px",borderBottom:"1px solid var(--border-primary)",flexShrink:0},children:[r.jsx("span",{style:{fontSize:13,fontWeight:600,color:"var(--text-primary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:1},children:q.original_name}),r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,flexShrink:0},children:[r.jsxs("a",{href:q.url||`/uploads/files/${q.filename}`,target:"_blank",rel:"noreferrer",style:{display:"flex",alignItems:"center",gap:4,fontSize:12,color:"var(--text-muted)",textDecoration:"none",padding:"4px 8px",borderRadius:6,transition:"color 0.15s"},onMouseEnter:K=>K.currentTarget.style.color="var(--text-primary)",onMouseLeave:K=>K.currentTarget.style.color="var(--text-muted)",children:[r.jsx(xn,{size:13})," ",P("files.openTab")]}),r.jsx("button",{onClick:()=>te(null),style:{background:"none",border:"none",cursor:"pointer",color:"var(--text-faint)",display:"flex",padding:4,borderRadius:6,transition:"color 0.15s"},onMouseEnter:K=>K.currentTarget.style.color="var(--text-primary)",onMouseLeave:K=>K.currentTarget.style.color="var(--text-faint)",children:r.jsx(gt,{size:18})})]})]}),r.jsx("object",{data:`${q.url||`/uploads/files/${q.filename}`}#view=FitH`,type:"application/pdf",style:{flex:1,width:"100%",border:"none"},title:q.original_name,children:r.jsx("p",{style:{padding:24,textAlign:"center",color:"var(--text-muted)"},children:r.jsx("a",{href:q.url||`/uploads/files/${q.filename}`,target:"_blank",rel:"noopener noreferrer",style:{color:"var(--text-primary)",textDecoration:"underline"},children:"PDF herunterladen"})})})]})}),document.body),r.jsxs("div",{style:{padding:"20px 24px 16px",borderBottom:"1px solid rgba(0,0,0,0.06)",display:"flex",alignItems:"center",justifyContent:"space-between",flexShrink:0},children:[r.jsxs("div",{children:[r.jsx("h2",{style:{margin:0,fontSize:18,fontWeight:700,color:"var(--text-primary)"},children:S?P("files.trash")||"Trash":P("files.title")}),r.jsx("p",{style:{margin:"2px 0 0",fontSize:12.5,color:"var(--text-faint)"},children:S?`${_.length} ${_.length===1?"file":"files"}`:e.length===1?P("files.countSingular"):P("files.count",{count:e.length})})]}),r.jsxs("button",{onClick:I,style:{padding:"6px 12px",borderRadius:8,border:"1px solid var(--border-primary)",background:S?"var(--accent)":"var(--bg-card)",color:S?"var(--accent-text)":"var(--text-muted)",fontSize:12,fontWeight:500,cursor:"pointer",display:"flex",alignItems:"center",gap:5,fontFamily:"inherit"},children:[r.jsx(_t,{size:13})," ",P("files.trash")||"Trash"]})]}),S?r.jsxs("div",{style:{flex:1,overflowY:"auto",padding:"12px 16px 16px"},children:[_.length>0&&r.jsx("div",{style:{display:"flex",justifyContent:"flex-end",marginBottom:12},children:r.jsx("button",{onClick:Z,style:{padding:"5px 12px",borderRadius:8,border:"1px solid #fecaca",background:"#fef2f2",color:"#dc2626",fontSize:12,fontWeight:500,cursor:"pointer",fontFamily:"inherit"},children:P("files.emptyTrash")||"Empty Trash"})}),E?r.jsx("div",{style:{textAlign:"center",padding:40,color:"var(--text-faint)"},children:r.jsx("div",{style:{width:20,height:20,border:"2px solid var(--text-faint)",borderTopColor:"transparent",borderRadius:"50%",animation:"spin 0.8s linear infinite",margin:"0 auto"}})}):_.length===0?r.jsxs("div",{style:{textAlign:"center",padding:"60px 20px",color:"var(--text-faint)"},children:[r.jsx(_t,{size:40,style:{color:"var(--text-faint)",display:"block",margin:"0 auto 12px"}}),r.jsx("p",{style:{fontSize:14,fontWeight:600,color:"var(--text-secondary)",margin:"0 0 4px"},children:P("files.trashEmpty")||"Trash is empty"})]}):r.jsx("div",{style:{display:"flex",flexDirection:"column",gap:8},children:_.map(K=>we(K,!0))})]}):r.jsxs(r.Fragment,{children:[r.jsxs("div",{...J(),style:{margin:"16px 16px 0",border:"2px dashed",borderRadius:14,padding:"20px 16px",textAlign:"center",cursor:"pointer",transition:"all 0.15s",borderColor:W?"var(--text-secondary)":"var(--border-primary)",background:W?"var(--bg-secondary)":"var(--bg-card)"},children:[r.jsx("input",{...z()}),r.jsx(So,{size:24,style:{margin:"0 auto 8px",color:W?"var(--text-secondary)":"var(--text-faint)",display:"block"}}),m?r.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",gap:6,fontSize:13,color:"var(--text-secondary)"},children:[r.jsx("div",{style:{width:14,height:14,border:"2px solid var(--text-secondary)",borderTopColor:"transparent",borderRadius:"50%",animation:"spin 0.8s linear infinite"}}),P("files.uploading")]}):r.jsxs(r.Fragment,{children:[r.jsx("p",{style:{fontSize:13,color:"var(--text-secondary)",fontWeight:500,margin:0},children:P("files.dropzone")}),r.jsx("p",{style:{fontSize:11.5,color:"var(--text-faint)",marginTop:3},children:P("files.dropzoneHint")}),r.jsxs("p",{style:{fontSize:10,color:"var(--text-faint)",marginTop:6,opacity:.7},children:[(p||"jpg,jpeg,png,gif,webp,heic,pdf,doc,docx,xls,xlsx,txt,csv").toUpperCase().split(",").join(", ")," · Max 50 MB"]})]})]}),r.jsxs("div",{style:{display:"flex",gap:4,padding:"12px 16px 0",flexShrink:0,flexWrap:"wrap"},children:[[{id:"all",label:P("files.filterAll")},...e.some(K=>K.starred)?[{id:"starred",icon:si}]:[],{id:"pdf",label:P("files.filterPdf")},{id:"image",label:P("files.filterImages")},{id:"doc",label:P("files.filterDocs")},...e.some(K=>K.note_id)?[{id:"collab",label:P("files.filterCollab")||"Collab"}]:[]].map(K=>r.jsx("button",{onClick:()=>y(K.id),style:{padding:"4px 12px",borderRadius:99,border:"none",cursor:"pointer",fontSize:12,fontFamily:"inherit",transition:"all 0.12s",background:f===K.id?"var(--accent)":"transparent",color:f===K.id?"var(--accent-text)":"var(--text-muted)",fontWeight:f===K.id?600:400},children:K.icon?r.jsx(K.icon,{size:13,fill:f===K.id?"#facc15":"none",color:f===K.id?"#facc15":"currentColor"}):K.label},K.id)),r.jsx("span",{style:{marginLeft:"auto",fontSize:11.5,color:"var(--text-faint)",alignSelf:"center"},children:C.length===1?P("files.countSingular"):P("files.count",{count:C.length})})]}),r.jsx("div",{style:{flex:1,overflowY:"auto",padding:"12px 16px 16px"},children:C.length===0?r.jsxs("div",{style:{textAlign:"center",padding:"60px 20px",color:"var(--text-faint)"},children:[r.jsx(Pa,{size:40,style:{color:"var(--text-faint)",display:"block",margin:"0 auto 12px"}}),r.jsx("p",{style:{fontSize:14,fontWeight:600,color:"var(--text-secondary)",margin:"0 0 4px"},children:P("files.empty")}),r.jsx("p",{style:{fontSize:13,color:"var(--text-faint)",margin:0},children:P("files.emptyHint")})]}):r.jsx("div",{style:{display:"flex",flexDirection:"column",gap:8},children:C.map(K=>we(K))})})]}),r.jsx("style",{children:`
+ @media (max-width: 767px) {
+ .file-actions button { padding: 8px !important; }
+ .file-actions svg { width: 18px !important; height: 18px !important; }
+ }
+ `})]})}const UL=["EUR","USD","GBP","JPY","CHF","CZK","PLN","SEK","NOK","DKK","TRY","THB","AUD","CAD","NZD","BRL","MXN","INR","IDR","MYR","PHP","SGD","KRW","CNY","HKD","TWD","ZAR","AED","SAR","ILS","EGP","MAD","HUF","RON","BGN","HRK","ISK","RUB","UAH","BDT","LKR","VND","CLP","COP","PEN","ARS"],ay={EUR:"€",USD:"$",GBP:"£",JPY:"¥",CHF:"CHF",CZK:"Kč",PLN:"zł",SEK:"kr",NOK:"kr",DKK:"kr",TRY:"₺",THB:"฿",AUD:"A$",CAD:"C$",NZD:"NZ$",BRL:"R$",MXN:"MX$",INR:"₹",IDR:"Rp",MYR:"RM",PHP:"₱",SGD:"S$",KRW:"₩",CNY:"¥",HKD:"HK$",TWD:"NT$",ZAR:"R",AED:"د.إ",SAR:"﷼",ILS:"₪",EGP:"E£",MAD:"MAD",HUF:"Ft",RON:"lei",BGN:"лв",HRK:"kn",ISK:"kr",RUB:"₽",UAH:"₴",BDT:"৳",LKR:"Rs",VND:"₫",CLP:"CL$",COP:"CO$",PEN:"S/.",ARS:"AR$"},yu=["#6366f1","#ec4899","#f59e0b","#10b981","#3b82f6","#8b5cf6","#ef4444","#14b8a6","#f97316","#06b6d4","#84cc16","#a855f7"],uC=(e,t,a)=>{if(e==null||isNaN(e))return"-";const n=el(a);return Number(e).toLocaleString(t,{minimumFractionDigits:n,maximumFractionDigits:n})+" "+(ay[a]||a)},WL=(e,t)=>t>0?e/t:null,$L=(e,t)=>t>0?e/t:null,VL=(e,t,a)=>t>0&&a>0?e/(t*a):null;function sd({value:e,onSave:t,type:a="text",style:n={},placeholder:i="",decimals:o=2,locale:s,editTooltip:d}){const[c,p]=b.useState(!1),[m,g]=b.useState(e??""),f=b.useRef(null);b.useEffect(()=>{c&&f.current&&(f.current.focus(),f.current.select())},[c]);const y=()=>{p(!1);let k=m;if(a==="number"){const S=parseFloat(String(m).replace(",","."));k=isNaN(S)?null:S}k!==e&&t(k)};if(c)return r.jsx("input",{ref:f,type:"text",inputMode:a==="number"?"decimal":"text",value:m,onChange:k=>g(k.target.value),onBlur:y,onKeyDown:k=>{k.key==="Enter"&&y(),k.key==="Escape"&&(g(e??""),p(!1))},style:{width:"100%",border:"1px solid var(--accent)",borderRadius:4,padding:"4px 6px",fontSize:13,outline:"none",background:"var(--bg-input)",color:"var(--text-primary)",fontFamily:"inherit",...n},placeholder:i});const x=a==="number"&&e!=null?Number(e).toLocaleString(s,{minimumFractionDigits:o,maximumFractionDigits:o}):e||"";return r.jsx("div",{onClick:()=>{g(e??""),p(!0)},title:d,style:{cursor:"pointer",padding:"4px 6px",borderRadius:4,minHeight:28,display:"flex",alignItems:"center",justifyContent:(n==null?void 0:n.textAlign)==="center"?"center":"flex-start",transition:"background 0.15s",color:x?"var(--text-primary)":"var(--text-faint)",fontSize:13,...n},onMouseEnter:k=>k.currentTarget.style.background="var(--bg-hover)",onMouseLeave:k=>k.currentTarget.style.background="transparent",children:x||i||"-"})}function KL({onAdd:e,t}){const[a,n]=b.useState(""),[i,o]=b.useState(""),[s,d]=b.useState(""),[c,p]=b.useState(""),[m,g]=b.useState(""),f=b.useRef(null),y=()=>{a.trim()&&(e({name:a.trim(),total_price:parseFloat(String(i).replace(",","."))||0,persons:parseInt(s)||null,days:parseInt(c)||null,note:m.trim()||null}),n(""),o(""),d(""),p(""),g(""),setTimeout(()=>{var k;return(k=f.current)==null?void 0:k.focus()},50))},x={border:"1px solid var(--border-primary)",borderRadius:4,padding:"4px 6px",fontSize:13,outline:"none",fontFamily:"inherit",width:"100%",background:"var(--bg-input)",color:"var(--text-primary)"};return r.jsxs("tr",{style:{background:"var(--bg-secondary)"},children:[r.jsx("td",{style:{padding:"4px 6px"},children:r.jsx("input",{ref:f,value:a,onChange:k=>n(k.target.value),onKeyDown:k=>k.key==="Enter"&&y(),placeholder:t("budget.newEntry"),style:x})}),r.jsx("td",{style:{padding:"4px 6px"},children:r.jsx("input",{value:i,onChange:k=>o(k.target.value),onKeyDown:k=>k.key==="Enter"&&y(),placeholder:"0,00",inputMode:"decimal",style:{...x,textAlign:"center"}})}),r.jsx("td",{className:"hidden sm:table-cell",style:{padding:"4px 6px",textAlign:"center"},children:r.jsx("input",{value:s,onChange:k=>d(k.target.value),onKeyDown:k=>k.key==="Enter"&&y(),placeholder:"-",inputMode:"numeric",style:{...x,textAlign:"center",maxWidth:50,margin:"0 auto"}})}),r.jsx("td",{className:"hidden sm:table-cell",style:{padding:"4px 6px",textAlign:"center"},children:r.jsx("input",{value:c,onChange:k=>p(k.target.value),onKeyDown:k=>k.key==="Enter"&&y(),placeholder:"-",inputMode:"numeric",style:{...x,textAlign:"center",maxWidth:50,margin:"0 auto"}})}),r.jsx("td",{className:"hidden md:table-cell",style:{padding:"4px 6px",color:"var(--text-faint)",fontSize:12,textAlign:"center"},children:"-"}),r.jsx("td",{className:"hidden md:table-cell",style:{padding:"4px 6px",color:"var(--text-faint)",fontSize:12,textAlign:"center"},children:"-"}),r.jsx("td",{className:"hidden lg:table-cell",style:{padding:"4px 6px",color:"var(--text-faint)",fontSize:12,textAlign:"center"},children:"-"}),r.jsx("td",{className:"hidden sm:table-cell",style:{padding:"4px 6px"},children:r.jsx("input",{value:m,onChange:k=>g(k.target.value),onKeyDown:k=>k.key==="Enter"&&y(),placeholder:t("budget.table.note"),style:x})}),r.jsx("td",{style:{padding:"4px 6px",textAlign:"center"},children:r.jsx("button",{onClick:y,disabled:!a.trim(),title:t("reservations.add"),style:{background:a.trim()?"var(--text-primary)":"var(--border-primary)",border:"none",borderRadius:4,color:"var(--bg-primary)",cursor:a.trim()?"pointer":"default",padding:"4px 8px",display:"inline-flex",alignItems:"center"},children:r.jsx(Ft,{size:14})})})]})}function ny({label:e,avatarUrl:t,size:a=20,paid:n,onClick:i}){var y;const[o,s]=b.useState(!1),[d,c]=b.useState({top:0,left:0}),p=b.useRef(null),m=()=>{if(p.current){const x=p.current.getBoundingClientRect();c({top:x.top-6,left:x.left+x.width/2})}s(!0)},g=n?"#22c55e":"var(--border-primary)",f=n?"rgba(34,197,94,0.15)":"var(--bg-tertiary)";return r.jsxs(r.Fragment,{children:[r.jsx("div",{ref:p,onMouseEnter:m,onMouseLeave:()=>s(!1),onClick:i,style:{width:a,height:a,borderRadius:"50%",border:`2px solid ${g}`,background:f,display:"flex",alignItems:"center",justifyContent:"center",fontSize:a*.4,fontWeight:700,color:n?"#16a34a":"var(--text-muted)",overflow:"hidden",flexShrink:0,cursor:i?"pointer":"default",transition:"border-color 0.15s, background 0.15s"},children:t?r.jsx("img",{src:t,style:{width:"100%",height:"100%",objectFit:"cover"}}):(y=e==null?void 0:e[0])==null?void 0:y.toUpperCase()}),o&&Vt.createPortal(r.jsxs("div",{style:{position:"fixed",top:d.top,left:d.left,transform:"translate(-50%, -100%)",pointerEvents:"none",zIndex:1e4,whiteSpace:"nowrap",display:"flex",alignItems:"center",gap:5,background:"var(--bg-card, white)",color:"var(--text-primary, #111827)",fontSize:11,fontWeight:500,padding:"5px 10px",borderRadius:8,boxShadow:"0 4px 12px rgba(0,0,0,0.15)",border:"1px solid var(--border-faint, #e5e7eb)"},children:[e,n&&r.jsx("span",{style:{fontSize:9,fontWeight:700,padding:"1px 5px",borderRadius:4,background:"rgba(34,197,94,0.15)",color:"#16a34a",textTransform:"uppercase",letterSpacing:"0.03em"},children:"Paid"})]}),document.body)]})}function n1({members:e=[],tripMembers:t=[],onSetMembers:a,onTogglePaid:n,compact:i=!0}){const o=i?20:30,s=i?18:28,d=i?e.length>0?8:9:e.length>0?12:14,[c,p]=b.useState(!1),[m,g]=b.useState({top:0,left:0}),f=b.useRef(null),y=b.useRef(null),x=b.useCallback(()=>{if(f.current){const v=f.current.getBoundingClientRect();g({top:v.bottom+4,left:v.left+v.width/2})}p(v=>!v)},[]);b.useEffect(()=>{if(!c)return;const v=_=>{y.current&&y.current.contains(_.target)||f.current&&f.current.contains(_.target)||p(!1)};return document.addEventListener("mousedown",v),()=>document.removeEventListener("mousedown",v)},[c]);const k=e.map(v=>v.user_id),S=v=>{const _=k.includes(v)?k.filter(w=>w!==v):[...k,v];a(_)};return r.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",gap:2,flexWrap:"wrap"},children:[e.map(v=>r.jsx(ny,{label:v.username,avatarUrl:v.avatar_url,size:o,paid:!!v.paid,onClick:n?()=>n(v.user_id,!v.paid):void 0},v.user_id)),r.jsx("button",{ref:f,onClick:x,style:{width:s,height:s,borderRadius:"50%",border:"1.5px dashed var(--border-primary)",background:"none",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",color:"var(--text-faint)",padding:0,flexShrink:0},children:e.length>0?r.jsx(sn,{size:d}):r.jsx(Ur,{size:d})}),c&&Vt.createPortal(r.jsx("div",{ref:y,style:{position:"fixed",top:m.top,left:m.left,transform:"translateX(-50%)",zIndex:1e4,background:"var(--bg-card)",border:"1px solid var(--border-primary)",borderRadius:10,boxShadow:"0 4px 16px rgba(0,0,0,0.12)",padding:4,minWidth:150},children:t.map(v=>{var w,E;const _=k.includes(v.id);return r.jsxs("button",{onClick:()=>S(v.id),style:{display:"flex",alignItems:"center",gap:6,width:"100%",padding:"5px 8px",borderRadius:6,border:"none",background:_?"var(--bg-hover)":"none",cursor:"pointer",fontFamily:"inherit",fontSize:11,color:"var(--text-primary)",textAlign:"left"},onMouseEnter:M=>{_||(M.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:M=>{_||(M.currentTarget.style.background="none")},children:[r.jsx("div",{style:{width:18,height:18,borderRadius:"50%",background:"var(--bg-tertiary)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:8,fontWeight:700,color:"var(--text-muted)",overflow:"hidden",flexShrink:0},children:v.avatar_url?r.jsx("img",{src:v.avatar_url,style:{width:"100%",height:"100%",objectFit:"cover"}}):(E=(w=v.username)==null?void 0:w[0])==null?void 0:E.toUpperCase()}),r.jsx("span",{style:{flex:1},children:v.username}),_&&r.jsx(Ga,{size:12,color:"var(--text-primary)"})]},v.id)})}),document.body)]})}function qL({tripId:e,budgetItems:t,currency:a,locale:n}){const[i,o]=b.useState(null),s=d=>uC(d,n,a);return b.useEffect(()=>{xi.perPersonSummary(e).then(d=>o(d.summary)).catch(()=>{})},[e,t]),!i||i.length===0?null:r.jsx("div",{style:{marginTop:16,borderTop:"1px solid rgba(255,255,255,0.1)",paddingTop:14,display:"flex",flexDirection:"column",gap:8},children:i.map(d=>{var c,p;return r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[r.jsx("div",{style:{width:22,height:22,borderRadius:"50%",background:"rgba(255,255,255,0.1)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:9,fontWeight:700,color:"rgba(255,255,255,0.7)",overflow:"hidden",flexShrink:0},children:d.avatar_url?r.jsx("img",{src:d.avatar_url,style:{width:"100%",height:"100%",objectFit:"cover"}}):(p=(c=d.username)==null?void 0:c[0])==null?void 0:p.toUpperCase()}),r.jsx("span",{style:{flex:1,fontSize:12,fontWeight:500,color:"rgba(255,255,255,0.7)"},children:d.username}),r.jsx("span",{style:{fontSize:12,fontWeight:600,color:"#fff"},children:s(d.total_assigned)})]},d.user_id)})})}function GL({segments:e,size:t=200,totalLabel:a}){if(!e.length)return null;const n=e.reduce((s,d)=>s+d.value,0);if(n===0)return null;let i=0;const o=e.map(s=>{const d=i,c=s.value/n*360;return i+=c,`${s.color} ${d}deg ${d+c}deg`}).join(", ");return r.jsxs("div",{style:{position:"relative",width:t,height:t,margin:"0 auto"},children:[r.jsx("div",{style:{width:t,height:t,borderRadius:"50%",background:`conic-gradient(${o})`,boxShadow:"0 4px 24px rgba(0,0,0,0.08)"}}),r.jsxs("div",{style:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:t*.55,height:t*.55,borderRadius:"50%",background:"var(--bg-card)",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",boxShadow:"inset 0 0 12px rgba(0,0,0,0.04)"},children:[r.jsx(Ml,{size:18,color:"var(--text-faint)",style:{marginBottom:2}}),r.jsx("span",{style:{fontSize:10,color:"var(--text-faint)",fontWeight:500},children:a})]})]})}function ZL({tripId:e,tripMembers:t=[]}){const{trip:a,budgetItems:n,addBudgetItem:i,updateBudgetItem:o,deleteBudgetItem:s,loadBudgetItems:d,updateTrip:c,setBudgetItemMembers:p,toggleBudgetMemberPaid:m}=Rn(),{t:g,locale:f}=ot(),[y,x]=b.useState(""),[k,S]=b.useState(null),[v,_]=b.useState(null),[w,E]=b.useState(!1),M=(a==null?void 0:a.currency)||"EUR",A=(W,B)=>uC(W,f,B),P=t.length>1;b.useEffect(()=>{P&&xi.settlement(e).then(_).catch(()=>{})},[e,n,P]);const R=W=>{e&&c(e,{currency:W})};b.useEffect(()=>{e&&d(e)},[e]);const $=b.useMemo(()=>(n||[]).reduce((W,B)=>{const C=B.category||"Other";return W[C]||(W[C]=[]),W[C].push(B),W},{}),[n]),I=Object.keys($),Y=(n||[]).reduce((W,B)=>W+(B.total_price||0),0),H=b.useMemo(()=>I.map((W,B)=>({name:W,value:$[W].reduce((C,U)=>C+(U.total_price||0),0),color:yu[B%yu.length]})).filter(W=>W.value>0),[$,I]),V=async(W,B)=>{try{await i(e,{...B,category:W})}catch{}},X=async(W,B,C)=>{try{await o(e,W,{[B]:C})}catch{}},Z=async W=>{try{await s(e,W)}catch{}},O=async W=>{const B=$[W]||[];for(const C of Array.from(B))await s(e,C.id)},Q=async(W,B)=>{if(!B.trim()||B.trim()===W)return;const C=$[W]||[];for(const U of Array.from(C))await o(e,U.id,{category:B.trim()})},D=()=>{y.trim()&&(i(e,{name:g("budget.defaultEntry"),category:y.trim(),total_price:0}),x(""))},J={padding:"6px 8px",textAlign:"center",fontSize:11,fontWeight:600,color:"var(--text-muted)",textTransform:"uppercase",letterSpacing:"0.05em",borderBottom:"2px solid var(--border-primary)",whiteSpace:"nowrap",background:"var(--bg-secondary)"},z={padding:"2px 6px",borderBottom:"1px solid var(--border-secondary)",fontSize:13,verticalAlign:"middle",color:"var(--text-primary)"};return!n||n.length===0?r.jsxs("div",{style:{padding:24,maxWidth:600,margin:"60px auto",textAlign:"center"},children:[r.jsx("div",{style:{width:64,height:64,borderRadius:16,background:"var(--bg-tertiary)",display:"flex",alignItems:"center",justifyContent:"center",margin:"0 auto 20px"},children:r.jsx(p0,{size:28,color:"#6b7280"})}),r.jsx("h2",{style:{fontSize:20,fontWeight:700,color:"var(--text-primary)",margin:"0 0 8px"},children:g("budget.emptyTitle")}),r.jsx("p",{style:{fontSize:14,color:"var(--text-muted)",margin:"0 0 24px",lineHeight:1.5},children:g("budget.emptyText")}),r.jsxs("div",{style:{display:"flex",gap:6,justifyContent:"center",alignItems:"stretch",maxWidth:320,margin:"0 auto"},children:[r.jsx("input",{value:y,onChange:W=>x(W.target.value),onKeyDown:W=>W.key==="Enter"&&D(),placeholder:g("budget.emptyPlaceholder"),style:{flex:1,padding:"9px 14px",borderRadius:10,border:"1px solid var(--border-primary)",fontSize:13,fontFamily:"inherit",outline:"none",background:"var(--bg-input)",color:"var(--text-primary)",minWidth:0}}),r.jsx("button",{onClick:D,disabled:!y.trim(),style:{background:"var(--accent)",color:"var(--accent-text)",border:"none",borderRadius:10,padding:"0 12px",cursor:"pointer",display:"flex",alignItems:"center",opacity:y.trim()?1:.5,flexShrink:0},children:r.jsx(Ft,{size:16})})]})]}):r.jsxs("div",{style:{fontFamily:"'Poppins', -apple-system, BlinkMacSystemFont, system-ui, sans-serif"},children:[r.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"16px 16px 12px",flexWrap:"wrap",gap:8},children:r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[r.jsx(p0,{size:20,color:"var(--text-primary)"}),r.jsx("h2",{style:{fontSize:18,fontWeight:700,color:"var(--text-primary)",margin:0},children:g("budget.title")})]})}),r.jsxs("div",{style:{display:"flex",gap:20,padding:"0 16px 40px",alignItems:"flex-start",flexWrap:"wrap"},children:[r.jsx("div",{style:{flex:1,minWidth:0},children:I.map((W,B)=>{const C=$[W],U=C.reduce((te,oe)=>te+(oe.total_price||0),0),q=yu[B%yu.length];return r.jsxs("div",{style:{marginBottom:16},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",background:"#000000",color:"#fff",borderRadius:"10px 10px 0 0",padding:"9px 14px"},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,flex:1,minWidth:0},children:[r.jsx("div",{style:{width:10,height:10,borderRadius:3,background:q,flexShrink:0}}),(k==null?void 0:k.name)===W?r.jsx("input",{autoFocus:!0,value:k.value,onChange:te=>S({...k,value:te.target.value}),onBlur:()=>{Q(W,k.value),S(null)},onKeyDown:te=>{te.key==="Enter"&&(Q(W,k.value),S(null)),te.key==="Escape"&&S(null)},style:{fontWeight:600,fontSize:13,background:"rgba(255,255,255,0.15)",border:"none",borderRadius:4,color:"#fff",padding:"1px 6px",outline:"none",fontFamily:"inherit",width:"100%"}}):r.jsxs(r.Fragment,{children:[r.jsx("span",{style:{fontWeight:600,fontSize:13},children:W}),r.jsx("button",{onClick:()=>S({name:W,value:W}),style:{background:"none",border:"none",cursor:"pointer",color:"rgba(255,255,255,0.4)",display:"flex",padding:1},onMouseEnter:te=>te.currentTarget.style.color="#fff",onMouseLeave:te=>te.currentTarget.style.color="rgba(255,255,255,0.4)",children:r.jsx(sn,{size:10})})]})]}),r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[r.jsx("span",{style:{fontSize:13,fontWeight:500,opacity:.9},children:A(U,M)}),r.jsx("button",{onClick:()=>O(W),title:g("budget.deleteCategory"),style:{background:"rgba(255,255,255,0.1)",border:"none",borderRadius:4,color:"#fff",cursor:"pointer",padding:"3px 6px",display:"flex",alignItems:"center",opacity:.6},onMouseEnter:te=>te.currentTarget.style.opacity="1",onMouseLeave:te=>te.currentTarget.style.opacity="0.6",children:r.jsx(_t,{size:13})})]})]}),r.jsx("div",{style:{overflowX:"auto",border:"1px solid var(--border-primary)",borderTop:"none",borderRadius:"0 0 10px 10px"},children:r.jsxs("table",{style:{width:"100%",borderCollapse:"collapse"},children:[r.jsx("thead",{children:r.jsxs("tr",{children:[r.jsx("th",{style:{...J,textAlign:"left",minWidth:100},children:g("budget.table.name")}),r.jsx("th",{style:{...J,minWidth:60},children:g("budget.table.total")}),r.jsx("th",{className:"hidden sm:table-cell",style:{...J,minWidth:130},children:g("budget.table.persons")}),r.jsx("th",{className:"hidden sm:table-cell",style:{...J,minWidth:45},children:g("budget.table.days")}),r.jsx("th",{className:"hidden md:table-cell",style:{...J,minWidth:90},children:g("budget.table.perPerson")}),r.jsx("th",{className:"hidden md:table-cell",style:{...J,minWidth:80},children:g("budget.table.perDay")}),r.jsx("th",{className:"hidden lg:table-cell",style:{...J,minWidth:95},children:g("budget.table.perPersonDay")}),r.jsx("th",{className:"hidden sm:table-cell",style:{...J,textAlign:"left",minWidth:80},children:g("budget.table.note")}),r.jsx("th",{style:{...J,width:36}})]})}),r.jsxs("tbody",{children:[C.map(te=>{var je;const oe=WL(te.total_price,te.persons),be=$L(te.total_price,te.days),Se=VL(te.total_price,te.persons,te.days);return((je=te.members)==null?void 0:je.length)>0,r.jsxs("tr",{style:{transition:"background 0.1s"},onMouseEnter:we=>we.currentTarget.style.background="var(--bg-hover)",onMouseLeave:we=>we.currentTarget.style.background="transparent",children:[r.jsxs("td",{style:z,children:[r.jsx(sd,{value:te.name,onSave:we=>X(te.id,"name",we),placeholder:g("budget.table.name"),locale:f,editTooltip:g("budget.editTooltip")}),P&&r.jsx("div",{className:"sm:hidden",style:{marginTop:4},children:r.jsx(n1,{members:te.members||[],tripMembers:t,onSetMembers:we=>p(e,te.id,we),onTogglePaid:(we,ce)=>m(e,te.id,we,ce),compact:!1})})]}),r.jsx("td",{style:{...z,textAlign:"center"},children:r.jsx(sd,{value:te.total_price,type:"number",decimals:el(M),onSave:we=>X(te.id,"total_price",we),style:{textAlign:"center"},placeholder:el(M)===0?"0":"0,00",locale:f,editTooltip:g("budget.editTooltip")})}),r.jsx("td",{className:"hidden sm:table-cell",style:{...z,textAlign:"center",position:"relative"},children:P?r.jsx(n1,{members:te.members||[],tripMembers:t,onSetMembers:we=>p(e,te.id,we),onTogglePaid:(we,ce)=>m(e,te.id,we,ce)}):r.jsx(sd,{value:te.persons,type:"number",decimals:0,onSave:we=>X(te.id,"persons",we!=null&&parseInt(we)||null),style:{textAlign:"center"},placeholder:"-",locale:f,editTooltip:g("budget.editTooltip")})}),r.jsx("td",{className:"hidden sm:table-cell",style:{...z,textAlign:"center"},children:r.jsx(sd,{value:te.days,type:"number",decimals:0,onSave:we=>X(te.id,"days",we!=null&&parseInt(we)||null),style:{textAlign:"center"},placeholder:"-",locale:f,editTooltip:g("budget.editTooltip")})}),r.jsx("td",{className:"hidden md:table-cell",style:{...z,textAlign:"center",color:oe!=null?"var(--text-secondary)":"var(--text-faint)"},children:oe!=null?A(oe,M):"-"}),r.jsx("td",{className:"hidden md:table-cell",style:{...z,textAlign:"center",color:be!=null?"var(--text-secondary)":"var(--text-faint)"},children:be!=null?A(be,M):"-"}),r.jsx("td",{className:"hidden lg:table-cell",style:{...z,textAlign:"center",color:Se!=null?"var(--text-secondary)":"var(--text-faint)"},children:Se!=null?A(Se,M):"-"}),r.jsx("td",{className:"hidden sm:table-cell",style:z,children:r.jsx(sd,{value:te.note,onSave:we=>X(te.id,"note",we),placeholder:g("budget.table.note"),locale:f,editTooltip:g("budget.editTooltip")})}),r.jsx("td",{style:{...z,textAlign:"center"},children:r.jsx("button",{onClick:()=>Z(te.id),title:g("common.delete"),style:{background:"none",border:"none",cursor:"pointer",padding:4,color:"var(--text-faint)",borderRadius:4,display:"inline-flex",transition:"color 0.15s"},onMouseEnter:we=>we.currentTarget.style.color="#ef4444",onMouseLeave:we=>we.currentTarget.style.color="#d1d5db",children:r.jsx(_t,{size:14})})})]},te.id)}),r.jsx(KL,{onAdd:te=>V(W,te),t:g})]})]})})]},W)})}),r.jsxs("div",{className:"w-full md:w-[280px]",style:{flexShrink:0,position:"sticky",top:16,alignSelf:"flex-start"},children:[r.jsx("div",{style:{marginBottom:12},children:r.jsx(ea,{value:M,onChange:R,options:UL.map(W=>({value:W,label:`${W} (${ay[W]||W})`})),searchable:!0})}),r.jsxs("div",{style:{display:"flex",gap:6,marginBottom:12},children:[r.jsx("input",{value:y,onChange:W=>x(W.target.value),onKeyDown:W=>{W.key==="Enter"&&D()},placeholder:g("budget.categoryName"),style:{flex:1,border:"1px solid var(--border-primary)",borderRadius:10,padding:"9px 14px",fontSize:13,outline:"none",fontFamily:"inherit",background:"var(--bg-input)",color:"var(--text-primary)"}}),r.jsx("button",{onClick:D,disabled:!y.trim(),style:{background:"var(--accent)",color:"var(--accent-text)",border:"none",borderRadius:10,padding:"9px 12px",cursor:"pointer",display:"flex",alignItems:"center",opacity:y.trim()?1:.4,flexShrink:0},children:r.jsx(Ft,{size:16})})]}),r.jsxs("div",{style:{background:"linear-gradient(135deg, #000000 0%, #18181b 100%)",borderRadius:16,padding:"24px 20px",color:"#fff",marginBottom:16,boxShadow:"0 8px 32px rgba(15,23,42,0.18)"},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:16},children:[r.jsx("div",{style:{width:36,height:36,borderRadius:10,background:"rgba(255,255,255,0.1)",display:"flex",alignItems:"center",justifyContent:"center"},children:r.jsx(Ml,{size:18,color:"rgba(255,255,255,0.8)"})}),r.jsx("div",{children:r.jsx("div",{style:{fontSize:11,color:"rgba(255,255,255,0.5)",fontWeight:500,letterSpacing:.5},children:g("budget.totalBudget")})})]}),r.jsx("div",{style:{fontSize:28,fontWeight:700,lineHeight:1,marginBottom:4},children:Number(Y).toLocaleString(f,{minimumFractionDigits:el(M),maximumFractionDigits:el(M)})}),r.jsxs("div",{style:{fontSize:14,color:"rgba(255,255,255,0.5)",fontWeight:500},children:[ay[M]||M," ",M]}),P&&(n||[]).some(W=>{var B;return((B=W.members)==null?void 0:B.length)>0})&&r.jsx(qL,{tripId:e,budgetItems:n,currency:M,locale:f}),P&&v&&v.flows.length>0&&r.jsxs("div",{style:{marginTop:16,borderTop:"1px solid rgba(255,255,255,0.1)",paddingTop:12},children:[r.jsxs("button",{onClick:()=>E(W=>!W),style:{display:"flex",alignItems:"center",gap:6,width:"100%",background:"none",border:"none",cursor:"pointer",padding:0,fontFamily:"inherit",color:"rgba(255,255,255,0.6)",fontSize:11,fontWeight:600,letterSpacing:.5},children:[w?r.jsx(en,{size:13}):r.jsx(Ao,{size:13}),g("budget.settlement"),r.jsxs("span",{style:{position:"relative",display:"inline-flex",marginLeft:2},children:[r.jsx("span",{style:{display:"flex",cursor:"help"},onMouseEnter:W=>{const B=W.currentTarget.nextElementSibling;B&&(B.style.display="block")},onMouseLeave:W=>{const B=W.currentTarget.nextElementSibling;B&&(B.style.display="none")},onClick:W=>W.stopPropagation(),children:r.jsx(Im,{size:11,strokeWidth:2})}),r.jsx("div",{style:{display:"none",position:"absolute",top:"100%",left:"50%",transform:"translateX(-50%)",marginTop:6,width:220,padding:"10px 12px",borderRadius:10,zIndex:100,background:"var(--bg-card)",border:"1px solid var(--border-faint)",boxShadow:"0 4px 16px rgba(0,0,0,0.12)",fontSize:11,fontWeight:400,color:"var(--text-secondary)",lineHeight:1.5,textAlign:"left"},children:g("budget.settlementInfo")})]})]}),w&&r.jsxs("div",{style:{marginTop:10,display:"flex",flexDirection:"column",gap:8},children:[v.flows.map((W,B)=>r.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",gap:10,padding:"8px 10px",borderRadius:10,background:"rgba(255,255,255,0.06)"},children:[r.jsx(ny,{label:W.from.username,avatarUrl:W.from.avatar_url,size:28}),r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4},children:[r.jsx("span",{style:{fontSize:11,color:"rgba(255,255,255,0.3)"},children:"→"}),r.jsx("span",{style:{fontSize:12,fontWeight:700,color:"#f87171",whiteSpace:"nowrap"},children:A(W.amount,M)}),r.jsx("span",{style:{fontSize:11,color:"rgba(255,255,255,0.3)"},children:"→"})]}),r.jsx(ny,{label:W.to.username,avatarUrl:W.to.avatar_url,size:28})]},B)),v.balances.filter(W=>Math.abs(W.balance)>.01).length>0&&r.jsxs("div",{style:{marginTop:4,borderTop:"1px solid rgba(255,255,255,0.08)",paddingTop:8},children:[r.jsx("div",{style:{fontSize:9,fontWeight:600,color:"rgba(255,255,255,0.35)",textTransform:"uppercase",letterSpacing:"0.05em",marginBottom:6},children:g("budget.netBalances")}),v.balances.filter(W=>Math.abs(W.balance)>.01).map(W=>{var B,C;return r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,padding:"2px 0"},children:[r.jsx("div",{style:{width:20,height:20,borderRadius:"50%",flexShrink:0,background:"rgba(255,255,255,0.1)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:8,fontWeight:700,color:"rgba(255,255,255,0.6)",overflow:"hidden"},children:W.avatar_url?r.jsx("img",{src:W.avatar_url,style:{width:"100%",height:"100%",objectFit:"cover"}}):(C=(B=W.username)==null?void 0:B[0])==null?void 0:C.toUpperCase()}),r.jsx("span",{style:{flex:1,fontSize:11,color:"rgba(255,255,255,0.6)",fontWeight:500,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:W.username}),r.jsxs("span",{style:{fontSize:11,fontWeight:600,flexShrink:0,color:W.balance>0?"#4ade80":"#f87171"},children:[W.balance>0?"+":"",A(W.balance,M)]})]},W.user_id)})]})]})]})]}),H.length>0&&r.jsxs("div",{style:{background:"var(--bg-card)",borderRadius:16,padding:"20px 16px",border:"1px solid var(--border-primary)",boxShadow:"0 2px 12px rgba(0,0,0,0.04)",marginBottom:16},children:[r.jsx("div",{style:{fontSize:13,fontWeight:600,color:"var(--text-primary)",marginBottom:16,textAlign:"center"},children:g("budget.byCategory")}),r.jsx(GL,{segments:H,size:180,totalLabel:g("budget.total")}),r.jsx("div",{style:{marginTop:20,display:"flex",flexDirection:"column",gap:6},children:H.map(W=>{const B=Y>0?(W.value/Y*100).toFixed(1):"0.0";return r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[r.jsx("div",{style:{width:10,height:10,borderRadius:3,background:W.color,flexShrink:0}}),r.jsx("span",{style:{flex:1,fontSize:12,color:"var(--text-secondary)",fontWeight:500},children:W.name}),r.jsx("span",{style:{fontSize:11,color:"var(--text-faint)",fontWeight:600,whiteSpace:"nowrap"},children:A(W.value,M)}),r.jsxs("span",{style:{fontSize:11,color:"var(--text-muted)",fontWeight:600,whiteSpace:"nowrap",minWidth:38,textAlign:"right"},children:[B,"%"]})]},W.name)})})]})]})]})]})}function YL(e){const t=[];for(const a of e){const n=a.codePointAt(0);n!==65039&&t.push(n.toString(16))}return t.join("-")}function nb({emoji:e,size:t=20,style:a={}}){const n=YL(e),[i,o]=b.useState(!1);return i?r.jsx("span",{style:{fontSize:t,lineHeight:1,display:"inline-block",verticalAlign:"middle",...a},children:e}):r.jsx("img",{src:`https://cdn.jsdelivr.net/gh/twitter/twemoji@14.0.2/assets/72x72/${n}.png`,alt:e,draggable:!1,style:{width:t,height:t,display:"inline-block",verticalAlign:"middle",...a},onError:()=>o(!0)})}const lh={Smileys:["😀","😂","🥹","😍","🤩","😎","🥳","😭","🤔","👀","🙈","🫠","😴","🤯","🥺","😤","💀","👻","🫡","🤝"],Reactions:["❤️","🔥","👍","👎","👏","🎉","💯","✨","⭐","💪","🙏","😱","😂","💖","💕","🤞","✅","❌","⚡","🏆"],Travel:["✈️","🏖️","🗺️","🧳","🏔️","🌅","🌴","🚗","🚂","🛳️","🏨","🍽️","🍕","🍹","📸","🎒","⛱️","🌍","🗼","🎌"]};function Up(e){return new Date(e&&!e.endsWith("Z")?e+"Z":e)}function r1(e,t){const a=Up(e),n=a.getHours(),i=String(a.getMinutes()).padStart(2,"0");if(t){const o=n>=12?"PM":"AM";return`${n===0?12:n>12?n-12:n}:${i} ${o}`}return`${String(n).padStart(2,"0")}:${i}`}function i1(e,t){const a=Up(e),n=new Date,i=new Date;return i.setDate(n.getDate()-1),a.toDateString()===n.toDateString()?t("collab.chat.today")||"Today":a.toDateString()===i.toDateString()?t("collab.chat.yesterday")||"Yesterday":a.toLocaleDateString(void 0,{day:"numeric",month:"short",year:"numeric"})}function XL(e,t){if(!t)return!0;const a=Up(e.created_at).toDateString(),n=Up(t.created_at).toDateString();return a!==n}function JL({onSelect:e,onClose:t,anchorRef:a,containerRef:n}){const[i,o]=b.useState(Object.keys(lh)[0]),s=b.useRef(null),c=(()=>{const p=n==null?void 0:n.current,m=a==null?void 0:a.current;if(p&&m){const g=p.getBoundingClientRect(),f=m.getBoundingClientRect();return{bottom:window.innerHeight-f.top+16,left:g.left+g.width/2-140}}return{bottom:80,left:0}})();return b.useEffect(()=>{const p=m=>{s.current&&s.current.contains(m.target)||a!=null&&a.current&&a.current.contains(m.target)||t()};return document.addEventListener("mousedown",p),()=>document.removeEventListener("mousedown",p)},[t,a]),Vt.createPortal(r.jsxs("div",{ref:s,style:{position:"fixed",bottom:c.bottom,left:c.left,zIndex:1e4,background:"var(--bg-card)",border:"1px solid var(--border-faint)",borderRadius:16,boxShadow:"0 8px 32px rgba(0,0,0,0.18)",width:280,overflow:"hidden"},children:[r.jsx("div",{style:{display:"flex",borderBottom:"1px solid var(--border-faint)",padding:"6px 8px",gap:2},children:Object.keys(lh).map(p=>r.jsx("button",{onClick:()=>o(p),style:{flex:1,padding:"4px 0",borderRadius:6,border:"none",cursor:"pointer",background:i===p?"var(--bg-hover)":"transparent",color:"var(--text-primary)",fontSize:10,fontWeight:600,fontFamily:"inherit"},children:p},p))}),r.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(10, 1fr)",gap:2,padding:8},children:lh[i].map((p,m)=>r.jsx("button",{onClick:()=>e(p),style:{width:28,height:28,display:"flex",alignItems:"center",justifyContent:"center",background:"none",border:"none",cursor:"pointer",borderRadius:6,padding:2,transition:"transform 0.1s"},onMouseEnter:g=>{g.currentTarget.style.background="var(--bg-hover)",g.currentTarget.style.transform="scale(1.2)"},onMouseLeave:g=>{g.currentTarget.style.background="none",g.currentTarget.style.transform="scale(1)"},children:r.jsx(nb,{emoji:p,size:20})},m))})]}),document.body)}const QL=["❤️","😂","👍","😮","😢","🔥","👏","🎉"];function e3({x:e,y:t,onReact:a,onClose:n}){const i=b.useRef(null);b.useEffect(()=>{const d=c=>{i.current&&!i.current.contains(c.target)&&n()};return document.addEventListener("mousedown",d),()=>document.removeEventListener("mousedown",d)},[n]);const o=156,s=Math.max(o/2+8,Math.min(e,window.innerWidth-o/2-8));return r.jsx("div",{ref:i,style:{position:"fixed",top:t-80,left:s,transform:"translateX(-50%)",zIndex:1e4,background:"var(--bg-card)",border:"1px solid var(--border-faint)",borderRadius:16,boxShadow:"0 8px 24px rgba(0,0,0,0.18)",padding:"6px 8px",display:"grid",gridTemplateColumns:"repeat(4, 1fr)",gap:2,width:o},children:QL.map(d=>r.jsx("button",{onClick:()=>a(d),style:{width:30,height:30,display:"flex",alignItems:"center",justifyContent:"center",background:"none",border:"none",cursor:"pointer",borderRadius:"50%",padding:3,transition:"transform 0.1s, background 0.1s"},onMouseEnter:c=>{c.currentTarget.style.transform="scale(1.2)",c.currentTarget.style.background="var(--bg-hover)"},onMouseLeave:c=>{c.currentTarget.style.transform="scale(1)",c.currentTarget.style.background="none"},children:r.jsx(nb,{emoji:d,size:18})},d))})}function o1({text:e}){const t=e.split(ry),a=e.match(ry)||[],n=[];return t.forEach((i,o)=>{i&&n.push(i),a[o]&&n.push(r.jsx("a",{href:a[o],target:"_blank",rel:"noopener noreferrer",style:{color:"inherit",textDecoration:"underline",textUnderlineOffset:2,opacity:.85},children:a[o]},o))}),r.jsx(r.Fragment,{children:n})}const ry=/https?:\/\/[^\s<>"']+/g,vu={};function t3({url:e,tripId:t,own:a,onLoad:n}){const[i,o]=b.useState(vu[e]||null),[s,d]=b.useState(!vu[e]);if(b.useEffect(()=>{vu[e]||Ta.linkPreview(t,e).then(p=>{vu[e]=p,o(p),d(!1),(p!=null&&p.title||p!=null&&p.description||p!=null&&p.image)&&(n==null||n())}).catch(()=>d(!1))},[e,t]),s||!i||!i.title&&!i.description&&!i.image)return null;const c=(()=>{try{return new URL(e).hostname.replace("www.","")}catch{return""}})();return r.jsxs("a",{href:e,target:"_blank",rel:"noopener noreferrer",style:{display:"block",textDecoration:"none",marginTop:6,borderRadius:12,overflow:"hidden",border:a?"1px solid rgba(255,255,255,0.15)":"1px solid var(--border-faint)",background:a?"rgba(255,255,255,0.1)":"var(--bg-secondary)",maxWidth:280,transition:"opacity 0.15s"},onMouseEnter:p=>p.currentTarget.style.opacity="0.85",onMouseLeave:p=>p.currentTarget.style.opacity="1",children:[i.image&&r.jsx("img",{src:i.image,alt:"",style:{width:"100%",height:140,objectFit:"cover",display:"block"},onError:p=>p.target.style.display="none"}),r.jsxs("div",{style:{padding:"8px 10px"},children:[c&&r.jsx("div",{style:{fontSize:10,fontWeight:600,color:a?"rgba(255,255,255,0.5)":"var(--text-faint)",textTransform:"uppercase",letterSpacing:.3,marginBottom:2},children:i.site_name||c}),i.title&&r.jsx("div",{style:{fontSize:12,fontWeight:600,color:a?"#fff":"var(--text-primary)",lineHeight:1.3,marginBottom:2,display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",overflow:"hidden"},children:i.title}),i.description&&r.jsx("div",{style:{fontSize:11,color:a?"rgba(255,255,255,0.7)":"var(--text-muted)",lineHeight:1.3,display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",overflow:"hidden"},children:i.description})]})]})}function a3({reaction:e,currentUserId:t,onReact:a}){const[n,i]=b.useState(!1),[o,s]=b.useState({top:0,left:0}),d=b.useRef(null),c=e.users.map(p=>p.username).join(", ");return r.jsxs(r.Fragment,{children:[r.jsxs("button",{ref:d,onClick:a,onMouseEnter:()=>{if(d.current){const p=d.current.getBoundingClientRect();s({top:p.top-6,left:p.left+p.width/2})}i(!0)},onMouseLeave:()=>i(!1),style:{display:"inline-flex",alignItems:"center",gap:2,padding:"1px 3px",borderRadius:99,border:"none",cursor:"pointer",fontFamily:"inherit",background:"transparent",transition:"transform 0.1s"},children:[r.jsx(nb,{emoji:e.emoji,size:16}),e.count>1&&r.jsx("span",{style:{fontSize:10,fontWeight:700,color:"var(--text-muted)",minWidth:8},children:e.count})]}),n&&c&&Vt.createPortal(r.jsx("div",{style:{position:"fixed",top:o.top,left:o.left,transform:"translate(-50%, -100%)",pointerEvents:"none",zIndex:1e4,whiteSpace:"nowrap",background:"var(--bg-card, white)",color:"var(--text-primary, #111827)",fontSize:11,fontWeight:500,padding:"5px 10px",borderRadius:8,boxShadow:"0 4px 12px rgba(0,0,0,0.15)",border:"1px solid var(--border-faint, #e5e7eb)"},children:c}),document.body)]})}function s1({tripId:e,currentUser:t}){const{t:a}=ot(),n=ta(oe=>oe.settings.time_format)==="12h",[i,o]=b.useState([]),[s,d]=b.useState(!0),[c,p]=b.useState(!1),[m,g]=b.useState(!1),[f,y]=b.useState(""),[x,k]=b.useState(null),[S,v]=b.useState(null),[_,w]=b.useState(!1),[E,M]=b.useState(!1),[A,P]=b.useState(null),[R,$]=b.useState(new Set),I=b.useRef(null),Y=b.useRef(i);Y.current=i;const H=b.useRef(null),V=b.useRef(null),X=b.useRef(null),Z=b.useRef(!0),O=b.useCallback((oe="auto")=>{const be=H.current;be&&requestAnimationFrame(()=>be.scrollTo({top:be.scrollHeight,behavior:oe}))},[]),Q=b.useCallback(()=>{const oe=H.current;oe&&(Z.current=oe.scrollHeight-oe.scrollTop-oe.clientHeight<48)},[]);b.useEffect(()=>{let oe=!1;return d(!0),Ta.getMessages(e).then(be=>{if(oe)return;const Se=(Array.isArray(be)?be:be.messages||[]).map(je=>je.deleted?{...je,_deleted:!0}:je);o(Se),p(Se.length>=100),d(!1),setTimeout(()=>O(),30)}).catch(()=>{oe||d(!1)}),()=>{oe=!0}},[e,O]);const D=b.useCallback(async()=>{var Se;if(m||i.length===0)return;g(!0);const oe=H.current,be=oe?oe.scrollHeight:0;try{const je=await Ta.getMessages(e,(Se=i[0])==null?void 0:Se.id),we=(Array.isArray(je)?je:je.messages||[]).map(ce=>ce.deleted?{...ce,_deleted:!0}:ce);we.length===0?p(!1):(o(ce=>[...we,...ce]),p(we.length>=100),requestAnimationFrame(()=>{oe&&(oe.scrollTop=oe.scrollHeight-be)}))}catch{}finally{g(!1)}},[e,m,i]);b.useEffect(()=>{const oe=be=>{be.type==="collab:message:created"&&String(be.tripId)===String(e)&&(o(Se=>Se.some(je=>je.id===be.message.id)?Se:[...Se,be.message]),Z.current&&setTimeout(()=>O("smooth"),30)),be.type==="collab:message:deleted"&&String(be.tripId)===String(e)&&(o(Se=>Se.map(je=>je.id===be.messageId?{...je,_deleted:!0}:je)),Z.current&&setTimeout(()=>O("smooth"),50)),be.type==="collab:message:reacted"&&String(be.tripId)===String(e)&&o(Se=>Se.map(je=>je.id===be.messageId?{...je,reactions:be.reactions}:je))};return xl(oe),()=>kl(oe)},[e,O]);const J=b.useCallback(oe=>{y(oe.target.value);const be=V.current;if(be){be.style.height="auto";const Se=Math.min(be.scrollHeight,100);be.style.height=Se+"px",be.style.overflowY=be.scrollHeight>100?"auto":"hidden"}},[]),z=b.useCallback(async()=>{const oe=f.trim();if(!(!oe||_)){w(!0);try{const be={text:oe};x&&(be.reply_to=x.id);const Se=await Ta.sendMessage(e,be);Se!=null&&Se.message&&o(je=>je.some(we=>we.id===Se.message.id)?je:[...je,Se.message]),y(""),k(null),M(!1),V.current&&(V.current.style.height="auto"),Z.current=!0,setTimeout(()=>O("smooth"),50)}catch{}finally{w(!1)}}},[f,_,x,e,O]),W=b.useCallback(oe=>{oe.key==="Enter"&&!oe.shiftKey&&(oe.preventDefault(),z())},[z]),B=b.useCallback(async oe=>{i.find(be=>be.id===oe),requestAnimationFrame(()=>{$(be=>new Set(be).add(oe))}),setTimeout(async()=>{try{await Ta.deleteMessage(e,oe),o(be=>be.map(Se=>Se.id===oe?{...Se,_deleted:!0}:Se))}catch{}$(be=>{const Se=new Set(be);return Se.delete(oe),Se})},400)},[e]),C=b.useCallback(async(oe,be)=>{P(null);try{const Se=await Ta.reactMessage(e,oe,be);o(je=>je.map(we=>we.id===oe?{...we,reactions:Se.reactions}:we))}catch{}},[e]),U=b.useCallback(oe=>{var be;y(Se=>Se+oe),(be=V.current)==null||be.focus()},[]),q=oe=>String(oe.user_id)===String(t.id),te=oe=>new RegExp("^(?:\\p{Emoji_Presentation}|\\p{Extended_Pictographic}[\\uFE0F]?(?:\\u200D\\p{Extended_Pictographic}[\\uFE0F]?)*){1,3}$","u").test(oe.trim());return s?r.jsxs("div",{style:{display:"flex",flex:1,alignItems:"center",justifyContent:"center"},children:[r.jsx("div",{style:{width:24,height:24,border:"2px solid var(--border-faint)",borderTopColor:"var(--accent)",borderRadius:"50%",animation:"spin .7s linear infinite"}}),r.jsx("style",{children:"@keyframes spin { to { transform: rotate(360deg) } }"})]}):r.jsxs("div",{ref:I,style:{display:"flex",flexDirection:"column",flex:1,overflow:"hidden",position:"relative",minHeight:0,height:"100%"},children:[i.length===0?r.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:8,color:"var(--text-faint)",padding:32},children:[r.jsx(Fp,{size:40,strokeWidth:1.2,style:{opacity:.4}}),r.jsx("span",{style:{fontSize:14,fontWeight:600},children:a("collab.chat.empty")}),r.jsx("span",{style:{fontSize:12,opacity:.6},children:a("collab.chat.emptyDesc")||""})]}):r.jsxs("div",{ref:H,onScroll:Q,className:"chat-scroll",style:{flex:1,overflowY:"auto",overflowX:"hidden",padding:"8px 14px 4px",WebkitOverflowScrolling:"touch",display:"flex",flexDirection:"column",gap:1},children:[c&&r.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"4px 0 10px"},children:r.jsxs("button",{onClick:D,disabled:m,style:{display:"inline-flex",alignItems:"center",gap:4,fontSize:11,fontWeight:600,color:"var(--text-muted)",background:"var(--bg-secondary)",border:"1px solid var(--border-faint)",borderRadius:99,padding:"5px 14px",cursor:"pointer",fontFamily:"inherit"},children:[r.jsx(oi,{size:13}),m?"...":a("collab.chat.loadMore")]})}),i.map((oe,be)=>{var He;const Se=q(oe),je=i[be-1],we=i[be+1],ce=be===0||String(je==null?void 0:je.user_id)!==String(oe.user_id),le=!we||String(we==null?void 0:we.user_id)!==String(oe.user_id),K=XL(oe,je),de=!Se&&le,_e=te(oe.text),pe=oe.reply_text||oe.reply_to;if(oe._deleted)return r.jsxs(Ka.Fragment,{children:[K&&r.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"14px 0 6px"},children:r.jsx("span",{style:{fontSize:10,fontWeight:600,color:"var(--text-faint)",background:"var(--bg-secondary)",padding:"3px 12px",borderRadius:99,letterSpacing:.3,textTransform:"uppercase"},children:i1(oe.created_at,a)})}),r.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"4px 0"},children:r.jsxs("span",{style:{fontSize:11,color:"var(--text-faint)",fontStyle:"italic"},children:[oe.username," ",a("collab.chat.deletedMessage")||"deleted a message"," · ",r1(oe.created_at,n)]})})]},oe.id);const Ae=Se?`18px 18px ${le?"4px":"18px"} 18px`:`18px 18px 18px ${le?"4px":"18px"}`;return r.jsxs(Ka.Fragment,{children:[K&&r.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"14px 0 6px"},children:r.jsx("span",{style:{fontSize:10,fontWeight:600,color:"var(--text-faint)",background:"var(--bg-secondary)",padding:"3px 12px",borderRadius:99,letterSpacing:.3,textTransform:"uppercase"},children:i1(oe.created_at,a)})}),r.jsxs("div",{style:{display:"flex",alignItems:Se?"flex-end":"flex-start",flexDirection:Se?"row-reverse":"row",gap:6,marginTop:ce?10:1,paddingLeft:Se?40:0,paddingRight:Se?0:40,transition:"transform 0.3s ease, opacity 0.3s ease, max-height 0.3s ease",...R.has(oe.id)?{transform:"scale(0.3)",opacity:0,maxHeight:0,marginTop:0,overflow:"hidden"}:{}},children:[!Se&&r.jsx("div",{style:{width:28,flexShrink:0,alignSelf:"flex-end"},children:de&&(oe.user_avatar?r.jsx("img",{src:oe.user_avatar,alt:"",style:{width:28,height:28,borderRadius:"50%",objectFit:"cover"}}):r.jsx("div",{style:{width:28,height:28,borderRadius:"50%",background:"var(--bg-tertiary)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:11,fontWeight:700,color:"var(--text-muted)"},children:(oe.username||"?")[0].toUpperCase()}))}),r.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:Se?"flex-end":"flex-start",maxWidth:"78%",minWidth:0},children:[!Se&&ce&&r.jsx("span",{style:{fontSize:10,fontWeight:600,color:"var(--text-faint)",marginBottom:2,paddingLeft:4},children:oe.username}),r.jsxs("div",{style:{position:"relative"},onMouseEnter:()=>v(oe.id),onMouseLeave:()=>v(null),onContextMenu:ze=>{ze.preventDefault(),P({msgId:oe.id,x:ze.clientX,y:ze.clientY})},onTouchEnd:ze=>{var ve;const Ye=Date.now(),G=ze.currentTarget.dataset.lastTap||0;if(Ye-G<300){ze.preventDefault();const Pe=(ve=ze.changedTouches)==null?void 0:ve[0];Pe&&P({msgId:oe.id,x:Pe.clientX,y:Pe.clientY})}ze.currentTarget.dataset.lastTap=Ye},children:[_e?r.jsx("div",{style:{fontSize:40,lineHeight:1.2,padding:"2px 0"},children:oe.text}):r.jsxs("div",{style:{background:Se?"#007AFF":"var(--bg-secondary)",color:Se?"#fff":"var(--text-primary)",borderRadius:Ae,padding:pe?"4px 4px 8px 4px":"8px 14px",fontSize:14,lineHeight:1.4,wordBreak:"break-word",whiteSpace:"pre-wrap"},children:[pe&&r.jsxs("div",{style:{padding:"5px 10px",marginBottom:4,borderRadius:12,background:Se?"rgba(255,255,255,0.15)":"var(--bg-tertiary)",fontSize:12,lineHeight:1.3},children:[r.jsx("div",{style:{fontWeight:600,fontSize:11,opacity:.7,marginBottom:1},children:oe.reply_username||""}),r.jsx("div",{style:{opacity:.8,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:(oe.reply_text||"").slice(0,80)})]}),pe?r.jsx("div",{style:{padding:"0 10px 4px"},children:r.jsx(o1,{text:oe.text})}):r.jsx(o1,{text:oe.text}),(oe.text.match(ry)||[]).slice(0,1).map(ze=>r.jsx(t3,{url:ze,tripId:e,own:Se,onLoad:()=>{Z.current&&setTimeout(()=>O("smooth"),50)}},ze))]}),r.jsxs("div",{style:{position:"absolute",top:-14,display:"flex",gap:2,opacity:S===oe.id?1:0,pointerEvents:S===oe.id?"auto":"none",transition:"opacity .1s",...Se?{left:-6}:{right:-6}},children:[r.jsx("button",{onClick:()=>k(oe),title:"Reply",style:{width:24,height:24,borderRadius:"50%",border:"none",background:"var(--accent)",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",color:"var(--accent-text)",padding:0,boxShadow:"0 2px 8px rgba(0,0,0,0.15)",transition:"transform 0.12s"},onMouseEnter:ze=>{ze.currentTarget.style.transform="scale(1.2)"},onMouseLeave:ze=>{ze.currentTarget.style.transform="scale(1)"},children:r.jsx(y0,{size:11})}),Se&&r.jsx("button",{onClick:()=>B(oe.id),title:"Delete",style:{width:24,height:24,borderRadius:"50%",border:"none",background:"var(--accent)",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",color:"var(--accent-text)",padding:0,boxShadow:"0 2px 8px rgba(0,0,0,0.15)",transition:"transform 0.12s, background 0.15s, color 0.15s"},onMouseEnter:ze=>{ze.currentTarget.style.transform="scale(1.2)",ze.currentTarget.style.background="#ef4444",ze.currentTarget.style.color="#fff"},onMouseLeave:ze=>{ze.currentTarget.style.transform="scale(1)",ze.currentTarget.style.background="var(--accent)",ze.currentTarget.style.color="var(--accent-text)"},children:r.jsx(_t,{size:11})})]})]}),((He=oe.reactions)==null?void 0:He.length)>0&&r.jsx("div",{style:{display:"flex",gap:3,marginTop:-6,marginBottom:4,justifyContent:Se?"flex-end":"flex-start",paddingLeft:Se?0:8,paddingRight:Se?8:0,position:"relative",zIndex:1},children:r.jsx("div",{style:{display:"inline-flex",alignItems:"center",gap:2,padding:"3px 6px",borderRadius:99,background:"var(--bg-card)",boxShadow:"0 1px 6px rgba(0,0,0,0.12)",border:"1px solid var(--border-faint)"},children:oe.reactions.map(ze=>(ze.users.some(Ye=>String(Ye.user_id)===String(t.id)),r.jsx(a3,{reaction:ze,currentUserId:t.id,onReact:()=>C(oe.id,ze.emoji)},ze.emoji)))})}),le&&r.jsx("span",{style:{fontSize:9,color:"var(--text-faint)",marginTop:2,padding:"0 4px"},children:r1(oe.created_at,n)})]})]})]},oe.id)})]}),r.jsxs("div",{style:{flexShrink:0,padding:"8px 12px calc(12px + env(safe-area-inset-bottom, 0px))",borderTop:"1px solid var(--border-faint)",background:"var(--bg-card)"},children:[x&&r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:8,padding:"6px 10px",borderRadius:10,background:"var(--bg-secondary)",borderLeft:"3px solid #007AFF",fontSize:12,color:"var(--text-muted)"},children:[r.jsx(y0,{size:12,style:{flexShrink:0,opacity:.5}}),r.jsxs("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:1},children:[r.jsx("strong",{children:x.username}),": ",(x.text||"").slice(0,60)]}),r.jsx("button",{onClick:()=>k(null),style:{background:"none",border:"none",cursor:"pointer",padding:2,color:"var(--text-faint)",display:"flex",flexShrink:0},children:r.jsx(gt,{size:14})})]}),r.jsxs("div",{style:{display:"flex",alignItems:"flex-end",gap:6},children:[r.jsx("button",{ref:X,onClick:()=>M(!E),style:{width:34,height:34,borderRadius:"50%",border:"none",background:E?"var(--bg-hover)":"transparent",color:"var(--text-muted)",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",padding:0,flexShrink:0,transition:"background 0.15s"},children:r.jsx(pD,{size:20})}),r.jsx("textarea",{ref:V,rows:1,style:{flex:1,resize:"none",border:"1px solid var(--border-primary)",borderRadius:20,padding:"8px 14px",fontSize:14,lineHeight:1.4,fontFamily:"inherit",background:"var(--bg-input)",color:"var(--text-primary)",outline:"none",maxHeight:100,overflowY:"hidden"},placeholder:a("collab.chat.placeholder"),value:f,onChange:J,onKeyDown:W}),r.jsx("button",{onClick:z,disabled:!f.trim()||_,style:{width:34,height:34,borderRadius:"50%",border:"none",background:f.trim()?"#007AFF":"var(--border-primary)",color:"#fff",display:"flex",alignItems:"center",justifyContent:"center",cursor:f.trim()?"pointer":"default",flexShrink:0,transition:"background 0.15s"},children:r.jsx(xM,{size:18,strokeWidth:2.5})})]})]}),E&&r.jsx(JL,{onSelect:U,onClose:()=>M(!1),anchorRef:X,containerRef:I}),A&&Vt.createPortal(r.jsx(e3,{x:A.x,y:A.y,onReact:oe=>C(A.msgId,oe),onClose:()=>P(null)}),document.body)]})}function n3(e,t){const a={};return(e[e.length-1]===""?[...e,""]:e).join((a.padRight?" ":"")+","+(a.padLeft===!1?"":" ")).trim()}const r3=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,i3=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,o3={};function l1(e,t){return(o3.jsx?i3:r3).test(e)}const s3=/[ \t\n\f\r]/g;function l3(e){return typeof e=="object"?e.type==="text"?d1(e.value):!1:d1(e)}function d1(e){return e.replace(s3,"")===""}class Pc{constructor(t,a,n){this.normal=a,this.property=t,n&&(this.space=n)}}Pc.prototype.normal={};Pc.prototype.property={};Pc.prototype.space=void 0;function pC(e,t){const a={},n={};for(const i of e)Object.assign(a,i.property),Object.assign(n,i.normal);return new Pc(a,n,t)}function iy(e){return e.toLowerCase()}class Yn{constructor(t,a){this.attribute=a,this.property=t}}Yn.prototype.attribute="";Yn.prototype.booleanish=!1;Yn.prototype.boolean=!1;Yn.prototype.commaOrSpaceSeparated=!1;Yn.prototype.commaSeparated=!1;Yn.prototype.defined=!1;Yn.prototype.mustUseProperty=!1;Yn.prototype.number=!1;Yn.prototype.overloadedBoolean=!1;Yn.prototype.property="";Yn.prototype.spaceSeparated=!1;Yn.prototype.space=void 0;let d3=0;const St=xs(),Oa=xs(),oy=xs(),Fe=xs(),ia=xs(),cl=xs(),er=xs();function xs(){return 2**++d3}const sy=Object.freeze(Object.defineProperty({__proto__:null,boolean:St,booleanish:Oa,commaOrSpaceSeparated:er,commaSeparated:cl,number:Fe,overloadedBoolean:oy,spaceSeparated:ia},Symbol.toStringTag,{value:"Module"})),dh=Object.keys(sy);class rb extends Yn{constructor(t,a,n,i){let o=-1;if(super(t,a),c1(this,"space",i),typeof n=="number")for(;++o4&&a.slice(0,4)==="data"&&g3.test(t)){if(t.charAt(4)==="-"){const o=t.slice(5).replace(u1,y3);n="data"+o.charAt(0).toUpperCase()+o.slice(1)}else{const o=t.slice(4);if(!u1.test(o)){let s=o.replace(m3,f3);s.charAt(0)!=="-"&&(s="-"+s),t="data"+s}}i=rb}return new i(n,t)}function f3(e){return"-"+e.toLowerCase()}function y3(e){return e.charAt(1).toUpperCase()}const v3=pC([mC,c3,fC,yC,vC],"html"),ib=pC([mC,u3,fC,yC,vC],"svg");function b3(e){return e.join(" ").trim()}var ob={},p1=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,x3=/\n/g,k3=/^\s*/,w3=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,S3=/^:\s*/,j3=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,_3=/^[;\s]*/,C3=/^\s+|\s+$/g,z3=`
+`,m1="/",g1="*",Vo="",T3="comment",P3="declaration";function E3(e,t){if(typeof e!="string")throw new TypeError("First argument must be a string");if(!e)return[];t=t||{};var a=1,n=1;function i(x){var k=x.match(x3);k&&(a+=k.length);var S=x.lastIndexOf(z3);n=~S?x.length-S:n+x.length}function o(){var x={line:a,column:n};return function(k){return k.position=new s(x),p(),k}}function s(x){this.start=x,this.end={line:a,column:n},this.source=t.source}s.prototype.content=e;function d(x){var k=new Error(t.source+":"+a+":"+n+": "+x);if(k.reason=x,k.filename=t.source,k.line=a,k.column=n,k.source=e,!t.silent)throw k}function c(x){var k=x.exec(e);if(k){var S=k[0];return i(S),e=e.slice(S.length),k}}function p(){c(k3)}function m(x){var k;for(x=x||[];k=g();)k!==!1&&x.push(k);return x}function g(){var x=o();if(!(m1!=e.charAt(0)||g1!=e.charAt(1))){for(var k=2;Vo!=e.charAt(k)&&(g1!=e.charAt(k)||m1!=e.charAt(k+1));)++k;if(k+=2,Vo===e.charAt(k-1))return d("End of comment missing");var S=e.slice(2,k-2);return n+=2,i(S),e=e.slice(k),n+=2,x({type:T3,comment:S})}}function f(){var x=o(),k=c(w3);if(k){if(g(),!c(S3))return d("property missing ':'");var S=c(j3),v=x({type:P3,property:h1(k[0].replace(p1,Vo)),value:S?h1(S[0].replace(p1,Vo)):Vo});return c(_3),v}}function y(){var x=[];m(x);for(var k;k=f();)k!==!1&&(x.push(k),m(x));return x}return p(),y()}function h1(e){return e?e.replace(C3,Vo):Vo}var A3=E3,N3=wr&&wr.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(ob,"__esModule",{value:!0});ob.default=M3;const R3=N3(A3);function M3(e,t){let a=null;if(!e||typeof e!="string")return a;const n=(0,R3.default)(e),i=typeof t=="function";return n.forEach(o=>{if(o.type!=="declaration")return;const{property:s,value:d}=o;i?t(s,d,o):d&&(a=a||{},a[s]=d)}),a}var Vm={};Object.defineProperty(Vm,"__esModule",{value:!0});Vm.camelCase=void 0;var D3=/^--[a-zA-Z0-9_-]+$/,I3=/-([a-z])/g,L3=/^[^-]+$/,F3=/^-(webkit|moz|ms|o|khtml)-/,O3=/^-(ms)-/,B3=function(e){return!e||L3.test(e)||D3.test(e)},H3=function(e,t){return t.toUpperCase()},f1=function(e,t){return"".concat(t,"-")},U3=function(e,t){return t===void 0&&(t={}),B3(e)?e:(e=e.toLowerCase(),t.reactCompat?e=e.replace(O3,f1):e=e.replace(F3,f1),e.replace(I3,H3))};Vm.camelCase=U3;var W3=wr&&wr.__importDefault||function(e){return e&&e.__esModule?e:{default:e}},$3=W3(ob),V3=Vm;function ly(e,t){var a={};return!e||typeof e!="string"||(0,$3.default)(e,function(n,i){n&&i&&(a[(0,V3.camelCase)(n,t)]=i)}),a}ly.default=ly;var K3=ly;const q3=gs(K3),bC=xC("end"),sb=xC("start");function xC(e){return t;function t(a){const n=a&&a.position&&a.position[e]||{};if(typeof n.line=="number"&&n.line>0&&typeof n.column=="number"&&n.column>0)return{line:n.line,column:n.column,offset:typeof n.offset=="number"&&n.offset>-1?n.offset:void 0}}}function G3(e){const t=sb(e),a=bC(e);if(t&&a)return{start:t,end:a}}function Nd(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?y1(e.position):"start"in e||"end"in e?y1(e):"line"in e||"column"in e?dy(e):""}function dy(e){return v1(e&&e.line)+":"+v1(e&&e.column)}function y1(e){return dy(e&&e.start)+"-"+dy(e&&e.end)}function v1(e){return e&&typeof e=="number"?e:1}class Sn extends Error{constructor(t,a,n){super(),typeof a=="string"&&(n=a,a=void 0);let i="",o={},s=!1;if(a&&("line"in a&&"column"in a?o={place:a}:"start"in a&&"end"in a?o={place:a}:"type"in a?o={ancestors:[a],place:a.position}:o={...a}),typeof t=="string"?i=t:!o.cause&&t&&(s=!0,i=t.message,o.cause=t),!o.ruleId&&!o.source&&typeof n=="string"){const c=n.indexOf(":");c===-1?o.ruleId=n:(o.source=n.slice(0,c),o.ruleId=n.slice(c+1))}if(!o.place&&o.ancestors&&o.ancestors){const c=o.ancestors[o.ancestors.length-1];c&&(o.place=c.position)}const d=o.place&&"start"in o.place?o.place.start:o.place;this.ancestors=o.ancestors||void 0,this.cause=o.cause||void 0,this.column=d?d.column:void 0,this.fatal=void 0,this.file="",this.message=i,this.line=d?d.line:void 0,this.name=Nd(o.place)||"1:1",this.place=o.place||void 0,this.reason=this.message,this.ruleId=o.ruleId||void 0,this.source=o.source||void 0,this.stack=s&&o.cause&&typeof o.cause.stack=="string"?o.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}Sn.prototype.file="";Sn.prototype.name="";Sn.prototype.reason="";Sn.prototype.message="";Sn.prototype.stack="";Sn.prototype.column=void 0;Sn.prototype.line=void 0;Sn.prototype.ancestors=void 0;Sn.prototype.cause=void 0;Sn.prototype.fatal=void 0;Sn.prototype.place=void 0;Sn.prototype.ruleId=void 0;Sn.prototype.source=void 0;const lb={}.hasOwnProperty,Z3=new Map,Y3=/[A-Z]/g,X3=new Set(["table","tbody","thead","tfoot","tr"]),J3=new Set(["td","th"]),kC="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function Q3(e,t){if(!t||t.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const a=t.filePath||void 0;let n;if(t.development){if(typeof t.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");n=sF(a,t.jsxDEV)}else{if(typeof t.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof t.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");n=oF(a,t.jsx,t.jsxs)}const i={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:n,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:a,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space==="svg"?ib:v3,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},o=wC(i,e,void 0);return o&&typeof o!="string"?o:i.create(e,i.Fragment,{children:o||void 0},void 0)}function wC(e,t,a){if(t.type==="element")return eF(e,t,a);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return tF(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return nF(e,t,a);if(t.type==="mdxjsEsm")return aF(e,t);if(t.type==="root")return rF(e,t,a);if(t.type==="text")return iF(e,t)}function eF(e,t,a){const n=e.schema;let i=n;t.tagName.toLowerCase()==="svg"&&n.space==="html"&&(i=ib,e.schema=i),e.ancestors.push(t);const o=jC(e,t.tagName,!1),s=lF(e,t);let d=cb(e,t);return X3.has(t.tagName)&&(d=d.filter(function(c){return typeof c=="string"?!l3(c):!0})),SC(e,s,o,t),db(s,d),e.ancestors.pop(),e.schema=n,e.create(t,o,s,a)}function tF(e,t){if(t.data&&t.data.estree&&e.evaluater){const n=t.data.estree.body[0];return n.type,e.evaluater.evaluateExpression(n.expression)}sc(e,t.position)}function aF(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);sc(e,t.position)}function nF(e,t,a){const n=e.schema;let i=n;t.name==="svg"&&n.space==="html"&&(i=ib,e.schema=i),e.ancestors.push(t);const o=t.name===null?e.Fragment:jC(e,t.name,!0),s=dF(e,t),d=cb(e,t);return SC(e,s,o,t),db(s,d),e.ancestors.pop(),e.schema=n,e.create(t,o,s,a)}function rF(e,t,a){const n={};return db(n,cb(e,t)),e.create(t,e.Fragment,n,a)}function iF(e,t){return t.value}function SC(e,t,a,n){typeof a!="string"&&a!==e.Fragment&&e.passNode&&(t.node=n)}function db(e,t){if(t.length>0){const a=t.length>1?t:t[0];a&&(e.children=a)}}function oF(e,t,a){return n;function n(i,o,s,d){const p=Array.isArray(s.children)?a:t;return d?p(o,s,d):p(o,s)}}function sF(e,t){return a;function a(n,i,o,s){const d=Array.isArray(o.children),c=sb(n);return t(i,o,s,d,{columnNumber:c?c.column-1:void 0,fileName:e,lineNumber:c?c.line:void 0},void 0)}}function lF(e,t){const a={};let n,i;for(i in t.properties)if(i!=="children"&&lb.call(t.properties,i)){const o=cF(e,i,t.properties[i]);if(o){const[s,d]=o;e.tableCellAlignToStyle&&s==="align"&&typeof d=="string"&&J3.has(t.tagName)?n=d:a[s]=d}}if(n){const o=a.style||(a.style={});o[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=n}return a}function dF(e,t){const a={};for(const n of t.attributes)if(n.type==="mdxJsxExpressionAttribute")if(n.data&&n.data.estree&&e.evaluater){const o=n.data.estree.body[0];o.type;const s=o.expression;s.type;const d=s.properties[0];d.type,Object.assign(a,e.evaluater.evaluateExpression(d.argument))}else sc(e,t.position);else{const i=n.name;let o;if(n.value&&typeof n.value=="object")if(n.value.data&&n.value.data.estree&&e.evaluater){const d=n.value.data.estree.body[0];d.type,o=e.evaluater.evaluateExpression(d.expression)}else sc(e,t.position);else o=n.value===null?!0:n.value;a[i]=o}return a}function cb(e,t){const a=[];let n=-1;const i=e.passKeys?new Map:Z3;for(;++ni?0:i+t:t=t>i?i:t,a=a>0?a:0,n.length<1e4)s=Array.from(n),s.unshift(t,a),e.splice(...s);else for(a&&e.splice(t,a);o0?(cr(e,e.length,0,t),e):t}const k1={}.hasOwnProperty;function CC(e){const t={};let a=-1;for(;++a13&&a<32||a>126&&a<160||a>55295&&a<57344||a>64975&&a<65008||(a&65535)===65535||(a&65535)===65534||a>1114111?"�":String.fromCodePoint(a)}function Lr(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const Pn=Mo(/[A-Za-z]/),bn=Mo(/[\dA-Za-z]/),bF=Mo(/[#-'*+\--9=?A-Z^-~]/);function Wp(e){return e!==null&&(e<32||e===127)}const cy=Mo(/\d/),xF=Mo(/[\dA-Fa-f]/),kF=Mo(/[!-/:-@[-`{-~]/);function st(e){return e!==null&&e<-2}function aa(e){return e!==null&&(e<0||e===32)}function Mt(e){return e===-2||e===-1||e===32}const Km=Mo(new RegExp("\\p{P}|\\p{S}","u")),ms=Mo(/\s/);function Mo(e){return t;function t(a){return a!==null&&a>-1&&e.test(String.fromCharCode(a))}}function Fl(e){const t=[];let a=-1,n=0,i=0;for(;++a55295&&o<57344){const d=e.charCodeAt(a+1);o<56320&&d>56319&&d<57344?(s=String.fromCharCode(o,d),i=1):s="�"}else s=String.fromCharCode(o);s&&(t.push(e.slice(n,a),encodeURIComponent(s)),n=a+i+1,s=""),i&&(a+=i,i=0)}return t.join("")+e.slice(n)}function Ht(e,t,a,n){const i=n?n-1:Number.POSITIVE_INFINITY;let o=0;return s;function s(c){return Mt(c)?(e.enter(a),d(c)):t(c)}function d(c){return Mt(c)&&o++s))return;const P=t.events.length;let R=P,$,I;for(;R--;)if(t.events[R][0]==="exit"&&t.events[R][1].type==="chunkFlow"){if($){I=t.events[R][1].end;break}$=!0}for(v(n),A=P;Aw;){const M=a[E];t.containerState=M[1],M[0].exit.call(t,e)}a.length=w}function _(){i.write([null]),o=void 0,i=void 0,t.containerState._closeFlow=void 0}}function CF(e,t,a){return Ht(e,e.attempt(this.parser.constructs.document,t,a),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function _l(e){if(e===null||aa(e)||ms(e))return 1;if(Km(e))return 2}function qm(e,t,a){const n=[];let i=-1;for(;++i1&&e[a][1].end.offset-e[a][1].start.offset>1?2:1;const g={...e[n][1].end},f={...e[a][1].start};S1(g,-c),S1(f,c),s={type:c>1?"strongSequence":"emphasisSequence",start:g,end:{...e[n][1].end}},d={type:c>1?"strongSequence":"emphasisSequence",start:{...e[a][1].start},end:f},o={type:c>1?"strongText":"emphasisText",start:{...e[n][1].end},end:{...e[a][1].start}},i={type:c>1?"strong":"emphasis",start:{...s.start},end:{...d.end}},e[n][1].end={...s.start},e[a][1].start={...d.end},p=[],e[n][1].end.offset-e[n][1].start.offset&&(p=br(p,[["enter",e[n][1],t],["exit",e[n][1],t]])),p=br(p,[["enter",i,t],["enter",s,t],["exit",s,t],["enter",o,t]]),p=br(p,qm(t.parser.constructs.insideSpan.null,e.slice(n+1,a),t)),p=br(p,[["exit",o,t],["enter",d,t],["exit",d,t],["exit",i,t]]),e[a][1].end.offset-e[a][1].start.offset?(m=2,p=br(p,[["enter",e[a][1],t],["exit",e[a][1],t]])):m=0,cr(e,n-1,a-n+3,p),a=n+p.length-m-2;break}}for(a=-1;++a0&&Mt(A)?Ht(e,_,"linePrefix",o+1)(A):_(A)}function _(A){return A===null||st(A)?e.check(j1,k,E)(A):(e.enter("codeFlowValue"),w(A))}function w(A){return A===null||st(A)?(e.exit("codeFlowValue"),_(A)):(e.consume(A),w)}function E(A){return e.exit("codeFenced"),t(A)}function M(A,P,R){let $=0;return I;function I(Z){return A.enter("lineEnding"),A.consume(Z),A.exit("lineEnding"),Y}function Y(Z){return A.enter("codeFencedFence"),Mt(Z)?Ht(A,H,"linePrefix",n.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(Z):H(Z)}function H(Z){return Z===d?(A.enter("codeFencedFenceSequence"),V(Z)):R(Z)}function V(Z){return Z===d?($++,A.consume(Z),V):$>=s?(A.exit("codeFencedFenceSequence"),Mt(Z)?Ht(A,X,"whitespace")(Z):X(Z)):R(Z)}function X(Z){return Z===null||st(Z)?(A.exit("codeFencedFence"),P(Z)):R(Z)}}}function FF(e,t,a){const n=this;return i;function i(s){return s===null?a(s):(e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),o)}function o(s){return n.parser.lazy[n.now().line]?a(s):t(s)}}const uh={name:"codeIndented",tokenize:BF},OF={partial:!0,tokenize:HF};function BF(e,t,a){const n=this;return i;function i(p){return e.enter("codeIndented"),Ht(e,o,"linePrefix",5)(p)}function o(p){const m=n.events[n.events.length-1];return m&&m[1].type==="linePrefix"&&m[2].sliceSerialize(m[1],!0).length>=4?s(p):a(p)}function s(p){return p===null?c(p):st(p)?e.attempt(OF,s,c)(p):(e.enter("codeFlowValue"),d(p))}function d(p){return p===null||st(p)?(e.exit("codeFlowValue"),s(p)):(e.consume(p),d)}function c(p){return e.exit("codeIndented"),t(p)}}function HF(e,t,a){const n=this;return i;function i(s){return n.parser.lazy[n.now().line]?a(s):st(s)?(e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),i):Ht(e,o,"linePrefix",5)(s)}function o(s){const d=n.events[n.events.length-1];return d&&d[1].type==="linePrefix"&&d[2].sliceSerialize(d[1],!0).length>=4?t(s):st(s)?i(s):a(s)}}const UF={name:"codeText",previous:$F,resolve:WF,tokenize:VF};function WF(e){let t=e.length-4,a=3,n,i;if((e[a][1].type==="lineEnding"||e[a][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(n=a;++n=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+t+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return tthis.left.length?this.right.slice(this.right.length-n+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-n+this.left.length).reverse())}splice(t,a,n){const i=a||0;this.setCursor(Math.trunc(t));const o=this.right.splice(this.right.length-i,Number.POSITIVE_INFINITY);return n&&ld(this.left,n),o.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),ld(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),ld(this.right,t.reverse())}setCursor(t){if(!(t===this.left.length||t>this.left.length&&this.right.length===0||t<0&&this.left.length===0))if(t=4?t(s):e.interrupt(n.parser.constructs.flow,a,t)(s)}}function NC(e,t,a,n,i,o,s,d,c){const p=c||Number.POSITIVE_INFINITY;let m=0;return g;function g(v){return v===60?(e.enter(n),e.enter(i),e.enter(o),e.consume(v),e.exit(o),f):v===null||v===32||v===41||Wp(v)?a(v):(e.enter(n),e.enter(s),e.enter(d),e.enter("chunkString",{contentType:"string"}),k(v))}function f(v){return v===62?(e.enter(o),e.consume(v),e.exit(o),e.exit(i),e.exit(n),t):(e.enter(d),e.enter("chunkString",{contentType:"string"}),y(v))}function y(v){return v===62?(e.exit("chunkString"),e.exit(d),f(v)):v===null||v===60||st(v)?a(v):(e.consume(v),v===92?x:y)}function x(v){return v===60||v===62||v===92?(e.consume(v),y):y(v)}function k(v){return!m&&(v===null||v===41||aa(v))?(e.exit("chunkString"),e.exit(d),e.exit(s),e.exit(n),t(v)):m999||y===null||y===91||y===93&&!c||y===94&&!d&&"_hiddenFootnoteSupport"in s.parser.constructs?a(y):y===93?(e.exit(o),e.enter(i),e.consume(y),e.exit(i),e.exit(n),t):st(y)?(e.enter("lineEnding"),e.consume(y),e.exit("lineEnding"),m):(e.enter("chunkString",{contentType:"string"}),g(y))}function g(y){return y===null||y===91||y===93||st(y)||d++>999?(e.exit("chunkString"),m(y)):(e.consume(y),c||(c=!Mt(y)),y===92?f:g)}function f(y){return y===91||y===92||y===93?(e.consume(y),d++,g):g(y)}}function MC(e,t,a,n,i,o){let s;return d;function d(f){return f===34||f===39||f===40?(e.enter(n),e.enter(i),e.consume(f),e.exit(i),s=f===40?41:f,c):a(f)}function c(f){return f===s?(e.enter(i),e.consume(f),e.exit(i),e.exit(n),t):(e.enter(o),p(f))}function p(f){return f===s?(e.exit(o),c(s)):f===null?a(f):st(f)?(e.enter("lineEnding"),e.consume(f),e.exit("lineEnding"),Ht(e,p,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),m(f))}function m(f){return f===s||f===null||st(f)?(e.exit("chunkString"),p(f)):(e.consume(f),f===92?g:m)}function g(f){return f===s||f===92?(e.consume(f),m):m(f)}}function Rd(e,t){let a;return n;function n(i){return st(i)?(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),a=!0,n):Mt(i)?Ht(e,n,a?"linePrefix":"lineSuffix")(i):t(i)}}const QF={name:"definition",tokenize:t6},e6={partial:!0,tokenize:a6};function t6(e,t,a){const n=this;let i;return o;function o(y){return e.enter("definition"),s(y)}function s(y){return RC.call(n,e,d,a,"definitionLabel","definitionLabelMarker","definitionLabelString")(y)}function d(y){return i=Lr(n.sliceSerialize(n.events[n.events.length-1][1]).slice(1,-1)),y===58?(e.enter("definitionMarker"),e.consume(y),e.exit("definitionMarker"),c):a(y)}function c(y){return aa(y)?Rd(e,p)(y):p(y)}function p(y){return NC(e,m,a,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(y)}function m(y){return e.attempt(e6,g,g)(y)}function g(y){return Mt(y)?Ht(e,f,"whitespace")(y):f(y)}function f(y){return y===null||st(y)?(e.exit("definition"),n.parser.defined.push(i),t(y)):a(y)}}function a6(e,t,a){return n;function n(d){return aa(d)?Rd(e,i)(d):a(d)}function i(d){return MC(e,o,a,"definitionTitle","definitionTitleMarker","definitionTitleString")(d)}function o(d){return Mt(d)?Ht(e,s,"whitespace")(d):s(d)}function s(d){return d===null||st(d)?t(d):a(d)}}const n6={name:"hardBreakEscape",tokenize:r6};function r6(e,t,a){return n;function n(o){return e.enter("hardBreakEscape"),e.consume(o),i}function i(o){return st(o)?(e.exit("hardBreakEscape"),t(o)):a(o)}}const i6={name:"headingAtx",resolve:o6,tokenize:s6};function o6(e,t){let a=e.length-2,n=3,i,o;return e[n][1].type==="whitespace"&&(n+=2),a-2>n&&e[a][1].type==="whitespace"&&(a-=2),e[a][1].type==="atxHeadingSequence"&&(n===a-1||a-4>n&&e[a-2][1].type==="whitespace")&&(a-=n+1===a?2:4),a>n&&(i={type:"atxHeadingText",start:e[n][1].start,end:e[a][1].end},o={type:"chunkText",start:e[n][1].start,end:e[a][1].end,contentType:"text"},cr(e,n,a-n+1,[["enter",i,t],["enter",o,t],["exit",o,t],["exit",i,t]])),e}function s6(e,t,a){let n=0;return i;function i(m){return e.enter("atxHeading"),o(m)}function o(m){return e.enter("atxHeadingSequence"),s(m)}function s(m){return m===35&&n++<6?(e.consume(m),s):m===null||aa(m)?(e.exit("atxHeadingSequence"),d(m)):a(m)}function d(m){return m===35?(e.enter("atxHeadingSequence"),c(m)):m===null||st(m)?(e.exit("atxHeading"),t(m)):Mt(m)?Ht(e,d,"whitespace")(m):(e.enter("atxHeadingText"),p(m))}function c(m){return m===35?(e.consume(m),c):(e.exit("atxHeadingSequence"),d(m))}function p(m){return m===null||m===35||aa(m)?(e.exit("atxHeadingText"),d(m)):(e.consume(m),p)}}const l6=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],C1=["pre","script","style","textarea"],d6={concrete:!0,name:"htmlFlow",resolveTo:p6,tokenize:m6},c6={partial:!0,tokenize:h6},u6={partial:!0,tokenize:g6};function p6(e){let t=e.length;for(;t--&&!(e[t][0]==="enter"&&e[t][1].type==="htmlFlow"););return t>1&&e[t-2][1].type==="linePrefix"&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function m6(e,t,a){const n=this;let i,o,s,d,c;return p;function p(C){return m(C)}function m(C){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(C),g}function g(C){return C===33?(e.consume(C),f):C===47?(e.consume(C),o=!0,k):C===63?(e.consume(C),i=3,n.interrupt?t:z):Pn(C)?(e.consume(C),s=String.fromCharCode(C),S):a(C)}function f(C){return C===45?(e.consume(C),i=2,y):C===91?(e.consume(C),i=5,d=0,x):Pn(C)?(e.consume(C),i=4,n.interrupt?t:z):a(C)}function y(C){return C===45?(e.consume(C),n.interrupt?t:z):a(C)}function x(C){const U="CDATA[";return C===U.charCodeAt(d++)?(e.consume(C),d===U.length?n.interrupt?t:H:x):a(C)}function k(C){return Pn(C)?(e.consume(C),s=String.fromCharCode(C),S):a(C)}function S(C){if(C===null||C===47||C===62||aa(C)){const U=C===47,q=s.toLowerCase();return!U&&!o&&C1.includes(q)?(i=1,n.interrupt?t(C):H(C)):l6.includes(s.toLowerCase())?(i=6,U?(e.consume(C),v):n.interrupt?t(C):H(C)):(i=7,n.interrupt&&!n.parser.lazy[n.now().line]?a(C):o?_(C):w(C))}return C===45||bn(C)?(e.consume(C),s+=String.fromCharCode(C),S):a(C)}function v(C){return C===62?(e.consume(C),n.interrupt?t:H):a(C)}function _(C){return Mt(C)?(e.consume(C),_):I(C)}function w(C){return C===47?(e.consume(C),I):C===58||C===95||Pn(C)?(e.consume(C),E):Mt(C)?(e.consume(C),w):I(C)}function E(C){return C===45||C===46||C===58||C===95||bn(C)?(e.consume(C),E):M(C)}function M(C){return C===61?(e.consume(C),A):Mt(C)?(e.consume(C),M):w(C)}function A(C){return C===null||C===60||C===61||C===62||C===96?a(C):C===34||C===39?(e.consume(C),c=C,P):Mt(C)?(e.consume(C),A):R(C)}function P(C){return C===c?(e.consume(C),c=null,$):C===null||st(C)?a(C):(e.consume(C),P)}function R(C){return C===null||C===34||C===39||C===47||C===60||C===61||C===62||C===96||aa(C)?M(C):(e.consume(C),R)}function $(C){return C===47||C===62||Mt(C)?w(C):a(C)}function I(C){return C===62?(e.consume(C),Y):a(C)}function Y(C){return C===null||st(C)?H(C):Mt(C)?(e.consume(C),Y):a(C)}function H(C){return C===45&&i===2?(e.consume(C),O):C===60&&i===1?(e.consume(C),Q):C===62&&i===4?(e.consume(C),W):C===63&&i===3?(e.consume(C),z):C===93&&i===5?(e.consume(C),J):st(C)&&(i===6||i===7)?(e.exit("htmlFlowData"),e.check(c6,B,V)(C)):C===null||st(C)?(e.exit("htmlFlowData"),V(C)):(e.consume(C),H)}function V(C){return e.check(u6,X,B)(C)}function X(C){return e.enter("lineEnding"),e.consume(C),e.exit("lineEnding"),Z}function Z(C){return C===null||st(C)?V(C):(e.enter("htmlFlowData"),H(C))}function O(C){return C===45?(e.consume(C),z):H(C)}function Q(C){return C===47?(e.consume(C),s="",D):H(C)}function D(C){if(C===62){const U=s.toLowerCase();return C1.includes(U)?(e.consume(C),W):H(C)}return Pn(C)&&s.length<8?(e.consume(C),s+=String.fromCharCode(C),D):H(C)}function J(C){return C===93?(e.consume(C),z):H(C)}function z(C){return C===62?(e.consume(C),W):C===45&&i===2?(e.consume(C),z):H(C)}function W(C){return C===null||st(C)?(e.exit("htmlFlowData"),B(C)):(e.consume(C),W)}function B(C){return e.exit("htmlFlow"),t(C)}}function g6(e,t,a){const n=this;return i;function i(s){return st(s)?(e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),o):a(s)}function o(s){return n.parser.lazy[n.now().line]?a(s):t(s)}}function h6(e,t,a){return n;function n(i){return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),e.attempt(Ec,t,a)}}const f6={name:"htmlText",tokenize:y6};function y6(e,t,a){const n=this;let i,o,s;return d;function d(z){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(z),c}function c(z){return z===33?(e.consume(z),p):z===47?(e.consume(z),M):z===63?(e.consume(z),w):Pn(z)?(e.consume(z),R):a(z)}function p(z){return z===45?(e.consume(z),m):z===91?(e.consume(z),o=0,x):Pn(z)?(e.consume(z),_):a(z)}function m(z){return z===45?(e.consume(z),y):a(z)}function g(z){return z===null?a(z):z===45?(e.consume(z),f):st(z)?(s=g,Q(z)):(e.consume(z),g)}function f(z){return z===45?(e.consume(z),y):g(z)}function y(z){return z===62?O(z):z===45?f(z):g(z)}function x(z){const W="CDATA[";return z===W.charCodeAt(o++)?(e.consume(z),o===W.length?k:x):a(z)}function k(z){return z===null?a(z):z===93?(e.consume(z),S):st(z)?(s=k,Q(z)):(e.consume(z),k)}function S(z){return z===93?(e.consume(z),v):k(z)}function v(z){return z===62?O(z):z===93?(e.consume(z),v):k(z)}function _(z){return z===null||z===62?O(z):st(z)?(s=_,Q(z)):(e.consume(z),_)}function w(z){return z===null?a(z):z===63?(e.consume(z),E):st(z)?(s=w,Q(z)):(e.consume(z),w)}function E(z){return z===62?O(z):w(z)}function M(z){return Pn(z)?(e.consume(z),A):a(z)}function A(z){return z===45||bn(z)?(e.consume(z),A):P(z)}function P(z){return st(z)?(s=P,Q(z)):Mt(z)?(e.consume(z),P):O(z)}function R(z){return z===45||bn(z)?(e.consume(z),R):z===47||z===62||aa(z)?$(z):a(z)}function $(z){return z===47?(e.consume(z),O):z===58||z===95||Pn(z)?(e.consume(z),I):st(z)?(s=$,Q(z)):Mt(z)?(e.consume(z),$):O(z)}function I(z){return z===45||z===46||z===58||z===95||bn(z)?(e.consume(z),I):Y(z)}function Y(z){return z===61?(e.consume(z),H):st(z)?(s=Y,Q(z)):Mt(z)?(e.consume(z),Y):$(z)}function H(z){return z===null||z===60||z===61||z===62||z===96?a(z):z===34||z===39?(e.consume(z),i=z,V):st(z)?(s=H,Q(z)):Mt(z)?(e.consume(z),H):(e.consume(z),X)}function V(z){return z===i?(e.consume(z),i=void 0,Z):z===null?a(z):st(z)?(s=V,Q(z)):(e.consume(z),V)}function X(z){return z===null||z===34||z===39||z===60||z===61||z===96?a(z):z===47||z===62||aa(z)?$(z):(e.consume(z),X)}function Z(z){return z===47||z===62||aa(z)?$(z):a(z)}function O(z){return z===62?(e.consume(z),e.exit("htmlTextData"),e.exit("htmlText"),t):a(z)}function Q(z){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(z),e.exit("lineEnding"),D}function D(z){return Mt(z)?Ht(e,J,"linePrefix",n.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(z):J(z)}function J(z){return e.enter("htmlTextData"),s(z)}}const mb={name:"labelEnd",resolveAll:k6,resolveTo:w6,tokenize:S6},v6={tokenize:j6},b6={tokenize:_6},x6={tokenize:C6};function k6(e){let t=-1;const a=[];for(;++t=3&&(p===null||st(p))?(e.exit("thematicBreak"),t(p)):a(p)}function c(p){return p===i?(e.consume(p),n++,c):(e.exit("thematicBreakSequence"),Mt(p)?Ht(e,d,"whitespace")(p):d(p))}}const On={continuation:{tokenize:I6},exit:F6,name:"list",tokenize:D6},R6={partial:!0,tokenize:O6},M6={partial:!0,tokenize:L6};function D6(e,t,a){const n=this,i=n.events[n.events.length-1];let o=i&&i[1].type==="linePrefix"?i[2].sliceSerialize(i[1],!0).length:0,s=0;return d;function d(y){const x=n.containerState.type||(y===42||y===43||y===45?"listUnordered":"listOrdered");if(x==="listUnordered"?!n.containerState.marker||y===n.containerState.marker:cy(y)){if(n.containerState.type||(n.containerState.type=x,e.enter(x,{_container:!0})),x==="listUnordered")return e.enter("listItemPrefix"),y===42||y===45?e.check(Gu,a,p)(y):p(y);if(!n.interrupt||y===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),c(y)}return a(y)}function c(y){return cy(y)&&++s<10?(e.consume(y),c):(!n.interrupt||s<2)&&(n.containerState.marker?y===n.containerState.marker:y===41||y===46)?(e.exit("listItemValue"),p(y)):a(y)}function p(y){return e.enter("listItemMarker"),e.consume(y),e.exit("listItemMarker"),n.containerState.marker=n.containerState.marker||y,e.check(Ec,n.interrupt?a:m,e.attempt(R6,f,g))}function m(y){return n.containerState.initialBlankLine=!0,o++,f(y)}function g(y){return Mt(y)?(e.enter("listItemPrefixWhitespace"),e.consume(y),e.exit("listItemPrefixWhitespace"),f):a(y)}function f(y){return n.containerState.size=o+n.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(y)}}function I6(e,t,a){const n=this;return n.containerState._closeFlow=void 0,e.check(Ec,i,o);function i(d){return n.containerState.furtherBlankLines=n.containerState.furtherBlankLines||n.containerState.initialBlankLine,Ht(e,t,"listItemIndent",n.containerState.size+1)(d)}function o(d){return n.containerState.furtherBlankLines||!Mt(d)?(n.containerState.furtherBlankLines=void 0,n.containerState.initialBlankLine=void 0,s(d)):(n.containerState.furtherBlankLines=void 0,n.containerState.initialBlankLine=void 0,e.attempt(M6,t,s)(d))}function s(d){return n.containerState._closeFlow=!0,n.interrupt=void 0,Ht(e,e.attempt(On,t,a),"linePrefix",n.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(d)}}function L6(e,t,a){const n=this;return Ht(e,i,"listItemIndent",n.containerState.size+1);function i(o){const s=n.events[n.events.length-1];return s&&s[1].type==="listItemIndent"&&s[2].sliceSerialize(s[1],!0).length===n.containerState.size?t(o):a(o)}}function F6(e){e.exit(this.containerState.type)}function O6(e,t,a){const n=this;return Ht(e,i,"listItemPrefixWhitespace",n.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function i(o){const s=n.events[n.events.length-1];return!Mt(o)&&s&&s[1].type==="listItemPrefixWhitespace"?t(o):a(o)}}const z1={name:"setextUnderline",resolveTo:B6,tokenize:H6};function B6(e,t){let a=e.length,n,i,o;for(;a--;)if(e[a][0]==="enter"){if(e[a][1].type==="content"){n=a;break}e[a][1].type==="paragraph"&&(i=a)}else e[a][1].type==="content"&&e.splice(a,1),!o&&e[a][1].type==="definition"&&(o=a);const s={type:"setextHeading",start:{...e[n][1].start},end:{...e[e.length-1][1].end}};return e[i][1].type="setextHeadingText",o?(e.splice(i,0,["enter",s,t]),e.splice(o+1,0,["exit",e[n][1],t]),e[n][1].end={...e[o][1].end}):e[n][1]=s,e.push(["exit",s,t]),e}function H6(e,t,a){const n=this;let i;return o;function o(p){let m=n.events.length,g;for(;m--;)if(n.events[m][1].type!=="lineEnding"&&n.events[m][1].type!=="linePrefix"&&n.events[m][1].type!=="content"){g=n.events[m][1].type==="paragraph";break}return!n.parser.lazy[n.now().line]&&(n.interrupt||g)?(e.enter("setextHeadingLine"),i=p,s(p)):a(p)}function s(p){return e.enter("setextHeadingLineSequence"),d(p)}function d(p){return p===i?(e.consume(p),d):(e.exit("setextHeadingLineSequence"),Mt(p)?Ht(e,c,"lineSuffix")(p):c(p))}function c(p){return p===null||st(p)?(e.exit("setextHeadingLine"),t(p)):a(p)}}const U6={tokenize:W6};function W6(e){const t=this,a=e.attempt(Ec,n,e.attempt(this.parser.constructs.flowInitial,i,Ht(e,e.attempt(this.parser.constructs.flow,i,e.attempt(GF,i)),"linePrefix")));return a;function n(o){if(o===null){e.consume(o);return}return e.enter("lineEndingBlank"),e.consume(o),e.exit("lineEndingBlank"),t.currentConstruct=void 0,a}function i(o){if(o===null){e.consume(o);return}return e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),t.currentConstruct=void 0,a}}const $6={resolveAll:IC()},V6=DC("string"),K6=DC("text");function DC(e){return{resolveAll:IC(e==="text"?q6:void 0),tokenize:t};function t(a){const n=this,i=this.parser.constructs[e],o=a.attempt(i,s,d);return s;function s(m){return p(m)?o(m):d(m)}function d(m){if(m===null){a.consume(m);return}return a.enter("data"),a.consume(m),c}function c(m){return p(m)?(a.exit("data"),o(m)):(a.consume(m),c)}function p(m){if(m===null)return!0;const g=i[m];let f=-1;if(g)for(;++f-1){const d=s[0];typeof d=="string"?s[0]=d.slice(n):s.shift()}o>0&&s.push(e[i].slice(0,o))}return s}function oO(e,t){let a=-1;const n=[];let i;for(;++a0){const dt=Ee.tokenStack[Ee.tokenStack.length-1];(dt[1]||P1).call(Ee,void 0,dt[0])}for(fe.position={start:qi(ne.length>0?ne[0][1].start:{line:1,column:1,offset:0}),end:qi(ne.length>0?ne[ne.length-2][1].end:{line:1,column:1,offset:0})},Ke=-1;++Ke0&&(n.className=["language-"+i[0]]);let o={type:"element",tagName:"code",properties:n,children:[{type:"text",value:a}]};return t.meta&&(o.data={meta:t.meta}),e.patch(t,o),o=e.applyData(t,o),o={type:"element",tagName:"pre",properties:{},children:[o]},e.patch(t,o),o}function xO(e,t){const a={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,a),e.applyData(t,a)}function kO(e,t){const a={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,a),e.applyData(t,a)}function wO(e,t){const a=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",n=String(t.identifier).toUpperCase(),i=Fl(n.toLowerCase()),o=e.footnoteOrder.indexOf(n);let s,d=e.footnoteCounts.get(n);d===void 0?(d=0,e.footnoteOrder.push(n),s=e.footnoteOrder.length):s=o+1,d+=1,e.footnoteCounts.set(n,d);const c={type:"element",tagName:"a",properties:{href:"#"+a+"fn-"+i,id:a+"fnref-"+i+(d>1?"-"+d:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(s)}]};e.patch(t,c);const p={type:"element",tagName:"sup",properties:{},children:[c]};return e.patch(t,p),e.applyData(t,p)}function SO(e,t){const a={type:"element",tagName:"h"+t.depth,properties:{},children:e.all(t)};return e.patch(t,a),e.applyData(t,a)}function jO(e,t){if(e.options.allowDangerousHtml){const a={type:"raw",value:t.value};return e.patch(t,a),e.applyData(t,a)}}function OC(e,t){const a=t.referenceType;let n="]";if(a==="collapsed"?n+="[]":a==="full"&&(n+="["+(t.label||t.identifier)+"]"),t.type==="imageReference")return[{type:"text",value:"!["+t.alt+n}];const i=e.all(t),o=i[0];o&&o.type==="text"?o.value="["+o.value:i.unshift({type:"text",value:"["});const s=i[i.length-1];return s&&s.type==="text"?s.value+=n:i.push({type:"text",value:n}),i}function _O(e,t){const a=String(t.identifier).toUpperCase(),n=e.definitionById.get(a);if(!n)return OC(e,t);const i={src:Fl(n.url||""),alt:t.alt};n.title!==null&&n.title!==void 0&&(i.title=n.title);const o={type:"element",tagName:"img",properties:i,children:[]};return e.patch(t,o),e.applyData(t,o)}function CO(e,t){const a={src:Fl(t.url)};t.alt!==null&&t.alt!==void 0&&(a.alt=t.alt),t.title!==null&&t.title!==void 0&&(a.title=t.title);const n={type:"element",tagName:"img",properties:a,children:[]};return e.patch(t,n),e.applyData(t,n)}function zO(e,t){const a={type:"text",value:t.value.replace(/\r?\n|\r/g," ")};e.patch(t,a);const n={type:"element",tagName:"code",properties:{},children:[a]};return e.patch(t,n),e.applyData(t,n)}function TO(e,t){const a=String(t.identifier).toUpperCase(),n=e.definitionById.get(a);if(!n)return OC(e,t);const i={href:Fl(n.url||"")};n.title!==null&&n.title!==void 0&&(i.title=n.title);const o={type:"element",tagName:"a",properties:i,children:e.all(t)};return e.patch(t,o),e.applyData(t,o)}function PO(e,t){const a={href:Fl(t.url)};t.title!==null&&t.title!==void 0&&(a.title=t.title);const n={type:"element",tagName:"a",properties:a,children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function EO(e,t,a){const n=e.all(t),i=a?AO(a):BC(t),o={},s=[];if(typeof t.checked=="boolean"){const m=n[0];let g;m&&m.type==="element"&&m.tagName==="p"?g=m:(g={type:"element",tagName:"p",properties:{},children:[]},n.unshift(g)),g.children.length>0&&g.children.unshift({type:"text",value:" "}),g.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),o.className=["task-list-item"]}let d=-1;for(;++d1}function NO(e,t){const a={},n=e.all(t);let i=-1;for(typeof t.start=="number"&&t.start!==1&&(a.start=t.start);++i0){const s={type:"element",tagName:"tbody",properties:{},children:e.wrap(a,!0)},d=sb(t.children[1]),c=bC(t.children[t.children.length-1]);d&&c&&(s.position={start:d,end:c}),i.push(s)}const o={type:"element",tagName:"table",properties:{},children:e.wrap(i,!0)};return e.patch(t,o),e.applyData(t,o)}function LO(e,t,a){const n=a?a.children:void 0,o=(n?n.indexOf(t):1)===0?"th":"td",s=a&&a.type==="table"?a.align:void 0,d=s?s.length:t.children.length;let c=-1;const p=[];for(;++c0,!0),n[0]),i=n.index+n[0].length,n=a.exec(t);return o.push(N1(t.slice(i),i>0,!1)),o.join("")}function N1(e,t,a){let n=0,i=e.length;if(t){let o=e.codePointAt(n);for(;o===E1||o===A1;)n++,o=e.codePointAt(n)}if(a){let o=e.codePointAt(i-1);for(;o===E1||o===A1;)i--,o=e.codePointAt(i-1)}return i>n?e.slice(n,i):""}function BO(e,t){const a={type:"text",value:OO(String(t.value))};return e.patch(t,a),e.applyData(t,a)}function HO(e,t){const a={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,a),e.applyData(t,a)}const UO={blockquote:yO,break:vO,code:bO,delete:xO,emphasis:kO,footnoteReference:wO,heading:SO,html:jO,imageReference:_O,image:CO,inlineCode:zO,linkReference:TO,link:PO,listItem:EO,list:NO,paragraph:RO,root:MO,strong:DO,table:IO,tableCell:FO,tableRow:LO,text:BO,thematicBreak:HO,toml:bu,yaml:bu,definition:bu,footnoteDefinition:bu};function bu(){}const HC=-1,Gm=0,Md=1,$p=2,gb=3,hb=4,fb=5,yb=6,UC=7,WC=8,R1=typeof self=="object"?self:globalThis,WO=(e,t)=>{const a=(i,o)=>(e.set(o,i),i),n=i=>{if(e.has(i))return e.get(i);const[o,s]=t[i];switch(o){case Gm:case HC:return a(s,i);case Md:{const d=a([],i);for(const c of s)d.push(n(c));return d}case $p:{const d=a({},i);for(const[c,p]of s)d[n(c)]=n(p);return d}case gb:return a(new Date(s),i);case hb:{const{source:d,flags:c}=s;return a(new RegExp(d,c),i)}case fb:{const d=a(new Map,i);for(const[c,p]of s)d.set(n(c),n(p));return d}case yb:{const d=a(new Set,i);for(const c of s)d.add(n(c));return d}case UC:{const{name:d,message:c}=s;return a(new R1[d](c),i)}case WC:return a(BigInt(s),i);case"BigInt":return a(Object(BigInt(s)),i);case"ArrayBuffer":return a(new Uint8Array(s).buffer,s);case"DataView":{const{buffer:d}=new Uint8Array(s);return a(new DataView(d),s)}}return a(new R1[o](s),i)};return n},M1=e=>WO(new Map,e)(0),As="",{toString:$O}={},{keys:VO}=Object,dd=e=>{const t=typeof e;if(t!=="object"||!e)return[Gm,t];const a=$O.call(e).slice(8,-1);switch(a){case"Array":return[Md,As];case"Object":return[$p,As];case"Date":return[gb,As];case"RegExp":return[hb,As];case"Map":return[fb,As];case"Set":return[yb,As];case"DataView":return[Md,a]}return a.includes("Array")?[Md,a]:a.includes("Error")?[UC,a]:[$p,a]},xu=([e,t])=>e===Gm&&(t==="function"||t==="symbol"),KO=(e,t,a,n)=>{const i=(s,d)=>{const c=n.push(s)-1;return a.set(d,c),c},o=s=>{if(a.has(s))return a.get(s);let[d,c]=dd(s);switch(d){case Gm:{let m=s;switch(c){case"bigint":d=WC,m=s.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+c);m=null;break;case"undefined":return i([HC],s)}return i([d,m],s)}case Md:{if(c){let f=s;return c==="DataView"?f=new Uint8Array(s.buffer):c==="ArrayBuffer"&&(f=new Uint8Array(s)),i([c,[...f]],s)}const m=[],g=i([d,m],s);for(const f of s)m.push(o(f));return g}case $p:{if(c)switch(c){case"BigInt":return i([c,s.toString()],s);case"Boolean":case"Number":case"String":return i([c,s.valueOf()],s)}if(t&&"toJSON"in s)return o(s.toJSON());const m=[],g=i([d,m],s);for(const f of VO(s))(e||!xu(dd(s[f])))&&m.push([o(f),o(s[f])]);return g}case gb:return i([d,s.toISOString()],s);case hb:{const{source:m,flags:g}=s;return i([d,{source:m,flags:g}],s)}case fb:{const m=[],g=i([d,m],s);for(const[f,y]of s)(e||!(xu(dd(f))||xu(dd(y))))&&m.push([o(f),o(y)]);return g}case yb:{const m=[],g=i([d,m],s);for(const f of s)(e||!xu(dd(f)))&&m.push(o(f));return g}}const{message:p}=s;return i([d,{name:c,message:p}],s)};return o},D1=(e,{json:t,lossy:a}={})=>{const n=[];return KO(!(t||a),!!t,new Map,n)(e),n},Vp=typeof structuredClone=="function"?(e,t)=>t&&("json"in t||"lossy"in t)?M1(D1(e,t)):structuredClone(e):(e,t)=>M1(D1(e,t));function qO(e,t){const a=[{type:"text",value:"↩"}];return t>1&&a.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(t)}]}),a}function GO(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}function ZO(e){const t=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",a=e.options.footnoteBackContent||qO,n=e.options.footnoteBackLabel||GO,i=e.options.footnoteLabel||"Footnotes",o=e.options.footnoteLabelTagName||"h2",s=e.options.footnoteLabelProperties||{className:["sr-only"]},d=[];let c=-1;for(;++c0&&x.push({type:"text",value:" "});let _=typeof a=="string"?a:a(c,y);typeof _=="string"&&(_={type:"text",value:_}),x.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+f+(y>1?"-"+y:""),dataFootnoteBackref:"",ariaLabel:typeof n=="string"?n:n(c,y),className:["data-footnote-backref"]},children:Array.isArray(_)?_:[_]})}const S=m[m.length-1];if(S&&S.type==="element"&&S.tagName==="p"){const _=S.children[S.children.length-1];_&&_.type==="text"?_.value+=" ":S.children.push({type:"text",value:" "}),S.children.push(...x)}else m.push(...x);const v={type:"element",tagName:"li",properties:{id:t+"fn-"+f},children:e.wrap(m,!0)};e.patch(p,v),d.push(v)}if(d.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:o,properties:{...Vp(s),id:"footnote-label"},children:[{type:"text",value:i}]},{type:"text",value:`
+`},{type:"element",tagName:"ol",properties:{},children:e.wrap(d,!0)},{type:"text",value:`
+`}]}}const Zm=function(e){if(e==null)return QO;if(typeof e=="function")return Ym(e);if(typeof e=="object")return Array.isArray(e)?YO(e):XO(e);if(typeof e=="string")return JO(e);throw new Error("Expected function, string, or object as test")};function YO(e){const t=[];let a=-1;for(;++a":""))+")"})}return f;function f(){let y=$C,x,k,S;if((!t||o(c,p,m[m.length-1]||void 0))&&(y=nB(a(c,m)),y[0]===py))return y;if("children"in c&&c.children){const v=c;if(v.children&&y[0]!==aB)for(k=(n?v.children.length:-1)+s,S=m.concat(v);k>-1&&k0&&a.push({type:"text",value:`
+`}),a}function I1(e){let t=0,a=e.charCodeAt(t);for(;a===9||a===32;)t++,a=e.charCodeAt(t);return e.slice(t)}function L1(e,t){const a=iB(e,t),n=a.one(e,void 0),i=ZO(a),o=Array.isArray(n)?{type:"root",children:n}:n||{type:"root",children:[]};return i&&o.children.push({type:"text",value:`
+`},i),o}function cB(e,t){return e&&"run"in e?async function(a,n){const i=L1(a,{file:n,...t});await e.run(i,n)}:function(a,n){return L1(a,{file:n,...e||t})}}function F1(e){if(e)throw e}var Zu=Object.prototype.hasOwnProperty,KC=Object.prototype.toString,O1=Object.defineProperty,B1=Object.getOwnPropertyDescriptor,H1=function(t){return typeof Array.isArray=="function"?Array.isArray(t):KC.call(t)==="[object Array]"},U1=function(t){if(!t||KC.call(t)!=="[object Object]")return!1;var a=Zu.call(t,"constructor"),n=t.constructor&&t.constructor.prototype&&Zu.call(t.constructor.prototype,"isPrototypeOf");if(t.constructor&&!a&&!n)return!1;var i;for(i in t);return typeof i>"u"||Zu.call(t,i)},W1=function(t,a){O1&&a.name==="__proto__"?O1(t,a.name,{enumerable:!0,configurable:!0,value:a.newValue,writable:!0}):t[a.name]=a.newValue},$1=function(t,a){if(a==="__proto__")if(Zu.call(t,a)){if(B1)return B1(t,a).value}else return;return t[a]},uB=function e(){var t,a,n,i,o,s,d=arguments[0],c=1,p=arguments.length,m=!1;for(typeof d=="boolean"&&(m=d,d=arguments[1]||{},c=2),(d==null||typeof d!="object"&&typeof d!="function")&&(d={});cs.length;let c;d&&s.push(i);try{c=e.apply(this,s)}catch(p){const m=p;if(d&&a)throw m;return i(m)}d||(c&&c.then&&typeof c.then=="function"?c.then(o,i):c instanceof Error?i(c):o(c))}function i(s,...d){a||(a=!0,t(s,...d))}function o(s){i(null,s)}}const ei={basename:gB,dirname:hB,extname:fB,join:yB,sep:"/"};function gB(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');Ac(e);let a=0,n=-1,i=e.length,o;if(t===void 0||t.length===0||t.length>e.length){for(;i--;)if(e.codePointAt(i)===47){if(o){a=i+1;break}}else n<0&&(o=!0,n=i+1);return n<0?"":e.slice(a,n)}if(t===e)return"";let s=-1,d=t.length-1;for(;i--;)if(e.codePointAt(i)===47){if(o){a=i+1;break}}else s<0&&(o=!0,s=i+1),d>-1&&(e.codePointAt(i)===t.codePointAt(d--)?d<0&&(n=i):(d=-1,n=s));return a===n?n=s:n<0&&(n=e.length),e.slice(a,n)}function hB(e){if(Ac(e),e.length===0)return".";let t=-1,a=e.length,n;for(;--a;)if(e.codePointAt(a)===47){if(n){t=a;break}}else n||(n=!0);return t<0?e.codePointAt(0)===47?"/":".":t===1&&e.codePointAt(0)===47?"//":e.slice(0,t)}function fB(e){Ac(e);let t=e.length,a=-1,n=0,i=-1,o=0,s;for(;t--;){const d=e.codePointAt(t);if(d===47){if(s){n=t+1;break}continue}a<0&&(s=!0,a=t+1),d===46?i<0?i=t:o!==1&&(o=1):i>-1&&(o=-1)}return i<0||a<0||o===0||o===1&&i===a-1&&i===n+1?"":e.slice(i,a)}function yB(...e){let t=-1,a;for(;++t0&&e.codePointAt(e.length-1)===47&&(a+="/"),t?"/"+a:a}function bB(e,t){let a="",n=0,i=-1,o=0,s=-1,d,c;for(;++s<=e.length;){if(s2){if(c=a.lastIndexOf("/"),c!==a.length-1){c<0?(a="",n=0):(a=a.slice(0,c),n=a.length-1-a.lastIndexOf("/")),i=s,o=0;continue}}else if(a.length>0){a="",n=0,i=s,o=0;continue}}t&&(a=a.length>0?a+"/..":"..",n=2)}else a.length>0?a+="/"+e.slice(i+1,s):a=e.slice(i+1,s),n=s-i-1;i=s,o=0}else d===46&&o>-1?o++:o=-1}return a}function Ac(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const xB={cwd:kB};function kB(){return"/"}function hy(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function wB(e){if(typeof e=="string")e=new URL(e);else if(!hy(e)){const t=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code="ERR_INVALID_ARG_TYPE",t}if(e.protocol!=="file:"){const t=new TypeError("The URL must be of scheme file");throw t.code="ERR_INVALID_URL_SCHEME",t}return SB(e)}function SB(e){if(e.hostname!==""){const n=new TypeError('File URL host must be "localhost" or empty on darwin');throw n.code="ERR_INVALID_FILE_URL_HOST",n}const t=e.pathname;let a=-1;for(;++a0){let[y,...x]=m;const k=n[f][1];gy(k)&&gy(y)&&(y=mh(!0,k,y)),n[f]=[p,y,...x]}}}}const zB=new bb().freeze();function yh(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function vh(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function bh(e,t){if(t)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function K1(e){if(!gy(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function q1(e,t,a){if(!a)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function ku(e){return TB(e)?e:new qC(e)}function TB(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function PB(e){return typeof e=="string"||EB(e)}function EB(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const AB="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",G1=[],Z1={allowDangerousHtml:!0},NB=/^(https?|ircs?|mailto|xmpp)$/i,RB=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"className",id:"remove-classname"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function GC(e){const t=MB(e),a=DB(e);return IB(t.runSync(t.parse(a),a),e)}function MB(e){const t=e.rehypePlugins||G1,a=e.remarkPlugins||G1,n=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...Z1}:Z1;return zB().use(fO).use(a).use(cB,n).use(t)}function DB(e){const t=e.children||"",a=new qC;return typeof t=="string"&&(a.value=t),a}function IB(e,t){const a=t.allowedElements,n=t.allowElement,i=t.components,o=t.disallowedElements,s=t.skipHtml,d=t.unwrapDisallowed,c=t.urlTransform||LB;for(const m of RB)Object.hasOwn(t,m.from)&&(""+m.from+(m.to?"use `"+m.to+"` instead":"remove it")+AB+m.id,void 0);return vb(e,p),Q3(e,{Fragment:r.Fragment,components:i,ignoreInvalidStyle:!0,jsx:r.jsx,jsxs:r.jsxs,passKeys:!0,passNode:!0});function p(m,g,f){if(m.type==="raw"&&f&&typeof g=="number")return s?f.children.splice(g,1):f.children[g]={type:"text",value:m.value},g;if(m.type==="element"){let y;for(y in ch)if(Object.hasOwn(ch,y)&&Object.hasOwn(m.properties,y)){const x=m.properties[y],k=ch[y];(k===null||k.includes(m.tagName))&&(m.properties[y]=c(String(x||""),y,m))}}if(m.type==="element"){let y=a?!a.includes(m.tagName):o?o.includes(m.tagName):!1;if(!y&&n&&typeof g=="number"&&(y=!n(m,g,f)),y&&f&&typeof g=="number")return d&&m.children?f.children.splice(g,1,...m.children):f.children.splice(g,1),g}}}function LB(e){const t=e.indexOf(":"),a=e.indexOf("?"),n=e.indexOf("#"),i=e.indexOf("/");return t===-1||i!==-1&&t>i||a!==-1&&t>a||n!==-1&&t>n||NB.test(e.slice(0,t))?e:""}function Y1(e,t){const a=String(e);if(typeof t!="string")throw new TypeError("Expected character");let n=0,i=a.indexOf(t);for(;i!==-1;)n++,i=a.indexOf(t,i+t.length);return n}function FB(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function OB(e,t,a){const i=Zm((a||{}).ignore||[]),o=BB(t);let s=-1;for(;++s0?{type:"text",value:A}:void 0),A===!1?f.lastIndex=E+1:(x!==E&&_.push({type:"text",value:p.value.slice(x,E)}),Array.isArray(A)?_.push(...A):A&&_.push(A),x=E+w[0].length,v=!0),!f.global)break;w=f.exec(p.value)}return v?(x?\]}]+$/.exec(e);if(!t)return[e,void 0];e=e.slice(0,t.index);let a=t[0],n=a.indexOf(")");const i=Y1(e,"(");let o=Y1(e,")");for(;n!==-1&&i>o;)e+=a.slice(0,n+1),a=a.slice(n+1),n=a.indexOf(")"),o++;return[e,a]}function ZC(e,t){const a=e.input.charCodeAt(e.index-1);return(e.index===0||ms(a)||Km(a))&&(!t||a!==47)}YC.peek=d8;function t8(){this.buffer()}function a8(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function n8(){this.buffer()}function r8(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function i8(e){const t=this.resume(),a=this.stack[this.stack.length-1];a.type,a.identifier=Lr(this.sliceSerialize(e)).toLowerCase(),a.label=t}function o8(e){this.exit(e)}function s8(e){const t=this.resume(),a=this.stack[this.stack.length-1];a.type,a.identifier=Lr(this.sliceSerialize(e)).toLowerCase(),a.label=t}function l8(e){this.exit(e)}function d8(){return"["}function YC(e,t,a,n){const i=a.createTracker(n);let o=i.move("[^");const s=a.enter("footnoteReference"),d=a.enter("reference");return o+=i.move(a.safe(a.associationId(e),{after:"]",before:o})),d(),s(),o+=i.move("]"),o}function c8(){return{enter:{gfmFootnoteCallString:t8,gfmFootnoteCall:a8,gfmFootnoteDefinitionLabelString:n8,gfmFootnoteDefinition:r8},exit:{gfmFootnoteCallString:i8,gfmFootnoteCall:o8,gfmFootnoteDefinitionLabelString:s8,gfmFootnoteDefinition:l8}}}function u8(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:a,footnoteReference:YC},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]};function a(n,i,o,s){const d=o.createTracker(s);let c=d.move("[^");const p=o.enter("footnoteDefinition"),m=o.enter("label");return c+=d.move(o.safe(o.associationId(n),{before:c,after:"]"})),m(),c+=d.move("]:"),n.children&&n.children.length>0&&(d.shift(4),c+=d.move((t?`
+`:" ")+o.indentLines(o.containerFlow(n,d.current()),t?XC:p8))),p(),c}}function p8(e,t,a){return t===0?e:XC(e,t,a)}function XC(e,t,a){return(a?"":" ")+e}const m8=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];JC.peek=v8;function g8(){return{canContainEols:["delete"],enter:{strikethrough:f8},exit:{strikethrough:y8}}}function h8(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:m8}],handlers:{delete:JC}}}function f8(e){this.enter({type:"delete",children:[]},e)}function y8(e){this.exit(e)}function JC(e,t,a,n){const i=a.createTracker(n),o=a.enter("strikethrough");let s=i.move("~~");return s+=a.containerPhrasing(e,{...i.current(),before:s,after:"~"}),s+=i.move("~~"),o(),s}function v8(){return"~"}function b8(e){return e.length}function x8(e,t){const a=t||{},n=(a.align||[]).concat(),i=a.stringLength||b8,o=[],s=[],d=[],c=[];let p=0,m=-1;for(;++mp&&(p=e[m].length);++vc[v])&&(c[v]=w)}k.push(_)}s[m]=k,d[m]=S}let g=-1;if(typeof n=="object"&&"length"in n)for(;++gc[g]&&(c[g]=_),y[g]=_),f[g]=w}s.splice(1,0,f),d.splice(1,0,y),m=-1;const x=[];for(;++m "),o.shift(2);const s=a.indentLines(a.containerFlow(e,o.current()),S8);return i(),s}function S8(e,t,a){return">"+(a?"":" ")+e}function j8(e,t){return J1(e,t.inConstruct,!0)&&!J1(e,t.notInConstruct,!1)}function J1(e,t,a){if(typeof t=="string"&&(t=[t]),!t||t.length===0)return a;let n=-1;for(;++ns&&(s=o):o=1,i=n+t.length,n=a.indexOf(t,i);return s}function C8(e,t){return!!(t.options.fences===!1&&e.value&&!e.lang&&/[^ \r\n]/.test(e.value)&&!/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(e.value))}function z8(e){const t=e.options.fence||"`";if(t!=="`"&&t!=="~")throw new Error("Cannot serialize code with `"+t+"` for `options.fence`, expected `` ` `` or `~`");return t}function T8(e,t,a,n){const i=z8(a),o=e.value||"",s=i==="`"?"GraveAccent":"Tilde";if(C8(e,a)){const g=a.enter("codeIndented"),f=a.indentLines(o,P8);return g(),f}const d=a.createTracker(n),c=i.repeat(Math.max(_8(o,i)+1,3)),p=a.enter("codeFenced");let m=d.move(c);if(e.lang){const g=a.enter(`codeFencedLang${s}`);m+=d.move(a.safe(e.lang,{before:m,after:" ",encode:["`"],...d.current()})),g()}if(e.lang&&e.meta){const g=a.enter(`codeFencedMeta${s}`);m+=d.move(" "),m+=d.move(a.safe(e.meta,{before:m,after:`
+`,encode:["`"],...d.current()})),g()}return m+=d.move(`
+`),o&&(m+=d.move(o+`
+`)),m+=d.move(c),p(),m}function P8(e,t,a){return(a?"":" ")+e}function xb(e){const t=e.options.quote||'"';if(t!=='"'&&t!=="'")throw new Error("Cannot serialize title with `"+t+"` for `options.quote`, expected `\"`, or `'`");return t}function E8(e,t,a,n){const i=xb(a),o=i==='"'?"Quote":"Apostrophe",s=a.enter("definition");let d=a.enter("label");const c=a.createTracker(n);let p=c.move("[");return p+=c.move(a.safe(a.associationId(e),{before:p,after:"]",...c.current()})),p+=c.move("]: "),d(),!e.url||/[\0- \u007F]/.test(e.url)?(d=a.enter("destinationLiteral"),p+=c.move("<"),p+=c.move(a.safe(e.url,{before:p,after:">",...c.current()})),p+=c.move(">")):(d=a.enter("destinationRaw"),p+=c.move(a.safe(e.url,{before:p,after:e.title?" ":`
+`,...c.current()}))),d(),e.title&&(d=a.enter(`title${o}`),p+=c.move(" "+i),p+=c.move(a.safe(e.title,{before:p,after:i,...c.current()})),p+=c.move(i),d()),s(),p}function A8(e){const t=e.options.emphasis||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize emphasis with `"+t+"` for `options.emphasis`, expected `*`, or `_`");return t}function lc(e){return""+e.toString(16).toUpperCase()+";"}function Kp(e,t,a){const n=_l(e),i=_l(t);return n===void 0?i===void 0?a==="_"?{inside:!0,outside:!0}:{inside:!1,outside:!1}:i===1?{inside:!0,outside:!0}:{inside:!1,outside:!0}:n===1?i===void 0?{inside:!1,outside:!1}:i===1?{inside:!0,outside:!0}:{inside:!1,outside:!1}:i===void 0?{inside:!1,outside:!1}:i===1?{inside:!0,outside:!1}:{inside:!1,outside:!1}}QC.peek=N8;function QC(e,t,a,n){const i=A8(a),o=a.enter("emphasis"),s=a.createTracker(n),d=s.move(i);let c=s.move(a.containerPhrasing(e,{after:i,before:d,...s.current()}));const p=c.charCodeAt(0),m=Kp(n.before.charCodeAt(n.before.length-1),p,i);m.inside&&(c=lc(p)+c.slice(1));const g=c.charCodeAt(c.length-1),f=Kp(n.after.charCodeAt(0),g,i);f.inside&&(c=c.slice(0,-1)+lc(g));const y=s.move(i);return o(),a.attentionEncodeSurroundingInfo={after:f.outside,before:m.outside},d+c+y}function N8(e,t,a){return a.options.emphasis||"*"}function R8(e,t){let a=!1;return vb(e,function(n){if("value"in n&&/\r?\n|\r/.test(n.value)||n.type==="break")return a=!0,py}),!!((!e.depth||e.depth<3)&&ub(e)&&(t.options.setext||a))}function M8(e,t,a,n){const i=Math.max(Math.min(6,e.depth||1),1),o=a.createTracker(n);if(R8(e,a)){const m=a.enter("headingSetext"),g=a.enter("phrasing"),f=a.containerPhrasing(e,{...o.current(),before:`
+`,after:`
+`});return g(),m(),f+`
+`+(i===1?"=":"-").repeat(f.length-(Math.max(f.lastIndexOf("\r"),f.lastIndexOf(`
+`))+1))}const s="#".repeat(i),d=a.enter("headingAtx"),c=a.enter("phrasing");o.move(s+" ");let p=a.containerPhrasing(e,{before:"# ",after:`
+`,...o.current()});return/^[\t ]/.test(p)&&(p=lc(p.charCodeAt(0))+p.slice(1)),p=p?s+" "+p:s,a.options.closeAtx&&(p+=" "+s),c(),d(),p}ez.peek=D8;function ez(e){return e.value||""}function D8(){return"<"}tz.peek=I8;function tz(e,t,a,n){const i=xb(a),o=i==='"'?"Quote":"Apostrophe",s=a.enter("image");let d=a.enter("label");const c=a.createTracker(n);let p=c.move("![");return p+=c.move(a.safe(e.alt,{before:p,after:"]",...c.current()})),p+=c.move("]("),d(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(d=a.enter("destinationLiteral"),p+=c.move("<"),p+=c.move(a.safe(e.url,{before:p,after:">",...c.current()})),p+=c.move(">")):(d=a.enter("destinationRaw"),p+=c.move(a.safe(e.url,{before:p,after:e.title?" ":")",...c.current()}))),d(),e.title&&(d=a.enter(`title${o}`),p+=c.move(" "+i),p+=c.move(a.safe(e.title,{before:p,after:i,...c.current()})),p+=c.move(i),d()),p+=c.move(")"),s(),p}function I8(){return"!"}az.peek=L8;function az(e,t,a,n){const i=e.referenceType,o=a.enter("imageReference");let s=a.enter("label");const d=a.createTracker(n);let c=d.move("![");const p=a.safe(e.alt,{before:c,after:"]",...d.current()});c+=d.move(p+"]["),s();const m=a.stack;a.stack=[],s=a.enter("reference");const g=a.safe(a.associationId(e),{before:c,after:"]",...d.current()});return s(),a.stack=m,o(),i==="full"||!p||p!==g?c+=d.move(g+"]"):i==="shortcut"?c=c.slice(0,-1):c+=d.move("]"),c}function L8(){return"!"}nz.peek=F8;function nz(e,t,a){let n=e.value||"",i="`",o=-1;for(;new RegExp("(^|[^`])"+i+"([^`]|$)").test(n);)i+="`";for(/[^ \r\n]/.test(n)&&(/^[ \r\n]/.test(n)&&/[ \r\n]$/.test(n)||/^`|`$/.test(n))&&(n=" "+n+" ");++o\u007F]/.test(e.url))}iz.peek=O8;function iz(e,t,a,n){const i=xb(a),o=i==='"'?"Quote":"Apostrophe",s=a.createTracker(n);let d,c;if(rz(e,a)){const m=a.stack;a.stack=[],d=a.enter("autolink");let g=s.move("<");return g+=s.move(a.containerPhrasing(e,{before:g,after:">",...s.current()})),g+=s.move(">"),d(),a.stack=m,g}d=a.enter("link"),c=a.enter("label");let p=s.move("[");return p+=s.move(a.containerPhrasing(e,{before:p,after:"](",...s.current()})),p+=s.move("]("),c(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(c=a.enter("destinationLiteral"),p+=s.move("<"),p+=s.move(a.safe(e.url,{before:p,after:">",...s.current()})),p+=s.move(">")):(c=a.enter("destinationRaw"),p+=s.move(a.safe(e.url,{before:p,after:e.title?" ":")",...s.current()}))),c(),e.title&&(c=a.enter(`title${o}`),p+=s.move(" "+i),p+=s.move(a.safe(e.title,{before:p,after:i,...s.current()})),p+=s.move(i),c()),p+=s.move(")"),d(),p}function O8(e,t,a){return rz(e,a)?"<":"["}oz.peek=B8;function oz(e,t,a,n){const i=e.referenceType,o=a.enter("linkReference");let s=a.enter("label");const d=a.createTracker(n);let c=d.move("[");const p=a.containerPhrasing(e,{before:c,after:"]",...d.current()});c+=d.move(p+"]["),s();const m=a.stack;a.stack=[],s=a.enter("reference");const g=a.safe(a.associationId(e),{before:c,after:"]",...d.current()});return s(),a.stack=m,o(),i==="full"||!p||p!==g?c+=d.move(g+"]"):i==="shortcut"?c=c.slice(0,-1):c+=d.move("]"),c}function B8(){return"["}function kb(e){const t=e.options.bullet||"*";if(t!=="*"&&t!=="+"&&t!=="-")throw new Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function H8(e){const t=kb(e),a=e.options.bulletOther;if(!a)return t==="*"?"-":"*";if(a!=="*"&&a!=="+"&&a!=="-")throw new Error("Cannot serialize items with `"+a+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(a===t)throw new Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+a+"`) to be different");return a}function U8(e){const t=e.options.bulletOrdered||".";if(t!=="."&&t!==")")throw new Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function sz(e){const t=e.options.rule||"*";if(t!=="*"&&t!=="-"&&t!=="_")throw new Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}function W8(e,t,a,n){const i=a.enter("list"),o=a.bulletCurrent;let s=e.ordered?U8(a):kb(a);const d=e.ordered?s==="."?")":".":H8(a);let c=t&&a.bulletLastUsed?s===a.bulletLastUsed:!1;if(!e.ordered){const m=e.children?e.children[0]:void 0;if((s==="*"||s==="-")&&m&&(!m.children||!m.children[0])&&a.stack[a.stack.length-1]==="list"&&a.stack[a.stack.length-2]==="listItem"&&a.stack[a.stack.length-3]==="list"&&a.stack[a.stack.length-4]==="listItem"&&a.indexStack[a.indexStack.length-1]===0&&a.indexStack[a.indexStack.length-2]===0&&a.indexStack[a.indexStack.length-3]===0&&(c=!0),sz(a)===s&&m){let g=-1;for(;++g-1?t.start:1)+(a.options.incrementListMarker===!1?0:t.children.indexOf(e))+o);let s=o.length+1;(i==="tab"||i==="mixed"&&(t&&t.type==="list"&&t.spread||e.spread))&&(s=Math.ceil(s/4)*4);const d=a.createTracker(n);d.move(o+" ".repeat(s-o.length)),d.shift(s);const c=a.enter("listItem"),p=a.indentLines(a.containerFlow(e,d.current()),m);return c(),p;function m(g,f,y){return f?(y?"":" ".repeat(s))+g:(y?o:o+" ".repeat(s-o.length))+g}}function K8(e,t,a,n){const i=a.enter("paragraph"),o=a.enter("phrasing"),s=a.containerPhrasing(e,n);return o(),i(),s}const q8=Zm(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function G8(e,t,a,n){return(e.children.some(function(s){return q8(s)})?a.containerPhrasing:a.containerFlow).call(a,e,n)}function Z8(e){const t=e.options.strong||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}lz.peek=Y8;function lz(e,t,a,n){const i=Z8(a),o=a.enter("strong"),s=a.createTracker(n),d=s.move(i+i);let c=s.move(a.containerPhrasing(e,{after:i,before:d,...s.current()}));const p=c.charCodeAt(0),m=Kp(n.before.charCodeAt(n.before.length-1),p,i);m.inside&&(c=lc(p)+c.slice(1));const g=c.charCodeAt(c.length-1),f=Kp(n.after.charCodeAt(0),g,i);f.inside&&(c=c.slice(0,-1)+lc(g));const y=s.move(i+i);return o(),a.attentionEncodeSurroundingInfo={after:f.outside,before:m.outside},d+c+y}function Y8(e,t,a){return a.options.strong||"*"}function X8(e,t,a,n){return a.safe(e.value,n)}function J8(e){const t=e.options.ruleRepetition||3;if(t<3)throw new Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}function Q8(e,t,a){const n=(sz(a)+(a.options.ruleSpaces?" ":"")).repeat(J8(a));return a.options.ruleSpaces?n.slice(0,-1):n}const dz={blockquote:w8,break:Q1,code:T8,definition:E8,emphasis:QC,hardBreak:Q1,heading:M8,html:ez,image:tz,imageReference:az,inlineCode:nz,link:iz,linkReference:oz,list:W8,listItem:V8,paragraph:K8,root:G8,strong:lz,text:X8,thematicBreak:Q8};function eH(){return{enter:{table:tH,tableData:ew,tableHeader:ew,tableRow:nH},exit:{codeText:rH,table:aH,tableData:Sh,tableHeader:Sh,tableRow:Sh}}}function tH(e){const t=e._align;this.enter({type:"table",align:t.map(function(a){return a==="none"?null:a}),children:[]},e),this.data.inTable=!0}function aH(e){this.exit(e),this.data.inTable=void 0}function nH(e){this.enter({type:"tableRow",children:[]},e)}function Sh(e){this.exit(e)}function ew(e){this.enter({type:"tableCell",children:[]},e)}function rH(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,iH));const a=this.stack[this.stack.length-1];a.type,a.value=t,this.exit(e)}function iH(e,t){return t==="|"?t:e}function oH(e){const t=e||{},a=t.tableCellPadding,n=t.tablePipeAlign,i=t.stringLength,o=a?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:`
+`,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:f,table:s,tableCell:c,tableRow:d}};function s(y,x,k,S){return p(m(y,k,S),y.align)}function d(y,x,k,S){const v=g(y,k,S),_=p([v]);return _.slice(0,_.indexOf(`
+`))}function c(y,x,k,S){const v=k.enter("tableCell"),_=k.enter("phrasing"),w=k.containerPhrasing(y,{...S,before:o,after:o});return _(),v(),w}function p(y,x){return x8(y,{align:x,alignDelimiters:n,padding:a,stringLength:i})}function m(y,x,k){const S=y.children;let v=-1;const _=[],w=x.enter("table");for(;++v0&&!a&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),a}const jH={tokenize:NH,partial:!0};function _H(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:PH,continuation:{tokenize:EH},exit:AH}},text:{91:{name:"gfmFootnoteCall",tokenize:TH},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:CH,resolveTo:zH}}}}function CH(e,t,a){const n=this;let i=n.events.length;const o=n.parser.gfmFootnotes||(n.parser.gfmFootnotes=[]);let s;for(;i--;){const c=n.events[i][1];if(c.type==="labelImage"){s=c;break}if(c.type==="gfmFootnoteCall"||c.type==="labelLink"||c.type==="label"||c.type==="image"||c.type==="link")break}return d;function d(c){if(!s||!s._balanced)return a(c);const p=Lr(n.sliceSerialize({start:s.end,end:n.now()}));return p.codePointAt(0)!==94||!o.includes(p.slice(1))?a(c):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(c),e.exit("gfmFootnoteCallLabelMarker"),t(c))}}function zH(e,t){let a=e.length;for(;a--;)if(e[a][1].type==="labelImage"&&e[a][0]==="enter"){e[a][1];break}e[a+1][1].type="data",e[a+3][1].type="gfmFootnoteCallLabelMarker";const n={type:"gfmFootnoteCall",start:Object.assign({},e[a+3][1].start),end:Object.assign({},e[e.length-1][1].end)},i={type:"gfmFootnoteCallMarker",start:Object.assign({},e[a+3][1].end),end:Object.assign({},e[a+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;const o={type:"gfmFootnoteCallString",start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},s={type:"chunkString",contentType:"string",start:Object.assign({},o.start),end:Object.assign({},o.end)},d=[e[a+1],e[a+2],["enter",n,t],e[a+3],e[a+4],["enter",i,t],["exit",i,t],["enter",o,t],["enter",s,t],["exit",s,t],["exit",o,t],e[e.length-2],e[e.length-1],["exit",n,t]];return e.splice(a,e.length-a+1,...d),e}function TH(e,t,a){const n=this,i=n.parser.gfmFootnotes||(n.parser.gfmFootnotes=[]);let o=0,s;return d;function d(g){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(g),e.exit("gfmFootnoteCallLabelMarker"),c}function c(g){return g!==94?a(g):(e.enter("gfmFootnoteCallMarker"),e.consume(g),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",p)}function p(g){if(o>999||g===93&&!s||g===null||g===91||aa(g))return a(g);if(g===93){e.exit("chunkString");const f=e.exit("gfmFootnoteCallString");return i.includes(Lr(n.sliceSerialize(f)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(g),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):a(g)}return aa(g)||(s=!0),o++,e.consume(g),g===92?m:p}function m(g){return g===91||g===92||g===93?(e.consume(g),o++,p):p(g)}}function PH(e,t,a){const n=this,i=n.parser.gfmFootnotes||(n.parser.gfmFootnotes=[]);let o,s=0,d;return c;function c(x){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(x),e.exit("gfmFootnoteDefinitionLabelMarker"),p}function p(x){return x===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(x),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",m):a(x)}function m(x){if(s>999||x===93&&!d||x===null||x===91||aa(x))return a(x);if(x===93){e.exit("chunkString");const k=e.exit("gfmFootnoteDefinitionLabelString");return o=Lr(n.sliceSerialize(k)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(x),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),f}return aa(x)||(d=!0),s++,e.consume(x),x===92?g:m}function g(x){return x===91||x===92||x===93?(e.consume(x),s++,m):m(x)}function f(x){return x===58?(e.enter("definitionMarker"),e.consume(x),e.exit("definitionMarker"),i.includes(o)||i.push(o),Ht(e,y,"gfmFootnoteDefinitionWhitespace")):a(x)}function y(x){return t(x)}}function EH(e,t,a){return e.check(Ec,t,e.attempt(jH,t,a))}function AH(e){e.exit("gfmFootnoteDefinition")}function NH(e,t,a){const n=this;return Ht(e,i,"gfmFootnoteDefinitionIndent",5);function i(o){const s=n.events[n.events.length-1];return s&&s[1].type==="gfmFootnoteDefinitionIndent"&&s[2].sliceSerialize(s[1],!0).length===4?t(o):a(o)}}function RH(e){let a=(e||{}).singleTilde;const n={name:"strikethrough",tokenize:o,resolveAll:i};return a==null&&(a=!0),{text:{126:n},insideSpan:{null:[n]},attentionMarkers:{null:[126]}};function i(s,d){let c=-1;for(;++c1?c(x):(s.consume(x),g++,y);if(g<2&&!a)return c(x);const S=s.exit("strikethroughSequenceTemporary"),v=_l(x);return S._open=!v||v===2&&!!k,S._close=!k||k===2&&!!v,d(x)}}}class MH{constructor(){this.map=[]}add(t,a,n){DH(this,t,a,n)}consume(t){if(this.map.sort(function(o,s){return o[0]-s[0]}),this.map.length===0)return;let a=this.map.length;const n=[];for(;a>0;)a-=1,n.push(t.slice(this.map[a][0]+this.map[a][1]),this.map[a][2]),t.length=this.map[a][0];n.push(t.slice()),t.length=0;let i=n.pop();for(;i;){for(const o of i)t.push(o);i=n.pop()}this.map.length=0}}function DH(e,t,a,n){let i=0;if(!(a===0&&n.length===0)){for(;i-1;){const X=n.events[Y][1].type;if(X==="lineEnding"||X==="linePrefix")Y--;else break}const H=Y>-1?n.events[Y][1].type:null,V=H==="tableHead"||H==="tableRow"?A:c;return V===A&&n.parser.lazy[n.now().line]?a(I):V(I)}function c(I){return e.enter("tableHead"),e.enter("tableRow"),p(I)}function p(I){return I===124||(s=!0,o+=1),m(I)}function m(I){return I===null?a(I):st(I)?o>1?(o=0,n.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(I),e.exit("lineEnding"),y):a(I):Mt(I)?Ht(e,m,"whitespace")(I):(o+=1,s&&(s=!1,i+=1),I===124?(e.enter("tableCellDivider"),e.consume(I),e.exit("tableCellDivider"),s=!0,m):(e.enter("data"),g(I)))}function g(I){return I===null||I===124||aa(I)?(e.exit("data"),m(I)):(e.consume(I),I===92?f:g)}function f(I){return I===92||I===124?(e.consume(I),g):g(I)}function y(I){return n.interrupt=!1,n.parser.lazy[n.now().line]?a(I):(e.enter("tableDelimiterRow"),s=!1,Mt(I)?Ht(e,x,"linePrefix",n.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(I):x(I))}function x(I){return I===45||I===58?S(I):I===124?(s=!0,e.enter("tableCellDivider"),e.consume(I),e.exit("tableCellDivider"),k):M(I)}function k(I){return Mt(I)?Ht(e,S,"whitespace")(I):S(I)}function S(I){return I===58?(o+=1,s=!0,e.enter("tableDelimiterMarker"),e.consume(I),e.exit("tableDelimiterMarker"),v):I===45?(o+=1,v(I)):I===null||st(I)?E(I):M(I)}function v(I){return I===45?(e.enter("tableDelimiterFiller"),_(I)):M(I)}function _(I){return I===45?(e.consume(I),_):I===58?(s=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(I),e.exit("tableDelimiterMarker"),w):(e.exit("tableDelimiterFiller"),w(I))}function w(I){return Mt(I)?Ht(e,E,"whitespace")(I):E(I)}function E(I){return I===124?x(I):I===null||st(I)?!s||i!==o?M(I):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(I)):M(I)}function M(I){return a(I)}function A(I){return e.enter("tableRow"),P(I)}function P(I){return I===124?(e.enter("tableCellDivider"),e.consume(I),e.exit("tableCellDivider"),P):I===null||st(I)?(e.exit("tableRow"),t(I)):Mt(I)?Ht(e,P,"whitespace")(I):(e.enter("data"),R(I))}function R(I){return I===null||I===124||aa(I)?(e.exit("data"),P(I)):(e.consume(I),I===92?$:R)}function $(I){return I===92||I===124?(e.consume(I),R):R(I)}}function OH(e,t){let a=-1,n=!0,i=0,o=[0,0,0,0],s=[0,0,0,0],d=!1,c=0,p,m,g;const f=new MH;for(;++aa[2]+1){const x=a[2]+1,k=a[3]-a[2]-1;e.add(x,k,[])}}e.add(a[3]+1,0,[["exit",g,t]])}return i!==void 0&&(o.end=Object.assign({},Ds(t.events,i)),e.add(i,0,[["exit",o,t]]),o=void 0),o}function aw(e,t,a,n,i){const o=[],s=Ds(t.events,a);i&&(i.end=Object.assign({},s),o.push(["exit",i,t])),n.end=Object.assign({},s),o.push(["exit",n,t]),e.add(a+1,0,o)}function Ds(e,t){const a=e[t],n=a[0]==="enter"?"start":"end";return a[1][n]}const BH={name:"tasklistCheck",tokenize:UH};function HH(){return{text:{91:BH}}}function UH(e,t,a){const n=this;return i;function i(c){return n.previous!==null||!n._gfmTasklistFirstContentOfListItem?a(c):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(c),e.exit("taskListCheckMarker"),o)}function o(c){return aa(c)?(e.enter("taskListCheckValueUnchecked"),e.consume(c),e.exit("taskListCheckValueUnchecked"),s):c===88||c===120?(e.enter("taskListCheckValueChecked"),e.consume(c),e.exit("taskListCheckValueChecked"),s):a(c)}function s(c){return c===93?(e.enter("taskListCheckMarker"),e.consume(c),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),d):a(c)}function d(c){return st(c)?t(c):Mt(c)?e.check({tokenize:WH},t,a)(c):a(c)}}function WH(e,t,a){return Ht(e,n,"whitespace");function n(i){return i===null?a(i):t(i)}}function $H(e){return CC([hH(),_H(),RH(e),LH(),HH()])}const VH={};function vz(e){const t=this,a=e||VH,n=t.data(),i=n.micromarkExtensions||(n.micromarkExtensions=[]),o=n.fromMarkdownExtensions||(n.fromMarkdownExtensions=[]),s=n.toMarkdownExtensions||(n.toMarkdownExtensions=[]);i.push($H(a)),o.push(uH()),s.push(pH(a))}const xa="-apple-system, BlinkMacSystemFont, 'SF Pro Text', system-ui, sans-serif",Su={};function KH({url:e,tripId:t,color:a}){const[n,i]=b.useState(Su[e]||null),[o,s]=b.useState(!1);b.useEffect(()=>{if(Su[e]){i(Su[e]);return}Ta.linkPreview(t,e).then(c=>{Su[e]=c,i(c)}).catch(()=>s(!0))},[e,t]);const d=(()=>{try{return new URL(e).hostname.replace("www.","")}catch{return"link"}})();return r.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",title:(n==null?void 0:n.title)||e,style:{width:48,height:48,borderRadius:8,cursor:"pointer",overflow:"hidden",background:n!=null&&n.image?"none":"var(--bg-tertiary)",border:"none",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:2,textDecoration:"none",transition:"transform 0.12s, box-shadow 0.12s",flexShrink:0},onMouseEnter:c=>{c.currentTarget.style.transform="scale(1.08)",c.currentTarget.style.boxShadow="0 2px 8px rgba(0,0,0,0.15)"},onMouseLeave:c=>{c.currentTarget.style.transform="scale(1)",c.currentTarget.style.boxShadow="none"},children:n!=null&&n.image&&!o?r.jsx("img",{src:n.image,alt:"",style:{width:"100%",height:"100%",objectFit:"cover"},onError:()=>s(!0)}):r.jsxs(r.Fragment,{children:[r.jsx(xn,{size:14,color:"var(--text-muted)"}),r.jsx("span",{style:{fontSize:7,fontWeight:600,color:"var(--text-muted)",maxWidth:42,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",textAlign:"center"},children:d})]})})}function qH({file:e,onClose:t}){var s,d;if(!e)return null;const a=e.url||`/uploads/${e.filename}`,n=(s=e.mime_type)==null?void 0:s.startsWith("image/"),i=e.mime_type==="application/pdf",o=(d=e.mime_type)==null?void 0:d.startsWith("text/");return Vt.createPortal(r.jsx("div",{style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.88)",zIndex:1e4,display:"flex",alignItems:"center",justifyContent:"center",padding:16},onClick:t,children:n?r.jsxs("div",{style:{position:"relative",maxWidth:"90vw",maxHeight:"90vh"},onClick:c=>c.stopPropagation(),children:[r.jsx("img",{src:a,alt:e.original_name,style:{maxWidth:"90vw",maxHeight:"90vh",objectFit:"contain",borderRadius:8,display:"block"}}),r.jsxs("div",{style:{position:"absolute",top:-36,left:0,right:0,display:"flex",alignItems:"center",justifyContent:"space-between",padding:"0 4px"},children:[r.jsx("span",{style:{fontSize:11,color:"rgba(255,255,255,0.7)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:"70%"},children:e.original_name}),r.jsxs("div",{style:{display:"flex",gap:8},children:[r.jsx("a",{href:a,target:"_blank",rel:"noreferrer",style:{color:"rgba(255,255,255,0.7)",display:"flex"},children:r.jsx(xn,{size:15})}),r.jsx("button",{onClick:t,style:{background:"none",border:"none",cursor:"pointer",color:"rgba(255,255,255,0.7)",display:"flex",padding:0},children:r.jsx(gt,{size:17})})]})]})]}):r.jsxs("div",{style:{width:"100%",maxWidth:950,height:"94vh",display:"flex",flexDirection:"column",background:"var(--bg-card)",borderRadius:12,overflow:"hidden",boxShadow:"0 20px 60px rgba(0,0,0,0.3)"},onClick:c=>c.stopPropagation(),children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"10px 16px",borderBottom:"1px solid var(--border-primary)",flexShrink:0},children:[r.jsx("span",{style:{fontSize:13,fontWeight:600,color:"var(--text-primary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:1},children:e.original_name}),r.jsxs("div",{style:{display:"flex",gap:8,flexShrink:0},children:[r.jsx("a",{href:a,target:"_blank",rel:"noreferrer",style:{display:"flex",alignItems:"center",gap:3,fontSize:11,color:"var(--text-muted)",textDecoration:"none"},children:r.jsx(xn,{size:13})}),r.jsx("button",{onClick:t,style:{background:"none",border:"none",cursor:"pointer",color:"var(--text-faint)",display:"flex",padding:2},children:r.jsx(gt,{size:18})})]})]}),i||o?r.jsx("object",{data:`${a}#view=FitH`,type:e.mime_type,style:{flex:1,width:"100%",border:"none",background:"#fff"},title:e.original_name,children:r.jsx("p",{style:{padding:24,textAlign:"center",color:"var(--text-muted)"},children:r.jsx("a",{href:a,target:"_blank",rel:"noopener noreferrer",style:{color:"var(--text-primary)",textDecoration:"underline"},children:"Download"})})}):r.jsx("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",padding:40},children:r.jsxs("a",{href:a,target:"_blank",rel:"noopener noreferrer",style:{color:"var(--text-primary)",textDecoration:"underline",fontSize:14},children:["Download ",e.original_name]})})]})}),document.body)}const to=[{value:"#6366f1",label:"Indigo"},{value:"#ef4444",label:"Red"},{value:"#f59e0b",label:"Amber"},{value:"#10b981",label:"Emerald"},{value:"#3b82f6",label:"Blue"},{value:"#8b5cf6",label:"Violet"}];function GH({user:e,size:t=14}){if(!e)return null;if(e.avatar)return r.jsx("img",{src:e.avatar,alt:e.username,style:{width:t,height:t,borderRadius:"50%",objectFit:"cover",flexShrink:0,background:"var(--bg-tertiary)"}});const a=(e.username||"?").slice(0,1);return r.jsx("div",{style:{width:t,height:t,borderRadius:"50%",background:"var(--bg-tertiary)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:t*.45,fontWeight:600,color:"var(--text-faint)",flexShrink:0,textTransform:"uppercase",fontFamily:xa},children:a})}function nw({onClose:e,onSubmit:t,onDeleteFile:a,existingCategories:n,categoryColors:i,getCategoryColor:o,note:s,tripId:d,t:c}){const p=!!s,m=[...new Set([...n,...Object.keys(i||{})])].filter(Boolean),[g,f]=b.useState((s==null?void 0:s.title)||""),[y,x]=b.useState((s==null?void 0:s.content)||""),[k,S]=b.useState((s==null?void 0:s.category)||m[0]||""),[v,_]=b.useState((s==null?void 0:s.website)||""),[w,E]=b.useState([]),[M,A]=b.useState((s==null?void 0:s.attachments)||[]),[P,R]=b.useState(!1),$=b.useRef(null),I=k,Y=async X=>{if(X.preventDefault(),!!g.trim()){R(!0);try{await t({title:g.trim(),content:y.trim(),category:I||null,color:o(I),website:v.trim()||null,_pendingFiles:w}),e()}catch{}finally{R(!1)}}},H=async X=>{a&&s&&(await a(s.id,X),A(Z=>Z.filter(O=>O.id!==X)))},V=g.trim()&&!P;return Vt.createPortal(r.jsx("div",{style:{position:"fixed",inset:0,background:"var(--overlay-bg, rgba(0,0,0,0.35))",backdropFilter:"blur(6px)",WebkitBackdropFilter:"blur(6px)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:9999,padding:16,fontFamily:xa},onClick:e,children:r.jsxs("form",{style:{background:"var(--bg-card)",borderRadius:16,width:"100%",maxWidth:400,maxHeight:"90vh",overflow:"auto",border:"1px solid var(--border-faint)"},onClick:X=>X.stopPropagation(),onPaste:X=>{var O;const Z=(O=X.clipboardData)==null?void 0:O.items;if(Z){for(const Q of Array.from(Z))if(Q.type.startsWith("image/")||Q.type==="application/pdf"){X.preventDefault();const D=Q.getAsFile();D&&E(J=>[...J,D]);return}}},onSubmit:Y,children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"14px 16px 12px",borderBottom:"1px solid var(--border-faint)"},children:[r.jsx("h3",{style:{fontSize:14,fontWeight:700,color:"var(--text-primary)",margin:0,fontFamily:xa},children:c(p?"collab.notes.edit":"collab.notes.new")}),r.jsx("button",{type:"button",onClick:e,style:{background:"none",border:"none",cursor:"pointer",color:"var(--text-faint)",padding:2,borderRadius:6,display:"flex"},children:r.jsx(gt,{size:16})})]}),r.jsxs("div",{style:{padding:"14px 16px 16px",display:"flex",flexDirection:"column",gap:12},children:[r.jsxs("div",{children:[r.jsx("div",{style:{fontSize:9,fontWeight:600,color:"var(--text-faint)",textTransform:"uppercase",letterSpacing:"0.05em",marginBottom:4,fontFamily:xa},children:c("collab.notes.title")}),r.jsx("input",{autoFocus:!0,value:g,onChange:X=>f(X.target.value),placeholder:c("collab.notes.titlePlaceholder"),style:{width:"100%",border:"1px solid var(--border-primary)",borderRadius:10,padding:"8px 12px",fontSize:13,background:"var(--bg-input)",color:"var(--text-primary)",fontFamily:"inherit",outline:"none",boxSizing:"border-box"}})]}),r.jsxs("div",{children:[r.jsx("div",{style:{fontSize:9,fontWeight:600,color:"var(--text-faint)",textTransform:"uppercase",letterSpacing:"0.05em",marginBottom:4,fontFamily:xa},children:c("collab.notes.contentPlaceholder")}),r.jsx("textarea",{value:y,onChange:X=>x(X.target.value),placeholder:c("collab.notes.contentPlaceholder"),style:{width:"100%",border:"1px solid var(--border-primary)",borderRadius:10,padding:"8px 12px",fontSize:13,background:"var(--bg-input)",color:"var(--text-primary)",fontFamily:"inherit",outline:"none",boxSizing:"border-box",resize:"vertical",minHeight:180,lineHeight:1.5}})]}),r.jsxs("div",{children:[r.jsx("div",{style:{fontSize:9,fontWeight:600,color:"var(--text-faint)",textTransform:"uppercase",letterSpacing:"0.05em",marginBottom:6,fontFamily:xa},children:c("collab.notes.category")}),r.jsx("div",{style:{display:"flex",gap:6,flexWrap:"wrap"},children:m.map(X=>{const Z=o(X),O=k===X;return r.jsx("button",{type:"button",onClick:()=>S(X),style:{padding:"4px 12px",borderRadius:99,border:O?`1.5px solid ${Z}`:"1px solid var(--border-faint)",background:O?`${Z}18`:"transparent",color:O?Z:"var(--text-muted)",fontSize:11,fontWeight:600,cursor:"pointer",fontFamily:xa},children:X},X)})})]}),r.jsxs("div",{children:[r.jsx("div",{style:{fontSize:9,fontWeight:600,color:"var(--text-faint)",textTransform:"uppercase",letterSpacing:"0.05em",marginBottom:4,fontFamily:xa},children:c("collab.notes.website")}),r.jsx("input",{value:v,onChange:X=>_(X.target.value),placeholder:c("collab.notes.websitePlaceholder"),style:{width:"100%",border:"1px solid var(--border-primary)",borderRadius:10,padding:"8px 12px",fontSize:13,background:"var(--bg-input)",color:"var(--text-primary)",fontFamily:"inherit",outline:"none",boxSizing:"border-box"}})]}),r.jsxs("div",{children:[r.jsx("div",{style:{fontSize:9,fontWeight:600,color:"var(--text-faint)",textTransform:"uppercase",letterSpacing:"0.05em",marginBottom:4,fontFamily:xa},children:c("collab.notes.attachFiles")}),r.jsx("input",{id:"note-file-input",ref:$,type:"file",multiple:!0,style:{display:"none"},onChange:X=>{E(Z=>[...Z,...Array.from(X.target.files)]),X.target.value=""}}),r.jsxs("div",{style:{display:"flex",gap:6,flexWrap:"wrap",alignItems:"center"},children:[M.map(X=>{var O;const Z=(O=X.mime_type)==null?void 0:O.startsWith("image/");return r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4,padding:"3px 8px",borderRadius:8,background:"var(--bg-secondary)",fontSize:11,color:"var(--text-muted)"},children:[Z&&r.jsx("img",{src:X.url,style:{width:18,height:18,objectFit:"cover",borderRadius:3}}),(X.original_name||"").length>20?X.original_name.slice(0,17)+"...":X.original_name,r.jsx("button",{type:"button",onClick:()=>H(X.id),style:{background:"none",border:"none",cursor:"pointer",color:"#ef4444",padding:0,display:"flex"},children:r.jsx(gt,{size:10})})]},X.id)}),w.map((X,Z)=>r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4,padding:"3px 8px",borderRadius:8,background:"var(--bg-secondary)",fontSize:11,color:"var(--text-muted)"},children:[X.name.length>20?X.name.slice(0,17)+"...":X.name,r.jsx("button",{type:"button",onClick:()=>E(O=>O.filter((Q,D)=>D!==Z)),style:{background:"none",border:"none",cursor:"pointer",color:"var(--text-faint)",padding:0,display:"flex"},children:r.jsx(gt,{size:10})})]},`new-${Z}`)),r.jsxs("label",{htmlFor:"note-file-input",style:{padding:"4px 10px",borderRadius:8,border:"1px dashed var(--border-faint)",background:"transparent",cursor:"pointer",color:"var(--text-faint)",fontSize:11,fontFamily:xa,display:"inline-flex",alignItems:"center",gap:4},children:[r.jsx(Ft,{size:11})," ",c("files.attach")||"Add"]})]})]}),r.jsx("button",{type:"submit",disabled:!V,style:{width:"100%",borderRadius:99,padding:"7px 14px",background:V?"var(--accent)":"var(--border-primary)",color:V?"var(--accent-text)":"var(--text-faint)",fontSize:12,fontWeight:600,fontFamily:xa,border:"none",cursor:V?"pointer":"default",marginTop:4},children:P?"...":c(p?"collab.notes.save":"collab.notes.create")})]})]})}),document.body)}function ZH({name:e,onRename:t}){const[a,n]=b.useState(!1),[i,o]=b.useState(e),s=b.useRef(null);b.useEffect(()=>{a&&s.current&&(s.current.focus(),s.current.select())},[a]);const d=()=>{n(!1),i.trim()&&i.trim()!==e?t(i.trim()):o(e)};return a?r.jsx("input",{ref:s,value:i,onChange:c=>o(c.target.value),onBlur:d,onKeyDown:c=>{c.key==="Enter"&&d(),c.key==="Escape"&&(o(e),n(!1))},style:{flex:1,fontSize:13,fontWeight:600,color:"var(--text-primary)",border:"1px solid var(--border-primary)",borderRadius:6,padding:"2px 8px",background:"var(--bg-input)",fontFamily:"inherit",outline:"none"}}):r.jsx("span",{onClick:()=>{o(e),n(!0)},style:{flex:1,fontSize:13,fontWeight:600,color:"var(--text-primary)",cursor:"pointer",padding:"2px 0"},title:"Click to rename",children:e})}function YH({onClose:e,categories:t,categoryColors:a,onSave:n,onRenameCategory:i,t:o}){const[s,d]=b.useState({...a}),[c,p]=b.useState({}),[m,g]=b.useState(""),f=(_,w)=>{d(E=>({...E,[_]:w}))},y=()=>{!m.trim()||s[m.trim()]||(d(_=>({..._,[m.trim()]:to[Object.keys(_).length%to.length].value})),g(""))},x=_=>{d(w=>{const E={...w};return delete E[_],E})},k=(_,w)=>{var M;if(!w.trim()||w.trim()===_||s[w.trim()])return;const E=((M=Object.entries(c).find(([,A])=>A===_))==null?void 0:M[0])||_;p(A=>({...A,[E]:w.trim()})),d(A=>{const P={};for(const[R,$]of Object.entries(A))P[R===_?w.trim():R]=$;return P})},S=async()=>{for(const[_,w]of Object.entries(c))_!==w&&await i(_,w);await n(s),e()},v=[...new Set([...t,...Object.keys(s)])];return Vt.createPortal(r.jsx("div",{style:{position:"fixed",inset:0,background:"var(--overlay-bg, rgba(0,0,0,0.35))",backdropFilter:"blur(6px)",WebkitBackdropFilter:"blur(6px)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:9999,padding:16,fontFamily:xa},onClick:e,children:r.jsxs("div",{style:{background:"var(--bg-card)",borderRadius:16,width:"100%",maxWidth:420,maxHeight:"80vh",overflow:"auto",border:"1px solid var(--border-faint)"},onClick:_=>_.stopPropagation(),children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"14px 16px 12px",borderBottom:"1px solid var(--border-faint)"},children:[r.jsx("h3",{style:{fontSize:14,fontWeight:700,color:"var(--text-primary)",margin:0},children:o("collab.notes.categorySettings")||"Category Settings"}),r.jsx("button",{onClick:e,style:{background:"none",border:"none",cursor:"pointer",color:"var(--text-faint)",padding:2,display:"flex"},children:r.jsx(gt,{size:16})})]}),r.jsxs("div",{style:{padding:"12px 16px",display:"flex",flexDirection:"column",gap:10},children:[v.length===0&&r.jsx("p",{style:{fontSize:12,color:"var(--text-faint)",textAlign:"center",padding:16},children:o("collab.notes.noCategoriesYet")||"No categories yet"}),v.map(_=>r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[r.jsx("div",{style:{display:"flex",gap:4},children:to.map(w=>r.jsx("button",{onClick:()=>f(_,w.value),style:{width:20,height:20,borderRadius:6,background:w.value,border:"none",cursor:"pointer",padding:0,outline:(s[_]||to[0].value)===w.value?"2px solid var(--text-primary)":"2px solid transparent",outlineOffset:1,transition:"transform 0.1s",transform:(s[_]||to[0].value)===w.value?"scale(1.1)":"scale(1)"}},w.value))}),r.jsx(ZH,{name:_,onRename:w=>k(_,w)}),r.jsx("button",{onClick:()=>x(_),style:{background:"none",border:"none",cursor:"pointer",color:"var(--text-faint)",padding:3,display:"flex"},onMouseEnter:w=>w.currentTarget.style.color="#ef4444",onMouseLeave:w=>w.currentTarget.style.color="var(--text-faint)",children:r.jsx(_t,{size:13})})]},_)),r.jsxs("div",{style:{display:"flex",gap:6,marginTop:4},children:[r.jsx("input",{value:m,onChange:_=>g(_.target.value),onKeyDown:_=>_.key==="Enter"&&y(),placeholder:o("collab.notes.newCategory"),style:{flex:1,border:"1px solid var(--border-primary)",borderRadius:10,padding:"8px 12px",fontSize:13,background:"var(--bg-input)",color:"var(--text-primary)",fontFamily:"inherit",outline:"none"}}),r.jsx("button",{onClick:y,disabled:!m.trim(),style:{background:m.trim()?"var(--accent)":"var(--border-primary)",color:"var(--accent-text)",border:"none",borderRadius:10,padding:"8px 14px",cursor:m.trim()?"pointer":"default",display:"flex",alignItems:"center",flexShrink:0},children:r.jsx(Ft,{size:14})})]}),r.jsx("button",{onClick:S,style:{width:"100%",borderRadius:99,padding:"9px 14px",background:"var(--accent)",color:"var(--accent-text)",fontSize:13,fontWeight:600,border:"none",cursor:"pointer",marginTop:8},children:o("collab.notes.save")})]})]})}),document.body)}function XH({note:e,currentUser:t,onUpdate:a,onDelete:n,onEdit:i,onView:o,onPreviewFile:s,getCategoryColor:d,tripId:c,t:p}){var S,v,_;const[m,g]=b.useState(!1),f=e.author||e.user||{username:e.username,avatar:e.avatar_url||(e.avatar?`/uploads/avatars/${e.avatar}`:null)},y=d?d(e.category):e.color||"#6366f1",x=b.useCallback(()=>{a(e.id,{pinned:!e.pinned})},[e.id,e.pinned,a]),k=b.useCallback(()=>{n(e.id)},[e.id,n]);return r.jsxs("div",{onMouseEnter:()=>g(!0),onMouseLeave:()=>g(!1),style:{position:"relative",borderRadius:12,overflow:"hidden",border:`1px solid ${e.pinned?y+"40":y+"25"}`,background:e.pinned?`${y}08`:"var(--bg-card)",display:"flex",flexDirection:"column",fontFamily:xa,transition:"transform 0.12s, box-shadow 0.12s",...m?{transform:"translateY(-1px)",boxShadow:"0 4px 16px rgba(0,0,0,0.08)"}:{}},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,padding:"7px 10px",background:`${y}0d`},children:[!!e.pinned&&r.jsx(f0,{size:9,color:y,style:{flexShrink:0}}),r.jsxs("span",{style:{display:"flex",alignItems:"center",gap:5,overflow:"hidden",flex:1,minWidth:0},children:[r.jsx("span",{style:{fontSize:11,fontWeight:700,color:"var(--text-primary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.title}),e.category&&r.jsx("span",{style:{fontSize:8,fontWeight:600,color:y,background:`${y}18`,padding:"2px 6px",borderRadius:99,flexShrink:0,letterSpacing:"0.02em",textTransform:"uppercase"},children:e.category})]}),r.jsxs("div",{style:{display:"flex",gap:2},children:[e.content&&r.jsx("button",{onClick:()=>o==null?void 0:o(e),title:p("collab.notes.expand")||"Expand",style:{padding:3,background:"none",border:"none",cursor:"pointer",color:"var(--text-faint)",display:"flex"},onMouseEnter:w=>w.currentTarget.style.color="var(--text-primary)",onMouseLeave:w=>w.currentTarget.style.color="var(--text-faint)",children:r.jsx(ZM,{size:10})}),r.jsx("button",{onClick:x,title:e.pinned?p("collab.notes.unpin"):p("collab.notes.pin"),style:{padding:3,background:"none",border:"none",cursor:"pointer",color:"var(--text-faint)",display:"flex"},onMouseEnter:w=>w.currentTarget.style.color=y,onMouseLeave:w=>w.currentTarget.style.color="var(--text-faint)",children:e.pinned?r.jsx(oD,{size:10}):r.jsx(f0,{size:10})}),r.jsx("button",{onClick:()=>i==null?void 0:i(e),title:p("collab.notes.edit"),style:{padding:3,background:"none",border:"none",cursor:"pointer",color:"var(--text-faint)",display:"flex"},onMouseEnter:w=>w.currentTarget.style.color="var(--text-primary)",onMouseLeave:w=>w.currentTarget.style.color="var(--text-faint)",children:r.jsx(sn,{size:10})}),r.jsx("button",{onClick:k,title:p("collab.notes.delete"),style:{padding:3,background:"none",border:"none",cursor:"pointer",color:"var(--text-faint)",display:"flex"},onMouseEnter:w=>w.currentTarget.style.color="#ef4444",onMouseLeave:w=>w.currentTarget.style.color="var(--text-faint)",children:r.jsx(_t,{size:10})}),r.jsx("div",{style:{width:1,height:12,background:"var(--border-faint)",flexShrink:0,marginLeft:1,marginRight:1}}),r.jsxs("div",{style:{position:"relative",flexShrink:0},onMouseEnter:w=>{const E=w.currentTarget.querySelector("[data-tip]");E&&(E.style.opacity="1")},onMouseLeave:w=>{const E=w.currentTarget.querySelector("[data-tip]");E&&(E.style.opacity="0")},children:[r.jsx(GH,{user:f,size:16}),r.jsx("div",{"data-tip":!0,style:{position:"absolute",bottom:"100%",left:"50%",transform:"translateX(-50%)",marginBottom:6,pointerEvents:"none",opacity:0,transition:"opacity 0.12s",whiteSpace:"nowrap",zIndex:10,background:"var(--bg-card)",color:"var(--text-primary)",fontSize:11,fontWeight:500,padding:"5px 10px",borderRadius:8,boxShadow:"0 4px 12px rgba(0,0,0,0.15)",border:"1px solid var(--border-faint)"},children:f.username})]})]})]}),r.jsx("div",{style:{padding:"8px 12px 10px",display:"flex",flexDirection:"column",gap:4,flex:1},children:r.jsxs("div",{style:{display:"flex",gap:8},children:[r.jsx("div",{style:{flex:1,minWidth:0},children:e.content&&r.jsx("div",{className:"collab-note-md",style:{fontSize:11.5,color:"var(--text-muted)",lineHeight:1.5,margin:0,maxHeight:"4.5em",overflow:"hidden",wordBreak:"break-word",fontFamily:xa},children:r.jsx(GC,{remarkPlugins:[vz],children:e.content})})}),(e.website||((S=e.attachments)==null?void 0:S.length)>0)&&r.jsxs("div",{style:{display:"flex",gap:6,flexShrink:0,alignItems:"flex-start"},children:[e.website&&r.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:2},children:[r.jsx("span",{style:{fontSize:7,fontWeight:600,color:"var(--text-faint)",textTransform:"uppercase",letterSpacing:.3},children:"Link"}),r.jsx(KH,{url:e.website,tripId:c,color:y})]}),(e.attachments||[]).length>0&&r.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:2},children:[r.jsx("span",{style:{fontSize:7,fontWeight:600,color:"var(--text-faint)",textTransform:"uppercase",letterSpacing:.3},children:p("files.title")}),r.jsxs("div",{style:{display:"flex",gap:4},children:[(e.attachments||[]).slice(0,e.website?1:2).map(w=>{var A,P;const E=(A=w.mime_type)==null?void 0:A.startsWith("image/"),M=((P=(w.original_name||"").split(".").pop())==null?void 0:P.toUpperCase())||"?";return E?r.jsx("img",{src:w.url,alt:w.original_name,style:{width:48,height:48,objectFit:"cover",borderRadius:8,cursor:"pointer",transition:"transform 0.12s, box-shadow 0.12s"},onClick:()=>s==null?void 0:s(w),onMouseEnter:R=>{R.currentTarget.style.transform="scale(1.08)",R.currentTarget.style.boxShadow="0 2px 8px rgba(0,0,0,0.15)"},onMouseLeave:R=>{R.currentTarget.style.transform="scale(1)",R.currentTarget.style.boxShadow="none"}},w.id):r.jsx("div",{title:w.original_name,onClick:()=>s==null?void 0:s(w),style:{width:48,height:48,borderRadius:8,cursor:"pointer",background:w.mime_type==="application/pdf"?"#ef44441a":"var(--bg-secondary)",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:1,transition:"transform 0.12s, box-shadow 0.12s"},onMouseEnter:R=>{R.currentTarget.style.transform="scale(1.08)",R.currentTarget.style.boxShadow="0 2px 8px rgba(0,0,0,0.15)"},onMouseLeave:R=>{R.currentTarget.style.transform="scale(1)",R.currentTarget.style.boxShadow="none"},children:r.jsx("span",{style:{fontSize:9,fontWeight:700,color:w.mime_type==="application/pdf"?"#ef4444":"var(--text-muted)",letterSpacing:.3},children:M})},w.id)}),(((v=e.attachments)==null?void 0:v.length)||0)>(e.website?1:2)&&r.jsxs("span",{style:{fontSize:8,color:"var(--text-faint)",textAlign:"center"},children:["+",(((_=e.attachments)==null?void 0:_.length)||0)-(e.website?1:2)]})]})]})]})]})})]})}function rw({tripId:e,currentUser:t}){const{t:a}=ot(),[n,i]=b.useState([]),[o,s]=b.useState(!0),[d,c]=b.useState(!1),[p,m]=b.useState(null),[g,f]=b.useState(null),[y,x]=b.useState(null),[k,S]=b.useState(!1),[v,_]=b.useState(null),[w,E]=b.useState(()=>{try{return JSON.parse(localStorage.getItem(`collab-cats-${e}`))||{}}catch{return{}}}),M=O=>{E(O),localStorage.setItem(`collab-cats-${e}`,JSON.stringify(O))},A=b.useMemo(()=>{const O={...w};for(const Q of n)Q.category&&Q.color&&(O[Q.category]=Q.color);return O},[n,w]),P=O=>O?A[O]?A[O]:to[Object.keys(A).length%to.length].value:to[0].value;b.useEffect(()=>{if(!e)return;let O=!1;return s(!0),Ta.getNotes(e).then(Q=>{O||i((Q==null?void 0:Q.notes)||Q||[])}).catch(()=>{O||i([])}).finally(()=>{O||s(!1)}),()=>{O=!0}},[e]),b.useEffect(()=>{if(!e)return;const O=Q=>{if(Q.type==="collab:note:created"&&Q.note&&i(D=>D.some(J=>J.id===Q.note.id)?D:[Q.note,...D]),Q.type==="collab:note:updated"&&Q.note&&i(D=>D.map(J=>J.id===Q.note.id?{...J,...Q.note}:J)),Q.type==="collab:note:deleted"){const D=Q.noteId||Q.id;D&&i(J=>J.filter(z=>z.id!==D))}};return xl(O),()=>kl(O)},[e]);const R=b.useCallback(async O=>{const Q=O._pendingFiles||[];delete O._pendingFiles;const D=await Ta.createNote(e,O);if(D){const J=D.note||D;if(Q.length>0&&J.id){for(const W of Q){const B=new FormData;B.append("file",W);try{await Ta.uploadNoteFile(e,J.id,B)}catch{}}const z=await Ta.getNotes(e);z!=null&&z.notes&&i(z.notes),window.dispatchEvent(new Event("collab-files-changed"));return}i(z=>z.some(W=>W.id===J.id)?z:[J,...z])}},[e]),$=b.useCallback(async(O,Q)=>{const D=await Ta.updateNote(e,O,Q),J=(D==null?void 0:D.note)||D;J&&i(z=>z.map(W=>W.id===O?{...W,...J}:W))},[e]),I=b.useCallback(async O=>{for(const[D,J]of Object.entries(O)){const z=n.filter(W=>W.category===D);if(z.length>0&&A[D]!==J)for(const W of z)await $(W.id,{color:J})}const Q={};for(const[D,J]of Object.entries(O))n.some(z=>z.category===D)||(Q[D]=J);M(Q)},[A,n,$]),Y=b.useCallback(async O=>{if(!p)return;const Q=O._pendingFiles||[];if(delete O._pendingFiles,await $(p.id,O),Q.length>0){for(const J of Q){const z=new FormData;z.append("file",J);try{await Ta.uploadNoteFile(e,p.id,z)}catch{}}const D=await Ta.getNotes(e);D!=null&&D.notes&&i(D.notes),window.dispatchEvent(new Event("collab-files-changed"))}},[p,e,$]),H=b.useCallback(async(O,Q)=>{try{await Ta.deleteNoteFile(e,O,Q)}catch{}window.dispatchEvent(new Event("collab-files-changed"))},[e]),V=b.useCallback(async O=>{await Ta.deleteNote(e,O),i(Q=>Q.filter(D=>D.id!==O)),window.dispatchEvent(new Event("collab-files-changed"))},[e]),X=[...new Set(n.map(O=>O.category).filter(Boolean))],Z=[...n].filter(O=>v===null||O.category===v).sort((O,Q)=>{if(O.pinned&&!Q.pinned)return-1;if(!O.pinned&&Q.pinned)return 1;const D=new Date(O.updated_at||O.created_at||0).getTime();return new Date(Q.updated_at||Q.created_at||0).getTime()-D});return o?r.jsxs("div",{style:{height:"100%",display:"flex",flexDirection:"column",fontFamily:xa},children:[r.jsx("div",{style:{padding:"12px 16px",borderBottom:"1px solid var(--border-faint)"},children:r.jsx("h3",{style:{fontSize:14,fontWeight:700,color:"var(--text-primary)",margin:0,fontFamily:xa},children:a("collab.notes.title")})}),r.jsxs("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center"},children:[r.jsx("div",{style:{width:20,height:20,border:"2px solid var(--border-primary)",borderTopColor:"var(--text-primary)",borderRadius:"50%",animation:"collab-notes-spin 0.7s linear infinite"}}),r.jsx("style",{children:"@keyframes collab-notes-spin { to { transform: rotate(360deg) } }"})]})]}):r.jsxs("div",{style:{height:"100%",display:"flex",flexDirection:"column",fontFamily:xa},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"10px 16px",flexShrink:0},children:[r.jsxs("h3",{style:{fontSize:12,fontWeight:600,color:"var(--text-muted)",margin:0,fontFamily:xa,letterSpacing:.3,textTransform:"uppercase",display:"flex",alignItems:"center",gap:7},children:[r.jsx(Ov,{size:14,color:"var(--text-faint)"}),a("collab.notes.title")]}),r.jsxs("div",{style:{display:"flex",gap:4,alignItems:"center"},children:[r.jsx("button",{onClick:()=>S(!0),title:a("collab.notes.categorySettings")||"Categories",style:{display:"flex",alignItems:"center",justifyContent:"center",width:28,height:28,borderRadius:8,border:"none",background:"transparent",cursor:"pointer",color:"var(--text-faint)",transition:"color 0.12s"},onMouseEnter:O=>O.currentTarget.style.color="var(--text-primary)",onMouseLeave:O=>O.currentTarget.style.color="var(--text-faint)",children:r.jsx(Bm,{size:14})}),r.jsxs("button",{onClick:()=>c(!0),style:{display:"inline-flex",alignItems:"center",gap:4,borderRadius:99,padding:"6px 12px",background:"var(--accent)",color:"var(--accent-text)",fontSize:11,fontWeight:600,fontFamily:xa,border:"none",cursor:"pointer",whiteSpace:"nowrap"},children:[r.jsx(Ft,{size:12}),a("collab.notes.new")]})]})]}),X.length>0&&r.jsxs("div",{style:{display:"flex",gap:4,padding:"8px 12px 0",overflowX:"auto",flexShrink:0},children:[r.jsx("button",{onClick:()=>_(null),style:{flexShrink:0,borderRadius:99,padding:"3px 10px",fontSize:10,fontWeight:600,fontFamily:xa,border:v===null?"1px solid var(--accent)":"1px solid var(--border-faint)",background:v===null?"var(--accent)":"transparent",color:v===null?"var(--accent-text)":"var(--text-secondary)",cursor:"pointer",whiteSpace:"nowrap",textTransform:"uppercase",letterSpacing:"0.03em"},children:a("collab.notes.all")}),X.map(O=>r.jsx("button",{onClick:()=>_(Q=>Q===O?null:O),style:{flexShrink:0,borderRadius:99,padding:"3px 10px",fontSize:10,fontWeight:600,fontFamily:xa,border:v===O?"1px solid var(--accent)":"1px solid var(--border-faint)",background:v===O?"var(--accent)":"transparent",color:v===O?"var(--accent-text)":"var(--text-secondary)",cursor:"pointer",whiteSpace:"nowrap",textTransform:"uppercase",letterSpacing:"0.03em"},children:O},O))]}),r.jsx("div",{style:{flex:1,overflowY:"auto",padding:12},children:Z.length===0?r.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"48px 20px",textAlign:"center",height:"100%"},children:[r.jsx(sn,{size:36,color:"var(--text-faint)",style:{marginBottom:12}}),r.jsx("div",{style:{fontSize:14,fontWeight:600,color:"var(--text-secondary)",marginBottom:4,fontFamily:xa},children:a("collab.notes.empty")}),r.jsx("div",{style:{fontSize:12,color:"var(--text-faint)",fontFamily:xa},children:a("collab.notes.emptyDesc")||"Create a note to get started"})]}):r.jsx("div",{style:{display:"grid",gridTemplateColumns:window.innerWidth<768?"1fr":"repeat(2, 1fr)",gap:8},children:Z.map(O=>r.jsx(XH,{note:O,currentUser:t,onUpdate:$,onDelete:V,onEdit:m,onView:f,onPreviewFile:x,getCategoryColor:P,tripId:e,t:a},O.id))})}),g&&Vt.createPortal(r.jsx("div",{style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.5)",backdropFilter:"blur(6px)",WebkitBackdropFilter:"blur(6px)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e4,padding:16},onClick:()=>f(null),children:r.jsxs("div",{style:{background:"var(--bg-card)",borderRadius:16,boxShadow:"0 20px 60px rgba(0,0,0,0.2)",width:"min(700px, calc(100vw - 32px))",maxHeight:"80vh",overflow:"hidden",display:"flex",flexDirection:"column"},onClick:O=>O.stopPropagation(),children:[r.jsxs("div",{style:{padding:"16px 20px 12px",borderBottom:"1px solid var(--border-primary)",display:"flex",alignItems:"center",justifyContent:"space-between",gap:12},children:[r.jsxs("div",{style:{flex:1,minWidth:0},children:[r.jsx("div",{style:{fontSize:17,fontWeight:600,color:"var(--text-primary)"},children:g.title}),g.category&&r.jsx("span",{style:{display:"inline-block",marginTop:4,fontSize:10,fontWeight:600,color:P(g.category),background:`${P(g.category)}18`,padding:"2px 8px",borderRadius:6},children:g.category})]}),r.jsxs("div",{style:{display:"flex",gap:4,flexShrink:0},children:[r.jsx("button",{onClick:()=>{f(null),m(g)},style:{padding:6,background:"none",border:"none",cursor:"pointer",color:"var(--text-faint)",display:"flex",borderRadius:6},onMouseEnter:O=>O.currentTarget.style.color="var(--text-primary)",onMouseLeave:O=>O.currentTarget.style.color="var(--text-faint)",children:r.jsx(sn,{size:16})}),r.jsx("button",{onClick:()=>f(null),style:{padding:6,background:"none",border:"none",cursor:"pointer",color:"var(--text-faint)",display:"flex",borderRadius:6},onMouseEnter:O=>O.currentTarget.style.color="var(--text-primary)",onMouseLeave:O=>O.currentTarget.style.color="var(--text-faint)",children:r.jsx(gt,{size:18})})]})]}),r.jsx("div",{className:"collab-note-md-full",style:{padding:"16px 20px",overflowY:"auto",fontSize:14,color:"var(--text-primary)",lineHeight:1.7},children:r.jsx(GC,{remarkPlugins:[vz],children:g.content||""})})]})}),document.body),d&&r.jsx(nw,{onClose:()=>c(!1),onSubmit:R,existingCategories:X,categoryColors:A,getCategoryColor:P,t:a}),p&&r.jsx(nw,{note:p,tripId:e,onClose:()=>m(null),onSubmit:Y,onDeleteFile:H,existingCategories:X,categoryColors:A,getCategoryColor:P,t:a}),r.jsx(qH,{file:y,onClose:()=>x(null)}),k&&r.jsx(YH,{onClose:()=>S(!1),categories:X,categoryColors:A,onSave:I,onRenameCategory:async(O,Q)=>{const D=n.filter(J=>J.category===O);for(const J of D)await $(J.id,{category:Q})},t:a})]})}const Si="-apple-system, BlinkMacSystemFont, 'SF Pro Text', system-ui, sans-serif";function JH(e){if(!e)return null;const t=new Date(e).getTime()-Date.now();if(t<=0)return null;const a=Math.floor(t/6e4),n=Math.floor(a/60),i=Math.floor(n/24);return i>0?`${i}d ${n%24}h`:n>0?`${n}h ${a%60}m`:`${a}m`}function yy(e){return e?new Date(e).getTime()<=Date.now():!1}function QH(e){return(e.options||[]).reduce((t,a)=>{var n;return t+(((n=a.voters)==null?void 0:n.length)||0)},0)}function e7({onClose:e,onCreate:t,t:a}){const[n,i]=b.useState(""),[o,s]=b.useState(["",""]),[d,c]=b.useState(!1),[p,m]=b.useState(!1),g=()=>s(S=>[...S,""]),f=S=>s(v=>v.filter((_,w)=>w!==S)),y=(S,v)=>s(_=>_.map((w,E)=>E===S?v:w)),x=n.trim()&&o.filter(S=>S.trim()).length>=2&&!p,k=async S=>{if(S.preventDefault(),!!x){m(!0);try{await t({question:n.trim(),options:o.filter(v=>v.trim()),multiple_choice:d}),e()}catch{}finally{m(!1)}}};return Vt.createPortal(r.jsx("div",{style:{position:"fixed",inset:0,background:"var(--overlay-bg, rgba(0,0,0,0.35))",backdropFilter:"blur(6px)",WebkitBackdropFilter:"blur(6px)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:9999,padding:16,fontFamily:Si},onClick:e,children:r.jsxs("form",{style:{background:"var(--bg-card)",borderRadius:16,width:"100%",maxWidth:400,maxHeight:"90vh",overflow:"auto",border:"1px solid var(--border-faint)"},onClick:S=>S.stopPropagation(),onSubmit:k,children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"14px 16px 12px",borderBottom:"1px solid var(--border-faint)"},children:[r.jsx("h3",{style:{fontSize:14,fontWeight:700,color:"var(--text-primary)",margin:0},children:a("collab.polls.new")}),r.jsx("button",{type:"button",onClick:e,style:{background:"none",border:"none",cursor:"pointer",color:"var(--text-faint)",padding:2,display:"flex"},children:r.jsx(gt,{size:16})})]}),r.jsxs("div",{style:{padding:"14px 16px 16px",display:"flex",flexDirection:"column",gap:12},children:[r.jsxs("div",{children:[r.jsx("div",{style:{fontSize:9,fontWeight:600,color:"var(--text-faint)",textTransform:"uppercase",letterSpacing:"0.05em",marginBottom:4},children:a("collab.polls.question")}),r.jsx("input",{autoFocus:!0,value:n,onChange:S=>i(S.target.value),placeholder:a("collab.polls.questionPlaceholder")||"Ask a question...",style:{width:"100%",border:"1px solid var(--border-primary)",borderRadius:10,padding:"8px 12px",fontSize:13,background:"var(--bg-input)",color:"var(--text-primary)",fontFamily:"inherit",outline:"none",boxSizing:"border-box"}})]}),r.jsxs("div",{children:[r.jsx("div",{style:{fontSize:9,fontWeight:600,color:"var(--text-faint)",textTransform:"uppercase",letterSpacing:"0.05em",marginBottom:4},children:a("collab.polls.options")}),r.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[o.map((S,v)=>r.jsxs("div",{style:{display:"flex",gap:6,alignItems:"center"},children:[r.jsx("input",{value:S,onChange:_=>y(v,_.target.value),placeholder:`${a("collab.polls.option")} ${v+1}`,style:{flex:1,border:"1px solid var(--border-primary)",borderRadius:10,padding:"8px 12px",fontSize:13,background:"var(--bg-input)",color:"var(--text-primary)",fontFamily:"inherit",outline:"none"}}),o.length>2&&r.jsx("button",{type:"button",onClick:()=>f(v),style:{background:"none",border:"none",cursor:"pointer",color:"var(--text-faint)",display:"flex",padding:2},children:r.jsx(gt,{size:14})})]},v)),r.jsxs("button",{type:"button",onClick:g,style:{display:"flex",alignItems:"center",gap:4,padding:"6px 12px",borderRadius:10,border:"1px dashed var(--border-faint)",background:"transparent",cursor:"pointer",color:"var(--text-faint)",fontSize:12,fontFamily:Si},children:[r.jsx(Ft,{size:12})," ",a("collab.polls.addOption")]})]})]}),r.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer"},children:[r.jsx("div",{onClick:()=>c(!d),style:{width:36,height:20,borderRadius:10,padding:2,cursor:"pointer",background:d?"#007AFF":"var(--border-primary)",transition:"background 0.2s",display:"flex",alignItems:"center"},children:r.jsx("div",{style:{width:16,height:16,borderRadius:"50%",background:"#fff",transition:"transform 0.2s",transform:d?"translateX(16px)":"translateX(0)"}})}),r.jsx("span",{style:{fontSize:12,color:"var(--text-muted)",fontFamily:Si},children:a("collab.polls.multiChoice")})]}),r.jsx("button",{type:"submit",disabled:!x,style:{width:"100%",borderRadius:99,padding:"9px 14px",background:x?"var(--accent)":"var(--border-primary)",color:x?"var(--accent-text)":"var(--text-faint)",fontSize:13,fontWeight:600,border:"none",cursor:x?"pointer":"default",fontFamily:Si},children:p?"...":a("collab.polls.create")})]})]})}),document.body)}function t7({voter:e,offset:t}){const[a,n]=b.useState(!1),i=Ka.useRef(null),[o,s]=b.useState({top:0,left:0});return r.jsxs(r.Fragment,{children:[r.jsx("div",{ref:i,onMouseEnter:()=>{if(i.current){const d=i.current.getBoundingClientRect();s({top:d.top-6,left:d.left+d.width/2})}n(!0)},onMouseLeave:()=>n(!1),style:{width:18,height:18,borderRadius:"50%",background:"var(--bg-tertiary)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:7,fontWeight:700,color:"var(--text-muted)",overflow:"hidden",border:"1.5px solid var(--bg-card)",marginLeft:t?-5:0,flexShrink:0},children:e.avatar_url?r.jsx("img",{src:e.avatar_url,style:{width:"100%",height:"100%",objectFit:"cover"}}):(e.username||"?")[0].toUpperCase()}),a&&Vt.createPortal(r.jsx("div",{style:{position:"fixed",top:o.top,left:o.left,transform:"translate(-50%, -100%)",pointerEvents:"none",zIndex:1e4,whiteSpace:"nowrap",background:"var(--bg-card)",color:"var(--text-primary)",fontSize:11,fontWeight:500,padding:"5px 10px",borderRadius:8,boxShadow:"0 4px 12px rgba(0,0,0,0.15)",border:"1px solid var(--border-faint)"},children:e.username}),document.body)]})}function iw({poll:e,currentUser:t,onVote:a,onClose:n,onDelete:i,t:o}){const s=QH(e),d=e.is_closed||yy(e.deadline),c=JH(e.deadline),p=(e.options||[]).some(m=>(m.voters||[]).some(g=>String(g.user_id)===String(t.id)));return r.jsxs("div",{style:{borderRadius:14,border:"1px solid var(--border-faint)",overflow:"hidden",background:"var(--bg-card)",fontFamily:Si},children:[r.jsxs("div",{style:{padding:"10px 12px",display:"flex",alignItems:"flex-start",gap:8,background:d?"var(--bg-secondary)":"transparent"},children:[r.jsxs("div",{style:{flex:1,minWidth:0},children:[r.jsx("div",{style:{fontSize:13,fontWeight:700,color:"var(--text-primary)",lineHeight:1.35,wordBreak:"break-word"},children:e.question}),r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginTop:4,flexWrap:"wrap"},children:[d&&r.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:3,fontSize:9,fontWeight:600,color:"var(--text-faint)",background:"var(--bg-tertiary)",padding:"2px 7px",borderRadius:99},children:[r.jsx(Sl,{size:8})," ",o("collab.polls.closed")]}),c&&!d&&r.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:3,fontSize:9,fontWeight:600,color:"#f59e0b",background:"#f59e0b18",padding:"2px 7px",borderRadius:99},children:[r.jsx(Nn,{size:8})," ",c]}),e.multiple_choice&&r.jsx("span",{style:{fontSize:9,fontWeight:600,color:"var(--text-faint)",background:"var(--bg-tertiary)",padding:"2px 7px",borderRadius:99},children:o("collab.polls.multiChoice")}),r.jsxs("span",{style:{fontSize:9,color:"var(--text-faint)"},children:[s," ",s===1?"vote":"votes"]})]})]}),r.jsxs("div",{style:{display:"flex",gap:2,flexShrink:0},children:[!d&&r.jsx("button",{onClick:()=>n(e.id),title:o("collab.polls.close"),style:{padding:4,background:"none",border:"none",cursor:"pointer",color:"var(--text-faint)",display:"flex",borderRadius:6},onMouseEnter:m=>m.currentTarget.style.color="var(--text-primary)",onMouseLeave:m=>m.currentTarget.style.color="var(--text-faint)",children:r.jsx(Sl,{size:12})}),r.jsx("button",{onClick:()=>i(e.id),title:o("collab.polls.delete"),style:{padding:4,background:"none",border:"none",cursor:"pointer",color:"var(--text-faint)",display:"flex",borderRadius:6},onMouseEnter:m=>m.currentTarget.style.color="#ef4444",onMouseLeave:m=>m.currentTarget.style.color="var(--text-faint)",children:r.jsx(_t,{size:12})})]})]}),r.jsx("div",{style:{padding:"4px 12px 12px",display:"flex",flexDirection:"column",gap:6},children:(e.options||[]).map((m,g)=>{var S;const f=((S=m.voters)==null?void 0:S.length)||0,y=s>0?Math.round(f/s*100):0,x=(m.voters||[]).some(v=>String(v.user_id)===String(t.id)),k=d&&f===Math.max(...(e.options||[]).map(v=>{var _;return((_=v.voters)==null?void 0:_.length)||0}))&&f>0;return r.jsxs("button",{onClick:()=>!d&&a(e.id,g),disabled:d,style:{position:"relative",display:"flex",alignItems:"center",gap:8,padding:"10px 12px",borderRadius:10,border:"none",cursor:d?"default":"pointer",background:"var(--bg-secondary)",fontFamily:Si,textAlign:"left",width:"100%",overflow:"hidden",transition:"transform 0.1s"},onMouseEnter:v=>{d||(v.currentTarget.style.transform="scale(1.01)")},onMouseLeave:v=>v.currentTarget.style.transform="scale(1)",children:[r.jsx("div",{style:{position:"absolute",left:0,top:0,bottom:0,width:`${y}%`,borderRadius:10,background:x?"#007AFF20":k?"#10b98118":"var(--bg-tertiary)",transition:"width 0.4s ease"}}),r.jsx("div",{style:{width:20,height:20,borderRadius:"50%",flexShrink:0,position:"relative",border:x?"2px solid #007AFF":"2px solid var(--border-primary)",background:x?"#007AFF":"transparent",display:"flex",alignItems:"center",justifyContent:"center",transition:"all 0.2s"},children:x&&r.jsx(Ga,{size:11,color:"#fff",strokeWidth:3})}),r.jsx("span",{style:{flex:1,fontSize:13,fontWeight:x||k?600:400,color:"var(--text-primary)",position:"relative",zIndex:1},children:typeof m=="string"?m:m.label||m}),(m.voters||[]).length>0&&(p||d)&&r.jsx("div",{style:{display:"flex",position:"relative",zIndex:1},children:(m.voters||[]).slice(0,3).map((v,_)=>r.jsx(t7,{voter:v,offset:_>0},v.user_id||_))}),(p||d)&&r.jsxs("span",{style:{fontSize:12,fontWeight:700,color:x?"#007AFF":"var(--text-muted)",position:"relative",zIndex:1,minWidth:32,textAlign:"right"},children:[y,"%"]})]},g)})})]})}function ow({tripId:e,currentUser:t}){const{t:a}=ot(),[n,i]=b.useState([]),[o,s]=b.useState(!0),[d,c]=b.useState(!1);b.useEffect(()=>{Ta.getPolls(e).then(S=>{i(Array.isArray(S)?S:S.polls||[])}).catch(()=>{}).finally(()=>s(!1))},[e]),b.useEffect(()=>{const S=v=>{var _;if(v!=null&&v.type&&(v.type==="collab:poll:created"&&v.poll&&i(w=>w.some(E=>E.id===v.poll.id)?w:[v.poll,...w]),v.type==="collab:poll:voted"&&v.poll&&i(w=>w.map(E=>E.id===v.poll.id?v.poll:E)),v.type==="collab:poll:closed"&&v.poll&&i(w=>w.map(E=>E.id===v.poll.id?{...E,...v.poll,is_closed:!0}:E)),v.type==="collab:poll:deleted")){const w=v.pollId||((_=v.poll)==null?void 0:_.id);w&&i(E=>E.filter(M=>M.id!==w))}};return xl(S),()=>kl(S)},[]);const p=b.useCallback(async S=>{const v=await Ta.createPoll(e,S),_=v.poll||v;i(w=>w.some(E=>E.id===_.id)?w:[_,...w]),c(!1)},[e]),m=b.useCallback(async(S,v)=>{try{const _=await Ta.votePoll(e,S,v),w=_.poll||_;i(E=>E.map(M=>M.id===w.id?w:M))}catch{}},[e]),g=b.useCallback(async S=>{try{await Ta.closePoll(e,S),i(v=>v.map(_=>_.id===S?{..._,is_closed:!0}:_))}catch{}},[e]),f=b.useCallback(async S=>{try{await Ta.deletePoll(e,S),i(v=>v.filter(_=>_.id!==S))}catch{}},[e]),y=n.filter(S=>!S.is_closed&&!yy(S.deadline)),x=n.filter(S=>S.is_closed||yy(S.deadline)),[,k]=b.useState(0);return b.useEffect(()=>{if(!n.some(v=>v.deadline&&!v.is_closed))return;const S=setInterval(()=>k(v=>v+1),3e4);return()=>clearInterval(S)},[n]),o?r.jsxs("div",{style:{height:"100%",display:"flex",alignItems:"center",justifyContent:"center",fontFamily:Si},children:[r.jsx("div",{style:{width:20,height:20,border:"2px solid var(--border-primary)",borderTopColor:"var(--text-primary)",borderRadius:"50%",animation:"collab-poll-spin 0.7s linear infinite"}}),r.jsx("style",{children:"@keyframes collab-poll-spin { to { transform: rotate(360deg) } }"})]}):r.jsxs("div",{style:{height:"100%",display:"flex",flexDirection:"column",fontFamily:Si},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"10px 16px",flexShrink:0},children:[r.jsxs("h3",{style:{margin:0,fontSize:12,fontWeight:600,color:"var(--text-muted)",display:"flex",alignItems:"center",gap:7,letterSpacing:.3,textTransform:"uppercase"},children:[r.jsx(Lf,{size:14,color:"var(--text-faint)"}),a("collab.polls.title")]}),r.jsxs("button",{onClick:()=>c(!0),style:{display:"inline-flex",alignItems:"center",gap:4,borderRadius:99,padding:"6px 12px",background:"var(--accent)",color:"var(--accent-text)",fontSize:11,fontWeight:600,fontFamily:Si,border:"none",cursor:"pointer"},children:[r.jsx(Ft,{size:12})," ",a("collab.polls.new")]})]}),r.jsx("div",{className:"chat-scroll",style:{flex:1,overflowY:"auto",padding:"0 12px 12px"},children:n.length===0?r.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"48px 20px",textAlign:"center",height:"100%"},children:[r.jsx(Lf,{size:36,color:"var(--text-faint)",strokeWidth:1.3,style:{marginBottom:12}}),r.jsx("div",{style:{fontSize:14,fontWeight:600,color:"var(--text-secondary)",marginBottom:4},children:a("collab.polls.empty")}),r.jsx("div",{style:{fontSize:12,color:"var(--text-faint)"},children:a("collab.polls.emptyHint")})]}):r.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[y.length>0&&y.map(S=>r.jsx(iw,{poll:S,currentUser:t,onVote:m,onClose:g,onDelete:f,t:a},S.id)),x.length>0&&r.jsxs(r.Fragment,{children:[y.length>0&&r.jsx("div",{style:{fontSize:10,fontWeight:600,color:"var(--text-faint)",textTransform:"uppercase",letterSpacing:.3,padding:"8px 0 2px"},children:a("collab.polls.closedSection")||"Closed"}),x.map(S=>r.jsx(iw,{poll:S,currentUser:t,onVote:m,onClose:g,onDelete:f,t:a},S.id))]})]})}),d&&r.jsx(e7,{onClose:()=>c(!1),onCreate:p,t:a})]})}function sw(e,t){if(!e)return"";const[a,n]=e.split(":").map(Number);if(t){const i=a>=12?"PM":"AM";return`${a===0?12:a>12?a-12:a}:${String(n).padStart(2,"0")} ${i}`}return`${String(a).padStart(2,"0")}:${String(n).padStart(2,"0")}`}function a7(e,t,a){const n=new Date(e+"T00:00:00"),i=new Date,o=new Date;return o.setDate(i.getDate()+1),n.toDateString()===i.toDateString()?t("collab.whatsNext.today")||"Today":n.toDateString()===o.toDateString()?t("collab.whatsNext.tomorrow")||"Tomorrow":n.toLocaleDateString(a||void 0,{weekday:"short",day:"numeric",month:"short"})}function lw({tripMembers:e=[]}){const{days:t,assignments:a}=Rn(),{t:n,locale:i}=ot(),o=ta(d=>d.settings.time_format)==="12h",s=b.useMemo(()=>{const d=new Date,c=d.toISOString().split("T")[0],p=`${String(d.getHours()).padStart(2,"0")}:${String(d.getMinutes()).padStart(2,"0")}`,m=[];for(const g of t||[]){if(!g.date)continue;const f=a[String(g.id)]||[];for(const y of f){if(!y.place)continue;const x=g.date>c,k=g.date===c&&(!y.place.place_time||y.place.place_time>=p);(x||k)&&m.push({id:y.id,name:y.place.name,time:y.place.place_time,endTime:y.place.end_time,date:g.date,dayTitle:g.title,category:y.place.category,participants:y.participants&&y.participants.length>0?y.participants:e.map(S=>({user_id:S.id,username:S.username,avatar:S.avatar})),address:y.place.address})}}return m.sort((g,f)=>{const y=g.date+(g.time||"99:99"),x=f.date+(f.time||"99:99");return y.localeCompare(x)}),m.slice(0,8)},[t,a,e]);return r.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",overflow:"hidden"},children:[r.jsxs("div",{style:{padding:"10px 14px",display:"flex",alignItems:"center",gap:7,flexShrink:0},children:[r.jsx(j_,{size:14,color:"var(--text-faint)"}),r.jsx("span",{style:{fontSize:12,fontWeight:600,color:"var(--text-muted)",letterSpacing:.3,textTransform:"uppercase"},children:n("collab.whatsNext.title")||"What's Next"})]}),r.jsx("div",{className:"chat-scroll",style:{flex:1,overflowY:"auto",padding:"8px 10px"},children:s.length===0?r.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100%",padding:"48px 20px",textAlign:"center"},children:[r.jsx(Ni,{size:36,color:"var(--text-faint)",strokeWidth:1.3,style:{marginBottom:12}}),r.jsx("div",{style:{fontSize:14,fontWeight:600,color:"var(--text-secondary)",marginBottom:4},children:n("collab.whatsNext.empty")}),r.jsx("div",{style:{fontSize:12,color:"var(--text-faint)"},children:n("collab.whatsNext.emptyHint")})]}):r.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:s.map((d,c)=>{const p=s[c-1],m=!p||p.date!==d.date;return r.jsxs(Ka.Fragment,{children:[m&&r.jsxs("div",{style:{fontSize:10,fontWeight:500,color:"var(--text-faint)",textTransform:"uppercase",letterSpacing:.5,padding:c===0?"0 4px 4px":"8px 4px 4px"},children:[a7(d.date,n,i),d.dayTitle?` — ${d.dayTitle}`:""]}),r.jsxs("div",{style:{display:"flex",gap:10,padding:"8px 10px",borderRadius:10,background:"var(--bg-secondary)",transition:"background 0.1s"},onMouseEnter:g=>g.currentTarget.style.background="var(--bg-hover)",onMouseLeave:g=>g.currentTarget.style.background="var(--bg-secondary)",children:[r.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",minWidth:44,flexShrink:0},children:[r.jsx("span",{style:{fontSize:11,fontWeight:700,color:"var(--text-primary)",whiteSpace:"nowrap",lineHeight:1},children:d.time?sw(d.time,o):"TBD"}),d.endTime&&r.jsxs(r.Fragment,{children:[r.jsx("span",{style:{fontSize:7,color:"var(--text-faint)",fontWeight:600,letterSpacing:.3,margin:"2px 0",textTransform:"uppercase"},children:n("collab.whatsNext.until")||"bis"}),r.jsx("span",{style:{fontSize:11,fontWeight:700,color:"var(--text-primary)",whiteSpace:"nowrap",lineHeight:1},children:sw(d.endTime,o)})]})]}),r.jsx("div",{style:{width:1,alignSelf:"stretch",background:"var(--border-faint)",flexShrink:0,margin:"2px 0"}}),r.jsxs("div",{style:{flex:1,minWidth:0},children:[r.jsx("div",{style:{fontSize:12,fontWeight:600,color:"var(--text-primary)",lineHeight:1.3,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:d.name}),d.address&&r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:3,marginTop:2},children:[r.jsx(tn,{size:9,color:"var(--text-faint)",style:{flexShrink:0}}),r.jsx("span",{style:{fontSize:10,color:"var(--text-faint)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:d.address})]}),d.participants.length>0&&r.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:4,marginTop:5},children:d.participants.map(g=>{var f,y;return r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4,padding:"2px 8px 2px 3px",borderRadius:99,background:"var(--bg-tertiary)",border:"1px solid var(--border-faint)"},children:[r.jsx("div",{style:{width:16,height:16,borderRadius:"50%",background:"var(--bg-secondary)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:7,fontWeight:700,color:"var(--text-muted)",overflow:"hidden",flexShrink:0},children:g.avatar?r.jsx("img",{src:`/uploads/avatars/${g.avatar}`,style:{width:"100%",height:"100%",objectFit:"cover"}}):(y=(f=g.username)==null?void 0:f[0])==null?void 0:y.toUpperCase()}),r.jsx("span",{style:{fontSize:10,fontWeight:500,color:"var(--text-muted)"},children:g.username})]},g.user_id)})})]})]})]},d.id)})})})]})}function n7(e=1024){const[t,a]=b.useState(window.innerWidth>=e);return b.useEffect(()=>{const n=()=>a(window.innerWidth>=e);return window.addEventListener("resize",n),()=>window.removeEventListener("resize",n)},[e]),t}const ju={display:"flex",flexDirection:"column",background:"var(--bg-card)",borderRadius:16,border:"1px solid var(--border-faint)",overflow:"hidden",minHeight:0};function r7({tripId:e,tripMembers:t=[]}){const{user:a}=cn(),{t:n}=ot(),[i,o]=b.useState("chat"),s=n7(),d=[{id:"chat",label:n("collab.tabs.chat")||"Chat",icon:Fp},{id:"notes",label:n("collab.tabs.notes")||"Notes",icon:Ov},{id:"polls",label:n("collab.tabs.polls")||"Polls",icon:Lf},{id:"next",label:n("collab.whatsNext.title")||"What's Next",icon:j_}];return s?r.jsxs("div",{style:{height:"100%",display:"flex",gap:12,padding:12,overflow:"hidden",minHeight:0},children:[r.jsx("div",{style:{...ju,flex:"0 0 380px"},children:r.jsx(s1,{tripId:e,currentUser:a})}),r.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",gap:12,overflow:"hidden",minHeight:0},children:[r.jsx("div",{style:{...ju,flex:1},children:r.jsx(rw,{tripId:e,currentUser:a})}),r.jsxs("div",{style:{flex:1,display:"flex",gap:12,overflow:"hidden",minHeight:0},children:[r.jsx("div",{style:{...ju,flex:1},children:r.jsx(ow,{tripId:e,currentUser:a})}),r.jsx("div",{style:{...ju,flex:1},children:r.jsx(lw,{tripMembers:t})})]})]})]}):r.jsxs("div",{style:{height:"100%",display:"flex",flexDirection:"column",overflow:"hidden",position:"absolute",inset:0},children:[r.jsx("div",{style:{display:"flex",gap:2,padding:"8px 12px",borderBottom:"1px solid var(--border-faint)",background:"var(--bg-card)",flexShrink:0},children:d.map(c=>{c.icon;const p=i===c.id;return r.jsx("button",{onClick:()=>o(c.id),style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",gap:6,padding:"8px 0",borderRadius:10,border:"none",cursor:"pointer",background:p?"var(--accent)":"transparent",color:p?"var(--accent-text)":"var(--text-muted)",fontSize:11,fontWeight:600,fontFamily:"inherit",transition:"all 0.15s"},children:c.label},c.id)})}),r.jsxs("div",{style:{flex:1,overflow:"hidden",minHeight:0},children:[i==="chat"&&r.jsx(s1,{tripId:e,currentUser:a}),i==="notes"&&r.jsx(rw,{tripId:e,currentUser:a}),i==="polls"&&r.jsx(ow,{tripId:e,currentUser:a}),i==="next"&&r.jsx(lw,{tripMembers:t})]})]})}function i7({isOpen:e,onClose:t,onConfirm:a,title:n,message:i,confirmLabel:o,cancelLabel:s,danger:d=!0}){const{t:c}=ot(),p=b.useCallback(m=>{m.key==="Escape"&&t()},[t]);return b.useEffect(()=>(e&&document.addEventListener("keydown",p),()=>document.removeEventListener("keydown",p)),[e,p]),e?r.jsxs("div",{className:"fixed inset-0 z-[60] flex items-center justify-center px-4",style:{backgroundColor:"rgba(15, 23, 42, 0.5)"},onClick:t,children:[r.jsxs("div",{className:"rounded-2xl shadow-2xl w-full max-w-sm p-6",style:{animation:"modalIn 0.2s ease-out forwards",background:"var(--bg-card)"},onClick:m=>m.stopPropagation(),children:[r.jsxs("div",{className:"flex items-start gap-4",children:[d&&r.jsx("div",{className:"flex-shrink-0 w-10 h-10 rounded-full bg-red-100 flex items-center justify-center",children:r.jsx(li,{className:"w-5 h-5 text-red-600"})}),r.jsxs("div",{className:"flex-1",children:[r.jsx("h3",{className:"text-base font-semibold",style:{color:"var(--text-primary)"},children:n||c("common.confirm")}),r.jsx("p",{className:"mt-1 text-sm",style:{color:"var(--text-secondary)"},children:i})]})]}),r.jsxs("div",{className:"flex justify-end gap-3 mt-6",children:[r.jsx("button",{onClick:t,className:"px-4 py-2 text-sm font-medium rounded-lg transition-colors",style:{color:"var(--text-secondary)",border:"1px solid var(--border-secondary)"},children:s||c("common.cancel")}),r.jsx("button",{onClick:()=>{a(),t()},className:`px-4 py-2 text-sm font-medium rounded-lg transition-colors text-white ${d?"bg-red-600 hover:bg-red-700":"bg-blue-600 hover:bg-blue-700"}`,children:o||c("common.delete")})]})]}),r.jsx("style",{children:`
+ @keyframes modalIn {
+ from { opacity: 0; transform: scale(0.95) translateY(-10px); }
+ to { opacity: 1; transform: scale(1) translateY(0); }
+ }
+ `})]}):null}const dw=200,cw=520;function o7(){const[e,t]=b.useState(()=>parseInt(localStorage.getItem("sidebarLeftWidth")||"")||340),[a,n]=b.useState(()=>parseInt(localStorage.getItem("sidebarRightWidth")||"")||300),[i,o]=b.useState(!1),[s,d]=b.useState(!1),c=b.useRef(!1),p=b.useRef(!1);return b.useEffect(()=>{const f=x=>{if(c.current){const k=Math.max(dw,Math.min(cw,x.clientX-10));t(k),localStorage.setItem("sidebarLeftWidth",String(k))}if(p.current){const k=Math.max(dw,Math.min(cw,window.innerWidth-x.clientX-10));n(k),localStorage.setItem("sidebarRightWidth",String(k))}},y=()=>{c.current=!1,p.current=!1,document.body.style.cursor="",document.body.style.userSelect=""};return document.addEventListener("mousemove",f),document.addEventListener("mouseup",y),()=>{document.removeEventListener("mousemove",f),document.removeEventListener("mouseup",y)}},[]),{leftWidth:e,rightWidth:a,leftCollapsed:i,rightCollapsed:s,setLeftCollapsed:o,setRightCollapsed:d,startResizeLeft:()=>{c.current=!0,document.body.style.cursor="col-resize",document.body.style.userSelect="none"},startResizeRight:()=>{p.current=!0,document.body.style.cursor="col-resize",document.body.style.userSelect="none"}}}function s7(e){const t=Rn();b.useEffect(()=>{if(!e)return;const a=Rn.getState().handleRemoteEvent;XR(e),xl(a);const n=o=>{var s;((o==null?void 0:o.type)==="collab:note:deleted"||(o==null?void 0:o.type)==="collab:note:updated")&&((s=t.loadFiles)==null||s.call(t,e))};xl(n);const i=()=>{var o;return(o=t.loadFiles)==null?void 0:o.call(t,e)};return window.addEventListener("collab-files-changed",i),()=>{JR(e),kl(a),kl(n),window.removeEventListener("collab-files-changed",i)}},[e])}function l7(e,t){const[a,n]=b.useState(null),[i,o]=b.useState(null),[s,d]=b.useState([]),c=ta(g=>g.settings.route_calculation)!==!1,p=b.useRef(null),m=b.useCallback(async g=>{if(p.current&&p.current.abort(),!g){n(null),d([]);return}const y=(e.assignments[String(g)]||[]).slice().sort((k,S)=>k.order_index-S.order_index).map(k=>k.place).filter(k=>(k==null?void 0:k.lat)&&(k==null?void 0:k.lng));if(y.length<2){n(null),d([]);return}if(n(y.map(k=>[k.lat,k.lng])),!c){d([]);return}const x=new AbortController;p.current=x;try{const k=await a4(y,{signal:x.signal});x.signal.aborted||d(k)}catch(k){k instanceof Error&&k.name!=="AbortError"?d([]):k instanceof Error||d([])}},[e,c]);return b.useEffect(()=>{if(!t){n(null),d([]);return}m(t)},[t,e.assignments]),{route:a,routeSegments:s,routeInfo:i,setRoute:n,setRouteInfo:o,updateRouteForDay:m}}function d7(){const[e,t]=b.useState(null),[a,n]=b.useState(null),i=b.useCallback(s=>{t(s),n(null)},[]),o=b.useCallback((s,d)=>{n(s),t(d)},[]);return{selectedPlaceId:e,selectedAssignmentId:a,setSelectedPlaceId:i,selectAssignment:o}}function c7(){const{id:e}=wm(),t=Br(),a=ya(),{t:n,language:i}=ot(),{settings:o}=ta(),s=Rn(),{trip:d,days:c,places:p,assignments:m,packingItems:g,categories:f,reservations:y,budgetItems:x,files:k,selectedDayId:S,isLoading:v}=s,[_,w]=b.useState({packing:!0,budget:!0,documents:!0}),[E,M]=b.useState([]),[A,P]=b.useState(null),[R,$]=b.useState([]),I=b.useCallback(()=>{e&&(ni.list(e).then(N=>M(N.accommodations||[])).catch(()=>{}),s.loadReservations(e))},[e]);b.useEffect(()=>{Mv.enabled().then(N=>{const se={};N.addons.forEach(he=>{se[he.id]=!0}),w({packing:!!se.packing,budget:!!se.budget,documents:!!se.documents,collab:!!se.collab,memories:!!se.memories})}).catch(()=>{}),jt.getAppConfig().then(N=>{N.allowed_file_types&&P(N.allowed_file_types)}).catch(()=>{})},[]);const Y=[{id:"plan",label:n("trip.tabs.plan")},{id:"buchungen",label:n("trip.tabs.reservations"),shortLabel:n("trip.tabs.reservationsShort")},..._.packing?[{id:"packliste",label:n("trip.tabs.packing"),shortLabel:n("trip.tabs.packingShort")}]:[],..._.budget?[{id:"finanzplan",label:n("trip.tabs.budget")}]:[],..._.documents?[{id:"dateien",label:n("trip.tabs.files")}]:[],..._.memories?[{id:"memories",label:n("memories.title")}]:[],..._.collab?[{id:"collab",label:n("admin.addons.catalog.collab.name")}]:[]],[H,V]=b.useState(()=>sessionStorage.getItem(`trip-tab-${e}`)||"plan"),X=N=>{var se,he;V(N),sessionStorage.setItem(`trip-tab-${e}`,N),N==="finanzplan"&&((se=s.loadBudgetItems)==null||se.call(s,e)),N==="dateien"&&(!k||k.length===0)&&((he=s.loadFiles)==null||he.call(s,e))},{leftWidth:Z,rightWidth:O,leftCollapsed:Q,rightCollapsed:D,setLeftCollapsed:J,setRightCollapsed:z,startResizeLeft:W,startResizeRight:B}=o7(),{selectedPlaceId:C,selectedAssignmentId:U,setSelectedPlaceId:q,selectAssignment:te}=d7(),[oe,be]=b.useState(null),[Se,je]=b.useState(!1),[we,ce]=b.useState(null),[le,K]=b.useState(null),[de,_e]=b.useState(null),[pe,Ae]=b.useState(!1),[He,ze]=b.useState(!1),[Ye,G]=b.useState(!1),[ve,Pe]=b.useState(null),[ye,ne]=b.useState(0),[fe,Ee]=b.useState(null),[Oe,Ke]=b.useState(null),[dt,Wt]=b.useState(()=>window.innerWidth<768);b.useEffect(()=>{const N=window.matchMedia("(max-width: 767px)"),se=he=>Wt(he.matches);return N.addEventListener("change",se),()=>N.removeEventListener("change",se)},[]),b.useEffect(()=>{e&&(s.loadTrip(e).catch(()=>{a.error(n("trip.toast.loadError")),t("/dashboard")}),s.loadFiles(e),I(),Ba.getMembers(e).then(N=>{const se=[N.owner,...N.members||[]].filter(Boolean);$(se)}).catch(()=>{}))},[e]),b.useEffect(()=>{e&&s.loadReservations(e)},[e]),s7(e);const[Be,Gt]=b.useState(""),Kt=b.useMemo(()=>p.filter(N=>!(!N.lat||!N.lng||Be&&String(N.category_id)!==String(Be))),[p,Be]),{route:Lt,routeSegments:Ce,setRoute:De,setRouteInfo:Qe,updateRouteForDay:ft}=l7(s,S),Et=b.useCallback((N,se)=>{const he=N!==S;s.setSelectedDay(N),he&&!se&&ne(ee=>ee+1),Ee(null),ft(N)},[s,ft,S]),pt=b.useCallback((N,se)=>{se?te(se,N):q(N),N&&(be(null),J(!1),z(!1))},[te,q]),Zt=b.useCallback(N=>{const se=N!==void 0;q(he=>he===N?null:N),se&&(J(!1),z(!1))},[]),jn=b.useCallback(()=>{q(null)},[]),ga=b.useCallback(async N=>{var ee;(ee=N.originalEvent)==null||ee.preventDefault();const{lat:se,lng:he}=N.latlng;K({lat:se,lng:he}),ce(null),_e(null),je(!0);try{const{mapsApi:ge}=await Hv(async()=>{const{mapsApi:$e}=await Promise.resolve().then(()=>r_);return{mapsApi:$e}},void 0),Me=await ge.reverse(se,he,i);(Me.name||Me.address)&&K($e=>$e&&{...$e,name:Me.name||"",address:Me.address||""})}catch{}},[i]),Ot=b.useCallback(async N=>{const se=N._pendingFiles;if(delete N._pendingFiles,we){const{place_time:he,end_time:ee,...ge}=N;if(await s.updatePlace(e,we.id,ge),de&&(await ti.updateTime(e,de,{place_time:he||null,end_time:ee||null}),await s.refreshDays(e)),(se==null?void 0:se.length)>0)for(const Me of se){const $e=new FormData;$e.append("file",Me),$e.append("place_id",we.id);try{await s.addFile(e,$e)}catch{}}a.success(n("trip.toast.placeUpdated"))}else{const he=await s.addPlace(e,N);if((se==null?void 0:se.length)>0&&(he!=null&&he.id))for(const ee of se){const ge=new FormData;ge.append("file",ee),ge.append("place_id",he.id);try{await s.addFile(e,ge)}catch{}}a.success(n("trip.toast.placeAdded"))}},[we,de,e,s,a]),Xt=b.useCallback(N=>{Ke(N)},[]),Za=b.useCallback(async()=>{if(Oe)try{await s.deletePlace(e,Oe),C===Oe&&q(null),a.success(n("trip.toast.placeDeleted"))}catch(N){a.error(N instanceof Error?N.message:"Unknown error")}},[Oe,e,s,a,C]),It=b.useCallback(async(N,se,he)=>{const ee=se||S;if(!ee){a.error(n("trip.toast.selectDay"));return}try{await s.assignPlaceToDay(e,ee,N,he),a.success(n("trip.toast.assignedToDay")),ft(ee)}catch(ge){a.error(ge instanceof Error?ge.message:"Unknown error")}},[S,e,s,a,ft]),re=b.useCallback(async(N,se)=>{try{await s.removeAssignment(e,N,se)}catch(he){a.error(he instanceof Error?he.message:"Unknown error")}},[e,s,a,ft]),Ie=b.useCallback((N,se)=>{try{s.reorderAssignments(e,N,se).catch(()=>{});const he=s.assignments[String(N)]||[],ge=se.map(Me=>he.find($e=>$e.id===Me)).filter(Boolean).map(Me=>Me.place).filter(Me=>(Me==null?void 0:Me.lat)&&(Me==null?void 0:Me.lng));ge.length>=2?De(ge.map(Me=>[Me.lat,Me.lng])):De(null),Qe(null)}catch{a.error(n("trip.toast.reorderError"))}},[e,s,a]),At=b.useCallback(async(N,se)=>{try{await s.updateDayTitle(e,N,se)}catch(he){a.error(he instanceof Error?he.message:"Unknown error")}},[e,s,a]),va=async N=>{try{if(ve){const se=await s.updateReservation(e,ve.id,N);return a.success(n("trip.toast.reservationUpdated")),G(!1),N.type==="hotel"&&ni.list(e).then(he=>M(he.accommodations||[])).catch(()=>{}),se}else{const se=await s.addReservation(e,{...N,day_id:S||null});return a.success(n("trip.toast.reservationAdded")),G(!1),N.type==="hotel"&&ni.list(e).then(he=>M(he.accommodations||[])).catch(()=>{}),se}}catch(se){a.error(se instanceof Error?se.message:"Unknown error")}},ba=async N=>{try{await s.deleteReservation(e,N),a.success(n("trip.toast.deleted")),ni.list(e).then(se=>M(se.accommodations||[])).catch(()=>{})}catch(se){a.error(se instanceof Error?se.message:"Unknown error")}},Ue=C?p.find(N=>N.id===C):null,Xn=b.useMemo(()=>{if(!S)return{};const se=[...m[String(S)]||[]].sort((ee,ge)=>ee.order_index-ge.order_index),he={};return se.forEach((ee,ge)=>{var Me;(Me=ee.place)!=null&&Me.id&&(he[ee.place.id]||(he[ee.place.id]=[]),he[ee.place.id].push(ge+1))}),he},[S,m]),_n=b.useMemo(()=>S?(m[String(S)]||[]).map(se=>se.place).filter(se=>(se==null?void 0:se.lat)&&(se==null?void 0:se.lng)):[],[S,m]),an=o.map_tile_url||"https://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}{r}.png",Ea=[o.default_lat||48.8566,o.default_lng||2.3522],Jn=o.default_zoom||10,ja={fontFamily:"-apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', system-ui, sans-serif"};return v?r.jsx("div",{style:{minHeight:"100vh",display:"flex",alignItems:"center",justifyContent:"center",background:"#f9fafb",...ja},children:r.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:12},children:[r.jsx("div",{style:{width:32,height:32,border:"3px solid rgba(0,0,0,0.1)",borderTopColor:"#111827",borderRadius:"50%",animation:"spin 0.8s linear infinite"}}),r.jsx("span",{style:{fontSize:13,color:"#9ca3af"},children:n("trip.loading")})]})}):d?r.jsxs("div",{style:{position:"fixed",inset:0,display:"flex",flexDirection:"column",overflow:"hidden",...ja},children:[r.jsx(Mi,{tripTitle:d.title,tripId:e,showBack:!0,onBack:()=>t("/dashboard"),onShare:()=>ze(!0)}),r.jsx("div",{style:{position:"fixed",top:"var(--nav-h)",left:0,right:0,zIndex:40,display:"flex",alignItems:"center",justifyContent:"center",padding:"0 12px",background:"var(--bg-elevated)",backdropFilter:"blur(16px)",WebkitBackdropFilter:"blur(16px)",borderBottom:"1px solid var(--border-faint)",height:44,overflowX:"auto",scrollbarWidth:"none",msOverflowStyle:"none",gap:2},children:Y.map(N=>{const se=H===N.id;return r.jsx("button",{onClick:()=>X(N.id),style:{flexShrink:0,padding:"5px 14px",borderRadius:20,border:"none",cursor:"pointer",fontSize:13,fontWeight:se?600:400,background:se?"var(--accent)":"transparent",color:se?"var(--accent-text)":"var(--text-muted)",fontFamily:"inherit",transition:"all 0.15s"},onMouseEnter:he=>{se||(he.currentTarget.style.background="var(--bg-hover)"),he.currentTarget.style.color=se?"var(--accent-text)":"var(--text-primary)"},onMouseLeave:he=>{se||(he.currentTarget.style.background="transparent"),he.currentTarget.style.color=se?"var(--accent-text)":"var(--text-muted)"},children:N.shortLabel?r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"sm:hidden",children:N.shortLabel}),r.jsx("span",{className:"hidden sm:inline",children:N.label})]}):N.label},N.id)})}),r.jsxs("div",{style:{position:"fixed",top:"calc(var(--nav-h) + 44px)",left:0,right:0,bottom:0,overflow:"hidden",overscrollBehavior:"contain"},children:[H==="plan"&&r.jsxs("div",{style:{position:"absolute",inset:0},children:[r.jsx(FI,{places:Kt,dayPlaces:_n,route:Lt,routeSegments:Ce,selectedPlaceId:C,onMarkerClick:Zt,onMapClick:jn,onMapContextMenu:ga,center:Ea,zoom:Jn,tileUrl:an,fitKey:ye,dayOrderMap:Xn,leftWidth:Q?0:Z,rightWidth:D?0:O,hasInspector:!!Ue}),r.jsxs("div",{className:"hidden md:block",style:{position:"absolute",left:10,top:10,bottom:10,zIndex:20},children:[r.jsx("button",{onClick:()=>J(N=>!N),style:{position:Q?"fixed":"absolute",top:Q?"calc(var(--nav-h) + 44px + 14px)":14,left:Q?10:void 0,right:Q?void 0:-28,zIndex:-1,width:36,height:36,borderRadius:Q?10:"0 10px 10px 0",background:Q?"#000":"var(--sidebar-bg)",backdropFilter:"blur(20px)",WebkitBackdropFilter:"blur(20px)",boxShadow:Q?"0 2px 12px rgba(0,0,0,0.2)":"none",border:"none",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",color:Q?"#fff":"var(--text-faint)",transition:"color 0.15s"},onMouseEnter:N=>{Q||(N.currentTarget.style.color="var(--text-primary)")},onMouseLeave:N=>{Q||(N.currentTarget.style.color="var(--text-faint)")},children:Q?r.jsx(aD,{size:16}):r.jsx(tD,{size:16})}),r.jsxs("div",{style:{width:Q?0:Z,height:"100%",background:"var(--sidebar-bg)",backdropFilter:"blur(24px) saturate(180%)",WebkitBackdropFilter:"blur(24px) saturate(180%)",boxShadow:Q?"none":"var(--sidebar-shadow)",borderRadius:16,overflow:"hidden",display:"flex",flexDirection:"column",transition:"width 0.25s ease",opacity:Q?0:1},children:[r.jsx(L0,{tripId:e,trip:d,days:c,places:p,categories:f,assignments:m,selectedDayId:S,selectedPlaceId:C,selectedAssignmentId:U,onSelectDay:Et,onPlaceClick:pt,onReorder:Ie,onUpdateDayTitle:At,onAssignToDay:It,onRouteCalculated:N=>{N?(De(N.coordinates),Qe({distance:N.distanceText,duration:N.durationText,walkingText:N.walkingText,drivingText:N.drivingText})):(De(null),Qe(null))},reservations:y,onAddReservation:N=>{Pe(null),s.setSelectedDay(N),G(!0)},onDayDetail:N=>{be(N),q(null),te(null)},onRemoveAssignment:re,onEditPlace:(N,se)=>{ce(N),_e(se||null),je(!0)},onDeletePlace:N=>Xt(N),accommodations:E,onNavigateToFiles:()=>X("dateien")}),!Q&&r.jsx("div",{onMouseDown:W,style:{position:"absolute",right:0,top:0,bottom:0,width:4,cursor:"col-resize",background:"transparent"},onMouseEnter:N=>N.currentTarget.style.background="rgba(0,0,0,0.08)",onMouseLeave:N=>N.currentTarget.style.background="transparent"})]})]}),r.jsxs("div",{className:"hidden md:block",style:{position:"absolute",right:10,top:10,bottom:10,zIndex:20},children:[r.jsx("button",{onClick:()=>z(N=>!N),style:{position:D?"fixed":"absolute",top:D?"calc(var(--nav-h) + 44px + 14px)":14,right:D?10:void 0,left:D?void 0:-28,zIndex:-1,width:36,height:36,borderRadius:D?10:"10px 0 0 10px",background:D?"#000":"var(--sidebar-bg)",backdropFilter:"blur(20px)",WebkitBackdropFilter:"blur(20px)",boxShadow:D?"0 2px 12px rgba(0,0,0,0.2)":"none",border:"none",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",color:D?"#fff":"var(--text-faint)",transition:"color 0.15s"},onMouseEnter:N=>{D||(N.currentTarget.style.color="var(--text-primary)")},onMouseLeave:N=>{D||(N.currentTarget.style.color="var(--text-faint)")},children:D?r.jsx(rD,{size:16}):r.jsx(nD,{size:16})}),r.jsxs("div",{style:{width:D?0:O,height:"100%",background:"var(--sidebar-bg)",backdropFilter:"blur(24px) saturate(180%)",WebkitBackdropFilter:"blur(24px) saturate(180%)",boxShadow:D?"none":"var(--sidebar-shadow)",borderRadius:16,overflow:"hidden",display:"flex",flexDirection:"column",transition:"width 0.25s ease",opacity:D?0:1},children:[!D&&r.jsx("div",{onMouseDown:B,style:{position:"absolute",left:0,top:0,bottom:0,width:4,cursor:"col-resize",background:"transparent"},onMouseEnter:N=>N.currentTarget.style.background="rgba(0,0,0,0.08)",onMouseLeave:N=>N.currentTarget.style.background="transparent"}),r.jsx("div",{style:{flex:1,overflow:"hidden",display:"flex",flexDirection:"column",paddingLeft:4},children:r.jsx(F0,{tripId:e,places:p,categories:f,assignments:m,selectedDayId:S,selectedPlaceId:C,onPlaceClick:pt,onAddPlace:()=>{ce(null),je(!0)},onAssignToDay:It,onEditPlace:N=>{ce(N),_e(null),je(!0)},onDeletePlace:N=>Xt(N),onCategoryFilterChange:Gt})})]})]}),H==="plan"&&!fe&&!Se&&!He&&!Ye&&Vt.createPortal(r.jsxs("div",{className:"flex md:hidden",style:{position:"fixed",top:"calc(var(--nav-h) + 44px + 12px)",left:12,right:12,justifyContent:"space-between",zIndex:100,pointerEvents:"none"},children:[r.jsx("button",{onClick:()=>Ee("left"),style:{pointerEvents:"auto",background:"var(--bg-card)",color:"var(--text-primary)",backdropFilter:"blur(12px)",border:"1px solid var(--border-primary)",borderRadius:24,padding:"11px 24px",fontSize:15,fontWeight:600,cursor:"pointer",boxShadow:"0 2px 12px rgba(0,0,0,0.15)",minHeight:44,fontFamily:"inherit",touchAction:"manipulation"},children:n("trip.mobilePlan")}),r.jsx("button",{onClick:()=>Ee("right"),style:{pointerEvents:"auto",background:"var(--bg-card)",color:"var(--text-primary)",backdropFilter:"blur(12px)",border:"1px solid var(--border-primary)",borderRadius:24,padding:"11px 24px",fontSize:15,fontWeight:600,cursor:"pointer",boxShadow:"0 2px 12px rgba(0,0,0,0.15)",minHeight:44,fontFamily:"inherit",touchAction:"manipulation"},children:n("trip.mobilePlaces")})]}),document.body),oe&&!Ue&&(()=>{var ee;const N=c.find(ge=>ge.id===oe.id)||oe,he=((ee=(m[String(N.id)]||[]).find(ge=>{var Me,$e;return((Me=ge.place)==null?void 0:Me.lat)&&(($e=ge.place)==null?void 0:$e.lng)}))==null?void 0:ee.place)||p.find(ge=>ge.lat&&ge.lng);return r.jsx(S4,{day:N,days:c,places:p,categories:f,tripId:e,assignments:m,reservations:y,lat:he==null?void 0:he.lat,lng:he==null?void 0:he.lng,onClose:()=>be(null),onAccommodationChange:I,leftWidth:dt||Q?0:Z,rightWidth:dt||D?0:O})})(),Ue&&r.jsx(y4,{place:Ue,categories:f,days:c,selectedDayId:S,selectedAssignmentId:U,assignments:m,reservations:y,onClose:()=>q(null),onEdit:()=>{if(U){const N=Object.values(m).flat().find(he=>he.id===U),se=N!=null&&N.place?{...Ue,place_time:N.place.place_time,end_time:N.place.end_time}:Ue;ce(se)}else ce(Ue);_e(U||null),je(!0)},onDelete:()=>Xt(Ue.id),onAssignToDay:It,onRemoveAssignment:re,files:k,onFileUpload:N=>s.addFile(e,N),tripMembers:R,onSetParticipants:async(N,se,he)=>{try{const ee=await ti.setParticipants(e,N,he);Rn.setState(ge=>({assignments:{...ge.assignments,[String(se)]:(ge.assignments[String(se)]||[]).map(Me=>Me.id===N?{...Me,participants:ee.participants}:Me)}}))}catch{}},onUpdatePlace:async(N,se)=>{try{await s.updatePlace(e,N,se)}catch(he){a.error(he instanceof Error?he.message:"Unknown error")}},leftWidth:Q?0:Z,rightWidth:D?0:O}),fe&&Vt.createPortal(r.jsx("div",{style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.3)",zIndex:9999},onClick:()=>Ee(null),children:r.jsxs("div",{style:{position:"absolute",top:"var(--nav-h)",left:0,right:0,bottom:0,background:"var(--bg-card)",display:"flex",flexDirection:"column",overflow:"hidden"},onClick:N=>N.stopPropagation(),children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"14px 16px",borderBottom:"1px solid var(--border-secondary)"},children:[r.jsx("span",{style:{fontWeight:600,fontSize:14,color:"var(--text-primary)"},children:n(fe==="left"?"trip.mobilePlan":"trip.mobilePlaces")}),r.jsx("button",{onClick:()=>Ee(null),style:{background:"var(--bg-tertiary)",border:"none",borderRadius:"50%",width:28,height:28,cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",color:"var(--text-primary)"},children:r.jsx(gt,{size:14})})]}),r.jsx("div",{style:{flex:1,overflow:"auto"},children:fe==="left"?r.jsx(L0,{tripId:e,trip:d,days:c,places:p,categories:f,assignments:m,selectedDayId:S,selectedPlaceId:C,selectedAssignmentId:U,onSelectDay:N=>{Et(N),Ee(null)},onPlaceClick:pt,onReorder:Ie,onUpdateDayTitle:At,onAssignToDay:It,onRouteCalculated:N=>{N&&(De(N.coordinates),Qe({distance:N.distanceText,duration:N.durationText}))},reservations:y,onAddReservation:N=>{Pe(null),s.setSelectedDay(N),G(!0),Ee(null)},onDayDetail:N=>{be(N),q(null),setSelectedAssignmentId(null),Ee(null)},accommodations:E,onNavigateToFiles:()=>{Ee(null),X("dateien")}}):r.jsx(F0,{tripId:e,places:p,categories:f,assignments:m,selectedDayId:S,selectedPlaceId:C,onPlaceClick:pt,onAddPlace:()=>{ce(null),je(!0),Ee(null)},onAssignToDay:It,days:c,isMobile:!0,onCategoryFilterChange:Gt})})]})}),document.body)]}),H==="buchungen"&&r.jsx("div",{style:{height:"100%",maxWidth:1200,margin:"0 auto",width:"100%",display:"flex",flexDirection:"column",overflowY:"auto",overscrollBehavior:"contain"},children:r.jsx(D4,{tripId:e,reservations:y,days:c,assignments:m,files:k,onAdd:()=>{Pe(null),G(!0)},onEdit:N=>{Pe(N),G(!0)},onDelete:ba,onNavigateToFiles:()=>X("dateien")})}),H==="packliste"&&r.jsx("div",{style:{height:"100%",overflowY:"auto",overscrollBehavior:"contain",maxWidth:1200,margin:"0 auto",width:"100%",padding:"8px 0"},children:r.jsx(F4,{tripId:e,items:g})}),H==="finanzplan"&&r.jsx("div",{style:{height:"100%",overflowY:"auto",overscrollBehavior:"contain",maxWidth:1800,margin:"0 auto",width:"100%",padding:"8px 0"},children:r.jsx(ZL,{tripId:e,tripMembers:R})}),H==="dateien"&&r.jsx("div",{style:{height:"100%",overflow:"hidden",overscrollBehavior:"contain"},children:r.jsx(cC,{files:k||[],onUpload:N=>s.addFile(e,N),onDelete:N=>s.deleteFile(e,N),onUpdate:(N,se)=>s.loadFiles(e),places:p,days:c,assignments:m,reservations:y,tripId:e,allowedFileTypes:A})}),H==="memories"&&r.jsx("div",{style:{position:"absolute",inset:0,overflow:"hidden"},children:r.jsx(N4,{tripId:Number(e),startDate:(d==null?void 0:d.start_date)||null,endDate:(d==null?void 0:d.end_date)||null})}),H==="collab"&&r.jsx("div",{style:{position:"absolute",inset:0,overflow:"hidden"},children:r.jsx(r7,{tripId:e,tripMembers:R})})]}),r.jsx(j4,{isOpen:Se,onClose:()=>{je(!1),ce(null),_e(null),K(null)},onSave:Ot,place:we,prefillCoords:le,assignmentId:de,dayAssignments:de?Object.values(m).flat():[],tripId:e,categories:f,onCategoryCreated:N=>{var se;return(se=s.addCategory)==null?void 0:se.call(s,N)}}),r.jsx(T_,{isOpen:pe,onClose:()=>Ae(!1),onSave:async N=>{await s.updateTrip(e,N),a.success(n("trip.toast.tripUpdated"))},trip:d}),r.jsx(T4,{isOpen:He,onClose:()=>ze(!1),tripId:e,tripTitle:d==null?void 0:d.title}),r.jsx(A4,{isOpen:Ye,onClose:()=>{G(!1),Pe(null)},onSave:va,reservation:ve,days:c,places:p,assignments:m,selectedDayId:S,files:k,onFileUpload:N=>s.addFile(e,N),onFileDelete:N=>s.deleteFile(e,N),accommodations:E}),r.jsx(i7,{isOpen:!!Oe,onClose:()=>Ke(null),onConfirm:Za,title:n("common.delete"),message:n("trip.confirm.deletePlace")})]}):null}function u7(){const{t:e}=ot(),{id:t}=wm(),a=Br(),n=Rn(),[i,o]=b.useState(null),[s,d]=b.useState([]),[c,p]=b.useState([]),[m,g]=b.useState(!0);b.useEffect(()=>{f()},[t]);const f=async()=>{g(!0);try{const[k,S]=await Promise.all([Ba.get(t),io.list(t)]);o(k.trip),d(S.places),await n.loadFiles(t)}catch{a("/dashboard")}finally{g(!1)}};b.useEffect(()=>{p(n.files)},[n.files]);const y=async k=>{await n.addFile(t,k)},x=async k=>{await n.deleteFile(t,k)};return m?r.jsx("div",{className:"min-h-screen flex items-center justify-center bg-slate-50",children:r.jsx("div",{className:"w-10 h-10 border-4 border-slate-200 border-t-slate-700 rounded-full animate-spin"})}):r.jsxs("div",{className:"min-h-screen bg-slate-50",children:[r.jsx(Mi,{tripTitle:i==null?void 0:i.name,tripId:t,showBack:!0,onBack:()=>a(`/trips/${t}`)}),r.jsx("div",{style:{paddingTop:"var(--nav-h)"},children:r.jsxs("div",{className:"max-w-5xl mx-auto px-4 py-6",children:[r.jsx("div",{className:"flex items-center gap-3 mb-6",children:r.jsxs(Rs,{to:`/trips/${t}`,className:"flex items-center gap-1 text-sm text-gray-500 hover:text-gray-700",children:[r.jsx(d_,{className:"w-4 h-4"}),e("common.backToPlanning")]})}),r.jsx("div",{className:"flex items-center justify-between mb-6",children:r.jsxs("div",{children:[r.jsx("h1",{className:"text-2xl font-bold text-gray-900",children:"Dateien & Dokumente"}),r.jsxs("p",{className:"text-gray-500 text-sm",children:[c.length," Dateien für ",i==null?void 0:i.name]})]})}),r.jsx(cC,{files:c,onUpload:y,onDelete:x,places:s,tripId:t})]})})]})}const uw=["#6366f1","#8b5cf6","#ec4899","#ef4444","#f97316","#f59e0b","#10b981","#06b6d4","#3b82f6","#84cc16","#6b7280","#1f2937"],p7=Object.keys(eb);function m7(){const[e,t]=b.useState([]),[a,n]=b.useState(!1),[i,o]=b.useState(null),[s,d]=b.useState({name:"",color:"#6366f1",icon:"MapPin"}),[c,p]=b.useState(!1),[m,g]=b.useState(!0),f=b.useRef(null),y=ya(),{t:x}=ot();b.useEffect(()=>{k()},[]);const k=async()=>{g(!0);try{const R=await Qo.list();t(R.categories||[])}catch{y.error(x("categories.toast.loadError"))}finally{g(!1)}},S=R=>{o(R.id),d({name:R.name,color:R.color||"#6366f1",icon:R.icon||"MapPin"}),n(!1)},v=()=>{o(null),d({name:"",color:"#6366f1",icon:"MapPin"}),n(!0)},_=()=>{n(!1),o(null)},w=async()=>{if(!s.name.trim()){y.error(x("categories.toast.nameRequired"));return}p(!0);try{if(i){const R=await Qo.update(i,s);t($=>$.map(I=>I.id===i?R.category:I)),o(null),y.success(x("categories.toast.updated"))}else{const R=await Qo.create(s);t($=>[...$,R.category]),n(!1),y.success(x("categories.toast.created"))}d({name:"",color:"#6366f1",icon:"MapPin"})}catch(R){y.error(at(R,x("categories.toast.saveError")))}finally{p(!1)}},E=async R=>{if(confirm(x("categories.confirm.delete")))try{await Qo.delete(R),t($=>$.filter(I=>I.id!==R)),y.success(x("categories.toast.deleted"))}catch($){y.error(at($,x("categories.toast.deleteError")))}},M=uw.includes(s.color),A=ci(s.icon),P=r.jsxs("div",{className:"bg-gray-50 rounded-xl p-4 space-y-3 border border-gray-200",children:[r.jsx("input",{type:"text",value:s.name,onChange:R=>d($=>({...$,name:R.target.value})),placeholder:x("categories.namePlaceholder"),className:"w-full border border-gray-200 rounded-lg px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-slate-400 bg-white",autoFocus:!0}),r.jsxs("div",{children:[r.jsx("label",{className:"block text-xs font-medium text-gray-600 mb-2",children:x("categories.icon")}),r.jsx("div",{className:"max-h-48 overflow-y-auto",children:r.jsx("div",{className:"flex flex-wrap gap-1.5 px-1.5 py-1.5",children:p7.map(R=>{const $=eb[R],I=s.icon===R;return r.jsx("button",{type:"button",title:TI[R]||R,onClick:()=>d(Y=>({...Y,icon:R})),className:`w-9 h-9 flex items-center justify-center rounded-lg transition-all ${I?"ring-2 ring-offset-1 ring-slate-700":"hover:bg-gray-200"}`,style:{background:I?`${s.color}18`:void 0},children:r.jsx($,{size:17,strokeWidth:1.8,color:I?s.color:"#374151"})},R)})})})]}),r.jsxs("div",{children:[r.jsx("label",{className:"block text-xs font-medium text-gray-600 mb-1.5",children:x("categories.color")}),r.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[uw.map(R=>r.jsx("button",{type:"button",onClick:()=>d($=>({...$,color:R})),className:`w-7 h-7 rounded-full transition-transform hover:scale-110 ${s.color===R?"ring-2 ring-offset-2 ring-gray-400 scale-110":""}`,style:{backgroundColor:R}},R)),r.jsx("input",{ref:f,type:"color",value:s.color,onChange:R=>d($=>({...$,color:R.target.value})),className:"sr-only"}),r.jsx("button",{type:"button",title:x("categories.customColor"),onClick:()=>{var R;return(R=f.current)==null?void 0:R.click()},className:`w-7 h-7 rounded-full flex items-center justify-center border-2 transition-transform hover:scale-110 ${M?"border-dashed border-gray-300 hover:border-gray-400":"ring-2 ring-offset-2 ring-gray-400 scale-110 border-transparent"}`,style:M?void 0:{backgroundColor:s.color},children:M&&r.jsx(sD,{className:"w-3 h-3 text-gray-400"})})]})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs("span",{className:"text-xs text-gray-500",children:[x("categories.preview"),":"]}),r.jsxs("span",{className:"inline-flex items-center gap-1.5 text-sm px-2.5 py-1 rounded-full font-medium",style:{backgroundColor:`${s.color}20`,color:s.color},children:[r.jsx(A,{size:14,strokeWidth:1.8}),s.name||x("categories.defaultName")]})]}),r.jsxs("div",{className:"flex justify-end gap-2",children:[r.jsx("button",{type:"button",onClick:_,className:"px-3 py-1.5 text-sm text-gray-600 border border-gray-200 rounded-lg hover:bg-gray-50",children:x("common.cancel")}),r.jsx("button",{type:"button",onClick:w,disabled:c||!s.name.trim(),className:"px-4 py-1.5 text-sm bg-slate-900 text-white rounded-lg hover:bg-slate-700 disabled:opacity-60 font-medium",children:x(c?"common.saving":i?"categories.update":"categories.create")})]})]});return r.jsxs("div",{className:"bg-white rounded-2xl border border-gray-200 p-6",children:[r.jsxs("div",{className:"flex items-center justify-between mb-6",children:[r.jsxs("div",{children:[r.jsx("h2",{className:"font-semibold",style:{color:"var(--text-primary)"},children:x("categories.title")}),r.jsx("p",{className:"text-xs mt-1",style:{color:"var(--text-muted)"},children:x("categories.subtitle")})]}),r.jsxs("button",{onClick:v,className:"flex items-center gap-2 bg-slate-900 text-white px-3 sm:px-4 py-2 rounded-lg hover:bg-slate-700 text-sm font-medium",children:[r.jsx(Ft,{className:"w-4 h-4"}),r.jsx("span",{className:"hidden sm:inline",children:x("categories.new")})]})]}),a&&r.jsx("div",{className:"mb-4",children:P}),m?r.jsx("div",{className:"flex items-center justify-center py-8 text-gray-400",children:r.jsx("div",{className:"w-6 h-6 border-2 border-gray-300 border-t-slate-600 rounded-full animate-spin"})}):e.length===0?r.jsx("div",{className:"text-center py-8 text-gray-400",children:r.jsx("p",{className:"text-sm",children:x("categories.empty")})}):r.jsx("div",{className:"space-y-2",children:e.map(R=>{const $=ci(R.icon);return r.jsx("div",{children:i===R.id?r.jsx("div",{className:"mb-2",children:P}):r.jsxs("div",{className:"flex items-center gap-3 p-3 border border-gray-100 rounded-xl hover:border-gray-200 group",children:[r.jsx("div",{className:"w-10 h-10 rounded-xl flex items-center justify-center flex-shrink-0",style:{backgroundColor:`${R.color}20`},children:r.jsx($,{size:18,strokeWidth:1.8,color:R.color})}),r.jsx("div",{className:"flex-1 min-w-0",children:r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"font-medium text-gray-900 text-sm",children:R.name}),r.jsx("span",{className:"text-xs px-2 py-0.5 rounded-full",style:{backgroundColor:`${R.color}20`,color:R.color},children:R.color})]})}),r.jsxs("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[r.jsx("button",{onClick:()=>S(R),className:"p-1.5 text-gray-400 hover:text-slate-700 hover:bg-slate-100 rounded-lg",children:r.jsx(Ci,{className:"w-4 h-4"})}),r.jsx("button",{onClick:()=>E(R.id),className:"p-1.5 text-gray-400 hover:text-red-600 hover:bg-red-50 rounded-lg",children:r.jsx(_t,{className:"w-4 h-4"})})]})]})},R.id)})})]})}const g7=[{value:"hourly",labelKey:"backup.interval.hourly"},{value:"daily",labelKey:"backup.interval.daily"},{value:"weekly",labelKey:"backup.interval.weekly"},{value:"monthly",labelKey:"backup.interval.monthly"}],h7=[{value:1,labelKey:"backup.keep.1day"},{value:3,labelKey:"backup.keep.3days"},{value:7,labelKey:"backup.keep.7days"},{value:14,labelKey:"backup.keep.14days"},{value:30,labelKey:"backup.keep.30days"},{value:0,labelKey:"backup.keep.forever"}],f7=[{value:0,labelKey:"backup.dow.sunday"},{value:1,labelKey:"backup.dow.monday"},{value:2,labelKey:"backup.dow.tuesday"},{value:3,labelKey:"backup.dow.wednesday"},{value:4,labelKey:"backup.dow.thursday"},{value:5,labelKey:"backup.dow.friday"},{value:6,labelKey:"backup.dow.saturday"}],y7=Array.from({length:24},(e,t)=>t),v7=Array.from({length:28},(e,t)=>t+1);function b7(){const[e,t]=b.useState([]),[a,n]=b.useState(!1),[i,o]=b.useState(!1),[s,d]=b.useState(null),[c,p]=b.useState(!1),[m,g]=b.useState({enabled:!1,interval:"daily",keep_days:7,hour:2,day_of_week:0,day_of_month:1}),[f,y]=b.useState(!1),[x,k]=b.useState(!1),[S,v]=b.useState(""),[_,w]=b.useState(null),E=b.useRef(null),M=ya(),{t:A,language:P,locale:R}=ot(),$=ta(B=>B.settings.time_format)==="12h",I=async()=>{n(!0);try{const B=await yi.list();t(B.backups||[])}catch{M.error(A("backup.toast.loadError"))}finally{n(!1)}},Y=async()=>{try{const B=await yi.getAutoSettings();g(B.settings),B.timezone&&v(B.timezone)}catch{}};b.useEffect(()=>{I(),Y()},[]);const H=async()=>{o(!0);try{await yi.create(),M.success(A("backup.toast.created")),await I()}catch{M.error(A("backup.toast.createError"))}finally{o(!1)}},V=B=>{w({type:"file",filename:B})},X=B=>{var U;const C=(U=B.target.files)==null?void 0:U[0];C&&(B.target.value="",w({type:"upload",filename:C.name,file:C}))},Z=async()=>{if(!_)return;const{type:B,filename:C,file:U}=_;if(w(null),B==="file"){d(C);try{await yi.restore(C),M.success(A("backup.toast.restored")),setTimeout(()=>window.location.reload(),1500)}catch(q){M.error(at(q,A("backup.toast.restoreError"))),d(null)}}else{p(!0);try{await yi.uploadRestore(U),M.success(A("backup.toast.restored")),setTimeout(()=>window.location.reload(),1500)}catch(q){M.error(at(q,A("backup.toast.uploadError"))),p(!1)}}},O=async B=>{if(confirm(A("backup.confirm.delete",{name:B})))try{await yi.delete(B),M.success(A("backup.toast.deleted")),t(C=>C.filter(U=>U.filename!==B))}catch{M.error(A("backup.toast.deleteError"))}},Q=(B,C)=>{g(U=>({...U,[B]:C})),k(!0)},D=async()=>{y(!0);try{const B=await yi.setAutoSettings(m);g(B.settings),k(!1),M.success(A("backup.toast.settingsSaved"))}catch{M.error(A("backup.toast.settingsError"))}finally{y(!1)}},J=B=>B?B<1024*1024?`${(B/1024).toFixed(1)} KB`:`${(B/1024/1024).toFixed(1)} MB`:"-",z=B=>{if(!B)return"-";try{const C={day:"2-digit",month:"2-digit",year:"numeric",hour:"2-digit",minute:"2-digit"};return S&&(C.timeZone=S),new Date(B).toLocaleString(R,C)}catch{return B}},W=B=>B.startsWith("auto-backup-");return r.jsxs("div",{className:"flex flex-col gap-6",children:[r.jsxs("div",{className:"bg-white rounded-2xl border border-gray-200 p-6",children:[r.jsxs("div",{className:"flex items-center justify-between mb-6",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx(Qg,{className:"w-5 h-5 text-gray-400"}),r.jsxs("div",{children:[r.jsx("h2",{className:"font-semibold",style:{color:"var(--text-primary)"},children:A("backup.title")}),r.jsx("p",{className:"text-xs mt-1",style:{color:"var(--text-muted)"},children:A("backup.subtitle")})]})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("button",{onClick:I,disabled:a,className:"p-2 text-gray-500 hover:bg-gray-100 rounded-lg transition-colors",title:A("backup.refresh"),children:r.jsx(ic,{className:`w-4 h-4 ${a?"animate-spin":""}`})}),r.jsx("input",{ref:E,type:"file",accept:".zip",className:"hidden",onChange:X}),r.jsxs("button",{onClick:()=>{var B;return(B=E.current)==null?void 0:B.click()},disabled:c,className:"flex items-center gap-2 border border-gray-200 text-gray-700 px-3 py-2 rounded-lg hover:bg-gray-50 text-sm font-medium disabled:opacity-60",title:A(c?"backup.uploading":"backup.upload"),children:[c?r.jsx("div",{className:"w-4 h-4 border-2 border-gray-400 border-t-transparent rounded-full animate-spin"}):r.jsx(So,{className:"w-4 h-4"}),r.jsx("span",{className:"hidden sm:inline",children:A(c?"backup.uploading":"backup.upload")})]}),r.jsxs("button",{onClick:H,disabled:i,className:"flex items-center gap-2 bg-slate-900 dark:bg-slate-100 text-white dark:text-slate-900 px-3 sm:px-4 py-2 rounded-lg hover:bg-slate-900 text-sm font-medium disabled:opacity-60",title:A(i?"backup.creating":"backup.create"),children:[i?r.jsx("div",{className:"w-4 h-4 border-2 border-white border-t-transparent rounded-full animate-spin"}):r.jsx(Ft,{className:"w-4 h-4"}),r.jsx("span",{className:"hidden sm:inline",children:A(i?"backup.creating":"backup.create")})]})]})]}),a&&e.length===0?r.jsxs("div",{className:"flex items-center justify-center py-12 text-gray-400",children:[r.jsx("div",{className:"w-6 h-6 border-2 border-gray-300 border-t-slate-700 rounded-full animate-spin mr-2"}),A("common.loading")]}):e.length===0?r.jsxs("div",{className:"text-center py-12 text-gray-400",children:[r.jsx(Qg,{className:"w-10 h-10 mb-3 mx-auto opacity-40"}),r.jsx("p",{className:"text-sm",children:A("backup.empty")}),r.jsx("button",{onClick:H,className:"mt-4 text-slate-700 text-sm hover:underline",children:A("backup.createFirst")})]}):r.jsx("div",{className:"divide-y divide-gray-100",children:e.map(B=>r.jsxs("div",{className:"flex items-center gap-4 py-3",children:[r.jsx("div",{className:"w-8 h-8 rounded-lg bg-gray-100 flex items-center justify-center flex-shrink-0",children:W(B.filename)?r.jsx(ic,{className:"w-4 h-4 text-blue-500"}):r.jsx(Qg,{className:"w-4 h-4 text-gray-500"})}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("p",{className:"font-medium text-sm text-gray-900 truncate",children:B.filename}),W(B.filename)&&r.jsx("span",{className:"text-xs bg-blue-50 text-blue-600 border border-blue-100 rounded-full px-2 py-0.5 whitespace-nowrap",children:"Auto"})]}),r.jsxs("div",{className:"flex items-center gap-3 mt-0.5",children:[r.jsx("span",{className:"text-xs text-gray-400",children:z(B.created_at)}),r.jsx("span",{className:"text-xs text-gray-400",children:J(B.size)})]})]}),r.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[r.jsxs("button",{onClick:()=>yi.download(B.filename).catch(()=>M.error(A("backup.toast.downloadError"))),className:"flex items-center gap-1.5 px-3 py-1.5 text-xs text-slate-700 border border-slate-200 rounded-lg hover:bg-slate-50",children:[r.jsx(Xs,{className:"w-3.5 h-3.5"}),A("backup.download")]}),r.jsxs("button",{onClick:()=>V(B.filename),disabled:s===B.filename,className:"flex items-center gap-1.5 px-3 py-1.5 text-xs text-amber-700 border border-amber-200 rounded-lg hover:bg-amber-50 disabled:opacity-60",children:[s===B.filename?r.jsx("div",{className:"w-3.5 h-3.5 border-2 border-amber-400 border-t-transparent rounded-full animate-spin"}):r.jsx(Fm,{className:"w-3.5 h-3.5"}),A("backup.restore")]}),r.jsx("button",{onClick:()=>O(B.filename),className:"p-1.5 text-gray-400 hover:text-red-600 hover:bg-red-50 rounded-lg",children:r.jsx(_t,{className:"w-4 h-4"})})]})]},B.filename))})]}),r.jsxs("div",{className:"bg-white rounded-2xl border border-gray-200 p-6",children:[r.jsxs("div",{className:"flex items-center gap-3 mb-6",children:[r.jsx(Nn,{className:"w-5 h-5 text-gray-400"}),r.jsxs("div",{children:[r.jsx("h2",{className:"font-semibold",style:{color:"var(--text-primary)"},children:A("backup.auto.title")}),r.jsx("p",{className:"text-xs mt-1",style:{color:"var(--text-muted)"},children:A("backup.auto.subtitle")})]})]}),r.jsxs("div",{className:"flex flex-col gap-5",children:[r.jsxs("label",{className:"flex items-center justify-between gap-4 cursor-pointer",children:[r.jsxs("div",{className:"min-w-0",children:[r.jsx("span",{className:"text-sm font-medium text-gray-900",children:A("backup.auto.enable")}),r.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:A("backup.auto.enableHint")})]}),r.jsx("button",{onClick:()=>Q("enabled",!m.enabled),className:`relative shrink-0 inline-flex h-6 w-11 items-center rounded-full transition-colors ${m.enabled?"bg-slate-900 dark:bg-slate-100":"bg-gray-200 dark:bg-gray-600"}`,children:r.jsx("span",{className:`absolute left-1 h-4 w-4 rounded-full bg-white shadow transition-transform duration-200 ${m.enabled?"translate-x-5":"translate-x-0"}`})})]}),m.enabled&&r.jsxs(r.Fragment,{children:[r.jsxs("div",{children:[r.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:A("backup.auto.interval")}),r.jsx("div",{className:"flex flex-wrap gap-2",children:g7.map(B=>r.jsx("button",{onClick:()=>Q("interval",B.value),className:`px-4 py-2 rounded-lg text-sm font-medium border transition-colors ${m.interval===B.value?"bg-slate-900 dark:bg-slate-100 text-white dark:text-slate-900 border-slate-700":"bg-white text-gray-600 border-gray-200 hover:border-gray-300"}`,children:A(B.labelKey)},B.value))})]}),m.interval!=="hourly"&&r.jsxs("div",{children:[r.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:A("backup.auto.hour")}),r.jsx(ea,{value:String(m.hour),onChange:B=>Q("hour",parseInt(B,10)),size:"sm",options:y7.map(B=>{let C;if($){const U=B>=12?"PM":"AM";C=`${B===0?12:B>12?B-12:B}:00 ${U}`}else C=`${String(B).padStart(2,"0")}:00`;return{value:String(B),label:C}})}),r.jsxs("p",{className:"text-xs text-gray-400 mt-1",children:[A("backup.auto.hourHint",{format:$?"12h":"24h"}),S?` (Timezone: ${S})`:""]})]}),m.interval==="weekly"&&r.jsxs("div",{children:[r.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:A("backup.auto.dayOfWeek")}),r.jsx("div",{className:"flex flex-wrap gap-2",children:f7.map(B=>r.jsx("button",{onClick:()=>Q("day_of_week",B.value),className:`px-3 py-2 rounded-lg text-sm font-medium border transition-colors ${m.day_of_week===B.value?"bg-slate-900 dark:bg-slate-100 text-white dark:text-slate-900 border-slate-700":"bg-white text-gray-600 border-gray-200 hover:border-gray-300"}`,children:A(B.labelKey)},B.value))})]}),m.interval==="monthly"&&r.jsxs("div",{children:[r.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:A("backup.auto.dayOfMonth")}),r.jsx(ea,{value:String(m.day_of_month),onChange:B=>Q("day_of_month",parseInt(B,10)),size:"sm",options:v7.map(B=>({value:String(B),label:String(B)}))}),r.jsx("p",{className:"text-xs text-gray-400 mt-1",children:A("backup.auto.dayOfMonthHint")})]}),r.jsxs("div",{children:[r.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:A("backup.auto.keepLabel")}),r.jsx("div",{className:"flex flex-wrap gap-2",children:h7.map(B=>r.jsx("button",{onClick:()=>Q("keep_days",B.value),className:`px-4 py-2 rounded-lg text-sm font-medium border transition-colors ${m.keep_days===B.value?"bg-slate-900 dark:bg-slate-100 text-white dark:text-slate-900 border-slate-700":"bg-white text-gray-600 border-gray-200 hover:border-gray-300"}`,children:A(B.labelKey)},B.value))})]})]}),r.jsx("div",{className:"flex justify-end pt-2 border-t border-gray-100",children:r.jsxs("button",{onClick:D,disabled:f||!x,className:"flex items-center gap-2 bg-slate-900 dark:bg-slate-100 text-white dark:text-slate-900 px-5 py-2 rounded-lg hover:bg-slate-900 text-sm font-medium disabled:opacity-50 transition-colors",children:[f?r.jsx("div",{className:"w-4 h-4 border-2 border-white border-t-transparent rounded-full animate-spin"}):r.jsx(Ga,{className:"w-4 h-4"}),A(f?"common.saving":"common.save")]})})]})]}),_&&r.jsx("div",{style:{position:"fixed",inset:0,zIndex:9999,background:"rgba(0,0,0,0.5)",backdropFilter:"blur(4px)",display:"flex",alignItems:"center",justifyContent:"center",padding:16},onClick:()=>w(null),children:r.jsxs("div",{onClick:B=>B.stopPropagation(),style:{width:"100%",maxWidth:440,borderRadius:16,overflow:"hidden"},className:"bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700",children:[r.jsxs("div",{style:{background:"linear-gradient(135deg, #dc2626, #b91c1c)",padding:"20px 24px",display:"flex",alignItems:"center",gap:12},children:[r.jsx("div",{style:{width:40,height:40,borderRadius:10,background:"rgba(255,255,255,0.2)",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:r.jsx(li,{size:20,style:{color:"white"}})}),r.jsxs("div",{children:[r.jsx("h3",{style:{margin:0,fontSize:16,fontWeight:700,color:"white"},children:A("backup.restoreConfirmTitle")}),r.jsx("p",{style:{margin:"2px 0 0",fontSize:12,color:"rgba(255,255,255,0.8)"},children:_.filename})]})]}),r.jsxs("div",{style:{padding:"20px 24px"},children:[r.jsx("p",{className:"text-gray-700 dark:text-gray-300",style:{fontSize:13,lineHeight:1.6,margin:0},children:A("backup.restoreWarning")}),r.jsx("div",{style:{marginTop:14,padding:"10px 12px",borderRadius:10,fontSize:12,lineHeight:1.5},className:"bg-red-50 dark:bg-red-900/30 text-red-700 dark:text-red-300 border border-red-200 dark:border-red-800",children:A("backup.restoreTip")})]}),r.jsxs("div",{style:{padding:"0 24px 20px",display:"flex",gap:10,justifyContent:"flex-end"},children:[r.jsx("button",{onClick:()=>w(null),className:"text-gray-600 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700",style:{padding:"9px 20px",borderRadius:10,fontSize:13,fontWeight:600,border:"none",cursor:"pointer",fontFamily:"inherit"},children:A("common.cancel")}),r.jsx("button",{onClick:Z,style:{padding:"9px 20px",borderRadius:10,fontSize:13,fontWeight:600,border:"none",cursor:"pointer",fontFamily:"inherit",background:"#dc2626",color:"white"},onMouseEnter:B=>B.currentTarget.style.background="#b91c1c",onMouseLeave:B=>B.currentTarget.style.background="#dc2626",children:A("backup.restoreConfirm")})]})]})})]})}const pw="mauriceboe/NOMAD",mw=10;function x7(){const{t:e,language:t}=ot(),[a,n]=b.useState([]),[i,o]=b.useState(!0),[s,d]=b.useState(null),[c,p]=b.useState({}),[m,g]=b.useState(1),[f,y]=b.useState(!0),[x,k]=b.useState(!1),S=async(M=1,A=!1)=>{try{const P=await ie.get("/admin/github-releases",{params:{per_page:mw,page:M}}),R=Array.isArray(P.data)?P.data:[];n($=>A?[...$,...R]:R),y(R.length===mw)}catch(P){d(P instanceof Error?P.message:"Unknown error")}};b.useEffect(()=>{o(!0),S(1).finally(()=>o(!1))},[]);const v=async()=>{const M=m+1;k(!0),await S(M,!0),g(M),k(!1)},_=M=>{p(A=>({...A,[M]:!A[M]}))},w=M=>new Date(M).toLocaleDateString(Pm(t),{day:"numeric",month:"short",year:"numeric"}),E=M=>{if(!M)return null;const A=M.split(`
+`),P=[];let R=[];const $=()=>{R.length>0&&(P.push(r.jsx("ul",{className:"space-y-1 my-2",children:R.map((H,V)=>r.jsxs("li",{className:"flex gap-2 text-xs",style:{color:"var(--text-muted)"},children:[r.jsx("span",{className:"mt-1.5 w-1 h-1 rounded-full flex-shrink-0",style:{background:"var(--text-faint)"}}),r.jsx("span",{dangerouslySetInnerHTML:{__html:Y(H)}})]},V))},`ul-${P.length}`)),R=[])},I=H=>H.replace(/&/g,"&").replace(//g,">").replace(/"/g,"""),Y=H=>I(H).replace(/\*\*(.+?)\*\*/g,"$1").replace(/`(.+?)`/g,'$1').replace(/\[([^\]]+)\]\(([^)]+)\)/g,(V,X,Z)=>{const O=Z.startsWith("http://")||Z.startsWith("https://")?Z:"#";return`${X}`});for(const H of A){const V=H.trim();if(!V){$();continue}V.startsWith("### ")?($(),P.push(r.jsx("h4",{className:"text-xs font-semibold mt-3 mb-1",style:{color:"var(--text-primary)"},children:V.slice(4)},P.length))):V.startsWith("## ")?($(),P.push(r.jsx("h3",{className:"text-sm font-semibold mt-3 mb-1",style:{color:"var(--text-primary)"},children:V.slice(3)},P.length))):/^[-*] /.test(V)?R.push(V.slice(2)):($(),P.push(r.jsx("p",{className:"text-xs my-1",style:{color:"var(--text-muted)"},dangerouslySetInnerHTML:{__html:Y(V)}},P.length)))}return $(),P};return r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[r.jsxs("a",{href:"https://ko-fi.com/mauriceboe",target:"_blank",rel:"noopener noreferrer",className:"rounded-xl border overflow-hidden flex items-center gap-4 px-5 py-4 transition-all",style:{background:"var(--bg-card)",borderColor:"var(--border-primary)",textDecoration:"none"},onMouseEnter:M=>{M.currentTarget.style.borderColor="#ff5e5b",M.currentTarget.style.boxShadow="0 0 0 1px #ff5e5b22"},onMouseLeave:M=>{M.currentTarget.style.borderColor="var(--border-primary)",M.currentTarget.style.boxShadow="none"},children:[r.jsx("div",{style:{width:40,height:40,borderRadius:10,background:"#ff5e5b15",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:r.jsx(Rm,{size:20,style:{color:"#ff5e5b"}})}),r.jsxs("div",{children:[r.jsx("div",{className:"text-sm font-semibold",style:{color:"var(--text-primary)"},children:"Ko-fi"}),r.jsx("div",{className:"text-xs",style:{color:"var(--text-faint)"},children:e("admin.github.support")})]}),r.jsx(xn,{size:14,className:"ml-auto flex-shrink-0",style:{color:"var(--text-faint)"}})]}),r.jsxs("a",{href:"https://buymeacoffee.com/mauriceboe",target:"_blank",rel:"noopener noreferrer",className:"rounded-xl border overflow-hidden flex items-center gap-4 px-5 py-4 transition-all",style:{background:"var(--bg-card)",borderColor:"var(--border-primary)",textDecoration:"none"},onMouseEnter:M=>{M.currentTarget.style.borderColor="#ffdd00",M.currentTarget.style.boxShadow="0 0 0 1px #ffdd0022"},onMouseLeave:M=>{M.currentTarget.style.borderColor="var(--border-primary)",M.currentTarget.style.boxShadow="none"},children:[r.jsx("div",{style:{width:40,height:40,borderRadius:10,background:"#ffdd0015",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:r.jsx(Dm,{size:20,style:{color:"#ffdd00"}})}),r.jsxs("div",{children:[r.jsx("div",{className:"text-sm font-semibold",style:{color:"var(--text-primary)"},children:"Buy Me a Coffee"}),r.jsx("div",{className:"text-xs",style:{color:"var(--text-faint)"},children:e("admin.github.support")})]}),r.jsx(xn,{size:14,className:"ml-auto flex-shrink-0",style:{color:"var(--text-faint)"}})]})]}),i?r.jsx("div",{className:"rounded-xl border overflow-hidden",style:{background:"var(--bg-card)",borderColor:"var(--border-primary)"},children:r.jsx("div",{className:"p-8 flex items-center justify-center",children:r.jsx(wl,{className:"w-6 h-6 animate-spin",style:{color:"var(--text-muted)"}})})}):s?r.jsx("div",{className:"rounded-xl border overflow-hidden",style:{background:"var(--bg-card)",borderColor:"var(--border-primary)"},children:r.jsxs("div",{className:"p-6 text-center",children:[r.jsx("p",{className:"text-sm",style:{color:"var(--text-muted)"},children:e("admin.github.error")}),r.jsx("p",{className:"text-xs mt-1",style:{color:"var(--text-faint)"},children:s})]})}):r.jsxs("div",{className:"rounded-xl border overflow-hidden",style:{background:"var(--bg-card)",borderColor:"var(--border-primary)"},children:[r.jsxs("div",{className:"px-5 py-4 border-b flex items-center justify-between",style:{borderColor:"var(--border-secondary)"},children:[r.jsxs("div",{children:[r.jsx("h2",{className:"font-semibold",style:{color:"var(--text-primary)"},children:e("admin.github.title")}),r.jsx("p",{className:"text-xs mt-0.5",style:{color:"var(--text-faint)"},children:e("admin.github.subtitle").replace("{repo}",pw)})]}),r.jsxs("a",{href:`https://github.com/${pw}/releases`,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-xs font-medium transition-colors",style:{background:"var(--bg-secondary)",color:"var(--text-muted)"},children:[r.jsx(xn,{size:12}),"GitHub"]})]}),r.jsxs("div",{className:"px-5 py-4",children:[r.jsxs("div",{className:"relative",children:[r.jsx("div",{className:"absolute left-[11px] top-3 bottom-3 w-px",style:{background:"var(--border-primary)"}}),r.jsx("div",{className:"space-y-0",children:a.map((M,A)=>{const P=A===0,R=c[M.id];return r.jsxs("div",{className:"relative pl-8 pb-5",children:[r.jsx("div",{className:"absolute left-0 top-1 w-[23px] h-[23px] rounded-full flex items-center justify-center border-2",style:{background:P?"var(--text-primary)":"var(--bg-card)",borderColor:P?"var(--text-primary)":"var(--border-primary)"},children:r.jsx(yD,{size:10,style:{color:P?"var(--bg-card)":"var(--text-faint)"}})}),r.jsxs("div",{children:[r.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[r.jsx("span",{className:"text-sm font-semibold",style:{color:"var(--text-primary)"},children:M.tag_name}),P&&r.jsx("span",{className:"text-[10px] font-semibold px-2 py-0.5 rounded-full",style:{background:"rgba(34,197,94,0.12)",color:"#16a34a"},children:e("admin.github.latest")}),M.prerelease&&r.jsx("span",{className:"text-[10px] font-semibold px-2 py-0.5 rounded-full",style:{background:"rgba(245,158,11,0.12)",color:"#d97706"},children:e("admin.github.prerelease")})]}),M.name&&M.name!==M.tag_name&&r.jsx("p",{className:"text-xs font-medium mt-0.5",style:{color:"var(--text-muted)"},children:M.name}),r.jsxs("div",{className:"flex items-center gap-3 mt-1",children:[r.jsxs("span",{className:"flex items-center gap-1 text-[11px]",style:{color:"var(--text-faint)"},children:[r.jsx(Ni,{size:10}),w(M.published_at||M.created_at)]}),M.author&&r.jsxs("span",{className:"text-[11px]",style:{color:"var(--text-faint)"},children:[e("admin.github.by")," ",M.author.login]})]}),M.body&&r.jsxs("div",{className:"mt-2",children:[r.jsxs("button",{onClick:()=>_(M.id),className:"flex items-center gap-1 text-[11px] font-medium transition-colors",style:{color:"var(--text-muted)"},children:[R?r.jsx(oi,{size:12}):r.jsx(en,{size:12}),e(R?"admin.github.hideDetails":"admin.github.showDetails")]}),R&&r.jsx("div",{className:"mt-2 p-3 rounded-lg",style:{background:"var(--bg-secondary)"},children:E(M.body)})]})]})]},M.id)})})]}),f&&r.jsx("div",{className:"text-center pt-2",children:r.jsxs("button",{onClick:v,disabled:x,className:"inline-flex items-center gap-2 px-4 py-2 rounded-lg text-xs font-medium transition-colors",style:{background:"var(--bg-secondary)",color:"var(--text-muted)"},children:[x?r.jsx(wl,{size:12,className:"animate-spin"}):r.jsx(en,{size:12}),e(x?"admin.github.loading":"admin.github.loadMore")]})})]})]})]})}const k7={ListChecks:k_,Wallet:Ml,FileText:Pa,CalendarDays:Nl,Puzzle:Lm,Globe:Ri,Briefcase:ys,Image:UM,Terminal:__,Link2:wo};function w7({name:e,size:t=20}){const a=k7[e]||Lm;return r.jsx(a,{size:t})}function S7({bagTrackingEnabled:e,onToggleBagTracking:t}){const{t:a}=ot(),n=ta(S=>S.settings.dark_mode),i=n===!0||n==="dark"||n==="auto"&&window.matchMedia("(prefers-color-scheme: dark)").matches,o=ya(),s=Uv(S=>S.loadAddons),[d,c]=b.useState([]),[p,m]=b.useState(!0);b.useEffect(()=>{g()},[]);const g=async()=>{m(!0);try{const S=await Rt.addons();c(S.addons)}catch{o.error(a("admin.addons.toast.error"))}finally{m(!1)}},f=async S=>{const v=!S.enabled;c(_=>_.map(w=>w.id===S.id?{...w,enabled:v}:w));try{await Rt.updateAddon(S.id,{enabled:v}),s(),o.success(a("admin.addons.toast.updated"))}catch{c(w=>w.map(E=>E.id===S.id?{...E,enabled:!v}:E)),o.error(a("admin.addons.toast.error"))}},y=d.filter(S=>S.type==="trip"),x=d.filter(S=>S.type==="global"),k=d.filter(S=>S.type==="integration");return p?r.jsx("div",{className:"p-8 text-center",children:r.jsx("div",{className:"w-8 h-8 border-2 border-slate-200 border-t-slate-900 rounded-full animate-spin mx-auto",style:{borderTopColor:"var(--text-primary)"}})}):r.jsx("div",{className:"space-y-6",children:r.jsxs("div",{className:"rounded-xl border overflow-hidden",style:{background:"var(--bg-card)",borderColor:"var(--border-primary)"},children:[r.jsxs("div",{className:"px-6 py-4 border-b",style:{borderColor:"var(--border-secondary)"},children:[r.jsx("h2",{className:"font-semibold",style:{color:"var(--text-primary)"},children:a("admin.addons.title")}),r.jsxs("p",{className:"text-xs mt-1",style:{color:"var(--text-muted)",display:"flex",alignItems:"center",gap:4,flexWrap:"wrap"},children:[a("admin.addons.subtitleBefore"),r.jsx("img",{src:i?"/text-light.svg":"/text-dark.svg",alt:"TREK",style:{height:11,display:"inline",verticalAlign:"middle",opacity:.7}}),a("admin.addons.subtitleAfter")]})]}),d.length===0?r.jsx("div",{className:"p-8 text-center text-sm",style:{color:"var(--text-faint)"},children:a("admin.addons.noAddons")}):r.jsxs("div",{children:[y.length>0&&r.jsxs("div",{children:[r.jsxs("div",{className:"px-6 py-2.5 border-b flex items-center gap-2",style:{background:"var(--bg-secondary)",borderColor:"var(--border-secondary)"},children:[r.jsx(ys,{size:13,style:{color:"var(--text-muted)"}}),r.jsxs("span",{className:"text-xs font-medium uppercase tracking-wider",style:{color:"var(--text-muted)"},children:[a("admin.addons.type.trip")," — ",a("admin.addons.tripHint")]})]}),y.map(S=>r.jsxs("div",{children:[r.jsx(jh,{addon:S,onToggle:f,t:a}),S.id==="packing"&&S.enabled&&t&&r.jsxs("div",{className:"flex items-center gap-4 px-6 py-3 border-b",style:{borderColor:"var(--border-secondary)",background:"var(--bg-secondary)",paddingLeft:70},children:[r.jsxs("div",{style:{flex:1,minWidth:0},children:[r.jsx("div",{className:"text-sm font-medium",style:{color:"var(--text-secondary)"},children:a("admin.bagTracking.title")}),r.jsx("div",{className:"text-xs mt-0.5",style:{color:"var(--text-faint)"},children:a("admin.bagTracking.subtitle")})]}),r.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[r.jsx("span",{className:"hidden sm:inline text-xs font-medium",style:{color:e?"var(--text-primary)":"var(--text-faint)"},children:a(e?"admin.addons.enabled":"admin.addons.disabled")}),r.jsx("button",{onClick:t,className:"relative inline-flex h-6 w-11 items-center rounded-full transition-colors",style:{background:e?"var(--text-primary)":"var(--border-primary)"},children:r.jsx("span",{className:"absolute left-0.5 h-5 w-5 rounded-full bg-white transition-transform duration-200",style:{transform:e?"translateX(20px)":"translateX(0)"}})})]})]})]},S.id))]}),x.length>0&&r.jsxs("div",{children:[r.jsxs("div",{className:"px-6 py-2.5 border-b border-t flex items-center gap-2",style:{background:"var(--bg-secondary)",borderColor:"var(--border-secondary)"},children:[r.jsx(Ri,{size:13,style:{color:"var(--text-muted)"}}),r.jsxs("span",{className:"text-xs font-medium uppercase tracking-wider",style:{color:"var(--text-muted)"},children:[a("admin.addons.type.global")," — ",a("admin.addons.globalHint")]})]}),x.map(S=>r.jsx(jh,{addon:S,onToggle:f,t:a},S.id))]}),k.length>0&&r.jsxs("div",{children:[r.jsxs("div",{className:"px-6 py-2.5 border-b border-t flex items-center gap-2",style:{background:"var(--bg-secondary)",borderColor:"var(--border-secondary)"},children:[r.jsx(wo,{size:13,style:{color:"var(--text-muted)"}}),r.jsxs("span",{className:"text-xs font-medium uppercase tracking-wider",style:{color:"var(--text-muted)"},children:[a("admin.addons.type.integration")," — ",a("admin.addons.integrationHint")]})]}),k.map(S=>r.jsx(jh,{addon:S,onToggle:f,t:a},S.id))]})]})]})})}function j7(e,t){const a=`admin.addons.catalog.${t.id}.name`,n=`admin.addons.catalog.${t.id}.description`,i=e(a),o=e(n);return{name:i!==a?i:t.name,description:o!==n?o:t.description}}function jh({addon:e,onToggle:t,t:a}){const i=j7(a,e);return r.jsxs("div",{className:"flex items-center gap-4 px-6 py-4 border-b transition-colors hover:opacity-95",style:{borderColor:"var(--border-secondary)",opacity:1,pointerEvents:"auto"},children:[r.jsx("div",{className:"w-10 h-10 rounded-xl flex items-center justify-center shrink-0",style:{background:"var(--bg-secondary)",color:"var(--text-primary)"},children:r.jsx(w7,{name:e.icon,size:20})}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-sm font-semibold",style:{color:"var(--text-primary)"},children:i.name}),!1,r.jsx("span",{className:"text-[10px] font-medium px-1.5 py-0.5 rounded-full",style:{background:"var(--bg-secondary)",color:"var(--text-muted)"},children:e.type==="global"?a("admin.addons.type.global"):e.type==="integration"?a("admin.addons.type.integration"):a("admin.addons.type.trip")})]}),r.jsx("p",{className:"text-xs mt-0.5",style:{color:"var(--text-muted)"},children:i.description})]}),r.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[r.jsx("span",{className:"hidden sm:inline text-xs font-medium",style:{color:e.enabled?"var(--text-primary)":"var(--text-faint)"},children:e.enabled?a("admin.addons.enabled"):a("admin.addons.disabled")}),r.jsx("button",{onClick:()=>t(e),disabled:!1,className:"relative inline-flex h-6 w-11 items-center rounded-full transition-colors",style:{background:e.enabled?"var(--text-primary)":"var(--border-primary)",cursor:"pointer"},children:r.jsx("span",{className:"inline-block h-4 w-4 transform rounded-full transition-transform",style:{background:"var(--bg-card)",transform:e.enabled?"translateX(22px)":"translateX(4px)"}})})]})]})}function _7(){const[e,t]=b.useState([]),[a,n]=b.useState(!0),[i,o]=b.useState(!1),[s,d]=b.useState(""),[c,p]=b.useState(null),[m,g]=b.useState([]),[f,y]=b.useState([]),[x,k]=b.useState(null),[S,v]=b.useState(""),[_,w]=b.useState(null),[E,M]=b.useState(""),[A,P]=b.useState(null),[R,$]=b.useState(""),[I,Y]=b.useState(!1),[H,V]=b.useState(""),[X,Z]=b.useState(null),[O,Q]=b.useState(""),D=b.useRef(null),J=ya(),{t:z}=ot();b.useEffect(()=>{W()},[]);const W=async()=>{n(!0);try{const K=await Rt.packingTemplates();t(K.templates||[])}catch{J.error(z("admin.packingTemplates.loadError"))}finally{n(!1)}},B=async K=>{if(c===K){p(null);return}p(K),Y(!1),Z(null);try{const de=await Rt.getPackingTemplate(K);g(de.categories||[]),y(de.items||[])}catch{J.error(z("admin.packingTemplates.loadError"))}},C=async()=>{if(s.trim())try{const K=await Rt.createPackingTemplate({name:s.trim()});t(de=>[{...K.template,item_count:0,category_count:0},...de]),d(""),o(!1),p(K.template.id),g([]),y([]),J.success(z("admin.packingTemplates.created"))}catch{J.error(z("admin.packingTemplates.createError"))}},U=async K=>{try{await Rt.deletePackingTemplate(K),t(de=>de.filter(_e=>_e.id!==K)),c===K&&p(null),J.success(z("admin.packingTemplates.deleted"))}catch{J.error(z("admin.packingTemplates.deleteError"))}},q=async K=>{if(!S.trim()){k(null);return}try{await Rt.updatePackingTemplate(K,{name:S.trim()}),t(de=>de.map(_e=>_e.id===K?{..._e,name:S.trim()}:_e)),k(null)}catch{J.error(z("admin.packingTemplates.saveError"))}},te=async()=>{if(!(!H.trim()||!c))try{const K=await Rt.addTemplateCategory(c,{name:H.trim()});g(de=>[...de,K.category]),V(""),Y(!1)}catch{J.error(z("admin.packingTemplates.saveError"))}},oe=async K=>{if(!E.trim()||!c){w(null);return}try{await Rt.updateTemplateCategory(c,K,{name:E.trim()}),g(de=>de.map(_e=>_e.id===K?{..._e,name:E.trim()}:_e)),w(null)}catch{J.error(z("admin.packingTemplates.saveError"))}},be=async K=>{if(c)try{await Rt.deleteTemplateCategory(c,K),g(de=>de.filter(_e=>_e.id!==K)),y(de=>de.filter(_e=>_e.category_id!==K))}catch{J.error(z("admin.packingTemplates.deleteError"))}},Se=async K=>{if(!(!O.trim()||!c))try{const de=await Rt.addTemplateItem(c,K,{name:O.trim()});y(_e=>[..._e,de.item]),Q(""),setTimeout(()=>{var _e;return(_e=D.current)==null?void 0:_e.focus()},30)}catch{J.error(z("admin.packingTemplates.saveError"))}},je=async K=>{if(!R.trim()||!c){P(null);return}try{await Rt.updateTemplateItem(c,K,{name:R.trim()}),y(de=>de.map(_e=>_e.id===K?{..._e,name:R.trim()}:_e)),P(null)}catch{J.error(z("admin.packingTemplates.saveError"))}},we=async K=>{if(c)try{await Rt.deleteTemplateItem(c,K),y(de=>de.filter(_e=>_e.id!==K))}catch{J.error(z("admin.packingTemplates.deleteError"))}},ce="w-full px-3 py-2 border border-slate-200 rounded-lg text-sm focus:ring-2 focus:ring-slate-400 focus:border-transparent outline-none",le="p-1.5 rounded-lg transition-colors";return r.jsxs("div",{className:"bg-white rounded-xl border border-slate-200 overflow-hidden",children:[r.jsxs("div",{className:"p-5 border-b border-slate-100 flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsx("h2",{className:"font-semibold text-slate-900",children:z("admin.packingTemplates.title")}),r.jsx("p",{className:"text-xs text-slate-400 mt-1",children:z("admin.packingTemplates.subtitle")})]}),r.jsxs("button",{onClick:()=>o(!0),className:"flex items-center gap-1.5 px-3 py-1.5 text-sm bg-slate-900 text-white rounded-lg hover:bg-slate-700 transition-colors",children:[r.jsx(Ft,{className:"w-4 h-4"})," ",r.jsx("span",{className:"hidden sm:inline",children:z("admin.packingTemplates.create")})]})]}),i&&r.jsxs("div",{className:"px-5 py-3 border-b border-slate-100 flex items-center gap-3",children:[r.jsx(rc,{size:16,className:"text-slate-400 flex-shrink-0"}),r.jsx("input",{autoFocus:!0,value:s,onChange:K=>d(K.target.value),onKeyDown:K=>{K.key==="Enter"&&C(),K.key==="Escape"&&o(!1)},placeholder:z("admin.packingTemplates.namePlaceholder"),className:ce}),r.jsx("button",{onClick:C,className:`${le} text-slate-600 hover:text-slate-900`,children:r.jsx(Ga,{size:16})}),r.jsx("button",{onClick:()=>o(!1),className:`${le} text-slate-400 hover:text-slate-600`,children:r.jsx(gt,{size:16})})]}),a?r.jsx("div",{className:"p-8 text-center",children:r.jsx("div",{className:"w-8 h-8 border-2 border-slate-200 border-t-slate-900 rounded-full animate-spin mx-auto"})}):e.length===0?r.jsx("div",{className:"p-8 text-center text-sm text-slate-400",children:z("admin.packingTemplates.empty")}):r.jsx("div",{className:"divide-y divide-slate-100",children:e.map(K=>r.jsxs("div",{children:[r.jsxs("div",{className:"px-5 py-3 flex items-center gap-3 hover:bg-slate-50 transition-colors",children:[r.jsx("button",{onClick:()=>B(K.id),className:"text-slate-400 flex-shrink-0 p-0 bg-transparent border-none cursor-pointer",children:c===K.id?r.jsx(en,{size:15}):r.jsx(Ao,{size:15})}),r.jsx(rc,{size:16,className:"text-slate-400 flex-shrink-0"}),x===K.id?r.jsx("input",{autoFocus:!0,value:S,onChange:de=>v(de.target.value),onBlur:()=>q(K.id),onKeyDown:de=>{de.key==="Enter"&&q(K.id),de.key==="Escape"&&k(null)},className:"flex-1 px-2 py-0.5 border border-slate-300 rounded text-sm"}):r.jsx("span",{onClick:()=>B(K.id),className:"flex-1 text-sm font-medium text-slate-700 cursor-pointer",children:K.name}),r.jsxs("span",{className:"text-xs text-slate-400 px-2 py-0.5 bg-slate-100 rounded-full",children:[K.category_count," ",z("admin.packingTemplates.categories")," · ",K.item_count," ",z("admin.packingTemplates.items")]}),r.jsx("button",{onClick:()=>{k(K.id),v(K.name)},className:`${le} hover:bg-slate-100 text-slate-400 hover:text-slate-700`,children:r.jsx(Ci,{size:14})}),r.jsx("button",{onClick:()=>U(K.id),className:`${le} hover:bg-red-50 text-slate-400 hover:text-red-500`,children:r.jsx(_t,{size:14})})]}),c===K.id&&r.jsxs("div",{className:"px-5 pb-4 ml-8 space-y-3",children:[m.map(de=>{const _e=f.filter(pe=>pe.category_id===de.id);return r.jsxs("div",{className:"border border-slate-200 rounded-lg overflow-hidden",children:[r.jsxs("div",{className:"flex items-center gap-2 px-4 py-2.5 bg-slate-50",children:[_===de.id?r.jsx(r.Fragment,{children:r.jsx("input",{autoFocus:!0,value:E,onChange:pe=>M(pe.target.value),onBlur:()=>oe(de.id),onKeyDown:pe=>{pe.key==="Enter"&&oe(de.id),pe.key==="Escape"&&w(null)},className:"flex-1 px-2 py-0.5 border border-slate-300 rounded text-sm font-semibold"})}):r.jsx("span",{className:"flex-1 text-xs font-bold text-slate-500 uppercase tracking-wider",children:de.name}),r.jsx("span",{className:"text-xs text-slate-400",children:_e.length}),r.jsx("button",{onClick:()=>{Z(X===de.id?null:de.id),Q(""),setTimeout(()=>{var pe;return(pe=D.current)==null?void 0:pe.focus()},30)},className:`${le} text-slate-400 hover:text-slate-700`,children:r.jsx(Ft,{size:13})}),r.jsx("button",{onClick:()=>{w(de.id),M(de.name)},className:`${le} text-slate-400 hover:text-slate-700`,children:r.jsx(Ci,{size:13})}),r.jsx("button",{onClick:()=>be(de.id),className:`${le} text-slate-400 hover:text-red-500`,children:r.jsx(_t,{size:13})})]}),(_e.length>0||X===de.id)&&r.jsxs("div",{className:"divide-y divide-slate-50",children:[_e.map(pe=>r.jsx("div",{className:"flex items-center gap-3 px-4 py-2 group",children:A===pe.id?r.jsxs(r.Fragment,{children:[r.jsx("input",{autoFocus:!0,value:R,onChange:Ae=>$(Ae.target.value),onKeyDown:Ae=>{Ae.key==="Enter"&&je(pe.id),Ae.key==="Escape"&&P(null)},className:"flex-1 px-2 py-1 border border-slate-200 rounded-lg text-sm"}),r.jsx("button",{onClick:()=>je(pe.id),className:"p-1 text-slate-600 hover:text-slate-900",children:r.jsx(Ga,{size:13})}),r.jsx("button",{onClick:()=>P(null),className:"p-1 text-slate-400",children:r.jsx(gt,{size:13})})]}):r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"flex-1 text-sm text-slate-700",children:pe.name}),r.jsx("button",{onClick:()=>{P(pe.id),$(pe.name)},className:"p-1 rounded opacity-0 group-hover:opacity-100 text-slate-400 hover:text-slate-700 transition-all",children:r.jsx(Ci,{size:12})}),r.jsx("button",{onClick:()=>we(pe.id),className:"p-1 rounded opacity-0 group-hover:opacity-100 text-slate-400 hover:text-red-500 transition-all",children:r.jsx(_t,{size:12})})]})},pe.id)),X===de.id&&r.jsxs("div",{className:"flex items-center gap-2 px-4 py-2",children:[r.jsx("input",{ref:D,value:O,onChange:pe=>Q(pe.target.value),onKeyDown:pe=>{pe.key==="Enter"&&O.trim()&&Se(de.id),pe.key==="Escape"&&(Z(null),Q(""))},placeholder:z("admin.packingTemplates.itemName"),className:"flex-1 px-2 py-1 border border-slate-200 rounded-lg text-sm"}),r.jsx("button",{onClick:()=>Se(de.id),disabled:!O.trim(),className:"p-1.5 rounded-lg bg-slate-900 text-white disabled:bg-slate-300 hover:bg-slate-700 transition-colors",children:r.jsx(Ft,{size:13})}),r.jsx("button",{onClick:()=>{Z(null),Q("")},className:"p-1 text-slate-400 hover:text-slate-600",children:r.jsx(gt,{size:13})})]})]})]},de.id)}),I?r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("input",{autoFocus:!0,value:H,onChange:de=>V(de.target.value),onKeyDown:de=>{de.key==="Enter"&&te(),de.key==="Escape"&&(Y(!1),V(""))},placeholder:z("admin.packingTemplates.categoryName"),className:"flex-1 px-3 py-2 border border-slate-200 rounded-lg text-sm"}),r.jsx("button",{onClick:te,className:`${le} text-slate-600 hover:text-slate-900`,children:r.jsx(Ga,{size:15})}),r.jsx("button",{onClick:()=>{Y(!1),V("")},className:`${le} text-slate-400`,children:r.jsx(gt,{size:15})})]}):r.jsxs("button",{onClick:()=>Y(!0),className:"flex items-center gap-2 px-3 py-2.5 w-full text-sm text-slate-400 hover:text-slate-600 border border-dashed border-slate-200 rounded-lg hover:border-slate-400 transition-colors",children:[r.jsx(v_,{size:14})," ",z("admin.packingTemplates.addCategory")]})]})]},K.id))})]})}function C7(){const{t:e,locale:t}=ot(),[a,n]=b.useState([]),[i,o]=b.useState(0),[s,d]=b.useState(0),[c,p]=b.useState(!0),m=100,g=b.useCallback(async()=>{p(!0);try{const S=await Rt.auditLog({limit:m,offset:0});n(S.entries||[]),o(S.total??0),d(0)}catch{n([]),o(0),d(0)}finally{p(!1)}},[]),f=b.useCallback(async()=>{const S=s+m;p(!0);try{const v=await Rt.auditLog({limit:m,offset:S});n(_=>[..._,...v.entries||[]]),o(v.total??0),d(S)}catch{}finally{p(!1)}},[s]);b.useEffect(()=>{g()},[g]);const y=S=>{try{return new Date(S).toLocaleString(t,{dateStyle:"short",timeStyle:"medium"})}catch{return S}},x=S=>{if(!S||Object.keys(S).length===0)return"—";try{return JSON.stringify(S)}catch{return"—"}},k=S=>S.username?S.username:S.user_email?S.user_email:S.user_id!=null?`#${S.user_id}`:"—";return r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[r.jsxs("div",{children:[r.jsxs("h2",{className:"font-semibold text-lg m-0 flex items-center gap-2",style:{color:"var(--text-primary)"},children:[r.jsx(TM,{size:20}),e("admin.tabs.audit")]}),r.jsx("p",{className:"text-sm m-0 mt-1",style:{color:"var(--text-muted)"},children:e("admin.audit.subtitle")})]}),r.jsxs("button",{type:"button",disabled:c,onClick:()=>g(),className:"inline-flex items-center gap-2 px-3 py-2 rounded-lg text-sm font-medium border transition-opacity disabled:opacity-50",style:{borderColor:"var(--border-primary)",color:"var(--text-primary)",background:"var(--bg-card)"},children:[r.jsx(ic,{size:16,className:c?"animate-spin":""}),e("admin.audit.refresh")]})]}),r.jsx("p",{className:"text-xs m-0",style:{color:"var(--text-faint)"},children:e("admin.audit.showing",{count:a.length,total:i})}),c&&a.length===0?r.jsx("div",{className:"py-12 text-center text-sm",style:{color:"var(--text-muted)"},children:e("common.loading")}):a.length===0?r.jsx("div",{className:"py-12 text-center text-sm",style:{color:"var(--text-muted)"},children:e("admin.audit.empty")}):r.jsx("div",{className:"rounded-xl border overflow-x-auto",style:{borderColor:"var(--border-primary)",background:"var(--bg-card)"},children:r.jsxs("table",{className:"w-full text-sm border-collapse min-w-[720px]",children:[r.jsx("thead",{children:r.jsxs("tr",{className:"border-b text-left",style:{borderColor:"var(--border-secondary)"},children:[r.jsx("th",{className:"p-3 font-semibold whitespace-nowrap",style:{color:"var(--text-secondary)"},children:e("admin.audit.col.time")}),r.jsx("th",{className:"p-3 font-semibold whitespace-nowrap",style:{color:"var(--text-secondary)"},children:e("admin.audit.col.user")}),r.jsx("th",{className:"p-3 font-semibold whitespace-nowrap",style:{color:"var(--text-secondary)"},children:e("admin.audit.col.action")}),r.jsx("th",{className:"p-3 font-semibold whitespace-nowrap",style:{color:"var(--text-secondary)"},children:e("admin.audit.col.resource")}),r.jsx("th",{className:"p-3 font-semibold whitespace-nowrap",style:{color:"var(--text-secondary)"},children:e("admin.audit.col.ip")}),r.jsx("th",{className:"p-3 font-semibold",style:{color:"var(--text-secondary)"},children:e("admin.audit.col.details")})]})}),r.jsx("tbody",{children:a.map(S=>r.jsxs("tr",{className:"border-b align-top",style:{borderColor:"var(--border-secondary)"},children:[r.jsx("td",{className:"p-3 whitespace-nowrap font-mono text-xs",style:{color:"var(--text-primary)"},children:y(S.created_at)}),r.jsx("td",{className:"p-3",style:{color:"var(--text-primary)"},children:k(S)}),r.jsx("td",{className:"p-3 font-mono text-xs",style:{color:"var(--text-primary)"},children:S.action}),r.jsx("td",{className:"p-3 font-mono text-xs break-all max-w-[140px]",style:{color:"var(--text-muted)"},children:S.resource||"—"}),r.jsx("td",{className:"p-3 font-mono text-xs whitespace-nowrap",style:{color:"var(--text-muted)"},children:S.ip||"—"}),r.jsx("td",{className:"p-3 font-mono text-xs break-all max-w-[280px]",style:{color:"var(--text-faint)"},children:x(S.details)})]},S.id))})]})}),a.lengthf(),className:"text-sm font-medium underline-offset-2 hover:underline disabled:opacity-50",style:{color:"var(--text-secondary)"},children:e("admin.audit.loadMore")})]})}function z7(){const[e,t]=b.useState([]),[a,n]=b.useState(!0),[i,o]=b.useState(null),s=ya(),{t:d,locale:c}=ot();b.useEffect(()=>{n(!0),Rt.mcpTokens().then(m=>t(m.tokens||[])).catch(()=>s.error(d("admin.mcpTokens.loadError"))).finally(()=>n(!1))},[]);const p=async m=>{try{await Rt.deleteMcpToken(m),t(g=>g.filter(f=>f.id!==m)),o(null),s.success(d("admin.mcpTokens.deleteSuccess"))}catch{s.error(d("admin.mcpTokens.deleteError"))}};return r.jsxs("div",{className:"space-y-6",children:[r.jsxs("div",{children:[r.jsx("h2",{className:"text-lg font-semibold",style:{color:"var(--text-primary)"},children:d("admin.mcpTokens.title")}),r.jsx("p",{className:"text-sm mt-0.5",style:{color:"var(--text-tertiary)"},children:d("admin.mcpTokens.subtitle")})]}),r.jsx("div",{className:"rounded-xl border overflow-hidden",style:{borderColor:"var(--border-primary)",background:"var(--bg-card)"},children:a?r.jsx("div",{className:"flex items-center justify-center py-12",children:r.jsx(wl,{className:"w-5 h-5 animate-spin",style:{color:"var(--text-tertiary)"}})}):e.length===0?r.jsxs("div",{className:"flex flex-col items-center justify-center py-12 gap-2",children:[r.jsx(b_,{className:"w-8 h-8",style:{color:"var(--text-tertiary)"}}),r.jsx("p",{className:"text-sm",style:{color:"var(--text-tertiary)"},children:d("admin.mcpTokens.empty")})]}):r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"grid grid-cols-[1fr_auto_auto_auto_auto] gap-x-4 px-4 py-2.5 text-xs font-medium border-b",style:{color:"var(--text-tertiary)",borderColor:"var(--border-primary)",background:"var(--bg-secondary)"},children:[r.jsx("span",{children:d("admin.mcpTokens.tokenName")}),r.jsx("span",{children:d("admin.mcpTokens.owner")}),r.jsx("span",{className:"text-right",children:d("admin.mcpTokens.created")}),r.jsx("span",{className:"text-right",children:d("admin.mcpTokens.lastUsed")}),r.jsx("span",{})]}),e.map((m,g)=>r.jsxs("div",{className:"grid grid-cols-[1fr_auto_auto_auto_auto] items-center gap-x-4 px-4 py-3",style:{borderBottom:go(m.id),className:"p-1.5 rounded-lg transition-colors hover:bg-red-50 hover:text-red-600 dark:hover:bg-red-900/20",style:{color:"var(--text-tertiary)"},title:d("common.delete"),children:r.jsx(_t,{className:"w-4 h-4"})})]},m.id))]})}),i!==null&&r.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",style:{background:"rgba(0,0,0,0.5)"},onClick:m=>{m.target===m.currentTarget&&o(null)},children:r.jsxs("div",{className:"rounded-xl shadow-xl w-full max-w-sm p-6 space-y-4",style:{background:"var(--bg-card)"},children:[r.jsx("h3",{className:"text-base font-semibold",style:{color:"var(--text-primary)"},children:d("admin.mcpTokens.deleteTitle")}),r.jsx("p",{className:"text-sm",style:{color:"var(--text-secondary)"},children:d("admin.mcpTokens.deleteMessage")}),r.jsxs("div",{className:"flex gap-2 justify-end",children:[r.jsx("button",{onClick:()=>o(null),className:"px-4 py-2 rounded-lg text-sm border",style:{borderColor:"var(--border-primary)",color:"var(--text-secondary)"},children:d("common.cancel")}),r.jsx("button",{onClick:()=>p(i),className:"px-4 py-2 rounded-lg text-sm font-medium text-white bg-red-600 hover:bg-red-700",children:d("common.delete")})]})]})})]})}function T7(){const{demoMode:e,serverTimezone:t}=cn(),{t:a,locale:n}=ot(),i=ta(re=>re.settings.time_format)==="12h",o=[{id:"users",label:a("admin.tabs.users")},{id:"config",label:a("admin.tabs.config")},{id:"addons",label:a("admin.tabs.addons")},{id:"settings",label:a("admin.tabs.settings")},{id:"backup",label:a("admin.tabs.backup")},{id:"audit",label:a("admin.tabs.audit")},{id:"mcp-tokens",label:a("admin.tabs.mcpTokens")},{id:"github",label:a("admin.tabs.github")}],[s,d]=b.useState("users"),[c,p]=b.useState([]),[m,g]=b.useState(null),[f,y]=b.useState(!0),[x,k]=b.useState(null),[S,v]=b.useState({username:"",email:"",role:"user",password:""}),[_,w]=b.useState(!1),[E,M]=b.useState({username:"",email:"",password:"",role:"user"}),[A,P]=b.useState(!1);b.useEffect(()=>{Rt.getBagTracking().then(re=>P(re.enabled)).catch(()=>{})},[]);const[R,$]=b.useState({issuer:"",client_id:"",client_secret:"",client_secret_set:!1,display_name:"",oidc_only:!1}),[I,Y]=b.useState(!1),[H,V]=b.useState(!0),[X,Z]=b.useState(!1),[O,Q]=b.useState([]),[D,J]=b.useState(!1),[z,W]=b.useState({max_uses:1,expires_in_days:7}),[B,C]=b.useState("jpg,jpeg,png,gif,webp,heic,pdf,doc,docx,xls,xlsx,txt,csv"),[U,q]=b.useState(!1),[te,oe]=b.useState({}),[be,Se]=b.useState(!1);b.useEffect(()=>{ie.get("/auth/app-settings").then(re=>{oe(re.data||{}),Se(!0)}).catch(()=>Se(!0))},[]);const[je,we]=b.useState(""),[ce,le]=b.useState(""),[K,de]=b.useState({}),[_e,pe]=b.useState(!1),[Ae,He]=b.useState({}),[ze,Ye]=b.useState({}),[G,ve]=b.useState(null),[Pe,ye]=b.useState(!1),[ne,fe]=b.useState(!1),[Ee,Oe]=b.useState(null),{user:Ke,updateApiKeys:dt,setAppRequireMfa:Wt}=cn();Br();const Be=ya();b.useEffect(()=>{Gt(),Kt(),Lt(),Rt.getOidc().then($).catch(()=>{}),Rt.checkVersion().then(re=>{re.update_available&&ve(re)}).catch(()=>{})},[]);const Gt=async()=>{y(!0);try{const[re,Ie,At]=await Promise.all([Rt.users(),Rt.stats(),Rt.listInvites().catch(()=>({invites:[]}))]);p(re.users),g(Ie),Q(At.invites||[])}catch{Be.error(a("admin.toast.loadError"))}finally{y(!1)}},Kt=async()=>{try{const re=await jt.getAppConfig();V(re.allow_registration),re.require_mfa!==void 0&&Z(!!re.require_mfa),re.allowed_file_types&&C(re.allowed_file_types)}catch{}},Lt=async()=>{var re,Ie;try{const At=await jt.getSettings();we(((re=At.settings)==null?void 0:re.maps_api_key)||""),le(((Ie=At.settings)==null?void 0:Ie.openweather_api_key)||"")}catch{}},Ce=async()=>{fe(!0),Oe(null);try{await Rt.installUpdate(),Oe("success");const re=setInterval(async()=>{try{await jt.getAppConfig(),clearInterval(re),window.location.reload()}catch{}},2e3)}catch{Oe("error"),fe(!1)}},De=async re=>{V(re);try{await jt.updateAppSettings({allow_registration:re})}catch(Ie){V(!re),Be.error(at(Ie,a("common.error")))}},Qe=async re=>{Z(re);try{await jt.updateAppSettings({require_mfa:re}),Wt(re),Be.success(a("common.saved"))}catch(Ie){Z(!re),Be.error(at(Ie,a("common.error")))}},ft=re=>{de(Ie=>({...Ie,[re]:!Ie[re]}))},Et=async()=>{pe(!0);try{await dt({maps_api_key:je,openweather_api_key:ce}),Be.success(a("admin.keySaved"))}catch(re){Be.error(re instanceof Error?re.message:"Unknown error")}finally{pe(!1)}},pt=async re=>{He(Ie=>({...Ie,[re]:!0}));try{await dt({maps_api_key:je,openweather_api_key:ce});const Ie=await jt.validateKeys();Ye(At=>({...At,[re]:Ie[re]}))}catch{Be.error(a("common.error"))}finally{He(Ie=>({...Ie,[re]:!1}))}},Zt=async()=>{if(!E.username.trim()||!E.email.trim()||!E.password.trim()){Be.error(a("admin.toast.fieldsRequired"));return}try{const re=await Rt.createUser(E);p(Ie=>[re.user,...Ie]),w(!1),M({username:"",email:"",password:"",role:"user"}),Be.success(a("admin.toast.userCreated"))}catch(re){Be.error(at(re,a("admin.toast.createError")))}},jn=async()=>{try{const re=await Rt.createInvite({max_uses:z.max_uses,expires_in_days:z.expires_in_days||void 0});Q(At=>[re.invite,...At]),J(!1),W({max_uses:1,expires_in_days:7});const Ie=`${window.location.origin}/register?invite=${re.invite.token}`;navigator.clipboard.writeText(Ie).then(()=>Be.success(a("admin.invite.copied")))}catch(re){Be.error(at(re,a("admin.invite.createError")))}},ga=async re=>{try{await Rt.deleteInvite(re),Q(Ie=>Ie.filter(At=>At.id!==re)),Be.success(a("admin.invite.deleted"))}catch{Be.error(a("admin.invite.deleteError"))}},Ot=re=>{const Ie=`${window.location.origin}/register?invite=${re}`;navigator.clipboard.writeText(Ie).then(()=>Be.success(a("admin.invite.copied")))},Xt=re=>{k(re),v({username:re.username,email:re.email,role:re.role,password:""})},Za=async()=>{try{const re={username:S.username.trim()||void 0,email:S.email.trim()||void 0,role:S.role};S.password.trim()&&(re.password=S.password.trim());const Ie=await Rt.updateUser(x.id,re);p(At=>At.map(va=>va.id===x.id?Ie.user:va)),k(null),Be.success(a("admin.toast.userUpdated"))}catch(re){Be.error(at(re,a("admin.toast.updateError")))}},It=async re=>{if(re.id===(Ke==null?void 0:Ke.id)){Be.error(a("admin.toast.cannotDeleteSelf"));return}if(confirm(a("admin.deleteUser",{name:re.username})))try{await Rt.deleteUser(re.id),p(Ie=>Ie.filter(At=>At.id!==re.id)),Be.success(a("admin.toast.userDeleted"))}catch(Ie){Be.error(at(Ie,a("admin.toast.deleteError")))}};return r.jsxs("div",{className:"min-h-screen",style:{background:"var(--bg-secondary)"},children:[r.jsx(Mi,{}),r.jsx("div",{style:{paddingTop:"var(--nav-h)"},children:r.jsxs("div",{className:"max-w-6xl mx-auto px-4 py-8",children:[r.jsxs("div",{className:"flex items-center gap-3 mb-6",children:[r.jsx("div",{className:"w-10 h-10 bg-slate-100 rounded-xl flex items-center justify-center",children:r.jsx(di,{className:"w-5 h-5 text-slate-700"})}),r.jsxs("div",{children:[r.jsx("h1",{className:"text-2xl font-bold text-slate-900",children:a("admin.title")}),r.jsx("p",{className:"text-slate-500 text-sm",children:a("admin.subtitle")})]})]}),G&&r.jsxs("div",{className:"mb-6 p-4 rounded-xl border flex flex-col sm:flex-row items-start sm:items-center gap-4 bg-amber-50 dark:bg-amber-950/40 border-amber-300 dark:border-amber-700",children:[r.jsxs("div",{className:"flex items-center gap-4 flex-1 min-w-0",children:[r.jsx("div",{className:"flex-shrink-0 w-10 h-10 rounded-full flex items-center justify-center bg-amber-500 dark:bg-amber-600",children:r.jsx(vM,{className:"w-5 h-5 text-white"})}),r.jsxs("div",{children:[r.jsx("p",{className:"text-sm font-semibold text-amber-900 dark:text-amber-200",children:a("admin.update.available")}),r.jsx("p",{className:"text-xs text-amber-700 dark:text-amber-400 mt-0.5",children:a("admin.update.text").replace("{version}",`v${G.latest}`).replace("{current}",`v${G.current}`)})]})]}),r.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[G.release_url&&r.jsxs("a",{href:G.release_url,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 px-3 py-2 rounded-lg text-xs font-medium transition-colors text-amber-800 dark:text-amber-300 border border-amber-300 dark:border-amber-600 hover:bg-amber-100 dark:hover:bg-amber-900/50",children:[r.jsx(xn,{className:"w-3.5 h-3.5"}),a("admin.update.button")]}),G.is_docker?r.jsxs("button",{onClick:()=>ye(!0),className:"flex items-center gap-1.5 px-4 py-2 rounded-lg text-sm font-semibold transition-colors bg-slate-900 dark:bg-white text-white dark:text-slate-900 hover:bg-slate-700 dark:hover:bg-gray-200",children:[r.jsx(Xs,{className:"w-4 h-4"}),a("admin.update.howTo")]}):r.jsxs("button",{onClick:()=>ye(!0),className:"flex items-center gap-1.5 px-4 py-2 rounded-lg text-sm font-semibold transition-colors bg-slate-900 dark:bg-white text-white dark:text-slate-900 hover:bg-slate-700 dark:hover:bg-gray-200",children:[r.jsx(Xs,{className:"w-4 h-4"}),a("admin.update.install")]})]})]}),e&&r.jsxs("div",{className:"mb-6 p-4 bg-amber-50 border border-amber-200 rounded-xl flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsx("p",{className:"text-sm font-semibold text-amber-900",children:"Demo Baseline"}),r.jsx("p",{className:"text-xs text-amber-700",children:"Save current state as the hourly reset point. All admin trips and settings will be preserved."})]}),r.jsx("button",{onClick:async()=>{var re,Ie;try{await Rt.saveDemoBaseline(),Be.success("Baseline saved! Resets will restore to this state.")}catch(At){Be.error(((Ie=(re=At.response)==null?void 0:re.data)==null?void 0:Ie.error)||"Failed to save baseline")}},className:"px-4 py-2 bg-amber-600 text-white rounded-lg text-sm font-semibold hover:bg-amber-700 transition-colors flex-shrink-0 ml-4",children:"Save Baseline"})]}),m&&r.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-4 mb-6",children:[{label:a("admin.stats.users"),value:m.totalUsers,icon:Ur},{label:a("admin.stats.trips"),value:m.totalTrips,icon:ys},{label:a("admin.stats.places"),value:m.totalPlaces,icon:vs},{label:a("admin.stats.files"),value:m.totalFiles||0,icon:Pa}].map(({label:re,value:Ie,icon:At})=>r.jsx("div",{className:"rounded-xl border p-4",style:{background:"var(--bg-card)",borderColor:"var(--border-primary)"},children:r.jsxs("div",{className:"flex items-center gap-4",children:[r.jsx(At,{className:"w-5 h-5",style:{color:"var(--text-primary)"}}),r.jsxs("div",{children:[r.jsx("p",{className:"text-xl font-bold",style:{color:"var(--text-primary)"},children:Ie}),r.jsx("p",{className:"text-xs",style:{color:"var(--text-muted)"},children:re})]})]})},re))}),r.jsx("div",{className:"grid grid-cols-3 sm:flex gap-1 mb-6 rounded-xl p-1",style:{background:"var(--bg-card)",border:"1px solid var(--border-primary)"},children:o.map(re=>r.jsx("button",{onClick:()=>d(re.id),className:`px-3 sm:px-4 py-2 text-xs sm:text-sm font-medium rounded-lg transition-colors ${s===re.id?"bg-slate-900 text-white":"text-slate-600 hover:text-slate-900 hover:bg-slate-50"}`,children:re.label},re.id))}),s==="users"&&r.jsxs("div",{className:"bg-white rounded-xl border border-slate-200 overflow-hidden",children:[r.jsxs("div",{className:"p-5 border-b border-slate-100 flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsx("h2",{className:"font-semibold text-slate-900",children:a("admin.tabs.users")}),r.jsxs("p",{className:"text-xs text-slate-400 mt-1",children:[c.length," ",a("admin.stats.users")]})]}),r.jsxs("button",{onClick:()=>w(!0),className:"flex items-center gap-1.5 px-3 py-1.5 text-sm bg-slate-900 text-white rounded-lg hover:bg-slate-700 transition-colors",children:[r.jsx(_c,{className:"w-4 h-4"}),a("admin.createUser")]})]}),f?r.jsx("div",{className:"p-8 text-center",children:r.jsx("div",{className:"w-8 h-8 border-2 border-slate-200 border-t-slate-900 rounded-full animate-spin mx-auto"})}):r.jsx("div",{className:"overflow-x-auto",children:r.jsxs("table",{className:"w-full",children:[r.jsx("thead",{children:r.jsxs("tr",{className:"text-left text-xs font-medium text-slate-500 uppercase tracking-wider border-b border-slate-100 bg-slate-50",children:[r.jsx("th",{className:"px-5 py-3",children:a("admin.table.user")}),r.jsx("th",{className:"px-5 py-3",children:a("admin.table.email")}),r.jsx("th",{className:"px-5 py-3",children:a("admin.table.role")}),r.jsx("th",{className:"px-5 py-3",children:a("admin.table.created")}),r.jsx("th",{className:"px-5 py-3",children:a("admin.table.lastLogin")}),r.jsx("th",{className:"px-5 py-3 text-right",children:a("admin.table.actions")})]})}),r.jsx("tbody",{className:"divide-y divide-slate-100",children:c.map(re=>r.jsxs("tr",{className:`hover:bg-slate-50 transition-colors ${re.id===(Ke==null?void 0:Ke.id)?"bg-slate-50/60":""}`,children:[r.jsx("td",{className:"px-5 py-3",children:r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs("div",{className:"relative",children:[r.jsx("div",{className:"w-8 h-8 rounded-full bg-slate-100 flex items-center justify-center text-sm font-medium text-slate-700",children:re.username.charAt(0).toUpperCase()}),r.jsx("span",{className:"absolute -bottom-0.5 -right-0.5 w-3 h-3 rounded-full border-2",style:{borderColor:"var(--bg-card)",background:re.online?"#22c55e":"#94a3b8"}})]}),r.jsxs("div",{children:[r.jsx("p",{className:"text-sm font-medium text-slate-900",children:re.username}),re.id===(Ke==null?void 0:Ke.id)&&r.jsx("span",{className:"text-xs text-slate-500",children:a("admin.you")})]})]})}),r.jsx("td",{className:"px-5 py-3 text-sm text-slate-600",children:re.email}),r.jsx("td",{className:"px-5 py-3",children:r.jsxs("span",{className:`inline-flex items-center gap-1 text-xs font-medium px-2.5 py-0.5 rounded-full ${re.role==="admin"?"bg-slate-900 text-white":"bg-slate-100 text-slate-600"}`,children:[re.role==="admin"&&r.jsx(di,{className:"w-3 h-3"}),re.role==="admin"?a("settings.roleAdmin"):a("settings.roleUser")]})}),r.jsx("td",{className:"px-5 py-3 text-sm text-slate-500",children:new Date(re.created_at).toLocaleDateString(n,{timeZone:t})}),r.jsx("td",{className:"px-5 py-3 text-sm text-slate-500",children:re.last_login?new Date(re.last_login).toLocaleDateString(n,{day:"numeric",month:"short",hour:"2-digit",minute:"2-digit",hour12:i,timeZone:t}):"—"}),r.jsx("td",{className:"px-5 py-3",children:r.jsxs("div",{className:"flex items-center gap-2 justify-end",children:[r.jsx("button",{onClick:()=>Xt(re),className:"p-1.5 text-slate-400 hover:text-slate-900 hover:bg-slate-100 rounded-lg transition-colors",title:a("admin.editUser"),children:r.jsx(Ci,{className:"w-4 h-4"})}),r.jsx("button",{onClick:()=>It(re),disabled:re.id===(Ke==null?void 0:Ke.id),className:"p-1.5 text-slate-400 hover:text-red-600 hover:bg-red-50 rounded-lg transition-colors disabled:opacity-30 disabled:cursor-not-allowed",title:a("admin.deleteUserTitle"),children:r.jsx(_t,{className:"w-4 h-4"})})]})})]},re.id))})]})})]}),s==="users"&&r.jsxs("div",{className:"bg-white rounded-xl border border-slate-200 overflow-hidden mt-6",children:[r.jsxs("div",{className:"p-5 border-b border-slate-100 flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsx("h2",{className:"font-semibold text-slate-900",children:a("admin.invite.title")}),r.jsx("p",{className:"text-xs text-slate-400 mt-1",children:a("admin.invite.subtitle")})]}),r.jsxs("button",{onClick:()=>J(!0),className:"flex items-center gap-1.5 px-3 py-1.5 text-sm bg-slate-900 text-white rounded-lg hover:bg-slate-700 transition-colors",children:[r.jsx(Ft,{className:"w-4 h-4"}),a("admin.invite.create")]})]}),O.length===0?r.jsx("div",{className:"p-8 text-center text-sm text-slate-400",children:a("admin.invite.empty")}):r.jsx("div",{className:"divide-y divide-slate-100",children:O.map(re=>{const Ie=re.expires_at&&new Date(re.expires_at)0&&re.used_count>=re.max_uses,va=!Ie&&!At;return r.jsxs("div",{className:"px-5 py-3 flex items-center gap-4",children:[r.jsx(wo,{className:"w-4 h-4 flex-shrink-0",style:{color:va?"var(--text-primary)":"#d1d5db"}}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs("code",{className:"text-xs font-mono text-slate-600 truncate",children:[re.token.slice(0,12),"..."]}),r.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded-full font-medium ${va?"bg-green-50 text-green-700":"bg-slate-100 text-slate-400"}`,children:a(At?"admin.invite.usedUp":Ie?"admin.invite.expired":"admin.invite.active")})]}),r.jsxs("div",{className:"text-xs text-slate-400 mt-0.5",children:[re.used_count,"/",re.max_uses===0?"∞":re.max_uses," ",a("admin.invite.uses"),re.expires_at&&` · ${a("admin.invite.expiresAt")} ${new Date(re.expires_at).toLocaleDateString(n,{timeZone:t})}`,` · ${a("admin.invite.createdBy")} ${re.created_by_name}`]})]}),va&&r.jsx("button",{onClick:()=>Ot(re.token),title:a("admin.invite.copyLink"),className:"p-1.5 rounded-lg hover:bg-slate-100 text-slate-400 hover:text-slate-700 transition-colors",children:r.jsx(Ys,{className:"w-3.5 h-3.5"})}),r.jsx("button",{onClick:()=>ga(re.id),title:a("common.delete"),className:"p-1.5 rounded-lg hover:bg-red-50 text-slate-400 hover:text-red-500 transition-colors",children:r.jsx(_t,{className:"w-3.5 h-3.5"})})]},re.id)})})]}),r.jsx(zi,{isOpen:D,onClose:()=>J(!1),title:a("admin.invite.create"),size:"sm",children:r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{children:[r.jsx("label",{className:"block text-xs font-semibold text-slate-500 uppercase tracking-wider mb-1.5",children:a("admin.invite.maxUses")}),r.jsx("div",{className:"flex gap-2",children:[1,2,3,4,5,0].map(re=>r.jsx("button",{type:"button",onClick:()=>W(Ie=>({...Ie,max_uses:re})),className:`flex-1 py-2 rounded-lg text-sm font-semibold border transition-colors ${z.max_uses===re?"bg-slate-900 text-white border-slate-900":"bg-white text-slate-600 border-slate-200 hover:border-slate-400"}`,children:re===0?"∞":`${re}×`},re))})]}),r.jsxs("div",{children:[r.jsx("label",{className:"block text-xs font-semibold text-slate-500 uppercase tracking-wider mb-1.5",children:a("admin.invite.expiry")}),r.jsx("div",{className:"flex gap-2",children:[{value:1,label:"1d"},{value:3,label:"3d"},{value:7,label:"7d"},{value:14,label:"14d"},{value:"",label:"∞"}].map(re=>r.jsx("button",{type:"button",onClick:()=>W(Ie=>({...Ie,expires_in_days:re.value})),className:`flex-1 py-2 rounded-lg text-sm font-semibold border transition-colors ${z.expires_in_days===re.value?"bg-slate-900 text-white border-slate-900":"bg-white text-slate-600 border-slate-200 hover:border-slate-400"}`,children:re.label},String(re.value)))})]}),r.jsxs("div",{className:"flex justify-end gap-2 pt-2 border-t border-slate-100",children:[r.jsx("button",{onClick:()=>J(!1),className:"px-4 py-2 text-sm text-slate-500 hover:text-slate-700",children:a("common.cancel")}),r.jsx("button",{onClick:jn,className:"px-4 py-2 text-sm bg-slate-900 text-white rounded-lg hover:bg-slate-700",children:a("admin.invite.createAndCopy")})]})]})}),s==="config"&&r.jsxs("div",{className:"space-y-6",children:[r.jsx(_7,{}),r.jsx(m7,{})]}),s==="addons"&&r.jsx("div",{className:"space-y-6",children:r.jsx(S7,{bagTrackingEnabled:A,onToggleBagTracking:async()=>{const re=!A;P(re);try{await Rt.updateBagTracking(re)}catch{P(!re)}}})}),s==="settings"&&r.jsxs("div",{className:"space-y-6",children:[r.jsxs("div",{className:"bg-white rounded-xl border border-slate-200 overflow-hidden",children:[r.jsx("div",{className:"px-6 py-4 border-b border-slate-100",children:r.jsx("h2",{className:"font-semibold text-slate-900",children:a("admin.allowRegistration")})}),r.jsx("div",{className:"p-6",children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsx("p",{className:"text-sm font-medium text-slate-700",children:a("admin.allowRegistration")}),r.jsx("p",{className:"text-xs text-slate-400 mt-0.5",children:a("admin.allowRegistrationHint")})]}),r.jsx("button",{onClick:()=>De(!H),className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors ${H?"bg-slate-900":"bg-slate-300"}`,children:r.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${H?"translate-x-6":"translate-x-1"}`})})]})})]}),r.jsxs("div",{className:"bg-white rounded-xl border border-slate-200 overflow-hidden",children:[r.jsx("div",{className:"px-6 py-4 border-b border-slate-100",children:r.jsx("h2",{className:"font-semibold text-slate-900",children:a("admin.requireMfa")})}),r.jsx("div",{className:"p-6",children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsx("p",{className:"text-sm font-medium text-slate-700",children:a("admin.requireMfa")}),r.jsx("p",{className:"text-xs text-slate-400 mt-0.5",children:a("admin.requireMfaHint")})]}),r.jsx("button",{type:"button",onClick:()=>Qe(!X),className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors ${X?"bg-slate-900":"bg-slate-300"}`,children:r.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${X?"translate-x-6":"translate-x-1"}`})})]})})]}),r.jsxs("div",{className:"bg-white rounded-xl border border-slate-200 overflow-hidden",children:[r.jsxs("div",{className:"px-6 py-4 border-b border-slate-100",children:[r.jsx("h2",{className:"font-semibold text-slate-900",children:a("admin.fileTypes")}),r.jsx("p",{className:"text-xs text-slate-400 mt-1",children:a("admin.fileTypesHint")})]}),r.jsxs("div",{className:"p-6",children:[r.jsx("input",{type:"text",value:B,onChange:re=>C(re.target.value),placeholder:"jpg,png,pdf,doc,docx,xls,xlsx,txt,csv",className:"w-full px-3 py-2 border border-slate-300 rounded-lg text-sm focus:ring-2 focus:ring-slate-400 focus:border-transparent"}),r.jsx("p",{className:"text-xs text-slate-400 mt-2",children:a("admin.fileTypesFormat")}),r.jsxs("button",{onClick:async()=>{q(!0);try{await jt.updateAppSettings({allowed_file_types:B}),Be.success(a("admin.fileTypesSaved"))}catch{Be.error(a("common.error"))}finally{q(!1)}},disabled:U,className:"flex items-center gap-2 px-4 py-2 bg-slate-900 text-white rounded-lg text-sm hover:bg-slate-700 disabled:bg-slate-400 mt-3",children:[U?r.jsx("div",{className:"w-4 h-4 border-2 border-white/30 border-t-white rounded-full animate-spin"}):r.jsx(ll,{className:"w-4 h-4"}),a("common.save")]})]})]}),r.jsxs("div",{className:"bg-white rounded-xl border border-slate-200 overflow-hidden",children:[r.jsxs("div",{className:"px-6 py-4 border-b border-slate-100",children:[r.jsx("h2",{className:"font-semibold text-slate-900",children:a("admin.apiKeys")}),r.jsx("p",{className:"text-xs text-slate-400 mt-1",children:a("admin.apiKeysHint")})]}),r.jsxs("div",{className:"p-6 space-y-4",children:[r.jsxs("div",{children:[r.jsxs("label",{className:"flex items-center gap-2 text-sm font-medium text-slate-700 mb-1.5",children:[a("admin.mapsKey"),r.jsx("span",{className:"text-[9px] font-medium px-1.5 py-px rounded-full bg-emerald-200 dark:bg-emerald-800 text-emerald-800 dark:text-emerald-200",children:a("admin.recommended")})]}),r.jsxs("div",{className:"flex gap-2",children:[r.jsxs("div",{className:"relative flex-1",children:[r.jsx("input",{type:K.maps?"text":"password",value:je,onChange:re=>we(re.target.value),placeholder:a("settings.keyPlaceholder"),className:"w-full pr-10 px-3 py-2 border border-slate-300 rounded-lg text-sm focus:ring-2 focus:ring-slate-400 focus:border-transparent"}),r.jsx("button",{type:"button",onClick:()=>ft("maps"),className:"absolute right-3 top-1/2 -translate-y-1/2 text-slate-400 hover:text-slate-600",children:K.maps?r.jsx(Dp,{className:"w-4 h-4"}):r.jsx(Mm,{className:"w-4 h-4"})})]}),r.jsxs("button",{onClick:()=>pt("maps"),disabled:!je||Ae.maps,className:"px-3 py-2 text-sm border border-slate-300 rounded-lg hover:bg-slate-50 disabled:opacity-40 disabled:cursor-not-allowed flex items-center gap-1.5",children:[Ae.maps?r.jsx(wl,{className:"w-4 h-4 animate-spin"}):ze.maps===!0?r.jsx(fd,{className:"w-4 h-4 text-emerald-500"}):ze.maps===!1?r.jsx(Uf,{className:"w-4 h-4 text-red-500"}):null,a("admin.validateKey")]})]}),r.jsx("p",{className:"text-xs text-slate-400 mt-1",children:a("admin.mapsKeyHintLong")}),ze.maps===!0&&r.jsxs("p",{className:"text-xs text-emerald-600 mt-1 flex items-center gap-1",children:[r.jsx("span",{className:"w-2 h-2 bg-emerald-500 rounded-full inline-block"}),a("admin.keyValid")]}),ze.maps===!1&&r.jsxs("p",{className:"text-xs text-red-500 mt-1 flex items-center gap-1",children:[r.jsx("span",{className:"w-2 h-2 bg-red-500 rounded-full inline-block"}),a("admin.keyInvalid")]})]}),r.jsxs("div",{className:"rounded-lg border border-emerald-200 bg-emerald-50 dark:bg-emerald-950/30 dark:border-emerald-800 overflow-hidden",children:[r.jsxs("div",{className:"px-4 py-3 flex items-center justify-between",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("div",{className:"w-7 h-7 rounded-lg bg-emerald-500 flex items-center justify-center flex-shrink-0",children:r.jsx(Rl,{className:"w-3.5 h-3.5 text-white"})}),r.jsx("span",{className:"text-sm font-semibold text-emerald-900 dark:text-emerald-200",children:a("admin.weather.title")})]}),r.jsx("span",{className:"text-[10px] font-medium px-2 py-0.5 rounded-full bg-emerald-200 dark:bg-emerald-800 text-emerald-800 dark:text-emerald-200",children:a("admin.weather.badge")})]}),r.jsxs("div",{className:"px-4 pb-3",children:[r.jsx("p",{className:"text-xs text-emerald-800 dark:text-emerald-300 leading-relaxed",children:a("admin.weather.description")}),r.jsx("p",{className:"text-[11px] text-emerald-600 dark:text-emerald-400 mt-1.5 leading-relaxed",children:a("admin.weather.locationHint")}),r.jsxs("div",{className:"mt-3 grid grid-cols-1 sm:grid-cols-3 gap-2",children:[r.jsxs("div",{className:"rounded-md bg-white dark:bg-emerald-900/40 px-3 py-2 border border-emerald-100 dark:border-emerald-800",children:[r.jsx("p",{className:"text-xs font-semibold text-emerald-900 dark:text-emerald-200",children:a("admin.weather.forecast")}),r.jsx("p",{className:"text-[11px] text-emerald-600 dark:text-emerald-400 mt-0.5",children:a("admin.weather.forecastDesc")})]}),r.jsxs("div",{className:"rounded-md bg-white dark:bg-emerald-900/40 px-3 py-2 border border-emerald-100 dark:border-emerald-800",children:[r.jsx("p",{className:"text-xs font-semibold text-emerald-900 dark:text-emerald-200",children:a("admin.weather.climate")}),r.jsx("p",{className:"text-[11px] text-emerald-600 dark:text-emerald-400 mt-0.5",children:a("admin.weather.climateDesc")})]}),r.jsxs("div",{className:"rounded-md bg-white dark:bg-emerald-900/40 px-3 py-2 border border-emerald-100 dark:border-emerald-800",children:[r.jsx("p",{className:"text-xs font-semibold text-emerald-900 dark:text-emerald-200",children:a("admin.weather.requests")}),r.jsx("p",{className:"text-[11px] text-emerald-600 dark:text-emerald-400 mt-0.5",children:a("admin.weather.requestsDesc")})]})]})]})]}),r.jsxs("button",{onClick:Et,disabled:_e,className:"flex items-center gap-2 px-4 py-2 bg-slate-900 text-white rounded-lg text-sm hover:bg-slate-700 disabled:bg-slate-400",children:[_e?r.jsx("div",{className:"w-4 h-4 border-2 border-white/30 border-t-white rounded-full animate-spin"}):r.jsx(ll,{className:"w-4 h-4"}),a("common.save")]})]})]}),r.jsxs("div",{className:"bg-white rounded-xl border border-slate-200 overflow-hidden",children:[r.jsxs("div",{className:"px-6 py-4 border-b border-slate-100",children:[r.jsx("h2",{className:"font-semibold text-slate-900",children:a("admin.oidcTitle")}),r.jsx("p",{className:"text-xs text-slate-400 mt-1",children:a("admin.oidcSubtitle")})]}),r.jsxs("div",{className:"p-6 space-y-4",children:[r.jsxs("div",{children:[r.jsx("label",{className:"block text-sm font-medium text-slate-700 mb-1.5",children:a("admin.oidcDisplayName")}),r.jsx("input",{type:"text",value:R.display_name,onChange:re=>$(Ie=>({...Ie,display_name:re.target.value})),placeholder:"z.B. Google, Authentik, Keycloak",className:"w-full px-3 py-2 border border-slate-300 rounded-lg text-sm focus:ring-2 focus:ring-slate-400 focus:border-transparent"})]}),r.jsxs("div",{children:[r.jsx("label",{className:"block text-sm font-medium text-slate-700 mb-1.5",children:a("admin.oidcIssuer")}),r.jsx("input",{type:"url",value:R.issuer,onChange:re=>$(Ie=>({...Ie,issuer:re.target.value})),placeholder:"https://accounts.google.com",className:"w-full px-3 py-2 border border-slate-300 rounded-lg text-sm focus:ring-2 focus:ring-slate-400 focus:border-transparent"}),r.jsx("p",{className:"text-xs text-slate-400 mt-1",children:a("admin.oidcIssuerHint")})]}),r.jsxs("div",{children:[r.jsx("label",{className:"block text-sm font-medium text-slate-700 mb-1.5",children:"Client ID"}),r.jsx("input",{type:"text",value:R.client_id,onChange:re=>$(Ie=>({...Ie,client_id:re.target.value})),className:"w-full px-3 py-2 border border-slate-300 rounded-lg text-sm focus:ring-2 focus:ring-slate-400 focus:border-transparent"})]}),r.jsxs("div",{children:[r.jsx("label",{className:"block text-sm font-medium text-slate-700 mb-1.5",children:"Client Secret"}),r.jsx("input",{type:"password",value:R.client_secret,onChange:re=>$(Ie=>({...Ie,client_secret:re.target.value})),placeholder:R.client_secret_set?"••••••••":"",className:"w-full px-3 py-2 border border-slate-300 rounded-lg text-sm focus:ring-2 focus:ring-slate-400 focus:border-transparent"})]}),r.jsxs("div",{className:"flex items-center justify-between pt-2 border-t border-slate-100",children:[r.jsxs("div",{children:[r.jsx("p",{className:"text-sm font-medium text-slate-700",children:a("admin.oidcOnlyMode")}),r.jsx("p",{className:"text-xs text-slate-400 mt-0.5",children:a("admin.oidcOnlyModeHint")})]}),r.jsx("button",{onClick:()=>$(re=>({...re,oidc_only:!re.oidc_only})),className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors flex-shrink-0 ml-4 ${R.oidc_only?"bg-slate-900":"bg-slate-300"}`,children:r.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${R.oidc_only?"translate-x-6":"translate-x-1"}`})})]}),r.jsxs("button",{onClick:async()=>{Y(!0);try{const re={issuer:R.issuer,client_id:R.client_id,display_name:R.display_name,oidc_only:R.oidc_only};R.client_secret&&(re.client_secret=R.client_secret),await Rt.updateOidc(re),Be.success(a("admin.oidcSaved"))}catch(re){Be.error(at(re,a("common.error")))}finally{Y(!1)}},disabled:I,className:"flex items-center gap-2 px-4 py-2 bg-slate-900 text-white rounded-lg text-sm hover:bg-slate-700 disabled:bg-slate-400",children:[I?r.jsx("div",{className:"w-4 h-4 border-2 border-white/30 border-t-white rounded-full animate-spin"}):r.jsx(ll,{className:"w-4 h-4"}),a("common.save")]})]})]}),r.jsxs("div",{className:"bg-white rounded-xl border border-slate-200 overflow-hidden",children:[r.jsxs("div",{className:"px-6 py-4 border-b border-slate-100",children:[r.jsx("h2",{className:"font-semibold text-slate-900",children:a("admin.smtp.title")}),r.jsx("p",{className:"text-xs text-slate-400 mt-1",children:a("admin.smtp.hint")})]}),r.jsxs("div",{className:"p-6 space-y-3",children:[be&&[{key:"smtp_host",label:"SMTP Host",placeholder:"mail.example.com"},{key:"smtp_port",label:"SMTP Port",placeholder:"587"},{key:"smtp_user",label:"SMTP User",placeholder:"trek@example.com"},{key:"smtp_pass",label:"SMTP Password",placeholder:"••••••••",type:"password"},{key:"smtp_from",label:"From Address",placeholder:"trek@example.com"},{key:"notification_webhook_url",label:"Webhook URL (optional)",placeholder:"https://discord.com/api/webhooks/..."},{key:"app_url",label:"App URL (for email links)",placeholder:"https://trek.example.com"}].map(re=>r.jsxs("div",{children:[r.jsx("label",{className:"block text-xs font-medium text-slate-500 mb-1",children:re.label}),r.jsx("input",{type:re.type||"text",value:te[re.key]||"",onChange:Ie=>oe(At=>({...At,[re.key]:Ie.target.value})),placeholder:re.placeholder,onBlur:Ie=>{Ie.target.value!==""&&jt.updateAppSettings({[re.key]:Ie.target.value}).then(()=>Be.success(a("common.saved"))).catch(()=>{})},className:"w-full px-3 py-2 border border-slate-300 rounded-lg text-sm focus:ring-2 focus:ring-slate-400 focus:border-transparent"})]},re.key)),r.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"4px 0"},children:[r.jsxs("div",{children:[r.jsx("span",{className:"text-xs font-medium text-slate-500",children:"Skip TLS certificate check"}),r.jsx("p",{className:"text-[10px] text-slate-400 mt-0.5",children:"Enable for self-signed certificates on local mail servers"})]}),r.jsx("button",{onClick:async()=>{const re=te.smtp_skip_tls_verify==="true"?"false":"true";oe(Ie=>({...Ie,smtp_skip_tls_verify:re})),await jt.updateAppSettings({smtp_skip_tls_verify:re}).catch(()=>{})},className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors ${te.smtp_skip_tls_verify==="true"?"bg-slate-900":"bg-slate-300"}`,children:r.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${te.smtp_skip_tls_verify==="true"?"translate-x-6":"translate-x-1"}`})})]}),r.jsx("button",{onClick:async()=>{for(const re of["smtp_host","smtp_port","smtp_user","smtp_pass","smtp_from"])te[re]&&await jt.updateAppSettings({[re]:te[re]}).catch(()=>{});try{const re=await Rp.testSmtp();re.success?Be.success(a("admin.smtp.testSuccess")):Be.error(re.error||a("admin.smtp.testFailed"))}catch{Be.error(a("admin.smtp.testFailed"))}},className:"px-4 py-2 bg-slate-900 text-white rounded-lg text-sm font-medium hover:bg-slate-800 transition-colors",children:a("admin.smtp.testButton")})]})]})]}),s==="backup"&&r.jsx(b7,{}),s==="audit"&&r.jsx(C7,{}),s==="mcp-tokens"&&r.jsx(z7,{}),s==="github"&&r.jsx(x7,{})]})}),r.jsx(zi,{isOpen:_,onClose:()=>w(!1),title:a("admin.createUser"),size:"sm",footer:r.jsxs("div",{className:"flex gap-3 justify-end",children:[r.jsx("button",{onClick:()=>w(!1),className:"px-4 py-2 text-sm text-slate-600 border border-slate-200 rounded-lg hover:bg-slate-50",children:a("common.cancel")}),r.jsx("button",{onClick:Zt,className:"px-4 py-2 text-sm bg-slate-900 hover:bg-slate-700 text-white rounded-lg",children:a("admin.createUser")})]}),children:r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{children:[r.jsxs("label",{className:"block text-sm font-medium text-slate-700 mb-1.5",children:[a("settings.username")," *"]}),r.jsx("input",{type:"text",value:E.username,onChange:re=>M(Ie=>({...Ie,username:re.target.value})),placeholder:a("settings.username"),className:"w-full px-3 py-2.5 border border-slate-300 rounded-lg text-slate-900 focus:ring-2 focus:ring-slate-400 focus:border-transparent text-sm"})]}),r.jsxs("div",{children:[r.jsxs("label",{className:"block text-sm font-medium text-slate-700 mb-1.5",children:[a("common.email")," *"]}),r.jsx("input",{type:"email",value:E.email,onChange:re=>M(Ie=>({...Ie,email:re.target.value})),placeholder:a("common.email"),className:"w-full px-3 py-2.5 border border-slate-300 rounded-lg text-slate-900 focus:ring-2 focus:ring-slate-400 focus:border-transparent text-sm"})]}),r.jsxs("div",{children:[r.jsxs("label",{className:"block text-sm font-medium text-slate-700 mb-1.5",children:[a("common.password")," *"]}),r.jsx("input",{type:"password",value:E.password,onChange:re=>M(Ie=>({...Ie,password:re.target.value})),placeholder:a("common.password"),className:"w-full px-3 py-2.5 border border-slate-300 rounded-lg text-slate-900 focus:ring-2 focus:ring-slate-400 focus:border-transparent text-sm"})]}),r.jsxs("div",{children:[r.jsx("label",{className:"block text-sm font-medium text-slate-700 mb-1.5",children:a("settings.role")}),r.jsx(ea,{value:E.role,onChange:re=>M(Ie=>({...Ie,role:re})),options:[{value:"user",label:a("settings.roleUser")},{value:"admin",label:a("settings.roleAdmin")}]})]})]})}),r.jsx(zi,{isOpen:!!x,onClose:()=>k(null),title:a("admin.editUser"),size:"sm",footer:r.jsxs("div",{className:"flex gap-3 justify-end",children:[r.jsx("button",{onClick:()=>k(null),className:"px-4 py-2 text-sm text-slate-600 border border-slate-200 rounded-lg hover:bg-slate-50",children:a("common.cancel")}),r.jsx("button",{onClick:Za,className:"px-4 py-2 text-sm bg-slate-900 hover:bg-slate-700 text-white rounded-lg",children:a("common.save")})]}),children:x&&r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{children:[r.jsx("label",{className:"block text-sm font-medium text-slate-700 mb-1.5",children:a("settings.username")}),r.jsx("input",{type:"text",value:S.username,onChange:re=>v(Ie=>({...Ie,username:re.target.value})),className:"w-full px-3 py-2.5 border border-slate-300 rounded-lg text-slate-900 focus:ring-2 focus:ring-slate-400 focus:border-transparent text-sm"})]}),r.jsxs("div",{children:[r.jsx("label",{className:"block text-sm font-medium text-slate-700 mb-1.5",children:a("common.email")}),r.jsx("input",{type:"email",value:S.email,onChange:re=>v(Ie=>({...Ie,email:re.target.value})),className:"w-full px-3 py-2.5 border border-slate-300 rounded-lg text-slate-900 focus:ring-2 focus:ring-slate-400 focus:border-transparent text-sm"})]}),r.jsxs("div",{children:[r.jsxs("label",{className:"block text-sm font-medium text-slate-700 mb-1.5",children:[a("admin.newPassword")," ",r.jsxs("span",{className:"text-slate-400 font-normal",children:["(",a("admin.newPasswordHint"),")"]})]}),r.jsx("input",{type:"password",value:S.password,onChange:re=>v(Ie=>({...Ie,password:re.target.value})),placeholder:a("admin.newPasswordPlaceholder"),className:"w-full px-3 py-2.5 border border-slate-300 rounded-lg text-slate-900 focus:ring-2 focus:ring-slate-400 focus:border-transparent text-sm"})]}),r.jsxs("div",{children:[r.jsx("label",{className:"block text-sm font-medium text-slate-700 mb-1.5",children:a("settings.role")}),r.jsx(ea,{value:S.role,onChange:re=>v(Ie=>({...Ie,role:re})),options:[{value:"user",label:a("settings.roleUser")},{value:"admin",label:a("settings.roleAdmin")}]})]})]})}),Pe&&r.jsx("div",{style:{position:"fixed",inset:0,zIndex:9999,background:"rgba(0,0,0,0.5)",backdropFilter:"blur(4px)",display:"flex",alignItems:"center",justifyContent:"center",padding:16},onClick:()=>{ne||ye(!1)},children:r.jsx("div",{onClick:re=>re.stopPropagation(),style:{width:"100%",maxWidth:440,borderRadius:16,overflow:"hidden"},className:"bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700",children:Ee==="success"?r.jsxs(r.Fragment,{children:[r.jsxs("div",{style:{background:"linear-gradient(135deg, #16a34a, #15803d)",padding:"20px 24px",display:"flex",alignItems:"center",gap:12},children:[r.jsx("div",{style:{width:40,height:40,borderRadius:10,background:"rgba(255,255,255,0.2)",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:r.jsx(fd,{size:20,style:{color:"white"}})}),r.jsx("div",{children:r.jsx("h3",{style:{margin:0,fontSize:16,fontWeight:700,color:"white"},children:a("admin.update.success")})})]}),r.jsxs("div",{style:{padding:"20px 24px",textAlign:"center"},children:[r.jsx(ic,{className:"w-5 h-5 animate-spin mx-auto mb-2",style:{color:"var(--text-muted)"}}),r.jsx("p",{style:{fontSize:13,color:"var(--text-muted)"},children:a("admin.update.reloadHint")})]})]}):Ee==="error"?r.jsxs(r.Fragment,{children:[r.jsxs("div",{style:{background:"linear-gradient(135deg, #dc2626, #b91c1c)",padding:"20px 24px",display:"flex",alignItems:"center",gap:12},children:[r.jsx("div",{style:{width:40,height:40,borderRadius:10,background:"rgba(255,255,255,0.2)",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:r.jsx(Uf,{size:20,style:{color:"white"}})}),r.jsx("div",{children:r.jsx("h3",{style:{margin:0,fontSize:16,fontWeight:700,color:"white"},children:a("admin.update.failed")})})]}),r.jsx("div",{style:{padding:"0 24px 20px",display:"flex",justifyContent:"flex-end",marginTop:16},children:r.jsx("button",{onClick:()=>{ye(!1),Oe(null)},className:"bg-slate-900 dark:bg-white text-white dark:text-slate-900 hover:bg-slate-700 dark:hover:bg-gray-200",style:{padding:"9px 20px",borderRadius:10,fontSize:13,fontWeight:600,border:"none",cursor:"pointer",fontFamily:"inherit"},children:a("common.cancel")})})]}):r.jsxs(r.Fragment,{children:[r.jsxs("div",{style:{background:"linear-gradient(135deg, #dc2626, #b91c1c)",padding:"20px 24px",display:"flex",alignItems:"center",gap:12},children:[r.jsx("div",{style:{width:40,height:40,borderRadius:10,background:"rgba(255,255,255,0.2)",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:r.jsx(li,{size:20,style:{color:"white"}})}),r.jsxs("div",{children:[r.jsx("h3",{style:{margin:0,fontSize:16,fontWeight:700,color:"white"},children:a("admin.update.confirmTitle")}),r.jsxs("p",{style:{margin:"2px 0 0",fontSize:12,color:"rgba(255,255,255,0.8)"},children:["v",G==null?void 0:G.current," → v",G==null?void 0:G.latest]})]})]}),r.jsx("div",{style:{padding:"20px 24px"},children:G!=null&&G.is_docker?r.jsxs(r.Fragment,{children:[r.jsx("p",{className:"text-gray-700 dark:text-gray-300",style:{fontSize:13,lineHeight:1.6,margin:0},children:a("admin.update.dockerText").replace("{version}",`v${G.latest}`)}),r.jsx("div",{style:{marginTop:14,padding:"12px 14px",borderRadius:10,fontSize:12,lineHeight:1.8,fontFamily:"monospace",whiteSpace:"pre-wrap",wordBreak:"break-all"},className:"bg-gray-900 dark:bg-gray-950 text-gray-100 border border-gray-700",children:`docker pull mauriceboe/nomad:latest
+docker stop nomad && docker rm nomad
+docker run -d --name nomad \\
+ -p 3000:3000 \\
+ -v /opt/nomad/data:/app/data \\
+ -v /opt/nomad/uploads:/app/uploads \\
+ --restart unless-stopped \\
+ mauriceboe/nomad:latest`}),r.jsx("div",{style:{marginTop:10,padding:"10px 12px",borderRadius:10,fontSize:12,lineHeight:1.5},className:"bg-emerald-50 dark:bg-emerald-900/30 text-emerald-700 dark:text-emerald-300 border border-emerald-200 dark:border-emerald-800",children:r.jsxs("div",{className:"flex items-start gap-2",children:[r.jsx(fd,{className:"w-3.5 h-3.5 mt-0.5 flex-shrink-0"}),r.jsx("span",{children:a("admin.update.dataInfo")})]})})]}):r.jsxs(r.Fragment,{children:[r.jsx("p",{className:"text-gray-700 dark:text-gray-300",style:{fontSize:13,lineHeight:1.6,margin:0},children:G&&a("admin.update.confirmText").replace("{current}",`v${G.current}`).replace("{version}",`v${G.latest}`)}),r.jsx("div",{style:{marginTop:14,padding:"10px 12px",borderRadius:10,fontSize:12,lineHeight:1.5},className:"bg-emerald-50 dark:bg-emerald-900/30 text-emerald-700 dark:text-emerald-300 border border-emerald-200 dark:border-emerald-800",children:r.jsxs("div",{className:"flex items-start gap-2",children:[r.jsx(fd,{className:"w-3.5 h-3.5 mt-0.5 flex-shrink-0"}),r.jsx("span",{children:a("admin.update.dataInfo")})]})}),r.jsx("div",{style:{marginTop:10,padding:"10px 12px",borderRadius:10,fontSize:12,lineHeight:1.5},className:"bg-blue-50 dark:bg-blue-900/30 text-blue-700 dark:text-blue-300 border border-blue-200 dark:border-blue-800",children:r.jsxs("div",{className:"flex items-start gap-2",children:[r.jsx(Xs,{className:"w-3.5 h-3.5 mt-0.5 flex-shrink-0"}),r.jsxs("span",{children:[a("admin.update.backupHint")," ",r.jsx("button",{onClick:()=>{ye(!1),d("backup")},className:"underline font-semibold hover:text-blue-950 dark:hover:text-blue-100",children:a("admin.update.backupLink")})]})]})}),r.jsx("div",{style:{marginTop:10,padding:"10px 12px",borderRadius:10,fontSize:12,lineHeight:1.5},className:"bg-red-50 dark:bg-red-900/30 text-red-700 dark:text-red-300 border border-red-200 dark:border-red-800",children:r.jsxs("div",{className:"flex items-start gap-2",children:[r.jsx(li,{className:"w-3.5 h-3.5 mt-0.5 flex-shrink-0"}),r.jsx("span",{children:a("admin.update.warning")})]})})]})}),r.jsxs("div",{style:{padding:"0 24px 20px",display:"flex",gap:10,justifyContent:"flex-end"},children:[r.jsx("button",{onClick:()=>ye(!1),disabled:ne,className:"text-gray-600 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700 disabled:opacity-40",style:{padding:"9px 20px",borderRadius:10,fontSize:13,fontWeight:600,border:"none",cursor:"pointer",fontFamily:"inherit"},children:a("common.cancel")}),!(G!=null&&G.is_docker)&&r.jsxs("button",{onClick:Ce,disabled:ne,className:"bg-slate-900 dark:bg-white text-white dark:text-slate-900 hover:bg-slate-700 dark:hover:bg-gray-200 disabled:opacity-60 flex items-center gap-2",style:{padding:"9px 20px",borderRadius:10,fontSize:13,fontWeight:600,border:"none",cursor:"pointer",fontFamily:"inherit"},children:[ne?r.jsx(wl,{size:14,className:"animate-spin"}):r.jsx(Xs,{size:14}),a(ne?"admin.update.installing":"admin.update.confirm")]})]})]})})})]})}const cd="trek_mfa_backup_codes_pending",P7=[{name:"OpenStreetMap",url:"https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"},{name:"OpenStreetMap DE",url:"https://tile.openstreetmap.de/{z}/{x}/{y}.png"},{name:"CartoDB Light",url:"https://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}{r}.png"},{name:"CartoDB Dark",url:"https://{s}.basemaps.cartocdn.com/dark_all/{z}/{x}/{y}{r}.png"},{name:"Stadia Smooth",url:"https://tiles.stadiamaps.com/tiles/alidade_smooth/{z}/{x}/{y}{r}.png"}];function Ns({title:e,icon:t,children:a}){return r.jsxs("div",{className:"rounded-xl border overflow-hidden",style:{background:"var(--bg-card)",borderColor:"var(--border-primary)",breakInside:"avoid",marginBottom:24},children:[r.jsxs("div",{className:"px-6 py-4 border-b flex items-center gap-2",style:{borderColor:"var(--border-secondary)"},children:[r.jsx(t,{className:"w-5 h-5",style:{color:"var(--text-secondary)"}}),r.jsx("h2",{className:"font-semibold",style:{color:"var(--text-primary)"},children:e})]}),r.jsx("div",{className:"p-6 space-y-4",children:a})]})}function E7({t:e,memoriesEnabled:t}){const[a,n]=b.useState(null),[i,o]=b.useState({});b.useEffect(()=>{Rp.getPreferences().then(c=>n(c.preferences)).catch(()=>{})},[]),b.useEffect(()=>{ie.get("/addons").then(c=>{const p={};for(const m of c.data.addons||[])p[m.id]=!!m.enabled;o(p)}).catch(()=>{})},[]);const s=async c=>{if(!a)return;const p=a[c]?0:1;n(m=>m&&{...m,[c]:p});try{await Rp.updatePreferences({[c]:!!p})}catch{}};if(!a)return r.jsx("p",{style:{fontSize:12,color:"var(--text-faint)"},children:e("common.loading")});const d=[{key:"notify_trip_invite",label:e("settings.notifyTripInvite")},{key:"notify_booking_change",label:e("settings.notifyBookingChange")},...i.vacay?[{key:"notify_vacay_invite",label:e("settings.notifyVacayInvite")}]:[],...t?[{key:"notify_photos_shared",label:e("settings.notifyPhotosShared")}]:[],...i.collab?[{key:"notify_collab_message",label:e("settings.notifyCollabMessage")}]:[],...i.documents?[{key:"notify_packing_tagged",label:e("settings.notifyPackingTagged")}]:[],{key:"notify_webhook",label:e("settings.notifyWebhook")}];return r.jsx("div",{style:{display:"flex",flexDirection:"column",gap:12},children:d.map(c=>r.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[r.jsx("span",{style:{fontSize:13,color:"var(--text-primary)"},children:c.label}),r.jsx("button",{onClick:()=>s(c.key),style:{position:"relative",width:44,height:24,borderRadius:12,border:"none",cursor:"pointer",background:a[c.key]?"var(--accent, #111827)":"var(--border-primary, #d1d5db)",transition:"background 0.2s"},children:r.jsx("span",{style:{position:"absolute",top:2,left:a[c.key]?22:2,width:20,height:20,borderRadius:"50%",background:"white",transition:"left 0.2s",boxShadow:"0 1px 3px rgba(0,0,0,0.2)"}})})]},c.key))})}function A7(){var he;const{user:e,updateProfile:t,uploadAvatar:a,deleteAvatar:n,logout:i,loadUser:o,demoMode:s,appRequireMfa:d}=cn(),[c]=BN(),[p,m]=b.useState(!1),g=Ka.useRef(null),{settings:f,updateSetting:y,updateSettings:x}=ta(),{isEnabled:k,loadAddons:S}=Uv(),{t:v,locale:_}=ot(),w=ya(),E=Br(),[M,A]=b.useState({}),P=k("memories"),R=k("mcp"),[$,I]=b.useState(""),[Y,H]=b.useState(""),[V,X]=b.useState(!1),[Z,O]=b.useState(!1);b.useEffect(()=>{S()},[]),b.useEffect(()=>{P&&ie.get("/integrations/immich/settings").then(ee=>{I(ee.data.immich_url||""),X(ee.data.connected)}).catch(()=>{})},[P]);const Q=async()=>{A(ee=>({...ee,immich:!0}));try{await ie.put("/integrations/immich/settings",{immich_url:$,immich_api_key:Y||void 0}),w.success(v("memories.saved"));const ee=await ie.get("/integrations/immich/status");X(ee.data.connected)}catch{w.error(v("memories.connectionError"))}finally{A(ee=>({...ee,immich:!1}))}},D=async()=>{var ee;O(!0);try{const ge=await ie.get("/integrations/immich/status");ge.data.connected?(w.success(`${v("memories.connectionSuccess")} — ${((ee=ge.data.user)==null?void 0:ee.name)||""}`),X(!0)):(w.error(`${v("memories.connectionError")}: ${ge.data.error}`),X(!1))}catch{w.error(v("memories.connectionError"))}finally{O(!1)}},[J,z]=b.useState([]),[W,B]=b.useState(!1),[C,U]=b.useState(""),[q,te]=b.useState(null),[oe,be]=b.useState(!1),[Se,je]=b.useState(null),[we,ce]=b.useState(null);b.useEffect(()=>{jt.mcpTokens.list().then(ee=>z(ee.tokens||[])).catch(()=>{})},[]);const le=async()=>{if(C.trim()){be(!0);try{const ee=await jt.mcpTokens.create(C.trim());te(ee.token.raw_token),U(""),z(ge=>[{id:ee.token.id,name:ee.token.name,token_prefix:ee.token.token_prefix,created_at:ee.token.created_at,last_used_at:null},...ge])}catch{w.error(v("settings.mcp.toast.createError"))}finally{be(!1)}}},K=async ee=>{try{await jt.mcpTokens.delete(ee),z(ge=>ge.filter(Me=>Me.id!==ee)),je(null),w.success(v("settings.mcp.toast.deleted"))}catch{w.error(v("settings.mcp.toast.deleteError"))}},de=(ee,ge)=>{navigator.clipboard.writeText(ee).then(()=>{ce(ge),setTimeout(()=>ce(null),2e3)})},_e=`${window.location.origin}/mcp`,pe=`{
+ "mcpServers": {
+ "trek": {
+ "command": "npx",
+ "args": [
+ "mcp-remote",
+ "${_e}",
+ "--header",
+ "Authorization: Bearer "
+ ]
+ }
+ }
+}`,[Ae,He]=b.useState(f.map_tile_url||""),[ze,Ye]=b.useState(f.default_lat||48.8566),[G,ve]=b.useState(f.default_lng||2.3522),[Pe,ye]=b.useState(f.default_zoom||10),[ne,fe]=b.useState(f.temperature_unit||"celsius"),[Ee,Oe]=b.useState((e==null?void 0:e.username)||""),[Ke,dt]=b.useState((e==null?void 0:e.email)||""),[Wt,Be]=b.useState(""),[Gt,Kt]=b.useState(""),[Lt,Ce]=b.useState(""),[De,Qe]=b.useState(!1);b.useEffect(()=>{var ee;(ee=jt.getAppConfig)==null||ee.call(jt).then(ge=>{ge!=null&&ge.oidc_only_mode&&Qe(!0)}).catch(()=>{})},[]);const[ft,Et]=b.useState(null),[pt,Zt]=b.useState(null),[jn,ga]=b.useState(""),[Ot,Xt]=b.useState(""),[Za,It]=b.useState(""),[re,Ie]=b.useState(!1),At=!s&&!(e!=null&&e.mfa_enabled)&&(c.get("mfa")==="required"||d),[va,ba]=b.useState(null),Ue=(va==null?void 0:va.join(`
+`))||"";b.useEffect(()=>{if(!(!(e!=null&&e.mfa_enabled)||va))try{const ee=sessionStorage.getItem(cd);if(!ee)return;const ge=JSON.parse(ee);Array.isArray(ge)&&ge.length>0&&ge.every(Me=>typeof Me=="string")&&ba(ge)}catch{sessionStorage.removeItem(cd)}},[e==null?void 0:e.mfa_enabled,va]);const Xn=()=>{sessionStorage.removeItem(cd),ba(null)},_n=async()=>{if(Ue)try{await navigator.clipboard.writeText(Ue),w.success(v("settings.mfa.backupCopied"))}catch{w.error(v("common.error"))}},an=()=>{if(!Ue)return;const ee=new Blob([Ue+`
+`],{type:"text/plain;charset=utf-8"}),ge=URL.createObjectURL(ee),Me=document.createElement("a");Me.href=ge,Me.download="trek-mfa-backup-codes.txt",document.body.appendChild(Me),Me.click(),Me.remove(),URL.revokeObjectURL(ge)},Ea=()=>{if(!Ue)return;const ee=`TREK MFA Backup Codes
+
+ TREK MFA Backup Codes
${new Date().toLocaleString()}
${Ue}`,ge=window.open("","_blank","width=900,height=700");ge&&(ge.document.open(),ge.document.write(ee),ge.document.close(),ge.focus(),ge.print())};b.useEffect(()=>{He(f.map_tile_url||""),Ye(f.default_lat||48.8566),ve(f.default_lng||2.3522),ye(f.default_zoom||10),fe(f.temperature_unit||"celsius")},[f]),b.useEffect(()=>{Oe((e==null?void 0:e.username)||""),dt((e==null?void 0:e.email)||"")},[e]);const Jn=async()=>{A(ee=>({...ee,map:!0}));try{await x({map_tile_url:Ae,default_lat:parseFloat(String(ze)),default_lng:parseFloat(String(G)),default_zoom:parseInt(String(Pe))}),w.success(v("settings.toast.mapSaved"))}catch(ee){w.error(ee instanceof Error?ee.message:"Error")}finally{A(ee=>({...ee,map:!1}))}},ja=async ee=>{var Me;const ge=(Me=ee.target.files)==null?void 0:Me[0];if(ge){try{await a(ge),w.success(v("settings.avatarUploaded"))}catch{w.error(v("settings.avatarError"))}g.current&&(g.current.value="")}},N=async()=>{try{await n(),w.success(v("settings.avatarRemoved"))}catch{w.error(v("settings.avatarError"))}},se=async()=>{A(ee=>({...ee,profile:!0}));try{await t({username:Ee,email:Ke}),w.success(v("settings.toast.profileSaved"))}catch(ee){w.error(ee instanceof Error?ee.message:"Error")}finally{A(ee=>({...ee,profile:!1}))}};return r.jsxs("div",{className:"min-h-screen",style:{background:"var(--bg-secondary)"},children:[r.jsx(Mi,{}),r.jsx("div",{style:{paddingTop:"var(--nav-h)"},children:r.jsxs("div",{className:"max-w-5xl mx-auto px-4 py-8",children:[r.jsx("style",{children:"@media (max-width: 900px) { .settings-columns { column-count: 1 !important; } }"}),r.jsxs("div",{style:{marginBottom:24},children:[r.jsx("h1",{className:"text-2xl font-bold",style:{color:"var(--text-primary)"},children:v("settings.title")}),r.jsx("p",{className:"text-sm mt-0.5",style:{color:"var(--text-muted)"},children:v("settings.subtitle")})]}),r.jsxs("div",{className:"settings-columns",style:{columnCount:2,columnGap:24},children:[r.jsxs(Ns,{title:v("settings.map"),icon:vs,children:[r.jsxs("div",{children:[r.jsx("label",{className:"block text-sm font-medium text-slate-700 mb-1.5",children:v("settings.mapTemplate")}),r.jsx(ea,{value:"",onChange:ee=>{ee&&He(ee)},placeholder:v("settings.mapTemplatePlaceholder.select"),options:P7.map(ee=>({value:ee.url,label:ee.name})),size:"sm",style:{marginBottom:8}}),r.jsx("input",{type:"text",value:Ae,onChange:ee=>He(ee.target.value),placeholder:"https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",className:"w-full px-3 py-2 border border-slate-300 rounded-lg text-sm focus:ring-2 focus:ring-slate-400 focus:border-transparent"}),r.jsx("p",{className:"text-xs text-slate-400 mt-1",children:v("settings.mapDefaultHint")})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[r.jsxs("div",{children:[r.jsx("label",{className:"block text-sm font-medium text-slate-700 mb-1.5",children:v("settings.latitude")}),r.jsx("input",{type:"number",step:"any",value:ze,onChange:ee=>Ye(ee.target.value),className:"w-full px-3 py-2 border border-slate-300 rounded-lg text-sm focus:ring-2 focus:ring-slate-400 focus:border-transparent"})]}),r.jsxs("div",{children:[r.jsx("label",{className:"block text-sm font-medium text-slate-700 mb-1.5",children:v("settings.longitude")}),r.jsx("input",{type:"number",step:"any",value:G,onChange:ee=>ve(ee.target.value),className:"w-full px-3 py-2 border border-slate-300 rounded-lg text-sm focus:ring-2 focus:ring-slate-400 focus:border-transparent"})]})]}),r.jsxs("button",{onClick:Jn,disabled:M.map,className:"flex items-center gap-2 px-4 py-2 bg-slate-900 text-white rounded-lg text-sm hover:bg-slate-700 disabled:bg-slate-400",children:[M.map?r.jsx("div",{className:"w-4 h-4 border-2 border-white/30 border-t-white rounded-full animate-spin"}):r.jsx(ll,{className:"w-4 h-4"}),v("settings.saveMap")]})]}),r.jsxs(Ns,{title:v("settings.display"),icon:eD,children:[r.jsxs("div",{children:[r.jsx("label",{className:"block text-sm font-medium mb-2",style:{color:"var(--text-secondary)"},children:v("settings.colorMode")}),r.jsx("div",{className:"flex gap-3",children:[{value:"light",label:v("settings.light"),icon:Rl},{value:"dark",label:v("settings.dark"),icon:S_},{value:"auto",label:v("settings.auto"),icon:YM}].map(ee=>{const ge=f.dark_mode,Me=ge===ee.value||ee.value==="light"&&ge===!1||ee.value==="dark"&&ge===!0;return r.jsxs("button",{onClick:async()=>{try{await y("dark_mode",ee.value)}catch($e){w.error($e instanceof Error?$e.message:"Error")}},style:{display:"flex",alignItems:"center",gap:8,padding:"10px 20px",borderRadius:10,cursor:"pointer",fontFamily:"inherit",fontSize:14,fontWeight:500,border:Me?"2px solid var(--text-primary)":"2px solid var(--border-primary)",background:Me?"var(--bg-hover)":"var(--bg-card)",color:"var(--text-primary)",transition:"all 0.15s"},children:[r.jsx(ee.icon,{size:16}),ee.label]},ee.value)})})]}),r.jsxs("div",{children:[r.jsx("label",{className:"block text-sm font-medium mb-2",style:{color:"var(--text-secondary)"},children:v("settings.language")}),r.jsx("div",{className:"flex flex-wrap gap-3",children:Mp.map(ee=>r.jsx("button",{onClick:async()=>{try{await y("language",ee.value)}catch(ge){w.error(ge instanceof Error?ge.message:"Error")}},style:{display:"flex",alignItems:"center",gap:8,padding:"10px 20px",borderRadius:10,cursor:"pointer",fontFamily:"inherit",fontSize:14,fontWeight:500,border:f.language===ee.value?"2px solid var(--text-primary)":"2px solid var(--border-primary)",background:f.language===ee.value?"var(--bg-hover)":"var(--bg-card)",color:"var(--text-primary)",transition:"all 0.15s"},children:ee.label},ee.value))})]}),r.jsxs("div",{children:[r.jsx("label",{className:"block text-sm font-medium mb-2",style:{color:"var(--text-secondary)"},children:v("settings.temperature")}),r.jsx("div",{className:"flex gap-3",children:[{value:"celsius",label:"°C Celsius"},{value:"fahrenheit",label:"°F Fahrenheit"}].map(ee=>r.jsx("button",{onClick:async()=>{fe(ee.value);try{await y("temperature_unit",ee.value)}catch(ge){w.error(ge instanceof Error?ge.message:"Error")}},style:{display:"flex",alignItems:"center",gap:8,padding:"10px 20px",borderRadius:10,cursor:"pointer",fontFamily:"inherit",fontSize:14,fontWeight:500,border:ne===ee.value?"2px solid var(--text-primary)":"2px solid var(--border-primary)",background:ne===ee.value?"var(--bg-hover)":"var(--bg-card)",color:"var(--text-primary)",transition:"all 0.15s"},children:ee.label},ee.value))})]}),r.jsxs("div",{children:[r.jsx("label",{className:"block text-sm font-medium mb-2",style:{color:"var(--text-secondary)"},children:v("settings.timeFormat")}),r.jsx("div",{className:"flex gap-3",children:[{value:"24h",label:"24h (14:30)"},{value:"12h",label:"12h (2:30 PM)"}].map(ee=>r.jsx("button",{onClick:async()=>{try{await y("time_format",ee.value)}catch(ge){w.error(ge instanceof Error?ge.message:"Error")}},style:{display:"flex",alignItems:"center",gap:8,padding:"10px 20px",borderRadius:10,cursor:"pointer",fontFamily:"inherit",fontSize:14,fontWeight:500,border:f.time_format===ee.value?"2px solid var(--text-primary)":"2px solid var(--border-primary)",background:f.time_format===ee.value?"var(--bg-hover)":"var(--bg-card)",color:"var(--text-primary)",transition:"all 0.15s"},children:ee.label},ee.value))})]}),r.jsxs("div",{children:[r.jsx("label",{className:"block text-sm font-medium mb-2",style:{color:"var(--text-secondary)"},children:v("settings.routeCalculation")}),r.jsx("div",{className:"flex gap-3",children:[{value:!0,label:v("settings.on")||"On"},{value:!1,label:v("settings.off")||"Off"}].map(ee=>r.jsx("button",{onClick:async()=>{try{await y("route_calculation",ee.value)}catch(ge){w.error(ge instanceof Error?ge.message:"Error")}},style:{display:"flex",alignItems:"center",gap:8,padding:"10px 20px",borderRadius:10,cursor:"pointer",fontFamily:"inherit",fontSize:14,fontWeight:500,border:f.route_calculation!==!1===ee.value?"2px solid var(--text-primary)":"2px solid var(--border-primary)",background:f.route_calculation!==!1===ee.value?"var(--bg-hover)":"var(--bg-card)",color:"var(--text-primary)",transition:"all 0.15s"},children:ee.label},String(ee.value)))})]}),r.jsxs("div",{children:[r.jsx("label",{className:"block text-sm font-medium mb-2",style:{color:"var(--text-secondary)"},children:v("settings.blurBookingCodes")}),r.jsx("div",{className:"flex gap-3",children:[{value:!0,label:v("settings.on")||"On"},{value:!1,label:v("settings.off")||"Off"}].map(ee=>r.jsx("button",{onClick:async()=>{try{await y("blur_booking_codes",ee.value)}catch(ge){w.error(ge instanceof Error?ge.message:"Error")}},style:{display:"flex",alignItems:"center",gap:8,padding:"10px 20px",borderRadius:10,cursor:"pointer",fontFamily:"inherit",fontSize:14,fontWeight:500,border:!!f.blur_booking_codes===ee.value?"2px solid var(--text-primary)":"2px solid var(--border-primary)",background:!!f.blur_booking_codes===ee.value?"var(--bg-hover)":"var(--bg-card)",color:"var(--text-primary)",transition:"all 0.15s"},children:ee.label},String(ee.value)))})]})]}),r.jsx(Ns,{title:v("settings.notifications"),icon:Sl,children:r.jsx(E7,{t:v,memoriesEnabled:P})}),P&&r.jsx(Ns,{title:"Immich",icon:Ir,children:r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{children:[r.jsx("label",{className:"block text-sm font-medium text-slate-700 mb-1.5",children:v("memories.immichUrl")}),r.jsx("input",{type:"url",value:$,onChange:ee=>I(ee.target.value),placeholder:"https://immich.example.com",className:"w-full px-3 py-2.5 border border-slate-200 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-slate-300"})]}),r.jsxs("div",{children:[r.jsx("label",{className:"block text-sm font-medium text-slate-700 mb-1.5",children:v("memories.immichApiKey")}),r.jsx("input",{type:"password",value:Y,onChange:ee=>H(ee.target.value),placeholder:V?"••••••••":"API Key",className:"w-full px-3 py-2.5 border border-slate-200 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-slate-300"})]}),r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsxs("button",{onClick:Q,disabled:M.immich,className:"flex items-center gap-2 px-4 py-2 bg-slate-900 text-white rounded-lg text-sm hover:bg-slate-700 disabled:bg-slate-400",children:[r.jsx(ll,{className:"w-4 h-4"})," ",v("common.save")]}),r.jsxs("button",{onClick:D,disabled:Z,className:"flex items-center gap-2 px-4 py-2 border border-slate-200 rounded-lg text-sm hover:bg-slate-50",children:[Z?r.jsx("div",{className:"w-4 h-4 border-2 border-slate-300 border-t-slate-700 rounded-full animate-spin"}):r.jsx(Ir,{className:"w-4 h-4"}),v("memories.testConnection")]}),V&&r.jsxs("span",{className:"text-xs font-medium text-green-600 flex items-center gap-1",children:[r.jsx("span",{className:"w-2 h-2 bg-green-500 rounded-full"}),v("memories.connected")]})]})]})}),R&&r.jsxs(Ns,{title:v("settings.mcp.title"),icon:__,children:[r.jsxs("div",{children:[r.jsx("label",{className:"block text-sm font-medium mb-1.5",style:{color:"var(--text-secondary)"},children:v("settings.mcp.endpoint")}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("code",{className:"flex-1 px-3 py-2 rounded-lg text-sm font-mono border",style:{background:"var(--bg-secondary)",borderColor:"var(--border-primary)",color:"var(--text-primary)"},children:_e}),r.jsx("button",{onClick:()=>de(_e,"endpoint"),className:"p-2 rounded-lg border transition-colors hover:bg-slate-100 dark:hover:bg-slate-700",style:{borderColor:"var(--border-primary)"},title:v("settings.mcp.copy"),children:we==="endpoint"?r.jsx(Ga,{className:"w-4 h-4 text-green-500"}):r.jsx(Ys,{className:"w-4 h-4",style:{color:"var(--text-secondary)"}})})]})]}),r.jsxs("div",{children:[r.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[r.jsx("label",{className:"block text-sm font-medium",style:{color:"var(--text-secondary)"},children:v("settings.mcp.clientConfig")}),r.jsxs("button",{onClick:()=>de(pe,"json"),className:"flex items-center gap-1.5 px-2.5 py-1 rounded text-xs border transition-colors hover:bg-slate-100 dark:hover:bg-slate-700",style:{borderColor:"var(--border-primary)",color:"var(--text-secondary)"},children:[we==="json"?r.jsx(Ga,{className:"w-3 h-3 text-green-500"}):r.jsx(Ys,{className:"w-3 h-3"}),v(we==="json"?"settings.mcp.copied":"settings.mcp.copy")]})]}),r.jsx("pre",{className:"p-3 rounded-lg text-xs font-mono overflow-x-auto border",style:{background:"var(--bg-secondary)",borderColor:"var(--border-primary)",color:"var(--text-primary)"},children:pe}),r.jsx("p",{className:"mt-1.5 text-xs",style:{color:"var(--text-tertiary)"},children:v("settings.mcp.clientConfigHint")})]}),r.jsxs("div",{children:[r.jsxs("div",{className:"flex items-center justify-between mb-2",children:[r.jsx("label",{className:"text-sm font-medium",style:{color:"var(--text-secondary)"},children:v("settings.mcp.apiTokens")}),r.jsxs("button",{onClick:()=>{B(!0),te(null),U("")},className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-sm font-medium transition-colors",style:{background:"var(--accent-primary, #4f46e5)",color:"#fff"},children:[r.jsx(Ft,{className:"w-3.5 h-3.5"})," ",v("settings.mcp.createToken")]})]}),J.length===0?r.jsx("p",{className:"text-sm py-3 text-center rounded-lg border",style:{color:"var(--text-tertiary)",borderColor:"var(--border-primary)"},children:v("settings.mcp.noTokens")}):r.jsx("div",{className:"rounded-lg border overflow-hidden",style:{borderColor:"var(--border-primary)"},children:J.map((ee,ge)=>r.jsxs("div",{className:"flex items-center gap-3 px-4 py-3",style:{borderBottom:geje(ee.id),className:"p-1.5 rounded-lg transition-colors hover:bg-red-50 hover:text-red-600 dark:hover:bg-red-900/20",style:{color:"var(--text-tertiary)"},title:v("settings.mcp.deleteTokenTitle"),children:r.jsx(_t,{className:"w-4 h-4"})})]},ee.id))})]})]}),W&&r.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",style:{background:"rgba(0,0,0,0.5)"},onClick:ee=>{ee.target===ee.currentTarget&&!q&&B(!1)},children:r.jsx("div",{className:"rounded-xl shadow-xl w-full max-w-md p-6 space-y-4",style:{background:"var(--bg-card)"},children:q?r.jsxs(r.Fragment,{children:[r.jsx("h3",{className:"text-lg font-semibold",style:{color:"var(--text-primary)"},children:v("settings.mcp.modal.createdTitle")}),r.jsxs("div",{className:"flex items-start gap-2 p-3 rounded-lg border border-amber-200",style:{background:"rgba(251,191,36,0.1)"},children:[r.jsx("span",{className:"text-amber-500 mt-0.5",children:"⚠"}),r.jsx("p",{className:"text-sm",style:{color:"var(--text-secondary)"},children:v("settings.mcp.modal.createdWarning")})]}),r.jsxs("div",{className:"relative",children:[r.jsx("pre",{className:"p-3 pr-10 rounded-lg text-xs font-mono break-all border whitespace-pre-wrap",style:{background:"var(--bg-secondary)",borderColor:"var(--border-primary)",color:"var(--text-primary)"},children:q}),r.jsx("button",{onClick:()=>de(q,"new-token"),className:"absolute top-2 right-2 p-1.5 rounded transition-colors hover:bg-slate-200 dark:hover:bg-slate-600",style:{color:"var(--text-secondary)"},title:v("settings.mcp.copy"),children:we==="new-token"?r.jsx(Ga,{className:"w-4 h-4 text-green-500"}):r.jsx(Ys,{className:"w-4 h-4"})})]}),r.jsx("div",{className:"flex justify-end",children:r.jsx("button",{onClick:()=>{B(!1),te(null)},className:"px-4 py-2 rounded-lg text-sm font-medium text-white",style:{background:"var(--accent-primary, #4f46e5)"},children:v("settings.mcp.modal.done")})})]}):r.jsxs(r.Fragment,{children:[r.jsx("h3",{className:"text-lg font-semibold",style:{color:"var(--text-primary)"},children:v("settings.mcp.modal.createTitle")}),r.jsxs("div",{children:[r.jsx("label",{className:"block text-sm font-medium mb-1.5",style:{color:"var(--text-secondary)"},children:v("settings.mcp.modal.tokenName")}),r.jsx("input",{type:"text",value:C,onChange:ee=>U(ee.target.value),onKeyDown:ee=>ee.key==="Enter"&&le(),placeholder:v("settings.mcp.modal.tokenNamePlaceholder"),className:"w-full px-3 py-2.5 border rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-indigo-300",style:{borderColor:"var(--border-primary)",background:"var(--bg-secondary)",color:"var(--text-primary)"},autoFocus:!0})]}),r.jsxs("div",{className:"flex gap-2 justify-end pt-1",children:[r.jsx("button",{onClick:()=>B(!1),className:"px-4 py-2 rounded-lg text-sm border",style:{borderColor:"var(--border-primary)",color:"var(--text-secondary)"},children:v("common.cancel")}),r.jsx("button",{onClick:le,disabled:!C.trim()||oe,className:"px-4 py-2 rounded-lg text-sm font-medium text-white disabled:opacity-50",style:{background:"var(--accent-primary, #4f46e5)"},children:v(oe?"settings.mcp.modal.creating":"settings.mcp.modal.create")})]})]})})}),Se!==null&&r.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",style:{background:"rgba(0,0,0,0.5)"},onClick:ee=>{ee.target===ee.currentTarget&&je(null)},children:r.jsxs("div",{className:"rounded-xl shadow-xl w-full max-w-sm p-6 space-y-4",style:{background:"var(--bg-card)"},children:[r.jsx("h3",{className:"text-base font-semibold",style:{color:"var(--text-primary)"},children:v("settings.mcp.deleteTokenTitle")}),r.jsx("p",{className:"text-sm",style:{color:"var(--text-secondary)"},children:v("settings.mcp.deleteTokenMessage")}),r.jsxs("div",{className:"flex gap-2 justify-end",children:[r.jsx("button",{onClick:()=>je(null),className:"px-4 py-2 rounded-lg text-sm border",style:{borderColor:"var(--border-primary)",color:"var(--text-secondary)"},children:v("common.cancel")}),r.jsx("button",{onClick:()=>K(Se),className:"px-4 py-2 rounded-lg text-sm font-medium text-white bg-red-600 hover:bg-red-700",children:v("settings.mcp.deleteTokenTitle")})]})]})}),r.jsxs(Ns,{title:v("settings.account"),icon:Bv,children:[r.jsxs("div",{children:[r.jsx("label",{className:"block text-sm font-medium text-slate-700 mb-1.5",children:v("settings.username")}),r.jsx("input",{type:"text",value:Ee,onChange:ee=>Oe(ee.target.value),className:"w-full px-3 py-2 border border-slate-300 rounded-lg text-sm focus:ring-2 focus:ring-slate-400 focus:border-transparent"})]}),r.jsxs("div",{children:[r.jsx("label",{className:"block text-sm font-medium text-slate-700 mb-1.5",children:v("settings.email")}),r.jsx("input",{type:"email",value:Ke,onChange:ee=>dt(ee.target.value),className:"w-full px-3 py-2 border border-slate-300 rounded-lg text-sm focus:ring-2 focus:ring-slate-400 focus:border-transparent"})]}),!De&&r.jsxs("div",{style:{paddingTop:16,marginTop:16,borderTop:"1px solid var(--border-secondary)"},children:[r.jsx("label",{className:"block text-sm font-medium text-slate-700 mb-3",children:v("settings.changePassword")}),r.jsxs("div",{className:"space-y-3",children:[r.jsx("input",{type:"password",value:Wt,onChange:ee=>Be(ee.target.value),placeholder:v("settings.currentPassword"),className:"w-full px-3 py-2 border border-slate-300 rounded-lg text-sm focus:ring-2 focus:ring-slate-400 focus:border-transparent"}),r.jsx("input",{type:"password",value:Gt,onChange:ee=>Kt(ee.target.value),placeholder:v("settings.newPassword"),className:"w-full px-3 py-2 border border-slate-300 rounded-lg text-sm focus:ring-2 focus:ring-slate-400 focus:border-transparent"}),r.jsx("input",{type:"password",value:Lt,onChange:ee=>Ce(ee.target.value),placeholder:v("settings.confirmPassword"),className:"w-full px-3 py-2 border border-slate-300 rounded-lg text-sm focus:ring-2 focus:ring-slate-400 focus:border-transparent"}),r.jsxs("button",{onClick:async()=>{if(!Wt)return w.error(v("settings.currentPasswordRequired"));if(!Gt)return w.error(v("settings.passwordRequired"));if(Gt.length<8)return w.error(v("settings.passwordTooShort"));if(Gt!==Lt)return w.error(v("settings.passwordMismatch"));try{await jt.changePassword({current_password:Wt,new_password:Gt}),w.success(v("settings.passwordChanged")),Be(""),Kt(""),Ce("")}catch(ee){w.error(at(ee,v("common.error")))}},className:"flex items-center gap-2 px-4 py-2 rounded-lg text-sm font-medium transition-colors",style:{border:"1px solid var(--border-primary)",background:"var(--bg-card)",color:"var(--text-secondary)"},onMouseEnter:ee=>ee.currentTarget.style.background="var(--bg-hover)",onMouseLeave:ee=>ee.currentTarget.style.background="var(--bg-card)",children:[r.jsx(Sl,{size:14}),v("settings.updatePassword")]})]})]}),r.jsxs("div",{style:{paddingTop:16,marginTop:16,borderTop:"1px solid var(--border-secondary)"},children:[r.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[r.jsx(Of,{className:"w-5 h-5",style:{color:"var(--text-secondary)"}}),r.jsx("h3",{className:"font-semibold text-base m-0",style:{color:"var(--text-primary)"},children:v("settings.mfa.title")})]}),r.jsxs("div",{className:"space-y-3",children:[At&&r.jsxs("div",{className:"flex gap-3 p-3 rounded-lg border text-sm",style:{background:"var(--bg-secondary)",borderColor:"var(--border-primary)",color:"var(--text-primary)"},children:[r.jsx(li,{className:"w-5 h-5 flex-shrink-0 text-amber-600"}),r.jsx("p",{className:"m-0 leading-relaxed",children:v("settings.mfa.requiredByPolicy")})]}),r.jsx("p",{className:"text-sm m-0",style:{color:"var(--text-muted)",lineHeight:1.5},children:v("settings.mfa.description")}),s?r.jsx("p",{className:"text-sm text-amber-700 m-0",children:v("settings.mfa.demoBlocked")}):r.jsxs(r.Fragment,{children:[r.jsx("p",{className:"text-sm font-medium m-0",style:{color:"var(--text-secondary)"},children:e!=null&&e.mfa_enabled?v("settings.mfa.enabled"):v("settings.mfa.disabled")}),!(e!=null&&e.mfa_enabled)&&!ft&&r.jsxs("button",{type:"button",disabled:re,onClick:async()=>{Ie(!0);try{const ee=await jt.mfaSetup();Et(ee.qr_data_url),Zt(ee.secret),ga("")}catch(ee){w.error(at(ee,v("common.error")))}finally{Ie(!1)}},className:"flex items-center gap-2 px-4 py-2 rounded-lg text-sm font-medium transition-colors",style:{border:"1px solid var(--border-primary)",background:"var(--bg-card)",color:"var(--text-primary)"},children:[re?r.jsx("div",{className:"w-4 h-4 border-2 border-slate-300 border-t-slate-700 rounded-full animate-spin"}):r.jsx(Of,{size:14}),v("settings.mfa.setup")]}),!(e!=null&&e.mfa_enabled)&&ft&&r.jsxs("div",{className:"space-y-3",children:[r.jsx("p",{className:"text-sm",style:{color:"var(--text-muted)"},children:v("settings.mfa.scanQr")}),r.jsx("img",{src:ft,alt:"",className:"rounded-lg border mx-auto block",style:{maxWidth:200,borderColor:"var(--border-primary)"}}),r.jsxs("div",{children:[r.jsx("label",{className:"block text-xs font-medium mb-1",style:{color:"var(--text-secondary)"},children:v("settings.mfa.secretLabel")}),r.jsx("code",{className:"block text-xs p-2 rounded break-all",style:{background:"var(--bg-hover)",color:"var(--text-primary)"},children:pt})]}),r.jsx("input",{type:"text",inputMode:"numeric",value:jn,onChange:ee=>ga(ee.target.value.replace(/\D/g,"").slice(0,8)),placeholder:v("settings.mfa.codePlaceholder"),className:"w-full px-3 py-2 border border-slate-300 rounded-lg text-sm"}),r.jsxs("div",{className:"flex flex-wrap gap-2",children:[r.jsx("button",{type:"button",disabled:re||jn.length<6,onClick:async()=>{Ie(!0);try{const ee=await jt.mfaEnable({code:jn});w.success(v("settings.mfa.toastEnabled")),Et(null),Zt(null),ga("");const ge=ee.backup_codes||null;if(ge!=null&&ge.length)try{sessionStorage.setItem(cd,JSON.stringify(ge))}catch{}ba(ge),await o({silent:!0})}catch(ee){w.error(at(ee,v("common.error")))}finally{Ie(!1)}},className:"px-4 py-2 bg-slate-900 text-white rounded-lg text-sm hover:bg-slate-700 disabled:opacity-50",children:v("settings.mfa.enable")}),r.jsx("button",{type:"button",onClick:()=>{Et(null),Zt(null),ga("")},className:"px-4 py-2 rounded-lg text-sm border",style:{borderColor:"var(--border-primary)",color:"var(--text-secondary)"},children:v("settings.mfa.cancelSetup")})]})]}),(e==null?void 0:e.mfa_enabled)&&r.jsxs("div",{className:"space-y-3",children:[r.jsx("p",{className:"text-sm font-medium",style:{color:"var(--text-secondary)"},children:v("settings.mfa.disableTitle")}),r.jsx("p",{className:"text-xs",style:{color:"var(--text-muted)"},children:v("settings.mfa.disableHint")}),r.jsx("input",{type:"password",value:Ot,onChange:ee=>Xt(ee.target.value),placeholder:v("settings.currentPassword"),className:"w-full px-3 py-2 border border-slate-300 rounded-lg text-sm"}),r.jsx("input",{type:"text",inputMode:"numeric",value:Za,onChange:ee=>It(ee.target.value.replace(/\D/g,"").slice(0,8)),placeholder:v("settings.mfa.codePlaceholder"),className:"w-full px-3 py-2 border border-slate-300 rounded-lg text-sm"}),r.jsx("button",{type:"button",disabled:re||!Ot||Za.length<6,onClick:async()=>{Ie(!0);try{await jt.mfaDisable({password:Ot,code:Za}),w.success(v("settings.mfa.toastDisabled")),Xt(""),It(""),sessionStorage.removeItem(cd),ba(null),await o({silent:!0})}catch(ee){w.error(at(ee,v("common.error")))}finally{Ie(!1)}},className:"px-4 py-2 rounded-lg text-sm font-medium text-red-600 border border-red-200 hover:bg-red-50 disabled:opacity-50",children:v("settings.mfa.disable")})]}),va&&va.length>0&&r.jsxs("div",{className:"space-y-3 p-3 rounded-lg border",style:{borderColor:"var(--border-primary)",background:"var(--bg-hover)"},children:[r.jsx("p",{className:"text-sm font-semibold m-0",style:{color:"var(--text-primary)"},children:v("settings.mfa.backupTitle")}),r.jsx("p",{className:"text-xs m-0",style:{color:"var(--text-muted)"},children:v("settings.mfa.backupDescription")}),r.jsx("pre",{className:"text-xs m-0 p-2 rounded border overflow-auto",style:{borderColor:"var(--border-primary)",background:"var(--bg-card)",color:"var(--text-primary)",maxHeight:220},children:Ue}),r.jsx("p",{className:"text-xs m-0",style:{color:"#b45309"},children:v("settings.mfa.backupWarning")}),r.jsxs("div",{className:"flex flex-wrap gap-2",children:[r.jsxs("button",{type:"button",onClick:_n,className:"px-3 py-2 rounded-lg text-xs border flex items-center gap-1.5",style:{borderColor:"var(--border-primary)",color:"var(--text-secondary)"},children:[r.jsx(Ys,{size:13})," ",v("settings.mfa.backupCopy")]}),r.jsxs("button",{type:"button",onClick:an,className:"px-3 py-2 rounded-lg text-xs border flex items-center gap-1.5",style:{borderColor:"var(--border-primary)",color:"var(--text-secondary)"},children:[r.jsx(Xs,{size:13})," ",v("settings.mfa.backupDownload")]}),r.jsxs("button",{type:"button",onClick:Ea,className:"px-3 py-2 rounded-lg text-xs border flex items-center gap-1.5",style:{borderColor:"var(--border-primary)",color:"var(--text-secondary)"},children:[r.jsx(lD,{size:13})," ",v("settings.mfa.backupPrint")]}),r.jsx("button",{type:"button",onClick:Xn,className:"px-3 py-2 rounded-lg text-xs border",style:{borderColor:"var(--border-primary)",color:"var(--text-secondary)"},children:v("common.ok")})]})]})]})]})]}),r.jsxs("div",{className:"flex items-center gap-4",children:[r.jsxs("div",{style:{position:"relative",flexShrink:0},children:[e!=null&&e.avatar_url?r.jsx("img",{src:e.avatar_url,alt:"",style:{width:64,height:64,borderRadius:"50%",objectFit:"cover"}}):r.jsx("div",{style:{width:64,height:64,borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",fontSize:24,fontWeight:700,background:"var(--bg-hover)",color:"var(--text-secondary)"},children:(he=e==null?void 0:e.username)==null?void 0:he.charAt(0).toUpperCase()}),r.jsx("input",{ref:g,type:"file",accept:"image/*",onChange:ja,style:{display:"none"}}),r.jsx("button",{onClick:()=>{var ee;return(ee=g.current)==null?void 0:ee.click()},style:{position:"absolute",bottom:-3,right:-3,width:28,height:28,borderRadius:"50%",background:"var(--text-primary)",color:"var(--bg-card)",border:"2px solid var(--bg-card)",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",padding:0,transition:"transform 0.15s, opacity 0.15s"},onMouseEnter:ee=>{ee.currentTarget.style.transform="scale(1.15)",ee.currentTarget.style.opacity="0.85"},onMouseLeave:ee=>{ee.currentTarget.style.transform="scale(1)",ee.currentTarget.style.opacity="1"},children:r.jsx(Ir,{size:14})}),(e==null?void 0:e.avatar_url)&&r.jsx("button",{onClick:N,style:{position:"absolute",top:-2,right:-2,width:20,height:20,borderRadius:"50%",background:"#ef4444",color:"white",border:"2px solid var(--bg-card)",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",padding:0},children:r.jsx(_t,{size:10})})]}),r.jsxs("div",{className:"flex flex-col gap-1",children:[r.jsxs("div",{className:"text-sm",style:{color:"var(--text-muted)"},children:[r.jsx("span",{className:"font-medium",style:{display:"inline-flex",alignItems:"center",gap:4,color:"var(--text-secondary)"},children:(e==null?void 0:e.role)==="admin"?r.jsxs(r.Fragment,{children:[r.jsx(di,{size:13})," ",v("settings.roleAdmin")]}):v("settings.roleUser")}),(e==null?void 0:e.oidc_issuer)&&r.jsx("span",{style:{display:"inline-flex",alignItems:"center",gap:4,fontSize:10,fontWeight:500,padding:"1px 8px",borderRadius:99,background:"#dbeafe",color:"#1d4ed8",marginLeft:6},children:"SSO"})]}),(e==null?void 0:e.oidc_issuer)&&r.jsxs("p",{style:{fontSize:11,color:"var(--text-faint)",marginTop:-2},children:[v("settings.oidcLinked")," ",e.oidc_issuer.replace("https://","").replace(/\/+$/,"")]})]})]}),r.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginTop:12},children:[r.jsxs("button",{onClick:se,disabled:M.profile,className:"flex items-center gap-2 px-4 py-2 bg-slate-900 text-white rounded-lg text-sm hover:bg-slate-700 disabled:bg-slate-400",children:[M.profile?r.jsx("div",{className:"w-4 h-4 border-2 border-white/30 border-t-white rounded-full animate-spin"}):r.jsx(ll,{className:"w-4 h-4"}),v("settings.saveProfile")]}),r.jsxs("button",{onClick:async()=>{if((e==null?void 0:e.role)==="admin")try{const ee=await Rt.stats();if((await Rt.users()).users.filter(Me=>Me.role==="admin").length<=1){m("blocked");return}}catch{}m(!0)},className:"flex items-center gap-2 px-4 py-2 rounded-lg text-sm font-medium transition-colors text-red-500 hover:bg-red-50",style:{border:"1px solid #fecaca"},children:[r.jsx(_t,{size:14}),v("settings.deleteAccount")]})]})]}),p==="blocked"&&r.jsx("div",{style:{position:"fixed",inset:0,zIndex:9999,background:"rgba(0,0,0,0.5)",backdropFilter:"blur(4px)",display:"flex",alignItems:"center",justifyContent:"center",padding:24},onClick:()=>m(!1),children:r.jsxs("div",{style:{background:"var(--bg-card)",borderRadius:16,padding:"28px 24px",maxWidth:400,width:"100%",boxShadow:"0 20px 60px rgba(0,0,0,0.3)"},onClick:ee=>ee.stopPropagation(),children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,marginBottom:16},children:[r.jsx("div",{style:{width:36,height:36,borderRadius:10,background:"#fef3c7",display:"flex",alignItems:"center",justifyContent:"center"},children:r.jsx(di,{size:18,style:{color:"#d97706"}})}),r.jsx("h3",{style:{margin:0,fontSize:16,fontWeight:700,color:"var(--text-primary)"},children:v("settings.deleteBlockedTitle")})]}),r.jsx("p",{style:{fontSize:13,color:"var(--text-muted)",lineHeight:1.6,margin:"0 0 20px"},children:v("settings.deleteBlockedMessage")}),r.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:r.jsx("button",{onClick:()=>m(!1),style:{padding:"8px 16px",borderRadius:8,fontSize:13,fontWeight:500,border:"1px solid var(--border-primary)",background:"var(--bg-card)",color:"var(--text-secondary)",cursor:"pointer",fontFamily:"inherit"},children:v("common.ok")||"OK"})})]})}),p===!0&&r.jsx("div",{style:{position:"fixed",inset:0,zIndex:9999,background:"rgba(0,0,0,0.5)",backdropFilter:"blur(4px)",display:"flex",alignItems:"center",justifyContent:"center",padding:24},onClick:()=>m(!1),children:r.jsxs("div",{style:{background:"var(--bg-card)",borderRadius:16,padding:"28px 24px",maxWidth:400,width:"100%",boxShadow:"0 20px 60px rgba(0,0,0,0.3)"},onClick:ee=>ee.stopPropagation(),children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,marginBottom:16},children:[r.jsx("div",{style:{width:36,height:36,borderRadius:10,background:"#fef2f2",display:"flex",alignItems:"center",justifyContent:"center"},children:r.jsx(_t,{size:18,style:{color:"#ef4444"}})}),r.jsx("h3",{style:{margin:0,fontSize:16,fontWeight:700,color:"var(--text-primary)"},children:v("settings.deleteAccountTitle")})]}),r.jsx("p",{style:{fontSize:13,color:"var(--text-muted)",lineHeight:1.6,margin:"0 0 20px"},children:v("settings.deleteAccountWarning")}),r.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[r.jsx("button",{onClick:()=>m(!1),style:{padding:"8px 16px",borderRadius:8,fontSize:13,fontWeight:500,border:"1px solid var(--border-primary)",background:"var(--bg-card)",color:"var(--text-secondary)",cursor:"pointer",fontFamily:"inherit"},children:v("common.cancel")}),r.jsx("button",{onClick:async()=>{try{await jt.deleteOwnAccount(),i(),E("/login")}catch(ee){w.error(at(ee,v("common.error"))),m(!1)}},style:{padding:"8px 16px",borderRadius:8,fontSize:13,fontWeight:600,border:"none",background:"#ef4444",color:"white",cursor:"pointer",fontFamily:"inherit"},children:v("settings.deleteAccountConfirm")})]})]})})]})]})})]})}const _a=ie,Fa={getPlan:()=>_a.get("/addons/vacay/plan").then(e=>e.data),updatePlan:e=>_a.put("/addons/vacay/plan",e).then(t=>t.data),updateColor:(e,t)=>_a.put("/addons/vacay/color",{color:e,target_user_id:t}).then(a=>a.data),invite:e=>_a.post("/addons/vacay/invite",{user_id:e}).then(t=>t.data),acceptInvite:e=>_a.post("/addons/vacay/invite/accept",{plan_id:e}).then(t=>t.data),declineInvite:e=>_a.post("/addons/vacay/invite/decline",{plan_id:e}).then(t=>t.data),cancelInvite:e=>_a.post("/addons/vacay/invite/cancel",{user_id:e}).then(t=>t.data),dissolve:()=>_a.post("/addons/vacay/dissolve").then(e=>e.data),availableUsers:()=>_a.get("/addons/vacay/available-users").then(e=>e.data),getYears:()=>_a.get("/addons/vacay/years").then(e=>e.data),addYear:e=>_a.post("/addons/vacay/years",{year:e}).then(t=>t.data),removeYear:e=>_a.delete(`/addons/vacay/years/${e}`).then(t=>t.data),getEntries:e=>_a.get(`/addons/vacay/entries/${e}`).then(t=>t.data),toggleEntry:(e,t)=>_a.post("/addons/vacay/entries/toggle",{date:e,target_user_id:t}).then(a=>a.data),toggleCompanyHoliday:e=>_a.post("/addons/vacay/entries/company-holiday",{date:e}).then(t=>t.data),getStats:e=>_a.get(`/addons/vacay/stats/${e}`).then(t=>t.data),updateStats:(e,t,a)=>_a.put(`/addons/vacay/stats/${e}`,{vacation_days:t,target_user_id:a}).then(n=>n.data),getCountries:()=>_a.get("/addons/vacay/holidays/countries").then(e=>e.data),getHolidays:(e,t)=>_a.get(`/addons/vacay/holidays/${e}/${t}`).then(a=>a.data),addHolidayCalendar:e=>_a.post("/addons/vacay/plan/holiday-calendars",e).then(t=>t.data),updateHolidayCalendar:(e,t)=>_a.put(`/addons/vacay/plan/holiday-calendars/${e}`,t).then(a=>a.data),deleteHolidayCalendar:e=>_a.delete(`/addons/vacay/plan/holiday-calendars/${e}`).then(t=>t.data)},Nc=vc((e,t)=>({plan:null,users:[],pendingInvites:[],incomingInvites:[],isOwner:!0,isFused:!1,years:[],entries:[],companyHolidays:[],stats:[],selectedYear:new Date().getFullYear(),selectedUserId:null,holidays:{},loading:!1,setSelectedYear:a=>e({selectedYear:a}),setSelectedUserId:a=>e({selectedUserId:a}),loadPlan:async()=>{const a=await Fa.getPlan();e({plan:a.plan,users:a.users,pendingInvites:a.pendingInvites,incomingInvites:a.incomingInvites,isOwner:a.isOwner,isFused:a.isFused})},updatePlan:async a=>{const n=await Fa.updatePlan(a);e({plan:n.plan}),await t().loadEntries(),await t().loadStats(),await t().loadHolidays()},updateColor:async(a,n)=>{await Fa.updateColor(a,n),await t().loadPlan(),await t().loadEntries()},invite:async a=>{await Fa.invite(a),await t().loadPlan()},acceptInvite:async a=>{await Fa.acceptInvite(a),await t().loadAll()},declineInvite:async a=>{await Fa.declineInvite(a),await t().loadPlan()},cancelInvite:async a=>{await Fa.cancelInvite(a),await t().loadPlan()},dissolve:async()=>{await Fa.dissolve(),await t().loadAll()},loadYears:async()=>{const a=await Fa.getYears();e({years:a.years}),a.years.length>0&&e({selectedYear:a.years[a.years.length-1]})},addYear:async a=>{const n=await Fa.addYear(a);e({years:n.years}),await t().loadStats(a)},removeYear:async a=>{const n=await Fa.removeYear(a);e({years:n.years})},loadEntries:async a=>{const n=a||t().selectedYear,i=await Fa.getEntries(n);e({entries:i.entries,companyHolidays:i.companyHolidays})},toggleEntry:async(a,n)=>{await Fa.toggleEntry(a,n),await t().loadEntries(),await t().loadStats()},toggleCompanyHoliday:async a=>{await Fa.toggleCompanyHoliday(a),await t().loadEntries()},loadStats:async a=>{const n=a||t().selectedYear,i=await Fa.getStats(n);e({stats:i.stats})},updateVacationDays:async(a,n,i)=>{await Fa.updateStats(a,n,i),await t().loadStats(a)},loadHolidays:async a=>{const n=a||t().selectedYear,i=t().plan,o=(i==null?void 0:i.holiday_calendars)??[];if(!(i!=null&&i.holidays_enabled)||o.length===0){e({holidays:{}});return}const s={};for(const d of o){const c=d.region.split("-")[0],p=d.region.includes("-")?d.region:null;try{const m=await Fa.getHolidays(n,c);if(m.some(f=>f.counties&&f.counties.length>0)&&!p)continue;m.forEach(f=>{(f.global||!f.counties||p&&f.counties.includes(p))&&(s[f.date]||(s[f.date]={name:f.name,localName:f.localName,color:d.color,label:d.label}))})}catch{}}e({holidays:s})},addHolidayCalendar:async a=>{await Fa.addHolidayCalendar(a),await t().loadPlan(),await t().loadHolidays()},updateHolidayCalendar:async(a,n)=>{await Fa.updateHolidayCalendar(a,n),await t().loadPlan(),await t().loadHolidays()},deleteHolidayCalendar:async a=>{await Fa.deleteHolidayCalendar(a),await t().loadPlan(),await t().loadHolidays()},loadAll:async()=>{e({loading:!0});try{await t().loadPlan(),await t().loadYears();const a=t().selectedYear;await t().loadEntries(a),await t().loadStats(a),await t().loadHolidays(a)}finally{e({loading:!1})}}}));function N7(e,t=[0,6]){const a=new Date(e+"T00:00:00");return t.includes(a.getDay())}const R7=["vacay.mon","vacay.tue","vacay.wed","vacay.thu","vacay.fri","vacay.sat","vacay.sun"];function M7(e,t){const a=parseInt(e.slice(1,3),16),n=parseInt(e.slice(3,5),16),i=parseInt(e.slice(5,7),16);return`rgba(${a},${n},${i},${t})`}function D7({year:e,month:t,holidays:a,companyHolidaySet:n,companyHolidaysEnabled:i=!0,entryMap:o,onCellClick:s,companyMode:d,blockWeekends:c,weekendDays:p=[0,6]}){const{t:m,locale:g}=ot(),f=R7.map(S=>m(S)),y=b.useMemo(()=>new Intl.DateTimeFormat(g,{month:"long"}).format(new Date(e,t,1)),[g,e,t]),x=b.useMemo(()=>{const S=new Date(e,t,1),v=new Date(e,t+1,0).getDate();let _=S.getDay()-1;_<0&&(_=6);const w=[];for(let M=0;M<_;M++)w.push(null);for(let M=1;M<=v;M++)w.push(M);for(;w.length%7!==0;)w.push(null);const E=[];for(let M=0;MString(S).padStart(2,"0");return r.jsxs("div",{className:"rounded-xl border overflow-hidden",style:{background:"var(--bg-card)",borderColor:"var(--border-primary)"},children:[r.jsx("div",{className:"px-3 py-2 border-b",style:{borderColor:"var(--border-secondary)"},children:r.jsx("span",{className:"text-xs font-semibold",style:{color:"var(--text-primary)",textTransform:"capitalize"},children:y})}),r.jsx("div",{className:"grid grid-cols-7 border-b",style:{borderColor:"var(--border-secondary)"},children:f.map((S,v)=>r.jsx("div",{className:"text-center text-[10px] font-medium py-1",style:{color:v>=5?"var(--text-faint)":"var(--text-muted)"},children:S},S))}),r.jsx("div",{children:x.map((S,v)=>r.jsx("div",{className:"grid grid-cols-7",children:S.map((_,w)=>{if(_===null)return r.jsx("div",{style:{height:28}},w);const E=`${e}-${k(t+1)}-${k(_)}`,M=new Date(e,t,_).getDay(),A=p.includes(M),P=a[E],R=i&&n.has(E),$=o[E]||[],I=!!P||A&&c||R&&!d;return r.jsxs("div",{className:"relative flex items-center justify-center cursor-pointer transition-colors",style:{height:28,background:A?"var(--bg-secondary)":"transparent",borderTop:"1px solid var(--border-secondary)",borderRight:"1px solid var(--border-secondary)",cursor:I?"default":"pointer"},onClick:()=>s(E),onMouseEnter:Y=>{I||(Y.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:Y=>{Y.currentTarget.style.background=A?"var(--bg-secondary)":"transparent"},children:[P&&r.jsx("div",{className:"absolute inset-0.5 rounded",style:{background:M7(P.color,.12)}}),R&&r.jsx("div",{className:"absolute inset-0.5 rounded",style:{background:"rgba(245,158,11,0.15)"}}),$.length===1&&r.jsx("div",{className:"absolute inset-0.5 rounded",style:{backgroundColor:$[0].person_color,opacity:.4}}),$.length===2&&r.jsx("div",{className:"absolute inset-0.5 rounded",style:{background:`linear-gradient(135deg, ${$[0].person_color} 50%, ${$[1].person_color} 50%)`,opacity:.4}}),$.length===3&&r.jsxs("div",{className:"absolute inset-0.5 rounded overflow-hidden",style:{opacity:.4},children:[r.jsx("div",{className:"absolute top-0 left-0 w-1/2 h-full",style:{backgroundColor:$[0].person_color}}),r.jsx("div",{className:"absolute top-0 right-0 w-1/2 h-1/2",style:{backgroundColor:$[1].person_color}}),r.jsx("div",{className:"absolute bottom-0 right-0 w-1/2 h-1/2",style:{backgroundColor:$[2].person_color}})]}),$.length>=4&&r.jsxs("div",{className:"absolute inset-0.5 rounded overflow-hidden",style:{opacity:.4},children:[r.jsx("div",{className:"absolute top-0 left-0 w-1/2 h-1/2",style:{backgroundColor:$[0].person_color}}),r.jsx("div",{className:"absolute top-0 right-0 w-1/2 h-1/2",style:{backgroundColor:$[1].person_color}}),r.jsx("div",{className:"absolute bottom-0 left-0 w-1/2 h-1/2",style:{backgroundColor:$[2].person_color}}),r.jsx("div",{className:"absolute bottom-0 right-0 w-1/2 h-1/2",style:{backgroundColor:$[3].person_color}})]}),r.jsx("span",{className:"relative z-[1] text-[11px] font-medium",style:{color:P?P.color:A?"var(--text-faint)":"var(--text-primary)",fontWeight:$.length>0?700:500},children:_})]},w)})},v))})]})}function I7(){const{t:e}=ot(),{selectedYear:t,selectedUserId:a,entries:n,companyHolidays:i,toggleEntry:o,toggleCompanyHoliday:s,plan:d,users:c,holidays:p}=Nc(),[m,g]=b.useState(!1),f=b.useMemo(()=>{const w=new Set;return i.forEach(E=>w.add(E.date)),w},[i]),y=b.useMemo(()=>{const w={};return n.forEach(E=>{w[E.date]||(w[E.date]=[]),w[E.date].push(E)}),w},[n]),x=(d==null?void 0:d.block_weekends)!==!1,k=d!=null&&d.weekend_days?String(d.weekend_days).split(",").map(Number):[0,6],S=(d==null?void 0:d.company_holidays_enabled)!==!1,v=b.useCallback(async w=>{if(m){if(!S)return;await s(w);return}p[w]||x&&N7(w,k)||S&&f.has(w)||await o(w,a||void 0)},[m,o,s,p,f,x,S,a]),_=c.find(w=>w.id===a);return r.jsxs("div",{children:[r.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-3",children:Array.from({length:12},(w,E)=>r.jsx(D7,{year:t,month:E,holidays:p,companyHolidaySet:f,companyHolidaysEnabled:S,entryMap:y,onCellClick:v,companyMode:m,blockWeekends:x,weekendDays:k},E))}),r.jsx("div",{className:"sticky bottom-3 sm:bottom-4 mt-3 sm:mt-4 flex items-center justify-center z-30 px-2",children:r.jsxs("div",{className:"flex items-center gap-1.5 sm:gap-2 px-2 sm:px-3 py-1.5 sm:py-2 rounded-xl border",style:{background:"var(--bg-card)",borderColor:"var(--border-primary)",boxShadow:"0 8px 32px rgba(0,0,0,0.12)"},children:[r.jsxs("button",{onClick:()=>g(!1),className:"flex items-center gap-1 sm:gap-1.5 px-2 sm:px-3 py-1.5 rounded-lg text-[11px] sm:text-xs font-medium transition-all",style:{background:m?"transparent":"var(--text-primary)",color:m?"var(--text-muted)":"var(--bg-card)",border:m?"1px solid var(--border-primary)":"1px solid transparent"},children:[r.jsx(JM,{size:13}),_&&r.jsx("span",{className:"w-2.5 h-2.5 rounded-full shrink-0",style:{backgroundColor:_.color}}),_?_.username:e("vacay.modeVacation")]}),S&&r.jsxs("button",{onClick:()=>g(!0),className:"flex items-center gap-1 sm:gap-1.5 px-2 sm:px-3 py-1.5 rounded-lg text-[11px] sm:text-xs font-medium transition-all",style:{background:m?"#d97706":"transparent",color:m?"#fff":"var(--text-muted)",border:m?"1px solid transparent":"1px solid var(--border-primary)"},children:[r.jsx(Dv,{size:13}),e("vacay.modeCompany")]})]})})]})}const L7=["#6366f1","#ec4899","#14b8a6","#8b5cf6","#ef4444","#3b82f6","#22c55e","#06b6d4","#f43f5e","#a855f7","#10b981","#0ea5e9","#64748b","#be185d","#0d9488"];function F7(){var Y;const{t:e}=ot(),t=ya(),{users:a,pendingInvites:n,invite:i,cancelInvite:o,updateColor:s,selectedUserId:d,setSelectedUserId:c,isFused:p}=Nc(),{user:m}=cn();b.useEffect(()=>{!d&&m&&c(m.id)},[m,d]);const[g,f]=b.useState(!1),[y,x]=b.useState(!1),[k,S]=b.useState(null),[v,_]=b.useState([]),[w,E]=b.useState(null),[M,A]=b.useState(!1),P=async()=>{try{const H=await ie.get("/addons/vacay/available-users").then(V=>V.data);_(H.users)}catch{}},R=async()=>{if(w){A(!0);try{await i(w),t.success(e("vacay.inviteSent")),f(!1),E(null)}catch(H){t.error(at(H,e("vacay.inviteError")))}finally{A(!1)}}},$=async H=>{await s(H,k),x(!1),S(null)},I=((Y=a.find(H=>H.id===k))==null?void 0:Y.color)||"#6366f1";return r.jsxs("div",{className:"rounded-xl border p-3",style:{background:"var(--bg-card)",borderColor:"var(--border-primary)"},children:[r.jsxs("div",{className:"flex items-center justify-between mb-2",children:[r.jsx("span",{className:"text-[11px] font-medium uppercase tracking-wider",style:{color:"var(--text-faint)"},children:e("vacay.persons")}),r.jsx("button",{onClick:()=>{f(!0),P()},className:"p-0.5 rounded transition-colors",style:{color:"var(--text-faint)"},children:r.jsx(_c,{size:14})})]}),r.jsxs("div",{className:"flex flex-col gap-0.5",children:[a.map(H=>{const V=d===H.id;return r.jsxs("div",{onClick:()=>{p&&c(H.id)},className:"flex items-center gap-2 px-2.5 py-1.5 rounded-lg group transition-all",style:{background:V?"var(--bg-hover)":"transparent",border:V?"1px solid var(--border-primary)":"1px solid transparent",cursor:p?"pointer":"default"},children:[r.jsx("button",{onClick:X=>{X.stopPropagation(),S(H.id),x(!0)},className:"w-3.5 h-3.5 rounded-full shrink-0 transition-transform hover:scale-125",style:{backgroundColor:H.color,cursor:"pointer"},title:e("vacay.changeColor")}),r.jsxs("span",{className:"text-xs font-medium flex-1 truncate",style:{color:"var(--text-primary)"},children:[H.username,H.id===(m==null?void 0:m.id)&&r.jsxs("span",{style:{color:"var(--text-faint)"},children:[" (",e("vacay.you"),")"]})]}),V&&p&&r.jsx(Ga,{size:12,style:{color:"var(--text-primary)"}})]},H.id)}),n.map(H=>r.jsxs("div",{className:"flex items-center gap-2 px-2.5 py-1.5 rounded-lg group",style:{background:"var(--bg-secondary)",opacity:.7},children:[r.jsx(Nn,{size:12,style:{color:"var(--text-faint)"}}),r.jsxs("span",{className:"text-xs flex-1 truncate",style:{color:"var(--text-muted)"},children:[H.username," ",r.jsxs("span",{className:"text-[10px]",children:["(",e("vacay.pending"),")"]})]}),r.jsx("button",{onClick:()=>o(H.user_id),className:"opacity-0 group-hover:opacity-100 text-[10px] px-1.5 py-0.5 rounded transition-all",style:{color:"var(--text-faint)"},children:e("common.cancel")})]},H.id))]}),g&&Vt.createPortal(r.jsx("div",{className:"fixed inset-0 flex items-center justify-center px-4",style:{zIndex:99990,backgroundColor:"rgba(15,23,42,0.5)",paddingTop:70},onClick:()=>f(!1),children:r.jsxs("div",{className:"rounded-2xl shadow-2xl w-full max-w-sm",style:{background:"var(--bg-card)",animation:"modalIn 0.2s ease-out"},onClick:H=>H.stopPropagation(),children:[r.jsxs("div",{className:"flex items-center justify-between p-5",style:{borderBottom:"1px solid var(--border-secondary)"},children:[r.jsx("h2",{className:"text-base font-semibold",style:{color:"var(--text-primary)"},children:e("vacay.inviteUser")}),r.jsx("button",{onClick:()=>f(!1),className:"p-1.5 rounded-lg transition-colors",style:{color:"var(--text-faint)"},children:r.jsx(gt,{size:16})})]}),r.jsxs("div",{className:"p-5 space-y-4",children:[r.jsx("p",{className:"text-xs",style:{color:"var(--text-muted)"},children:e("vacay.inviteHint")}),v.length===0?r.jsx("p",{className:"text-xs text-center py-4",style:{color:"var(--text-faint)"},children:e("vacay.noUsersAvailable")}):r.jsx(ea,{value:w,onChange:E,options:v.map(H=>({value:H.id,label:`${H.username} (${H.email})`})),placeholder:e("vacay.selectUser"),searchable:!0}),r.jsxs("div",{className:"flex gap-3 justify-end pt-2",children:[r.jsx("button",{onClick:()=>f(!1),className:"px-4 py-2 text-sm rounded-lg",style:{color:"var(--text-muted)",border:"1px solid var(--border-primary)"},children:e("common.cancel")}),r.jsxs("button",{onClick:R,disabled:!w||M,className:"px-4 py-2 text-sm rounded-lg transition-colors flex items-center gap-1.5 disabled:opacity-40",style:{background:"var(--text-primary)",color:"var(--bg-card)"},children:[M&&r.jsx(wl,{size:13,className:"animate-spin"}),e("vacay.sendInvite")]})]})]})]})}),document.body),y&&Vt.createPortal(r.jsx("div",{className:"fixed inset-0 flex items-center justify-center px-4",style:{zIndex:99990,backgroundColor:"rgba(15,23,42,0.5)",paddingTop:70},onClick:()=>{x(!1),S(null)},children:r.jsxs("div",{className:"rounded-2xl shadow-2xl w-full max-w-xs",style:{background:"var(--bg-card)",animation:"modalIn 0.2s ease-out"},onClick:H=>H.stopPropagation(),children:[r.jsxs("div",{className:"flex items-center justify-between p-5",style:{borderBottom:"1px solid var(--border-secondary)"},children:[r.jsx("h2",{className:"text-base font-semibold",style:{color:"var(--text-primary)"},children:e("vacay.changeColor")}),r.jsx("button",{onClick:()=>{x(!1),S(null)},className:"p-1.5 rounded-lg transition-colors",style:{color:"var(--text-faint)"},children:r.jsx(gt,{size:16})})]}),r.jsx("div",{className:"p-5",children:r.jsx("div",{className:"flex flex-wrap gap-2 justify-center",children:L7.map(H=>r.jsx("button",{onClick:()=>$(H),className:`w-8 h-8 rounded-full transition-all ${I===H?"ring-2 ring-offset-2 scale-110":"hover:scale-110"}`,style:{backgroundColor:H}},H))})})]})}),document.body)]})}function O7(){const{t:e}=ot(),{stats:t,selectedYear:a,loadStats:n,updateVacationDays:i,isFused:o}=Nc(),{user:s}=cn();return b.useEffect(()=>{n(a)},[a]),r.jsxs("div",{className:"rounded-xl border p-3",style:{background:"var(--bg-card)",borderColor:"var(--border-primary)"},children:[r.jsxs("div",{className:"flex items-center gap-1.5 mb-3",children:[r.jsx(ys,{size:13,style:{color:"var(--text-faint)"}}),r.jsxs("span",{className:"text-[11px] font-medium uppercase tracking-wider",style:{color:"var(--text-faint)"},children:[e("vacay.entitlement")," ",a]})]}),t.length===0?r.jsx("p",{className:"text-[11px] text-center py-3",style:{color:"var(--text-faint)"},children:e("vacay.noData")}):r.jsx("div",{className:"space-y-2",children:t.map(d=>r.jsx(B7,{stat:d,isMe:d.user_id===(s==null?void 0:s.id),canEdit:d.user_id===(s==null?void 0:s.id)||o,selectedYear:a,onSave:i,t:e},d.user_id))})]})}function B7({stat:e,isMe:t,canEdit:a,selectedYear:n,onSave:i,t:o}){const[s,d]=b.useState(!1),[c,p]=b.useState(e.vacation_days),m=e.total_available>0?Math.min(100,e.used/e.total_available*100):0;b.useEffect(()=>{s||p(e.vacation_days)},[e.vacation_days,s]);const g=()=>{d(!1);const f=parseInt(c);!isNaN(f)&&f>=0&&f<=365&&f!==e.vacation_days&&i(n,f,e.user_id)};return r.jsxs("div",{className:"rounded-lg p-2.5 space-y-2",style:{border:"1px solid var(--border-secondary)"},children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"w-2.5 h-2.5 rounded-full shrink-0",style:{backgroundColor:e.person_color}}),r.jsxs("span",{className:"text-xs font-semibold flex-1 truncate",style:{color:"var(--text-primary)"},children:[e.person_name,t&&r.jsxs("span",{style:{color:"var(--text-faint)"},children:[" (",o("vacay.you"),")"]})]}),r.jsxs("span",{className:"text-[10px] tabular-nums",style:{color:"var(--text-faint)"},children:[e.used,"/",e.total_available]})]}),r.jsx("div",{className:"h-1.5 rounded-full overflow-hidden",style:{background:"var(--bg-secondary)"},children:r.jsx("div",{className:"h-full rounded-full transition-all duration-500",style:{width:`${m}%`,backgroundColor:e.person_color}})}),r.jsxs("div",{className:"grid grid-cols-3 gap-1.5",children:[r.jsxs("div",{className:"rounded-md px-2 py-2 group/days",style:{background:a?"var(--bg-card)":"var(--bg-secondary)",border:a?"1px solid var(--border-primary)":"1px solid transparent",cursor:a?"pointer":"default"},onClick:()=>{a&&!s&&d(!0)},children:[r.jsxs("div",{className:"text-[10px] mb-1",style:{color:"var(--text-faint)",height:14,lineHeight:"14px"},children:[o("vacay.entitlementDays")," ",a&&!s&&r.jsx(sn,{size:9,className:"inline opacity-0 group-hover/days:opacity-100 transition-opacity",style:{color:"var(--text-faint)",verticalAlign:"middle"}})]}),s?r.jsx("input",{type:"number",value:c,onChange:f=>p(f.target.value),onBlur:g,onKeyDown:f=>{f.key==="Enter"&&g(),f.key==="Escape"&&(d(!1),p(e.vacation_days))},autoFocus:!0,className:"w-full bg-transparent text-sm font-bold outline-none p-0 m-0 [appearance:textfield] [&::-webkit-inner-spin-button]:appearance-none",style:{color:"var(--text-primary)",height:18,lineHeight:"18px"}}):r.jsx("div",{className:"text-sm font-bold",style:{color:"var(--text-primary)",height:18,lineHeight:"18px"},children:e.vacation_days})]}),r.jsxs("div",{className:"rounded-md px-2 py-2",style:{background:"var(--bg-secondary)"},children:[r.jsx("div",{className:"text-[10px] mb-1",style:{color:"var(--text-faint)",height:14,lineHeight:"14px"},children:o("vacay.used")}),r.jsx("div",{className:"text-sm font-bold",style:{color:"var(--text-primary)",height:18,lineHeight:"18px"},children:e.used})]}),r.jsxs("div",{className:"rounded-md px-2 py-2",style:{background:"var(--bg-secondary)"},children:[r.jsx("div",{className:"text-[10px] mb-1",style:{color:"var(--text-faint)",height:14,lineHeight:"14px"},children:o("vacay.remaining")}),r.jsx("div",{className:"text-sm font-bold",style:{color:e.remaining<0?"#ef4444":e.remaining<=3?"#f59e0b":"#22c55e",height:18,lineHeight:"18px"},children:e.remaining})]})]}),e.carried_over>0&&r.jsx("div",{className:"flex items-center gap-1.5 px-2 py-1 rounded-md",style:{background:"rgba(245,158,11,0.08)",border:"1px solid rgba(245,158,11,0.15)"},children:r.jsxs("span",{className:"text-[10px]",style:{color:"#d97706"},children:["+",e.carried_over," ",o("vacay.carriedOver",{year:n-1})]})})]})}function H7({onClose:e}){const{t}=ot(),a=ya(),{plan:n,updatePlan:i,addHolidayCalendar:o,updateHolidayCalendar:s,deleteHolidayCalendar:d,isFused:c,dissolve:p,users:m}=Nc(),[g,f]=b.useState([]),[y,x]=b.useState(!1),{language:k}=ot();if(b.useEffect(()=>{ie.get("/addons/vacay/holidays/countries").then(v=>{let _;try{_=new Intl.DisplayNames([o_(k)],{type:"region"})}catch{}const w=v.data.map(E=>({value:E.countryCode,label:_&&_.of(E.countryCode)||E.name}));w.sort((E,M)=>E.label.localeCompare(M.label)),f(w)}).catch(()=>{})},[k]),!n)return null;const S=v=>i({[v]:!n[v]});return r.jsxs("div",{className:"space-y-5",children:[r.jsx(_u,{icon:_M,label:t("vacay.blockWeekends"),hint:t("vacay.blockWeekendsHint"),value:n.block_weekends,onChange:()=>S("block_weekends")}),n.block_weekends!==!1&&r.jsxs("div",{style:{paddingLeft:36},children:[r.jsx("p",{className:"text-xs font-medium mb-2",style:{color:"var(--text-muted)"},children:t("vacay.weekendDays")}),r.jsx("div",{className:"flex flex-wrap gap-1.5",children:[{day:1,label:t("vacay.mon")},{day:2,label:t("vacay.tue")},{day:3,label:t("vacay.wed")},{day:4,label:t("vacay.thu")},{day:5,label:t("vacay.fri")},{day:6,label:t("vacay.sat")},{day:0,label:t("vacay.sun")}].map(({day:v,label:_})=>{const w=n.weekend_days?String(n.weekend_days).split(",").map(Number):[0,6],E=w.includes(v);return r.jsx("button",{onClick:()=>{const M=E?w.filter(A=>A!==v):[...w,v];i({weekend_days:M.join(",")})},style:{padding:"4px 10px",borderRadius:8,fontSize:12,fontWeight:600,cursor:"pointer",fontFamily:"inherit",border:"1px solid",transition:"all 0.12s",background:E?"var(--text-primary)":"var(--bg-card)",borderColor:E?"var(--text-primary)":"var(--border-primary)",color:E?"var(--bg-primary)":"var(--text-muted)"},children:_},v)})})]}),r.jsx(_u,{icon:Am,label:t("vacay.carryOver"),hint:t("vacay.carryOverHint"),value:n.carry_over_enabled,onChange:()=>S("carry_over_enabled")}),r.jsxs("div",{children:[r.jsx(_u,{icon:Dv,label:t("vacay.companyHolidays"),hint:t("vacay.companyHolidaysHint"),value:n.company_holidays_enabled,onChange:()=>S("company_holidays_enabled")}),n.company_holidays_enabled&&r.jsx("div",{className:"ml-7 mt-2",children:r.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-1.5 rounded-md",style:{background:"var(--bg-secondary)"},children:[r.jsx(l_,{size:12,style:{color:"var(--text-faint)"}}),r.jsx("span",{className:"text-[10px]",style:{color:"var(--text-faint)"},children:t("vacay.companyHolidaysNoDeduct")})]})})]}),r.jsxs("div",{children:[r.jsx(_u,{icon:Ri,label:t("vacay.publicHolidays"),hint:t("vacay.publicHolidaysHint"),value:n.holidays_enabled,onChange:()=>S("holidays_enabled")}),n.holidays_enabled&&r.jsxs("div",{className:"ml-7 mt-2 space-y-2",children:[(n.holiday_calendars??[]).length===0&&r.jsx("p",{className:"text-xs",style:{color:"var(--text-faint)"},children:t("vacay.noCalendars")}),(n.holiday_calendars??[]).map(v=>r.jsx(U7,{cal:v,countries:g,language:k,onUpdate:_=>s(v.id,_),onDelete:()=>d(v.id)},v.id)),y?r.jsx(W7,{countries:g,language:k,onAdd:async v=>{await o(v),x(!1)},onCancel:()=>x(!1)}):r.jsxs("button",{onClick:()=>x(!0),className:"flex items-center gap-1.5 text-xs px-2 py-1.5 rounded-md transition-colors",style:{color:"var(--text-muted)",background:"var(--bg-secondary)"},children:[r.jsx(Ft,{size:12}),t("vacay.addCalendar")]})]})]}),c&&r.jsx("div",{className:"pt-4 mt-2 border-t",style:{borderColor:"var(--border-secondary)"},children:r.jsxs("div",{className:"rounded-xl overflow-hidden",style:{border:"1px solid rgba(239,68,68,0.2)"},children:[r.jsxs("div",{className:"px-4 py-3 flex items-center gap-3",style:{background:"rgba(239,68,68,0.06)"},children:[r.jsx("div",{className:"w-8 h-8 rounded-lg flex items-center justify-center",style:{background:"rgba(239,68,68,0.1)"},children:r.jsx(C_,{size:16,className:"text-red-500"})}),r.jsxs("div",{children:[r.jsx("p",{className:"text-sm font-semibold",style:{color:"var(--text-primary)"},children:t("vacay.dissolve")}),r.jsx("p",{className:"text-[11px]",style:{color:"var(--text-faint)"},children:t("vacay.dissolveHint")})]})]}),r.jsx("div",{className:"px-4 py-3 flex items-center gap-2 flex-wrap",style:{borderTop:"1px solid rgba(239,68,68,0.1)"},children:m.map(v=>r.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-1 rounded-md",style:{background:"var(--bg-secondary)"},children:[r.jsx("span",{className:"w-2 h-2 rounded-full",style:{backgroundColor:v.color||"#6366f1"}}),r.jsx("span",{className:"text-xs font-medium",style:{color:"var(--text-primary)"},children:v.username})]},v.id))}),r.jsx("div",{className:"px-4 py-3",style:{borderTop:"1px solid rgba(239,68,68,0.1)"},children:r.jsx("button",{onClick:async()=>{await p(),a.success(t("vacay.dissolved")),e()},className:"w-full px-3 py-2 text-xs font-medium bg-red-500 hover:bg-red-600 text-white rounded-lg transition-colors",children:t("vacay.dissolveAction")})})]})})]})}function _u({icon:e,label:t,hint:a,value:n,onChange:i}){return r.jsxs("div",{className:"flex items-center justify-between gap-3",children:[r.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[r.jsx(e,{size:15,className:"shrink-0",style:{color:"var(--text-muted)"}}),r.jsxs("div",{className:"min-w-0",children:[r.jsx("p",{className:"text-sm font-medium",style:{color:"var(--text-primary)"},children:t}),r.jsx("p",{className:"text-[11px]",style:{color:"var(--text-faint)"},children:a})]})]}),r.jsx("button",{onClick:i,className:"relative shrink-0 inline-flex h-6 w-11 items-center rounded-full transition-colors",style:{background:n?"var(--text-primary)":"var(--border-primary)"},children:r.jsx("span",{className:"absolute left-1 h-4 w-4 rounded-full transition-transform duration-200",style:{background:"var(--bg-card)",transform:n?"translateX(20px)":"translateX(0)"}})})]})}async function bz(e){try{const t=new Date().getFullYear(),a=await ie.get(`/addons/vacay/holidays/${t}/${e}`),n=new Set;return a.data.forEach(i=>{i.counties&&i.counties.forEach(o=>n.add(o))}),n.size===0?[]:[...n].sort().map(i=>{let o=i.split("-")[1]||i;return i.startsWith("DE-")?o={BW:"Baden-Württemberg",BY:"Bayern",BE:"Berlin",BB:"Brandenburg",HB:"Bremen",HH:"Hamburg",HE:"Hessen",MV:"Mecklenburg-Vorpommern",NI:"Niedersachsen",NW:"Nordrhein-Westfalen",RP:"Rheinland-Pfalz",SL:"Saarland",SN:"Sachsen",ST:"Sachsen-Anhalt",SH:"Schleswig-Holstein",TH:"Thüringen"}[i.split("-")[1]]||o:i.startsWith("CH-")&&(o={AG:"Aargau",AI:"Appenzell Innerrhoden",AR:"Appenzell Ausserrhoden",BE:"Bern",BL:"Basel-Landschaft",BS:"Basel-Stadt",FR:"Freiburg",GE:"Genf",GL:"Glarus",GR:"Graubünden",JU:"Jura",LU:"Luzern",NE:"Neuenburg",NW:"Nidwalden",OW:"Obwalden",SG:"St. Gallen",SH:"Schaffhausen",SO:"Solothurn",SZ:"Schwyz",TG:"Thurgau",TI:"Tessin",UR:"Uri",VD:"Waadt",VS:"Wallis",ZG:"Zug",ZH:"Zürich"}[i.split("-")[1]]||o),{value:i,label:o}})}catch{return[]}}function U7({cal:e,countries:t,onUpdate:a,onDelete:n}){const{t:i}=ot(),[o,s]=b.useState(e.color),[d,c]=b.useState(e.label||""),[p,m]=b.useState([]),g=e.region.split("-")[0],f=e.region.includes("-")?e.region:"";b.useEffect(()=>{s(e.color)},[e.color]),b.useEffect(()=>{c(e.label||"")},[e.label]),b.useEffect(()=>{if(!g){m([]);return}bz(g).then(m)},[g]);const y=["#fecaca","#fed7aa","#fde68a","#bbf7d0","#a5f3fc","#c7d2fe","#e9d5ff","#fda4af","#6366f1","#ef4444","#22c55e","#3b82f6"],[x,k]=b.useState(!1);return r.jsxs("div",{className:"flex gap-3 items-start p-3 rounded-xl",style:{background:"var(--bg-secondary)"},children:[r.jsxs("div",{style:{position:"relative",flexShrink:0},children:[r.jsx("button",{onClick:()=>k(!x),style:{width:28,height:28,borderRadius:8,background:o,border:"2px solid var(--border-primary)",cursor:"pointer"},title:i("vacay.calendarColor")}),x&&r.jsx("div",{style:{position:"absolute",top:34,left:0,zIndex:50,background:"var(--bg-card)",border:"1px solid var(--border-primary)",borderRadius:12,padding:8,boxShadow:"0 8px 24px rgba(0,0,0,0.12)",display:"grid",gridTemplateColumns:"repeat(4, 1fr)",gap:4,width:120},children:y.map(S=>r.jsx("button",{onClick:()=>{s(S),k(!1),S!==e.color&&a({color:S})},style:{width:24,height:24,borderRadius:6,background:S,border:o===S?"2px solid var(--text-primary)":"2px solid transparent",cursor:"pointer"}},S))})]}),r.jsxs("div",{className:"flex-1 min-w-0 space-y-1.5",children:[r.jsx("input",{type:"text",value:d,onChange:S=>c(S.target.value),onBlur:()=>{const S=d.trim()||null;S!==e.label&&a({label:S})},onKeyDown:S=>{S.key==="Enter"&&S.target.blur()},placeholder:i("vacay.calendarLabel"),style:{width:"100%",fontSize:12,padding:"6px 10px",borderRadius:8,background:"var(--bg-input)",border:"1px solid var(--border-primary)",color:"var(--text-primary)",fontFamily:"inherit",outline:"none"}}),r.jsx(ea,{value:g,onChange:S=>a({region:S}),options:t,placeholder:i("vacay.selectCountry"),searchable:!0}),p.length>0&&r.jsx(ea,{value:f,onChange:S=>a({region:S}),options:p,placeholder:i("vacay.selectRegion"),searchable:!0})]}),r.jsx("button",{onClick:n,className:"shrink-0 p-1.5 rounded-md transition-colors",style:{color:"var(--text-faint)"},onMouseEnter:S=>{S.currentTarget.style.background="rgba(239,68,68,0.1)"},onMouseLeave:S=>{S.currentTarget.style.background="transparent"},children:r.jsx(_t,{size:13})})]})}function W7({countries:e,onAdd:t,onCancel:a}){const{t:n}=ot(),[i,o]=b.useState(""),[s,d]=b.useState("#fecaca"),[c,p]=b.useState(""),[m,g]=b.useState([]),[f,y]=b.useState(!1),x=i.split("-")[0]||"",k=i.includes("-")?i:"";b.useEffect(()=>{if(!x){g([]);return}y(!0),bz(x).then(E=>{g(E)}).finally(()=>y(!1))},[x]);const S=x&&(m.length===0||k!==""),v=["#fecaca","#fed7aa","#fde68a","#bbf7d0","#a5f3fc","#c7d2fe","#e9d5ff","#fda4af","#6366f1","#ef4444","#22c55e","#3b82f6"],[_,w]=b.useState(!1);return r.jsxs("div",{className:"flex gap-3 items-start p-3 rounded-xl border border-dashed",style:{borderColor:"var(--border-primary)"},children:[r.jsxs("div",{style:{position:"relative",flexShrink:0},children:[r.jsx("button",{onClick:()=>w(!_),style:{width:28,height:28,borderRadius:8,background:s,border:"2px solid var(--border-primary)",cursor:"pointer"},title:n("vacay.calendarColor")}),_&&r.jsx("div",{style:{position:"absolute",top:34,left:0,zIndex:50,background:"var(--bg-card)",border:"1px solid var(--border-primary)",borderRadius:12,padding:8,boxShadow:"0 8px 24px rgba(0,0,0,0.12)",display:"grid",gridTemplateColumns:"repeat(4, 1fr)",gap:4,width:120},children:v.map(E=>r.jsx("button",{onClick:()=>{d(E),w(!1)},style:{width:24,height:24,borderRadius:6,background:E,border:s===E?"2px solid var(--text-primary)":"2px solid transparent",cursor:"pointer"}},E))})]}),r.jsxs("div",{className:"flex-1 min-w-0 space-y-1.5",children:[r.jsx("input",{type:"text",value:c,onChange:E=>p(E.target.value),placeholder:n("vacay.calendarLabel"),style:{width:"100%",fontSize:12,padding:"6px 10px",borderRadius:8,background:"var(--bg-input)",border:"1px solid var(--border-primary)",color:"var(--text-primary)",fontFamily:"inherit",outline:"none"}}),r.jsx(ea,{value:x,onChange:E=>{o(E),g([])},options:e,placeholder:n("vacay.selectCountry"),searchable:!0}),m.length>0&&r.jsx(ea,{value:k,onChange:E=>o(E),options:m,placeholder:n("vacay.selectRegion"),searchable:!0}),r.jsxs("div",{className:"flex gap-1.5 pt-0.5",children:[r.jsx("button",{disabled:!S,onClick:()=>t({region:i||x,color:s,label:c.trim()||null}),className:"flex-1 text-xs px-2 py-1.5 rounded-md font-medium transition-colors disabled:opacity-40",style:{background:"var(--text-primary)",color:"var(--bg-card)"},children:n("vacay.add")}),r.jsx("button",{onClick:a,className:"text-xs px-2 py-1.5 rounded-md transition-colors",style:{background:"var(--bg-secondary)",color:"var(--text-muted)"},children:"✕"})]})]})]})}function $7(){const{t:e}=ot(),{years:t,selectedYear:a,setSelectedYear:n,addYear:i,removeYear:o,loadAll:s,loadPlan:d,loadEntries:c,loadStats:p,loadHolidays:m,loading:g,incomingInvites:f,acceptInvite:y,declineInvite:x,plan:k}=Nc(),[S,v]=b.useState(!1),[_,w]=b.useState(null),[E,M]=b.useState(!1);b.useEffect(()=>{s()},[]);const A=b.useCallback($=>{($.type==="vacay:update"||$.type==="vacay:settings")&&(d(),c(a),p(a),$.type==="vacay:settings"&&s()),($.type==="vacay:invite"||$.type==="vacay:accepted"||$.type==="vacay:declined"||$.type==="vacay:cancelled"||$.type==="vacay:dissolved")&&s()},[a]);b.useEffect(()=>(xl(A),()=>kl(A)),[A]),b.useEffect(()=>{a&&(c(a),p(a),m(a))},[a]);const P=()=>{const $=t.length>0?Math.max(...t)+1:new Date().getFullYear();i($)};if(g)return r.jsxs("div",{className:"min-h-screen",style:{background:"var(--bg-primary)"},children:[r.jsx(Mi,{}),r.jsx("div",{className:"flex items-center justify-center",style:{paddingTop:"var(--nav-h)",minHeight:"calc(100vh - var(--nav-h))"},children:r.jsx("div",{className:"w-8 h-8 border-2 rounded-full animate-spin",style:{borderColor:"var(--border-primary)",borderTopColor:"var(--text-primary)"}})})]});const R=r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"rounded-xl border p-3",style:{background:"var(--bg-card)",borderColor:"var(--border-primary)"},children:[r.jsxs("div",{className:"flex items-center justify-between mb-2",children:[r.jsx("span",{className:"text-[11px] font-medium uppercase tracking-wider",style:{color:"var(--text-faint)"},children:e("vacay.year")}),r.jsx("button",{onClick:P,className:"p-0.5 rounded transition-colors",style:{color:"var(--text-faint)"},title:e("vacay.addYear"),children:r.jsx(Ft,{size:14})})]}),r.jsxs("div",{className:"flex items-center justify-between mb-2",children:[r.jsx("button",{onClick:()=>{const $=t.indexOf(a);$>0&&n(t[$-1])},disabled:t.indexOf(a)<=0,className:"p-1 lg:p-1 p-2 rounded-lg disabled:opacity-20 transition-colors",style:{background:"var(--bg-secondary)"},children:r.jsx(m_,{size:16,style:{color:"var(--text-muted)"}})}),r.jsx("span",{className:"text-xl font-bold tabular-nums",style:{color:"var(--text-primary)"},children:a}),r.jsx("button",{onClick:()=>{const $=t.indexOf(a);$=t.length-1,className:"p-1 lg:p-1 p-2 rounded-lg disabled:opacity-20 transition-colors",style:{background:"var(--bg-secondary)"},children:r.jsx(Ao,{size:16,style:{color:"var(--text-muted)"}})})]}),r.jsx("div",{className:"grid grid-cols-4 gap-1",children:t.map($=>r.jsxs("div",{onClick:()=>n($),className:"group relative py-1.5 rounded-lg text-xs font-medium transition-all text-center cursor-pointer",style:{background:$===a?"var(--text-primary)":"var(--bg-secondary)",color:$===a?"var(--bg-card)":"var(--text-muted)"},children:[$,t.length>1&&r.jsx("span",{onClick:I=>{I.stopPropagation(),w($),M(!1)},className:"absolute -top-1 -right-1 w-3.5 h-3.5 rounded-full bg-red-500 text-white text-[7px] flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity cursor-pointer",children:r.jsx(w_,{size:7})})]},$))})]}),r.jsx(F7,{}),((k==null?void 0:k.holidays_enabled)||(k==null?void 0:k.company_holidays_enabled)||(k==null?void 0:k.block_weekends))&&r.jsxs("div",{className:"rounded-xl border p-3",style:{background:"var(--bg-card)",borderColor:"var(--border-primary)"},children:[r.jsx("span",{className:"text-[11px] font-medium uppercase tracking-wider",style:{color:"var(--text-faint)"},children:e("vacay.legend")}),r.jsxs("div",{className:"mt-2 flex flex-wrap gap-x-3 gap-y-1.5",children:[(k==null?void 0:k.holidays_enabled)&&((k==null?void 0:k.holiday_calendars)??[]).length===0&&r.jsx(Cu,{color:"#fecaca",label:e("vacay.publicHoliday")}),(k==null?void 0:k.holidays_enabled)&&((k==null?void 0:k.holiday_calendars)??[]).map($=>r.jsx(Cu,{color:$.color,label:$.label||$.region},$.id)),(k==null?void 0:k.company_holidays_enabled)&&r.jsx(Cu,{color:"#fde68a",label:e("vacay.companyHoliday")}),(k==null?void 0:k.block_weekends)&&r.jsx(Cu,{color:"#e5e7eb",label:e("vacay.weekend")})]})]}),r.jsx(O7,{})]});return r.jsxs("div",{className:"min-h-screen",style:{background:"var(--bg-primary)"},children:[r.jsx(Mi,{}),r.jsx("div",{style:{paddingTop:"var(--nav-h)"},children:r.jsxs("div",{className:"max-w-[1800px] mx-auto px-3 sm:px-4 py-4 sm:py-6",children:[r.jsxs("div",{className:"flex items-center justify-between mb-4 sm:mb-5",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"w-9 h-9 rounded-xl flex items-center justify-center",style:{background:"var(--bg-secondary)"},children:r.jsx(Nl,{size:18,style:{color:"var(--text-primary)"}})}),r.jsxs("div",{children:[r.jsx("h1",{className:"text-lg sm:text-xl font-bold",style:{color:"var(--text-primary)"},children:e("admin.addons.catalog.vacay.name")}),r.jsx("p",{className:"text-xs hidden sm:block",style:{color:"var(--text-muted)"},children:e("vacay.subtitle")})]})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("button",{onClick:()=>M(!0),className:"lg:hidden flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-sm transition-colors",style:{background:"var(--bg-secondary)",color:"var(--text-muted)"},children:r.jsx(uD,{size:14})}),r.jsxs("button",{onClick:()=>v(!0),className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-sm transition-colors",style:{background:"var(--bg-secondary)",color:"var(--text-muted)"},children:[r.jsx(Bm,{size:14}),r.jsx("span",{className:"hidden sm:inline",children:e("vacay.settings")})]})]})]}),r.jsxs("div",{className:"flex gap-4 items-start",children:[r.jsx("div",{className:"hidden lg:flex w-[240px] shrink-0 flex-col gap-3 sticky top-[70px]",children:R}),r.jsx("div",{className:"flex-1 min-w-0",children:r.jsx(I7,{})})]})]})}),E&&Vt.createPortal(r.jsxs("div",{className:"fixed inset-0 lg:hidden",style:{zIndex:99980},children:[r.jsx("div",{className:"absolute inset-0",style:{background:"rgba(0,0,0,0.4)"},onClick:()=>M(!1)}),r.jsx("div",{className:"absolute left-0 top-0 bottom-0 w-[280px] overflow-y-auto p-3 flex flex-col gap-3",style:{background:"var(--bg-primary)",boxShadow:"4px 0 24px rgba(0,0,0,0.15)",animation:"slideInLeft 0.2s ease-out"},children:R})]}),document.body),r.jsx(zi,{isOpen:S,onClose:()=>v(!1),title:e("vacay.settings"),size:"md",children:r.jsx(H7,{onClose:()=>v(!1)})}),r.jsx(zi,{isOpen:_!==null,onClose:()=>w(null),title:e("vacay.removeYear"),size:"sm",children:r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"flex gap-3 p-3 rounded-lg",style:{background:"rgba(239,68,68,0.08)",border:"1px solid rgba(239,68,68,0.15)"},children:[r.jsx(li,{size:18,className:"text-red-500 shrink-0 mt-0.5"}),r.jsxs("div",{children:[r.jsx("p",{className:"text-sm font-medium",style:{color:"var(--text-primary)"},children:e("vacay.removeYearConfirm",{year:_})}),r.jsx("p",{className:"text-xs mt-1",style:{color:"var(--text-muted)"},children:e("vacay.removeYearHint")})]})]}),r.jsxs("div",{className:"flex gap-3 justify-end",children:[r.jsx("button",{onClick:()=>w(null),className:"px-4 py-2 text-sm rounded-lg transition-colors",style:{color:"var(--text-muted)",border:"1px solid var(--border-primary)"},children:e("common.cancel")}),r.jsx("button",{onClick:async()=>{await o(_),w(null)},className:"px-4 py-2 text-sm bg-red-500 hover:bg-red-600 text-white rounded-lg transition-colors",children:e("vacay.remove")})]})]})}),f.length>0&&Vt.createPortal(r.jsx("div",{className:"fixed inset-0 flex items-center justify-center px-4",style:{zIndex:99995,backgroundColor:"rgba(0,0,0,0.7)",backdropFilter:"blur(8px)"},children:f.map($=>{var I,Y;return r.jsxs("div",{className:"w-full max-w-md rounded-2xl shadow-2xl overflow-hidden",style:{background:"var(--bg-card)",animation:"modalIn 0.25s ease-out"},children:[r.jsxs("div",{className:"px-6 pt-6 pb-4 text-center",children:[r.jsx("div",{className:"w-14 h-14 rounded-full mx-auto mb-4 flex items-center justify-center text-lg font-bold",style:{background:"var(--bg-secondary)",color:"var(--text-primary)"},children:(Y=(I=$.username)==null?void 0:I[0])==null?void 0:Y.toUpperCase()}),r.jsx("h2",{className:"text-lg font-bold mb-1",style:{color:"var(--text-primary)"},children:e("vacay.inviteTitle")}),r.jsxs("p",{className:"text-sm",style:{color:"var(--text-muted)"},children:[r.jsx("span",{className:"font-semibold",style:{color:"var(--text-primary)"},children:$.username})," ",e("vacay.inviteWantsToFuse")]})]}),r.jsxs("div",{className:"px-6 pb-4 space-y-2",children:[r.jsx(ud,{icon:Mm,text:e("vacay.fuseInfo1")}),r.jsx(ud,{icon:sn,text:e("vacay.fuseInfo2")}),r.jsx(ud,{icon:_t,text:e("vacay.fuseInfo3")}),r.jsx(ud,{icon:cD,text:e("vacay.fuseInfo4")}),r.jsx(ud,{icon:C_,text:e("vacay.fuseInfo5")})]}),r.jsxs("div",{className:"px-6 pb-6 flex gap-3",children:[r.jsx("button",{onClick:()=>x($.plan_id),className:"flex-1 px-4 py-2.5 text-sm font-medium rounded-xl transition-colors",style:{color:"var(--text-muted)",border:"1px solid var(--border-primary)"},children:e("vacay.decline")}),r.jsx("button",{onClick:()=>y($.plan_id),className:"flex-1 px-4 py-2.5 text-sm font-medium rounded-xl transition-colors",style:{background:"var(--text-primary)",color:"var(--bg-card)"},children:e("vacay.acceptFusion")})]})]},$.id)})}),document.body),r.jsx("style",{children:`
+ @keyframes slideInLeft {
+ from { transform: translateX(-100%); }
+ to { transform: translateX(0); }
+ }
+ `})]})}function ud({icon:e,text:t}){return r.jsxs("div",{className:"flex items-start gap-3 px-3 py-2 rounded-lg",style:{background:"var(--bg-secondary)"},children:[r.jsx(e,{size:15,className:"shrink-0 mt-0.5",style:{color:"var(--text-muted)"}}),r.jsx("span",{className:"text-xs",style:{color:"var(--text-primary)"},children:t})]})}function Cu({color:e,label:t}){return r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"w-4 h-3 rounded",style:{background:e,border:`1px solid ${e}`}}),r.jsx("span",{className:"text-[11px]",style:{color:"var(--text-muted)"},children:t})]})}function qp(e){return!e||e.length!==2?"":String.fromCodePoint(...[...e.toUpperCase()].map(t=>127462+t.charCodeAt(0)-65))}function V7(e){const[t,a]=b.useState(()=>n=>n);return b.useEffect(()=>{try{const n=new Intl.DisplayNames([o_(e)],{type:"region"});a(()=>i=>{try{return n.of(i)||i}catch{return i}})}catch{}},[e]),t}const K7={AF:"AFG",AL:"ALB",DZ:"DZA",AD:"AND",AO:"AGO",AG:"ATG",AR:"ARG",AM:"ARM",AU:"AUS",AT:"AUT",AZ:"AZE",BS:"BHS",BH:"BHR",BD:"BGD",BB:"BRB",BY:"BLR",BE:"BEL",BZ:"BLZ",BJ:"BEN",BT:"BTN",BO:"BOL",BA:"BIH",BW:"BWA",BR:"BRA",BN:"BRN",BG:"BGR",BF:"BFA",BI:"BDI",CV:"CPV",KH:"KHM",CM:"CMR",CA:"CAN",CF:"CAF",TD:"TCD",CL:"CHL",CN:"CHN",CO:"COL",KM:"COM",CG:"COG",CD:"COD",CR:"CRI",CI:"CIV",HR:"HRV",CU:"CUB",CY:"CYP",CZ:"CZE",DK:"DNK",DJ:"DJI",DM:"DMA",DO:"DOM",EC:"ECU",EG:"EGY",SV:"SLV",GQ:"GNQ",ER:"ERI",EE:"EST",SZ:"SWZ",ET:"ETH",FJ:"FJI",FI:"FIN",FR:"FRA",GA:"GAB",GM:"GMB",GE:"GEO",DE:"DEU",GH:"GHA",GR:"GRC",GD:"GRD",GT:"GTM",GN:"GIN",GW:"GNB",GY:"GUY",HT:"HTI",HN:"HND",HU:"HUN",IS:"ISL",IN:"IND",ID:"IDN",IR:"IRN",IQ:"IRQ",IE:"IRL",IL:"ISR",IT:"ITA",JM:"JAM",JP:"JPN",JO:"JOR",KZ:"KAZ",KE:"KEN",KI:"KIR",KP:"PRK",KR:"KOR",KW:"KWT",KG:"KGZ",LA:"LAO",LV:"LVA",LB:"LBN",LS:"LSO",LR:"LBR",LY:"LBY",LI:"LIE",LT:"LTU",LU:"LUX",MG:"MDG",MW:"MWI",MY:"MYS",MV:"MDV",ML:"MLI",MT:"MLT",MR:"MRT",MU:"MUS",MX:"MEX",MD:"MDA",MN:"MNG",ME:"MNE",MA:"MAR",MZ:"MOZ",MM:"MMR",NA:"NAM",NP:"NPL",NL:"NLD",NZ:"NZL",NI:"NIC",NE:"NER",NG:"NGA",MK:"MKD",NO:"NOR",OM:"OMN",PK:"PAK",PA:"PAN",PG:"PNG",PY:"PRY",PE:"PER",PH:"PHL",PL:"POL",PT:"PRT",QA:"QAT",RO:"ROU",RU:"RUS",RW:"RWA",SA:"SAU",SN:"SEN",RS:"SRB",SL:"SLE",SG:"SGP",SK:"SVK",SI:"SVN",SB:"SLB",SO:"SOM",ZA:"ZAF",SS:"SSD",ES:"ESP",LK:"LKA",SD:"SDN",SR:"SUR",SE:"SWE",CH:"CHE",SY:"SYR",TW:"TWN",TJ:"TJK",TZ:"TZA",TH:"THA",TL:"TLS",TG:"TGO",TT:"TTO",TN:"TUN",TR:"TUR",TM:"TKM",UG:"UGA",UA:"UKR",AE:"ARE",GB:"GBR",US:"USA",UY:"URY",UZ:"UZB",VU:"VUT",VE:"VEN",VN:"VNM",YE:"YEM",ZM:"ZMB",ZW:"ZWE"};let Wo={...K7};function q7(){const{t:e,language:t}=ot(),{settings:a}=ta(),n=Br(),i=V7(t),o=a.dark_mode,s=o===!0||o==="dark"||o==="auto"&&window.matchMedia("(prefers-color-scheme: dark)").matches,d=b.useRef(null),c=b.useRef(null),p=b.useRef(null),m=b.useRef(null),g=b.useRef(null),f=b.useRef(null),y=b.useRef({}),x=Ce=>{if(!f.current||!m.current||!g.current)return;const De=f.current.getBoundingClientRect(),Qe=Ce.clientX-De.left,ft=Ce.clientY-De.top;m.current.style.background=`radial-gradient(circle 300px at ${Qe}px ${ft}px, ${s?"rgba(255,255,255,0.025)":"rgba(255,255,255,0.25)"} 0%, transparent 70%)`,m.current.style.opacity="1",g.current.style.opacity="1",g.current.style.maskImage=`radial-gradient(circle 150px at ${Qe}px ${ft}px, black 0%, transparent 100%)`,g.current.style.webkitMaskImage=`radial-gradient(circle 150px at ${Qe}px ${ft}px, black 0%, transparent 100%)`},k=()=>{m.current&&(m.current.style.opacity="0"),g.current&&(g.current.style.opacity="0")},[S,v]=b.useState(null),[_,w]=b.useState(!0),[E,M]=b.useState(!0),[A,P]=b.useState(!1),[R,$]=b.useState(null),[I,Y]=b.useState(null),[H,V]=b.useState(null),[X,Z]=b.useState(null),[O,Q]=b.useState(0),[D,J]=b.useState(0),[z,W]=b.useState([]),[B,C]=b.useState(!1),[U,q]=b.useState({name:"",notes:"",lat:"",lng:"",target_date:""}),[te,oe]=b.useState(""),[be,Se]=b.useState([]),[je,we]=b.useState(!1),[ce,le]=b.useState(0),[K,de]=b.useState(0),[_e,pe]=b.useState("stats"),Ae=b.useRef(null),[He,ze]=b.useState(""),[Ye,G]=b.useState([]),[ve,Pe]=b.useState(!1),ye=b.useMemo(()=>{var Qe,ft,Et;if(!H)return[];const Ce=[],De=new Set;for(const pt of H.features||[]){const Zt=(Qe=pt==null?void 0:pt.properties)==null?void 0:Qe.ISO_A2;if(!Zt||Zt==="-99"||typeof Zt!="string"||Zt.length!==2||De.has(Zt))continue;De.add(Zt);const jn=String(((ft=pt==null?void 0:pt.properties)==null?void 0:ft.NAME)||((Et=pt==null?void 0:pt.properties)==null?void 0:Et.ADMIN)||i(Zt)||Zt);Ce.push({code:Zt,label:jn})}return Ce.sort((pt,Zt)=>pt.label.localeCompare(Zt.label)),Ce},[H,i]);b.useEffect(()=>{Promise.all([ie.get("/addons/atlas/stats"),ie.get("/addons/atlas/bucket-list")]).then(([Ce,De])=>{v(Ce.data),W(De.data.items||[]),w(!1)}).catch(()=>w(!1))},[]),b.useEffect(()=>{fetch("https://raw.githubusercontent.com/nvkelso/natural-earth-vector/master/geojson/ne_50m_admin_0_countries.geojson").then(Ce=>Ce.json()).then(Ce=>{var De,Qe,ft;for(const Et of Ce.features){const pt=(De=Et.properties)==null?void 0:De.ISO_A2,Zt=((Qe=Et.properties)==null?void 0:Qe.ADM0_A3)||((ft=Et.properties)==null?void 0:ft.ISO_A3);pt&&Zt&&pt!=="-99"&&Zt!=="-99"&&!Wo[pt]&&(Wo[pt]=Zt)}V(Ce)}).catch(()=>{})},[]),b.useEffect(()=>{if(_||!d.current)return;c.current&&(c.current.remove(),c.current=null);const Ce=$a.map(d.current,{center:[25,0],zoom:3,minZoom:3,maxZoom:7,zoomControl:!1,attributionControl:!1,maxBounds:[[-90,-220],[90,220]],maxBoundsViscosity:1,fadeAnimation:!1,preferCanvas:!0});$a.control.zoom({position:"bottomright"}).addTo(Ce);const De=s?"https://{s}.basemaps.cartocdn.com/dark_nolabels/{z}/{x}/{y}{r}.png":"https://{s}.basemaps.cartocdn.com/light_nolabels/{z}/{x}/{y}{r}.png";return $a.tileLayer(De,{maxZoom:8,keepBuffer:25,updateWhenZooming:!0,updateWhenIdle:!1,tileSize:256,zoomOffset:0,crossOrigin:!0}).addTo(Ce),$a.tileLayer(De,{maxZoom:8,keepBuffer:10,opacity:0,tileSize:256,crossOrigin:!0}).addTo(Ce),c.current=Ce,()=>{Ce.remove(),c.current=null}},[s,_]),b.useEffect(()=>{if(!c.current||!H||!S)return;const Ce=new Set(S.countries.map(Ot=>Wo[Ot.code]).filter(Boolean)),De={};S.countries.forEach(Ot=>{Wo[Ot.code]&&(De[Wo[Ot.code]]=Ot)});const Qe=c.current.getCenter(),ft=c.current.getZoom();p.current&&c.current.removeLayer(p.current);const Et=["#6366f1","#ec4899","#14b8a6","#f97316","#8b5cf6","#ef4444","#3b82f6","#22c55e","#06b6d4","#f43f5e","#a855f7","#10b981","#0ea5e9","#e11d48","#0d9488","#7c3aed","#2563eb","#dc2626","#059669","#d946ef"],pt=[...Ce],Zt={};pt.forEach((Ot,Xt)=>{Zt[Ot]=Et[Xt%Et.length]});const jn=Ot=>Zt[Ot]||Et[0],ga=$a.canvas({padding:.5,tolerance:5});p.current=$a.geoJSON(H,{renderer:ga,interactive:!0,bubblingMouseEvents:!1,style:Ot=>{var It,re,Ie;const Xt=((It=Ot.properties)==null?void 0:It.ADM0_A3)||((re=Ot.properties)==null?void 0:re.ISO_A3)||((Ie=Ot.properties)==null?void 0:Ie["ISO3166-1-Alpha-3"])||Ot.id,Za=Ce.has(Xt);return{fillColor:Za?jn(Xt):s?"#1e1e2e":"#e2e8f0",fillOpacity:Za?.7:.3,color:s?"#333":"#cbd5e1",weight:.5}},onEachFeature:(Ot,Xt)=>{var re,Ie,At,va,ba,Ue;const Za=((re=Ot.properties)==null?void 0:re.ADM0_A3)||((Ie=Ot.properties)==null?void 0:Ie.ISO_A3)||((At=Ot.properties)==null?void 0:At["ISO3166-1-Alpha-3"])||Ot.id,It=De[Za];if(It){y.current[It.code]=Xt;const Xn=i(It.code),_n=Ea=>Ea?new Date(Ea).toLocaleDateString(Pm(t),{month:"short",year:"numeric"}):"—",an=`
+
+
${Xn}
+
+
${It.tripCount} ${It.tripCount===1?e("atlas.tripSingular"):e("atlas.tripPlural")}
+
${It.placeCount} ${It.placeCount===1?e("atlas.placeVisited"):e("atlas.placesVisited")}
+
+
+
+ ${e("atlas.firstVisit")}
+ ${_n(It.firstVisit)}
+
+
+ ${e("atlas.lastVisitLabel")}
+ ${_n(It.lastVisit)}
+
+
+
+ `;Xt.bindTooltip(an,{sticky:!1,permanent:!1,className:"atlas-tooltip",direction:"top",offset:[0,-10],opacity:1}),Xt.on("click",()=>{It.placeCount===0&&It.tripCount===0?fe(It.code):Gt(It.code)}),Xt.on("mouseover",Ea=>{Ea.target.setStyle({fillOpacity:.9,weight:2,color:s?"#818cf8":"#4f46e5"})}),Xt.on("mouseout",Ea=>{p.current.resetStyle(Ea.target)})}else{const Xn=Object.entries(Wo).find(([,Ea])=>Ea===Za),_n=(va=Ot.properties)==null?void 0:va.ISO_A2,an=Xn?Xn[0]:_n&&_n!=="-99"?_n:null;if(an&&an!=="-99"){y.current[an]=Xt;const Ea=((ba=Ot.properties)==null?void 0:ba.NAME)||((Ue=Ot.properties)==null?void 0:Ue.ADMIN)||i(an);Xt.bindTooltip(`${Ea}
`,{sticky:!1,className:"atlas-tooltip",direction:"top",offset:[0,-10],opacity:1}),Xt.on("click",()=>ne(an,Ea)),Xt.on("mouseover",Jn=>{Jn.target.setStyle({fillOpacity:.5,weight:1.5,color:s?"#555":"#94a3b8"})}),Xt.on("mouseout",Jn=>{p.current.resetStyle(Jn.target)})}}}}).addTo(c.current),c.current.setView(Qe,ft,{animate:!1})},[H,S,s]);const ne=(Ce,De)=>{Z({type:"choose",code:Ce,name:De})},fe=Ce=>{S==null||S.countries.find(De=>De.code===Ce),Z({type:"unmark",code:Ce,name:i(Ce)})},Ee=Ce=>{const De=i(Ce);ze(De),Pe(!1),G([]);const Qe=y.current[Ce];try{Qe!=null&&Qe.getBounds&&c.current&&c.current.fitBounds(Qe.getBounds(),{padding:[24,24],animate:!0,maxZoom:6})}catch(ft){console.error("Error fitting bounds",ft)}Z({type:"choose",code:Ce,name:De})},Oe=async()=>{if(!X)return;const{type:Ce,code:De}=X;Z(null),Ce==="mark"?(ie.post(`/addons/atlas/country/${De}/mark`).catch(()=>{}),v(Qe=>!Qe||Qe.countries.find(ft=>ft.code===De)?Qe:{...Qe,countries:[...Qe.countries,{code:De,placeCount:0,tripCount:0,firstVisit:null,lastVisit:null}],stats:{...Qe.stats,totalCountries:Qe.stats.totalCountries+1}})):(ie.delete(`/addons/atlas/country/${De}/mark`).catch(()=>{}),$(null),Y(null),v(Qe=>{if(!Qe)return Qe;const ft=Qe.countries.find(Et=>Et.code===De);return!ft||ft.placeCount>0||ft.tripCount>0?Qe:{...Qe,countries:Qe.countries.filter(Et=>Et.code!==De),stats:{...Qe.stats,totalCountries:Math.max(0,Qe.stats.totalCountries-1)}}}))},Ke=async()=>{if(U.name.trim())try{const Ce={name:U.name.trim()};U.notes.trim()&&(Ce.notes=U.notes.trim()),U.lat&&U.lng&&(Ce.lat=parseFloat(U.lat),Ce.lng=parseFloat(U.lng));const De=U.target_date||(ce>0&&K>0?`${K}-${String(ce).padStart(2,"0")}`:null);De&&(Ce.target_date=De);const Qe=await ie.post("/addons/atlas/bucket-list",Ce);W(ft=>[Qe.data.item,...ft]),q({name:"",notes:"",lat:"",lng:"",target_date:""}),oe(""),Se([]),le(0),de(0),C(!1)}catch{}},dt=async Ce=>{try{await ie.delete(`/addons/atlas/bucket-list/${Ce}`),W(De=>De.filter(Qe=>Qe.id!==Ce))}catch{}},Wt=async()=>{if(te.trim()){we(!0);try{const Ce=await ko.search(te,t);Se(Ce.places||[])}catch{}finally{we(!1)}}},Be=Ce=>{const De=ce>0&&K>0?`${K}-${String(ce).padStart(2,"0")}`:null;q({name:Ce.name||te,notes:"",lat:String(Ce.lat||""),lng:String(Ce.lng||""),target_date:De||""}),Se([]),oe("")};b.useEffect(()=>{if(!c.current||(Ae.current&&c.current.removeLayer(Ae.current),z.length===0))return;const Ce=z.filter(De=>De.lat&&De.lng).map(De=>{const Qe=$a.divIcon({className:"",html:'',iconSize:[28,28],iconAnchor:[14,14]});return $a.marker([De.lat,De.lng],{icon:Qe}).bindTooltip(`${De.name}
${De.notes?`${De.notes}
`:""}`,{className:"atlas-tooltip",direction:"top",offset:[0,-14]})});Ae.current=$a.layerGroup(Ce).addTo(c.current)},[z]);const Gt=async Ce=>{$(Ce);try{const De=await ie.get(`/addons/atlas/country/${Ce}`);Y(De.data)}catch{}},Kt=(S==null?void 0:S.stats)||{totalTrips:0,totalPlaces:0,totalCountries:0,totalDays:0},Lt=(S==null?void 0:S.countries)||[];return _?r.jsxs("div",{className:"min-h-screen",style:{background:"var(--bg-primary)"},children:[r.jsx(Mi,{}),r.jsx("div",{className:"flex items-center justify-center",style:{paddingTop:"var(--nav-h)",minHeight:"calc(100vh - var(--nav-h))"},children:r.jsx("div",{className:"w-8 h-8 border-2 rounded-full animate-spin",style:{borderColor:"var(--border-primary)",borderTopColor:"var(--text-primary)"}})})]}):r.jsxs("div",{className:"min-h-screen",style:{background:"var(--bg-primary)"},children:[r.jsx(Mi,{}),r.jsxs("div",{style:{position:"fixed",top:"var(--nav-h)",left:0,right:0,bottom:0},children:[r.jsx("div",{ref:d,style:{position:"absolute",inset:0,zIndex:1,background:s?"#1a1a2e":"#f0f0f0"}}),r.jsx("div",{className:"absolute z-20 flex justify-center",style:{top:14,left:0,right:0,pointerEvents:"none"},children:r.jsxs("div",{style:{width:"min(520px, calc(100vw - 28px))",pointerEvents:"auto"},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"10px 12px",borderRadius:16,border:"1px solid "+(s?"rgba(255,255,255,0.10)":"rgba(0,0,0,0.08)"),background:s?"rgba(10,10,15,0.55)":"rgba(255,255,255,0.55)",backdropFilter:"blur(18px) saturate(180%)",WebkitBackdropFilter:"blur(18px) saturate(180%)",boxShadow:s?"0 8px 26px rgba(0,0,0,0.25)":"0 8px 26px rgba(0,0,0,0.10)"},children:[r.jsx(Om,{size:16,style:{color:"var(--text-faint)",flexShrink:0}}),r.jsx("input",{value:He,onChange:Ce=>{const De=Ce.target.value;ze(De);const Qe=De.trim().toLowerCase();if(!Qe){G([]),Pe(!1);return}const ft=ye.filter(Et=>Et.label.toLowerCase().includes(Qe)||Et.code.toLowerCase()===Qe).slice(0,8);G(ft),Pe(!0)},onFocus:()=>{Ye.length>0&&Pe(!0)},onKeyDown:Ce=>{if(Ce.key==="Escape"){Pe(!1);return}if(Ce.key==="Enter"){const De=Ye[0];De&&Ee(De.code)}},placeholder:e("atlas.searchCountry"),autoComplete:"off",spellCheck:!1,style:{flex:1,border:"none",outline:"none",background:"transparent",fontSize:13,fontFamily:"inherit",color:"var(--text-primary)"}}),He.trim()&&r.jsx("button",{onClick:()=>{ze(""),G([]),Pe(!1)},style:{border:"none",background:"none",cursor:"pointer",color:"var(--text-faint)",padding:2,display:"flex"},"aria-label":"Clear",children:r.jsx(gt,{size:14})})]}),ve&&Ye.length>0&&r.jsx("div",{style:{marginTop:8,borderRadius:14,overflow:"hidden",border:"1px solid "+(s?"rgba(255,255,255,0.10)":"rgba(0,0,0,0.08)"),background:s?"rgba(10,10,15,0.75)":"rgba(255,255,255,0.75)",backdropFilter:"blur(18px) saturate(180%)",WebkitBackdropFilter:"blur(18px) saturate(180%)",boxShadow:s?"0 12px 30px rgba(0,0,0,0.35)":"0 12px 30px rgba(0,0,0,0.12)"},onMouseLeave:()=>Pe(!1),children:Ye.map(Ce=>r.jsxs("button",{onClick:()=>Ee(Ce.code),style:{width:"100%",border:"none",background:"transparent",cursor:"pointer",padding:"10px 12px",display:"flex",alignItems:"center",justifyContent:"space-between",fontFamily:"inherit",textAlign:"left",borderBottom:"1px solid "+(s?"rgba(255,255,255,0.06)":"rgba(0,0,0,0.06)")},onMouseEnter:De=>{De.currentTarget.style.background=s?"rgba(255,255,255,0.06)":"rgba(0,0,0,0.05)"},onMouseLeave:De=>{De.currentTarget.style.background="transparent"},children:[r.jsxs("span",{style:{display:"flex",alignItems:"center",gap:10,minWidth:0},children:[r.jsx("span",{style:{fontSize:16},children:qp(Ce.code)}),r.jsx("span",{style:{fontSize:13,fontWeight:650,color:"var(--text-primary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:Ce.label})]}),r.jsx(Ao,{size:16,style:{color:"var(--text-faint)",flexShrink:0}})]},Ce.code))})]})}),r.jsx("div",{className:"md:hidden absolute bottom-3 left-0 right-0 z-10 flex justify-center",style:{touchAction:"manipulation"},children:r.jsxs("div",{className:"flex items-center gap-4 px-5 py-4 rounded-2xl",style:{background:s?"rgba(0,0,0,0.45)":"rgba(255,255,255,0.5)",backdropFilter:"blur(16px)"},children:[r.jsxs("div",{className:"text-center px-3 py-1.5 rounded-xl",style:{background:s?"rgba(255,255,255,0.08)":"rgba(0,0,0,0.05)"},children:[r.jsx("p",{className:"text-3xl font-black tabular-nums leading-none",style:{color:"var(--text-primary)"},children:Kt.totalCountries}),r.jsx("p",{className:"text-[9px] font-semibold uppercase tracking-wide mt-1",style:{color:"var(--text-faint)"},children:e("atlas.countries")})]}),[[Kt.totalTrips,e("atlas.trips")],[Kt.totalPlaces,e("atlas.places")],[Kt.totalCities||0,e("atlas.cities")],[Kt.totalDays,e("atlas.days")]].map(([Ce,De],Qe)=>r.jsxs("div",{className:"text-center px-1",children:[r.jsx("p",{className:"text-xl font-black tabular-nums leading-none",style:{color:"var(--text-primary)"},children:Ce}),r.jsx("p",{className:"text-[9px] font-semibold uppercase tracking-wide mt-1",style:{color:"var(--text-faint)"},children:De})]},Qe))]})}),r.jsxs("div",{ref:f,onMouseMove:x,onMouseLeave:k,className:"hidden md:flex flex-col absolute z-10 overflow-hidden transition-all duration-300",style:{bottom:16,left:"50%",transform:"translateX(-50%)",width:"fit-content",maxWidth:"calc(100vw - 40px)",background:s?"rgba(10,10,15,0.55)":"rgba(255,255,255,0.2)",backdropFilter:"blur(24px) saturate(180%)",WebkitBackdropFilter:"blur(24px) saturate(180%)",border:"1px solid "+(s?"rgba(255,255,255,0.08)":"rgba(0,0,0,0.06)"),borderRadius:20,boxShadow:s?"0 8px 32px rgba(0,0,0,0.3)":"0 8px 32px rgba(0,0,0,0.08)"},children:[r.jsx("div",{ref:m,className:"absolute inset-0 pointer-events-none",style:{opacity:0,transition:"opacity 0.3s ease",borderRadius:20}}),r.jsx("div",{ref:g,className:"absolute inset-0 pointer-events-none",style:{opacity:0,transition:"opacity 0.3s ease",borderRadius:20,border:s?"1.5px solid rgba(255,255,255,0.5)":"2px solid rgba(0,0,0,0.15)"}}),r.jsx(G7,{data:S,stats:Kt,countries:Lt,selectedCountry:R,countryDetail:I,resolveName:i,onCountryClick:Gt,onTripClick:Ce=>n(`/trips/${Ce}`),onUnmarkCountry:fe,bucketList:z,bucketTab:_e,setBucketTab:pe,showBucketAdd:B,setShowBucketAdd:C,bucketForm:U,setBucketForm:q,onAddBucket:Ke,onDeleteBucket:dt,onSearchBucket:Wt,onSelectBucketPoi:Be,bucketSearchResults:be,setBucketSearchResults:Se,bucketPoiMonth:ce,setBucketPoiMonth:le,bucketPoiYear:K,setBucketPoiYear:de,bucketSearching:je,bucketSearch:te,setBucketSearch:oe,t:e,dark:s})]})]}),X&&r.jsx("div",{style:{position:"fixed",inset:0,zIndex:1e3,background:"rgba(0,0,0,0.4)",display:"flex",alignItems:"center",justifyContent:"center",padding:20},onClick:()=>Z(null),children:r.jsxs("div",{style:{background:"var(--bg-card)",borderRadius:16,padding:24,maxWidth:340,width:"100%",boxShadow:"0 16px 48px rgba(0,0,0,0.2)",textAlign:"center"},onClick:Ce=>Ce.stopPropagation(),children:[X.code.length===2?r.jsx("img",{src:`https://flagcdn.com/w80/${X.code.toLowerCase()}.png`,alt:X.code,style:{width:48,height:34,borderRadius:6,objectFit:"cover",marginBottom:12,display:"inline-block"}}):r.jsx("div",{style:{fontSize:36,marginBottom:12},children:qp(X.code)}),r.jsx("h3",{style:{margin:"0 0 16px",fontSize:16,fontWeight:700,color:"var(--text-primary)"},children:X.name}),X.type==="choose"&&r.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[r.jsxs("button",{onClick:async()=>{try{await ie.post(`/addons/atlas/country/${X.code}/mark`),v(Ce=>!Ce||Ce.countries.find(De=>De.code===X.code)?Ce:{...Ce,countries:[...Ce.countries,{code:X.code,placeCount:0,tripCount:0,firstVisit:null,lastVisit:null}],stats:{...Ce.stats,totalCountries:Ce.stats.totalCountries+1}})}catch{}Z(null)},style:{display:"flex",alignItems:"center",gap:10,width:"100%",padding:"12px 16px",borderRadius:12,border:"1px solid var(--border-primary)",background:"none",cursor:"pointer",fontFamily:"inherit",textAlign:"left",transition:"background 0.12s"},onMouseEnter:Ce=>Ce.currentTarget.style.background="var(--bg-secondary)",onMouseLeave:Ce=>Ce.currentTarget.style.background="none",children:[r.jsx(tn,{size:18,style:{color:"var(--text-primary)",flexShrink:0}}),r.jsxs("div",{children:[r.jsx("div",{style:{fontSize:13,fontWeight:600,color:"var(--text-primary)"},children:e("atlas.markVisited")}),r.jsx("div",{style:{fontSize:11,color:"var(--text-muted)",marginTop:1},children:e("atlas.markVisitedHint")})]})]}),r.jsxs("button",{onClick:()=>Z({...X,type:"bucket"}),style:{display:"flex",alignItems:"center",gap:10,width:"100%",padding:"12px 16px",borderRadius:12,border:"1px solid var(--border-primary)",background:"none",cursor:"pointer",fontFamily:"inherit",textAlign:"left",transition:"background 0.12s"},onMouseEnter:Ce=>Ce.currentTarget.style.background="var(--bg-secondary)",onMouseLeave:Ce=>Ce.currentTarget.style.background="none",children:[r.jsx(si,{size:18,style:{color:"#fbbf24",flexShrink:0}}),r.jsxs("div",{children:[r.jsx("div",{style:{fontSize:13,fontWeight:600,color:"var(--text-primary)"},children:e("atlas.addToBucket")}),r.jsx("div",{style:{fontSize:11,color:"var(--text-muted)",marginTop:1},children:e("atlas.addToBucketHint")})]})]})]}),X.type==="unmark"&&r.jsxs(r.Fragment,{children:[r.jsx("p",{style:{margin:"0 0 20px",fontSize:13,color:"var(--text-muted)"},children:e("atlas.confirmUnmark")}),r.jsxs("div",{style:{display:"flex",gap:8,justifyContent:"center"},children:[r.jsx("button",{onClick:()=>Z(null),style:{padding:"8px 20px",borderRadius:10,border:"1px solid var(--border-primary)",background:"none",fontSize:13,cursor:"pointer",fontFamily:"inherit",color:"var(--text-muted)"},children:e("common.cancel")}),r.jsx("button",{onClick:Oe,style:{padding:"8px 20px",borderRadius:10,border:"none",fontSize:13,fontWeight:600,cursor:"pointer",fontFamily:"inherit",background:"#ef4444",color:"white"},children:e("atlas.unmark")})]})]}),X.type==="bucket"&&r.jsxs(r.Fragment,{children:[r.jsx("p",{style:{margin:"0 0 14px",fontSize:13,color:"var(--text-muted)"},children:e("atlas.bucketWhen")}),r.jsxs("div",{style:{display:"flex",gap:8,justifyContent:"center",marginBottom:16},children:[r.jsx("div",{style:{flex:1},children:r.jsx(ea,{value:String(O),onChange:Ce=>Q(Number(Ce)),placeholder:e("atlas.month"),options:[{value:"0",label:"—"},...Array.from({length:12},(Ce,De)=>({value:String(De+1),label:new Date(2e3,De).toLocaleString(t,{month:"long"})}))],size:"sm"})}),r.jsx("div",{style:{flex:1},children:r.jsx(ea,{value:String(D),onChange:Ce=>J(Number(Ce)),placeholder:e("atlas.year"),options:[{value:"0",label:"—"},...Array.from({length:20},(Ce,De)=>({value:String(new Date().getFullYear()+De),label:String(new Date().getFullYear()+De)}))],size:"sm"})})]}),r.jsxs("div",{style:{display:"flex",gap:8,justifyContent:"center",flexWrap:"wrap"},children:[r.jsx("button",{onClick:()=>Z({...X,type:"choose"}),style:{padding:"8px 20px",borderRadius:10,border:"1px solid var(--border-primary)",background:"none",fontSize:13,cursor:"pointer",fontFamily:"inherit",color:"var(--text-muted)"},children:e("common.back")}),r.jsx("button",{onClick:async()=>{const Ce=O>0&&D>0?`${D}-${String(O).padStart(2,"0")}`:null;try{const De=await ie.post("/addons/atlas/bucket-list",{name:X.name,country_code:X.code,target_date:Ce});W(Qe=>[De.data.item,...Qe])}catch{}Q(0),J(0),Z(null)},style:{padding:"8px 20px",borderRadius:10,border:"none",fontSize:13,fontWeight:600,cursor:"pointer",fontFamily:"inherit",background:"#fbbf24",color:"#1a1a1a"},children:e("atlas.addToBucket")})]})]}),X.type==="mark"&&r.jsxs(r.Fragment,{children:[r.jsx("p",{style:{margin:"0 0 20px",fontSize:13,color:"var(--text-muted)"},children:e("atlas.confirmMark")}),r.jsxs("div",{style:{display:"flex",gap:8,justifyContent:"center"},children:[r.jsx("button",{onClick:()=>Z(null),style:{padding:"8px 20px",borderRadius:10,border:"1px solid var(--border-primary)",background:"none",fontSize:13,cursor:"pointer",fontFamily:"inherit",color:"var(--text-muted)"},children:e("common.cancel")}),r.jsx("button",{onClick:Oe,style:{padding:"8px 20px",borderRadius:10,border:"none",fontSize:13,fontWeight:600,cursor:"pointer",fontFamily:"inherit",background:"var(--text-primary)",color:"white"},children:e("atlas.markVisited")})]})]})]})})]})}function G7({data:e,stats:t,countries:a,selectedCountry:n,countryDetail:i,resolveName:o,onTripClick:s,onUnmarkCountry:d,bucketList:c,bucketTab:p,setBucketTab:m,showBucketAdd:g,setShowBucketAdd:f,bucketForm:y,setBucketForm:x,onAddBucket:k,onDeleteBucket:S,onSearchBucket:v,onSelectBucketPoi:_,bucketSearchResults:w,setBucketSearchResults:E,bucketPoiMonth:M,setBucketPoiMonth:A,bucketPoiYear:P,setBucketPoiYear:R,bucketSearching:$,bucketSearch:I,setBucketSearch:Y,t:H,dark:V}){const{language:X}=ot(),Z=we=>V?`rgba(255,255,255,${we})`:`rgba(0,0,0,${we})`,O=V?"#f1f5f9":"#0f172a",Q=V?"#94a3b8":"#64748b",D=V?"#475569":"#94a3b8",{mostVisited:J,continents:z,lastTrip:W,nextTrip:B,streak:C,firstYear:U,tripsThisYear:q}=e||{},te=z?Object.entries(z).sort((we,ce)=>ce[1]-we[1]):[];te.length>0&&te[0][1];const oe={Europe:H("atlas.europe"),Asia:H("atlas.asia"),"North America":H("atlas.northAmerica"),"South America":H("atlas.southAmerica"),Africa:H("atlas.africa"),Oceania:H("atlas.oceania")},be=r.jsx("div",{style:{display:"flex",gap:4,padding:"12px 16px 0",marginBottom:4},children:[{id:"stats",label:H("atlas.statsTab"),icon:Ri},{id:"bucket",label:H("atlas.bucketTab"),icon:si}].map(we=>r.jsxs("button",{onClick:()=>m(we.id),style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",gap:5,padding:"7px 0",borderRadius:10,border:"none",cursor:"pointer",fontFamily:"inherit",fontSize:12,fontWeight:600,transition:"all 0.15s",background:p===we.id?Z(.1):"transparent",color:p===we.id?O:D},children:[r.jsx(we.icon,{size:13}),we.label]},we.id))});if(a.length===0&&!W&&p!=="bucket")return r.jsxs(r.Fragment,{children:[be,r.jsxs("div",{className:"p-8 text-center",children:[r.jsx(Ri,{size:28,className:"mx-auto mb-2",style:{color:D,opacity:.4}}),r.jsx("p",{className:"text-sm font-medium",style:{color:Q},children:H("atlas.noData")}),r.jsx("p",{className:"text-xs mt-1",style:{color:D},children:H("atlas.noDataHint")})]})]});const Se=new Date().getFullYear(),je=r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"flex items-stretch",style:{overflowX:"auto",padding:"0 8px"},children:[c.map(we=>r.jsxs("div",{className:"group flex flex-col items-center justify-center shrink-0",style:{padding:"8px 14px",position:"relative",minWidth:80},children:[(()=>{var le,K;const ce=((le=we.country_code)==null?void 0:le.length)===2?we.country_code:((K=Object.entries(Wo).find(([,de])=>de===we.country_code))==null?void 0:K[0])||"";return ce?r.jsx("img",{src:`https://flagcdn.com/w40/${ce.toLowerCase()}.png`,alt:ce,style:{width:28,height:20,borderRadius:4,objectFit:"cover",marginBottom:4}}):r.jsx(si,{size:16,style:{color:"#fbbf24",marginBottom:4},fill:"#fbbf24"})})(),r.jsx("span",{className:"text-xs font-semibold text-center leading-tight",style:{color:O,maxWidth:90,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:we.name}),we.target_date&&(()=>{const[ce,le]=we.target_date.split("-"),K=le?new Date(Number(ce),Number(le)-1).toLocaleString(X,{month:"short",year:"numeric"}):ce;return r.jsx("span",{className:"text-[9px] mt-0.5 text-center",style:{color:D},children:K})})(),!we.target_date&&we.notes&&r.jsx("span",{className:"text-[9px] mt-0.5 text-center",style:{color:D,maxWidth:90,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:we.notes}),r.jsx("button",{onClick:()=>S(we.id),className:"opacity-0 group-hover:opacity-100",style:{position:"absolute",top:4,right:4,background:"none",border:"none",cursor:"pointer",padding:2,color:D,display:"flex",transition:"opacity 0.15s"},children:r.jsx(gt,{size:10})})]},we.id)),c.length===0&&!g&&r.jsx("div",{className:"flex items-center justify-center py-4 px-6",style:{color:D,fontSize:12},children:H("atlas.bucketEmptyHint")})]}),g?r.jsxs("div",{style:{padding:"8px 16px 12px",display:"flex",flexDirection:"column",gap:6},children:[r.jsxs("div",{style:{position:"relative"},children:[r.jsxs("div",{style:{display:"flex",gap:4},children:[r.jsx("input",{type:"text",value:y.name||I,onChange:we=>{const ce=we.target.value;y.name?x({...y,name:ce}):Y(ce)},onKeyDown:we=>{we.key==="Enter"&&!y.name?v():we.key==="Enter"&&k(),we.key==="Escape"&&f(!1)},placeholder:H("atlas.bucketNamePlaceholder"),autoFocus:!0,style:{flex:1,padding:"6px 10px",borderRadius:8,border:"1px solid var(--border-primary)",fontSize:12,fontFamily:"inherit",outline:"none",boxSizing:"border-box",color:"var(--text-primary)",background:"var(--bg-input)"}}),!y.name&&r.jsx("button",{onClick:v,disabled:$,style:{padding:"6px 10px",borderRadius:8,border:"none",background:"var(--accent)",color:"var(--accent-text)",cursor:"pointer",display:"flex",alignItems:"center"},children:r.jsx(Om,{size:12})}),y.name&&r.jsx("button",{onClick:()=>{x({...y,name:"",lat:"",lng:""}),Y("")},style:{padding:"6px 8px",borderRadius:8,border:"1px solid var(--border-primary)",background:"none",cursor:"pointer",display:"flex",alignItems:"center",color:"var(--text-faint)"},children:r.jsx(gt,{size:12})})]}),w.length>0&&r.jsx("div",{style:{position:"absolute",bottom:"100%",left:0,right:0,zIndex:50,marginBottom:4,background:"var(--bg-card)",border:"1px solid var(--border-primary)",borderRadius:8,boxShadow:"0 4px 12px rgba(0,0,0,0.12)",maxHeight:160,overflowY:"auto"},children:w.slice(0,6).map((we,ce)=>r.jsxs("button",{onClick:()=>_(we),style:{display:"flex",flexDirection:"column",gap:1,width:"100%",padding:"6px 10px",border:"none",background:"none",cursor:"pointer",textAlign:"left",fontFamily:"inherit",borderBottom:"1px solid var(--border-faint)"},children:[r.jsx("span",{style:{fontSize:12,fontWeight:500,color:"var(--text-primary)"},children:we.name}),we.address&&r.jsx("span",{style:{fontSize:10,color:"var(--text-faint)"},children:we.address})]},ce))})]}),y.lat&&y.lng&&r.jsxs("div",{style:{fontSize:10,color:"var(--text-faint)",display:"flex",alignItems:"center",gap:4},children:[r.jsx(tn,{size:10})," ",Number(y.lat).toFixed(4),", ",Number(y.lng).toFixed(4)]}),r.jsxs("div",{style:{display:"flex",gap:6},children:[r.jsx("div",{style:{flex:1},children:r.jsx(ea,{value:String(M),onChange:we=>A(Number(we)),placeholder:H("atlas.month"),size:"sm",options:[{value:"0",label:"—"},...Array.from({length:12},(we,ce)=>({value:String(ce+1),label:new Date(2e3,ce).toLocaleString(X,{month:"short"})}))]})}),r.jsx("div",{style:{flex:1},children:r.jsx(ea,{value:String(P),onChange:we=>R(Number(we)),placeholder:H("atlas.year"),size:"sm",options:[{value:"0",label:"—"},...Array.from({length:20},(we,ce)=>({value:String(new Date().getFullYear()+ce),label:String(new Date().getFullYear()+ce)}))]})})]}),r.jsxs("div",{style:{display:"flex",gap:6,justifyContent:"flex-end"},children:[r.jsx("button",{onClick:()=>{f(!1),x({name:"",notes:"",lat:"",lng:"",target_date:""}),Y(""),E([]),A(0),R(0)},style:{fontSize:11,padding:"4px 10px",borderRadius:6,border:"1px solid var(--border-primary)",background:"none",cursor:"pointer",fontFamily:"inherit",color:"var(--text-muted)"},children:H("common.cancel")}),r.jsx("button",{onClick:k,disabled:!y.name.trim(),style:{fontSize:11,padding:"4px 12px",borderRadius:6,border:"none",background:"#fbbf24",color:"#1a1a1a",fontWeight:600,cursor:"pointer",fontFamily:"inherit",opacity:y.name.trim()?1:.5},children:H("common.add")})]})]}):r.jsx("div",{style:{padding:"4px 16px 8px"},children:r.jsxs("button",{onClick:()=>f(!0),style:{display:"flex",alignItems:"center",justifyContent:"center",gap:4,width:"100%",padding:"5px 0",borderRadius:8,border:"1px dashed var(--border-primary)",background:"none",fontSize:11,color:D,cursor:"pointer",fontFamily:"inherit"},children:[r.jsx(Ft,{size:11})," ",H("atlas.addPoi")]})})]});return r.jsxs(r.Fragment,{children:[be,r.jsxs("div",{style:{display:"grid"},children:[r.jsx("div",{style:p==="bucket"?{visibility:"hidden",gridArea:"1/1"}:{gridArea:"1/1"},children:r.jsxs("div",{className:"flex items-stretch justify-center",children:[r.jsxs("div",{className:"flex items-baseline gap-1.5 px-5 py-4 mx-2 my-2 rounded-xl",style:{background:Z(.08)},children:[r.jsx("span",{className:"text-5xl font-black tabular-nums leading-none",style:{color:O},children:t.totalCountries}),r.jsx("span",{className:"text-sm font-medium",style:{color:Q},children:H("atlas.countries")})]}),[[t.totalTrips,H("atlas.trips")],[t.totalPlaces,H("atlas.places")],[t.totalCities||0,H("atlas.cities")],[t.totalDays,H("atlas.days")]].map(([we,ce],le)=>r.jsxs("div",{className:"flex flex-col items-center justify-center px-3 py-5 shrink-0",children:[r.jsx("span",{className:"text-2xl font-black tabular-nums leading-none",style:{color:O},children:we}),r.jsx("span",{className:"text-[9px] font-semibold mt-1.5 uppercase tracking-wide whitespace-nowrap",style:{color:D},children:ce})]},le)),r.jsx("div",{style:{width:2,background:Z(.08),margin:"12px 14px"}}),r.jsx("div",{className:"flex items-center gap-4 px-3 py-4 shrink-0",children:["Europe","Asia","North America","South America","Africa","Oceania"].map(we=>{const ce=(z==null?void 0:z[we])||0,le=ce>0;return r.jsxs("div",{className:"flex flex-col items-center shrink-0",children:[r.jsx("span",{className:"text-2xl font-black tabular-nums leading-none",style:{color:le?O:Z(.15)},children:ce}),r.jsx("span",{className:"text-[9px] font-semibold mt-1.5 uppercase tracking-wide whitespace-nowrap",style:{color:le?D:Z(.1)},children:oe[we]})]},we)})}),r.jsx("div",{style:{width:2,background:Z(.08),margin:"12px 14px"}}),r.jsxs("div",{className:"flex items-center gap-5 px-3 py-4",children:[W&&r.jsxs("button",{onClick:()=>s(W.id),className:"flex items-center gap-2.5 text-left transition-opacity hover:opacity-75",children:[r.jsx("div",{className:"w-10 h-10 rounded-xl flex items-center justify-center text-lg shrink-0",style:{background:Z(.06)},children:W.countryCode?qp(W.countryCode):r.jsx(tn,{size:16,style:{color:Q}})}),r.jsxs("div",{className:"min-w-0",children:[r.jsx("p",{className:"text-[9px] uppercase tracking-wider font-semibold",style:{color:D},children:H("atlas.lastTrip")}),r.jsx("p",{className:"text-[13px] font-bold truncate",style:{color:O},children:W.title})]})]}),C>0&&r.jsxs("div",{className:"flex flex-col items-center justify-center px-3",children:[r.jsx("span",{className:"text-2xl font-black tabular-nums leading-none",style:{color:O},children:C}),r.jsx("span",{className:"text-[9px] font-semibold mt-1.5 uppercase tracking-wide text-center leading-tight whitespace-nowrap",style:{color:D},children:H(C===1?"atlas.yearInRow":"atlas.yearsInRow")})]}),q>0&&r.jsxs("div",{className:"flex flex-col items-center justify-center px-3",children:[r.jsx("span",{className:"text-2xl font-black tabular-nums leading-none",style:{color:O},children:q}),r.jsxs("span",{className:"text-[9px] font-semibold mt-1.5 uppercase tracking-wide text-center leading-tight whitespace-nowrap",style:{color:D},children:[H(q===1?"atlas.tripIn":"atlas.tripsIn")," ",Se]})]})]}),n&&i&&r.jsxs(r.Fragment,{children:[r.jsx("div",{style:{width:2,background:Z(.08),margin:"12px 0"}}),r.jsxs("div",{className:"flex items-center gap-3 px-6 py-4",children:[r.jsx("span",{className:"text-3xl",children:qp(n)}),r.jsxs("div",{children:[r.jsx("p",{className:"text-sm font-bold",style:{color:O},children:o(n)}),r.jsxs("p",{className:"text-[10px] mb-1",style:{color:D},children:[i.places.length," ",H("atlas.places")," · ",i.trips.length," Trips"]}),r.jsxs("div",{className:"flex flex-wrap gap-1",children:[i.trips.slice(0,3).map(we=>r.jsxs("button",{onClick:()=>s(we.id),className:"flex items-center gap-1 px-2 py-0.5 rounded text-[10px] font-semibold transition-opacity hover:opacity-75",style:{background:Z(.08),color:O},children:[r.jsx(ys,{size:9,style:{color:Q}}),we.title]},we.id)),i.manually_marked&&d&&r.jsxs("button",{onClick:()=>d(n),className:"flex items-center gap-1 px-2 py-0.5 rounded text-[10px] font-semibold transition-opacity hover:opacity-75",style:{background:"rgba(239,68,68,0.1)",color:"#ef4444"},children:[r.jsx(gt,{size:9}),H("atlas.unmark")]})]})]})]})]})]})}),r.jsx("div",{style:p==="stats"?{visibility:"hidden",gridArea:"1/1"}:{gridArea:"1/1"},children:je})]})]})}var Co={},Ol={};/**
+ * @license React
+ * react-dom-server-legacy.browser.production.min.js
+ *
+ * Copyright (c) Facebook, Inc. and its affiliates.
+ *
+ * This source code is licensed under the MIT license found in the
+ * LICENSE file in the root directory of this source tree.
+ */var xz=b;function kt(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,a=1;a]/;function En(e){if(typeof e=="boolean"||typeof e=="number")return""+e;e=""+e;var t=X7.exec(e);if(t){var a="",n,i=0;for(n=t.index;n"),Xu(e,i,a),typeof a=="string"?(e.push(En(a)),null):a}var a9=/^[a-zA-Z][a-zA-Z:_\.\-\d]*$/,yw=new Map;function Yr(e){var t=yw.get(e);if(t===void 0){if(!a9.test(e))throw Error(kt(65,e));t="<"+e,yw.set(e,t)}return t}function n9(e,t,a,n,i){switch(t){case"select":e.push(Yr("select"));var o=null,s=null;for(m in a)if(Bn.call(a,m)){var d=a[m];if(d!=null)switch(m){case"children":o=d;break;case"dangerouslySetInnerHTML":s=d;break;case"defaultValue":case"value":break;default:tr(e,n,m,d)}}return e.push(">"),Xu(e,s,o),o;case"option":s=i.selectedValue,e.push(Yr("option"));var c=d=null,p=null,m=null;for(o in a)if(Bn.call(a,o)){var g=a[o];if(g!=null)switch(o){case"children":d=g;break;case"selected":p=g;break;case"dangerouslySetInnerHTML":m=g;break;case"value":c=g;default:tr(e,n,o,g)}}if(s!=null)if(a=c!==null?""+c:t9(d),vy(s)){for(n=0;n"),Xu(e,m,d),d;case"textarea":e.push(Yr("textarea")),m=s=o=null;for(d in a)if(Bn.call(a,d)&&(c=a[d],c!=null))switch(d){case"children":m=c;break;case"value":o=c;break;case"defaultValue":s=c;break;case"dangerouslySetInnerHTML":throw Error(kt(91));default:tr(e,n,d,c)}if(o===null&&s!==null&&(o=s),e.push(">"),m!=null){if(o!=null)throw Error(kt(92));if(vy(m)&&1"),null;case"menuitem":e.push(Yr("menuitem"));for(var f in a)if(Bn.call(a,f)&&(o=a[f],o!=null))switch(f){case"children":case"dangerouslySetInnerHTML":throw Error(kt(400));default:tr(e,n,f,o)}return e.push(">"),null;case"title":e.push(Yr("title")),o=null;for(g in a)if(Bn.call(a,g)&&(s=a[g],s!=null))switch(g){case"children":o=s;break;case"dangerouslySetInnerHTML":throw Error(kt(434));default:tr(e,n,g,s)}return e.push(">"),o;case"listing":case"pre":e.push(Yr(t)),s=o=null;for(c in a)if(Bn.call(a,c)&&(d=a[c],d!=null))switch(c){case"children":o=d;break;case"dangerouslySetInnerHTML":s=d;break;default:tr(e,n,c,d)}if(e.push(">"),s!=null){if(o!=null)throw Error(kt(60));if(typeof s!="object"||!("__html"in s))throw Error(kt(61));a=s.__html,a!=null&&(typeof a=="string"&&0"),null;case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return _h(e,a,t,n);case"html":return i.insertionMode===0&&e.push(""),_h(e,a,t,n);default:if(t.indexOf("-")===-1&&typeof a.is!="string")return _h(e,a,t,n);e.push(Yr(t)),s=o=null;for(p in a)if(Bn.call(a,p)&&(d=a[p],d!=null))switch(p){case"children":o=d;break;case"dangerouslySetInnerHTML":s=d;break;case"style":wz(e,n,d);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":break;default:kz(p)&&typeof d!="function"&&typeof d!="symbol"&&e.push(" ",p,'="',En(d),'"')}return e.push(">"),Xu(e,s,o),o}}function vw(e,t,a){if(e.push('')}function r9(e,t,a,n){switch(a.insertionMode){case 0:case 1:return e.push('');case 2:return e.push('