import"./modulepreload-polyfill-B5Qt9EMX.js";import{d as ut,u as dt,g as pt,r as _,o as ft,D as mt,m as gt,c as z,a as B,x as E,e as c,F as ht,j as yt,t as $,q as xt,M as i,z as vt,G as j,K as bt,A as _t}from"./vendor-nt8ldNfT.js";import{N as wt,F as kt}from"./FooterBar-J0dB23BZ.js";import{c as Lt,l as Tt,_ as Ct}from"./ThemeSwitcher.vue_vue_type_script_setup_true_lang-hbZuyjE_.js";import{_ as Mt}from"./tailwind-Bkcu6GYy.js";const Nt={class:"flex-grow flex justify-center items-start py-3 relative"},zt={class:"chuansong-map-square"},Bt={class:"chuansong-sidebar"},Et={class:"sidebar-content bg-opacity-80 p-4 bg-black rounded-lg"},It={class:"max-h-[70vh] overflow-y-auto pr-2"},St={class:"list-none p-0 m-0 space-y-2"},Pt={class:"bg-[var(--linkColor)] text-white text-center py-3 px-6 rounded-md shadow-sm transform transition duration-300 hover:scale-105 hover:shadow-md text-xs"},At=["disabled","onClick"],Dt={class:"truncate text-xxs"},$t={class:"truncate text-xxs"},l=9920,w=0,u=6,jt="https://doc.scum8.cn/mappngv2/tiles/{z}/{x}/{y}.png",k=619200,Z=-904800,L=619200,O=-904800,X=.9934858979065955,F=-1788.4429271168192,Y=.9576599908898422,R=543.0168796377957,Zt=ut({__name:"TransmitPage",setup(Xt){const d=dt(),U=pt(()=>({backgroundImage:`url(${Lt.value})`,backgroundSize:"cover",backgroundRepeat:"no-repeat",backgroundPosition:"center"})),p=_(null);let a=null,m=null,x=null,f=null,T=null;function V(e,t){return{x:X*e+F,y:Y*t+R}}function q(e,t){return{mapX:(e-F)/X,mapY:(t-R)/Y}}function W(e,t){return e>=-1e-4&&e<=l+1e-4&&t>=-1e-4&&t<=l+1e-4}function H(e){if(!a)return{pxX:0,pxY:0};const t=a.project(e,u);return{pxX:t.x,pxY:t.y}}function K(e,t){const n=e/l,s=t/l,o=k+n*(Z-k),r=L+s*(O-L);return{mapX:o,mapY:r}}function J(e){const{pxX:t,pxY:n}=H(e),s=W(t,n),{mapX:o,mapY:r}=K(t,n),y=V(o,r);return{inside:s,x:y.x,y:y.y}}function I(e,t){if(!a)return i.latLng(0,0);const{mapX:n,mapY:s}=q(e,t),o=(n-k)/(Z-k)*l,r=(s-L)/(O-L)*l;return a.unproject([o,r],u)}function Q(){if(!a)return w;const e=a.getSize(),t=Math.min(e.x,e.y),n=u+Math.log2(t/l);return Math.max(w,Math.min(u,n))}function S(){if(!a||!m)return;const e=Q();a.setMinZoom(e),a.setView(m.getCenter(),e,{animate:!1}),a.panInsideBounds(m,{animate:!1})}const C=_(!1);async function tt(){try{const t=await(await fetch("/chuansong.html?query=ziyouchuansong&_t="+Date.now(),{cache:"no-store"})).json();C.value=(t==null?void 0:t.status)===200&&(t==null?void 0:t.msg)!=="0"}catch{C.value=!1}}function et(){return i.divIcon({className:"click-marker",html:'<div class="cm-wrap"><div class="cm-h"></div><div class="cm-v"></div></div>',iconSize:[16,16],iconAnchor:[8,8]})}function nt(e){if(!a)return[0,0];const t=a.latLngToContainerPoint(e),n=a.getSize(),s=120;let o=0,r=0;return t.y<s?r=140:t.y>n.y-s&&(r=-140),t.x<s?o=180:t.x>n.x-s&&(o=-180),[o,r]}let M=!1,g=null;function at(e,t,n){if(!a)return;const s=t.toFixed(0),o=n.toFixed(0);g={x:s,y:o};const r=`
    <div class="daisy-popup card bg-base-200 text-base-content shadow-lg border border-base-300 p-3 rounded-xl text-sm text-center space-y-2">
      <div class="flex justify-center gap-2 flex-wrap">
        <div class="badge badge-outline">X = ${s}</div>
        <div class="badge badge-outline">Y = ${o}</div>
        <div class="badge badge-outline">Z = 0</div>
      </div>
      <button
        type="button"
        class="btn btn-primary btn-sm w-full js-free-tp-btn"
        data-x="${s}"
        data-y="${o}"
      >
        🚀 自由传送
      </button>
      <div class="text-xs opacity-70">将按当前坐标执行传送</div>
    </div>`,y=nt(e);i.popup({closeButton:!0,className:"coord-popup",maxWidth:420,autoClose:!0,offset:y,autoPan:!0,keepInView:!0,autoPanPadding:[24,24],autoPanPaddingTopLeft:[36,36],autoPanPaddingBottomRight:[36,36]}).setLatLng(e).setContent(r).openOn(a)}function P(e){var N;if(!p.value)return;const n=e.target;if(!n)return;const s=(N=n.closest)==null?void 0:N.call(n,".js-free-tp-btn");if(!s)return;e.preventDefault(),e.stopPropagation();const o=s.dataset.x||(g==null?void 0:g.x),r=s.dataset.y||(g==null?void 0:g.y);if(!o||!r||M)return;M=!0;const y=s.textContent||"";s.disabled=!0,s.textContent="传送中...",(async()=>{try{const lt=`/chuansong.html?ziyouchuansong=yes&xdata=${encodeURIComponent(o)}&ydata=${encodeURIComponent(r)}&_t=${Date.now()}`,h=await(await fetch(lt,{cache:"no-store"})).json();(h==null?void 0:h.status)===200?d.success(h.msg||"自由传送成功"):d.warning((h==null?void 0:h.msg)||"自由传送失败")}catch{d.error("自由传送请求失败")}finally{M=!1,s.disabled=!1,s.textContent=y}})()}function st(e){const t=J(e.latlng);t.inside&&(T?T.setLatLng(e.latlng):T=i.marker(e.latlng,{icon:et(),title:"点击坐标"}).addTo(f),C.value&&at(e.latlng,t.x,t.y))}const b=_([]),v=_({});async function ot(){try{const t=await(await fetch("/chuansong.html?query=transmitdata&_t="+Date.now(),{cache:"no-store"})).json();t.status===200?b.value=t.data:d.warning(t.msg||"获取传送点失败")}catch{d.error("请求失败，无法加载传送点")}}async function A(e){const t=e.fanhuiurl;if(!v.value[t]){v.value[t]=!0;try{const n=e.fanhuiurl+(e.fanhuiurl.includes("?")?"&":"?")+"_t="+Date.now(),o=await(await fetch(n,{cache:"no-store"})).json();o.status===200?d.success(o.msg||"传送成功（仅提示，不跳转）"):d.warning(o.msg||"传送失败，请检查条件")}catch{d.error("传送请求失败，请稍后再试")}finally{v.value[t]=!1}}}function rt(e,t){return i.divIcon({className:"leaflet-daisy-label",iconSize:[100,24],iconAnchor:[50,24],html:`<div class="badge badge-primary badge-md shadow-lg whitespace-nowrap">
      ${e}${t?`<span class="opacity-80 ml-1">${t}</span>`:""}
    </div>`})}function D(){!a||!f||(f.clearLayers(),b.value.forEach(e=>{const t=Number(e.x),n=Number(e.y);if(Number.isNaN(t)||Number.isNaN(n))return;const s=I(t,n),o=i.marker(s,{icon:rt(e.didian,e.didianjine),title:e.didian});o.on("click",()=>A(e)),o.addTo(f)}))}function ct(e){if(!a)return;const t=Number(e.x),n=Number(e.y);Number.isNaN(t)||Number.isNaN(n)||a.flyTo(I(t,n),Math.min(Math.max(a.getZoom(),w),u),{duration:.45})}function it(){if(a||!p.value)return;a=i.map(p.value,{crs:i.CRS.Simple,maxZoom:u,zoomControl:!0,attributionControl:!1,zoomSnap:0,zoomDelta:.25});const e=a.unproject([0,l],u),t=a.unproject([l,0],u);m=i.latLngBounds(e,t),i.tileLayer(jt,{minZoom:w,maxZoom:u,bounds:m,noWrap:!0,tileSize:256}).addTo(a),a.fitBounds(m,{animate:!1}),S(),a.setMaxBounds(m),a.options.maxBoundsViscosity=1,f=i.layerGroup().addTo(a),a.on("click",st),a.on("popupopen",n=>{var o,r;const s=(r=(o=n==null?void 0:n.popup)==null?void 0:o.getElement)==null?void 0:r.call(o);if(s){try{i.DomEvent.disableClickPropagation(s)}catch{}try{i.DomEvent.disableScrollPropagation(s)}catch{}}}),p.value.addEventListener("click",P,!0),x=new ResizeObserver(()=>{a&&(a.invalidateSize({animate:!1}),S())}),x.observe(p.value)}return ft(async()=>{await Tt(),it(),await ot(),D(),await tt()}),mt(b,()=>D(),{deep:!0}),gt(()=>{if(p.value)try{p.value.removeEventListener("click",P,!0)}catch{}if(x){try{x.disconnect()}catch{}x=null}if(f&&a){try{a.removeLayer(f)}catch{}f=null}a&&(a.off(),a.remove(),a=null)}),(e,t)=>(B(),z("div",{class:"flex flex-col min-h-screen",style:xt(U.value)},[E(wt),E(Ct),c("div",Nt,[c("div",zt,[c("div",{ref_key:"mapEl",ref:p,class:"chuansong-map"},null,512)]),c("div",Bt,[t[0]||(t[0]=c("input",{type:"checkbox",id:"sidebar-toggle",class:"hidden",checked:""},null,-1)),t[1]||(t[1]=c("label",{for:"sidebar-toggle",class:"bg-gray-800 text-white p-2 rounded-full cursor-pointer select-none"}," 传送列表 ",-1)),c("div",Et,[c("div",It,[c("ul",St,[(B(!0),z(ht,null,yt(b.value,n=>(B(),z("li",{key:n.fanhuiurl},[c("div",Pt,[c("button",{class:"w-full",disabled:v.value[n.fanhuiurl],onClick:()=>{ct(n),A(n)}},[c("div",Dt,$(v.value[n.fanhuiurl]?"传送中...":n.didian),1),c("div",$t,$(n.didianjine),1)],8,At)])]))),128))])])])])]),E(kt)],4))}}),Ot=Mt(Zt,[["__scopeId","data-v-411194fc"]]),G=vt({render(){return j(bt,null,{default:()=>j(Ot)})}});G.use(_t);G.mount("#app");
