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.
@@ -1 +1 @@
1
- import{j as f,r as a,D as z,i as q,k as K,b as F,u as V,a as X,f as Y,e as _,c as Q}from"./index-DosWj0lR.js";import{O as ee,u as te,L as p,w as ne}from"./openable-DE9jbyAc.js";import{a as oe}from"./paged-B9vOXGFT.js";const y=t=>Number(t)||0,B=t=>t.replace(/[&<>"]/g,o=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;"})[o]);function re(t){return t.map(o=>{const s=q({name:o.label,color:o.color});return K(o.path)?`<span class="tagswatch" style="--tag:${s}" title="${B(o.label)}"></span>`:`<span class="tagtag" style="--tag:${s}">${B(o.label)}</span>`}).join("")}function se(t,o,s,n,c){if(!t||n<=0||c<=0)return;const r=document.createElement("canvas");r.width=n,r.height=c;const w=r.getContext("2d");if(w){w.drawImage(t,o,s,n,c,0,0,n,c);try{return r.toDataURL("image/png")}catch{return}}}function ae(t,o){const s=new Map;for(const n of t){if(n.selector?.type!=="rect")continue;const c=JSON.stringify(n.selector);let r=s.get(c);r||(r={x:y(n.selector.x),y:y(n.selector.y),w:y(n.selector.w),h:y(n.selector.h),title:n.description,color:Q(n),ann:_(n)?n:void 0,id:n.fragmentSlug?Y(o,n.fragmentSlug):void 0,tags:[]},s.set(c,r)),n.tag&&r.tags.push({path:n.tag.path,label:n.tag.name,color:n.tag.color})}return[...s.values()]}function ce({src:t,className:o,regions:s,onSelectRegion:n,onRegionClick:c,selectColor:r,fill:w=!0}){const d=a.useRef(null),l=a.useRef(null),R=a.useRef(null),b=a.useRef(null),S=a.useRef({w:1,h:1}),C=a.useRef(n),N=a.useRef(c),O=a.useRef(r),[k,I]=a.useState(null),[L,P]=a.useState(0),T=JSON.stringify(s??[]),M=!!n;oe(d,14,w),te(d,()=>l.current),a.useEffect(()=>{C.current=n,N.current=c,O.current=r}),a.useEffect(()=>{let i=!1,h=null;I(null);const e=new Image;return e.onload=()=>{if(i||!d.current)return;const m=e.naturalWidth||1,v=e.naturalHeight||1;S.current={w:m,h:v},b.current=e;const u=p.map(d.current,{crs:p.CRS.Simple,minZoom:-8,attributionControl:!1,zoomSnap:0}),x=[[0,0],[v,m]];p.imageOverlay(t,x).addTo(u),u.fitBounds(x),R.current=p.layerGroup().addTo(u),l.current=u,h=ne(u,{color:()=>O.current?.()??z,onSelect:M?(g,E)=>{const{h:G}=S.current,A=g.getWest(),J=g.getEast(),W=g.getSouth(),D=g.getNorth(),H=Math.round(A),U=Math.round(G-D),Z=Math.round(J-A),$=Math.round(D-W);C.current?.({type:"rect",x:H,y:U,w:Z,h:$},E,se(b.current,H,U,Z,$))}:void 0}),P(g=>g+1)},e.onerror=()=>{i||I("could not load image")},e.src=t,()=>{i=!0,h?.(),l.current?.remove(),l.current=null,R.current=null}},[t]);const j=a.useRef(new Map);return a.useEffect(()=>{const i=R.current;if(!i)return;i.clearLayers(),j.current.clear();const{h}=S.current;for(const e of s??[]){const m=e.color||z,v=[[h-e.y,e.x],[h-(e.y+e.h),e.x+e.w]],u=p.rectangle(v,{className:"yo-region",color:m,weight:3,fillColor:m,fillOpacity:.25});if(e.title&&u.bindTooltip(e.title),e.ann){const x=e.ann,g=E=>{p.DomEvent.stop(E),N.current?.(x,{x:E.originalEvent.clientX,y:E.originalEvent.clientY})};u.on("click",g),u.on("contextmenu",g)}if(u.addTo(i),e.tags&&e.tags.length){const x=p.latLng(h-(e.y+e.h),e.x),g=p.divIcon({className:"yo-region-tags",html:re(e.tags),iconAnchor:[0,0]});p.marker(x,{icon:g,interactive:!1,keyboard:!1}).addTo(i)}e.id&&j.current.set(e.id,{rect:u,bounds:v})}},[T,L]),a.useEffect(()=>{const i=()=>{const h=l.current,e=decodeURIComponent(window.location.hash.slice(1)),m=e?j.current.get(e):void 0;!h||!m||(h.fitBounds(m.bounds,{maxZoom:h.getZoom(),padding:[40,40]}),m.rect.setStyle({weight:6,fillOpacity:.45}),window.setTimeout(()=>m.rect.setStyle({weight:3,fillOpacity:.25}),1e3))};return i(),window.addEventListener("hashchange",i),()=>window.removeEventListener("hashchange",i)},[T,L]),f.jsxs(f.Fragment,{children:[k&&f.jsxs("div",{className:"error",children:["image: ",k]}),f.jsx("div",{ref:d,className:o+(M?" yo-selectable":"")})]})}function fe({node:t}){const o=V(t.path),{openCreate:s,openEdit:n,palette:c,preview:r,color:w}=X(o,t.path),d=ae(o.annotations,t.path);if(r?.selector.type==="rect"){const l=r.selector;d.push({x:y(l.x),y:y(l.y),w:y(l.w),h:y(l.h),color:r.color})}return f.jsxs("div",{className:"text",children:[t.title&&f.jsx("h1",{className:"chapter-title",children:t.title}),t.description&&f.jsx("p",{className:"chapter-subtitle",children:t.description}),f.jsx(ce,{src:F(t.path),regions:d,onSelectRegion:(l,R,b)=>s(l,R,void 0,b),onRegionClick:n,selectColor:()=>w,className:"filemap fileimagemap"}),c]})}function le({src:t,path:o,onNavigate:s}){return f.jsx(ee,{path:o,onNavigate:s,title:"Open image on its own page",children:f.jsx("img",{className:"chunk-image",src:t,alt:"",loading:"lazy"})})}function he({chunk:t,onNavigate:o}){return f.jsx(le,{src:F(t.path),path:t.path,onNavigate:o})}export{he as ImageChunk,fe as ImageView,ce as PanZoomImage,le as StaticImageChunk};
1
+ import{j as f,r as a,D as z,i as q,k as K,b as F,u as V,a as X,f as Y,e as _,c as Q}from"./index-BVK9vlzr.js";import{O as ee,u as te,L as p,w as ne}from"./openable-BgRIW6s1.js";import{a as oe}from"./paged-CMePxwer.js";const y=t=>Number(t)||0,B=t=>t.replace(/[&<>"]/g,o=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;"})[o]);function re(t){return t.map(o=>{const s=q({name:o.label,color:o.color});return K(o.path)?`<span class="tagswatch" style="--tag:${s}" title="${B(o.label)}"></span>`:`<span class="tagtag" style="--tag:${s}">${B(o.label)}</span>`}).join("")}function se(t,o,s,n,c){if(!t||n<=0||c<=0)return;const r=document.createElement("canvas");r.width=n,r.height=c;const w=r.getContext("2d");if(w){w.drawImage(t,o,s,n,c,0,0,n,c);try{return r.toDataURL("image/png")}catch{return}}}function ae(t,o){const s=new Map;for(const n of t){if(n.selector?.type!=="rect")continue;const c=JSON.stringify(n.selector);let r=s.get(c);r||(r={x:y(n.selector.x),y:y(n.selector.y),w:y(n.selector.w),h:y(n.selector.h),title:n.description,color:Q(n),ann:_(n)?n:void 0,id:n.fragmentSlug?Y(o,n.fragmentSlug):void 0,tags:[]},s.set(c,r)),n.tag&&r.tags.push({path:n.tag.path,label:n.tag.name,color:n.tag.color})}return[...s.values()]}function ce({src:t,className:o,regions:s,onSelectRegion:n,onRegionClick:c,selectColor:r,fill:w=!0}){const d=a.useRef(null),l=a.useRef(null),R=a.useRef(null),b=a.useRef(null),S=a.useRef({w:1,h:1}),C=a.useRef(n),N=a.useRef(c),O=a.useRef(r),[k,I]=a.useState(null),[L,P]=a.useState(0),T=JSON.stringify(s??[]),M=!!n;oe(d,14,w),te(d,()=>l.current),a.useEffect(()=>{C.current=n,N.current=c,O.current=r}),a.useEffect(()=>{let i=!1,h=null;I(null);const e=new Image;return e.onload=()=>{if(i||!d.current)return;const m=e.naturalWidth||1,v=e.naturalHeight||1;S.current={w:m,h:v},b.current=e;const u=p.map(d.current,{crs:p.CRS.Simple,minZoom:-8,attributionControl:!1,zoomSnap:0}),x=[[0,0],[v,m]];p.imageOverlay(t,x).addTo(u),u.fitBounds(x),R.current=p.layerGroup().addTo(u),l.current=u,h=ne(u,{color:()=>O.current?.()??z,onSelect:M?(g,E)=>{const{h:G}=S.current,A=g.getWest(),J=g.getEast(),W=g.getSouth(),D=g.getNorth(),H=Math.round(A),U=Math.round(G-D),Z=Math.round(J-A),$=Math.round(D-W);C.current?.({type:"rect",x:H,y:U,w:Z,h:$},E,se(b.current,H,U,Z,$))}:void 0}),P(g=>g+1)},e.onerror=()=>{i||I("could not load image")},e.src=t,()=>{i=!0,h?.(),l.current?.remove(),l.current=null,R.current=null}},[t]);const j=a.useRef(new Map);return a.useEffect(()=>{const i=R.current;if(!i)return;i.clearLayers(),j.current.clear();const{h}=S.current;for(const e of s??[]){const m=e.color||z,v=[[h-e.y,e.x],[h-(e.y+e.h),e.x+e.w]],u=p.rectangle(v,{className:"yo-region",color:m,weight:3,fillColor:m,fillOpacity:.25});if(e.title&&u.bindTooltip(e.title),e.ann){const x=e.ann,g=E=>{p.DomEvent.stop(E),N.current?.(x,{x:E.originalEvent.clientX,y:E.originalEvent.clientY})};u.on("click",g),u.on("contextmenu",g)}if(u.addTo(i),e.tags&&e.tags.length){const x=p.latLng(h-(e.y+e.h),e.x),g=p.divIcon({className:"yo-region-tags",html:re(e.tags),iconAnchor:[0,0]});p.marker(x,{icon:g,interactive:!1,keyboard:!1}).addTo(i)}e.id&&j.current.set(e.id,{rect:u,bounds:v})}},[T,L]),a.useEffect(()=>{const i=()=>{const h=l.current,e=decodeURIComponent(window.location.hash.slice(1)),m=e?j.current.get(e):void 0;!h||!m||(h.fitBounds(m.bounds,{maxZoom:h.getZoom(),padding:[40,40]}),m.rect.setStyle({weight:6,fillOpacity:.45}),window.setTimeout(()=>m.rect.setStyle({weight:3,fillOpacity:.25}),1e3))};return i(),window.addEventListener("hashchange",i),()=>window.removeEventListener("hashchange",i)},[T,L]),f.jsxs(f.Fragment,{children:[k&&f.jsxs("div",{className:"error",children:["image: ",k]}),f.jsx("div",{ref:d,className:o+(M?" yo-selectable":"")})]})}function fe({node:t}){const o=V(t.path),{openCreate:s,openEdit:n,palette:c,preview:r,color:w}=X(o,t.path),d=ae(o.annotations,t.path);if(r?.selector.type==="rect"){const l=r.selector;d.push({x:y(l.x),y:y(l.y),w:y(l.w),h:y(l.h),color:r.color})}return f.jsxs("div",{className:"text",children:[t.title&&f.jsx("h1",{className:"chapter-title",children:t.title}),t.description&&f.jsx("p",{className:"chapter-subtitle",children:t.description}),f.jsx(ce,{src:F(t.path),regions:d,onSelectRegion:(l,R,b)=>s(l,R,void 0,b),onRegionClick:n,selectColor:()=>w,className:"filemap fileimagemap"}),c]})}function le({src:t,path:o,onNavigate:s}){return f.jsx(ee,{path:o,onNavigate:s,title:"Open image on its own page",children:f.jsx("img",{className:"chunk-image",src:t,alt:"",loading:"lazy"})})}function he({chunk:t,onNavigate:o}){return f.jsx(le,{src:F(t.path),path:t.path,onNavigate:o})}export{he as ImageChunk,fe as ImageView,ce as PanZoomImage,le as StaticImageChunk};