yamlover 0.3.52 → 0.3.53
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/request-url.js +36 -0
- package/bin/yamlover.js +16 -11
- package/dist/client/assets/{decoded-DIrynyA3.js → decoded-D1-rSiME.js} +1 -1
- package/dist/client/assets/{djvu-nd21Uprr.js → djvu-Mwp4sXBt.js} +1 -1
- package/dist/client/assets/{docx-Vop1BSUJ.js → docx-CB6J14IE.js} +1 -1
- package/dist/client/assets/{heic-CsSwcPBN.js → heic-3lumWxbh.js} +1 -1
- package/dist/client/assets/{imagemap-zS65hQz-.js → imagemap-DW9oOX-E.js} +1 -1
- package/dist/client/assets/{index-DosWj0lR.js → index-BVK9vlzr.js} +131 -131
- package/dist/client/assets/{map-CWLpLgs5.js → map-Cdvi3ulU.js} +1 -1
- package/dist/client/assets/{openable-DE9jbyAc.js → openable-BgRIW6s1.js} +2 -2
- package/dist/client/assets/{paged-B9vOXGFT.js → paged-CMePxwer.js} +1 -1
- package/dist/client/assets/{pdf-BlhT_YB6.js → pdf-Dn7yQugW.js} +1 -1
- package/dist/client/assets/{psd-DqFDBsP9.js → psd-KS-xpL2T.js} +1 -1
- package/dist/client/assets/{spreadsheet-C1PFD0U5.js → spreadsheet-DReUrdn2.js} +1 -1
- package/dist/client/assets/{tiff-BhJNM15B.js → tiff-CoQYoJao.js} +1 -1
- package/dist/client/assets/{xyflow-CAiiOrwd.js → xyflow-AJHWfzJh.js} +1 -1
- package/dist/client/index.html +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{h as ft,s as pt,j as L,u as mt,a as gt,r as f,b as dt,D as Y,f as yt,e as ht,c as bt}from"./index-DosWj0lR.js";import{O as Lt,u as xt,L as O,w as Tt}from"./openable-DE9jbyAc.js";import{a as Nt}from"./paged-B9vOXGFT.js";function x(t,e){return Array.from(t.getElementsByTagName(e))}function v(t){return t[0]==="#"?t:`#${t}`}function Ot(t,e,n){return Array.from(t.getElementsByTagNameNS(n,e))}function m(t){return t?.normalize(),t?.textContent||""}function u(t,e,n){const r=t.getElementsByTagName(e);return r.length?r[0]:null}function T(t,e,n){const r={};if(!t)return r;const o=t.getElementsByTagName(e),i=o.length?o[0]:null;return i&&n?n(i,r):r}function k(t,e,n){const r=m(u(t,e));return r&&n?n(r)||{}:{}}function p(t,e,n){const r=Number.parseFloat(m(u(t,e)));if(!Number.isNaN(r))return n&&n(r),r}function M(t,e){const n={};for(const r of e)k(t,r,o=>{n[r]=o});return n}function et(t){return t?.nodeType===1}function nt(t,e){const n={},r=e==="stroke"||e==="fill"?e:`${e}-color`;return t[0]==="#"&&(t=t.substring(1)),t.length===6||t.length===3?n[r]=`#${t}`:t.length===8&&(n[`${e}-opacity`]=Number.parseInt(t.substring(0,2),16)/255,n[r]=`#${t.substring(6,8)}${t.substring(4,6)}${t.substring(2,4)}`),n}function _(t,e,n){const r={};return p(t,e,o=>{r[n]=o}),r}function V(t,e){return T(t,"color",n=>nt(m(n),e))}function $(t){return T(t,"Icon",(e,n)=>(k(e,"href",r=>{n.icon=r}),n))}function wt(t){return T(t,"IconStyle",e=>Object.assign(V(e,"icon"),_(e,"scale","icon-scale"),_(e,"heading","icon-heading"),T(e,"hotSpot",n=>{const r=Number.parseFloat(n.getAttribute("x")||""),o=Number.parseFloat(n.getAttribute("y")||""),i=n.getAttribute("xunits")||"",s=n.getAttribute("yunits")||"";return!Number.isNaN(r)&&!Number.isNaN(o)?{"icon-offset":[r,o],"icon-offset-units":[i,s]}:{}}),$(e)))}function Et(t){return T(t,"LabelStyle",e=>Object.assign(V(e,"label"),_(e,"scale","label-scale")))}function kt(t){return T(t,"LineStyle",e=>Object.assign(V(e,"stroke"),_(e,"width","stroke-width")))}function At(t){return T(t,"PolyStyle",(e,n)=>Object.assign(n,T(e,"color",r=>nt(m(r),"fill")),k(e,"fill",r=>{if(r==="0")return{"fill-opacity":0}}),k(e,"outline",r=>{if(r==="0")return{"stroke-opacity":0}})))}function B(t){return Object.assign({},At(t),kt(t),Et(t),wt(t))}const Rt=/\s*/g,St=/^\s*|\s*$/g,vt=/\s+/;function rt(t){return t.replace(Rt,"").split(",").map(Number.parseFloat).filter(e=>!Number.isNaN(e)).slice(0,3)}function j(t){return t.replace(St,"").split(vt).map(rt).filter(e=>e.length>=2)}function _t(t){let e=x(t,"coord");e.length===0&&(e=Ot(t,"coord","*"));const n=e.map(r=>m(r).split(" ").map(Number.parseFloat));return n.length===0?null:{geometry:n.length>2?{type:"LineString",coordinates:n}:{type:"Point",coordinates:n[0]},times:x(t,"when").map(r=>m(r))}}function ot(t){if(t.length===0)return t;const e=t[0],n=t[t.length-1];let r=!0;for(let o=0;o<Math.max(e.length,n.length);o++)if(e[o]!==n[o]){r=!1;break}return r?t:t.concat([t[0]])}function S(t){return m(u(t,"coordinates"))}function it(t){let e=[],n=[];for(let r=0;r<t.childNodes.length;r++){const o=t.childNodes.item(r);if(et(o))switch(o.tagName){case"MultiGeometry":case"MultiTrack":case"gx:MultiTrack":{const i=it(o);e=e.concat(i.geometries),n=n.concat(i.coordTimes);break}case"Point":{const i=rt(S(o));i.length>=2&&e.push({type:"Point",coordinates:i});break}case"LinearRing":case"LineString":{const i=j(S(o));i.length>=2&&e.push({type:"LineString",coordinates:i});break}case"Polygon":{const i=[];for(const s of x(o,"LinearRing")){const c=ot(j(S(s)));c.length>=4&&i.push(c)}i.length&&e.push({type:"Polygon",coordinates:i});break}case"Track":case"gx:Track":{const i=_t(o);if(!i)break;const{times:s,geometry:c}=i;e.push(c),s.length&&n.push(s);break}}}return{geometries:e,coordTimes:n}}const E=t=>Number(t),D={string:t=>t,int:E,uint:E,short:E,ushort:E,float:E,double:E,bool:t=>!!t};function U(t,e){return T(t,"ExtendedData",(n,r)=>{for(const o of x(n,"Data"))r[o.getAttribute("name")||""]=m(u(o,"value"));for(const o of x(n,"SimpleData")){const i=o.getAttribute("name")||"",s=e[i]||D.string;r[i]=s(m(o))}return r})}function Z(t){const e=u(t,"description");for(const n of Array.from(e?.childNodes||[]))if(n.nodeType===4)return{description:{"@type":"html",value:m(n)}};return{}}function z(t){return T(t,"TimeSpan",e=>({timespan:{begin:m(u(e,"begin")),end:m(u(e,"end"))}}))}function H(t){return T(t,"TimeStamp",e=>({timestamp:m(u(e,"when"))}))}function J(t,e){return k(t,"styleUrl",n=>(n=v(n),e[n]?Object.assign({styleUrl:n},e[n]):{styleUrl:n}))}var d;(function(t){t.ABSOLUTE="absolute",t.RELATIVE_TO_GROUND="relativeToGround",t.CLAMP_TO_GROUND="clampToGround",t.CLAMP_TO_SEAFLOOR="clampToSeaFloor",t.RELATIVE_TO_SEAFLOOR="relativeToSeaFloor"})(d||(d={}));function Mt(t){switch(t?.textContent){case d.ABSOLUTE:return d.ABSOLUTE;case d.CLAMP_TO_GROUND:return d.CLAMP_TO_GROUND;case d.CLAMP_TO_SEAFLOOR:return d.CLAMP_TO_SEAFLOOR;case d.RELATIVE_TO_GROUND:return d.RELATIVE_TO_GROUND;case d.RELATIVE_TO_SEAFLOOR:return d.RELATIVE_TO_SEAFLOOR}return null}function Bt(t){return u(t,"gx:LatLonQuad")?{geometry:{type:"Polygon",coordinates:[ot(j(S(t)))]}}:Pt(t)}const Ct=Math.PI/180;function It(t,e,n){const r=[(t[0]+t[2])/2,(t[1]+t[3])/2];return[e[0].map(o=>{const i=o[1]-r[1],s=o[0]-r[0],c=Math.sqrt(i**2+s**2),a=Math.atan2(i,s)+n*Ct;return[r[0]+Math.cos(a)*c,r[1]+Math.sin(a)*c]})]}function Pt(t){const e=u(t,"LatLonBox");if(e){const n=p(e,"north"),r=p(e,"west"),o=p(e,"east"),i=p(e,"south"),s=p(e,"rotation");if(typeof n=="number"&&typeof i=="number"&&typeof r=="number"&&typeof o=="number"){const c=[r,i,o,n];let a=[[[r,n],[o,n],[o,i],[r,i],[r,n]]];return typeof s=="number"&&(a=It(c,a,s)),{bbox:c,geometry:{type:"Polygon",coordinates:a}}}}return null}function Ft(t,e,n,r){const o=Bt(t),i=o?.geometry||null;if(!i&&r.skipNullGeometry)return null;const s={type:"Feature",geometry:i,properties:Object.assign({"@geometry-type":"groundoverlay"},M(t,["name","address","visibility","open","phoneNumber","description"]),Z(t),J(t,e),B(t),$(t),U(t,n),z(t),H(t))};o?.bbox&&(s.bbox=o.bbox),s.properties?.visibility!==void 0&&(s.properties.visibility=s.properties.visibility!=="0");const c=t.getAttribute("id");return c!==null&&c!==""&&(s.id=c),s}function Gt(t){const e=u(t,"Region");return e?{coordinateBox:Dt(e),lod:jt(t)}:null}function jt(t){const e=u(t,"Lod");return e?[p(e,"minLodPixels")??-1,p(e,"maxLodPixels")??-1,p(e,"minFadeExtent")??null,p(e,"maxFadeExtent")??null]:null}function Dt(t){const e=u(t,"LatLonAltBox");if(e){const n=p(e,"north"),r=p(e,"west"),o=p(e,"east"),i=p(e,"south");if(Mt(u(e,"altitudeMode")||u(e,"gx:altitudeMode"))&&console.debug("Encountered an unsupported feature of KML for togeojson: please contact developers for support of altitude mode."),typeof n=="number"&&typeof i=="number"&&typeof r=="number"&&typeof o=="number")return{bbox:[r,i,o,n],geometry:{type:"Polygon",coordinates:[[[r,n],[o,n],[o,i],[r,i],[r,n]]]}}}return null}function Vt(t){const e=u(t,"Link");return e?M(e,["href","refreshMode","refreshInterval","viewRefreshMode","viewRefreshTime","viewBoundScale","viewFormat","httpQuery"]):{}}function $t(t,e,n,r){const o=Gt(t),i=o?.coordinateBox?.geometry||null;if(!i&&r.skipNullGeometry)return null;const s={type:"Feature",geometry:i,properties:Object.assign({"@geometry-type":"networklink"},M(t,["name","address","visibility","open","phoneNumber","styleUrl","refreshVisibility","flyToView","description"]),Z(t),J(t,e),B(t),$(t),U(t,n),z(t),H(t),Vt(t),o?.lod?{lod:o.lod}:{})};o?.coordinateBox?.bbox&&(s.bbox=o.coordinateBox.bbox),s.properties?.visibility!==void 0&&(s.properties.visibility=s.properties.visibility!=="0");const c=t.getAttribute("id");return c!==null&&c!==""&&(s.id=c),s}function Ut(t){return t.length===0?null:t.length===1?t[0]:{type:"GeometryCollection",geometries:t}}function Zt(t,e,n,r){const{coordTimes:o,geometries:i}=it(t),s=Ut(i);if(!s&&r.skipNullGeometry)return null;const c={type:"Feature",geometry:s,properties:Object.assign(M(t,["name","address","visibility","open","phoneNumber","description"]),Z(t),J(t,e),B(t),U(t,n),z(t),H(t),o.length?{coordinateProperties:{times:o.length===1?o[0]:o}}:{})};c.properties?.visibility!==void 0&&(c.properties.visibility=c.properties.visibility!=="0");const a=t.getAttribute("id");return a!==null&&a!==""&&(c.id=a),c}function zt(t){let e=t.getAttribute("id");const n=t.parentNode;return!e&&et(n)&&n.localName==="CascadingStyle"&&(e=n.getAttribute("kml:id")||n.getAttribute("id")),v(e||"")}function Ht(t){const e={};for(const n of x(t,"Style"))e[zt(n)]=B(n);for(const n of x(t,"StyleMap")){const r=v(n.getAttribute("id")||"");k(n,"styleUrl",o=>{o=v(o),e[o]&&(e[r]=e[o])})}return e}function Jt(t){const e={};for(const n of x(t,"SimpleField"))e[n.getAttribute("name")||""]=D[n.getAttribute("type")||""]||D.string;return e}function*Kt(t,e={skipNullGeometry:!1}){const n=t,r=Ht(n),o=Jt(n);for(const i of x(n,"Placemark")){const s=Zt(i,r,o,e);s&&(yield s)}for(const i of x(n,"GroundOverlay")){const s=Ft(i,r,o,e);s&&(yield s)}for(const i of x(n,"NetworkLink")){const s=$t(i,r,o,e);s&&(yield s)}}function Qt(t,e={skipNullGeometry:!1}){return{type:"FeatureCollection",features:Array.from(Kt(t,e))}}function Wt(t){return t[0]===80&&t[1]===75&&t[2]===3&&t[3]===4}function tt(t){const e=new DOMParser().parseFromString(t,"application/xml");if(e.getElementsByTagName("parsererror").length)throw new Error("malformed KML XML");return Qt(e)}function qt(t){if(Wt(t)){const e=ft(t),n=Object.keys(e).find(r=>r.toLowerCase().endsWith(".kml"));if(!n)throw new Error("no .kml document inside the KMZ archive");return tt(pt(e[n]))}return tt(new TextDecoder().decode(t))}const st={},Xt=st?.VITE_MAP_TILE_URL??"https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",Yt=st?.VITE_MAP_TILE_ATTRIBUTION??'© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',N=t=>Number(t)||0;function te(t,e){return t.filter(n=>n.selector?.type==="map").map(n=>({n:N(n.selector.n),s:N(n.selector.s),e:N(n.selector.e),w:N(n.selector.w),title:n.description,color:bt(n),ann:ht(n)?n:void 0,id:n.fragmentSlug?yt(e,n.fragmentSlug):void 0}))}function ct(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function ee(t){return t?typeof t=="string"?ct(t):typeof t=="object"&&t["@type"]==="html"?String(t.value??""):"":""}function ne(t,e,n=!0){const r=O.map(t,n?{}:{dragging:!1,scrollWheelZoom:!1,doubleClickZoom:!1,boxZoom:!1,keyboard:!1,touchZoom:!1,zoomControl:!1});O.tileLayer(Xt,{maxZoom:19,attribution:Yt}).addTo(r);const i=O.geoJSON(e,{style:s=>{const c=s?.properties??{};return{color:c.stroke||"#3388ff",weight:c["stroke-width"]||2,opacity:c["stroke-opacity"]??1,fillColor:c.fill||"#3388ff",fillOpacity:c["fill-opacity"]??.2}},pointToLayer:(s,c)=>O.circleMarker(c,{radius:5,color:"#e23",weight:2,fillOpacity:.8}),onEachFeature:n?(s,c)=>{const a=s.properties??{},w=a.name?`<strong>${ct(a.name)}</strong>`:"",A=ee(a.description),R=A?`<div class="map-popup-desc">${A}</div>`:"";(w||R)&&c.bindPopup(`${w}${R}`)}:void 0}).addTo(r).getBounds();return i.isValid()?r.fitBounds(i,{padding:[24,24],maxZoom:16}):r.setView([0,0],2),r}function at({path:t,className:e,regions:n,onSelectRegion:r,onRegionClick:o,selectColor:i,interactive:s=!0}){const c=f.useRef(null),a=f.useRef(null),w=f.useRef(null),A=f.useRef(r),R=f.useRef(o),K=f.useRef(i),[C,Q]=f.useState(null),[lt,I]=f.useState(!0),[W,ut]=f.useState(0),q=JSON.stringify(n??[]),X=!!r;Nt(c,14,s),xt(c,()=>a.current),f.useEffect(()=>{A.current=r,R.current=o,K.current=i}),f.useEffect(()=>{let y=!1,l=null;return Q(null),I(!0),fetch(dt(t)).then(g=>g.arrayBuffer()).then(g=>{if(y||!c.current)return;const h=ne(c.current,qt(new Uint8Array(g)),s);w.current=O.layerGroup().addTo(h),a.current=h,s&&(l=Tt(h,{color:()=>K.current?.()??Y,onSelect:X?(b,F)=>A.current?.({type:"map",n:b.getNorth(),s:b.getSouth(),e:b.getEast(),w:b.getWest()},F):void 0})),ut(b=>b+1),I(!1)}).catch(g=>{y||(Q(String(g.message||g)),I(!1))}),()=>{y=!0,l?.(),a.current?.remove(),a.current=null,w.current=null}},[t]);const P=f.useRef(new Map);return f.useEffect(()=>{const y=w.current;if(y){y.clearLayers(),P.current.clear();for(const l of n??[]){const g=l.color||Y,h=[[l.s,l.w],[l.n,l.e]],b=O.rectangle(h,{className:"yo-region",color:g,weight:3,fillColor:g,fillOpacity:.25});if(l.title&&b.bindTooltip(l.title),l.ann){const F=l.ann;b.on("click",G=>{O.DomEvent.stop(G),R.current?.(F,{x:G.originalEvent.clientX,y:G.originalEvent.clientY})})}b.addTo(y),l.id&&P.current.set(l.id,{rect:b,bounds:h})}}},[q,W]),f.useEffect(()=>{const y=()=>{const l=a.current,g=decodeURIComponent(window.location.hash.slice(1)),h=g?P.current.get(g):void 0;!l||!h||(l.fitBounds(h.bounds,{maxZoom:l.getZoom(),padding:[40,40]}),h.rect.setStyle({weight:6,fillOpacity:.45}),window.setTimeout(()=>h.rect.setStyle({weight:3,fillOpacity:.25}),1e3))};return y(),window.addEventListener("hashchange",y),()=>window.removeEventListener("hashchange",y)},[q,W]),L.jsxs(L.Fragment,{children:[C&&L.jsxs("div",{className:"error",children:["map: ",C]}),L.jsx("div",{ref:c,className:e+(X?" yo-selectable":"")}),lt&&!C&&L.jsx("div",{className:"loading",children:"loading map…"})]})}function se({node:t}){const e=mt(t.path),{openCreate:n,openEdit:r,palette:o,preview:i,color:s}=gt(e,t.path),c=te(e.annotations,t.path);if(i?.selector.type==="map"){const a=i.selector;c.push({n:N(a.n),s:N(a.s),e:N(a.e),w:N(a.w),color:i.color})}return L.jsxs("div",{className:"text",children:[t.title&&L.jsx("h1",{className:"chapter-title",children:t.title}),t.description&&L.jsx("p",{className:"chapter-subtitle",children:t.description}),L.jsx(at,{path:t.path,regions:c,onSelectRegion:n,onRegionClick:r,selectColor:()=>s,className:"filemap"}),o]})}function ce({chunk:t,onNavigate:e}){return L.jsx(Lt,{path:t.path,onNavigate:e,title:"Open map on its own page",children:L.jsx(at,{path:t.path,className:"filemap chunk-map chunk-static",interactive:!1})})}export{ce as MapChunk,se as MapView};
|
|
1
|
+
import{h as ft,s as pt,j as L,u as mt,a as gt,r as f,b as dt,D as Y,f as yt,e as ht,c as bt}from"./index-BVK9vlzr.js";import{O as Lt,u as xt,L as O,w as Tt}from"./openable-BgRIW6s1.js";import{a as Nt}from"./paged-CMePxwer.js";function x(t,e){return Array.from(t.getElementsByTagName(e))}function v(t){return t[0]==="#"?t:`#${t}`}function Ot(t,e,n){return Array.from(t.getElementsByTagNameNS(n,e))}function m(t){return t?.normalize(),t?.textContent||""}function u(t,e,n){const r=t.getElementsByTagName(e);return r.length?r[0]:null}function T(t,e,n){const r={};if(!t)return r;const o=t.getElementsByTagName(e),i=o.length?o[0]:null;return i&&n?n(i,r):r}function k(t,e,n){const r=m(u(t,e));return r&&n?n(r)||{}:{}}function p(t,e,n){const r=Number.parseFloat(m(u(t,e)));if(!Number.isNaN(r))return n&&n(r),r}function M(t,e){const n={};for(const r of e)k(t,r,o=>{n[r]=o});return n}function et(t){return t?.nodeType===1}function nt(t,e){const n={},r=e==="stroke"||e==="fill"?e:`${e}-color`;return t[0]==="#"&&(t=t.substring(1)),t.length===6||t.length===3?n[r]=`#${t}`:t.length===8&&(n[`${e}-opacity`]=Number.parseInt(t.substring(0,2),16)/255,n[r]=`#${t.substring(6,8)}${t.substring(4,6)}${t.substring(2,4)}`),n}function _(t,e,n){const r={};return p(t,e,o=>{r[n]=o}),r}function V(t,e){return T(t,"color",n=>nt(m(n),e))}function $(t){return T(t,"Icon",(e,n)=>(k(e,"href",r=>{n.icon=r}),n))}function wt(t){return T(t,"IconStyle",e=>Object.assign(V(e,"icon"),_(e,"scale","icon-scale"),_(e,"heading","icon-heading"),T(e,"hotSpot",n=>{const r=Number.parseFloat(n.getAttribute("x")||""),o=Number.parseFloat(n.getAttribute("y")||""),i=n.getAttribute("xunits")||"",s=n.getAttribute("yunits")||"";return!Number.isNaN(r)&&!Number.isNaN(o)?{"icon-offset":[r,o],"icon-offset-units":[i,s]}:{}}),$(e)))}function Et(t){return T(t,"LabelStyle",e=>Object.assign(V(e,"label"),_(e,"scale","label-scale")))}function kt(t){return T(t,"LineStyle",e=>Object.assign(V(e,"stroke"),_(e,"width","stroke-width")))}function At(t){return T(t,"PolyStyle",(e,n)=>Object.assign(n,T(e,"color",r=>nt(m(r),"fill")),k(e,"fill",r=>{if(r==="0")return{"fill-opacity":0}}),k(e,"outline",r=>{if(r==="0")return{"stroke-opacity":0}})))}function B(t){return Object.assign({},At(t),kt(t),Et(t),wt(t))}const Rt=/\s*/g,St=/^\s*|\s*$/g,vt=/\s+/;function rt(t){return t.replace(Rt,"").split(",").map(Number.parseFloat).filter(e=>!Number.isNaN(e)).slice(0,3)}function j(t){return t.replace(St,"").split(vt).map(rt).filter(e=>e.length>=2)}function _t(t){let e=x(t,"coord");e.length===0&&(e=Ot(t,"coord","*"));const n=e.map(r=>m(r).split(" ").map(Number.parseFloat));return n.length===0?null:{geometry:n.length>2?{type:"LineString",coordinates:n}:{type:"Point",coordinates:n[0]},times:x(t,"when").map(r=>m(r))}}function ot(t){if(t.length===0)return t;const e=t[0],n=t[t.length-1];let r=!0;for(let o=0;o<Math.max(e.length,n.length);o++)if(e[o]!==n[o]){r=!1;break}return r?t:t.concat([t[0]])}function S(t){return m(u(t,"coordinates"))}function it(t){let e=[],n=[];for(let r=0;r<t.childNodes.length;r++){const o=t.childNodes.item(r);if(et(o))switch(o.tagName){case"MultiGeometry":case"MultiTrack":case"gx:MultiTrack":{const i=it(o);e=e.concat(i.geometries),n=n.concat(i.coordTimes);break}case"Point":{const i=rt(S(o));i.length>=2&&e.push({type:"Point",coordinates:i});break}case"LinearRing":case"LineString":{const i=j(S(o));i.length>=2&&e.push({type:"LineString",coordinates:i});break}case"Polygon":{const i=[];for(const s of x(o,"LinearRing")){const c=ot(j(S(s)));c.length>=4&&i.push(c)}i.length&&e.push({type:"Polygon",coordinates:i});break}case"Track":case"gx:Track":{const i=_t(o);if(!i)break;const{times:s,geometry:c}=i;e.push(c),s.length&&n.push(s);break}}}return{geometries:e,coordTimes:n}}const E=t=>Number(t),D={string:t=>t,int:E,uint:E,short:E,ushort:E,float:E,double:E,bool:t=>!!t};function U(t,e){return T(t,"ExtendedData",(n,r)=>{for(const o of x(n,"Data"))r[o.getAttribute("name")||""]=m(u(o,"value"));for(const o of x(n,"SimpleData")){const i=o.getAttribute("name")||"",s=e[i]||D.string;r[i]=s(m(o))}return r})}function Z(t){const e=u(t,"description");for(const n of Array.from(e?.childNodes||[]))if(n.nodeType===4)return{description:{"@type":"html",value:m(n)}};return{}}function z(t){return T(t,"TimeSpan",e=>({timespan:{begin:m(u(e,"begin")),end:m(u(e,"end"))}}))}function H(t){return T(t,"TimeStamp",e=>({timestamp:m(u(e,"when"))}))}function J(t,e){return k(t,"styleUrl",n=>(n=v(n),e[n]?Object.assign({styleUrl:n},e[n]):{styleUrl:n}))}var d;(function(t){t.ABSOLUTE="absolute",t.RELATIVE_TO_GROUND="relativeToGround",t.CLAMP_TO_GROUND="clampToGround",t.CLAMP_TO_SEAFLOOR="clampToSeaFloor",t.RELATIVE_TO_SEAFLOOR="relativeToSeaFloor"})(d||(d={}));function Mt(t){switch(t?.textContent){case d.ABSOLUTE:return d.ABSOLUTE;case d.CLAMP_TO_GROUND:return d.CLAMP_TO_GROUND;case d.CLAMP_TO_SEAFLOOR:return d.CLAMP_TO_SEAFLOOR;case d.RELATIVE_TO_GROUND:return d.RELATIVE_TO_GROUND;case d.RELATIVE_TO_SEAFLOOR:return d.RELATIVE_TO_SEAFLOOR}return null}function Bt(t){return u(t,"gx:LatLonQuad")?{geometry:{type:"Polygon",coordinates:[ot(j(S(t)))]}}:Pt(t)}const Ct=Math.PI/180;function It(t,e,n){const r=[(t[0]+t[2])/2,(t[1]+t[3])/2];return[e[0].map(o=>{const i=o[1]-r[1],s=o[0]-r[0],c=Math.sqrt(i**2+s**2),a=Math.atan2(i,s)+n*Ct;return[r[0]+Math.cos(a)*c,r[1]+Math.sin(a)*c]})]}function Pt(t){const e=u(t,"LatLonBox");if(e){const n=p(e,"north"),r=p(e,"west"),o=p(e,"east"),i=p(e,"south"),s=p(e,"rotation");if(typeof n=="number"&&typeof i=="number"&&typeof r=="number"&&typeof o=="number"){const c=[r,i,o,n];let a=[[[r,n],[o,n],[o,i],[r,i],[r,n]]];return typeof s=="number"&&(a=It(c,a,s)),{bbox:c,geometry:{type:"Polygon",coordinates:a}}}}return null}function Ft(t,e,n,r){const o=Bt(t),i=o?.geometry||null;if(!i&&r.skipNullGeometry)return null;const s={type:"Feature",geometry:i,properties:Object.assign({"@geometry-type":"groundoverlay"},M(t,["name","address","visibility","open","phoneNumber","description"]),Z(t),J(t,e),B(t),$(t),U(t,n),z(t),H(t))};o?.bbox&&(s.bbox=o.bbox),s.properties?.visibility!==void 0&&(s.properties.visibility=s.properties.visibility!=="0");const c=t.getAttribute("id");return c!==null&&c!==""&&(s.id=c),s}function Gt(t){const e=u(t,"Region");return e?{coordinateBox:Dt(e),lod:jt(t)}:null}function jt(t){const e=u(t,"Lod");return e?[p(e,"minLodPixels")??-1,p(e,"maxLodPixels")??-1,p(e,"minFadeExtent")??null,p(e,"maxFadeExtent")??null]:null}function Dt(t){const e=u(t,"LatLonAltBox");if(e){const n=p(e,"north"),r=p(e,"west"),o=p(e,"east"),i=p(e,"south");if(Mt(u(e,"altitudeMode")||u(e,"gx:altitudeMode"))&&console.debug("Encountered an unsupported feature of KML for togeojson: please contact developers for support of altitude mode."),typeof n=="number"&&typeof i=="number"&&typeof r=="number"&&typeof o=="number")return{bbox:[r,i,o,n],geometry:{type:"Polygon",coordinates:[[[r,n],[o,n],[o,i],[r,i],[r,n]]]}}}return null}function Vt(t){const e=u(t,"Link");return e?M(e,["href","refreshMode","refreshInterval","viewRefreshMode","viewRefreshTime","viewBoundScale","viewFormat","httpQuery"]):{}}function $t(t,e,n,r){const o=Gt(t),i=o?.coordinateBox?.geometry||null;if(!i&&r.skipNullGeometry)return null;const s={type:"Feature",geometry:i,properties:Object.assign({"@geometry-type":"networklink"},M(t,["name","address","visibility","open","phoneNumber","styleUrl","refreshVisibility","flyToView","description"]),Z(t),J(t,e),B(t),$(t),U(t,n),z(t),H(t),Vt(t),o?.lod?{lod:o.lod}:{})};o?.coordinateBox?.bbox&&(s.bbox=o.coordinateBox.bbox),s.properties?.visibility!==void 0&&(s.properties.visibility=s.properties.visibility!=="0");const c=t.getAttribute("id");return c!==null&&c!==""&&(s.id=c),s}function Ut(t){return t.length===0?null:t.length===1?t[0]:{type:"GeometryCollection",geometries:t}}function Zt(t,e,n,r){const{coordTimes:o,geometries:i}=it(t),s=Ut(i);if(!s&&r.skipNullGeometry)return null;const c={type:"Feature",geometry:s,properties:Object.assign(M(t,["name","address","visibility","open","phoneNumber","description"]),Z(t),J(t,e),B(t),U(t,n),z(t),H(t),o.length?{coordinateProperties:{times:o.length===1?o[0]:o}}:{})};c.properties?.visibility!==void 0&&(c.properties.visibility=c.properties.visibility!=="0");const a=t.getAttribute("id");return a!==null&&a!==""&&(c.id=a),c}function zt(t){let e=t.getAttribute("id");const n=t.parentNode;return!e&&et(n)&&n.localName==="CascadingStyle"&&(e=n.getAttribute("kml:id")||n.getAttribute("id")),v(e||"")}function Ht(t){const e={};for(const n of x(t,"Style"))e[zt(n)]=B(n);for(const n of x(t,"StyleMap")){const r=v(n.getAttribute("id")||"");k(n,"styleUrl",o=>{o=v(o),e[o]&&(e[r]=e[o])})}return e}function Jt(t){const e={};for(const n of x(t,"SimpleField"))e[n.getAttribute("name")||""]=D[n.getAttribute("type")||""]||D.string;return e}function*Kt(t,e={skipNullGeometry:!1}){const n=t,r=Ht(n),o=Jt(n);for(const i of x(n,"Placemark")){const s=Zt(i,r,o,e);s&&(yield s)}for(const i of x(n,"GroundOverlay")){const s=Ft(i,r,o,e);s&&(yield s)}for(const i of x(n,"NetworkLink")){const s=$t(i,r,o,e);s&&(yield s)}}function Qt(t,e={skipNullGeometry:!1}){return{type:"FeatureCollection",features:Array.from(Kt(t,e))}}function Wt(t){return t[0]===80&&t[1]===75&&t[2]===3&&t[3]===4}function tt(t){const e=new DOMParser().parseFromString(t,"application/xml");if(e.getElementsByTagName("parsererror").length)throw new Error("malformed KML XML");return Qt(e)}function qt(t){if(Wt(t)){const e=ft(t),n=Object.keys(e).find(r=>r.toLowerCase().endsWith(".kml"));if(!n)throw new Error("no .kml document inside the KMZ archive");return tt(pt(e[n]))}return tt(new TextDecoder().decode(t))}const st={},Xt=st?.VITE_MAP_TILE_URL??"https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",Yt=st?.VITE_MAP_TILE_ATTRIBUTION??'© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',N=t=>Number(t)||0;function te(t,e){return t.filter(n=>n.selector?.type==="map").map(n=>({n:N(n.selector.n),s:N(n.selector.s),e:N(n.selector.e),w:N(n.selector.w),title:n.description,color:bt(n),ann:ht(n)?n:void 0,id:n.fragmentSlug?yt(e,n.fragmentSlug):void 0}))}function ct(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function ee(t){return t?typeof t=="string"?ct(t):typeof t=="object"&&t["@type"]==="html"?String(t.value??""):"":""}function ne(t,e,n=!0){const r=O.map(t,n?{}:{dragging:!1,scrollWheelZoom:!1,doubleClickZoom:!1,boxZoom:!1,keyboard:!1,touchZoom:!1,zoomControl:!1});O.tileLayer(Xt,{maxZoom:19,attribution:Yt}).addTo(r);const i=O.geoJSON(e,{style:s=>{const c=s?.properties??{};return{color:c.stroke||"#3388ff",weight:c["stroke-width"]||2,opacity:c["stroke-opacity"]??1,fillColor:c.fill||"#3388ff",fillOpacity:c["fill-opacity"]??.2}},pointToLayer:(s,c)=>O.circleMarker(c,{radius:5,color:"#e23",weight:2,fillOpacity:.8}),onEachFeature:n?(s,c)=>{const a=s.properties??{},w=a.name?`<strong>${ct(a.name)}</strong>`:"",A=ee(a.description),R=A?`<div class="map-popup-desc">${A}</div>`:"";(w||R)&&c.bindPopup(`${w}${R}`)}:void 0}).addTo(r).getBounds();return i.isValid()?r.fitBounds(i,{padding:[24,24],maxZoom:16}):r.setView([0,0],2),r}function at({path:t,className:e,regions:n,onSelectRegion:r,onRegionClick:o,selectColor:i,interactive:s=!0}){const c=f.useRef(null),a=f.useRef(null),w=f.useRef(null),A=f.useRef(r),R=f.useRef(o),K=f.useRef(i),[C,Q]=f.useState(null),[lt,I]=f.useState(!0),[W,ut]=f.useState(0),q=JSON.stringify(n??[]),X=!!r;Nt(c,14,s),xt(c,()=>a.current),f.useEffect(()=>{A.current=r,R.current=o,K.current=i}),f.useEffect(()=>{let y=!1,l=null;return Q(null),I(!0),fetch(dt(t)).then(g=>g.arrayBuffer()).then(g=>{if(y||!c.current)return;const h=ne(c.current,qt(new Uint8Array(g)),s);w.current=O.layerGroup().addTo(h),a.current=h,s&&(l=Tt(h,{color:()=>K.current?.()??Y,onSelect:X?(b,F)=>A.current?.({type:"map",n:b.getNorth(),s:b.getSouth(),e:b.getEast(),w:b.getWest()},F):void 0})),ut(b=>b+1),I(!1)}).catch(g=>{y||(Q(String(g.message||g)),I(!1))}),()=>{y=!0,l?.(),a.current?.remove(),a.current=null,w.current=null}},[t]);const P=f.useRef(new Map);return f.useEffect(()=>{const y=w.current;if(y){y.clearLayers(),P.current.clear();for(const l of n??[]){const g=l.color||Y,h=[[l.s,l.w],[l.n,l.e]],b=O.rectangle(h,{className:"yo-region",color:g,weight:3,fillColor:g,fillOpacity:.25});if(l.title&&b.bindTooltip(l.title),l.ann){const F=l.ann;b.on("click",G=>{O.DomEvent.stop(G),R.current?.(F,{x:G.originalEvent.clientX,y:G.originalEvent.clientY})})}b.addTo(y),l.id&&P.current.set(l.id,{rect:b,bounds:h})}}},[q,W]),f.useEffect(()=>{const y=()=>{const l=a.current,g=decodeURIComponent(window.location.hash.slice(1)),h=g?P.current.get(g):void 0;!l||!h||(l.fitBounds(h.bounds,{maxZoom:l.getZoom(),padding:[40,40]}),h.rect.setStyle({weight:6,fillOpacity:.45}),window.setTimeout(()=>h.rect.setStyle({weight:3,fillOpacity:.25}),1e3))};return y(),window.addEventListener("hashchange",y),()=>window.removeEventListener("hashchange",y)},[q,W]),L.jsxs(L.Fragment,{children:[C&&L.jsxs("div",{className:"error",children:["map: ",C]}),L.jsx("div",{ref:c,className:e+(X?" yo-selectable":"")}),lt&&!C&&L.jsx("div",{className:"loading",children:"loading map…"})]})}function se({node:t}){const e=mt(t.path),{openCreate:n,openEdit:r,palette:o,preview:i,color:s}=gt(e,t.path),c=te(e.annotations,t.path);if(i?.selector.type==="map"){const a=i.selector;c.push({n:N(a.n),s:N(a.s),e:N(a.e),w:N(a.w),color:i.color})}return L.jsxs("div",{className:"text",children:[t.title&&L.jsx("h1",{className:"chapter-title",children:t.title}),t.description&&L.jsx("p",{className:"chapter-subtitle",children:t.description}),L.jsx(at,{path:t.path,regions:c,onSelectRegion:n,onRegionClick:r,selectColor:()=>s,className:"filemap"}),o]})}function ce({chunk:t,onNavigate:e}){return L.jsx(Lt,{path:t.path,onNavigate:e,title:"Open map on its own page",children:L.jsx(at,{path:t.path,className:"filemap chunk-map chunk-static",interactive:!1})})}export{ce as MapChunk,se as MapView};
|