@qwanyx/stack 0.2.79 → 0.2.80
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/dist/index.cjs.js +1 -1
- package/dist/index.esm.js +7 -1
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -182,7 +182,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
182
182
|
}
|
|
183
183
|
`})]})}const Dg={background:"#ffffff",text:"#111827",textSecondary:"#6b7280",border:"#e5e7eb",primary:"#3b82f6",chipBackground:"#f3f4f6",chipText:"#374151",hoverBackground:"#f9fafb"};function Ag({options:r,value:e,onChange:t,placeholder:n="Search or select...",allowCreate:s=!0,onCreate:i,allowDelete:o=!1,onDelete:l,label:a,disabled:u=!1,max:c=0,theme:d={},className:f=""}){const p={...Dg,...d},[g,m]=b.useState(!1),[x,_]=b.useState(""),y=b.useRef(null),v=b.useRef(null);b.useEffect(()=>{function N(M){y.current&&!y.current.contains(M.target)&&(m(!1),_(""))}return document.addEventListener("mousedown",N),()=>document.removeEventListener("mousedown",N)},[]);const S=r.filter(N=>{var M;return((M=N.label)==null?void 0:M.toLowerCase().includes(x.toLowerCase()))&&!e.includes(N.id)}),D=s&&x.trim()&&!r.some(N=>{var M;return((M=N.label)==null?void 0:M.toLowerCase())===x.toLowerCase()}),C=e.map(N=>r.find(M=>M.id===N)).filter(Boolean),w=b.useCallback(N=>{var M;c>0&&e.length>=c||(t([...e,N]),_(""),c===1?m(!1):(M=v.current)==null||M.focus())},[e,t,c]),E=b.useCallback(N=>{t(e.filter(M=>M!==N))},[e,t]),R=b.useCallback(async()=>{if(!D)return;const N=await(i==null?void 0:i(x.trim()));N&&w(N.id),_("")},[D,x,i,w]),T=b.useCallback(N=>{N.key==="Enter"?(N.preventDefault(),D?R():S.length>0&&w(S[0].id)):N.key==="Backspace"&&!x&&e.length>0?E(e[e.length-1]):N.key==="Escape"&&(m(!1),_(""))},[D,S,x,e,R,w,E]);return h.jsxs("div",{ref:y,className:f,style:{position:"relative"},children:[a&&h.jsx("label",{style:{display:"block",fontSize:"12px",textTransform:"uppercase",color:p.textSecondary,marginBottom:"4px"},children:a}),h.jsxs("div",{onClick:()=>!u&&m(!0),style:{display:"flex",flexWrap:"wrap",gap:"6px",padding:"8px 12px",border:`1px solid ${g?p.primary:p.border}`,borderRadius:"8px",background:u?p.hoverBackground:p.background,cursor:u?"not-allowed":"text",minHeight:"42px",alignItems:"center"},children:[C.map(N=>h.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"2px 8px",borderRadius:"4px",fontSize:"13px",background:N.color||p.chipBackground,color:N.color?"#fff":p.chipText},children:[N.label,!u&&h.jsx("button",{type:"button",onClick:M=>{M.stopPropagation(),E(N.id)},style:{border:"none",background:"transparent",cursor:"pointer",padding:"0 2px",fontSize:"14px",color:"inherit",opacity:.7},children:"×"})]},N.id)),h.jsx("input",{ref:v,type:"text",value:x,onChange:N=>{_(N.target.value),g||m(!0)},onFocus:()=>m(!0),onKeyDown:T,placeholder:C.length===0?n:"",disabled:u||c>0&&e.length>=c,style:{flex:1,minWidth:"60px",border:"none",outline:"none",fontSize:"14px",background:"transparent",color:p.text}})]}),g&&!u&&h.jsx("div",{style:{position:"absolute",top:"100%",left:0,right:0,marginTop:"4px",background:p.background,border:`1px solid ${p.border}`,borderRadius:"8px",boxShadow:"0 4px 12px rgba(0,0,0,0.1)",maxHeight:"200px",overflowY:"auto",zIndex:50},children:S.length===0&&!D?h.jsx("div",{style:{padding:"12px",fontSize:"14px",color:p.textSecondary,textAlign:"center"},children:x?"No matches":"No options available"}):h.jsxs(h.Fragment,{children:[S.map(N=>h.jsxs("div",{onClick:()=>w(N.id),style:{padding:"10px 12px",fontSize:"14px",cursor:"pointer",color:p.text,display:"flex",alignItems:"center",justifyContent:"space-between"},onMouseEnter:M=>{M.currentTarget.style.background=p.hoverBackground||""},onMouseLeave:M=>{M.currentTarget.style.background=""},children:[N.label,o&&l&&h.jsx("button",{type:"button",onClick:M=>{M.stopPropagation(),l(N.id)},style:{border:"none",background:"transparent",cursor:"pointer",padding:"2px",fontSize:"14px",color:p.textSecondary,opacity:.5},onMouseEnter:M=>{M.currentTarget.style.opacity="1",M.currentTarget.style.color="#ef4444"},onMouseLeave:M=>{M.currentTarget.style.opacity="0.5",M.currentTarget.style.color=p.textSecondary||""},children:"×"})]},N.id)),D&&h.jsxs("div",{onClick:R,style:{padding:"10px 12px",fontSize:"14px",cursor:"pointer",color:p.primary,borderTop:S.length>0?`1px solid ${p.border}`:"none"},onMouseEnter:N=>{N.currentTarget.style.background=p.hoverBackground||""},onMouseLeave:N=>{N.currentTarget.style.background=""},children:['+ Create "',x.trim(),'"']})]})})]})}const Tg={background:"#ffffff",cardBackground:"#f9fafb",cardHover:"#f3f4f6",text:"#111827",textSecondary:"#6b7280",border:"#e5e7eb",primary:"#3b82f6"};function Ng({options:r,value:e,type:t,placeholder:n="Search...",onItemClick:s,onClear:i,onCreate:o,maxHeight:l=300,className:a="",theme:u={}}){const c={...Tg,...u},[d,f]=b.useState(""),[p,g]=b.useState(!1),m=b.useRef(null),x=b.useRef(null),_=b.useMemo(()=>e&&r.find(E=>E.id===e)||null,[e,r]),y=b.useMemo(()=>{if(!d.trim())return r;const E=d.toLowerCase();return r.filter(R=>{var T,N;return((T=R.label)==null?void 0:T.toLowerCase().includes(E))||((N=R.notes)==null?void 0:N.toLowerCase().includes(E))})},[r,d]);b.useEffect(()=>{const E=R=>{m.current&&!m.current.contains(R.target)&&g(!1)};return document.addEventListener("mousedown",E),()=>document.removeEventListener("mousedown",E)},[]);const v=E=>{s&&s(E),g(!1),f("")},S=()=>{o&&o(d.trim()||void 0),g(!1),f("")},D=()=>{g(!0)},C=E=>{f(E.target.value),p||g(!0)},w=E=>{E.key==="Enter"?(E.preventDefault(),y.length>0&&s?(s(y[0]),g(!1),f("")):o&&d.trim()&&(o(d.trim()),g(!1),f(""))):E.key==="Escape"&&(g(!1),f(""))};return h.jsxs("div",{ref:m,className:`combostack ${a}`,style:{position:"relative",width:"100%"},children:[h.jsxs("div",{style:{display:"flex",gap:"8px"},children:[h.jsx("div",{style:{flex:1,position:"relative"},children:_&&!p?h.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"6px 10px",fontSize:"14px",border:`1px solid ${c.border}`,borderRadius:"6px",background:c.cardBackground,color:c.text,cursor:"pointer",minHeight:"36px",boxSizing:"border-box"},onClick:()=>g(!0),children:[h.jsxs("div",{style:{overflow:"hidden"},children:[h.jsx("div",{style:{fontWeight:500,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:_.label}),_.notes&&h.jsx("div",{style:{fontSize:"11px",color:c.textSecondary,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:_.notes})]}),i&&h.jsx("button",{onClick:E=>{E.stopPropagation(),i()},style:{marginLeft:"8px",padding:"2px",background:"none",border:"none",cursor:"pointer",color:c.textSecondary,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"50%",flexShrink:0},title:"Clear selection",children:h.jsx("span",{className:"material-icons",style:{fontSize:"16px"},children:"close"})})]}):h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"material-icons",style:{position:"absolute",left:"10px",top:"50%",transform:"translateY(-50%)",color:c.textSecondary,fontSize:"18px",pointerEvents:"none"},children:"search"}),h.jsx("input",{ref:x,type:"text",value:d,onChange:C,onFocus:D,onKeyDown:w,placeholder:n,style:{width:"100%",padding:"8px 12px 8px 36px",fontSize:"14px",border:`1px solid ${p?c.primary:c.border}`,borderRadius:"6px",background:c.background,color:c.text,outline:"none",boxSizing:"border-box",transition:"border-color 0.15s"}})]})}),o&&h.jsx("button",{onClick:S,style:{width:"36px",height:"36px",display:"flex",alignItems:"center",justifyContent:"center",border:`1px solid ${c.border}`,borderRadius:"6px",background:c.background,color:c.primary,cursor:"pointer",fontSize:"18px",fontWeight:"bold",transition:"background 0.15s",flexShrink:0},onMouseEnter:E=>{E.currentTarget.style.background=c.cardHover||"#f3f4f6"},onMouseLeave:E=>{E.currentTarget.style.background=c.background||"#ffffff"},title:`Create ${t||"item"}`,children:"+"})]}),p&&h.jsx("div",{style:{position:"absolute",top:"100%",left:0,right:0,marginTop:"4px",maxHeight:typeof l=="number"?`${l}px`:l,overflowY:"auto",border:`1px solid ${c.border}`,borderRadius:"8px",background:c.background,boxShadow:"0 4px 12px rgba(0, 0, 0, 0.15)",zIndex:50},children:y.length===0?h.jsx("div",{style:{padding:"16px",textAlign:"center",color:c.textSecondary,fontSize:"14px"},children:d?`No results for "${d}"`:"No items"}):y.map((E,R)=>h.jsxs("div",{onClick:()=>v(E),style:{padding:"10px 14px",cursor:"pointer",borderBottom:R<y.length-1?`1px solid ${c.border}`:"none",background:c.cardBackground,transition:"background 0.15s"},onMouseEnter:T=>{T.currentTarget.style.background=c.cardHover||"#f3f4f6"},onMouseLeave:T=>{T.currentTarget.style.background=c.cardBackground||"#f9fafb"},children:[h.jsx("div",{style:{fontSize:"14px",fontWeight:500,color:E.color||c.text,marginBottom:E.notes?"2px":0},children:E.label}),E.notes&&h.jsx("div",{style:{fontSize:"12px",color:c.textSecondary,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:E.notes})]},E.id))})]})}function Bg({items:r,columns:e,getItemId:t,getItemColumn:n,getItemOrder:s,renderItem:i,onItemMove:o,onItemReorder:l,onItemClick:a,renderColumnHeader:u,renderColumnFooter:c,className:d="",columnClassName:f="",itemClassName:p=""}){const[g,m]=b.useState(null),[x,_]=b.useState(null),[y,v]=b.useState(null),S=b.useRef(null),D=e.reduce((M,j)=>{let k=r.filter(B=>n(B)===j.id);return s&&(k=k.sort((B,F)=>s(B)-s(F))),M[j.id]=k,M},{}),C=b.useCallback((M,j)=>{const k=t(j),B=n(j);m(k),S.current=B,M.dataTransfer.effectAllowed="move",M.dataTransfer.setData("text/plain",k),requestAnimationFrame(()=>{const F=M.target;F.style.opacity="0.5"})},[t,n]),w=b.useCallback(M=>{const j=M.target;j.style.opacity="1",m(null),_(null),v(null),S.current=null},[]),E=b.useCallback((M,j,k)=>{M.preventDefault(),M.dataTransfer.dropEffect="move",_(j),v(k)},[]),R=b.useCallback(M=>{const j=M.relatedTarget;j!=null&&j.closest("[data-kanban-column]")||(_(null),v(null))},[]),T=b.useCallback((M,j,k)=>{if(M.preventDefault(),!g)return;const B=S.current;B===j?l==null||l(g,j,k):B&&o(g,B,j,k),m(null),_(null),v(null),S.current=null},[g,o,l]),N=(M,j)=>h.jsxs("div",{className:"flex items-center justify-between px-3 py-2",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[M.color&&h.jsx("div",{className:"w-2 h-2 rounded-full",style:{backgroundColor:M.color}}),h.jsx("span",{className:"font-medium text-sm text-neutral-700",children:M.label})]}),h.jsx("span",{className:"text-xs text-neutral-400 bg-neutral-100 px-2 py-0.5 rounded-full",children:j})]});return h.jsx("div",{className:`flex gap-4 overflow-x-auto pb-4 ${d}`,style:{minHeight:"400px"},children:e.map(M=>{const j=D[M.id]||[],k=x===M.id;return h.jsxs("div",{"data-kanban-column":M.id,className:`flex-1 min-w-[180px] bg-neutral-50 rounded-xl flex flex-col ${f}`,onDragOver:B=>{B.preventDefault(),g&&!k&&_(M.id)},onDragLeave:R,onDrop:B=>T(B,M.id,y??j.length),children:[h.jsx("div",{className:"flex-shrink-0 border-b border-neutral-200",children:u?u(M,j.length):N(M,j.length)}),h.jsxs("div",{className:`flex-1 overflow-y-auto p-2 space-y-2 min-h-[100px] transition-colors ${k?"bg-blue-50":""}`,children:[j.map((B,F)=>{const O=t(B),V=g===O,U=k&&y===F&&!V;return h.jsxs("div",{children:[U&&h.jsx("div",{className:"h-1 bg-blue-500 rounded-full mb-2 mx-1"}),h.jsx("div",{draggable:!0,onDragStart:te=>C(te,B),onDragEnd:w,onDragOver:te=>E(te,M.id,F),onClick:()=>a==null?void 0:a(B),className:`cursor-grab active:cursor-grabbing transition-all ${V?"opacity-50 scale-95":""} ${p}`,children:i(B,V)})]},O)}),h.jsx("div",{className:"min-h-[40px] flex-1",onDragOver:B=>{B.preventDefault(),E(B,M.id,j.length)},children:k&&y===j.length&&h.jsx("div",{className:"h-1 bg-blue-500 rounded-full mx-1 mt-1"})}),j.length===0&&k&&h.jsx("div",{className:"h-20 border-2 border-dashed border-blue-300 rounded-lg bg-blue-50/50 flex items-center justify-center",children:h.jsx("span",{className:"text-sm text-blue-400",children:"Drop here"})})]}),c&&h.jsx("div",{className:"flex-shrink-0 border-t border-neutral-200 p-2",children:c(M)})]},M.id)})})}const Rg={background:"#ffffff",hourLineColor:"#e5e7eb",halfHourLineColor:"#f3f4f6",hourTextColor:"#9ca3af",currentTimeColor:"#ef4444",allDayBackground:"#f9fafb",allDayBorder:"#e5e7eb"};function Mg(r){const e=r.match(/^(\d{1,2}):(\d{2})$/);return e?{hours:parseInt(e[1],10),minutes:parseInt(e[2],10)}:null}function Fg(r){const e=r%12||12,t=r<12?"AM":"PM";return`${e} ${t}`}function jg(r){const e=new Date;return r.getDate()===e.getDate()&&r.getMonth()===e.getMonth()&&r.getFullYear()===e.getFullYear()}function Lg({items:r,date:e,startHour:t=7,endHour:n=22,hourHeight:s=60,getItemTime:i,getItemDuration:o,getItemIsAllDay:l,getItemId:a,renderItem:u,onItemClick:c,onTimeSlotClick:d,showCurrentTime:f=!0,className:p="",theme:g={}}){const m={...Rg,...g},{allDayItems:x,timedItems:_}=b.useMemo(()=>{const w=[],E=[];for(const R of r)l(R)?w.push(R):E.push(R);return{allDayItems:w,timedItems:E}},[r,l]),y=b.useMemo(()=>{const w=[];for(let E=t;E<=n;E++)w.push(E);return w},[t,n]),v=(n-t+1)*s,S=b.useCallback(w=>{const E=i(w);if(!E)return null;const R=Mg(E);if(!R)return null;const{hours:T,minutes:N}=R,M=Math.max(t,Math.min(n,T)),j=T<t?0:N,k=(M-t)*s+j/60*s,B=o(w),F=Math.max(20,B/60*s);return{top:k,height:F}},[i,o,t,n,s]),D=b.useMemo(()=>{if(!f||!jg(e))return null;const w=new Date,E=w.getHours(),R=w.getMinutes();return E<t||E>n?null:(E-t)*s+R/60*s},[e,f,t,n,s]),C=b.useCallback(w=>{if(!d)return;const E=w.currentTarget.getBoundingClientRect(),T=(w.clientY-E.top)/s*60,N=Math.floor(T/60)+t,M=Math.round(T%60/15)*15,j=Math.min(n,Math.max(t,N)),k=M>=60?0:M,B=`${j.toString().padStart(2,"0")}:${k.toString().padStart(2,"0")}`;d(B)},[d,s,t,n]);return h.jsxs("div",{className:p,style:{background:m.background},children:[x.length>0&&h.jsxs("div",{style:{padding:"8px 0 8px 60px",borderBottom:`1px solid ${m.allDayBorder}`,background:m.allDayBackground},children:[h.jsx("div",{style:{fontSize:"11px",color:m.hourTextColor,marginBottom:"4px",textTransform:"uppercase",letterSpacing:"0.05em"},children:"All Day"}),h.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"4px"},children:x.map(w=>h.jsx("div",{onClick:()=>c==null?void 0:c(w),style:{cursor:c?"pointer":"default"},children:u(w)},a(w)))})]}),h.jsxs("div",{style:{position:"relative",height:v},children:[y.map((w,E)=>h.jsxs("div",{style:{position:"absolute",top:E*s,left:0,right:0},children:[h.jsx("div",{style:{position:"absolute",left:0,top:-8,width:"50px",textAlign:"right",paddingRight:"10px",fontSize:"11px",color:m.hourTextColor},children:Fg(w)}),h.jsx("div",{style:{position:"absolute",left:"60px",right:0,top:0,height:"1px",background:m.hourLineColor}}),E<y.length-1&&h.jsx("div",{style:{position:"absolute",left:"60px",right:0,top:s/2,height:"1px",background:m.halfHourLineColor}})]},w)),h.jsx("div",{style:{position:"absolute",left:"60px",right:0,top:0,bottom:0,cursor:d?"pointer":"default"},onClick:C}),D!==null&&h.jsxs("div",{style:{position:"absolute",left:"55px",right:0,top:D,zIndex:20,pointerEvents:"none"},children:[h.jsx("div",{style:{width:"10px",height:"10px",borderRadius:"50%",background:m.currentTimeColor,marginLeft:"-5px",marginTop:"-5px",position:"absolute"}}),h.jsx("div",{style:{marginLeft:"5px",height:"2px",background:m.currentTimeColor}})]}),_.map(w=>{const E=S(w);return E?h.jsx("div",{style:{position:"absolute",left:"64px",right:"8px",top:E.top,height:E.height,zIndex:10,cursor:c?"pointer":"default"},onClick:R=>{R.stopPropagation(),c==null||c(w)},children:u(w)},a(w)):null})]})]})}function Vc({onComplete:r,onCancel:e,onTranscribe:t,onTranscriptionComplete:n,variant:s="widget",hideSaveButton:i=!1,maxDuration:o=180}){const l=s==="widget",[a,u]=b.useState("idle"),[c,d]=b.useState(0),[f,p]=b.useState(0),[g,m]=b.useState(!1),[x,_]=b.useState(0),[y,v]=b.useState(null),[S,D]=b.useState(!1),[C,w]=b.useState(null),[E,R]=b.useState(!0),[T,N]=b.useState([]),[M,j]=b.useState({completed:0,total:0}),k=b.useRef(!1),B=b.useRef(!0);b.useEffect(()=>{B.current=E},[E]);const F=b.useRef(null),O=b.useRef(null),V=b.useRef(null),U=b.useRef(null),te=b.useRef(null),q=b.useRef([]),X=b.useRef(null),W=b.useRef(null),se=b.useRef(null),ue=b.useRef(null),de=b.useRef(!1),pe=b.useRef([]),De=b.useRef(null),xe=b.useRef(null),J=b.useRef([]),Ce=b.useRef([]),ne=b.useRef("insert"),Be=b.useRef(!1),Se=b.useRef(0),ke=b.useRef(0),Ie=b.useRef(0),Le=Z=>{const L=Math.floor(Z/60),le=Math.floor(Z%60);return`${L.toString().padStart(2,"0")}:${le.toString().padStart(2,"0")}`},$e=async Z=>{const L=await Z.arrayBuffer(),le=new AudioContext,fe=await le.decodeAudioData(L);return await le.close(),fe},Y=Z=>{const L=Z.numberOfChannels,le=Z.sampleRate,fe=1,G=16,we=G/8,be=L*we,_e=le*be,Fe=Z.length*be,qe=new ArrayBuffer(44+Fe),ve=new DataView(qe),Ee=(Ve,Oe)=>{for(let ut=0;ut<Oe.length;ut++)ve.setUint8(Ve+ut,Oe.charCodeAt(ut))};Ee(0,"RIFF"),ve.setUint32(4,36+Fe,!0),Ee(8,"WAVE"),Ee(12,"fmt "),ve.setUint32(16,16,!0),ve.setUint16(20,fe,!0),ve.setUint16(22,L,!0),ve.setUint32(24,le,!0),ve.setUint32(28,_e,!0),ve.setUint16(32,be,!0),ve.setUint16(34,G,!0),Ee(36,"data"),ve.setUint32(40,Fe,!0);const et=[];for(let Ve=0;Ve<L;Ve++)et.push(Z.getChannelData(Ve));let nt=44;for(let Ve=0;Ve<Z.length;Ve++)for(let Oe=0;Oe<L;Oe++){const ut=Math.max(-1,Math.min(1,et[Oe][Ve])),ct=ut<0?ut*32768:ut*32767;ve.setInt16(nt,ct,!0),nt+=2}return new Blob([qe],{type:"audio/wav"})},P=async(Z,L,le,fe)=>{const G=new AudioContext,we=Z.sampleRate,be=Math.max(Z.numberOfChannels,L.numberOfChannels),_e=Math.min(le,Z.length),Fe=Math.max(0,Z.length-le),qe=fe==="insert"?_e+L.length+Fe:_e+L.length,ve=G.createBuffer(be,qe,we);for(let Ee=0;Ee<be;Ee++){const et=ve.getChannelData(Ee),nt=Ee<Z.numberOfChannels?Z.getChannelData(Ee):Z.getChannelData(0);for(let Oe=0;Oe<_e;Oe++)et[Oe]=nt[Oe];const Ve=Ee<L.numberOfChannels?L.getChannelData(Ee):L.getChannelData(0);for(let Oe=0;Oe<L.length;Oe++)et[_e+Oe]=Ve[Oe];if(fe==="insert")for(let Oe=0;Oe<Fe;Oe++)et[_e+L.length+Oe]=nt[le+Oe]}return await G.close(),ve},me=b.useCallback(()=>{const Z=F.current;if(!Z)return;const L=Z.getContext("2d");if(!L)return;const le=Z.getBoundingClientRect(),fe=le.width,G=le.height,we=pe.current,be=f||c||1,_e=a==="recording"?c:x;L.fillStyle="#2d3b35",L.fillRect(0,0,fe,G);const Fe=8,qe="rgba(0, 0, 0, 0.4)",ve=L.createLinearGradient(0,0,0,Fe);ve.addColorStop(0,qe),ve.addColorStop(1,"transparent"),L.fillStyle=ve,L.fillRect(0,0,fe,Fe);const Ee=L.createLinearGradient(0,G-Fe,0,G);Ee.addColorStop(0,"transparent"),Ee.addColorStop(1,qe),L.fillStyle=Ee,L.fillRect(0,G-Fe,fe,Fe);const et=L.createLinearGradient(0,0,Fe,0);et.addColorStop(0,qe),et.addColorStop(1,"transparent"),L.fillStyle=et,L.fillRect(0,0,Fe,G);const nt=L.createLinearGradient(fe-Fe,0,fe,0);nt.addColorStop(0,"transparent"),nt.addColorStop(1,qe),L.fillStyle=nt,L.fillRect(fe-Fe,0,Fe,G),L.strokeStyle="#5a6b62",L.lineWidth=1,L.beginPath(),L.moveTo(0,G/2),L.lineTo(fe,G/2),L.stroke();const Ve=fe/2;if(we.length>0)if(a==="recording")for(let ct=0;ct<we.length;ct++){const At=we.length-1-ct,Zt=Ve-At*4;if(Zt<-3||Zt>fe)continue;const Rt=we[ct]*(G/2-12),A=G/2-Rt;L.fillStyle="#10b981",L.fillRect(Zt,A,3,Rt*2)}else{const ct=be>0?_e/be*we.length:0;for(let At=0;At<we.length;At++){const Zt=ct-At,Rt=Ve-Zt*4;if(Rt<-3||Rt>fe)continue;const A=we[At]*(G/2-12),$=G/2-A;L.fillStyle=At<=ct?"#10b981":"#4b5563",L.fillRect(Rt,$,3,A*2)}}L.strokeStyle="#ef4444",L.lineWidth=1,L.beginPath(),L.moveTo(Ve,0),L.lineTo(Ve,G),L.stroke(),L.fillStyle="#fff",L.font="bold 18px monospace",L.textAlign="center",L.fillText(Le(_e),Ve,G-6),a==="recording"&&(L.fillStyle="#ef4444",L.beginPath(),L.arc(20,20,8,0,Math.PI*2),L.fill(),L.fillStyle="#fff",L.font="10px sans-serif",L.textAlign="left",L.fillText("REC",34,24)),L.textAlign="left"},[a,x,c,f]),We=()=>{const Z=te.current;if(!Z||!de.current)return;const L=Z.frequencyBinCount,le=new Uint8Array(L);Z.getByteTimeDomainData(le);let fe=0;for(let be=0;be<L;be++){const _e=(le[be]-128)/128;fe+=_e*_e}const G=Math.sqrt(fe/L),we=Math.min(1,G*3);pe.current.push(we),me(),de.current&&(W.current=requestAnimationFrame(We))},z=async()=>{try{v(null),D(!1),De.current===null&&(pe.current=[]);const Z=await navigator.mediaDevices.getUserMedia({audio:!0});V.current=Z;const L=new AudioContext;U.current=L;const le=L.createAnalyser();le.fftSize=2048,te.current=le,L.createMediaStreamSource(Z).connect(le);const G=new MediaRecorder(Z);O.current=G,q.current=[],G.ondataavailable=we=>{we.data.size>0&&q.current.push(we.data)},G.onstop=async()=>{try{if(de.current=!1,q.current.length===0){v("No audio was recorded. Please try again."),u("idle"),Z.getTracks().forEach(ve=>ve.stop());return}const we=new Blob(q.current,{type:"audio/webm"});let be,_e;if(De.current!==null&&xe.current)try{const ve=await $e(we),Ee=xe.current.sampleRate,et=Math.floor(De.current*Ee),nt=await P(xe.current,ve,et,ne.current);be=Y(nt),_e=nt.length/nt.sampleRate,ne.current==="insert"&&(pe.current=[...pe.current,...Ce.current]),De.current=null,xe.current=null,J.current=[],Ce.current=[]}catch{be=we,_e=Se.current>0?Se.current:1}else be=we,_e=Se.current>0?Se.current:1;if(ue.current=be,Z.getTracks().forEach(ve=>ve.stop()),B.current&&t){N(ve=>[...ve,be]),j(ve=>({...ve,total:ve.total+1})),ue.current=null,pe.current=[],_(0),p(0),d(0),u("idle");return}const Fe=URL.createObjectURL(be),qe=new Audio(Fe);qe.ontimeupdate=()=>{_(qe.currentTime)},qe.onended=()=>{m(!1)},se.current=qe,p(_e),_(_e),u("editing")}catch{v("Failed to process recording"),u("idle")}},G.start(100),de.current=!0,u("recording"),d(0),Se.current=0,X.current=setInterval(()=>{Se.current+=1,d(Se.current),Se.current>=o&&(O.current&&O.current.state!=="inactive"&&O.current.stop(),de.current=!1,w(null),X.current&&(clearInterval(X.current),X.current=null),W.current&&(cancelAnimationFrame(W.current),W.current=null),setTimeout(()=>{alert(`Maximum recording time of ${Math.floor(o/60)} minutes reached.`)},100))},1e3)}catch{v("Could not access microphone. Please allow microphone access.")}},ae=()=>{de.current=!1,D(!1),w(null),W.current&&(cancelAnimationFrame(W.current),W.current=null),X.current&&(clearInterval(X.current),X.current=null),O.current&&O.current.state!=="inactive"&&O.current.stop()},ge=Z=>{const L=F.current;if(!L)return;const le=f||c;if(le<=0)return;const fe=pe.current;if(fe.length===0)return;const G=L.getBoundingClientRect(),we=Z-ke.current,be=4,_e=G.width/L.width,Fe=fe.length/le*be,qe=-we/(Fe*_e),ve=Ie.current+qe,Ee=Math.max(0,Math.min(ve,le));se.current&&(se.current.currentTime=Ee),_(Ee)},ye=()=>{se.current&&(se.current.currentTime=0),_(0)},Ue=()=>{const Z=f||c;se.current&&(se.current.currentTime=Z),_(Z)},mt=()=>{const Z=se.current;Z&&(g?(Z.pause(),_(Z.currentTime),m(!1)):(Z.currentTime=x,Z.play().catch(()=>{}),m(!0)))},yt=async Z=>{if(!ue.current){z();return}try{se.current&&(se.current.pause(),m(!1)),ne.current=Z,xe.current=await $e(ue.current);const L=f||c;De.current=x;const le=L>0?x/L:0,fe=Math.floor(le*pe.current.length);J.current=pe.current.slice(0,fe),Ce.current=pe.current.slice(fe),pe.current=[...J.current],z()}catch{v("Failed to prepare recording. Please try again.")}},ie=()=>{se.current&&(se.current.pause(),se.current=null),ue.current=null,xe.current=null,De.current=null,J.current=[],m(!1),_(0),p(0),d(0),z()},ce=()=>{ue.current?r(ue.current,f||c):alert("No audio recorded yet!")};b.useEffect(()=>{a==="recording"&&F.current&&te.current&&de.current&&(W.current=requestAnimationFrame(We))},[a]),b.useEffect(()=>{const Z=F.current;if(!Z)return;const L=()=>{const le=window.devicePixelRatio||1,fe=Z.getBoundingClientRect();Z.width=fe.width*le,Z.height=fe.height*le;const G=Z.getContext("2d");G&&G.scale(le,le)};return L(),window.addEventListener("resize",L),()=>window.removeEventListener("resize",L)},[]),b.useEffect(()=>{if(a==="idle"){const Z=F.current;if(!Z)return;const L=Z.getContext("2d");if(!L)return;const le=Z.getBoundingClientRect(),fe=le.width,G=le.height;L.fillStyle="#2d3b35",L.fillRect(0,0,fe,G);const we=8,be="rgba(0, 0, 0, 0.4)",_e=L.createLinearGradient(0,0,0,we);_e.addColorStop(0,be),_e.addColorStop(1,"transparent"),L.fillStyle=_e,L.fillRect(0,0,fe,we);const Fe=L.createLinearGradient(0,G-we,0,G);Fe.addColorStop(0,"transparent"),Fe.addColorStop(1,be),L.fillStyle=Fe,L.fillRect(0,G-we,fe,we);const qe=L.createLinearGradient(0,0,we,0);qe.addColorStop(0,be),qe.addColorStop(1,"transparent"),L.fillStyle=qe,L.fillRect(0,0,we,G);const ve=L.createLinearGradient(fe-we,0,fe,0);ve.addColorStop(0,"transparent"),ve.addColorStop(1,be),L.fillStyle=ve,L.fillRect(fe-we,0,we,G),L.strokeStyle="#5a6b62",L.lineWidth=1,L.beginPath(),L.moveTo(0,G/2),L.lineTo(fe,G/2),L.stroke();const Ee=fe/2;L.strokeStyle="#ef4444",L.lineWidth=1,L.beginPath(),L.moveTo(Ee,0),L.lineTo(Ee,G),L.stroke(),L.fillStyle="#fff",L.font="bold 18px monospace",L.textAlign="center",L.fillText("00:00",Ee,G-6)}},[a]);const He=b.useCallback(Z=>{N(L=>[...L,Z]),j(L=>({...L,total:L.total+1}))},[]);if(b.useEffect(()=>{(async()=>{if(k.current||T.length===0||!t)return;k.current=!0;const L=T[0];try{const le=await t(L);le&&n&&n(le)}catch(le){console.error("Transcription failed:",le)}finally{N(le=>le.slice(1)),j(le=>({...le,completed:le.completed+1})),k.current=!1}})()},[T,t,n]),b.useEffect(()=>()=>{de.current=!1,X.current&&clearInterval(X.current),W.current&&cancelAnimationFrame(W.current),V.current&&V.current.getTracks().forEach(Z=>Z.stop()),U.current&&U.current.state!=="closed"&&U.current.close()},[]),b.useEffect(()=>{if(a==="editing"&&g){let Z;const L=()=>{const le=se.current;if(le&&g){const fe=F.current;if(fe){const G=fe.getContext("2d");if(G){const we=fe.getBoundingClientRect(),be=we.width,_e=we.height,Fe=pe.current,qe=f||c||1,ve=le.currentTime;G.fillStyle="#2d3b35",G.fillRect(0,0,be,_e);const Ee=8,et="rgba(0, 0, 0, 0.4)",nt=G.createLinearGradient(0,0,0,Ee);nt.addColorStop(0,et),nt.addColorStop(1,"transparent"),G.fillStyle=nt,G.fillRect(0,0,be,Ee);const Ve=G.createLinearGradient(0,_e-Ee,0,_e);Ve.addColorStop(0,"transparent"),Ve.addColorStop(1,et),G.fillStyle=Ve,G.fillRect(0,_e-Ee,be,Ee);const Oe=G.createLinearGradient(0,0,Ee,0);Oe.addColorStop(0,et),Oe.addColorStop(1,"transparent"),G.fillStyle=Oe,G.fillRect(0,0,Ee,_e);const ut=G.createLinearGradient(be-Ee,0,be,0);ut.addColorStop(0,"transparent"),ut.addColorStop(1,et),G.fillStyle=ut,G.fillRect(be-Ee,0,Ee,_e),G.strokeStyle="#5a6b62",G.lineWidth=1,G.beginPath(),G.moveTo(0,_e/2),G.lineTo(be,_e/2),G.stroke();const ct=be/2,At=3,Zt=4,Rt=qe>0?ve/qe*Fe.length:0;for(let ee=0;ee<Fe.length;ee++){const he=Rt-ee,Re=ct-he*Zt;if(Re<-At||Re>be)continue;const Pe=Fe[ee]*(_e/2-12),Te=_e/2-Pe;G.fillStyle=ee<=Rt?"#10b981":"#4b5563",G.fillRect(Re,Te,At,Pe*2)}G.strokeStyle="#ef4444",G.lineWidth=1,G.beginPath(),G.moveTo(ct,0),G.lineTo(ct,_e),G.stroke(),G.fillStyle="#fff",G.font="bold 18px monospace",G.textAlign="center";const A=Math.floor(ve/60),$=Math.floor(ve%60);G.fillText(`${A.toString().padStart(2,"0")}:${$.toString().padStart(2,"0")}`,ct,_e-6),G.textAlign="left"}}Z=requestAnimationFrame(L)}};return Z=requestAnimationFrame(L),()=>cancelAnimationFrame(Z)}},[a,g,f,c]),b.useEffect(()=>{a==="editing"&&!g&&me()},[a,x,g,me]),y)return h.jsxs("div",{style:{border:"1px solid #fecaca",borderRadius:"12px",padding:"16px",background:"#fef2f2"},children:[h.jsx("p",{style:{fontSize:"14px",color:"#dc2626",marginBottom:"12px"},children:y}),h.jsx("button",{onClick:()=>{v(null),z()},style:{padding:"8px 16px",fontSize:"14px",background:"#171717",color:"white",borderRadius:"8px",border:"none",cursor:"pointer"},children:"Try Again"})]});const Xe={padding:"8px",borderRadius:"8px",border:"none",background:"transparent",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",transition:"background 0.15s"},Je={...Xe,opacity:.3,cursor:"not-allowed"},Bt=l?{border:"1px solid #e5e5e5",borderRadius:"12px",overflow:"hidden",background:"white"}:{overflow:"hidden",background:"white",flexShrink:0};return h.jsxs("div",{style:Bt,children:[h.jsx("canvas",{ref:F,style:{width:"100%",height:"32px",cursor:"pointer",flexShrink:0},onMouseDown:Z=>{if(a==="editing"){Be.current=!0,ke.current=Z.clientX,Ie.current=x;const L=fe=>{Be.current&&ge(fe.clientX)},le=()=>{Be.current=!1,window.removeEventListener("mousemove",L),window.removeEventListener("mouseup",le)};window.addEventListener("mousemove",L),window.addEventListener("mouseup",le)}}}),h.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:l?"6px 8px":"4px",borderTop:"1px solid #d4d4d4",background:"linear-gradient(to bottom, #e0e0e0 0%, #c8c8c8 100%)",boxShadow:"inset 0 1px 0 rgba(255,255,255,0.6), inset 0 -1px 0 rgba(0,0,0,0.1)",flexShrink:0},children:[h.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px"},children:[h.jsx("button",{onClick:ye,disabled:a==="idle"||a==="recording",style:a==="idle"||a==="recording"?Je:Xe,title:"Go to start",children:h.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:"#171717"},children:"first_page"})}),h.jsx("button",{onClick:()=>{if(a==="recording"){const Z=O.current;Z&&(Z.state==="recording"?(Z.pause(),D(!0)):Z.state==="paused"&&(Z.resume(),D(!1)))}else mt()},disabled:a==="idle",style:a==="idle"?Je:Xe,title:g||a==="recording"&&!S?"Pause":"Play",children:h.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:"#171717"},children:g||a==="recording"&&!S?"pause":"play_arrow"})}),h.jsx("button",{onClick:Ue,disabled:a==="idle"||a==="recording",style:a==="idle"||a==="recording"?Je:Xe,title:"Go to end",children:h.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:"#171717"},children:"last_page"})}),h.jsx("div",{style:{width:"1px",height:"24px",margin:"0 4px",background:"linear-gradient(to bottom, rgba(255,255,255,0.5), rgba(0,0,0,0.15))"}}),h.jsx("button",{onClick:()=>{C==="insert"?ae():a==="idle"?(w("insert"),z()):a==="editing"&&(w("insert"),yt("insert"))},disabled:a==="recording"&&C!=="insert"||g,style:a==="recording"&&C!=="insert"||g?Je:Xe,title:C==="insert"?"Stop recording":"Insert recording",children:h.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:C==="insert"?"#ef4444":"#171717"},children:"add"})}),h.jsx("button",{onClick:()=>{B.current||(C==="mic"?ae():a==="idle"?(w("mic"),z()):a==="editing"&&(w("mic"),yt("replace")))},onMouseDown:()=>{B.current&&a==="idle"&&!g&&(w("mic"),z())},onMouseUp:()=>{B.current&&a==="recording"&&C==="mic"&&ae()},onMouseLeave:()=>{B.current&&a==="recording"&&C==="mic"&&ae()},onTouchStart:()=>{B.current&&a==="idle"&&!g&&(w("mic"),z())},onTouchEnd:()=>{B.current&&a==="recording"&&C==="mic"&&ae()},disabled:a==="recording"&&C!=="mic"||g,style:a==="recording"&&C!=="mic"||g?Je:Xe,title:E?"Hold to record (walkie-talkie)":C==="mic"?"Stop recording":"Record",children:h.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:C==="mic"?"#ef4444":"#171717"},children:"mic"})}),h.jsx("button",{onClick:()=>{C==="startover"?ae():a==="editing"&&(w("startover"),ie())},disabled:a==="idle"||a==="recording"&&C!=="startover"||g,style:a==="idle"||a==="recording"&&C!=="startover"||g?Je:Xe,title:C==="startover"?"Stop recording":"Start over",children:h.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:C==="startover"?"#ef4444":"#171717"},children:"refresh"})})]}),h.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px"},children:[M.total>0&&M.completed<M.total&&h.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px",padding:"4px 8px",background:"rgba(16, 185, 129, 0.1)",borderRadius:"4px",fontSize:"11px",color:"#10b981"},children:[h.jsx("span",{className:"material-icons",style:{fontSize:"14px",animation:"spin 1s linear infinite"},children:"sync"}),M.completed,"/",M.total]}),t&&h.jsxs(h.Fragment,{children:[h.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px",marginRight:"4px"},children:[h.jsx("button",{onClick:()=>R(!E),style:{width:"28px",height:"16px",borderRadius:"8px",border:"none",background:E?"#10b981":"#9ca3af",cursor:"pointer",position:"relative",transition:"background 0.2s",padding:0},title:E?"Auto-transcribe ON":"Auto-transcribe OFF",children:h.jsx("div",{style:{width:"12px",height:"12px",borderRadius:"50%",background:"white",position:"absolute",top:"2px",left:E?"14px":"2px",transition:"left 0.2s",boxShadow:"0 1px 2px rgba(0,0,0,0.2)"}})}),h.jsx("span",{style:{fontSize:"10px",color:"#666"},children:"auto"})]}),h.jsx("button",{onClick:()=>{a==="editing"&&ue.current&&He(ue.current)},disabled:a!=="editing",style:a!=="editing"?Je:Xe,title:"Transcribe audio",children:h.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:E?"#10b981":"#171717"},children:"subtitles"})})]}),!i&&h.jsx("button",{onClick:ce,disabled:a!=="editing",style:a!=="editing"?Je:Xe,title:"Save recording",children:h.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:"#171717"},children:"save"})})]})]}),M.total>0&&M.completed<M.total&&h.jsx("div",{style:{height:"3px",background:"#e5e5e5",overflow:"hidden"},children:h.jsx("div",{style:{height:"100%",background:"#10b981",width:`${M.completed/M.total*100}%`,transition:"width 0.3s ease"}})})]})}function Pg({label:r,value:e,onChange:t,onTranscribe:n,onAIAction:s,placeholder:i="Type or record...",className:o="",rows:l}){const[a,u]=b.useState(!1),[c,d]=b.useState(null),[f,p]=b.useState(!1),g=b.useRef(null),m=y=>{t(e?`${e}
|
|
184
184
|
|
|
185
|
-
${y}`:y)},x=async y=>{if(!(!e.trim()||a||!s)){u(!0),d(y),p(!1);try{const v=await s(y,e);t(v)}catch(v){console.error(`${y} failed:`,v)}finally{u(!1),d(null)}}},_=()=>{setTimeout(()=>{var y;(y=g.current)!=null&&y.contains(document.activeElement)||p(!1)},150)};return h.jsxs("div",{className:`flex flex-col flex-1 min-h-0 ${o}`,children:[h.jsx(Vc,{onComplete:()=>{},onTranscribe:n,onTranscriptionComplete:m,hideSaveButton:!0,variant:"div"}),h.jsxs("div",{className:"flex items-center justify-between mt-3 mb-1",children:[h.jsx("label",{className:"text-sm font-medium text-neutral-700",children:r}),h.jsxs("div",{className:"flex items-center gap-1",children:[e.trim()&&h.jsx("button",{type:"button",onClick:()=>navigator.clipboard.writeText(e),className:"p-1 rounded hover:bg-neutral-100 transition-colors",title:"Copy to clipboard",children:h.jsx("span",{className:"material-icons text-neutral-500",style:{fontSize:"16px"},children:"content_copy"})}),s&&h.jsxs("div",{className:"relative",ref:g,children:[h.jsx("button",{type:"button",onClick:()=>p(!f),disabled:a||!e.trim(),className:"flex items-center gap-1 text-xs text-purple-600 hover:text-purple-700 disabled:opacity-40 disabled:hover:text-purple-600 px-2 py-1 rounded hover:bg-purple-50 transition-colors",children:a?h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"material-icons text-sm animate-spin",children:"hourglass_empty"}),c==="restructure"&&"Restructuring...",c==="proofread"&&"Proofreading...",c==="rewrite"&&"Rewriting..."]}):h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"material-icons text-sm",children:"auto_fix_high"}),"AI",h.jsx("span",{className:"material-icons text-sm",children:"expand_more"})]})}),f&&!a&&h.jsxs("div",{className:"absolute right-0 top-full mt-1 bg-white border border-neutral-200 rounded-lg shadow-lg z-50 min-w-[180px] py-1",onBlur:_,children:[h.jsxs("button",{type:"button",onClick:()=>x("restructure"),className:"w-full px-3 py-2 text-left text-sm hover:bg-neutral-50 flex items-center gap-2",children:[h.jsx("span",{className:"material-icons text-base text-blue-500",children:"format_list_bulleted"}),h.jsxs("div",{children:[h.jsx("div",{className:"font-medium",children:"Restructure"}),h.jsx("div",{className:"text-xs text-neutral-500",children:"Organize & clarify"})]})]}),h.jsxs("button",{type:"button",onClick:()=>x("proofread"),className:"w-full px-3 py-2 text-left text-sm hover:bg-neutral-50 flex items-center gap-2",children:[h.jsx("span",{className:"material-icons text-base text-green-500",children:"spellcheck"}),h.jsxs("div",{children:[h.jsx("div",{className:"font-medium",children:"Proofread"}),h.jsx("div",{className:"text-xs text-neutral-500",children:"Fix grammar & spelling"})]})]}),h.jsxs("button",{type:"button",onClick:()=>x("rewrite"),className:"w-full px-3 py-2 text-left text-sm hover:bg-neutral-50 flex items-center gap-2",children:[h.jsx("span",{className:"material-icons text-base text-purple-500",children:"brush"}),h.jsxs("div",{children:[h.jsx("div",{className:"font-medium",children:"Rewrite"}),h.jsx("div",{className:"text-xs text-neutral-500",children:"Your voice & style"})]})]})]})]})]})]}),h.jsx("textarea",{value:e,onChange:y=>t(y.target.value),onKeyDown:y=>y.stopPropagation(),placeholder:i,rows:l,disabled:a,className:"flex-1 w-full px-3 py-2 border border-neutral-300 rounded-lg focus:ring-2 focus:ring-neutral-900 text-sm disabled:opacity-50 disabled:bg-neutral-50 resize-none"})]})}const gs={"4/3":4/3,"16/9":16/9,"1/1":1,"3/4":3/4,"9/16":9/16,free:null};function Ig({src:r,onSave:e,onCancel:t,aspectRatio:n="4/3",outputFormat:s="image/jpeg",outputQuality:i=.9,theme:o="dark"}){const l=b.useRef(null),a=b.useRef(null),u=b.useRef(null),[c,d]=b.useState(!0),[f,p]=b.useState(null),[g,m]=b.useState(n),[x,_]=b.useState(0),[y,v]=b.useState({x:0,y:0,width:100,height:100}),[S,D]=b.useState(!1),[C,w]=b.useState(null),[E,R]=b.useState({x:0,y:0}),[T,N]=b.useState({x:0,y:0,width:100,height:100}),M=o==="dark",j=b.useCallback(()=>{const J=u.current;return J?x===90||x===270?{width:J.height,height:J.width}:{width:J.width,height:J.height}:{width:100,height:100}},[x]),k=b.useCallback((J,Ce)=>{const ne=J/Ce,Be=.05;for(const[Se,ke]of Object.entries(gs))if(ke!==null&&Math.abs(ne-ke)/ke<Be)return Se;return"free"},[]);b.useEffect(()=>{const J=new Image;J.crossOrigin="anonymous",J.onload=()=>{u.current=J;const Ce=k(J.width,J.height);m(Ce),d(!1)},J.onerror=()=>{p("Failed to load image"),d(!1)},J.src=r},[r,k]);const B=b.useCallback(()=>{const{width:J,height:Ce}=j(),ne=gs[g];if(ne===null){v({x:0,y:0,width:100,height:100});return}const Be=J/Ce;let Se,ke;Be>ne?(ke=100,Se=ne/Be*100):(Se=100,ke=Be/ne*100);const Ie=(100-Se)/2,Le=(100-ke)/2;v({x:Ie,y:Le,width:Se,height:ke})},[g,j]);b.useEffect(()=>{u.current&&B()},[g,x,B]),b.useEffect(()=>{const J=a.current,Ce=u.current;if(!J||!Ce||c)return;const ne=J.getContext("2d");if(!ne)return;const Be=l.current;if(!Be)return;const Se=Be.clientWidth,ke=Be.clientHeight-140,{width:Ie,height:Le}=j(),$e=Ie/Le;let Y,P;Se/ke>$e?(P=Math.min(ke,Le),Y=P*$e):(Y=Math.min(Se,Ie),P=Y/$e),Y>Se&&(Y=Se,P=Y/$e),P>ke&&(P=ke,Y=P*$e),J.width=Y,J.height=P,ne.clearRect(0,0,Y,P),ne.save(),ne.translate(Y/2,P/2),ne.rotate(x*Math.PI/180);let me,We;x===90||x===270?(me=P,We=Y):(me=Y,We=P),ne.drawImage(Ce,-me/2,-We/2,me,We),ne.restore(),ne.fillStyle="rgba(0, 0, 0, 0.6)";const z=y.x/100*Y,ae=y.y/100*P,ge=y.width/100*Y,ye=y.height/100*P;ne.fillRect(0,0,Y,ae),ne.fillRect(0,ae+ye,Y,P-ae-ye),ne.fillRect(0,ae,z,ye),ne.fillRect(z+ge,ae,Y-z-ge,ye),ne.strokeStyle="#fff",ne.lineWidth=2,ne.strokeRect(z,ae,ge,ye),ne.strokeStyle="rgba(255, 255, 255, 0.3)",ne.lineWidth=1,ne.beginPath(),ne.moveTo(z+ge/3,ae),ne.lineTo(z+ge/3,ae+ye),ne.moveTo(z+ge*2/3,ae),ne.lineTo(z+ge*2/3,ae+ye),ne.moveTo(z,ae+ye/3),ne.lineTo(z+ge,ae+ye/3),ne.moveTo(z,ae+ye*2/3),ne.lineTo(z+ge,ae+ye*2/3),ne.stroke();const Ue=14;ne.fillStyle="#fff",ne.strokeStyle="#333",ne.lineWidth=1,[{x:z,y:ae},{x:z+ge,y:ae},{x:z,y:ae+ye},{x:z+ge,y:ae+ye}].forEach(yt=>{ne.fillRect(yt.x-Ue/2,yt.y-Ue/2,Ue,Ue),ne.strokeRect(yt.x-Ue/2,yt.y-Ue/2,Ue,Ue)})},[y,x,c,j]);const F=J=>{const Ce=a.current;if(!Ce)return;const ne=Ce.getBoundingClientRect(),Be=(J.clientX-ne.left)/ne.width*100,Se=(J.clientY-ne.top)/ne.height*100,ke=4,Ie=[{name:"nw",x:y.x,y:y.y},{name:"ne",x:y.x+y.width,y:y.y},{name:"sw",x:y.x,y:y.y+y.height},{name:"se",x:y.x+y.width,y:y.y+y.height}];for(const Le of Ie)if(Math.abs(Be-Le.x)<ke&&Math.abs(Se-Le.y)<ke){w(Le.name),R({x:Be,y:Se}),N({...y});return}Be>=y.x&&Be<=y.x+y.width&&Se>=y.y&&Se<=y.y+y.height&&(D(!0),R({x:Be,y:Se}),N({...y}))},O=J=>{const Ce=a.current;if(!Ce)return;const ne=Ce.getBoundingClientRect(),Be=(J.clientX-ne.left)/ne.width*100,Se=(J.clientY-ne.top)/ne.height*100;if(S){const ke=Be-E.x,Ie=Se-E.y;let Le=T.x+ke,$e=T.y+Ie;Le=Math.max(0,Math.min(Le,100-T.width)),$e=Math.max(0,Math.min($e,100-T.height)),v({...T,x:Le,y:$e})}else if(C){const ke=gs[g],{width:Ie,height:Le}=j(),$e=Ie/Le,Y=ke?ke/$e:null;let P={...T};const me=Be-E.x,We=Se-E.y;if(C==="se")P.width=Math.max(10,Math.min(100-P.x,T.width+me)),Y?(P.height=P.width/Y,P.y+P.height>100&&(P.height=100-P.y,P.width=P.height*Y)):P.height=Math.max(10,Math.min(100-P.y,T.height+We));else if(C==="sw"){const z=-me,ae=Math.max(10,T.width+z),ge=T.x+T.width-ae;ge>=0&&(P.width=ae,P.x=ge,Y?(P.height=P.width/Y,P.y+P.height>100&&(P.height=100-P.y,P.width=P.height*Y,P.x=T.x+T.width-P.width)):P.height=Math.max(10,Math.min(100-P.y,T.height+We)))}else if(C==="ne")if(P.width=Math.max(10,Math.min(100-P.x,T.width+me)),Y){const z=P.width/Y,ae=T.y+T.height-z;ae>=0?(P.height=z,P.y=ae):(P.y=0,P.height=T.y+T.height,P.width=P.height*Y)}else{const z=-We,ae=Math.max(10,T.height+z),ge=T.y+T.height-ae;ge>=0&&(P.height=ae,P.y=ge)}else if(C==="nw"){const z=-me,ae=Math.max(10,T.width+z),ge=T.x+T.width-ae;if(ge>=0)if(P.width=ae,P.x=ge,Y){const ye=P.width/Y,Ue=T.y+T.height-ye;Ue>=0?(P.height=ye,P.y=Ue):(P.y=0,P.height=T.y+T.height,P.width=P.height*Y,P.x=T.x+T.width-P.width)}else{const ye=-We,Ue=Math.max(10,T.height+ye),mt=T.y+T.height-Ue;mt>=0&&(P.height=Ue,P.y=mt)}}P.x=Math.max(0,P.x),P.y=Math.max(0,P.y),P.width=Math.min(P.width,100-P.x),P.height=Math.min(P.height,100-P.y),v(P)}},V=()=>{D(!1),w(null)},U=J=>{_(Ce=>J==="right"?(Ce+90)%360:(Ce-90+360)%360)},te=()=>{const J=u.current;if(!J)return;const{width:Ce,height:ne}=j(),Be=y.x/100*Ce,Se=y.y/100*ne,ke=y.width/100*Ce,Ie=y.height/100*ne,Le=document.createElement("canvas"),$e=Le.getContext("2d");if(!$e)return;Le.width=ke,Le.height=Ie;const Y=document.createElement("canvas"),P=Y.getContext("2d");P&&(Y.width=Ce,Y.height=ne,P.save(),P.translate(Ce/2,ne/2),P.rotate(x*Math.PI/180),P.drawImage(J,-J.width/2,-J.height/2,J.width,J.height),P.restore(),$e.drawImage(Y,Be,Se,ke,Ie,0,0,ke,Ie),Le.toBlob(me=>{me&&e(me)},s,i))},q={display:"flex",flexDirection:"column",width:"100%",height:"100%",background:M?"#1a1a1a":"#f5f5f5",overflow:"hidden"},X={flex:1,display:"flex",alignItems:"center",justifyContent:"center",padding:"16px",minHeight:0,overflow:"hidden"},W={display:"flex",flexDirection:"column",gap:"12px",padding:"16px",borderTop:`1px solid ${M?"#333":"#ddd"}`,background:M?"#242424":"#fff",flexShrink:0},se={display:"flex",alignItems:"center",justifyContent:"space-between",gap:"8px"},ue={padding:"10px 20px",borderRadius:"8px",border:"none",cursor:"pointer",fontSize:"14px",fontWeight:500,transition:"background 0.15s, opacity 0.15s"},de={...ue,background:"#E67E22",color:"#fff"},pe={...ue,background:M?"#333":"#e5e5e5",color:M?"#fff":"#333"},De={padding:"10px",borderRadius:"8px",border:"none",background:M?"#333":"#e5e5e5",color:M?"#fff":"#333",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center"},xe=J=>({padding:"8px 14px",borderRadius:"6px",border:J?"2px solid #E67E22":"2px solid transparent",background:J?"#E67E22":M?"#333":"#e5e5e5",color:J?"#fff":M?"#ccc":"#666",cursor:"pointer",fontSize:"13px",fontWeight:600,transition:"all 0.15s"});return c?h.jsx("div",{style:{...q,alignItems:"center",justifyContent:"center"},children:h.jsx("div",{style:{color:M?"#aaa":"#666"},children:"Loading image..."})}):f?h.jsxs("div",{style:{...q,alignItems:"center",justifyContent:"center"},children:[h.jsx("div",{style:{color:"#ef4444"},children:f}),t&&h.jsx("button",{onClick:t,style:{...pe,marginTop:"16px"},children:"Close"})]}):h.jsxs("div",{ref:l,style:q,children:[h.jsx("div",{style:X,children:h.jsx("canvas",{ref:a,style:{cursor:S?"grabbing":C?"nwse-resize":"grab",maxWidth:"100%",maxHeight:"100%"},onMouseDown:F,onMouseMove:O,onMouseUp:V,onMouseLeave:V})}),h.jsxs("div",{style:W,children:[h.jsx("div",{style:{display:"flex",gap:"8px",flexWrap:"wrap",justifyContent:"center"},children:Object.keys(gs).map(J=>h.jsx("button",{onClick:()=>m(J),style:xe(g===J),children:J==="free"?"Libre":J},J))}),h.jsxs("div",{style:se,children:[h.jsxs("div",{style:{display:"flex",gap:"8px"},children:[h.jsx("button",{onClick:()=>U("left"),style:De,title:"Rotate left",children:h.jsx("svg",{width:"22",height:"22",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:h.jsx("path",{d:"M2.5 2v6h6M2.66 15.57a10 10 0 1 0 .57-8.38"})})}),h.jsx("button",{onClick:()=>U("right"),style:De,title:"Rotate right",children:h.jsx("svg",{width:"22",height:"22",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:h.jsx("path",{d:"M21.5 2v6h-6M21.34 15.57a10 10 0 1 1-.57-8.38"})})})]}),h.jsxs("div",{style:{display:"flex",gap:"8px"},children:[t&&h.jsx("button",{onClick:t,style:pe,children:"Annuler"}),h.jsx("button",{onClick:te,style:de,children:"Enregistrer"})]})]})]})]})}var Og={value:()=>{}};function la(){for(var r=0,e=arguments.length,t={},n;r<e;++r){if(!(n=arguments[r]+"")||n in t||/[\s.]/.test(n))throw new Error("illegal type: "+n);t[n]=[]}return new Cs(t)}function Cs(r){this._=r}function zg(r,e){return r.trim().split(/^|\s+/).map(function(t){var n="",s=t.indexOf(".");if(s>=0&&(n=t.slice(s+1),t=t.slice(0,s)),t&&!e.hasOwnProperty(t))throw new Error("unknown type: "+t);return{type:t,name:n}})}Cs.prototype=la.prototype={constructor:Cs,on:function(r,e){var t=this._,n=zg(r+"",t),s,i=-1,o=n.length;if(arguments.length<2){for(;++i<o;)if((s=(r=n[i]).type)&&(s=$g(t[s],r.name)))return s;return}if(e!=null&&typeof e!="function")throw new Error("invalid callback: "+e);for(;++i<o;)if(s=(r=n[i]).type)t[s]=Il(t[s],r.name,e);else if(e==null)for(s in t)t[s]=Il(t[s],r.name,null);return this},copy:function(){var r={},e=this._;for(var t in e)r[t]=e[t].slice();return new Cs(r)},call:function(r,e){if((s=arguments.length-2)>0)for(var t=new Array(s),n=0,s,i;n<s;++n)t[n]=arguments[n+2];if(!this._.hasOwnProperty(r))throw new Error("unknown type: "+r);for(i=this._[r],n=0,s=i.length;n<s;++n)i[n].value.apply(e,t)},apply:function(r,e,t){if(!this._.hasOwnProperty(r))throw new Error("unknown type: "+r);for(var n=this._[r],s=0,i=n.length;s<i;++s)n[s].value.apply(e,t)}};function $g(r,e){for(var t=0,n=r.length,s;t<n;++t)if((s=r[t]).name===e)return s.value}function Il(r,e,t){for(var n=0,s=r.length;n<s;++n)if(r[n].name===e){r[n]=Og,r=r.slice(0,n).concat(r.slice(n+1));break}return t!=null&&r.push({name:e,value:t}),r}var bo="http://www.w3.org/1999/xhtml";const Ol={svg:"http://www.w3.org/2000/svg",xhtml:bo,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function vi(r){var e=r+="",t=e.indexOf(":");return t>=0&&(e=r.slice(0,t))!=="xmlns"&&(r=r.slice(t+1)),Ol.hasOwnProperty(e)?{space:Ol[e],local:r}:r}function qg(r){return function(){var e=this.ownerDocument,t=this.namespaceURI;return t===bo&&e.documentElement.namespaceURI===bo?e.createElement(r):e.createElementNS(t,r)}}function Ug(r){return function(){return this.ownerDocument.createElementNS(r.space,r.local)}}function Gc(r){var e=vi(r);return(e.local?Ug:qg)(e)}function Wg(){}function ua(r){return r==null?Wg:function(){return this.querySelector(r)}}function Hg(r){typeof r!="function"&&(r=ua(r));for(var e=this._groups,t=e.length,n=new Array(t),s=0;s<t;++s)for(var i=e[s],o=i.length,l=n[s]=new Array(o),a,u,c=0;c<o;++c)(a=i[c])&&(u=r.call(a,a.__data__,c,i))&&("__data__"in a&&(u.__data__=a.__data__),l[c]=u);return new Dt(n,this._parents)}function Vg(r){return r==null?[]:Array.isArray(r)?r:Array.from(r)}function Gg(){return[]}function Kc(r){return r==null?Gg:function(){return this.querySelectorAll(r)}}function Kg(r){return function(){return Vg(r.apply(this,arguments))}}function Yg(r){typeof r=="function"?r=Kg(r):r=Kc(r);for(var e=this._groups,t=e.length,n=[],s=[],i=0;i<t;++i)for(var o=e[i],l=o.length,a,u=0;u<l;++u)(a=o[u])&&(n.push(r.call(a,a.__data__,u,o)),s.push(a));return new Dt(n,s)}function Yc(r){return function(){return this.matches(r)}}function Qc(r){return function(e){return e.matches(r)}}var Qg=Array.prototype.find;function Xg(r){return function(){return Qg.call(this.children,r)}}function Jg(){return this.firstElementChild}function Zg(r){return this.select(r==null?Jg:Xg(typeof r=="function"?r:Qc(r)))}var e0=Array.prototype.filter;function t0(){return Array.from(this.children)}function r0(r){return function(){return e0.call(this.children,r)}}function n0(r){return this.selectAll(r==null?t0:r0(typeof r=="function"?r:Qc(r)))}function s0(r){typeof r!="function"&&(r=Yc(r));for(var e=this._groups,t=e.length,n=new Array(t),s=0;s<t;++s)for(var i=e[s],o=i.length,l=n[s]=[],a,u=0;u<o;++u)(a=i[u])&&r.call(a,a.__data__,u,i)&&l.push(a);return new Dt(n,this._parents)}function Xc(r){return new Array(r.length)}function i0(){return new Dt(this._enter||this._groups.map(Xc),this._parents)}function Qs(r,e){this.ownerDocument=r.ownerDocument,this.namespaceURI=r.namespaceURI,this._next=null,this._parent=r,this.__data__=e}Qs.prototype={constructor:Qs,appendChild:function(r){return this._parent.insertBefore(r,this._next)},insertBefore:function(r,e){return this._parent.insertBefore(r,e)},querySelector:function(r){return this._parent.querySelector(r)},querySelectorAll:function(r){return this._parent.querySelectorAll(r)}};function o0(r){return function(){return r}}function a0(r,e,t,n,s,i){for(var o=0,l,a=e.length,u=i.length;o<u;++o)(l=e[o])?(l.__data__=i[o],n[o]=l):t[o]=new Qs(r,i[o]);for(;o<a;++o)(l=e[o])&&(s[o]=l)}function l0(r,e,t,n,s,i,o){var l,a,u=new Map,c=e.length,d=i.length,f=new Array(c),p;for(l=0;l<c;++l)(a=e[l])&&(f[l]=p=o.call(a,a.__data__,l,e)+"",u.has(p)?s[l]=a:u.set(p,a));for(l=0;l<d;++l)p=o.call(r,i[l],l,i)+"",(a=u.get(p))?(n[l]=a,a.__data__=i[l],u.delete(p)):t[l]=new Qs(r,i[l]);for(l=0;l<c;++l)(a=e[l])&&u.get(f[l])===a&&(s[l]=a)}function u0(r){return r.__data__}function c0(r,e){if(!arguments.length)return Array.from(this,u0);var t=e?l0:a0,n=this._parents,s=this._groups;typeof r!="function"&&(r=o0(r));for(var i=s.length,o=new Array(i),l=new Array(i),a=new Array(i),u=0;u<i;++u){var c=n[u],d=s[u],f=d.length,p=d0(r.call(c,c&&c.__data__,u,n)),g=p.length,m=l[u]=new Array(g),x=o[u]=new Array(g),_=a[u]=new Array(f);t(c,d,m,x,_,p,e);for(var y=0,v=0,S,D;y<g;++y)if(S=m[y]){for(y>=v&&(v=y+1);!(D=x[v])&&++v<g;);S._next=D||null}}return o=new Dt(o,n),o._enter=l,o._exit=a,o}function d0(r){return typeof r=="object"&&"length"in r?r:Array.from(r)}function f0(){return new Dt(this._exit||this._groups.map(Xc),this._parents)}function h0(r,e,t){var n=this.enter(),s=this,i=this.exit();return typeof r=="function"?(n=r(n),n&&(n=n.selection())):n=n.append(r+""),e!=null&&(s=e(s),s&&(s=s.selection())),t==null?i.remove():t(i),n&&s?n.merge(s).order():s}function p0(r){for(var e=r.selection?r.selection():r,t=this._groups,n=e._groups,s=t.length,i=n.length,o=Math.min(s,i),l=new Array(s),a=0;a<o;++a)for(var u=t[a],c=n[a],d=u.length,f=l[a]=new Array(d),p,g=0;g<d;++g)(p=u[g]||c[g])&&(f[g]=p);for(;a<s;++a)l[a]=t[a];return new Dt(l,this._parents)}function g0(){for(var r=this._groups,e=-1,t=r.length;++e<t;)for(var n=r[e],s=n.length-1,i=n[s],o;--s>=0;)(o=n[s])&&(i&&o.compareDocumentPosition(i)^4&&i.parentNode.insertBefore(o,i),i=o);return this}function m0(r){r||(r=y0);function e(d,f){return d&&f?r(d.__data__,f.__data__):!d-!f}for(var t=this._groups,n=t.length,s=new Array(n),i=0;i<n;++i){for(var o=t[i],l=o.length,a=s[i]=new Array(l),u,c=0;c<l;++c)(u=o[c])&&(a[c]=u);a.sort(e)}return new Dt(s,this._parents).order()}function y0(r,e){return r<e?-1:r>e?1:r>=e?0:NaN}function x0(){var r=arguments[0];return arguments[0]=this,r.apply(null,arguments),this}function b0(){return Array.from(this)}function _0(){for(var r=this._groups,e=0,t=r.length;e<t;++e)for(var n=r[e],s=0,i=n.length;s<i;++s){var o=n[s];if(o)return o}return null}function v0(){let r=0;for(const e of this)++r;return r}function w0(){return!this.node()}function C0(r){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var s=e[t],i=0,o=s.length,l;i<o;++i)(l=s[i])&&r.call(l,l.__data__,i,s);return this}function S0(r){return function(){this.removeAttribute(r)}}function k0(r){return function(){this.removeAttributeNS(r.space,r.local)}}function E0(r,e){return function(){this.setAttribute(r,e)}}function D0(r,e){return function(){this.setAttributeNS(r.space,r.local,e)}}function A0(r,e){return function(){var t=e.apply(this,arguments);t==null?this.removeAttribute(r):this.setAttribute(r,t)}}function T0(r,e){return function(){var t=e.apply(this,arguments);t==null?this.removeAttributeNS(r.space,r.local):this.setAttributeNS(r.space,r.local,t)}}function N0(r,e){var t=vi(r);if(arguments.length<2){var n=this.node();return t.local?n.getAttributeNS(t.space,t.local):n.getAttribute(t)}return this.each((e==null?t.local?k0:S0:typeof e=="function"?t.local?T0:A0:t.local?D0:E0)(t,e))}function Jc(r){return r.ownerDocument&&r.ownerDocument.defaultView||r.document&&r||r.defaultView}function B0(r){return function(){this.style.removeProperty(r)}}function R0(r,e,t){return function(){this.style.setProperty(r,e,t)}}function M0(r,e,t){return function(){var n=e.apply(this,arguments);n==null?this.style.removeProperty(r):this.style.setProperty(r,n,t)}}function F0(r,e,t){return arguments.length>1?this.each((e==null?B0:typeof e=="function"?M0:R0)(r,e,t??"")):rn(this.node(),r)}function rn(r,e){return r.style.getPropertyValue(e)||Jc(r).getComputedStyle(r,null).getPropertyValue(e)}function j0(r){return function(){delete this[r]}}function L0(r,e){return function(){this[r]=e}}function P0(r,e){return function(){var t=e.apply(this,arguments);t==null?delete this[r]:this[r]=t}}function I0(r,e){return arguments.length>1?this.each((e==null?j0:typeof e=="function"?P0:L0)(r,e)):this.node()[r]}function Zc(r){return r.trim().split(/^|\s+/)}function ca(r){return r.classList||new ed(r)}function ed(r){this._node=r,this._names=Zc(r.getAttribute("class")||"")}ed.prototype={add:function(r){var e=this._names.indexOf(r);e<0&&(this._names.push(r),this._node.setAttribute("class",this._names.join(" ")))},remove:function(r){var e=this._names.indexOf(r);e>=0&&(this._names.splice(e,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(r){return this._names.indexOf(r)>=0}};function td(r,e){for(var t=ca(r),n=-1,s=e.length;++n<s;)t.add(e[n])}function rd(r,e){for(var t=ca(r),n=-1,s=e.length;++n<s;)t.remove(e[n])}function O0(r){return function(){td(this,r)}}function z0(r){return function(){rd(this,r)}}function $0(r,e){return function(){(e.apply(this,arguments)?td:rd)(this,r)}}function q0(r,e){var t=Zc(r+"");if(arguments.length<2){for(var n=ca(this.node()),s=-1,i=t.length;++s<i;)if(!n.contains(t[s]))return!1;return!0}return this.each((typeof e=="function"?$0:e?O0:z0)(t,e))}function U0(){this.textContent=""}function W0(r){return function(){this.textContent=r}}function H0(r){return function(){var e=r.apply(this,arguments);this.textContent=e??""}}function V0(r){return arguments.length?this.each(r==null?U0:(typeof r=="function"?H0:W0)(r)):this.node().textContent}function G0(){this.innerHTML=""}function K0(r){return function(){this.innerHTML=r}}function Y0(r){return function(){var e=r.apply(this,arguments);this.innerHTML=e??""}}function Q0(r){return arguments.length?this.each(r==null?G0:(typeof r=="function"?Y0:K0)(r)):this.node().innerHTML}function X0(){this.nextSibling&&this.parentNode.appendChild(this)}function J0(){return this.each(X0)}function Z0(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function em(){return this.each(Z0)}function tm(r){var e=typeof r=="function"?r:Gc(r);return this.select(function(){return this.appendChild(e.apply(this,arguments))})}function rm(){return null}function nm(r,e){var t=typeof r=="function"?r:Gc(r),n=e==null?rm:typeof e=="function"?e:ua(e);return this.select(function(){return this.insertBefore(t.apply(this,arguments),n.apply(this,arguments)||null)})}function sm(){var r=this.parentNode;r&&r.removeChild(this)}function im(){return this.each(sm)}function om(){var r=this.cloneNode(!1),e=this.parentNode;return e?e.insertBefore(r,this.nextSibling):r}function am(){var r=this.cloneNode(!0),e=this.parentNode;return e?e.insertBefore(r,this.nextSibling):r}function lm(r){return this.select(r?am:om)}function um(r){return arguments.length?this.property("__data__",r):this.node().__data__}function cm(r){return function(e){r.call(this,e,this.__data__)}}function dm(r){return r.trim().split(/^|\s+/).map(function(e){var t="",n=e.indexOf(".");return n>=0&&(t=e.slice(n+1),e=e.slice(0,n)),{type:e,name:t}})}function fm(r){return function(){var e=this.__on;if(e){for(var t=0,n=-1,s=e.length,i;t<s;++t)i=e[t],(!r.type||i.type===r.type)&&i.name===r.name?this.removeEventListener(i.type,i.listener,i.options):e[++n]=i;++n?e.length=n:delete this.__on}}}function hm(r,e,t){return function(){var n=this.__on,s,i=cm(e);if(n){for(var o=0,l=n.length;o<l;++o)if((s=n[o]).type===r.type&&s.name===r.name){this.removeEventListener(s.type,s.listener,s.options),this.addEventListener(s.type,s.listener=i,s.options=t),s.value=e;return}}this.addEventListener(r.type,i,t),s={type:r.type,name:r.name,value:e,listener:i,options:t},n?n.push(s):this.__on=[s]}}function pm(r,e,t){var n=dm(r+""),s,i=n.length,o;if(arguments.length<2){var l=this.node().__on;if(l){for(var a=0,u=l.length,c;a<u;++a)for(s=0,c=l[a];s<i;++s)if((o=n[s]).type===c.type&&o.name===c.name)return c.value}return}for(l=e?hm:fm,s=0;s<i;++s)this.each(l(n[s],e,t));return this}function nd(r,e,t){var n=Jc(r),s=n.CustomEvent;typeof s=="function"?s=new s(e,t):(s=n.document.createEvent("Event"),t?(s.initEvent(e,t.bubbles,t.cancelable),s.detail=t.detail):s.initEvent(e,!1,!1)),r.dispatchEvent(s)}function gm(r,e){return function(){return nd(this,r,e)}}function mm(r,e){return function(){return nd(this,r,e.apply(this,arguments))}}function ym(r,e){return this.each((typeof e=="function"?mm:gm)(r,e))}function*xm(){for(var r=this._groups,e=0,t=r.length;e<t;++e)for(var n=r[e],s=0,i=n.length,o;s<i;++s)(o=n[s])&&(yield o)}var sd=[null];function Dt(r,e){this._groups=r,this._parents=e}function ss(){return new Dt([[document.documentElement]],sd)}function bm(){return this}Dt.prototype=ss.prototype={constructor:Dt,select:Hg,selectAll:Yg,selectChild:Zg,selectChildren:n0,filter:s0,data:c0,enter:i0,exit:f0,join:h0,merge:p0,selection:bm,order:g0,sort:m0,call:x0,nodes:b0,node:_0,size:v0,empty:w0,each:C0,attr:N0,style:F0,property:I0,classed:q0,text:V0,html:Q0,raise:J0,lower:em,append:tm,insert:nm,remove:im,clone:lm,datum:um,on:pm,dispatch:ym,[Symbol.iterator]:xm};function Lt(r){return typeof r=="string"?new Dt([[document.querySelector(r)]],[document.documentElement]):new Dt([[r]],sd)}function _m(r){let e;for(;e=r.sourceEvent;)r=e;return r}function wr(r,e){if(r=_m(r),e===void 0&&(e=r.currentTarget),e){var t=e.ownerSVGElement||e;if(t.createSVGPoint){var n=t.createSVGPoint();return n.x=r.clientX,n.y=r.clientY,n=n.matrixTransform(e.getScreenCTM().inverse()),[n.x,n.y]}if(e.getBoundingClientRect){var s=e.getBoundingClientRect();return[r.clientX-s.left-e.clientLeft,r.clientY-s.top-e.clientTop]}}return[r.pageX,r.pageY]}const _o={capture:!0,passive:!1};function vo(r){r.preventDefault(),r.stopImmediatePropagation()}function vm(r){var e=r.document.documentElement,t=Lt(r).on("dragstart.drag",vo,_o);"onselectstart"in e?t.on("selectstart.drag",vo,_o):(e.__noselect=e.style.MozUserSelect,e.style.MozUserSelect="none")}function wm(r,e){var t=r.document.documentElement,n=Lt(r).on("dragstart.drag",null);e&&(n.on("click.drag",vo,_o),setTimeout(function(){n.on("click.drag",null)},0)),"onselectstart"in t?n.on("selectstart.drag",null):(t.style.MozUserSelect=t.__noselect,delete t.__noselect)}function da(r,e,t){r.prototype=e.prototype=t,t.constructor=r}function id(r,e){var t=Object.create(r.prototype);for(var n in e)t[n]=e[n];return t}function is(){}var $n=.7,Xs=1/$n,Xr="\\s*([+-]?\\d+)\\s*",qn="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Gt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Cm=/^#([0-9a-f]{3,8})$/,Sm=new RegExp(`^rgb\\(${Xr},${Xr},${Xr}\\)$`),km=new RegExp(`^rgb\\(${Gt},${Gt},${Gt}\\)$`),Em=new RegExp(`^rgba\\(${Xr},${Xr},${Xr},${qn}\\)$`),Dm=new RegExp(`^rgba\\(${Gt},${Gt},${Gt},${qn}\\)$`),Am=new RegExp(`^hsl\\(${qn},${Gt},${Gt}\\)$`),Tm=new RegExp(`^hsla\\(${qn},${Gt},${Gt},${qn}\\)$`),zl={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};da(is,Un,{copy(r){return Object.assign(new this.constructor,this,r)},displayable(){return this.rgb().displayable()},hex:$l,formatHex:$l,formatHex8:Nm,formatHsl:Bm,formatRgb:ql,toString:ql});function $l(){return this.rgb().formatHex()}function Nm(){return this.rgb().formatHex8()}function Bm(){return od(this).formatHsl()}function ql(){return this.rgb().formatRgb()}function Un(r){var e,t;return r=(r+"").trim().toLowerCase(),(e=Cm.exec(r))?(t=e[1].length,e=parseInt(e[1],16),t===6?Ul(e):t===3?new wt(e>>8&15|e>>4&240,e>>4&15|e&240,(e&15)<<4|e&15,1):t===8?ms(e>>24&255,e>>16&255,e>>8&255,(e&255)/255):t===4?ms(e>>12&15|e>>8&240,e>>8&15|e>>4&240,e>>4&15|e&240,((e&15)<<4|e&15)/255):null):(e=Sm.exec(r))?new wt(e[1],e[2],e[3],1):(e=km.exec(r))?new wt(e[1]*255/100,e[2]*255/100,e[3]*255/100,1):(e=Em.exec(r))?ms(e[1],e[2],e[3],e[4]):(e=Dm.exec(r))?ms(e[1]*255/100,e[2]*255/100,e[3]*255/100,e[4]):(e=Am.exec(r))?Vl(e[1],e[2]/100,e[3]/100,1):(e=Tm.exec(r))?Vl(e[1],e[2]/100,e[3]/100,e[4]):zl.hasOwnProperty(r)?Ul(zl[r]):r==="transparent"?new wt(NaN,NaN,NaN,0):null}function Ul(r){return new wt(r>>16&255,r>>8&255,r&255,1)}function ms(r,e,t,n){return n<=0&&(r=e=t=NaN),new wt(r,e,t,n)}function Rm(r){return r instanceof is||(r=Un(r)),r?(r=r.rgb(),new wt(r.r,r.g,r.b,r.opacity)):new wt}function wo(r,e,t,n){return arguments.length===1?Rm(r):new wt(r,e,t,n??1)}function wt(r,e,t,n){this.r=+r,this.g=+e,this.b=+t,this.opacity=+n}da(wt,wo,id(is,{brighter(r){return r=r==null?Xs:Math.pow(Xs,r),new wt(this.r*r,this.g*r,this.b*r,this.opacity)},darker(r){return r=r==null?$n:Math.pow($n,r),new wt(this.r*r,this.g*r,this.b*r,this.opacity)},rgb(){return this},clamp(){return new wt(Tr(this.r),Tr(this.g),Tr(this.b),Js(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:Wl,formatHex:Wl,formatHex8:Mm,formatRgb:Hl,toString:Hl}));function Wl(){return`#${Sr(this.r)}${Sr(this.g)}${Sr(this.b)}`}function Mm(){return`#${Sr(this.r)}${Sr(this.g)}${Sr(this.b)}${Sr((isNaN(this.opacity)?1:this.opacity)*255)}`}function Hl(){const r=Js(this.opacity);return`${r===1?"rgb(":"rgba("}${Tr(this.r)}, ${Tr(this.g)}, ${Tr(this.b)}${r===1?")":`, ${r})`}`}function Js(r){return isNaN(r)?1:Math.max(0,Math.min(1,r))}function Tr(r){return Math.max(0,Math.min(255,Math.round(r)||0))}function Sr(r){return r=Tr(r),(r<16?"0":"")+r.toString(16)}function Vl(r,e,t,n){return n<=0?r=e=t=NaN:t<=0||t>=1?r=e=NaN:e<=0&&(r=NaN),new Pt(r,e,t,n)}function od(r){if(r instanceof Pt)return new Pt(r.h,r.s,r.l,r.opacity);if(r instanceof is||(r=Un(r)),!r)return new Pt;if(r instanceof Pt)return r;r=r.rgb();var e=r.r/255,t=r.g/255,n=r.b/255,s=Math.min(e,t,n),i=Math.max(e,t,n),o=NaN,l=i-s,a=(i+s)/2;return l?(e===i?o=(t-n)/l+(t<n)*6:t===i?o=(n-e)/l+2:o=(e-t)/l+4,l/=a<.5?i+s:2-i-s,o*=60):l=a>0&&a<1?0:o,new Pt(o,l,a,r.opacity)}function Fm(r,e,t,n){return arguments.length===1?od(r):new Pt(r,e,t,n??1)}function Pt(r,e,t,n){this.h=+r,this.s=+e,this.l=+t,this.opacity=+n}da(Pt,Fm,id(is,{brighter(r){return r=r==null?Xs:Math.pow(Xs,r),new Pt(this.h,this.s,this.l*r,this.opacity)},darker(r){return r=r==null?$n:Math.pow($n,r),new Pt(this.h,this.s,this.l*r,this.opacity)},rgb(){var r=this.h%360+(this.h<0)*360,e=isNaN(r)||isNaN(this.s)?0:this.s,t=this.l,n=t+(t<.5?t:1-t)*e,s=2*t-n;return new wt(qi(r>=240?r-240:r+120,s,n),qi(r,s,n),qi(r<120?r+240:r-120,s,n),this.opacity)},clamp(){return new Pt(Gl(this.h),ys(this.s),ys(this.l),Js(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const r=Js(this.opacity);return`${r===1?"hsl(":"hsla("}${Gl(this.h)}, ${ys(this.s)*100}%, ${ys(this.l)*100}%${r===1?")":`, ${r})`}`}}));function Gl(r){return r=(r||0)%360,r<0?r+360:r}function ys(r){return Math.max(0,Math.min(1,r||0))}function qi(r,e,t){return(r<60?e+(t-e)*r/60:r<180?t:r<240?e+(t-e)*(240-r)/60:e)*255}const ad=r=>()=>r;function jm(r,e){return function(t){return r+t*e}}function Lm(r,e,t){return r=Math.pow(r,t),e=Math.pow(e,t)-r,t=1/t,function(n){return Math.pow(r+n*e,t)}}function Pm(r){return(r=+r)==1?ld:function(e,t){return t-e?Lm(e,t,r):ad(isNaN(e)?t:e)}}function ld(r,e){var t=e-r;return t?jm(r,t):ad(isNaN(r)?e:r)}const Kl=function r(e){var t=Pm(e);function n(s,i){var o=t((s=wo(s)).r,(i=wo(i)).r),l=t(s.g,i.g),a=t(s.b,i.b),u=ld(s.opacity,i.opacity);return function(c){return s.r=o(c),s.g=l(c),s.b=a(c),s.opacity=u(c),s+""}}return n.gamma=r,n}(1);function fr(r,e){return r=+r,e=+e,function(t){return r*(1-t)+e*t}}var Co=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Ui=new RegExp(Co.source,"g");function Im(r){return function(){return r}}function Om(r){return function(e){return r(e)+""}}function zm(r,e){var t=Co.lastIndex=Ui.lastIndex=0,n,s,i,o=-1,l=[],a=[];for(r=r+"",e=e+"";(n=Co.exec(r))&&(s=Ui.exec(e));)(i=s.index)>t&&(i=e.slice(t,i),l[o]?l[o]+=i:l[++o]=i),(n=n[0])===(s=s[0])?l[o]?l[o]+=s:l[++o]=s:(l[++o]=null,a.push({i:o,x:fr(n,s)})),t=Ui.lastIndex;return t<e.length&&(i=e.slice(t),l[o]?l[o]+=i:l[++o]=i),l.length<2?a[0]?Om(a[0].x):Im(e):(e=a.length,function(u){for(var c=0,d;c<e;++c)l[(d=a[c]).i]=d.x(u);return l.join("")})}var Yl=180/Math.PI,So={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function ud(r,e,t,n,s,i){var o,l,a;return(o=Math.sqrt(r*r+e*e))&&(r/=o,e/=o),(a=r*t+e*n)&&(t-=r*a,n-=e*a),(l=Math.sqrt(t*t+n*n))&&(t/=l,n/=l,a/=l),r*n<e*t&&(r=-r,e=-e,a=-a,o=-o),{translateX:s,translateY:i,rotate:Math.atan2(e,r)*Yl,skewX:Math.atan(a)*Yl,scaleX:o,scaleY:l}}var xs;function $m(r){const e=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(r+"");return e.isIdentity?So:ud(e.a,e.b,e.c,e.d,e.e,e.f)}function qm(r){return r==null||(xs||(xs=document.createElementNS("http://www.w3.org/2000/svg","g")),xs.setAttribute("transform",r),!(r=xs.transform.baseVal.consolidate()))?So:(r=r.matrix,ud(r.a,r.b,r.c,r.d,r.e,r.f))}function cd(r,e,t,n){function s(u){return u.length?u.pop()+" ":""}function i(u,c,d,f,p,g){if(u!==d||c!==f){var m=p.push("translate(",null,e,null,t);g.push({i:m-4,x:fr(u,d)},{i:m-2,x:fr(c,f)})}else(d||f)&&p.push("translate("+d+e+f+t)}function o(u,c,d,f){u!==c?(u-c>180?c+=360:c-u>180&&(u+=360),f.push({i:d.push(s(d)+"rotate(",null,n)-2,x:fr(u,c)})):c&&d.push(s(d)+"rotate("+c+n)}function l(u,c,d,f){u!==c?f.push({i:d.push(s(d)+"skewX(",null,n)-2,x:fr(u,c)}):c&&d.push(s(d)+"skewX("+c+n)}function a(u,c,d,f,p,g){if(u!==d||c!==f){var m=p.push(s(p)+"scale(",null,",",null,")");g.push({i:m-4,x:fr(u,d)},{i:m-2,x:fr(c,f)})}else(d!==1||f!==1)&&p.push(s(p)+"scale("+d+","+f+")")}return function(u,c){var d=[],f=[];return u=r(u),c=r(c),i(u.translateX,u.translateY,c.translateX,c.translateY,d,f),o(u.rotate,c.rotate,d,f),l(u.skewX,c.skewX,d,f),a(u.scaleX,u.scaleY,c.scaleX,c.scaleY,d,f),u=c=null,function(p){for(var g=-1,m=f.length,x;++g<m;)d[(x=f[g]).i]=x.x(p);return d.join("")}}}var Um=cd($m,"px, ","px)","deg)"),Wm=cd(qm,", ",")",")"),Hm=1e-12;function Ql(r){return((r=Math.exp(r))+1/r)/2}function Vm(r){return((r=Math.exp(r))-1/r)/2}function Gm(r){return((r=Math.exp(2*r))-1)/(r+1)}const Km=function r(e,t,n){function s(i,o){var l=i[0],a=i[1],u=i[2],c=o[0],d=o[1],f=o[2],p=c-l,g=d-a,m=p*p+g*g,x,_;if(m<Hm)_=Math.log(f/u)/e,x=function(w){return[l+w*p,a+w*g,u*Math.exp(e*w*_)]};else{var y=Math.sqrt(m),v=(f*f-u*u+n*m)/(2*u*t*y),S=(f*f-u*u-n*m)/(2*f*t*y),D=Math.log(Math.sqrt(v*v+1)-v),C=Math.log(Math.sqrt(S*S+1)-S);_=(C-D)/e,x=function(w){var E=w*_,R=Ql(D),T=u/(t*y)*(R*Gm(e*E+D)-Vm(D));return[l+T*p,a+T*g,u*R/Ql(e*E+D)]}}return x.duration=_*1e3*e/Math.SQRT2,x}return s.rho=function(i){var o=Math.max(.001,+i),l=o*o,a=l*l;return r(o,l,a)},s}(Math.SQRT2,2,4);var nn=0,Cn=0,yn=0,dd=1e3,Zs,Sn,ei=0,Lr=0,wi=0,Wn=typeof performance=="object"&&performance.now?performance:Date,fd=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(r){setTimeout(r,17)};function fa(){return Lr||(fd(Ym),Lr=Wn.now()+wi)}function Ym(){Lr=0}function ti(){this._call=this._time=this._next=null}ti.prototype=hd.prototype={constructor:ti,restart:function(r,e,t){if(typeof r!="function")throw new TypeError("callback is not a function");t=(t==null?fa():+t)+(e==null?0:+e),!this._next&&Sn!==this&&(Sn?Sn._next=this:Zs=this,Sn=this),this._call=r,this._time=t,ko()},stop:function(){this._call&&(this._call=null,this._time=1/0,ko())}};function hd(r,e,t){var n=new ti;return n.restart(r,e,t),n}function Qm(){fa(),++nn;for(var r=Zs,e;r;)(e=Lr-r._time)>=0&&r._call.call(void 0,e),r=r._next;--nn}function Xl(){Lr=(ei=Wn.now())+wi,nn=Cn=0;try{Qm()}finally{nn=0,Jm(),Lr=0}}function Xm(){var r=Wn.now(),e=r-ei;e>dd&&(wi-=e,ei=r)}function Jm(){for(var r,e=Zs,t,n=1/0;e;)e._call?(n>e._time&&(n=e._time),r=e,e=e._next):(t=e._next,e._next=null,e=r?r._next=t:Zs=t);Sn=r,ko(n)}function ko(r){if(!nn){Cn&&(Cn=clearTimeout(Cn));var e=r-Lr;e>24?(r<1/0&&(Cn=setTimeout(Xl,r-Wn.now()-wi)),yn&&(yn=clearInterval(yn))):(yn||(ei=Wn.now(),yn=setInterval(Xm,dd)),nn=1,fd(Xl))}}function Jl(r,e,t){var n=new ti;return e=e==null?0:+e,n.restart(s=>{n.stop(),r(s+e)},e,t),n}var Zm=la("start","end","cancel","interrupt"),e2=[],pd=0,Zl=1,Eo=2,Ss=3,eu=4,Do=5,ks=6;function Ci(r,e,t,n,s,i){var o=r.__transition;if(!o)r.__transition={};else if(t in o)return;t2(r,t,{name:e,index:n,group:s,on:Zm,tween:e2,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:pd})}function ha(r,e){var t=qt(r,e);if(t.state>pd)throw new Error("too late; already scheduled");return t}function Jt(r,e){var t=qt(r,e);if(t.state>Ss)throw new Error("too late; already running");return t}function qt(r,e){var t=r.__transition;if(!t||!(t=t[e]))throw new Error("transition not found");return t}function t2(r,e,t){var n=r.__transition,s;n[e]=t,t.timer=hd(i,0,t.time);function i(u){t.state=Zl,t.timer.restart(o,t.delay,t.time),t.delay<=u&&o(u-t.delay)}function o(u){var c,d,f,p;if(t.state!==Zl)return a();for(c in n)if(p=n[c],p.name===t.name){if(p.state===Ss)return Jl(o);p.state===eu?(p.state=ks,p.timer.stop(),p.on.call("interrupt",r,r.__data__,p.index,p.group),delete n[c]):+c<e&&(p.state=ks,p.timer.stop(),p.on.call("cancel",r,r.__data__,p.index,p.group),delete n[c])}if(Jl(function(){t.state===Ss&&(t.state=eu,t.timer.restart(l,t.delay,t.time),l(u))}),t.state=Eo,t.on.call("start",r,r.__data__,t.index,t.group),t.state===Eo){for(t.state=Ss,s=new Array(f=t.tween.length),c=0,d=-1;c<f;++c)(p=t.tween[c].value.call(r,r.__data__,t.index,t.group))&&(s[++d]=p);s.length=d+1}}function l(u){for(var c=u<t.duration?t.ease.call(null,u/t.duration):(t.timer.restart(a),t.state=Do,1),d=-1,f=s.length;++d<f;)s[d].call(r,c);t.state===Do&&(t.on.call("end",r,r.__data__,t.index,t.group),a())}function a(){t.state=ks,t.timer.stop(),delete n[e];for(var u in n)return;delete r.__transition}}function Es(r,e){var t=r.__transition,n,s,i=!0,o;if(t){e=e==null?null:e+"";for(o in t){if((n=t[o]).name!==e){i=!1;continue}s=n.state>Eo&&n.state<Do,n.state=ks,n.timer.stop(),n.on.call(s?"interrupt":"cancel",r,r.__data__,n.index,n.group),delete t[o]}i&&delete r.__transition}}function r2(r){return this.each(function(){Es(this,r)})}function n2(r,e){var t,n;return function(){var s=Jt(this,r),i=s.tween;if(i!==t){n=t=i;for(var o=0,l=n.length;o<l;++o)if(n[o].name===e){n=n.slice(),n.splice(o,1);break}}s.tween=n}}function s2(r,e,t){var n,s;if(typeof t!="function")throw new Error;return function(){var i=Jt(this,r),o=i.tween;if(o!==n){s=(n=o).slice();for(var l={name:e,value:t},a=0,u=s.length;a<u;++a)if(s[a].name===e){s[a]=l;break}a===u&&s.push(l)}i.tween=s}}function i2(r,e){var t=this._id;if(r+="",arguments.length<2){for(var n=qt(this.node(),t).tween,s=0,i=n.length,o;s<i;++s)if((o=n[s]).name===r)return o.value;return null}return this.each((e==null?n2:s2)(t,r,e))}function pa(r,e,t){var n=r._id;return r.each(function(){var s=Jt(this,n);(s.value||(s.value={}))[e]=t.apply(this,arguments)}),function(s){return qt(s,n).value[e]}}function gd(r,e){var t;return(typeof e=="number"?fr:e instanceof Un?Kl:(t=Un(e))?(e=t,Kl):zm)(r,e)}function o2(r){return function(){this.removeAttribute(r)}}function a2(r){return function(){this.removeAttributeNS(r.space,r.local)}}function l2(r,e,t){var n,s=t+"",i;return function(){var o=this.getAttribute(r);return o===s?null:o===n?i:i=e(n=o,t)}}function u2(r,e,t){var n,s=t+"",i;return function(){var o=this.getAttributeNS(r.space,r.local);return o===s?null:o===n?i:i=e(n=o,t)}}function c2(r,e,t){var n,s,i;return function(){var o,l=t(this),a;return l==null?void this.removeAttribute(r):(o=this.getAttribute(r),a=l+"",o===a?null:o===n&&a===s?i:(s=a,i=e(n=o,l)))}}function d2(r,e,t){var n,s,i;return function(){var o,l=t(this),a;return l==null?void this.removeAttributeNS(r.space,r.local):(o=this.getAttributeNS(r.space,r.local),a=l+"",o===a?null:o===n&&a===s?i:(s=a,i=e(n=o,l)))}}function f2(r,e){var t=vi(r),n=t==="transform"?Wm:gd;return this.attrTween(r,typeof e=="function"?(t.local?d2:c2)(t,n,pa(this,"attr."+r,e)):e==null?(t.local?a2:o2)(t):(t.local?u2:l2)(t,n,e))}function h2(r,e){return function(t){this.setAttribute(r,e.call(this,t))}}function p2(r,e){return function(t){this.setAttributeNS(r.space,r.local,e.call(this,t))}}function g2(r,e){var t,n;function s(){var i=e.apply(this,arguments);return i!==n&&(t=(n=i)&&p2(r,i)),t}return s._value=e,s}function m2(r,e){var t,n;function s(){var i=e.apply(this,arguments);return i!==n&&(t=(n=i)&&h2(r,i)),t}return s._value=e,s}function y2(r,e){var t="attr."+r;if(arguments.length<2)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!="function")throw new Error;var n=vi(r);return this.tween(t,(n.local?g2:m2)(n,e))}function x2(r,e){return function(){ha(this,r).delay=+e.apply(this,arguments)}}function b2(r,e){return e=+e,function(){ha(this,r).delay=e}}function _2(r){var e=this._id;return arguments.length?this.each((typeof r=="function"?x2:b2)(e,r)):qt(this.node(),e).delay}function v2(r,e){return function(){Jt(this,r).duration=+e.apply(this,arguments)}}function w2(r,e){return e=+e,function(){Jt(this,r).duration=e}}function C2(r){var e=this._id;return arguments.length?this.each((typeof r=="function"?v2:w2)(e,r)):qt(this.node(),e).duration}function S2(r,e){if(typeof e!="function")throw new Error;return function(){Jt(this,r).ease=e}}function k2(r){var e=this._id;return arguments.length?this.each(S2(e,r)):qt(this.node(),e).ease}function E2(r,e){return function(){var t=e.apply(this,arguments);if(typeof t!="function")throw new Error;Jt(this,r).ease=t}}function D2(r){if(typeof r!="function")throw new Error;return this.each(E2(this._id,r))}function A2(r){typeof r!="function"&&(r=Yc(r));for(var e=this._groups,t=e.length,n=new Array(t),s=0;s<t;++s)for(var i=e[s],o=i.length,l=n[s]=[],a,u=0;u<o;++u)(a=i[u])&&r.call(a,a.__data__,u,i)&&l.push(a);return new ir(n,this._parents,this._name,this._id)}function T2(r){if(r._id!==this._id)throw new Error;for(var e=this._groups,t=r._groups,n=e.length,s=t.length,i=Math.min(n,s),o=new Array(n),l=0;l<i;++l)for(var a=e[l],u=t[l],c=a.length,d=o[l]=new Array(c),f,p=0;p<c;++p)(f=a[p]||u[p])&&(d[p]=f);for(;l<n;++l)o[l]=e[l];return new ir(o,this._parents,this._name,this._id)}function N2(r){return(r+"").trim().split(/^|\s+/).every(function(e){var t=e.indexOf(".");return t>=0&&(e=e.slice(0,t)),!e||e==="start"})}function B2(r,e,t){var n,s,i=N2(e)?ha:Jt;return function(){var o=i(this,r),l=o.on;l!==n&&(s=(n=l).copy()).on(e,t),o.on=s}}function R2(r,e){var t=this._id;return arguments.length<2?qt(this.node(),t).on.on(r):this.each(B2(t,r,e))}function M2(r){return function(){var e=this.parentNode;for(var t in this.__transition)if(+t!==r)return;e&&e.removeChild(this)}}function F2(){return this.on("end.remove",M2(this._id))}function j2(r){var e=this._name,t=this._id;typeof r!="function"&&(r=ua(r));for(var n=this._groups,s=n.length,i=new Array(s),o=0;o<s;++o)for(var l=n[o],a=l.length,u=i[o]=new Array(a),c,d,f=0;f<a;++f)(c=l[f])&&(d=r.call(c,c.__data__,f,l))&&("__data__"in c&&(d.__data__=c.__data__),u[f]=d,Ci(u[f],e,t,f,u,qt(c,t)));return new ir(i,this._parents,e,t)}function L2(r){var e=this._name,t=this._id;typeof r!="function"&&(r=Kc(r));for(var n=this._groups,s=n.length,i=[],o=[],l=0;l<s;++l)for(var a=n[l],u=a.length,c,d=0;d<u;++d)if(c=a[d]){for(var f=r.call(c,c.__data__,d,a),p,g=qt(c,t),m=0,x=f.length;m<x;++m)(p=f[m])&&Ci(p,e,t,m,f,g);i.push(f),o.push(c)}return new ir(i,o,e,t)}var P2=ss.prototype.constructor;function I2(){return new P2(this._groups,this._parents)}function O2(r,e){var t,n,s;return function(){var i=rn(this,r),o=(this.style.removeProperty(r),rn(this,r));return i===o?null:i===t&&o===n?s:s=e(t=i,n=o)}}function md(r){return function(){this.style.removeProperty(r)}}function z2(r,e,t){var n,s=t+"",i;return function(){var o=rn(this,r);return o===s?null:o===n?i:i=e(n=o,t)}}function $2(r,e,t){var n,s,i;return function(){var o=rn(this,r),l=t(this),a=l+"";return l==null&&(a=l=(this.style.removeProperty(r),rn(this,r))),o===a?null:o===n&&a===s?i:(s=a,i=e(n=o,l))}}function q2(r,e){var t,n,s,i="style."+e,o="end."+i,l;return function(){var a=Jt(this,r),u=a.on,c=a.value[i]==null?l||(l=md(e)):void 0;(u!==t||s!==c)&&(n=(t=u).copy()).on(o,s=c),a.on=n}}function U2(r,e,t){var n=(r+="")=="transform"?Um:gd;return e==null?this.styleTween(r,O2(r,n)).on("end.style."+r,md(r)):typeof e=="function"?this.styleTween(r,$2(r,n,pa(this,"style."+r,e))).each(q2(this._id,r)):this.styleTween(r,z2(r,n,e),t).on("end.style."+r,null)}function W2(r,e,t){return function(n){this.style.setProperty(r,e.call(this,n),t)}}function H2(r,e,t){var n,s;function i(){var o=e.apply(this,arguments);return o!==s&&(n=(s=o)&&W2(r,o,t)),n}return i._value=e,i}function V2(r,e,t){var n="style."+(r+="");if(arguments.length<2)return(n=this.tween(n))&&n._value;if(e==null)return this.tween(n,null);if(typeof e!="function")throw new Error;return this.tween(n,H2(r,e,t??""))}function G2(r){return function(){this.textContent=r}}function K2(r){return function(){var e=r(this);this.textContent=e??""}}function Y2(r){return this.tween("text",typeof r=="function"?K2(pa(this,"text",r)):G2(r==null?"":r+""))}function Q2(r){return function(e){this.textContent=r.call(this,e)}}function X2(r){var e,t;function n(){var s=r.apply(this,arguments);return s!==t&&(e=(t=s)&&Q2(s)),e}return n._value=r,n}function J2(r){var e="text";if(arguments.length<1)return(e=this.tween(e))&&e._value;if(r==null)return this.tween(e,null);if(typeof r!="function")throw new Error;return this.tween(e,X2(r))}function Z2(){for(var r=this._name,e=this._id,t=yd(),n=this._groups,s=n.length,i=0;i<s;++i)for(var o=n[i],l=o.length,a,u=0;u<l;++u)if(a=o[u]){var c=qt(a,e);Ci(a,r,t,u,o,{time:c.time+c.delay+c.duration,delay:0,duration:c.duration,ease:c.ease})}return new ir(n,this._parents,r,t)}function ey(){var r,e,t=this,n=t._id,s=t.size();return new Promise(function(i,o){var l={value:o},a={value:function(){--s===0&&i()}};t.each(function(){var u=Jt(this,n),c=u.on;c!==r&&(e=(r=c).copy(),e._.cancel.push(l),e._.interrupt.push(l),e._.end.push(a)),u.on=e}),s===0&&i()})}var ty=0;function ir(r,e,t,n){this._groups=r,this._parents=e,this._name=t,this._id=n}function yd(){return++ty}var tr=ss.prototype;ir.prototype={constructor:ir,select:j2,selectAll:L2,selectChild:tr.selectChild,selectChildren:tr.selectChildren,filter:A2,merge:T2,selection:I2,transition:Z2,call:tr.call,nodes:tr.nodes,node:tr.node,size:tr.size,empty:tr.empty,each:tr.each,on:R2,attr:f2,attrTween:y2,style:U2,styleTween:V2,text:Y2,textTween:J2,remove:F2,tween:i2,delay:_2,duration:C2,ease:k2,easeVarying:D2,end:ey,[Symbol.iterator]:tr[Symbol.iterator]};function ry(r){return((r*=2)<=1?r*r*r:(r-=2)*r*r+2)/2}var ny={time:null,delay:0,duration:250,ease:ry};function sy(r,e){for(var t;!(t=r.__transition)||!(t=t[e]);)if(!(r=r.parentNode))throw new Error(`transition ${e} not found`);return t}function iy(r){var e,t;r instanceof ir?(e=r._id,r=r._name):(e=yd(),(t=ny).time=fa(),r=r==null?null:r+"");for(var n=this._groups,s=n.length,i=0;i<s;++i)for(var o=n[i],l=o.length,a,u=0;u<l;++u)(a=o[u])&&Ci(a,r,e,u,o,t||sy(a,e));return new ir(n,this._parents,r,e)}ss.prototype.interrupt=r2;ss.prototype.transition=iy;const bs=r=>()=>r;function oy(r,{sourceEvent:e,target:t,transform:n,dispatch:s}){Object.defineProperties(this,{type:{value:r,enumerable:!0,configurable:!0},sourceEvent:{value:e,enumerable:!0,configurable:!0},target:{value:t,enumerable:!0,configurable:!0},transform:{value:n,enumerable:!0,configurable:!0},_:{value:s}})}function nr(r,e,t){this.k=r,this.x=e,this.y=t}nr.prototype={constructor:nr,scale:function(r){return r===1?this:new nr(this.k*r,this.x,this.y)},translate:function(r,e){return r===0&e===0?this:new nr(this.k,this.x+this.k*r,this.y+this.k*e)},apply:function(r){return[r[0]*this.k+this.x,r[1]*this.k+this.y]},applyX:function(r){return r*this.k+this.x},applyY:function(r){return r*this.k+this.y},invert:function(r){return[(r[0]-this.x)/this.k,(r[1]-this.y)/this.k]},invertX:function(r){return(r-this.x)/this.k},invertY:function(r){return(r-this.y)/this.k},rescaleX:function(r){return r.copy().domain(r.range().map(this.invertX,this).map(r.invert,r))},rescaleY:function(r){return r.copy().domain(r.range().map(this.invertY,this).map(r.invert,r))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var ri=new nr(1,0,0);nr.prototype;function Wi(r){r.stopImmediatePropagation()}function xn(r){r.preventDefault(),r.stopImmediatePropagation()}function ay(r){return(!r.ctrlKey||r.type==="wheel")&&!r.button}function ly(){var r=this;return r instanceof SVGElement?(r=r.ownerSVGElement||r,r.hasAttribute("viewBox")?(r=r.viewBox.baseVal,[[r.x,r.y],[r.x+r.width,r.y+r.height]]):[[0,0],[r.width.baseVal.value,r.height.baseVal.value]]):[[0,0],[r.clientWidth,r.clientHeight]]}function tu(){return this.__zoom||ri}function uy(r){return-r.deltaY*(r.deltaMode===1?.05:r.deltaMode?1:.002)*(r.ctrlKey?10:1)}function cy(){return navigator.maxTouchPoints||"ontouchstart"in this}function dy(r,e,t){var n=r.invertX(e[0][0])-t[0][0],s=r.invertX(e[1][0])-t[1][0],i=r.invertY(e[0][1])-t[0][1],o=r.invertY(e[1][1])-t[1][1];return r.translate(s>n?(n+s)/2:Math.min(0,n)||Math.max(0,s),o>i?(i+o)/2:Math.min(0,i)||Math.max(0,o))}function fy(){var r=ay,e=ly,t=dy,n=uy,s=cy,i=[0,1/0],o=[[-1/0,-1/0],[1/0,1/0]],l=250,a=Km,u=la("start","zoom","end"),c,d,f,p=500,g=150,m=0,x=10;function _(k){k.property("__zoom",tu).on("wheel.zoom",E,{passive:!1}).on("mousedown.zoom",R).on("dblclick.zoom",T).filter(s).on("touchstart.zoom",N).on("touchmove.zoom",M).on("touchend.zoom touchcancel.zoom",j).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}_.transform=function(k,B,F,O){var V=k.selection?k.selection():k;V.property("__zoom",tu),k!==V?D(k,B,F,O):V.interrupt().each(function(){C(this,arguments).event(O).start().zoom(null,typeof B=="function"?B.apply(this,arguments):B).end()})},_.scaleBy=function(k,B,F,O){_.scaleTo(k,function(){var V=this.__zoom.k,U=typeof B=="function"?B.apply(this,arguments):B;return V*U},F,O)},_.scaleTo=function(k,B,F,O){_.transform(k,function(){var V=e.apply(this,arguments),U=this.__zoom,te=F==null?S(V):typeof F=="function"?F.apply(this,arguments):F,q=U.invert(te),X=typeof B=="function"?B.apply(this,arguments):B;return t(v(y(U,X),te,q),V,o)},F,O)},_.translateBy=function(k,B,F,O){_.transform(k,function(){return t(this.__zoom.translate(typeof B=="function"?B.apply(this,arguments):B,typeof F=="function"?F.apply(this,arguments):F),e.apply(this,arguments),o)},null,O)},_.translateTo=function(k,B,F,O,V){_.transform(k,function(){var U=e.apply(this,arguments),te=this.__zoom,q=O==null?S(U):typeof O=="function"?O.apply(this,arguments):O;return t(ri.translate(q[0],q[1]).scale(te.k).translate(typeof B=="function"?-B.apply(this,arguments):-B,typeof F=="function"?-F.apply(this,arguments):-F),U,o)},O,V)};function y(k,B){return B=Math.max(i[0],Math.min(i[1],B)),B===k.k?k:new nr(B,k.x,k.y)}function v(k,B,F){var O=B[0]-F[0]*k.k,V=B[1]-F[1]*k.k;return O===k.x&&V===k.y?k:new nr(k.k,O,V)}function S(k){return[(+k[0][0]+ +k[1][0])/2,(+k[0][1]+ +k[1][1])/2]}function D(k,B,F,O){k.on("start.zoom",function(){C(this,arguments).event(O).start()}).on("interrupt.zoom end.zoom",function(){C(this,arguments).event(O).end()}).tween("zoom",function(){var V=this,U=arguments,te=C(V,U).event(O),q=e.apply(V,U),X=F==null?S(q):typeof F=="function"?F.apply(V,U):F,W=Math.max(q[1][0]-q[0][0],q[1][1]-q[0][1]),se=V.__zoom,ue=typeof B=="function"?B.apply(V,U):B,de=a(se.invert(X).concat(W/se.k),ue.invert(X).concat(W/ue.k));return function(pe){if(pe===1)pe=ue;else{var De=de(pe),xe=W/De[2];pe=new nr(xe,X[0]-De[0]*xe,X[1]-De[1]*xe)}te.zoom(null,pe)}})}function C(k,B,F){return!F&&k.__zooming||new w(k,B)}function w(k,B){this.that=k,this.args=B,this.active=0,this.sourceEvent=null,this.extent=e.apply(k,B),this.taps=0}w.prototype={event:function(k){return k&&(this.sourceEvent=k),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(k,B){return this.mouse&&k!=="mouse"&&(this.mouse[1]=B.invert(this.mouse[0])),this.touch0&&k!=="touch"&&(this.touch0[1]=B.invert(this.touch0[0])),this.touch1&&k!=="touch"&&(this.touch1[1]=B.invert(this.touch1[0])),this.that.__zoom=B,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(k){var B=Lt(this.that).datum();u.call(k,this.that,new oy(k,{sourceEvent:this.sourceEvent,target:_,transform:this.that.__zoom,dispatch:u}),B)}};function E(k,...B){if(!r.apply(this,arguments))return;var F=C(this,B).event(k),O=this.__zoom,V=Math.max(i[0],Math.min(i[1],O.k*Math.pow(2,n.apply(this,arguments)))),U=wr(k);if(F.wheel)(F.mouse[0][0]!==U[0]||F.mouse[0][1]!==U[1])&&(F.mouse[1]=O.invert(F.mouse[0]=U)),clearTimeout(F.wheel);else{if(O.k===V)return;F.mouse=[U,O.invert(U)],Es(this),F.start()}xn(k),F.wheel=setTimeout(te,g),F.zoom("mouse",t(v(y(O,V),F.mouse[0],F.mouse[1]),F.extent,o));function te(){F.wheel=null,F.end()}}function R(k,...B){if(f||!r.apply(this,arguments))return;var F=k.currentTarget,O=C(this,B,!0).event(k),V=Lt(k.view).on("mousemove.zoom",X,!0).on("mouseup.zoom",W,!0),U=wr(k,F),te=k.clientX,q=k.clientY;vm(k.view),Wi(k),O.mouse=[U,this.__zoom.invert(U)],Es(this),O.start();function X(se){if(xn(se),!O.moved){var ue=se.clientX-te,de=se.clientY-q;O.moved=ue*ue+de*de>m}O.event(se).zoom("mouse",t(v(O.that.__zoom,O.mouse[0]=wr(se,F),O.mouse[1]),O.extent,o))}function W(se){V.on("mousemove.zoom mouseup.zoom",null),wm(se.view,O.moved),xn(se),O.event(se).end()}}function T(k,...B){if(r.apply(this,arguments)){var F=this.__zoom,O=wr(k.changedTouches?k.changedTouches[0]:k,this),V=F.invert(O),U=F.k*(k.shiftKey?.5:2),te=t(v(y(F,U),O,V),e.apply(this,B),o);xn(k),l>0?Lt(this).transition().duration(l).call(D,te,O,k):Lt(this).call(_.transform,te,O,k)}}function N(k,...B){if(r.apply(this,arguments)){var F=k.touches,O=F.length,V=C(this,B,k.changedTouches.length===O).event(k),U,te,q,X;for(Wi(k),te=0;te<O;++te)q=F[te],X=wr(q,this),X=[X,this.__zoom.invert(X),q.identifier],V.touch0?!V.touch1&&V.touch0[2]!==X[2]&&(V.touch1=X,V.taps=0):(V.touch0=X,U=!0,V.taps=1+!!c);c&&(c=clearTimeout(c)),U&&(V.taps<2&&(d=X[0],c=setTimeout(function(){c=null},p)),Es(this),V.start())}}function M(k,...B){if(this.__zooming){var F=C(this,B).event(k),O=k.changedTouches,V=O.length,U,te,q,X;for(xn(k),U=0;U<V;++U)te=O[U],q=wr(te,this),F.touch0&&F.touch0[2]===te.identifier?F.touch0[0]=q:F.touch1&&F.touch1[2]===te.identifier&&(F.touch1[0]=q);if(te=F.that.__zoom,F.touch1){var W=F.touch0[0],se=F.touch0[1],ue=F.touch1[0],de=F.touch1[1],pe=(pe=ue[0]-W[0])*pe+(pe=ue[1]-W[1])*pe,De=(De=de[0]-se[0])*De+(De=de[1]-se[1])*De;te=y(te,Math.sqrt(pe/De)),q=[(W[0]+ue[0])/2,(W[1]+ue[1])/2],X=[(se[0]+de[0])/2,(se[1]+de[1])/2]}else if(F.touch0)q=F.touch0[0],X=F.touch0[1];else return;F.zoom("touch",t(v(te,q,X),F.extent,o))}}function j(k,...B){if(this.__zooming){var F=C(this,B).event(k),O=k.changedTouches,V=O.length,U,te;for(Wi(k),f&&clearTimeout(f),f=setTimeout(function(){f=null},p),U=0;U<V;++U)te=O[U],F.touch0&&F.touch0[2]===te.identifier?delete F.touch0:F.touch1&&F.touch1[2]===te.identifier&&delete F.touch1;if(F.touch1&&!F.touch0&&(F.touch0=F.touch1,delete F.touch1),F.touch0)F.touch0[1]=this.__zoom.invert(F.touch0[0]);else if(F.end(),F.taps===2&&(te=wr(te,this),Math.hypot(d[0]-te[0],d[1]-te[1])<x)){var q=Lt(this).on("dblclick.zoom");q&&q.apply(this,arguments)}}}return _.wheelDelta=function(k){return arguments.length?(n=typeof k=="function"?k:bs(+k),_):n},_.filter=function(k){return arguments.length?(r=typeof k=="function"?k:bs(!!k),_):r},_.touchable=function(k){return arguments.length?(s=typeof k=="function"?k:bs(!!k),_):s},_.extent=function(k){return arguments.length?(e=typeof k=="function"?k:bs([[+k[0][0],+k[0][1]],[+k[1][0],+k[1][1]]]),_):e},_.scaleExtent=function(k){return arguments.length?(i[0]=+k[0],i[1]=+k[1],_):[i[0],i[1]]},_.translateExtent=function(k){return arguments.length?(o[0][0]=+k[0][0],o[1][0]=+k[1][0],o[0][1]=+k[0][1],o[1][1]=+k[1][1],_):[[o[0][0],o[0][1]],[o[1][0],o[1][1]]]},_.constrain=function(k){return arguments.length?(t=k,_):t},_.duration=function(k){return arguments.length?(l=+k,_):l},_.interpolate=function(k){return arguments.length?(a=k,_):a},_.on=function(){var k=u.on.apply(u,arguments);return k===u?_:k},_.clickDistance=function(k){return arguments.length?(m=(k=+k)*k,_):Math.sqrt(m)},_.tapDistance=function(k){return arguments.length?(x=+k,_):x},_}function xd(r={}){const{minZoom:e=.1,maxZoom:t=4,initialTransform:n,zoomable:s=!0,pannable:i=!0,onTransformChange:o}=r,l=b.useRef(null),a=b.useRef(),[u,c]=b.useState(n||{x:0,y:0,k:1});b.useEffect(()=>{if(!l.current)return;const x=fy().scaleExtent([e,t]).filter(y=>!s&&y.type==="wheel"||!i&&(y.type==="mousedown"||y.type==="touchstart")?!1:y.type==="wheel"?s:y.type==="mousedown"||y.type==="touchstart"?y.target.closest("[data-qmap-node]")?!1:i:!0).on("zoom",y=>{const v={x:y.transform.x,y:y.transform.y,k:y.transform.k};c(v),o==null||o(v)});a.current=x;const _=Lt(l.current);return _.call(x),_.on("dblclick.zoom",null),n&&_.call(x.transform,ri.translate(n.x,n.y).scale(n.k)),()=>{_.on(".zoom",null)}},[e,t,s,i]),b.useEffect(()=>{a.current&&a.current.on("zoom",x=>{const _={x:x.transform.x,y:x.transform.y,k:x.transform.k};c(_),o==null||o(_)})},[o]);const d=b.useCallback((x,_,y,v=!0)=>{if(!l.current||!a.current)return;const S=Lt(l.current),D=ri.translate(x,_).scale(y);S.call(a.current.transform,D)},[]),f=b.useCallback(()=>{!l.current||!a.current||Lt(l.current).call(a.current.scaleBy,1.3)},[]),p=b.useCallback(()=>{!l.current||!a.current||Lt(l.current).call(a.current.scaleBy,.7)},[]),g=b.useCallback(()=>{d(0,0,1,!0)},[d]),m=b.useCallback((x,_=50)=>{if(!l.current||!a.current||x.length===0)return;const v=l.current.getBoundingClientRect();let S=1/0,D=1/0,C=-1/0,w=-1/0;for(const O of x){const V=O.width||200,U=O.height||100;S=Math.min(S,O.x),D=Math.min(D,O.y),C=Math.max(C,O.x+V),w=Math.max(w,O.y+U)}const E=C-S,R=w-D,T=(v.width-_*2)/E,N=(v.height-_*2)/R,M=Math.min(T,N,t),j=(S+C)/2,k=(D+w)/2,B=v.width/2-j*M,F=v.height/2-k*M;d(B,F,M,!0)},[t,d]);return{transform:u,containerRef:l,zoomTo:d,zoomIn:f,zoomOut:p,resetZoom:g,fitToContent:m}}function bd(r){const{transform:e,onDragStart:t,onDragMove:n,onDragEnd:s,disabled:i=!1}=r,[o,l]=b.useState(null),[a,u]=b.useState(!1),[c,d]=b.useState({x:0,y:0}),f=b.useRef(null),p=b.useRef({x:0,y:0}),g=b.useRef(e);b.useEffect(()=>{g.current=e},[e]);const m=b.useCallback((v,S)=>{const D=g.current;return{x:(v-D.x)/D.k,y:(S-D.y)/D.k}},[]),x=b.useCallback((v,S)=>{if(i)return;S.preventDefault(),S.stopPropagation();const D=S.currentTarget,C=parseFloat(D.dataset.x||"0"),w=parseFloat(D.dataset.y||"0");f.current={x:S.clientX,y:S.clientY,nodeX:C,nodeY:w},p.current={x:C,y:w},l(v),u(!0),d({x:0,y:0}),t==null||t(v)},[i,m,t]),_=b.useCallback(v=>{if(!a||!o||!f.current)return;const S=g.current,D=f.current,C=v.clientX-D.x,w=v.clientY-D.y,E=C/S.k,R=w/S.k,T=D.nodeX+E,N=D.nodeY+R;p.current={x:T,y:N},d({x:E,y:R}),n==null||n(o,T,N,E,R)},[a,o,n]),y=b.useCallback(()=>{if(!a||!o)return;const v=p.current;s==null||s(o,v.x,v.y),l(null),u(!1),d({x:0,y:0}),f.current=null},[a,o,s]);return b.useEffect(()=>{if(!a)return;const v=D=>{_(D)},S=()=>{y()};return window.addEventListener("mousemove",v),window.addEventListener("mouseup",S),()=>{window.removeEventListener("mousemove",v),window.removeEventListener("mouseup",S)}},[a,_,y]),{draggedNodeId:o,isDragging:a,dragOffset:c,startDrag:x,updateDrag:_,endDrag:y}}function _d(r){const{transform:e,nodePositions:t,disabled:n=!1,controlledSelectedIds:s,onSelectionChange:i}=r,[o,l]=b.useState(new Set),a=s!==void 0,u=a?new Set(s):o,c=a?T=>{const N=typeof T=="function"?T(u):T;i==null||i(Array.from(N))}:l,[d,f]=b.useState(null),[p,g]=b.useState(!1),m=b.useRef(null),x=b.useRef(e),_=b.useRef(t);b.useEffect(()=>{x.current=e},[e]),b.useEffect(()=>{_.current=t},[t]);const y=b.useCallback((T,N)=>{const M=x.current;return{x:(T-M.x)/M.k,y:(N-M.y)/M.k}},[]),v=b.useCallback((T,N)=>{const M=_.current.get(T);if(!M)return!1;const j=M.width||200,k=M.height||100;return M.x<N.x+N.width&&M.x+j>N.x&&M.y<N.y+N.height&&M.y+k>N.y},[]),S=b.useCallback(T=>{if(n||T.target.closest("[data-qmap-node]"))return;T.preventDefault();const M=y(T.clientX,T.clientY);m.current=M,f({x:M.x,y:M.y,width:0,height:0}),g(!0),T.shiftKey||c(new Set)},[n,y]),D=b.useCallback(T=>{if(!p||!m.current)return;const N=m.current,M=y(T.clientX,T.clientY),j={x:Math.min(N.x,M.x),y:Math.min(N.y,M.y),width:Math.abs(M.x-N.x),height:Math.abs(M.y-N.y)};f(j);const k=new Set;for(const[B]of _.current)v(B,j)&&k.add(B);c(k)},[p,y,v]),C=b.useCallback(()=>{p&&(i==null||i(Array.from(u)),g(!1),f(null),m.current=null)},[p,u,i]);b.useEffect(()=>{if(!p)return;const T=M=>{D(M)},N=()=>{C()};return window.addEventListener("mousemove",T),window.addEventListener("mouseup",N),()=>{window.removeEventListener("mousemove",T),window.removeEventListener("mouseup",N)}},[p,D,C]);const w=b.useCallback((T,N=!1)=>{c(M=>{const j=new Set(N?M:[]);return M.has(T)&&N?j.delete(T):j.add(T),i==null||i(Array.from(j)),j})},[i]),E=b.useCallback(()=>{const T=new Set(_.current.keys());c(T),i==null||i(Array.from(T))},[i]),R=b.useCallback(()=>{c(new Set),i==null||i([])},[i]);return{selectedIds:u,setSelectedIds:c,selectionBox:d,isSelecting:p,startSelection:S,updateSelection:D,endSelection:C,toggleSelect:w,selectAll:E,clearSelection:R}}const vd=b.memo(function({nodeId:e,position:t,isSelected:n,isDragging:s,draggable:i,onDragStart:o,onClick:l,onDoubleClick:a,onContextMenu:u,children:c}){const d=b.useCallback(y=>{i&&y.button===0&&o(e,y)},[e,i,o]),f=b.useCallback(y=>{s||l==null||l(y)},[s,l]),p=b.useCallback(y=>{y.stopPropagation(),a==null||a(y)},[a]),g=b.useCallback(y=>{y.preventDefault(),y.stopPropagation(),u==null||u(y)},[u]),m=t.width||200,x=t.height||100,_=t.rotation||0;return h.jsx("div",{"data-qmap-node":e,"data-x":t.x,"data-y":t.y,style:{position:"absolute",left:t.x,top:t.y,width:m,height:x,transform:_!==0?`rotate(${_}deg)`:void 0,transformOrigin:"center center",cursor:i?s?"grabbing":"grab":"pointer",userSelect:"none",opacity:s?.8:1,zIndex:s?1e3:n?100:1,WebkitUserSelect:"none",MozUserSelect:"none",msUserSelect:"none"},onMouseDown:d,onClick:f,onDoubleClick:p,onContextMenu:g,children:c})},(r,e)=>r.nodeId===e.nodeId&&r.position.x===e.position.x&&r.position.y===e.position.y&&r.position.width===e.position.width&&r.position.height===e.position.height&&r.position.rotation===e.position.rotation&&r.isSelected===e.isSelected&&r.isDragging===e.isDragging&&r.draggable===e.draggable&&r.children===e.children);function wd(r,e,t="bezier"){const n={x:r.x,y:r.y},s={x:e.x,y:e.y};switch(t){case"straight":return`M ${n.x} ${n.y} L ${s.x} ${s.y}`;case"orthogonal":return py(n,s);case"bezier":default:return hy(n,s)}}function hy(r,e){const t=e.x-r.x,n=e.y-r.y,s=Math.sqrt(t*t+n*n),i=Math.min(s*.4,150),o=Math.abs(t)>Math.abs(n);let l,a,u,c;return o?(l=r.x+i*Math.sign(t),a=r.y,u=e.x-i*Math.sign(t),c=e.y):(l=r.x,a=r.y+i*Math.sign(n),u=e.x,c=e.y-i*Math.sign(n)),`M ${r.x} ${r.y} C ${l} ${a}, ${u} ${c}, ${e.x} ${e.y}`}function py(r,e){const t=e.x-r.x,n=e.y-r.y;if(Math.abs(t)>Math.abs(n)){const i=r.x+t/2;return`M ${r.x} ${r.y} H ${i} V ${e.y} H ${e.x}`}else{const i=r.y+n/2;return`M ${r.x} ${r.y} V ${i} H ${e.x} V ${e.y}`}}function ga(r){const e=r.width||200,t=r.height||100;return{x:r.x+e/2,y:r.y+t/2}}function gy(r,e){const t=r.width||200,n=r.height||100,s=ga(r),i=e.x-s.x,o=e.y-s.y;if(i===0&&o===0)return s;const l=t/2,a=n/2,u=Math.abs(o/(i||.001)),c=a/l;let d,f;return u<c?(d=s.x+(i>0?l:-l),f=s.y+o*l/Math.abs(i)):(f=s.y+(o>0?a:-a),d=s.x+i*a/Math.abs(o)),{x:d,y:f}}function my(r,e){const t=r.width||200,n=r.height||100;switch(e){case"left":return{x:r.x,y:r.y+n/2};case"right":return{x:r.x+t,y:r.y+n/2};case"top":return{x:r.x+t/2,y:r.y};case"bottom":return{x:r.x+t/2,y:r.y+n};case"center":default:return ga(r)}}function yy(r,e){return r.x>=e.x&&r.x<=e.x+e.width&&r.y>=e.y&&r.y<=e.y+e.height}function xy(r,e){return r.x<e.x+e.width&&r.x+r.width>e.x&&r.y<e.y+e.height&&r.y+r.height>e.y}function by(r){if(r.length===0)return null;let e=1/0,t=1/0,n=-1/0,s=-1/0;for(const i of r){const o=i.width||200,l=i.height||100;e=Math.min(e,i.x),t=Math.min(t,i.y),n=Math.max(n,i.x+o),s=Math.max(s,i.y+l)}return{x:e,y:t,width:n-e,height:s-t}}function _y(r,e){const t=e.x-r.x,n=e.y-r.y;return Math.sqrt(t*t+n*n)}function vy(r,e){const t=e.x-r.x,n=e.y-r.y;return t*t+n*n}const Cd=b.memo(function({edge:e,sourcePosition:t,targetPosition:n,style:s,color:i,width:o,onClick:l}){const[a,u]=b.useState(!1),c=b.useMemo(()=>wd(t,n,s),[t,n,s]),d=b.useCallback(x=>{x.stopPropagation(),l==null||l(e,x)},[e,l]),f=b.useCallback(()=>{u(!0)},[]),p=b.useCallback(()=>{u(!1)},[]),g=e.color||i,m=e.width||o;return h.jsxs("g",{children:[h.jsx("path",{d:c,fill:"none",stroke:"transparent",strokeWidth:Math.max(m*3,10),style:{cursor:l?"pointer":"default",pointerEvents:"stroke"},onClick:d,onMouseEnter:f,onMouseLeave:p}),h.jsx("path",{d:c,fill:"none",stroke:g,strokeWidth:a?m*1.5:m,strokeLinecap:"round",strokeLinejoin:"round",style:{pointerEvents:"none",transition:"stroke-width 0.15s ease"}}),e.label&&h.jsx(wy,{pathD:c,label:e.label,color:g})]})},(r,e)=>r.edge.id===e.edge.id&&r.sourcePosition.x===e.sourcePosition.x&&r.sourcePosition.y===e.sourcePosition.y&&r.sourcePosition.width===e.sourcePosition.width&&r.sourcePosition.height===e.sourcePosition.height&&r.targetPosition.x===e.targetPosition.x&&r.targetPosition.y===e.targetPosition.y&&r.targetPosition.width===e.targetPosition.width&&r.targetPosition.height===e.targetPosition.height&&r.style===e.style&&r.color===e.color&&r.width===e.width&&r.edge.label===e.edge.label&&r.edge.color===e.edge.color&&r.edge.width===e.edge.width);function wy({pathD:r,label:e,color:t}){const n=b.useMemo(()=>`edge-label-${Math.random().toString(36).substr(2,9)}`,[]);return h.jsxs(h.Fragment,{children:[h.jsx("defs",{children:h.jsx("path",{id:n,d:r})}),h.jsx("text",{fill:t,fontSize:"12",fontFamily:"system-ui, sans-serif",style:{pointerEvents:"none"},children:h.jsx("textPath",{href:`#${n}`,startOffset:"50%",textAnchor:"middle",children:e})})]})}const Sd=b.memo(function({edges:e,nodePositions:t,defaultStyle:n,defaultColor:s,defaultWidth:i,onEdgeClick:o}){const l=b.useMemo(()=>e.filter(a=>t.has(a.source)&&t.has(a.target)),[e,t]);return h.jsx("svg",{style:{position:"absolute",top:0,left:0,width:1,height:1,overflow:"visible",pointerEvents:"none"},children:h.jsx("g",{style:{pointerEvents:"auto"},children:l.map(a=>{const u=t.get(a.source),c=t.get(a.target);return h.jsx(Cd,{edge:a,sourcePosition:u,targetPosition:c,style:a.style||n,color:a.color||s,width:a.width||i,onClick:o},a.id)})})})},(r,e)=>!(r.edges!==e.edges||r.nodePositions!==e.nodePositions||r.defaultStyle!==e.defaultStyle||r.defaultColor!==e.defaultColor||r.defaultWidth!==e.defaultWidth)),kd=b.memo(function({box:e,transform:t}){const n=b.useMemo(()=>({x:e.x*t.k+t.x,y:e.y*t.k+t.y,width:e.width*t.k,height:e.height*t.k}),[e,t]);return h.jsx("div",{style:{position:"absolute",left:n.x,top:n.y,width:n.width,height:n.height,backgroundColor:"rgba(59, 130, 246, 0.1)",border:"1px solid rgba(59, 130, 246, 0.5)",borderRadius:2,pointerEvents:"none",zIndex:9999}})}),Cy=200,Sy=100,ky="bezier",Ey="#94a3b8",Dy=2,Ay=.1,Ty=4;function Ny({viewNode:r,nodes:e,edges:t,renderNode:n,defaultNodeWidth:s=Cy,defaultNodeHeight:i=Sy,onNodeMove:o,onNodeClick:l,onNodeDoubleClick:a,onNodeContextMenu:u,selectedIds:c,onSelectionChange:d,onEdgeClick:f,onViewChange:p,onTransformChange:g,minZoom:m=Ay,maxZoom:x=Ty,initialTransform:_,defaultEdgeStyle:y=ky,defaultEdgeColor:v=Ey,defaultEdgeWidth:S=Dy,draggable:D=!0,selectable:C=!0,zoomable:w=!0,pannable:E=!0,className:R="",style:T,background:N="#f8fafc",showGrid:M=!1,gridSize:j=20}){const k=r.data||{positions:{}},B=k.positions||{},F=b.useMemo(()=>{const Y=new Map;for(const P of e){const me=B[P._id]||{x:0,y:0};Y.set(P._id,{x:me.x,y:me.y,width:me.width||s,height:me.height||i,rotation:me.rotation||0})}return Y},[e,B,s,i]),{transform:O,containerRef:V,zoomIn:U,zoomOut:te,resetZoom:q,fitToContent:X}=xd({minZoom:m,maxZoom:x,initialTransform:_||k.transform,zoomable:w,pannable:E,onTransformChange:Y=>{g==null||g(Y);const P={...k,transform:Y};p==null||p(P)}}),[W,se]=b.useState(new Map),{draggedNodeId:ue,startDrag:de}=bd({transform:O,disabled:!D,onDragStart:Y=>{const P=F.get(Y);P&&se(new Map([[Y,{x:P.x,y:P.y}]]))},onDragMove:(Y,P,me)=>{se(new Map([[Y,{x:P,y:me}]]))},onDragEnd:(Y,P,me)=>{se(new Map),o==null||o(Y,P,me)}}),{selectedIds:pe,selectionBox:De,isSelecting:xe,startSelection:J,toggleSelect:Ce,clearSelection:ne}=_d({transform:O,nodePositions:F,disabled:!C,controlledSelectedIds:c,onSelectionChange:d}),Be=b.useCallback(Y=>{const P=F.get(Y)||{x:0,y:0,width:s,height:i},me=W.get(Y);return me?{...P,x:me.x,y:me.y}:P},[F,W,s,i]),Se=b.useMemo(()=>{const Y=new Map;for(const P of F.keys())Y.set(P,Be(P));return Y},[F,Be]),ke=b.useCallback((Y,P)=>{Ce(Y._id,P.shiftKey),l==null||l(Y,P)},[Ce,l]),Ie=b.useCallback(Y=>{Y.target.closest("[data-qmap-node]")||ne()},[ne]),Le=b.useCallback(Y=>{Y.button===0&&(Y.target.closest("[data-qmap-node]")||J(Y))},[J]),$e=M?`
|
|
185
|
+
${y}`:y)},x=async y=>{if(!(!e.trim()||a||!s)){u(!0),d(y),p(!1);try{const v=await s(y,e);t(v)}catch(v){console.error(`${y} failed:`,v)}finally{u(!1),d(null)}}},_=()=>{setTimeout(()=>{var y;(y=g.current)!=null&&y.contains(document.activeElement)||p(!1)},150)};return h.jsxs("div",{className:`flex flex-col flex-1 min-h-0 ${o}`,children:[h.jsx(Vc,{onComplete:()=>{},onTranscribe:n,onTranscriptionComplete:m,hideSaveButton:!0,variant:"div"}),h.jsxs("div",{className:"flex items-center justify-between mt-3 mb-1",children:[h.jsx("label",{className:"text-sm font-medium text-neutral-700",children:r}),h.jsxs("div",{className:"flex items-center gap-1",children:[e.trim()&&h.jsx("button",{type:"button",onClick:()=>navigator.clipboard.writeText(e),className:"p-1 rounded hover:bg-neutral-100 transition-colors",title:"Copy to clipboard",children:h.jsx("span",{className:"material-icons text-neutral-500",style:{fontSize:"16px"},children:"content_copy"})}),s&&h.jsxs("div",{className:"relative",ref:g,children:[h.jsx("button",{type:"button",onClick:()=>p(!f),disabled:a||!e.trim(),className:"flex items-center gap-1 text-xs text-purple-600 hover:text-purple-700 disabled:opacity-40 disabled:hover:text-purple-600 px-2 py-1 rounded hover:bg-purple-50 transition-colors",children:a?h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"material-icons text-sm animate-spin",children:"hourglass_empty"}),c==="restructure"&&"Restructuring...",c==="proofread"&&"Proofreading...",c==="rewrite"&&"Rewriting..."]}):h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"material-icons text-sm",children:"auto_fix_high"}),"AI",h.jsx("span",{className:"material-icons text-sm",children:"expand_more"})]})}),f&&!a&&h.jsxs("div",{className:"absolute right-0 top-full mt-1 bg-white border border-neutral-200 rounded-lg shadow-lg z-50 min-w-[180px] py-1",onBlur:_,children:[h.jsxs("button",{type:"button",onClick:()=>x("restructure"),className:"w-full px-3 py-2 text-left text-sm hover:bg-neutral-50 flex items-center gap-2",children:[h.jsx("span",{className:"material-icons text-base text-blue-500",children:"format_list_bulleted"}),h.jsxs("div",{children:[h.jsx("div",{className:"font-medium",children:"Restructure"}),h.jsx("div",{className:"text-xs text-neutral-500",children:"Organize & clarify"})]})]}),h.jsxs("button",{type:"button",onClick:()=>x("proofread"),className:"w-full px-3 py-2 text-left text-sm hover:bg-neutral-50 flex items-center gap-2",children:[h.jsx("span",{className:"material-icons text-base text-green-500",children:"spellcheck"}),h.jsxs("div",{children:[h.jsx("div",{className:"font-medium",children:"Proofread"}),h.jsx("div",{className:"text-xs text-neutral-500",children:"Fix grammar & spelling"})]})]}),h.jsxs("button",{type:"button",onClick:()=>x("rewrite"),className:"w-full px-3 py-2 text-left text-sm hover:bg-neutral-50 flex items-center gap-2",children:[h.jsx("span",{className:"material-icons text-base text-purple-500",children:"brush"}),h.jsxs("div",{children:[h.jsx("div",{className:"font-medium",children:"Rewrite"}),h.jsx("div",{className:"text-xs text-neutral-500",children:"Your voice & style"})]})]})]})]})]})]}),h.jsx("textarea",{value:e,onChange:y=>t(y.target.value),onKeyDown:y=>y.stopPropagation(),placeholder:i,rows:l,disabled:a,className:"flex-1 w-full px-3 py-2 border border-neutral-300 rounded-lg focus:ring-2 focus:ring-neutral-900 text-sm disabled:opacity-50 disabled:bg-neutral-50 resize-none"})]})}const gs={"4/3":4/3,"16/9":16/9,"1/1":1,"3/4":3/4,"9/16":9/16,free:null};function Ig({src:r,onSave:e,onCancel:t,aspectRatio:n="4/3",outputFormat:s="image/jpeg",outputQuality:i=.9,theme:o="dark"}){const l=b.useRef(null),a=b.useRef(null),u=b.useRef(null),[c,d]=b.useState(!0),[f,p]=b.useState(null),[g,m]=b.useState(n),[x,_]=b.useState(0),[y,v]=b.useState({x:0,y:0,width:100,height:100}),[S,D]=b.useState(!1),[C,w]=b.useState(null),[E,R]=b.useState({x:0,y:0}),[T,N]=b.useState({x:0,y:0,width:100,height:100}),M=o==="dark",j=b.useCallback(()=>{const J=u.current;return J?x===90||x===270?{width:J.height,height:J.width}:{width:J.width,height:J.height}:{width:100,height:100}},[x]),k=b.useCallback((J,Ce)=>{const ne=J/Ce,Be=.05;for(const[Se,ke]of Object.entries(gs))if(ke!==null&&Math.abs(ne-ke)/ke<Be)return Se;return"free"},[]);b.useEffect(()=>{const J=new Image;J.crossOrigin="anonymous",J.onload=()=>{u.current=J;const Ce=k(J.width,J.height);m(Ce),d(!1)},J.onerror=()=>{p("Failed to load image"),d(!1)},J.src=r},[r,k]);const B=b.useCallback(()=>{const{width:J,height:Ce}=j(),ne=gs[g];if(ne===null){v({x:0,y:0,width:100,height:100});return}const Be=J/Ce;let Se,ke;Be>ne?(ke=100,Se=ne/Be*100):(Se=100,ke=Be/ne*100);const Ie=(100-Se)/2,Le=(100-ke)/2;v({x:Ie,y:Le,width:Se,height:ke})},[g,j]);b.useEffect(()=>{u.current&&B()},[g,x,B]),b.useEffect(()=>{const J=a.current,Ce=u.current;if(!J||!Ce||c)return;const ne=J.getContext("2d");if(!ne)return;const Be=l.current;if(!Be)return;const Se=Be.clientWidth,ke=Be.clientHeight-140,{width:Ie,height:Le}=j(),$e=Ie/Le;let Y,P;Se/ke>$e?(P=Math.min(ke,Le),Y=P*$e):(Y=Math.min(Se,Ie),P=Y/$e),Y>Se&&(Y=Se,P=Y/$e),P>ke&&(P=ke,Y=P*$e),J.width=Y,J.height=P,ne.clearRect(0,0,Y,P),ne.save(),ne.translate(Y/2,P/2),ne.rotate(x*Math.PI/180);let me,We;x===90||x===270?(me=P,We=Y):(me=Y,We=P),ne.drawImage(Ce,-me/2,-We/2,me,We),ne.restore(),ne.fillStyle="rgba(0, 0, 0, 0.6)";const z=y.x/100*Y,ae=y.y/100*P,ge=y.width/100*Y,ye=y.height/100*P;ne.fillRect(0,0,Y,ae),ne.fillRect(0,ae+ye,Y,P-ae-ye),ne.fillRect(0,ae,z,ye),ne.fillRect(z+ge,ae,Y-z-ge,ye),ne.strokeStyle="#fff",ne.lineWidth=2,ne.strokeRect(z,ae,ge,ye),ne.strokeStyle="rgba(255, 255, 255, 0.3)",ne.lineWidth=1,ne.beginPath(),ne.moveTo(z+ge/3,ae),ne.lineTo(z+ge/3,ae+ye),ne.moveTo(z+ge*2/3,ae),ne.lineTo(z+ge*2/3,ae+ye),ne.moveTo(z,ae+ye/3),ne.lineTo(z+ge,ae+ye/3),ne.moveTo(z,ae+ye*2/3),ne.lineTo(z+ge,ae+ye*2/3),ne.stroke();const Ue=14;ne.fillStyle="#fff",ne.strokeStyle="#333",ne.lineWidth=1,[{x:z,y:ae},{x:z+ge,y:ae},{x:z,y:ae+ye},{x:z+ge,y:ae+ye}].forEach(yt=>{ne.fillRect(yt.x-Ue/2,yt.y-Ue/2,Ue,Ue),ne.strokeRect(yt.x-Ue/2,yt.y-Ue/2,Ue,Ue)})},[y,x,c,j]);const F=J=>{const Ce=a.current;if(!Ce)return;const ne=Ce.getBoundingClientRect(),Be=(J.clientX-ne.left)/ne.width*100,Se=(J.clientY-ne.top)/ne.height*100,ke=4,Ie=[{name:"nw",x:y.x,y:y.y},{name:"ne",x:y.x+y.width,y:y.y},{name:"sw",x:y.x,y:y.y+y.height},{name:"se",x:y.x+y.width,y:y.y+y.height}];for(const Le of Ie)if(Math.abs(Be-Le.x)<ke&&Math.abs(Se-Le.y)<ke){w(Le.name),R({x:Be,y:Se}),N({...y});return}Be>=y.x&&Be<=y.x+y.width&&Se>=y.y&&Se<=y.y+y.height&&(D(!0),R({x:Be,y:Se}),N({...y}))},O=J=>{const Ce=a.current;if(!Ce)return;const ne=Ce.getBoundingClientRect(),Be=(J.clientX-ne.left)/ne.width*100,Se=(J.clientY-ne.top)/ne.height*100;if(S){const ke=Be-E.x,Ie=Se-E.y;let Le=T.x+ke,$e=T.y+Ie;Le=Math.max(0,Math.min(Le,100-T.width)),$e=Math.max(0,Math.min($e,100-T.height)),v({...T,x:Le,y:$e})}else if(C){const ke=gs[g],{width:Ie,height:Le}=j(),$e=Ie/Le,Y=ke?ke/$e:null;let P={...T};const me=Be-E.x,We=Se-E.y;if(C==="se")P.width=Math.max(10,Math.min(100-P.x,T.width+me)),Y?(P.height=P.width/Y,P.y+P.height>100&&(P.height=100-P.y,P.width=P.height*Y)):P.height=Math.max(10,Math.min(100-P.y,T.height+We));else if(C==="sw"){const z=-me,ae=Math.max(10,T.width+z),ge=T.x+T.width-ae;ge>=0&&(P.width=ae,P.x=ge,Y?(P.height=P.width/Y,P.y+P.height>100&&(P.height=100-P.y,P.width=P.height*Y,P.x=T.x+T.width-P.width)):P.height=Math.max(10,Math.min(100-P.y,T.height+We)))}else if(C==="ne")if(P.width=Math.max(10,Math.min(100-P.x,T.width+me)),Y){const z=P.width/Y,ae=T.y+T.height-z;ae>=0?(P.height=z,P.y=ae):(P.y=0,P.height=T.y+T.height,P.width=P.height*Y)}else{const z=-We,ae=Math.max(10,T.height+z),ge=T.y+T.height-ae;ge>=0&&(P.height=ae,P.y=ge)}else if(C==="nw"){const z=-me,ae=Math.max(10,T.width+z),ge=T.x+T.width-ae;if(ge>=0)if(P.width=ae,P.x=ge,Y){const ye=P.width/Y,Ue=T.y+T.height-ye;Ue>=0?(P.height=ye,P.y=Ue):(P.y=0,P.height=T.y+T.height,P.width=P.height*Y,P.x=T.x+T.width-P.width)}else{const ye=-We,Ue=Math.max(10,T.height+ye),mt=T.y+T.height-Ue;mt>=0&&(P.height=Ue,P.y=mt)}}P.x=Math.max(0,P.x),P.y=Math.max(0,P.y),P.width=Math.min(P.width,100-P.x),P.height=Math.min(P.height,100-P.y),v(P)}},V=()=>{D(!1),w(null)},U=J=>{_(Ce=>J==="right"?(Ce+90)%360:(Ce-90+360)%360)},te=()=>{const J=u.current;if(!J)return;const{width:Ce,height:ne}=j(),Be=y.x/100*Ce,Se=y.y/100*ne,ke=y.width/100*Ce,Ie=y.height/100*ne,Le=document.createElement("canvas"),$e=Le.getContext("2d");if(!$e)return;Le.width=ke,Le.height=Ie;const Y=document.createElement("canvas"),P=Y.getContext("2d");P&&(Y.width=Ce,Y.height=ne,P.save(),P.translate(Ce/2,ne/2),P.rotate(x*Math.PI/180),P.drawImage(J,-J.width/2,-J.height/2,J.width,J.height),P.restore(),$e.drawImage(Y,Be,Se,ke,Ie,0,0,ke,Ie),Le.toBlob(me=>{me&&e(me)},s,i))},q={display:"flex",flexDirection:"column",width:"100%",height:"100%",background:M?"#1a1a1a":"#f5f5f5",overflow:"hidden"},X={flex:1,display:"flex",alignItems:"center",justifyContent:"center",padding:"16px",minHeight:0,overflow:"hidden"},W={display:"flex",flexDirection:"column",gap:"12px",padding:"16px",borderTop:`1px solid ${M?"#333":"#ddd"}`,background:M?"#242424":"#fff",flexShrink:0},se={display:"flex",alignItems:"center",justifyContent:"space-between",gap:"8px"},ue={padding:"10px 20px",borderRadius:"8px",border:"none",cursor:"pointer",fontSize:"14px",fontWeight:500,transition:"background 0.15s, opacity 0.15s"},de={...ue,background:"#E67E22",color:"#fff"},pe={...ue,background:M?"#333":"#e5e5e5",color:M?"#fff":"#333"},De={padding:"10px",borderRadius:"8px",border:"none",background:M?"#333":"#e5e5e5",color:M?"#fff":"#333",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center"},xe=J=>({padding:"8px 14px",borderRadius:"6px",border:J?"2px solid #E67E22":"2px solid transparent",background:J?"#E67E22":M?"#333":"#e5e5e5",color:J?"#fff":M?"#ccc":"#666",cursor:"pointer",fontSize:"13px",fontWeight:600,transition:"all 0.15s"});return c?h.jsx("div",{style:{...q,alignItems:"center",justifyContent:"center"},children:h.jsx("div",{style:{color:M?"#aaa":"#666"},children:"Loading image..."})}):f?h.jsxs("div",{style:{...q,alignItems:"center",justifyContent:"center"},children:[h.jsx("div",{style:{color:"#ef4444"},children:f}),t&&h.jsx("button",{onClick:t,style:{...pe,marginTop:"16px"},children:"Close"})]}):h.jsxs("div",{ref:l,style:q,children:[h.jsx("div",{style:X,children:h.jsx("canvas",{ref:a,style:{cursor:S?"grabbing":C?"nwse-resize":"grab",maxWidth:"100%",maxHeight:"100%"},onMouseDown:F,onMouseMove:O,onMouseUp:V,onMouseLeave:V})}),h.jsxs("div",{style:W,children:[h.jsx("div",{style:{display:"flex",gap:"8px",flexWrap:"wrap",justifyContent:"center"},children:Object.keys(gs).map(J=>h.jsx("button",{onClick:()=>m(J),style:xe(g===J),children:J==="free"?"Libre":J},J))}),h.jsxs("div",{style:se,children:[h.jsxs("div",{style:{display:"flex",gap:"8px"},children:[h.jsx("button",{onClick:()=>U("left"),style:De,title:"Rotate left",children:h.jsx("svg",{width:"22",height:"22",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:h.jsx("path",{d:"M2.5 2v6h6M2.66 15.57a10 10 0 1 0 .57-8.38"})})}),h.jsx("button",{onClick:()=>U("right"),style:De,title:"Rotate right",children:h.jsx("svg",{width:"22",height:"22",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:h.jsx("path",{d:"M21.5 2v6h-6M21.34 15.57a10 10 0 1 1-.57-8.38"})})})]}),h.jsxs("div",{style:{display:"flex",gap:"8px"},children:[t&&h.jsx("button",{onClick:t,style:pe,children:"Annuler"}),h.jsx("button",{onClick:te,style:de,children:"Enregistrer"})]})]})]})]})}var Og={value:()=>{}};function la(){for(var r=0,e=arguments.length,t={},n;r<e;++r){if(!(n=arguments[r]+"")||n in t||/[\s.]/.test(n))throw new Error("illegal type: "+n);t[n]=[]}return new Cs(t)}function Cs(r){this._=r}function zg(r,e){return r.trim().split(/^|\s+/).map(function(t){var n="",s=t.indexOf(".");if(s>=0&&(n=t.slice(s+1),t=t.slice(0,s)),t&&!e.hasOwnProperty(t))throw new Error("unknown type: "+t);return{type:t,name:n}})}Cs.prototype=la.prototype={constructor:Cs,on:function(r,e){var t=this._,n=zg(r+"",t),s,i=-1,o=n.length;if(arguments.length<2){for(;++i<o;)if((s=(r=n[i]).type)&&(s=$g(t[s],r.name)))return s;return}if(e!=null&&typeof e!="function")throw new Error("invalid callback: "+e);for(;++i<o;)if(s=(r=n[i]).type)t[s]=Il(t[s],r.name,e);else if(e==null)for(s in t)t[s]=Il(t[s],r.name,null);return this},copy:function(){var r={},e=this._;for(var t in e)r[t]=e[t].slice();return new Cs(r)},call:function(r,e){if((s=arguments.length-2)>0)for(var t=new Array(s),n=0,s,i;n<s;++n)t[n]=arguments[n+2];if(!this._.hasOwnProperty(r))throw new Error("unknown type: "+r);for(i=this._[r],n=0,s=i.length;n<s;++n)i[n].value.apply(e,t)},apply:function(r,e,t){if(!this._.hasOwnProperty(r))throw new Error("unknown type: "+r);for(var n=this._[r],s=0,i=n.length;s<i;++s)n[s].value.apply(e,t)}};function $g(r,e){for(var t=0,n=r.length,s;t<n;++t)if((s=r[t]).name===e)return s.value}function Il(r,e,t){for(var n=0,s=r.length;n<s;++n)if(r[n].name===e){r[n]=Og,r=r.slice(0,n).concat(r.slice(n+1));break}return t!=null&&r.push({name:e,value:t}),r}var bo="http://www.w3.org/1999/xhtml";const Ol={svg:"http://www.w3.org/2000/svg",xhtml:bo,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function vi(r){var e=r+="",t=e.indexOf(":");return t>=0&&(e=r.slice(0,t))!=="xmlns"&&(r=r.slice(t+1)),Ol.hasOwnProperty(e)?{space:Ol[e],local:r}:r}function qg(r){return function(){var e=this.ownerDocument,t=this.namespaceURI;return t===bo&&e.documentElement.namespaceURI===bo?e.createElement(r):e.createElementNS(t,r)}}function Ug(r){return function(){return this.ownerDocument.createElementNS(r.space,r.local)}}function Gc(r){var e=vi(r);return(e.local?Ug:qg)(e)}function Wg(){}function ua(r){return r==null?Wg:function(){return this.querySelector(r)}}function Hg(r){typeof r!="function"&&(r=ua(r));for(var e=this._groups,t=e.length,n=new Array(t),s=0;s<t;++s)for(var i=e[s],o=i.length,l=n[s]=new Array(o),a,u,c=0;c<o;++c)(a=i[c])&&(u=r.call(a,a.__data__,c,i))&&("__data__"in a&&(u.__data__=a.__data__),l[c]=u);return new Dt(n,this._parents)}function Vg(r){return r==null?[]:Array.isArray(r)?r:Array.from(r)}function Gg(){return[]}function Kc(r){return r==null?Gg:function(){return this.querySelectorAll(r)}}function Kg(r){return function(){return Vg(r.apply(this,arguments))}}function Yg(r){typeof r=="function"?r=Kg(r):r=Kc(r);for(var e=this._groups,t=e.length,n=[],s=[],i=0;i<t;++i)for(var o=e[i],l=o.length,a,u=0;u<l;++u)(a=o[u])&&(n.push(r.call(a,a.__data__,u,o)),s.push(a));return new Dt(n,s)}function Yc(r){return function(){return this.matches(r)}}function Qc(r){return function(e){return e.matches(r)}}var Qg=Array.prototype.find;function Xg(r){return function(){return Qg.call(this.children,r)}}function Jg(){return this.firstElementChild}function Zg(r){return this.select(r==null?Jg:Xg(typeof r=="function"?r:Qc(r)))}var e0=Array.prototype.filter;function t0(){return Array.from(this.children)}function r0(r){return function(){return e0.call(this.children,r)}}function n0(r){return this.selectAll(r==null?t0:r0(typeof r=="function"?r:Qc(r)))}function s0(r){typeof r!="function"&&(r=Yc(r));for(var e=this._groups,t=e.length,n=new Array(t),s=0;s<t;++s)for(var i=e[s],o=i.length,l=n[s]=[],a,u=0;u<o;++u)(a=i[u])&&r.call(a,a.__data__,u,i)&&l.push(a);return new Dt(n,this._parents)}function Xc(r){return new Array(r.length)}function i0(){return new Dt(this._enter||this._groups.map(Xc),this._parents)}function Qs(r,e){this.ownerDocument=r.ownerDocument,this.namespaceURI=r.namespaceURI,this._next=null,this._parent=r,this.__data__=e}Qs.prototype={constructor:Qs,appendChild:function(r){return this._parent.insertBefore(r,this._next)},insertBefore:function(r,e){return this._parent.insertBefore(r,e)},querySelector:function(r){return this._parent.querySelector(r)},querySelectorAll:function(r){return this._parent.querySelectorAll(r)}};function o0(r){return function(){return r}}function a0(r,e,t,n,s,i){for(var o=0,l,a=e.length,u=i.length;o<u;++o)(l=e[o])?(l.__data__=i[o],n[o]=l):t[o]=new Qs(r,i[o]);for(;o<a;++o)(l=e[o])&&(s[o]=l)}function l0(r,e,t,n,s,i,o){var l,a,u=new Map,c=e.length,d=i.length,f=new Array(c),p;for(l=0;l<c;++l)(a=e[l])&&(f[l]=p=o.call(a,a.__data__,l,e)+"",u.has(p)?s[l]=a:u.set(p,a));for(l=0;l<d;++l)p=o.call(r,i[l],l,i)+"",(a=u.get(p))?(n[l]=a,a.__data__=i[l],u.delete(p)):t[l]=new Qs(r,i[l]);for(l=0;l<c;++l)(a=e[l])&&u.get(f[l])===a&&(s[l]=a)}function u0(r){return r.__data__}function c0(r,e){if(!arguments.length)return Array.from(this,u0);var t=e?l0:a0,n=this._parents,s=this._groups;typeof r!="function"&&(r=o0(r));for(var i=s.length,o=new Array(i),l=new Array(i),a=new Array(i),u=0;u<i;++u){var c=n[u],d=s[u],f=d.length,p=d0(r.call(c,c&&c.__data__,u,n)),g=p.length,m=l[u]=new Array(g),x=o[u]=new Array(g),_=a[u]=new Array(f);t(c,d,m,x,_,p,e);for(var y=0,v=0,S,D;y<g;++y)if(S=m[y]){for(y>=v&&(v=y+1);!(D=x[v])&&++v<g;);S._next=D||null}}return o=new Dt(o,n),o._enter=l,o._exit=a,o}function d0(r){return typeof r=="object"&&"length"in r?r:Array.from(r)}function f0(){return new Dt(this._exit||this._groups.map(Xc),this._parents)}function h0(r,e,t){var n=this.enter(),s=this,i=this.exit();return typeof r=="function"?(n=r(n),n&&(n=n.selection())):n=n.append(r+""),e!=null&&(s=e(s),s&&(s=s.selection())),t==null?i.remove():t(i),n&&s?n.merge(s).order():s}function p0(r){for(var e=r.selection?r.selection():r,t=this._groups,n=e._groups,s=t.length,i=n.length,o=Math.min(s,i),l=new Array(s),a=0;a<o;++a)for(var u=t[a],c=n[a],d=u.length,f=l[a]=new Array(d),p,g=0;g<d;++g)(p=u[g]||c[g])&&(f[g]=p);for(;a<s;++a)l[a]=t[a];return new Dt(l,this._parents)}function g0(){for(var r=this._groups,e=-1,t=r.length;++e<t;)for(var n=r[e],s=n.length-1,i=n[s],o;--s>=0;)(o=n[s])&&(i&&o.compareDocumentPosition(i)^4&&i.parentNode.insertBefore(o,i),i=o);return this}function m0(r){r||(r=y0);function e(d,f){return d&&f?r(d.__data__,f.__data__):!d-!f}for(var t=this._groups,n=t.length,s=new Array(n),i=0;i<n;++i){for(var o=t[i],l=o.length,a=s[i]=new Array(l),u,c=0;c<l;++c)(u=o[c])&&(a[c]=u);a.sort(e)}return new Dt(s,this._parents).order()}function y0(r,e){return r<e?-1:r>e?1:r>=e?0:NaN}function x0(){var r=arguments[0];return arguments[0]=this,r.apply(null,arguments),this}function b0(){return Array.from(this)}function _0(){for(var r=this._groups,e=0,t=r.length;e<t;++e)for(var n=r[e],s=0,i=n.length;s<i;++s){var o=n[s];if(o)return o}return null}function v0(){let r=0;for(const e of this)++r;return r}function w0(){return!this.node()}function C0(r){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var s=e[t],i=0,o=s.length,l;i<o;++i)(l=s[i])&&r.call(l,l.__data__,i,s);return this}function S0(r){return function(){this.removeAttribute(r)}}function k0(r){return function(){this.removeAttributeNS(r.space,r.local)}}function E0(r,e){return function(){this.setAttribute(r,e)}}function D0(r,e){return function(){this.setAttributeNS(r.space,r.local,e)}}function A0(r,e){return function(){var t=e.apply(this,arguments);t==null?this.removeAttribute(r):this.setAttribute(r,t)}}function T0(r,e){return function(){var t=e.apply(this,arguments);t==null?this.removeAttributeNS(r.space,r.local):this.setAttributeNS(r.space,r.local,t)}}function N0(r,e){var t=vi(r);if(arguments.length<2){var n=this.node();return t.local?n.getAttributeNS(t.space,t.local):n.getAttribute(t)}return this.each((e==null?t.local?k0:S0:typeof e=="function"?t.local?T0:A0:t.local?D0:E0)(t,e))}function Jc(r){return r.ownerDocument&&r.ownerDocument.defaultView||r.document&&r||r.defaultView}function B0(r){return function(){this.style.removeProperty(r)}}function R0(r,e,t){return function(){this.style.setProperty(r,e,t)}}function M0(r,e,t){return function(){var n=e.apply(this,arguments);n==null?this.style.removeProperty(r):this.style.setProperty(r,n,t)}}function F0(r,e,t){return arguments.length>1?this.each((e==null?B0:typeof e=="function"?M0:R0)(r,e,t??"")):rn(this.node(),r)}function rn(r,e){return r.style.getPropertyValue(e)||Jc(r).getComputedStyle(r,null).getPropertyValue(e)}function j0(r){return function(){delete this[r]}}function L0(r,e){return function(){this[r]=e}}function P0(r,e){return function(){var t=e.apply(this,arguments);t==null?delete this[r]:this[r]=t}}function I0(r,e){return arguments.length>1?this.each((e==null?j0:typeof e=="function"?P0:L0)(r,e)):this.node()[r]}function Zc(r){return r.trim().split(/^|\s+/)}function ca(r){return r.classList||new ed(r)}function ed(r){this._node=r,this._names=Zc(r.getAttribute("class")||"")}ed.prototype={add:function(r){var e=this._names.indexOf(r);e<0&&(this._names.push(r),this._node.setAttribute("class",this._names.join(" ")))},remove:function(r){var e=this._names.indexOf(r);e>=0&&(this._names.splice(e,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(r){return this._names.indexOf(r)>=0}};function td(r,e){for(var t=ca(r),n=-1,s=e.length;++n<s;)t.add(e[n])}function rd(r,e){for(var t=ca(r),n=-1,s=e.length;++n<s;)t.remove(e[n])}function O0(r){return function(){td(this,r)}}function z0(r){return function(){rd(this,r)}}function $0(r,e){return function(){(e.apply(this,arguments)?td:rd)(this,r)}}function q0(r,e){var t=Zc(r+"");if(arguments.length<2){for(var n=ca(this.node()),s=-1,i=t.length;++s<i;)if(!n.contains(t[s]))return!1;return!0}return this.each((typeof e=="function"?$0:e?O0:z0)(t,e))}function U0(){this.textContent=""}function W0(r){return function(){this.textContent=r}}function H0(r){return function(){var e=r.apply(this,arguments);this.textContent=e??""}}function V0(r){return arguments.length?this.each(r==null?U0:(typeof r=="function"?H0:W0)(r)):this.node().textContent}function G0(){this.innerHTML=""}function K0(r){return function(){this.innerHTML=r}}function Y0(r){return function(){var e=r.apply(this,arguments);this.innerHTML=e??""}}function Q0(r){return arguments.length?this.each(r==null?G0:(typeof r=="function"?Y0:K0)(r)):this.node().innerHTML}function X0(){this.nextSibling&&this.parentNode.appendChild(this)}function J0(){return this.each(X0)}function Z0(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function em(){return this.each(Z0)}function tm(r){var e=typeof r=="function"?r:Gc(r);return this.select(function(){return this.appendChild(e.apply(this,arguments))})}function rm(){return null}function nm(r,e){var t=typeof r=="function"?r:Gc(r),n=e==null?rm:typeof e=="function"?e:ua(e);return this.select(function(){return this.insertBefore(t.apply(this,arguments),n.apply(this,arguments)||null)})}function sm(){var r=this.parentNode;r&&r.removeChild(this)}function im(){return this.each(sm)}function om(){var r=this.cloneNode(!1),e=this.parentNode;return e?e.insertBefore(r,this.nextSibling):r}function am(){var r=this.cloneNode(!0),e=this.parentNode;return e?e.insertBefore(r,this.nextSibling):r}function lm(r){return this.select(r?am:om)}function um(r){return arguments.length?this.property("__data__",r):this.node().__data__}function cm(r){return function(e){r.call(this,e,this.__data__)}}function dm(r){return r.trim().split(/^|\s+/).map(function(e){var t="",n=e.indexOf(".");return n>=0&&(t=e.slice(n+1),e=e.slice(0,n)),{type:e,name:t}})}function fm(r){return function(){var e=this.__on;if(e){for(var t=0,n=-1,s=e.length,i;t<s;++t)i=e[t],(!r.type||i.type===r.type)&&i.name===r.name?this.removeEventListener(i.type,i.listener,i.options):e[++n]=i;++n?e.length=n:delete this.__on}}}function hm(r,e,t){return function(){var n=this.__on,s,i=cm(e);if(n){for(var o=0,l=n.length;o<l;++o)if((s=n[o]).type===r.type&&s.name===r.name){this.removeEventListener(s.type,s.listener,s.options),this.addEventListener(s.type,s.listener=i,s.options=t),s.value=e;return}}this.addEventListener(r.type,i,t),s={type:r.type,name:r.name,value:e,listener:i,options:t},n?n.push(s):this.__on=[s]}}function pm(r,e,t){var n=dm(r+""),s,i=n.length,o;if(arguments.length<2){var l=this.node().__on;if(l){for(var a=0,u=l.length,c;a<u;++a)for(s=0,c=l[a];s<i;++s)if((o=n[s]).type===c.type&&o.name===c.name)return c.value}return}for(l=e?hm:fm,s=0;s<i;++s)this.each(l(n[s],e,t));return this}function nd(r,e,t){var n=Jc(r),s=n.CustomEvent;typeof s=="function"?s=new s(e,t):(s=n.document.createEvent("Event"),t?(s.initEvent(e,t.bubbles,t.cancelable),s.detail=t.detail):s.initEvent(e,!1,!1)),r.dispatchEvent(s)}function gm(r,e){return function(){return nd(this,r,e)}}function mm(r,e){return function(){return nd(this,r,e.apply(this,arguments))}}function ym(r,e){return this.each((typeof e=="function"?mm:gm)(r,e))}function*xm(){for(var r=this._groups,e=0,t=r.length;e<t;++e)for(var n=r[e],s=0,i=n.length,o;s<i;++s)(o=n[s])&&(yield o)}var sd=[null];function Dt(r,e){this._groups=r,this._parents=e}function ss(){return new Dt([[document.documentElement]],sd)}function bm(){return this}Dt.prototype=ss.prototype={constructor:Dt,select:Hg,selectAll:Yg,selectChild:Zg,selectChildren:n0,filter:s0,data:c0,enter:i0,exit:f0,join:h0,merge:p0,selection:bm,order:g0,sort:m0,call:x0,nodes:b0,node:_0,size:v0,empty:w0,each:C0,attr:N0,style:F0,property:I0,classed:q0,text:V0,html:Q0,raise:J0,lower:em,append:tm,insert:nm,remove:im,clone:lm,datum:um,on:pm,dispatch:ym,[Symbol.iterator]:xm};function Lt(r){return typeof r=="string"?new Dt([[document.querySelector(r)]],[document.documentElement]):new Dt([[r]],sd)}function _m(r){let e;for(;e=r.sourceEvent;)r=e;return r}function wr(r,e){if(r=_m(r),e===void 0&&(e=r.currentTarget),e){var t=e.ownerSVGElement||e;if(t.createSVGPoint){var n=t.createSVGPoint();return n.x=r.clientX,n.y=r.clientY,n=n.matrixTransform(e.getScreenCTM().inverse()),[n.x,n.y]}if(e.getBoundingClientRect){var s=e.getBoundingClientRect();return[r.clientX-s.left-e.clientLeft,r.clientY-s.top-e.clientTop]}}return[r.pageX,r.pageY]}const _o={capture:!0,passive:!1};function vo(r){r.preventDefault(),r.stopImmediatePropagation()}function vm(r){var e=r.document.documentElement,t=Lt(r).on("dragstart.drag",vo,_o);"onselectstart"in e?t.on("selectstart.drag",vo,_o):(e.__noselect=e.style.MozUserSelect,e.style.MozUserSelect="none")}function wm(r,e){var t=r.document.documentElement,n=Lt(r).on("dragstart.drag",null);e&&(n.on("click.drag",vo,_o),setTimeout(function(){n.on("click.drag",null)},0)),"onselectstart"in t?n.on("selectstart.drag",null):(t.style.MozUserSelect=t.__noselect,delete t.__noselect)}function da(r,e,t){r.prototype=e.prototype=t,t.constructor=r}function id(r,e){var t=Object.create(r.prototype);for(var n in e)t[n]=e[n];return t}function is(){}var $n=.7,Xs=1/$n,Xr="\\s*([+-]?\\d+)\\s*",qn="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Gt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Cm=/^#([0-9a-f]{3,8})$/,Sm=new RegExp(`^rgb\\(${Xr},${Xr},${Xr}\\)$`),km=new RegExp(`^rgb\\(${Gt},${Gt},${Gt}\\)$`),Em=new RegExp(`^rgba\\(${Xr},${Xr},${Xr},${qn}\\)$`),Dm=new RegExp(`^rgba\\(${Gt},${Gt},${Gt},${qn}\\)$`),Am=new RegExp(`^hsl\\(${qn},${Gt},${Gt}\\)$`),Tm=new RegExp(`^hsla\\(${qn},${Gt},${Gt},${qn}\\)$`),zl={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};da(is,Un,{copy(r){return Object.assign(new this.constructor,this,r)},displayable(){return this.rgb().displayable()},hex:$l,formatHex:$l,formatHex8:Nm,formatHsl:Bm,formatRgb:ql,toString:ql});function $l(){return this.rgb().formatHex()}function Nm(){return this.rgb().formatHex8()}function Bm(){return od(this).formatHsl()}function ql(){return this.rgb().formatRgb()}function Un(r){var e,t;return r=(r+"").trim().toLowerCase(),(e=Cm.exec(r))?(t=e[1].length,e=parseInt(e[1],16),t===6?Ul(e):t===3?new wt(e>>8&15|e>>4&240,e>>4&15|e&240,(e&15)<<4|e&15,1):t===8?ms(e>>24&255,e>>16&255,e>>8&255,(e&255)/255):t===4?ms(e>>12&15|e>>8&240,e>>8&15|e>>4&240,e>>4&15|e&240,((e&15)<<4|e&15)/255):null):(e=Sm.exec(r))?new wt(e[1],e[2],e[3],1):(e=km.exec(r))?new wt(e[1]*255/100,e[2]*255/100,e[3]*255/100,1):(e=Em.exec(r))?ms(e[1],e[2],e[3],e[4]):(e=Dm.exec(r))?ms(e[1]*255/100,e[2]*255/100,e[3]*255/100,e[4]):(e=Am.exec(r))?Vl(e[1],e[2]/100,e[3]/100,1):(e=Tm.exec(r))?Vl(e[1],e[2]/100,e[3]/100,e[4]):zl.hasOwnProperty(r)?Ul(zl[r]):r==="transparent"?new wt(NaN,NaN,NaN,0):null}function Ul(r){return new wt(r>>16&255,r>>8&255,r&255,1)}function ms(r,e,t,n){return n<=0&&(r=e=t=NaN),new wt(r,e,t,n)}function Rm(r){return r instanceof is||(r=Un(r)),r?(r=r.rgb(),new wt(r.r,r.g,r.b,r.opacity)):new wt}function wo(r,e,t,n){return arguments.length===1?Rm(r):new wt(r,e,t,n??1)}function wt(r,e,t,n){this.r=+r,this.g=+e,this.b=+t,this.opacity=+n}da(wt,wo,id(is,{brighter(r){return r=r==null?Xs:Math.pow(Xs,r),new wt(this.r*r,this.g*r,this.b*r,this.opacity)},darker(r){return r=r==null?$n:Math.pow($n,r),new wt(this.r*r,this.g*r,this.b*r,this.opacity)},rgb(){return this},clamp(){return new wt(Tr(this.r),Tr(this.g),Tr(this.b),Js(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:Wl,formatHex:Wl,formatHex8:Mm,formatRgb:Hl,toString:Hl}));function Wl(){return`#${Sr(this.r)}${Sr(this.g)}${Sr(this.b)}`}function Mm(){return`#${Sr(this.r)}${Sr(this.g)}${Sr(this.b)}${Sr((isNaN(this.opacity)?1:this.opacity)*255)}`}function Hl(){const r=Js(this.opacity);return`${r===1?"rgb(":"rgba("}${Tr(this.r)}, ${Tr(this.g)}, ${Tr(this.b)}${r===1?")":`, ${r})`}`}function Js(r){return isNaN(r)?1:Math.max(0,Math.min(1,r))}function Tr(r){return Math.max(0,Math.min(255,Math.round(r)||0))}function Sr(r){return r=Tr(r),(r<16?"0":"")+r.toString(16)}function Vl(r,e,t,n){return n<=0?r=e=t=NaN:t<=0||t>=1?r=e=NaN:e<=0&&(r=NaN),new Pt(r,e,t,n)}function od(r){if(r instanceof Pt)return new Pt(r.h,r.s,r.l,r.opacity);if(r instanceof is||(r=Un(r)),!r)return new Pt;if(r instanceof Pt)return r;r=r.rgb();var e=r.r/255,t=r.g/255,n=r.b/255,s=Math.min(e,t,n),i=Math.max(e,t,n),o=NaN,l=i-s,a=(i+s)/2;return l?(e===i?o=(t-n)/l+(t<n)*6:t===i?o=(n-e)/l+2:o=(e-t)/l+4,l/=a<.5?i+s:2-i-s,o*=60):l=a>0&&a<1?0:o,new Pt(o,l,a,r.opacity)}function Fm(r,e,t,n){return arguments.length===1?od(r):new Pt(r,e,t,n??1)}function Pt(r,e,t,n){this.h=+r,this.s=+e,this.l=+t,this.opacity=+n}da(Pt,Fm,id(is,{brighter(r){return r=r==null?Xs:Math.pow(Xs,r),new Pt(this.h,this.s,this.l*r,this.opacity)},darker(r){return r=r==null?$n:Math.pow($n,r),new Pt(this.h,this.s,this.l*r,this.opacity)},rgb(){var r=this.h%360+(this.h<0)*360,e=isNaN(r)||isNaN(this.s)?0:this.s,t=this.l,n=t+(t<.5?t:1-t)*e,s=2*t-n;return new wt(qi(r>=240?r-240:r+120,s,n),qi(r,s,n),qi(r<120?r+240:r-120,s,n),this.opacity)},clamp(){return new Pt(Gl(this.h),ys(this.s),ys(this.l),Js(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const r=Js(this.opacity);return`${r===1?"hsl(":"hsla("}${Gl(this.h)}, ${ys(this.s)*100}%, ${ys(this.l)*100}%${r===1?")":`, ${r})`}`}}));function Gl(r){return r=(r||0)%360,r<0?r+360:r}function ys(r){return Math.max(0,Math.min(1,r||0))}function qi(r,e,t){return(r<60?e+(t-e)*r/60:r<180?t:r<240?e+(t-e)*(240-r)/60:e)*255}const ad=r=>()=>r;function jm(r,e){return function(t){return r+t*e}}function Lm(r,e,t){return r=Math.pow(r,t),e=Math.pow(e,t)-r,t=1/t,function(n){return Math.pow(r+n*e,t)}}function Pm(r){return(r=+r)==1?ld:function(e,t){return t-e?Lm(e,t,r):ad(isNaN(e)?t:e)}}function ld(r,e){var t=e-r;return t?jm(r,t):ad(isNaN(r)?e:r)}const Kl=function r(e){var t=Pm(e);function n(s,i){var o=t((s=wo(s)).r,(i=wo(i)).r),l=t(s.g,i.g),a=t(s.b,i.b),u=ld(s.opacity,i.opacity);return function(c){return s.r=o(c),s.g=l(c),s.b=a(c),s.opacity=u(c),s+""}}return n.gamma=r,n}(1);function fr(r,e){return r=+r,e=+e,function(t){return r*(1-t)+e*t}}var Co=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Ui=new RegExp(Co.source,"g");function Im(r){return function(){return r}}function Om(r){return function(e){return r(e)+""}}function zm(r,e){var t=Co.lastIndex=Ui.lastIndex=0,n,s,i,o=-1,l=[],a=[];for(r=r+"",e=e+"";(n=Co.exec(r))&&(s=Ui.exec(e));)(i=s.index)>t&&(i=e.slice(t,i),l[o]?l[o]+=i:l[++o]=i),(n=n[0])===(s=s[0])?l[o]?l[o]+=s:l[++o]=s:(l[++o]=null,a.push({i:o,x:fr(n,s)})),t=Ui.lastIndex;return t<e.length&&(i=e.slice(t),l[o]?l[o]+=i:l[++o]=i),l.length<2?a[0]?Om(a[0].x):Im(e):(e=a.length,function(u){for(var c=0,d;c<e;++c)l[(d=a[c]).i]=d.x(u);return l.join("")})}var Yl=180/Math.PI,So={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function ud(r,e,t,n,s,i){var o,l,a;return(o=Math.sqrt(r*r+e*e))&&(r/=o,e/=o),(a=r*t+e*n)&&(t-=r*a,n-=e*a),(l=Math.sqrt(t*t+n*n))&&(t/=l,n/=l,a/=l),r*n<e*t&&(r=-r,e=-e,a=-a,o=-o),{translateX:s,translateY:i,rotate:Math.atan2(e,r)*Yl,skewX:Math.atan(a)*Yl,scaleX:o,scaleY:l}}var xs;function $m(r){const e=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(r+"");return e.isIdentity?So:ud(e.a,e.b,e.c,e.d,e.e,e.f)}function qm(r){return r==null||(xs||(xs=document.createElementNS("http://www.w3.org/2000/svg","g")),xs.setAttribute("transform",r),!(r=xs.transform.baseVal.consolidate()))?So:(r=r.matrix,ud(r.a,r.b,r.c,r.d,r.e,r.f))}function cd(r,e,t,n){function s(u){return u.length?u.pop()+" ":""}function i(u,c,d,f,p,g){if(u!==d||c!==f){var m=p.push("translate(",null,e,null,t);g.push({i:m-4,x:fr(u,d)},{i:m-2,x:fr(c,f)})}else(d||f)&&p.push("translate("+d+e+f+t)}function o(u,c,d,f){u!==c?(u-c>180?c+=360:c-u>180&&(u+=360),f.push({i:d.push(s(d)+"rotate(",null,n)-2,x:fr(u,c)})):c&&d.push(s(d)+"rotate("+c+n)}function l(u,c,d,f){u!==c?f.push({i:d.push(s(d)+"skewX(",null,n)-2,x:fr(u,c)}):c&&d.push(s(d)+"skewX("+c+n)}function a(u,c,d,f,p,g){if(u!==d||c!==f){var m=p.push(s(p)+"scale(",null,",",null,")");g.push({i:m-4,x:fr(u,d)},{i:m-2,x:fr(c,f)})}else(d!==1||f!==1)&&p.push(s(p)+"scale("+d+","+f+")")}return function(u,c){var d=[],f=[];return u=r(u),c=r(c),i(u.translateX,u.translateY,c.translateX,c.translateY,d,f),o(u.rotate,c.rotate,d,f),l(u.skewX,c.skewX,d,f),a(u.scaleX,u.scaleY,c.scaleX,c.scaleY,d,f),u=c=null,function(p){for(var g=-1,m=f.length,x;++g<m;)d[(x=f[g]).i]=x.x(p);return d.join("")}}}var Um=cd($m,"px, ","px)","deg)"),Wm=cd(qm,", ",")",")"),Hm=1e-12;function Ql(r){return((r=Math.exp(r))+1/r)/2}function Vm(r){return((r=Math.exp(r))-1/r)/2}function Gm(r){return((r=Math.exp(2*r))-1)/(r+1)}const Km=function r(e,t,n){function s(i,o){var l=i[0],a=i[1],u=i[2],c=o[0],d=o[1],f=o[2],p=c-l,g=d-a,m=p*p+g*g,x,_;if(m<Hm)_=Math.log(f/u)/e,x=function(w){return[l+w*p,a+w*g,u*Math.exp(e*w*_)]};else{var y=Math.sqrt(m),v=(f*f-u*u+n*m)/(2*u*t*y),S=(f*f-u*u-n*m)/(2*f*t*y),D=Math.log(Math.sqrt(v*v+1)-v),C=Math.log(Math.sqrt(S*S+1)-S);_=(C-D)/e,x=function(w){var E=w*_,R=Ql(D),T=u/(t*y)*(R*Gm(e*E+D)-Vm(D));return[l+T*p,a+T*g,u*R/Ql(e*E+D)]}}return x.duration=_*1e3*e/Math.SQRT2,x}return s.rho=function(i){var o=Math.max(.001,+i),l=o*o,a=l*l;return r(o,l,a)},s}(Math.SQRT2,2,4);var nn=0,Cn=0,yn=0,dd=1e3,Zs,Sn,ei=0,Lr=0,wi=0,Wn=typeof performance=="object"&&performance.now?performance:Date,fd=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(r){setTimeout(r,17)};function fa(){return Lr||(fd(Ym),Lr=Wn.now()+wi)}function Ym(){Lr=0}function ti(){this._call=this._time=this._next=null}ti.prototype=hd.prototype={constructor:ti,restart:function(r,e,t){if(typeof r!="function")throw new TypeError("callback is not a function");t=(t==null?fa():+t)+(e==null?0:+e),!this._next&&Sn!==this&&(Sn?Sn._next=this:Zs=this,Sn=this),this._call=r,this._time=t,ko()},stop:function(){this._call&&(this._call=null,this._time=1/0,ko())}};function hd(r,e,t){var n=new ti;return n.restart(r,e,t),n}function Qm(){fa(),++nn;for(var r=Zs,e;r;)(e=Lr-r._time)>=0&&r._call.call(void 0,e),r=r._next;--nn}function Xl(){Lr=(ei=Wn.now())+wi,nn=Cn=0;try{Qm()}finally{nn=0,Jm(),Lr=0}}function Xm(){var r=Wn.now(),e=r-ei;e>dd&&(wi-=e,ei=r)}function Jm(){for(var r,e=Zs,t,n=1/0;e;)e._call?(n>e._time&&(n=e._time),r=e,e=e._next):(t=e._next,e._next=null,e=r?r._next=t:Zs=t);Sn=r,ko(n)}function ko(r){if(!nn){Cn&&(Cn=clearTimeout(Cn));var e=r-Lr;e>24?(r<1/0&&(Cn=setTimeout(Xl,r-Wn.now()-wi)),yn&&(yn=clearInterval(yn))):(yn||(ei=Wn.now(),yn=setInterval(Xm,dd)),nn=1,fd(Xl))}}function Jl(r,e,t){var n=new ti;return e=e==null?0:+e,n.restart(s=>{n.stop(),r(s+e)},e,t),n}var Zm=la("start","end","cancel","interrupt"),e2=[],pd=0,Zl=1,Eo=2,Ss=3,eu=4,Do=5,ks=6;function Ci(r,e,t,n,s,i){var o=r.__transition;if(!o)r.__transition={};else if(t in o)return;t2(r,t,{name:e,index:n,group:s,on:Zm,tween:e2,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:pd})}function ha(r,e){var t=qt(r,e);if(t.state>pd)throw new Error("too late; already scheduled");return t}function Jt(r,e){var t=qt(r,e);if(t.state>Ss)throw new Error("too late; already running");return t}function qt(r,e){var t=r.__transition;if(!t||!(t=t[e]))throw new Error("transition not found");return t}function t2(r,e,t){var n=r.__transition,s;n[e]=t,t.timer=hd(i,0,t.time);function i(u){t.state=Zl,t.timer.restart(o,t.delay,t.time),t.delay<=u&&o(u-t.delay)}function o(u){var c,d,f,p;if(t.state!==Zl)return a();for(c in n)if(p=n[c],p.name===t.name){if(p.state===Ss)return Jl(o);p.state===eu?(p.state=ks,p.timer.stop(),p.on.call("interrupt",r,r.__data__,p.index,p.group),delete n[c]):+c<e&&(p.state=ks,p.timer.stop(),p.on.call("cancel",r,r.__data__,p.index,p.group),delete n[c])}if(Jl(function(){t.state===Ss&&(t.state=eu,t.timer.restart(l,t.delay,t.time),l(u))}),t.state=Eo,t.on.call("start",r,r.__data__,t.index,t.group),t.state===Eo){for(t.state=Ss,s=new Array(f=t.tween.length),c=0,d=-1;c<f;++c)(p=t.tween[c].value.call(r,r.__data__,t.index,t.group))&&(s[++d]=p);s.length=d+1}}function l(u){for(var c=u<t.duration?t.ease.call(null,u/t.duration):(t.timer.restart(a),t.state=Do,1),d=-1,f=s.length;++d<f;)s[d].call(r,c);t.state===Do&&(t.on.call("end",r,r.__data__,t.index,t.group),a())}function a(){t.state=ks,t.timer.stop(),delete n[e];for(var u in n)return;delete r.__transition}}function Es(r,e){var t=r.__transition,n,s,i=!0,o;if(t){e=e==null?null:e+"";for(o in t){if((n=t[o]).name!==e){i=!1;continue}s=n.state>Eo&&n.state<Do,n.state=ks,n.timer.stop(),n.on.call(s?"interrupt":"cancel",r,r.__data__,n.index,n.group),delete t[o]}i&&delete r.__transition}}function r2(r){return this.each(function(){Es(this,r)})}function n2(r,e){var t,n;return function(){var s=Jt(this,r),i=s.tween;if(i!==t){n=t=i;for(var o=0,l=n.length;o<l;++o)if(n[o].name===e){n=n.slice(),n.splice(o,1);break}}s.tween=n}}function s2(r,e,t){var n,s;if(typeof t!="function")throw new Error;return function(){var i=Jt(this,r),o=i.tween;if(o!==n){s=(n=o).slice();for(var l={name:e,value:t},a=0,u=s.length;a<u;++a)if(s[a].name===e){s[a]=l;break}a===u&&s.push(l)}i.tween=s}}function i2(r,e){var t=this._id;if(r+="",arguments.length<2){for(var n=qt(this.node(),t).tween,s=0,i=n.length,o;s<i;++s)if((o=n[s]).name===r)return o.value;return null}return this.each((e==null?n2:s2)(t,r,e))}function pa(r,e,t){var n=r._id;return r.each(function(){var s=Jt(this,n);(s.value||(s.value={}))[e]=t.apply(this,arguments)}),function(s){return qt(s,n).value[e]}}function gd(r,e){var t;return(typeof e=="number"?fr:e instanceof Un?Kl:(t=Un(e))?(e=t,Kl):zm)(r,e)}function o2(r){return function(){this.removeAttribute(r)}}function a2(r){return function(){this.removeAttributeNS(r.space,r.local)}}function l2(r,e,t){var n,s=t+"",i;return function(){var o=this.getAttribute(r);return o===s?null:o===n?i:i=e(n=o,t)}}function u2(r,e,t){var n,s=t+"",i;return function(){var o=this.getAttributeNS(r.space,r.local);return o===s?null:o===n?i:i=e(n=o,t)}}function c2(r,e,t){var n,s,i;return function(){var o,l=t(this),a;return l==null?void this.removeAttribute(r):(o=this.getAttribute(r),a=l+"",o===a?null:o===n&&a===s?i:(s=a,i=e(n=o,l)))}}function d2(r,e,t){var n,s,i;return function(){var o,l=t(this),a;return l==null?void this.removeAttributeNS(r.space,r.local):(o=this.getAttributeNS(r.space,r.local),a=l+"",o===a?null:o===n&&a===s?i:(s=a,i=e(n=o,l)))}}function f2(r,e){var t=vi(r),n=t==="transform"?Wm:gd;return this.attrTween(r,typeof e=="function"?(t.local?d2:c2)(t,n,pa(this,"attr."+r,e)):e==null?(t.local?a2:o2)(t):(t.local?u2:l2)(t,n,e))}function h2(r,e){return function(t){this.setAttribute(r,e.call(this,t))}}function p2(r,e){return function(t){this.setAttributeNS(r.space,r.local,e.call(this,t))}}function g2(r,e){var t,n;function s(){var i=e.apply(this,arguments);return i!==n&&(t=(n=i)&&p2(r,i)),t}return s._value=e,s}function m2(r,e){var t,n;function s(){var i=e.apply(this,arguments);return i!==n&&(t=(n=i)&&h2(r,i)),t}return s._value=e,s}function y2(r,e){var t="attr."+r;if(arguments.length<2)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!="function")throw new Error;var n=vi(r);return this.tween(t,(n.local?g2:m2)(n,e))}function x2(r,e){return function(){ha(this,r).delay=+e.apply(this,arguments)}}function b2(r,e){return e=+e,function(){ha(this,r).delay=e}}function _2(r){var e=this._id;return arguments.length?this.each((typeof r=="function"?x2:b2)(e,r)):qt(this.node(),e).delay}function v2(r,e){return function(){Jt(this,r).duration=+e.apply(this,arguments)}}function w2(r,e){return e=+e,function(){Jt(this,r).duration=e}}function C2(r){var e=this._id;return arguments.length?this.each((typeof r=="function"?v2:w2)(e,r)):qt(this.node(),e).duration}function S2(r,e){if(typeof e!="function")throw new Error;return function(){Jt(this,r).ease=e}}function k2(r){var e=this._id;return arguments.length?this.each(S2(e,r)):qt(this.node(),e).ease}function E2(r,e){return function(){var t=e.apply(this,arguments);if(typeof t!="function")throw new Error;Jt(this,r).ease=t}}function D2(r){if(typeof r!="function")throw new Error;return this.each(E2(this._id,r))}function A2(r){typeof r!="function"&&(r=Yc(r));for(var e=this._groups,t=e.length,n=new Array(t),s=0;s<t;++s)for(var i=e[s],o=i.length,l=n[s]=[],a,u=0;u<o;++u)(a=i[u])&&r.call(a,a.__data__,u,i)&&l.push(a);return new ir(n,this._parents,this._name,this._id)}function T2(r){if(r._id!==this._id)throw new Error;for(var e=this._groups,t=r._groups,n=e.length,s=t.length,i=Math.min(n,s),o=new Array(n),l=0;l<i;++l)for(var a=e[l],u=t[l],c=a.length,d=o[l]=new Array(c),f,p=0;p<c;++p)(f=a[p]||u[p])&&(d[p]=f);for(;l<n;++l)o[l]=e[l];return new ir(o,this._parents,this._name,this._id)}function N2(r){return(r+"").trim().split(/^|\s+/).every(function(e){var t=e.indexOf(".");return t>=0&&(e=e.slice(0,t)),!e||e==="start"})}function B2(r,e,t){var n,s,i=N2(e)?ha:Jt;return function(){var o=i(this,r),l=o.on;l!==n&&(s=(n=l).copy()).on(e,t),o.on=s}}function R2(r,e){var t=this._id;return arguments.length<2?qt(this.node(),t).on.on(r):this.each(B2(t,r,e))}function M2(r){return function(){var e=this.parentNode;for(var t in this.__transition)if(+t!==r)return;e&&e.removeChild(this)}}function F2(){return this.on("end.remove",M2(this._id))}function j2(r){var e=this._name,t=this._id;typeof r!="function"&&(r=ua(r));for(var n=this._groups,s=n.length,i=new Array(s),o=0;o<s;++o)for(var l=n[o],a=l.length,u=i[o]=new Array(a),c,d,f=0;f<a;++f)(c=l[f])&&(d=r.call(c,c.__data__,f,l))&&("__data__"in c&&(d.__data__=c.__data__),u[f]=d,Ci(u[f],e,t,f,u,qt(c,t)));return new ir(i,this._parents,e,t)}function L2(r){var e=this._name,t=this._id;typeof r!="function"&&(r=Kc(r));for(var n=this._groups,s=n.length,i=[],o=[],l=0;l<s;++l)for(var a=n[l],u=a.length,c,d=0;d<u;++d)if(c=a[d]){for(var f=r.call(c,c.__data__,d,a),p,g=qt(c,t),m=0,x=f.length;m<x;++m)(p=f[m])&&Ci(p,e,t,m,f,g);i.push(f),o.push(c)}return new ir(i,o,e,t)}var P2=ss.prototype.constructor;function I2(){return new P2(this._groups,this._parents)}function O2(r,e){var t,n,s;return function(){var i=rn(this,r),o=(this.style.removeProperty(r),rn(this,r));return i===o?null:i===t&&o===n?s:s=e(t=i,n=o)}}function md(r){return function(){this.style.removeProperty(r)}}function z2(r,e,t){var n,s=t+"",i;return function(){var o=rn(this,r);return o===s?null:o===n?i:i=e(n=o,t)}}function $2(r,e,t){var n,s,i;return function(){var o=rn(this,r),l=t(this),a=l+"";return l==null&&(a=l=(this.style.removeProperty(r),rn(this,r))),o===a?null:o===n&&a===s?i:(s=a,i=e(n=o,l))}}function q2(r,e){var t,n,s,i="style."+e,o="end."+i,l;return function(){var a=Jt(this,r),u=a.on,c=a.value[i]==null?l||(l=md(e)):void 0;(u!==t||s!==c)&&(n=(t=u).copy()).on(o,s=c),a.on=n}}function U2(r,e,t){var n=(r+="")=="transform"?Um:gd;return e==null?this.styleTween(r,O2(r,n)).on("end.style."+r,md(r)):typeof e=="function"?this.styleTween(r,$2(r,n,pa(this,"style."+r,e))).each(q2(this._id,r)):this.styleTween(r,z2(r,n,e),t).on("end.style."+r,null)}function W2(r,e,t){return function(n){this.style.setProperty(r,e.call(this,n),t)}}function H2(r,e,t){var n,s;function i(){var o=e.apply(this,arguments);return o!==s&&(n=(s=o)&&W2(r,o,t)),n}return i._value=e,i}function V2(r,e,t){var n="style."+(r+="");if(arguments.length<2)return(n=this.tween(n))&&n._value;if(e==null)return this.tween(n,null);if(typeof e!="function")throw new Error;return this.tween(n,H2(r,e,t??""))}function G2(r){return function(){this.textContent=r}}function K2(r){return function(){var e=r(this);this.textContent=e??""}}function Y2(r){return this.tween("text",typeof r=="function"?K2(pa(this,"text",r)):G2(r==null?"":r+""))}function Q2(r){return function(e){this.textContent=r.call(this,e)}}function X2(r){var e,t;function n(){var s=r.apply(this,arguments);return s!==t&&(e=(t=s)&&Q2(s)),e}return n._value=r,n}function J2(r){var e="text";if(arguments.length<1)return(e=this.tween(e))&&e._value;if(r==null)return this.tween(e,null);if(typeof r!="function")throw new Error;return this.tween(e,X2(r))}function Z2(){for(var r=this._name,e=this._id,t=yd(),n=this._groups,s=n.length,i=0;i<s;++i)for(var o=n[i],l=o.length,a,u=0;u<l;++u)if(a=o[u]){var c=qt(a,e);Ci(a,r,t,u,o,{time:c.time+c.delay+c.duration,delay:0,duration:c.duration,ease:c.ease})}return new ir(n,this._parents,r,t)}function ey(){var r,e,t=this,n=t._id,s=t.size();return new Promise(function(i,o){var l={value:o},a={value:function(){--s===0&&i()}};t.each(function(){var u=Jt(this,n),c=u.on;c!==r&&(e=(r=c).copy(),e._.cancel.push(l),e._.interrupt.push(l),e._.end.push(a)),u.on=e}),s===0&&i()})}var ty=0;function ir(r,e,t,n){this._groups=r,this._parents=e,this._name=t,this._id=n}function yd(){return++ty}var tr=ss.prototype;ir.prototype={constructor:ir,select:j2,selectAll:L2,selectChild:tr.selectChild,selectChildren:tr.selectChildren,filter:A2,merge:T2,selection:I2,transition:Z2,call:tr.call,nodes:tr.nodes,node:tr.node,size:tr.size,empty:tr.empty,each:tr.each,on:R2,attr:f2,attrTween:y2,style:U2,styleTween:V2,text:Y2,textTween:J2,remove:F2,tween:i2,delay:_2,duration:C2,ease:k2,easeVarying:D2,end:ey,[Symbol.iterator]:tr[Symbol.iterator]};function ry(r){return((r*=2)<=1?r*r*r:(r-=2)*r*r+2)/2}var ny={time:null,delay:0,duration:250,ease:ry};function sy(r,e){for(var t;!(t=r.__transition)||!(t=t[e]);)if(!(r=r.parentNode))throw new Error(`transition ${e} not found`);return t}function iy(r){var e,t;r instanceof ir?(e=r._id,r=r._name):(e=yd(),(t=ny).time=fa(),r=r==null?null:r+"");for(var n=this._groups,s=n.length,i=0;i<s;++i)for(var o=n[i],l=o.length,a,u=0;u<l;++u)(a=o[u])&&Ci(a,r,e,u,o,t||sy(a,e));return new ir(n,this._parents,r,e)}ss.prototype.interrupt=r2;ss.prototype.transition=iy;const bs=r=>()=>r;function oy(r,{sourceEvent:e,target:t,transform:n,dispatch:s}){Object.defineProperties(this,{type:{value:r,enumerable:!0,configurable:!0},sourceEvent:{value:e,enumerable:!0,configurable:!0},target:{value:t,enumerable:!0,configurable:!0},transform:{value:n,enumerable:!0,configurable:!0},_:{value:s}})}function nr(r,e,t){this.k=r,this.x=e,this.y=t}nr.prototype={constructor:nr,scale:function(r){return r===1?this:new nr(this.k*r,this.x,this.y)},translate:function(r,e){return r===0&e===0?this:new nr(this.k,this.x+this.k*r,this.y+this.k*e)},apply:function(r){return[r[0]*this.k+this.x,r[1]*this.k+this.y]},applyX:function(r){return r*this.k+this.x},applyY:function(r){return r*this.k+this.y},invert:function(r){return[(r[0]-this.x)/this.k,(r[1]-this.y)/this.k]},invertX:function(r){return(r-this.x)/this.k},invertY:function(r){return(r-this.y)/this.k},rescaleX:function(r){return r.copy().domain(r.range().map(this.invertX,this).map(r.invert,r))},rescaleY:function(r){return r.copy().domain(r.range().map(this.invertY,this).map(r.invert,r))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var ri=new nr(1,0,0);nr.prototype;function Wi(r){r.stopImmediatePropagation()}function xn(r){r.preventDefault(),r.stopImmediatePropagation()}function ay(r){return(!r.ctrlKey||r.type==="wheel")&&!r.button}function ly(){var r=this;return r instanceof SVGElement?(r=r.ownerSVGElement||r,r.hasAttribute("viewBox")?(r=r.viewBox.baseVal,[[r.x,r.y],[r.x+r.width,r.y+r.height]]):[[0,0],[r.width.baseVal.value,r.height.baseVal.value]]):[[0,0],[r.clientWidth,r.clientHeight]]}function tu(){return this.__zoom||ri}function uy(r){return-r.deltaY*(r.deltaMode===1?.05:r.deltaMode?1:.002)*(r.ctrlKey?10:1)}function cy(){return navigator.maxTouchPoints||"ontouchstart"in this}function dy(r,e,t){var n=r.invertX(e[0][0])-t[0][0],s=r.invertX(e[1][0])-t[1][0],i=r.invertY(e[0][1])-t[0][1],o=r.invertY(e[1][1])-t[1][1];return r.translate(s>n?(n+s)/2:Math.min(0,n)||Math.max(0,s),o>i?(i+o)/2:Math.min(0,i)||Math.max(0,o))}function fy(){var r=ay,e=ly,t=dy,n=uy,s=cy,i=[0,1/0],o=[[-1/0,-1/0],[1/0,1/0]],l=250,a=Km,u=la("start","zoom","end"),c,d,f,p=500,g=150,m=0,x=10;function _(k){k.property("__zoom",tu).on("wheel.zoom",E,{passive:!1}).on("mousedown.zoom",R).on("dblclick.zoom",T).filter(s).on("touchstart.zoom",N).on("touchmove.zoom",M).on("touchend.zoom touchcancel.zoom",j).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}_.transform=function(k,B,F,O){var V=k.selection?k.selection():k;V.property("__zoom",tu),k!==V?D(k,B,F,O):V.interrupt().each(function(){C(this,arguments).event(O).start().zoom(null,typeof B=="function"?B.apply(this,arguments):B).end()})},_.scaleBy=function(k,B,F,O){_.scaleTo(k,function(){var V=this.__zoom.k,U=typeof B=="function"?B.apply(this,arguments):B;return V*U},F,O)},_.scaleTo=function(k,B,F,O){_.transform(k,function(){var V=e.apply(this,arguments),U=this.__zoom,te=F==null?S(V):typeof F=="function"?F.apply(this,arguments):F,q=U.invert(te),X=typeof B=="function"?B.apply(this,arguments):B;return t(v(y(U,X),te,q),V,o)},F,O)},_.translateBy=function(k,B,F,O){_.transform(k,function(){return t(this.__zoom.translate(typeof B=="function"?B.apply(this,arguments):B,typeof F=="function"?F.apply(this,arguments):F),e.apply(this,arguments),o)},null,O)},_.translateTo=function(k,B,F,O,V){_.transform(k,function(){var U=e.apply(this,arguments),te=this.__zoom,q=O==null?S(U):typeof O=="function"?O.apply(this,arguments):O;return t(ri.translate(q[0],q[1]).scale(te.k).translate(typeof B=="function"?-B.apply(this,arguments):-B,typeof F=="function"?-F.apply(this,arguments):-F),U,o)},O,V)};function y(k,B){return B=Math.max(i[0],Math.min(i[1],B)),B===k.k?k:new nr(B,k.x,k.y)}function v(k,B,F){var O=B[0]-F[0]*k.k,V=B[1]-F[1]*k.k;return O===k.x&&V===k.y?k:new nr(k.k,O,V)}function S(k){return[(+k[0][0]+ +k[1][0])/2,(+k[0][1]+ +k[1][1])/2]}function D(k,B,F,O){k.on("start.zoom",function(){C(this,arguments).event(O).start()}).on("interrupt.zoom end.zoom",function(){C(this,arguments).event(O).end()}).tween("zoom",function(){var V=this,U=arguments,te=C(V,U).event(O),q=e.apply(V,U),X=F==null?S(q):typeof F=="function"?F.apply(V,U):F,W=Math.max(q[1][0]-q[0][0],q[1][1]-q[0][1]),se=V.__zoom,ue=typeof B=="function"?B.apply(V,U):B,de=a(se.invert(X).concat(W/se.k),ue.invert(X).concat(W/ue.k));return function(pe){if(pe===1)pe=ue;else{var De=de(pe),xe=W/De[2];pe=new nr(xe,X[0]-De[0]*xe,X[1]-De[1]*xe)}te.zoom(null,pe)}})}function C(k,B,F){return!F&&k.__zooming||new w(k,B)}function w(k,B){this.that=k,this.args=B,this.active=0,this.sourceEvent=null,this.extent=e.apply(k,B),this.taps=0}w.prototype={event:function(k){return k&&(this.sourceEvent=k),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(k,B){return this.mouse&&k!=="mouse"&&(this.mouse[1]=B.invert(this.mouse[0])),this.touch0&&k!=="touch"&&(this.touch0[1]=B.invert(this.touch0[0])),this.touch1&&k!=="touch"&&(this.touch1[1]=B.invert(this.touch1[0])),this.that.__zoom=B,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(k){var B=Lt(this.that).datum();u.call(k,this.that,new oy(k,{sourceEvent:this.sourceEvent,target:_,transform:this.that.__zoom,dispatch:u}),B)}};function E(k,...B){if(!r.apply(this,arguments))return;var F=C(this,B).event(k),O=this.__zoom,V=Math.max(i[0],Math.min(i[1],O.k*Math.pow(2,n.apply(this,arguments)))),U=wr(k);if(F.wheel)(F.mouse[0][0]!==U[0]||F.mouse[0][1]!==U[1])&&(F.mouse[1]=O.invert(F.mouse[0]=U)),clearTimeout(F.wheel);else{if(O.k===V)return;F.mouse=[U,O.invert(U)],Es(this),F.start()}xn(k),F.wheel=setTimeout(te,g),F.zoom("mouse",t(v(y(O,V),F.mouse[0],F.mouse[1]),F.extent,o));function te(){F.wheel=null,F.end()}}function R(k,...B){if(f||!r.apply(this,arguments))return;var F=k.currentTarget,O=C(this,B,!0).event(k),V=Lt(k.view).on("mousemove.zoom",X,!0).on("mouseup.zoom",W,!0),U=wr(k,F),te=k.clientX,q=k.clientY;vm(k.view),Wi(k),O.mouse=[U,this.__zoom.invert(U)],Es(this),O.start();function X(se){if(xn(se),!O.moved){var ue=se.clientX-te,de=se.clientY-q;O.moved=ue*ue+de*de>m}O.event(se).zoom("mouse",t(v(O.that.__zoom,O.mouse[0]=wr(se,F),O.mouse[1]),O.extent,o))}function W(se){V.on("mousemove.zoom mouseup.zoom",null),wm(se.view,O.moved),xn(se),O.event(se).end()}}function T(k,...B){if(r.apply(this,arguments)){var F=this.__zoom,O=wr(k.changedTouches?k.changedTouches[0]:k,this),V=F.invert(O),U=F.k*(k.shiftKey?.5:2),te=t(v(y(F,U),O,V),e.apply(this,B),o);xn(k),l>0?Lt(this).transition().duration(l).call(D,te,O,k):Lt(this).call(_.transform,te,O,k)}}function N(k,...B){if(r.apply(this,arguments)){var F=k.touches,O=F.length,V=C(this,B,k.changedTouches.length===O).event(k),U,te,q,X;for(Wi(k),te=0;te<O;++te)q=F[te],X=wr(q,this),X=[X,this.__zoom.invert(X),q.identifier],V.touch0?!V.touch1&&V.touch0[2]!==X[2]&&(V.touch1=X,V.taps=0):(V.touch0=X,U=!0,V.taps=1+!!c);c&&(c=clearTimeout(c)),U&&(V.taps<2&&(d=X[0],c=setTimeout(function(){c=null},p)),Es(this),V.start())}}function M(k,...B){if(this.__zooming){var F=C(this,B).event(k),O=k.changedTouches,V=O.length,U,te,q,X;for(xn(k),U=0;U<V;++U)te=O[U],q=wr(te,this),F.touch0&&F.touch0[2]===te.identifier?F.touch0[0]=q:F.touch1&&F.touch1[2]===te.identifier&&(F.touch1[0]=q);if(te=F.that.__zoom,F.touch1){var W=F.touch0[0],se=F.touch0[1],ue=F.touch1[0],de=F.touch1[1],pe=(pe=ue[0]-W[0])*pe+(pe=ue[1]-W[1])*pe,De=(De=de[0]-se[0])*De+(De=de[1]-se[1])*De;te=y(te,Math.sqrt(pe/De)),q=[(W[0]+ue[0])/2,(W[1]+ue[1])/2],X=[(se[0]+de[0])/2,(se[1]+de[1])/2]}else if(F.touch0)q=F.touch0[0],X=F.touch0[1];else return;F.zoom("touch",t(v(te,q,X),F.extent,o))}}function j(k,...B){if(this.__zooming){var F=C(this,B).event(k),O=k.changedTouches,V=O.length,U,te;for(Wi(k),f&&clearTimeout(f),f=setTimeout(function(){f=null},p),U=0;U<V;++U)te=O[U],F.touch0&&F.touch0[2]===te.identifier?delete F.touch0:F.touch1&&F.touch1[2]===te.identifier&&delete F.touch1;if(F.touch1&&!F.touch0&&(F.touch0=F.touch1,delete F.touch1),F.touch0)F.touch0[1]=this.__zoom.invert(F.touch0[0]);else if(F.end(),F.taps===2&&(te=wr(te,this),Math.hypot(d[0]-te[0],d[1]-te[1])<x)){var q=Lt(this).on("dblclick.zoom");q&&q.apply(this,arguments)}}}return _.wheelDelta=function(k){return arguments.length?(n=typeof k=="function"?k:bs(+k),_):n},_.filter=function(k){return arguments.length?(r=typeof k=="function"?k:bs(!!k),_):r},_.touchable=function(k){return arguments.length?(s=typeof k=="function"?k:bs(!!k),_):s},_.extent=function(k){return arguments.length?(e=typeof k=="function"?k:bs([[+k[0][0],+k[0][1]],[+k[1][0],+k[1][1]]]),_):e},_.scaleExtent=function(k){return arguments.length?(i[0]=+k[0],i[1]=+k[1],_):[i[0],i[1]]},_.translateExtent=function(k){return arguments.length?(o[0][0]=+k[0][0],o[1][0]=+k[1][0],o[0][1]=+k[0][1],o[1][1]=+k[1][1],_):[[o[0][0],o[0][1]],[o[1][0],o[1][1]]]},_.constrain=function(k){return arguments.length?(t=k,_):t},_.duration=function(k){return arguments.length?(l=+k,_):l},_.interpolate=function(k){return arguments.length?(a=k,_):a},_.on=function(){var k=u.on.apply(u,arguments);return k===u?_:k},_.clickDistance=function(k){return arguments.length?(m=(k=+k)*k,_):Math.sqrt(m)},_.tapDistance=function(k){return arguments.length?(x=+k,_):x},_}function xd(r={}){const{minZoom:e=.1,maxZoom:t=4,initialTransform:n,zoomable:s=!0,pannable:i=!0,onTransformChange:o}=r,l=b.useRef(null),a=b.useRef(),[u,c]=b.useState(n||{x:0,y:0,k:1});b.useEffect(()=>{if(!l.current)return;const x=fy().scaleExtent([e,t]).filter(y=>!s&&y.type==="wheel"||!i&&(y.type==="mousedown"||y.type==="touchstart")?!1:y.type==="wheel"?s:y.type==="mousedown"||y.type==="touchstart"?y.target.closest("[data-qmap-node]")?!1:i:!0).on("zoom",y=>{const v={x:y.transform.x,y:y.transform.y,k:y.transform.k};c(v),o==null||o(v)});a.current=x;const _=Lt(l.current);return _.call(x),_.on("dblclick.zoom",null),n&&_.call(x.transform,ri.translate(n.x,n.y).scale(n.k)),()=>{_.on(".zoom",null)}},[e,t,s,i]),b.useEffect(()=>{a.current&&a.current.on("zoom",x=>{const _={x:x.transform.x,y:x.transform.y,k:x.transform.k};c(_),o==null||o(_)})},[o]);const d=b.useCallback((x,_,y,v=!0)=>{if(!l.current||!a.current)return;const S=Lt(l.current),D=ri.translate(x,_).scale(y);S.call(a.current.transform,D)},[]),f=b.useCallback(()=>{!l.current||!a.current||Lt(l.current).call(a.current.scaleBy,1.3)},[]),p=b.useCallback(()=>{!l.current||!a.current||Lt(l.current).call(a.current.scaleBy,.7)},[]),g=b.useCallback(()=>{d(0,0,1,!0)},[d]),m=b.useCallback((x,_=50)=>{if(!l.current||!a.current||x.length===0)return;const v=l.current.getBoundingClientRect();let S=1/0,D=1/0,C=-1/0,w=-1/0;for(const O of x){const V=O.width||200,U=O.height||100;S=Math.min(S,O.x),D=Math.min(D,O.y),C=Math.max(C,O.x+V),w=Math.max(w,O.y+U)}const E=C-S,R=w-D,T=(v.width-_*2)/E,N=(v.height-_*2)/R,M=Math.min(T,N,t),j=(S+C)/2,k=(D+w)/2,B=v.width/2-j*M,F=v.height/2-k*M;d(B,F,M,!0)},[t,d]);return{transform:u,containerRef:l,zoomTo:d,zoomIn:f,zoomOut:p,resetZoom:g,fitToContent:m}}function bd(r){const{transform:e,onDragStart:t,onDragMove:n,onDragEnd:s,disabled:i=!1}=r,[o,l]=b.useState(null),[a,u]=b.useState(!1),[c,d]=b.useState({x:0,y:0}),f=b.useRef(null),p=b.useRef({x:0,y:0}),g=b.useRef(e);b.useEffect(()=>{g.current=e},[e]);const m=b.useCallback((v,S)=>{const D=g.current;return{x:(v-D.x)/D.k,y:(S-D.y)/D.k}},[]),x=b.useCallback((v,S)=>{if(i)return;S.preventDefault(),S.stopPropagation();const D=S.currentTarget,C=parseFloat(D.dataset.x||"0"),w=parseFloat(D.dataset.y||"0");f.current={x:S.clientX,y:S.clientY,nodeX:C,nodeY:w},p.current={x:C,y:w},l(v),u(!0),d({x:0,y:0}),t==null||t(v)},[i,m,t]),_=b.useCallback(v=>{if(!a||!o||!f.current)return;const S=g.current,D=f.current,C=v.clientX-D.x,w=v.clientY-D.y,E=C/S.k,R=w/S.k,T=D.nodeX+E,N=D.nodeY+R;p.current={x:T,y:N},d({x:E,y:R}),n==null||n(o,T,N,E,R)},[a,o,n]),y=b.useCallback(()=>{if(!a||!o)return;const v=p.current;s==null||s(o,v.x,v.y),l(null),u(!1),d({x:0,y:0}),f.current=null},[a,o,s]);return b.useEffect(()=>{if(!a)return;const v=D=>{_(D)},S=()=>{y()};return window.addEventListener("mousemove",v),window.addEventListener("mouseup",S),()=>{window.removeEventListener("mousemove",v),window.removeEventListener("mouseup",S)}},[a,_,y]),{draggedNodeId:o,isDragging:a,dragOffset:c,startDrag:x,updateDrag:_,endDrag:y}}function _d(r){const{transform:e,nodePositions:t,disabled:n=!1,controlledSelectedIds:s,onSelectionChange:i}=r,[o,l]=b.useState(new Set),a=s!==void 0,u=a?new Set(s):o,c=a?T=>{const N=typeof T=="function"?T(u):T;i==null||i(Array.from(N))}:l,[d,f]=b.useState(null),[p,g]=b.useState(!1),m=b.useRef(null),x=b.useRef(e),_=b.useRef(t);b.useEffect(()=>{x.current=e},[e]),b.useEffect(()=>{_.current=t},[t]);const y=b.useCallback((T,N)=>{const M=x.current;return{x:(T-M.x)/M.k,y:(N-M.y)/M.k}},[]),v=b.useCallback((T,N)=>{const M=_.current.get(T);if(!M)return!1;const j=M.width||200,k=M.height||100;return M.x<N.x+N.width&&M.x+j>N.x&&M.y<N.y+N.height&&M.y+k>N.y},[]),S=b.useCallback(T=>{if(n||T.target.closest("[data-qmap-node]"))return;T.preventDefault();const M=y(T.clientX,T.clientY);m.current=M,f({x:M.x,y:M.y,width:0,height:0}),g(!0),T.shiftKey||c(new Set)},[n,y]),D=b.useCallback(T=>{if(!p||!m.current)return;const N=m.current,M=y(T.clientX,T.clientY),j={x:Math.min(N.x,M.x),y:Math.min(N.y,M.y),width:Math.abs(M.x-N.x),height:Math.abs(M.y-N.y)};f(j);const k=new Set;for(const[B]of _.current)v(B,j)&&k.add(B);c(k)},[p,y,v]),C=b.useCallback(()=>{p&&(i==null||i(Array.from(u)),g(!1),f(null),m.current=null)},[p,u,i]);b.useEffect(()=>{if(!p)return;const T=M=>{D(M)},N=()=>{C()};return window.addEventListener("mousemove",T),window.addEventListener("mouseup",N),()=>{window.removeEventListener("mousemove",T),window.removeEventListener("mouseup",N)}},[p,D,C]);const w=b.useCallback((T,N=!1)=>{c(M=>{const j=new Set(N?M:[]);return M.has(T)&&N?j.delete(T):j.add(T),i==null||i(Array.from(j)),j})},[i]),E=b.useCallback(()=>{const T=new Set(_.current.keys());c(T),i==null||i(Array.from(T))},[i]),R=b.useCallback(()=>{c(new Set),i==null||i([])},[i]);return{selectedIds:u,setSelectedIds:c,selectionBox:d,isSelecting:p,startSelection:S,updateSelection:D,endSelection:C,toggleSelect:w,selectAll:E,clearSelection:R}}const vd=b.memo(function({nodeId:e,position:t,isSelected:n,isDragging:s,draggable:i,onDragStart:o,onClick:l,onDoubleClick:a,onContextMenu:u,children:c}){const d=b.useCallback(y=>{i&&y.button===0&&o(e,y)},[e,i,o]),f=b.useCallback(y=>{s||l==null||l(y)},[s,l]),p=b.useCallback(y=>{y.stopPropagation(),a==null||a(y)},[a]),g=b.useCallback(y=>{y.preventDefault(),y.stopPropagation(),u==null||u(y)},[u]),m=t.width||200,x=t.height||100,_=t.rotation||0;return h.jsx("div",{"data-qmap-node":e,"data-x":t.x,"data-y":t.y,style:{position:"absolute",left:t.x,top:t.y,width:m,height:x,transform:_!==0?`rotate(${_}deg)`:void 0,transformOrigin:"center center",cursor:i?s?"grabbing":"grab":"pointer",userSelect:"none",opacity:s?.8:1,zIndex:s?1e3:n?100:1,WebkitUserSelect:"none",MozUserSelect:"none",msUserSelect:"none"},onMouseDown:d,onClick:f,onDoubleClick:p,onContextMenu:g,children:c})},(r,e)=>r.nodeId===e.nodeId&&r.position.x===e.position.x&&r.position.y===e.position.y&&r.position.width===e.position.width&&r.position.height===e.position.height&&r.position.rotation===e.position.rotation&&r.isSelected===e.isSelected&&r.isDragging===e.isDragging&&r.draggable===e.draggable&&r.children===e.children);function wd(r,e,t="bezier"){const n={x:r.x+(r.width||200)/2,y:r.y+(r.height||100)/2},s={x:e.x+(e.width||200)/2,y:e.y+(e.height||100)/2};switch(t){case"straight":return`M ${n.x} ${n.y} L ${s.x} ${s.y}`;case"orthogonal":return py(n,s);case"bezier":default:return hy(n,s)}}function hy(r,e){const t=e.x-r.x,n=e.y-r.y,s=Math.sqrt(t*t+n*n),i=Math.min(s*.4,150),o=Math.abs(t)>Math.abs(n);let l,a,u,c;return o?(l=r.x+i*Math.sign(t),a=r.y,u=e.x-i*Math.sign(t),c=e.y):(l=r.x,a=r.y+i*Math.sign(n),u=e.x,c=e.y-i*Math.sign(n)),`M ${r.x} ${r.y} C ${l} ${a}, ${u} ${c}, ${e.x} ${e.y}`}function py(r,e){const t=e.x-r.x,n=e.y-r.y;if(Math.abs(t)>Math.abs(n)){const i=r.x+t/2;return`M ${r.x} ${r.y} H ${i} V ${e.y} H ${e.x}`}else{const i=r.y+n/2;return`M ${r.x} ${r.y} V ${i} H ${e.x} V ${e.y}`}}function ga(r){const e=r.width||200,t=r.height||100;return{x:r.x+e/2,y:r.y+t/2}}function gy(r,e){const t=r.width||200,n=r.height||100,s=ga(r),i=e.x-s.x,o=e.y-s.y;if(i===0&&o===0)return s;const l=t/2,a=n/2,u=Math.abs(o/(i||.001)),c=a/l;let d,f;return u<c?(d=s.x+(i>0?l:-l),f=s.y+o*l/Math.abs(i)):(f=s.y+(o>0?a:-a),d=s.x+i*a/Math.abs(o)),{x:d,y:f}}function my(r,e){const t=r.width||200,n=r.height||100;switch(e){case"left":return{x:r.x,y:r.y+n/2};case"right":return{x:r.x+t,y:r.y+n/2};case"top":return{x:r.x+t/2,y:r.y};case"bottom":return{x:r.x+t/2,y:r.y+n};case"center":default:return ga(r)}}function yy(r,e){return r.x>=e.x&&r.x<=e.x+e.width&&r.y>=e.y&&r.y<=e.y+e.height}function xy(r,e){return r.x<e.x+e.width&&r.x+r.width>e.x&&r.y<e.y+e.height&&r.y+r.height>e.y}function by(r){if(r.length===0)return null;let e=1/0,t=1/0,n=-1/0,s=-1/0;for(const i of r){const o=i.width||200,l=i.height||100;e=Math.min(e,i.x),t=Math.min(t,i.y),n=Math.max(n,i.x+o),s=Math.max(s,i.y+l)}return{x:e,y:t,width:n-e,height:s-t}}function _y(r,e){const t=e.x-r.x,n=e.y-r.y;return Math.sqrt(t*t+n*n)}function vy(r,e){const t=e.x-r.x,n=e.y-r.y;return t*t+n*n}const Cd=b.memo(function({edge:e,sourcePosition:t,targetPosition:n,style:s,color:i,width:o,onClick:l}){const[a,u]=b.useState(!1),c=b.useMemo(()=>wd(t,n,s),[t,n,s]),d=b.useCallback(x=>{x.stopPropagation(),l==null||l(e,x)},[e,l]),f=b.useCallback(()=>{u(!0)},[]),p=b.useCallback(()=>{u(!1)},[]),g=e.color||i,m=e.width||o;return h.jsxs("g",{children:[h.jsx("path",{d:c,fill:"none",stroke:"transparent",strokeWidth:Math.max(m*3,10),style:{cursor:l?"pointer":"default",pointerEvents:"stroke"},onClick:d,onMouseEnter:f,onMouseLeave:p}),h.jsx("path",{d:c,fill:"none",stroke:g,strokeWidth:a?m*1.5:m,strokeLinecap:"round",strokeLinejoin:"round",style:{pointerEvents:"none",transition:"stroke-width 0.15s ease"}}),e.label&&h.jsx(wy,{pathD:c,label:e.label,color:g})]})},(r,e)=>r.edge.id===e.edge.id&&r.sourcePosition.x===e.sourcePosition.x&&r.sourcePosition.y===e.sourcePosition.y&&r.sourcePosition.width===e.sourcePosition.width&&r.sourcePosition.height===e.sourcePosition.height&&r.targetPosition.x===e.targetPosition.x&&r.targetPosition.y===e.targetPosition.y&&r.targetPosition.width===e.targetPosition.width&&r.targetPosition.height===e.targetPosition.height&&r.style===e.style&&r.color===e.color&&r.width===e.width&&r.edge.label===e.edge.label&&r.edge.color===e.edge.color&&r.edge.width===e.edge.width);function wy({pathD:r,label:e,color:t}){const n=b.useMemo(()=>`edge-label-${Math.random().toString(36).substr(2,9)}`,[]);return h.jsxs(h.Fragment,{children:[h.jsx("defs",{children:h.jsx("path",{id:n,d:r})}),h.jsx("text",{fill:t,fontSize:"12",fontFamily:"system-ui, sans-serif",style:{pointerEvents:"none"},children:h.jsx("textPath",{href:`#${n}`,startOffset:"50%",textAnchor:"middle",children:e})})]})}const Sd=b.memo(function({edges:e,nodePositions:t,defaultStyle:n,defaultColor:s,defaultWidth:i,onEdgeClick:o}){const l=b.useMemo(()=>e.filter(a=>t.has(a.source)&&t.has(a.target)),[e,t]);return h.jsx("svg",{style:{position:"absolute",top:0,left:0,width:1,height:1,overflow:"visible",pointerEvents:"none"},children:h.jsx("g",{style:{pointerEvents:"auto"},children:l.map(a=>{const u=t.get(a.source),c=t.get(a.target);return h.jsx(Cd,{edge:a,sourcePosition:u,targetPosition:c,style:a.style||n,color:a.color||s,width:a.width||i,onClick:o},a.id)})})})},(r,e)=>!(r.edges!==e.edges||r.nodePositions!==e.nodePositions||r.defaultStyle!==e.defaultStyle||r.defaultColor!==e.defaultColor||r.defaultWidth!==e.defaultWidth)),kd=b.memo(function({box:e,transform:t}){const n=b.useMemo(()=>({x:e.x*t.k+t.x,y:e.y*t.k+t.y,width:e.width*t.k,height:e.height*t.k}),[e,t]);return h.jsx("div",{style:{position:"absolute",left:n.x,top:n.y,width:n.width,height:n.height,backgroundColor:"rgba(59, 130, 246, 0.1)",border:"1px solid rgba(59, 130, 246, 0.5)",borderRadius:2,pointerEvents:"none",zIndex:9999}})}),Cy=200,Sy=100,ky="bezier",Ey="#94a3b8",Dy=2,Ay=.1,Ty=4;function Ny({viewNode:r,nodes:e,edges:t,renderNode:n,defaultNodeWidth:s=Cy,defaultNodeHeight:i=Sy,onNodeMove:o,onNodeClick:l,onNodeDoubleClick:a,onNodeContextMenu:u,selectedIds:c,onSelectionChange:d,onEdgeClick:f,onViewChange:p,onTransformChange:g,minZoom:m=Ay,maxZoom:x=Ty,initialTransform:_,defaultEdgeStyle:y=ky,defaultEdgeColor:v=Ey,defaultEdgeWidth:S=Dy,draggable:D=!0,selectable:C=!0,zoomable:w=!0,pannable:E=!0,className:R="",style:T,background:N="#f8fafc",showGrid:M=!1,gridSize:j=20}){const k=r.data||{positions:{}},B=k.positions||{},F=b.useMemo(()=>{const Y=new Map;for(const P of e){const me=B[P._id]||{x:0,y:0};Y.set(P._id,{x:me.x,y:me.y,width:me.width||s,height:me.height||i,rotation:me.rotation||0})}return Y},[e,B,s,i]),{transform:O,containerRef:V,zoomIn:U,zoomOut:te,resetZoom:q,fitToContent:X}=xd({minZoom:m,maxZoom:x,initialTransform:_||k.transform,zoomable:w,pannable:E,onTransformChange:Y=>{g==null||g(Y);const P={...k,transform:Y};p==null||p(P)}}),[W,se]=b.useState(new Map),{draggedNodeId:ue,startDrag:de}=bd({transform:O,disabled:!D,onDragStart:Y=>{const P=F.get(Y);P&&se(new Map([[Y,{x:P.x,y:P.y}]]))},onDragMove:(Y,P,me)=>{se(new Map([[Y,{x:P,y:me}]]))},onDragEnd:(Y,P,me)=>{se(new Map),o==null||o(Y,P,me)}}),{selectedIds:pe,selectionBox:De,isSelecting:xe,startSelection:J,toggleSelect:Ce,clearSelection:ne}=_d({transform:O,nodePositions:F,disabled:!C,controlledSelectedIds:c,onSelectionChange:d}),Be=b.useCallback(Y=>{const P=F.get(Y)||{x:0,y:0,width:s,height:i},me=W.get(Y);return me?{...P,x:me.x,y:me.y}:P},[F,W,s,i]),Se=b.useMemo(()=>{const Y=new Map;for(const P of F.keys())Y.set(P,Be(P));return Y},[F,Be]),ke=b.useCallback((Y,P)=>{Ce(Y._id,P.shiftKey),l==null||l(Y,P)},[Ce,l]),Ie=b.useCallback(Y=>{Y.target.closest("[data-qmap-node]")||ne()},[ne]),Le=b.useCallback(Y=>{Y.button===0&&(Y.target.closest("[data-qmap-node]")||J(Y))},[J]),$e=M?`
|
|
186
186
|
linear-gradient(to right, rgba(0,0,0,0.05) 1px, transparent 1px),
|
|
187
187
|
linear-gradient(to bottom, rgba(0,0,0,0.05) 1px, transparent 1px)
|
|
188
188
|
`:void 0;return h.jsxs("div",{ref:V,className:`qmap-container ${R}`,style:{position:"relative",width:"100%",height:"100%",overflow:"hidden",background:N,backgroundImage:$e,backgroundSize:M?`${j}px ${j}px`:void 0,cursor:xe?"crosshair":E?"grab":"default",...T},onMouseDown:Le,onClick:Ie,children:[h.jsxs("div",{className:"qmap-canvas",style:{position:"absolute",transformOrigin:"0 0",transform:`translate(${O.x}px, ${O.y}px) scale(${O.k})`,willChange:"transform"},children:[h.jsx(Sd,{edges:t,nodePositions:Se,defaultStyle:y,defaultColor:v,defaultWidth:S,onEdgeClick:f}),e.map(Y=>{const P=Be(Y._id),me=pe.has(Y._id),We=ue===Y._id;return h.jsx(vd,{nodeId:Y._id,position:P,isSelected:me,isDragging:We,draggable:D,onDragStart:de,onClick:z=>ke(Y,z),onDoubleClick:z=>a==null?void 0:a(Y,z),onContextMenu:z=>u==null?void 0:u(Y,z),children:n(Y,me,P)},Y._id)})]}),De&&h.jsx(kd,{box:De,transform:O}),h.jsxs("div",{className:"qmap-controls",style:{position:"absolute",bottom:16,right:16,display:"flex",flexDirection:"column",gap:4,zIndex:100},children:[h.jsx("button",{onClick:U,style:{width:32,height:32,border:"1px solid #e2e8f0",borderRadius:4,background:"white",cursor:"pointer",fontSize:18,display:"flex",alignItems:"center",justifyContent:"center"},title:"Zoom in",children:"+"}),h.jsx("button",{onClick:te,style:{width:32,height:32,border:"1px solid #e2e8f0",borderRadius:4,background:"white",cursor:"pointer",fontSize:18,display:"flex",alignItems:"center",justifyContent:"center"},title:"Zoom out",children:"−"}),h.jsx("button",{onClick:q,style:{width:32,height:32,border:"1px solid #e2e8f0",borderRadius:4,background:"white",cursor:"pointer",fontSize:12,display:"flex",alignItems:"center",justifyContent:"center"},title:"Reset zoom",children:"1:1"}),h.jsx("button",{onClick:()=>X(Array.from(F.values())),style:{width:32,height:32,border:"1px solid #e2e8f0",borderRadius:4,background:"white",cursor:"pointer",fontSize:12,display:"flex",alignItems:"center",justifyContent:"center"},title:"Fit to content",children:"⊡"})]})]})}exports.$createQRCodeNode=aa;exports.$isQRCodeNode=xg;exports.AnimatedCardFlip=xf;exports.ApiClient=iu;exports.AudioEditor=Vc;exports.AuthFlow=cu;exports.AuthFlowModal=ff;exports.AuthManager=_t;exports.AuthProvider=nf;exports.AuthService=Ao;exports.Card=gf;exports.ComboBox=Ag;exports.ComboStack=Ng;exports.DataOperations=_s;exports.Detail=mf;exports.ForgotPasswordForm=lu;exports.GraphClient=Bd;exports.ImageEditor=Ig;exports.KanbanBoard=Bg;exports.LLMClient=Xd;exports.LoginForm=No;exports.LoginModal=af;exports.Mail=_f;exports.MailClient=su;exports.MailComposer=Eg;exports.MailEditor=Hc;exports.QMap=Ny;exports.QMapEdgeComponent=Cd;exports.QMapEdgeLayer=Sd;exports.QMapNode=vd;exports.QMapSelectionBox=kd;exports.QRCodeNode=un;exports.RegisterForm=au;exports.ResetPasswordForm=uu;exports.SelectableList=vf;exports.Stack=pf;exports.Timeline=Lg;exports.VerifyCodeForm=Gi;exports.VoiceTextEditor=Pg;exports.calculateBoundingBox=by;exports.calculateEdgePath=wd;exports.distance=_y;exports.distanceSquared=vy;exports.getApiClient=To;exports.getAuthService=Zd;exports.getConnectionPoint=gy;exports.getNodeCenter=ga;exports.getNodeSidePoint=my;exports.initializeApiClient=ef;exports.initializeAuthService=Jd;exports.pointInRect=yy;exports.rectsIntersect=xy;exports.useAuth=sf;exports.useMutation=hf;exports.useNodeDrag=bd;exports.useQuery=du;exports.useSelection=_d;exports.useZoomPan=xd;
|
package/dist/index.esm.js
CHANGED
|
@@ -19296,7 +19296,13 @@ const Y2 = ls(function({
|
|
|
19296
19296
|
);
|
|
19297
19297
|
}, (r, e) => r.nodeId === e.nodeId && r.position.x === e.position.x && r.position.y === e.position.y && r.position.width === e.position.width && r.position.height === e.position.height && r.position.rotation === e.position.rotation && r.isSelected === e.isSelected && r.isDragging === e.isDragging && r.draggable === e.draggable && r.children === e.children);
|
|
19298
19298
|
function Q2(r, e, t = "bezier") {
|
|
19299
|
-
const n = {
|
|
19299
|
+
const n = {
|
|
19300
|
+
x: r.x + (r.width || 200) / 2,
|
|
19301
|
+
y: r.y + (r.height || 100) / 2
|
|
19302
|
+
}, i = {
|
|
19303
|
+
x: e.x + (e.width || 200) / 2,
|
|
19304
|
+
y: e.y + (e.height || 100) / 2
|
|
19305
|
+
};
|
|
19300
19306
|
switch (t) {
|
|
19301
19307
|
case "straight":
|
|
19302
19308
|
return `M ${n.x} ${n.y} L ${i.x} ${i.y}`;
|
package/package.json
CHANGED