@qwanyx/stack 0.2.77 → 0.2.78
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 +96 -106
- 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 Ag={background:"#ffffff",text:"#111827",textSecondary:"#6b7280",border:"#e5e7eb",primary:"#3b82f6",chipBackground:"#f3f4f6",chipText:"#374151",hoverBackground:"#f9fafb"};function Tg({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={...Ag,...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 Ng={background:"#ffffff",cardBackground:"#f9fafb",cardHover:"#f3f4f6",text:"#111827",textSecondary:"#6b7280",border:"#e5e7eb",primary:"#3b82f6"};function Bg({options:r,value:e,type:t,placeholder:n="Search...",onItemClick:s,onClear:i,onCreate:o,maxHeight:l=300,className:a="",theme:u={}}){const c={...Ng,...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 Rg({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 Mg={background:"#ffffff",hourLineColor:"#e5e7eb",halfHourLineColor:"#f3f4f6",hourTextColor:"#9ca3af",currentTimeColor:"#ef4444",allDayBackground:"#f9fafb",allDayBorder:"#e5e7eb"};function Fg(r){const e=r.match(/^(\d{1,2}):(\d{2})$/);return e?{hours:parseInt(e[1],10),minutes:parseInt(e[2],10)}:null}function jg(r){const e=r%12||12,t=r<12?"AM":"PM";return`${e} ${t}`}function Lg(r){const e=new Date;return r.getDate()===e.getDate()&&r.getMonth()===e.getMonth()&&r.getFullYear()===e.getFullYear()}function Pg({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={...Mg,...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=Fg(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||!Lg(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:jg(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 Gc({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 Ig({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(Gc,{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 ms={"4/3":4/3,"16/9":16/9,"1/1":1,"3/4":3/4,"9/16":9/16,free:null};function Og({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(ms))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=ms[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=ms[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(ms).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 zg={value:()=>{}};function ca(){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 Ss(t)}function Ss(r){this._=r}function $g(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}})}Ss.prototype=ca.prototype={constructor:Ss,on:function(r,e){var t=this._,n=$g(r+"",t),s,i=-1,o=n.length;if(arguments.length<2){for(;++i<o;)if((s=(r=n[i]).type)&&(s=qg(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]=Ol(t[s],r.name,e);else if(e==null)for(s in t)t[s]=Ol(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 Ss(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 qg(r,e){for(var t=0,n=r.length,s;t<n;++t)if((s=r[t]).name===e)return s.value}function Ol(r,e,t){for(var n=0,s=r.length;n<s;++n)if(r[n].name===e){r[n]=zg,r=r.slice(0,n).concat(r.slice(n+1));break}return t!=null&&r.push({name:e,value:t}),r}var _o="http://www.w3.org/1999/xhtml";const zl={svg:"http://www.w3.org/2000/svg",xhtml:_o,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function wi(r){var e=r+="",t=e.indexOf(":");return t>=0&&(e=r.slice(0,t))!=="xmlns"&&(r=r.slice(t+1)),zl.hasOwnProperty(e)?{space:zl[e],local:r}:r}function Ug(r){return function(){var e=this.ownerDocument,t=this.namespaceURI;return t===_o&&e.documentElement.namespaceURI===_o?e.createElement(r):e.createElementNS(t,r)}}function Wg(r){return function(){return this.ownerDocument.createElementNS(r.space,r.local)}}function Kc(r){var e=wi(r);return(e.local?Wg:Ug)(e)}function Hg(){}function da(r){return r==null?Hg:function(){return this.querySelector(r)}}function Vg(r){typeof r!="function"&&(r=da(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 Gg(r){return r==null?[]:Array.isArray(r)?r:Array.from(r)}function Kg(){return[]}function Yc(r){return r==null?Kg:function(){return this.querySelectorAll(r)}}function Yg(r){return function(){return Gg(r.apply(this,arguments))}}function Qg(r){typeof r=="function"?r=Yg(r):r=Yc(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 Qc(r){return function(){return this.matches(r)}}function Xc(r){return function(e){return e.matches(r)}}var Xg=Array.prototype.find;function Jg(r){return function(){return Xg.call(this.children,r)}}function Zg(){return this.firstElementChild}function e0(r){return this.select(r==null?Zg:Jg(typeof r=="function"?r:Xc(r)))}var t0=Array.prototype.filter;function r0(){return Array.from(this.children)}function n0(r){return function(){return t0.call(this.children,r)}}function s0(r){return this.selectAll(r==null?r0:n0(typeof r=="function"?r:Xc(r)))}function i0(r){typeof r!="function"&&(r=Qc(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 Jc(r){return new Array(r.length)}function o0(){return new Dt(this._enter||this._groups.map(Jc),this._parents)}function Xs(r,e){this.ownerDocument=r.ownerDocument,this.namespaceURI=r.namespaceURI,this._next=null,this._parent=r,this.__data__=e}Xs.prototype={constructor:Xs,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 a0(r){return function(){return r}}function l0(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 Xs(r,i[o]);for(;o<a;++o)(l=e[o])&&(s[o]=l)}function u0(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 Xs(r,i[l]);for(l=0;l<c;++l)(a=e[l])&&u.get(f[l])===a&&(s[l]=a)}function c0(r){return r.__data__}function d0(r,e){if(!arguments.length)return Array.from(this,c0);var t=e?u0:l0,n=this._parents,s=this._groups;typeof r!="function"&&(r=a0(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=f0(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 f0(r){return typeof r=="object"&&"length"in r?r:Array.from(r)}function h0(){return new Dt(this._exit||this._groups.map(Jc),this._parents)}function p0(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 g0(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 m0(){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 y0(r){r||(r=x0);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 x0(r,e){return r<e?-1:r>e?1:r>=e?0:NaN}function b0(){var r=arguments[0];return arguments[0]=this,r.apply(null,arguments),this}function _0(){return Array.from(this)}function v0(){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 w0(){let r=0;for(const e of this)++r;return r}function C0(){return!this.node()}function S0(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 k0(r){return function(){this.removeAttribute(r)}}function E0(r){return function(){this.removeAttributeNS(r.space,r.local)}}function D0(r,e){return function(){this.setAttribute(r,e)}}function A0(r,e){return function(){this.setAttributeNS(r.space,r.local,e)}}function T0(r,e){return function(){var t=e.apply(this,arguments);t==null?this.removeAttribute(r):this.setAttribute(r,t)}}function N0(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 B0(r,e){var t=wi(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?E0:k0:typeof e=="function"?t.local?N0:T0:t.local?A0:D0)(t,e))}function Zc(r){return r.ownerDocument&&r.ownerDocument.defaultView||r.document&&r||r.defaultView}function R0(r){return function(){this.style.removeProperty(r)}}function M0(r,e,t){return function(){this.style.setProperty(r,e,t)}}function F0(r,e,t){return function(){var n=e.apply(this,arguments);n==null?this.style.removeProperty(r):this.style.setProperty(r,n,t)}}function j0(r,e,t){return arguments.length>1?this.each((e==null?R0:typeof e=="function"?F0:M0)(r,e,t??"")):rn(this.node(),r)}function rn(r,e){return r.style.getPropertyValue(e)||Zc(r).getComputedStyle(r,null).getPropertyValue(e)}function L0(r){return function(){delete this[r]}}function P0(r,e){return function(){this[r]=e}}function I0(r,e){return function(){var t=e.apply(this,arguments);t==null?delete this[r]:this[r]=t}}function O0(r,e){return arguments.length>1?this.each((e==null?L0:typeof e=="function"?I0:P0)(r,e)):this.node()[r]}function ed(r){return r.trim().split(/^|\s+/)}function fa(r){return r.classList||new td(r)}function td(r){this._node=r,this._names=ed(r.getAttribute("class")||"")}td.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 rd(r,e){for(var t=fa(r),n=-1,s=e.length;++n<s;)t.add(e[n])}function nd(r,e){for(var t=fa(r),n=-1,s=e.length;++n<s;)t.remove(e[n])}function z0(r){return function(){rd(this,r)}}function $0(r){return function(){nd(this,r)}}function q0(r,e){return function(){(e.apply(this,arguments)?rd:nd)(this,r)}}function U0(r,e){var t=ed(r+"");if(arguments.length<2){for(var n=fa(this.node()),s=-1,i=t.length;++s<i;)if(!n.contains(t[s]))return!1;return!0}return this.each((typeof e=="function"?q0:e?z0:$0)(t,e))}function W0(){this.textContent=""}function H0(r){return function(){this.textContent=r}}function V0(r){return function(){var e=r.apply(this,arguments);this.textContent=e??""}}function G0(r){return arguments.length?this.each(r==null?W0:(typeof r=="function"?V0:H0)(r)):this.node().textContent}function K0(){this.innerHTML=""}function Y0(r){return function(){this.innerHTML=r}}function Q0(r){return function(){var e=r.apply(this,arguments);this.innerHTML=e??""}}function X0(r){return arguments.length?this.each(r==null?K0:(typeof r=="function"?Q0:Y0)(r)):this.node().innerHTML}function J0(){this.nextSibling&&this.parentNode.appendChild(this)}function Z0(){return this.each(J0)}function em(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function tm(){return this.each(em)}function rm(r){var e=typeof r=="function"?r:Kc(r);return this.select(function(){return this.appendChild(e.apply(this,arguments))})}function nm(){return null}function sm(r,e){var t=typeof r=="function"?r:Kc(r),n=e==null?nm:typeof e=="function"?e:da(e);return this.select(function(){return this.insertBefore(t.apply(this,arguments),n.apply(this,arguments)||null)})}function im(){var r=this.parentNode;r&&r.removeChild(this)}function om(){return this.each(im)}function am(){var r=this.cloneNode(!1),e=this.parentNode;return e?e.insertBefore(r,this.nextSibling):r}function lm(){var r=this.cloneNode(!0),e=this.parentNode;return e?e.insertBefore(r,this.nextSibling):r}function um(r){return this.select(r?lm:am)}function cm(r){return arguments.length?this.property("__data__",r):this.node().__data__}function dm(r){return function(e){r.call(this,e,this.__data__)}}function fm(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 hm(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 pm(r,e,t){return function(){var n=this.__on,s,i=dm(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 gm(r,e,t){var n=fm(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?pm:hm,s=0;s<i;++s)this.each(l(n[s],e,t));return this}function sd(r,e,t){var n=Zc(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 mm(r,e){return function(){return sd(this,r,e)}}function ym(r,e){return function(){return sd(this,r,e.apply(this,arguments))}}function xm(r,e){return this.each((typeof e=="function"?ym:mm)(r,e))}function*bm(){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 id=[null];function Dt(r,e){this._groups=r,this._parents=e}function is(){return new Dt([[document.documentElement]],id)}function _m(){return this}Dt.prototype=is.prototype={constructor:Dt,select:Vg,selectAll:Qg,selectChild:e0,selectChildren:s0,filter:i0,data:d0,enter:o0,exit:h0,join:p0,merge:g0,selection:_m,order:m0,sort:y0,call:b0,nodes:_0,node:v0,size:w0,empty:C0,each:S0,attr:B0,style:j0,property:O0,classed:U0,text:G0,html:X0,raise:Z0,lower:tm,append:rm,insert:sm,remove:om,clone:um,datum:cm,on:gm,dispatch:xm,[Symbol.iterator]:bm};function Lt(r){return typeof r=="string"?new Dt([[document.querySelector(r)]],[document.documentElement]):new Dt([[r]],id)}function vm(r){let e;for(;e=r.sourceEvent;)r=e;return r}function wr(r,e){if(r=vm(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 vo={capture:!0,passive:!1};function wo(r){r.preventDefault(),r.stopImmediatePropagation()}function wm(r){var e=r.document.documentElement,t=Lt(r).on("dragstart.drag",wo,vo);"onselectstart"in e?t.on("selectstart.drag",wo,vo):(e.__noselect=e.style.MozUserSelect,e.style.MozUserSelect="none")}function Cm(r,e){var t=r.document.documentElement,n=Lt(r).on("dragstart.drag",null);e&&(n.on("click.drag",wo,vo),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 ha(r,e,t){r.prototype=e.prototype=t,t.constructor=r}function od(r,e){var t=Object.create(r.prototype);for(var n in e)t[n]=e[n];return t}function os(){}var $n=.7,Js=1/$n,Xr="\\s*([+-]?\\d+)\\s*",qn="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Gt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Sm=/^#([0-9a-f]{3,8})$/,km=new RegExp(`^rgb\\(${Xr},${Xr},${Xr}\\)$`),Em=new RegExp(`^rgb\\(${Gt},${Gt},${Gt}\\)$`),Dm=new RegExp(`^rgba\\(${Xr},${Xr},${Xr},${qn}\\)$`),Am=new RegExp(`^rgba\\(${Gt},${Gt},${Gt},${qn}\\)$`),Tm=new RegExp(`^hsl\\(${qn},${Gt},${Gt}\\)$`),Nm=new RegExp(`^hsla\\(${qn},${Gt},${Gt},${qn}\\)$`),$l={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};ha(os,Un,{copy(r){return Object.assign(new this.constructor,this,r)},displayable(){return this.rgb().displayable()},hex:ql,formatHex:ql,formatHex8:Bm,formatHsl:Rm,formatRgb:Ul,toString:Ul});function ql(){return this.rgb().formatHex()}function Bm(){return this.rgb().formatHex8()}function Rm(){return ad(this).formatHsl()}function Ul(){return this.rgb().formatRgb()}function Un(r){var e,t;return r=(r+"").trim().toLowerCase(),(e=Sm.exec(r))?(t=e[1].length,e=parseInt(e[1],16),t===6?Wl(e):t===3?new wt(e>>8&15|e>>4&240,e>>4&15|e&240,(e&15)<<4|e&15,1):t===8?ys(e>>24&255,e>>16&255,e>>8&255,(e&255)/255):t===4?ys(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=km.exec(r))?new wt(e[1],e[2],e[3],1):(e=Em.exec(r))?new wt(e[1]*255/100,e[2]*255/100,e[3]*255/100,1):(e=Dm.exec(r))?ys(e[1],e[2],e[3],e[4]):(e=Am.exec(r))?ys(e[1]*255/100,e[2]*255/100,e[3]*255/100,e[4]):(e=Tm.exec(r))?Gl(e[1],e[2]/100,e[3]/100,1):(e=Nm.exec(r))?Gl(e[1],e[2]/100,e[3]/100,e[4]):$l.hasOwnProperty(r)?Wl($l[r]):r==="transparent"?new wt(NaN,NaN,NaN,0):null}function Wl(r){return new wt(r>>16&255,r>>8&255,r&255,1)}function ys(r,e,t,n){return n<=0&&(r=e=t=NaN),new wt(r,e,t,n)}function Mm(r){return r instanceof os||(r=Un(r)),r?(r=r.rgb(),new wt(r.r,r.g,r.b,r.opacity)):new wt}function Co(r,e,t,n){return arguments.length===1?Mm(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}ha(wt,Co,od(os,{brighter(r){return r=r==null?Js:Math.pow(Js,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),Zs(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:Hl,formatHex:Hl,formatHex8:Fm,formatRgb:Vl,toString:Vl}));function Hl(){return`#${Sr(this.r)}${Sr(this.g)}${Sr(this.b)}`}function Fm(){return`#${Sr(this.r)}${Sr(this.g)}${Sr(this.b)}${Sr((isNaN(this.opacity)?1:this.opacity)*255)}`}function Vl(){const r=Zs(this.opacity);return`${r===1?"rgb(":"rgba("}${Tr(this.r)}, ${Tr(this.g)}, ${Tr(this.b)}${r===1?")":`, ${r})`}`}function Zs(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 Gl(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 ad(r){if(r instanceof Pt)return new Pt(r.h,r.s,r.l,r.opacity);if(r instanceof os||(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 jm(r,e,t,n){return arguments.length===1?ad(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}ha(Pt,jm,od(os,{brighter(r){return r=r==null?Js:Math.pow(Js,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(Ui(r>=240?r-240:r+120,s,n),Ui(r,s,n),Ui(r<120?r+240:r-120,s,n),this.opacity)},clamp(){return new Pt(Kl(this.h),xs(this.s),xs(this.l),Zs(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=Zs(this.opacity);return`${r===1?"hsl(":"hsla("}${Kl(this.h)}, ${xs(this.s)*100}%, ${xs(this.l)*100}%${r===1?")":`, ${r})`}`}}));function Kl(r){return r=(r||0)%360,r<0?r+360:r}function xs(r){return Math.max(0,Math.min(1,r||0))}function Ui(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 ld=r=>()=>r;function Lm(r,e){return function(t){return r+t*e}}function Pm(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 Im(r){return(r=+r)==1?ud:function(e,t){return t-e?Pm(e,t,r):ld(isNaN(e)?t:e)}}function ud(r,e){var t=e-r;return t?Lm(r,t):ld(isNaN(r)?e:r)}const Yl=function r(e){var t=Im(e);function n(s,i){var o=t((s=Co(s)).r,(i=Co(i)).r),l=t(s.g,i.g),a=t(s.b,i.b),u=ud(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 So=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Wi=new RegExp(So.source,"g");function Om(r){return function(){return r}}function zm(r){return function(e){return r(e)+""}}function $m(r,e){var t=So.lastIndex=Wi.lastIndex=0,n,s,i,o=-1,l=[],a=[];for(r=r+"",e=e+"";(n=So.exec(r))&&(s=Wi.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=Wi.lastIndex;return t<e.length&&(i=e.slice(t),l[o]?l[o]+=i:l[++o]=i),l.length<2?a[0]?zm(a[0].x):Om(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 Ql=180/Math.PI,ko={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function cd(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)*Ql,skewX:Math.atan(a)*Ql,scaleX:o,scaleY:l}}var bs;function qm(r){const e=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(r+"");return e.isIdentity?ko:cd(e.a,e.b,e.c,e.d,e.e,e.f)}function Um(r){return r==null||(bs||(bs=document.createElementNS("http://www.w3.org/2000/svg","g")),bs.setAttribute("transform",r),!(r=bs.transform.baseVal.consolidate()))?ko:(r=r.matrix,cd(r.a,r.b,r.c,r.d,r.e,r.f))}function dd(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 Wm=dd(qm,"px, ","px)","deg)"),Hm=dd(Um,", ",")",")"),Vm=1e-12;function Xl(r){return((r=Math.exp(r))+1/r)/2}function Gm(r){return((r=Math.exp(r))-1/r)/2}function Km(r){return((r=Math.exp(2*r))-1)/(r+1)}const Ym=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<Vm)_=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=Xl(D),T=u/(t*y)*(R*Km(e*E+D)-Gm(D));return[l+T*p,a+T*g,u*R/Xl(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,fd=1e3,ei,Sn,ti=0,Lr=0,Ci=0,Wn=typeof performance=="object"&&performance.now?performance:Date,hd=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(r){setTimeout(r,17)};function pa(){return Lr||(hd(Qm),Lr=Wn.now()+Ci)}function Qm(){Lr=0}function ri(){this._call=this._time=this._next=null}ri.prototype=pd.prototype={constructor:ri,restart:function(r,e,t){if(typeof r!="function")throw new TypeError("callback is not a function");t=(t==null?pa():+t)+(e==null?0:+e),!this._next&&Sn!==this&&(Sn?Sn._next=this:ei=this,Sn=this),this._call=r,this._time=t,Eo()},stop:function(){this._call&&(this._call=null,this._time=1/0,Eo())}};function pd(r,e,t){var n=new ri;return n.restart(r,e,t),n}function Xm(){pa(),++nn;for(var r=ei,e;r;)(e=Lr-r._time)>=0&&r._call.call(void 0,e),r=r._next;--nn}function Jl(){Lr=(ti=Wn.now())+Ci,nn=Cn=0;try{Xm()}finally{nn=0,Zm(),Lr=0}}function Jm(){var r=Wn.now(),e=r-ti;e>fd&&(Ci-=e,ti=r)}function Zm(){for(var r,e=ei,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:ei=t);Sn=r,Eo(n)}function Eo(r){if(!nn){Cn&&(Cn=clearTimeout(Cn));var e=r-Lr;e>24?(r<1/0&&(Cn=setTimeout(Jl,r-Wn.now()-Ci)),yn&&(yn=clearInterval(yn))):(yn||(ti=Wn.now(),yn=setInterval(Jm,fd)),nn=1,hd(Jl))}}function Zl(r,e,t){var n=new ri;return e=e==null?0:+e,n.restart(s=>{n.stop(),r(s+e)},e,t),n}var e2=ca("start","end","cancel","interrupt"),t2=[],gd=0,eu=1,Do=2,ks=3,tu=4,Ao=5,Es=6;function Si(r,e,t,n,s,i){var o=r.__transition;if(!o)r.__transition={};else if(t in o)return;r2(r,t,{name:e,index:n,group:s,on:e2,tween:t2,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:gd})}function ga(r,e){var t=qt(r,e);if(t.state>gd)throw new Error("too late; already scheduled");return t}function Jt(r,e){var t=qt(r,e);if(t.state>ks)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 r2(r,e,t){var n=r.__transition,s;n[e]=t,t.timer=pd(i,0,t.time);function i(u){t.state=eu,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!==eu)return a();for(c in n)if(p=n[c],p.name===t.name){if(p.state===ks)return Zl(o);p.state===tu?(p.state=Es,p.timer.stop(),p.on.call("interrupt",r,r.__data__,p.index,p.group),delete n[c]):+c<e&&(p.state=Es,p.timer.stop(),p.on.call("cancel",r,r.__data__,p.index,p.group),delete n[c])}if(Zl(function(){t.state===ks&&(t.state=tu,t.timer.restart(l,t.delay,t.time),l(u))}),t.state=Do,t.on.call("start",r,r.__data__,t.index,t.group),t.state===Do){for(t.state=ks,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=Ao,1),d=-1,f=s.length;++d<f;)s[d].call(r,c);t.state===Ao&&(t.on.call("end",r,r.__data__,t.index,t.group),a())}function a(){t.state=Es,t.timer.stop(),delete n[e];for(var u in n)return;delete r.__transition}}function Ds(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>Do&&n.state<Ao,n.state=Es,n.timer.stop(),n.on.call(s?"interrupt":"cancel",r,r.__data__,n.index,n.group),delete t[o]}i&&delete r.__transition}}function n2(r){return this.each(function(){Ds(this,r)})}function s2(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 i2(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 o2(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?s2:i2)(t,r,e))}function ma(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 md(r,e){var t;return(typeof e=="number"?fr:e instanceof Un?Yl:(t=Un(e))?(e=t,Yl):$m)(r,e)}function a2(r){return function(){this.removeAttribute(r)}}function l2(r){return function(){this.removeAttributeNS(r.space,r.local)}}function u2(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 c2(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 d2(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 f2(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 h2(r,e){var t=wi(r),n=t==="transform"?Hm:md;return this.attrTween(r,typeof e=="function"?(t.local?f2:d2)(t,n,ma(this,"attr."+r,e)):e==null?(t.local?l2:a2)(t):(t.local?c2:u2)(t,n,e))}function p2(r,e){return function(t){this.setAttribute(r,e.call(this,t))}}function g2(r,e){return function(t){this.setAttributeNS(r.space,r.local,e.call(this,t))}}function m2(r,e){var t,n;function s(){var i=e.apply(this,arguments);return i!==n&&(t=(n=i)&&g2(r,i)),t}return s._value=e,s}function y2(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 x2(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=wi(r);return this.tween(t,(n.local?m2:y2)(n,e))}function b2(r,e){return function(){ga(this,r).delay=+e.apply(this,arguments)}}function _2(r,e){return e=+e,function(){ga(this,r).delay=e}}function v2(r){var e=this._id;return arguments.length?this.each((typeof r=="function"?b2:_2)(e,r)):qt(this.node(),e).delay}function w2(r,e){return function(){Jt(this,r).duration=+e.apply(this,arguments)}}function C2(r,e){return e=+e,function(){Jt(this,r).duration=e}}function S2(r){var e=this._id;return arguments.length?this.each((typeof r=="function"?w2:C2)(e,r)):qt(this.node(),e).duration}function k2(r,e){if(typeof e!="function")throw new Error;return function(){Jt(this,r).ease=e}}function E2(r){var e=this._id;return arguments.length?this.each(k2(e,r)):qt(this.node(),e).ease}function D2(r,e){return function(){var t=e.apply(this,arguments);if(typeof t!="function")throw new Error;Jt(this,r).ease=t}}function A2(r){if(typeof r!="function")throw new Error;return this.each(D2(this._id,r))}function T2(r){typeof r!="function"&&(r=Qc(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 N2(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 B2(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 R2(r,e,t){var n,s,i=B2(e)?ga:Jt;return function(){var o=i(this,r),l=o.on;l!==n&&(s=(n=l).copy()).on(e,t),o.on=s}}function M2(r,e){var t=this._id;return arguments.length<2?qt(this.node(),t).on.on(r):this.each(R2(t,r,e))}function F2(r){return function(){var e=this.parentNode;for(var t in this.__transition)if(+t!==r)return;e&&e.removeChild(this)}}function j2(){return this.on("end.remove",F2(this._id))}function L2(r){var e=this._name,t=this._id;typeof r!="function"&&(r=da(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,Si(u[f],e,t,f,u,qt(c,t)));return new ir(i,this._parents,e,t)}function P2(r){var e=this._name,t=this._id;typeof r!="function"&&(r=Yc(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])&&Si(p,e,t,m,f,g);i.push(f),o.push(c)}return new ir(i,o,e,t)}var I2=is.prototype.constructor;function O2(){return new I2(this._groups,this._parents)}function z2(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 yd(r){return function(){this.style.removeProperty(r)}}function $2(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 q2(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 U2(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=yd(e)):void 0;(u!==t||s!==c)&&(n=(t=u).copy()).on(o,s=c),a.on=n}}function W2(r,e,t){var n=(r+="")=="transform"?Wm:md;return e==null?this.styleTween(r,z2(r,n)).on("end.style."+r,yd(r)):typeof e=="function"?this.styleTween(r,q2(r,n,ma(this,"style."+r,e))).each(U2(this._id,r)):this.styleTween(r,$2(r,n,e),t).on("end.style."+r,null)}function H2(r,e,t){return function(n){this.style.setProperty(r,e.call(this,n),t)}}function V2(r,e,t){var n,s;function i(){var o=e.apply(this,arguments);return o!==s&&(n=(s=o)&&H2(r,o,t)),n}return i._value=e,i}function G2(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,V2(r,e,t??""))}function K2(r){return function(){this.textContent=r}}function Y2(r){return function(){var e=r(this);this.textContent=e??""}}function Q2(r){return this.tween("text",typeof r=="function"?Y2(ma(this,"text",r)):K2(r==null?"":r+""))}function X2(r){return function(e){this.textContent=r.call(this,e)}}function J2(r){var e,t;function n(){var s=r.apply(this,arguments);return s!==t&&(e=(t=s)&&X2(s)),e}return n._value=r,n}function Z2(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,J2(r))}function ey(){for(var r=this._name,e=this._id,t=xd(),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);Si(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 ty(){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 ry=0;function ir(r,e,t,n){this._groups=r,this._parents=e,this._name=t,this._id=n}function xd(){return++ry}var tr=is.prototype;ir.prototype={constructor:ir,select:L2,selectAll:P2,selectChild:tr.selectChild,selectChildren:tr.selectChildren,filter:T2,merge:N2,selection:O2,transition:ey,call:tr.call,nodes:tr.nodes,node:tr.node,size:tr.size,empty:tr.empty,each:tr.each,on:M2,attr:h2,attrTween:x2,style:W2,styleTween:G2,text:Q2,textTween:Z2,remove:j2,tween:o2,delay:v2,duration:S2,ease:E2,easeVarying:A2,end:ty,[Symbol.iterator]:tr[Symbol.iterator]};function ny(r){return((r*=2)<=1?r*r*r:(r-=2)*r*r+2)/2}var sy={time:null,delay:0,duration:250,ease:ny};function iy(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 oy(r){var e,t;r instanceof ir?(e=r._id,r=r._name):(e=xd(),(t=sy).time=pa(),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])&&Si(a,r,e,u,o,t||iy(a,e));return new ir(n,this._parents,r,e)}is.prototype.interrupt=n2;is.prototype.transition=oy;const _s=r=>()=>r;function ay(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 ni=new nr(1,0,0);nr.prototype;function Hi(r){r.stopImmediatePropagation()}function xn(r){r.preventDefault(),r.stopImmediatePropagation()}function ly(r){return(!r.ctrlKey||r.type==="wheel")&&!r.button}function uy(){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 ru(){return this.__zoom||ni}function cy(r){return-r.deltaY*(r.deltaMode===1?.05:r.deltaMode?1:.002)*(r.ctrlKey?10:1)}function dy(){return navigator.maxTouchPoints||"ontouchstart"in this}function fy(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 hy(){var r=ly,e=uy,t=fy,n=cy,s=dy,i=[0,1/0],o=[[-1/0,-1/0],[1/0,1/0]],l=250,a=Ym,u=ca("start","zoom","end"),c,d,f,p=500,g=150,m=0,x=10;function _(k){k.property("__zoom",ru).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",ru),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(ni.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 ay(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)],Ds(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;wm(k.view),Hi(k),O.mouse=[U,this.__zoom.invert(U)],Ds(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),Cm(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(Hi(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)),Ds(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(Hi(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:_s(+k),_):n},_.filter=function(k){return arguments.length?(r=typeof k=="function"?k:_s(!!k),_):r},_.touchable=function(k){return arguments.length?(s=typeof k=="function"?k:_s(!!k),_):s},_.extent=function(k){return arguments.length?(e=typeof k=="function"?k:_s([[+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 bd(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=hy().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,ni.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=ni.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 _d(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 vd(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 wd=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 Cd(r,e,t="bezier"){const n=Hn(r),s=Hn(e),i=To(r,s),o=To(e,n);switch(t){case"straight":return`M ${i.x} ${i.y} L ${o.x} ${o.y}`;case"orthogonal":return gy(i,o);case"bezier":default:return py(i,o)}}function py(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 gy(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 Hn(r){const e=r.width||200,t=r.height||100;return{x:r.x+e/2,y:r.y+t/2}}function To(r,e){const t=r.width||200,n=r.height||100,s=Hn(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 Hn(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 Sd=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(()=>Cd(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 kd=b.memo(function({edges:e,nodePositions:t,defaultStyle:n,defaultColor:s,defaultWidth:i,onEdgeClick:o}){const l=b.useMemo(()=>e.filter(u=>t.has(u.source)&&t.has(u.target)),[e,t]),a=b.useMemo(()=>{if(t.size===0)return"0 0 1000 1000";let u=1/0,c=1/0,d=-1/0,f=-1/0;for(const p of t.values()){const g=p.width||200,m=p.height||100;u=Math.min(u,p.x-100),c=Math.min(c,p.y-100),d=Math.max(d,p.x+g+100),f=Math.max(f,p.y+m+100)}return u-=1e3,c-=1e3,d+=1e3,f+=1e3,`${u} ${c} ${d-u} ${f-c}`},[t]);return h.jsx("svg",{style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",overflow:"visible",pointerEvents:"none"},viewBox:a,preserveAspectRatio:"none",children:h.jsx("g",{style:{pointerEvents:"auto"},children:l.map(u=>{const c=t.get(u.source),d=t.get(u.target);return h.jsx(Sd,{edge:u,sourcePosition:c,targetPosition:d,style:u.style||n,color:u.color||s,width:u.width||i,onClick:o},u.id)})})})},(r,e)=>!(r.edges!==e.edges||r.nodePositions!==e.nodePositions||r.defaultStyle!==e.defaultStyle||r.defaultColor!==e.defaultColor||r.defaultWidth!==e.defaultWidth)),Ed=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}=bd({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}=_d({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}=vd({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(Gc,{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 ms={"4/3":4/3,"16/9":16/9,"1/1":1,"3/4":3/4,"9/16":9/16,free:null};function Og({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(ms))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=ms[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=ms[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(ms).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 zg={value:()=>{}};function ca(){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 Ss(t)}function Ss(r){this._=r}function $g(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}})}Ss.prototype=ca.prototype={constructor:Ss,on:function(r,e){var t=this._,n=$g(r+"",t),s,i=-1,o=n.length;if(arguments.length<2){for(;++i<o;)if((s=(r=n[i]).type)&&(s=qg(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]=Ol(t[s],r.name,e);else if(e==null)for(s in t)t[s]=Ol(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 Ss(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 qg(r,e){for(var t=0,n=r.length,s;t<n;++t)if((s=r[t]).name===e)return s.value}function Ol(r,e,t){for(var n=0,s=r.length;n<s;++n)if(r[n].name===e){r[n]=zg,r=r.slice(0,n).concat(r.slice(n+1));break}return t!=null&&r.push({name:e,value:t}),r}var _o="http://www.w3.org/1999/xhtml";const zl={svg:"http://www.w3.org/2000/svg",xhtml:_o,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function wi(r){var e=r+="",t=e.indexOf(":");return t>=0&&(e=r.slice(0,t))!=="xmlns"&&(r=r.slice(t+1)),zl.hasOwnProperty(e)?{space:zl[e],local:r}:r}function Ug(r){return function(){var e=this.ownerDocument,t=this.namespaceURI;return t===_o&&e.documentElement.namespaceURI===_o?e.createElement(r):e.createElementNS(t,r)}}function Wg(r){return function(){return this.ownerDocument.createElementNS(r.space,r.local)}}function Kc(r){var e=wi(r);return(e.local?Wg:Ug)(e)}function Hg(){}function da(r){return r==null?Hg:function(){return this.querySelector(r)}}function Vg(r){typeof r!="function"&&(r=da(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 Gg(r){return r==null?[]:Array.isArray(r)?r:Array.from(r)}function Kg(){return[]}function Yc(r){return r==null?Kg:function(){return this.querySelectorAll(r)}}function Yg(r){return function(){return Gg(r.apply(this,arguments))}}function Qg(r){typeof r=="function"?r=Yg(r):r=Yc(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 Qc(r){return function(){return this.matches(r)}}function Xc(r){return function(e){return e.matches(r)}}var Xg=Array.prototype.find;function Jg(r){return function(){return Xg.call(this.children,r)}}function Zg(){return this.firstElementChild}function e0(r){return this.select(r==null?Zg:Jg(typeof r=="function"?r:Xc(r)))}var t0=Array.prototype.filter;function r0(){return Array.from(this.children)}function n0(r){return function(){return t0.call(this.children,r)}}function s0(r){return this.selectAll(r==null?r0:n0(typeof r=="function"?r:Xc(r)))}function i0(r){typeof r!="function"&&(r=Qc(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 Jc(r){return new Array(r.length)}function o0(){return new Dt(this._enter||this._groups.map(Jc),this._parents)}function Xs(r,e){this.ownerDocument=r.ownerDocument,this.namespaceURI=r.namespaceURI,this._next=null,this._parent=r,this.__data__=e}Xs.prototype={constructor:Xs,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 a0(r){return function(){return r}}function l0(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 Xs(r,i[o]);for(;o<a;++o)(l=e[o])&&(s[o]=l)}function u0(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 Xs(r,i[l]);for(l=0;l<c;++l)(a=e[l])&&u.get(f[l])===a&&(s[l]=a)}function c0(r){return r.__data__}function d0(r,e){if(!arguments.length)return Array.from(this,c0);var t=e?u0:l0,n=this._parents,s=this._groups;typeof r!="function"&&(r=a0(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=f0(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 f0(r){return typeof r=="object"&&"length"in r?r:Array.from(r)}function h0(){return new Dt(this._exit||this._groups.map(Jc),this._parents)}function p0(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 g0(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 m0(){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 y0(r){r||(r=x0);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 x0(r,e){return r<e?-1:r>e?1:r>=e?0:NaN}function b0(){var r=arguments[0];return arguments[0]=this,r.apply(null,arguments),this}function _0(){return Array.from(this)}function v0(){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 w0(){let r=0;for(const e of this)++r;return r}function C0(){return!this.node()}function S0(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 k0(r){return function(){this.removeAttribute(r)}}function E0(r){return function(){this.removeAttributeNS(r.space,r.local)}}function D0(r,e){return function(){this.setAttribute(r,e)}}function A0(r,e){return function(){this.setAttributeNS(r.space,r.local,e)}}function T0(r,e){return function(){var t=e.apply(this,arguments);t==null?this.removeAttribute(r):this.setAttribute(r,t)}}function N0(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 B0(r,e){var t=wi(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?E0:k0:typeof e=="function"?t.local?N0:T0:t.local?A0:D0)(t,e))}function Zc(r){return r.ownerDocument&&r.ownerDocument.defaultView||r.document&&r||r.defaultView}function R0(r){return function(){this.style.removeProperty(r)}}function M0(r,e,t){return function(){this.style.setProperty(r,e,t)}}function F0(r,e,t){return function(){var n=e.apply(this,arguments);n==null?this.style.removeProperty(r):this.style.setProperty(r,n,t)}}function j0(r,e,t){return arguments.length>1?this.each((e==null?R0:typeof e=="function"?F0:M0)(r,e,t??"")):rn(this.node(),r)}function rn(r,e){return r.style.getPropertyValue(e)||Zc(r).getComputedStyle(r,null).getPropertyValue(e)}function L0(r){return function(){delete this[r]}}function P0(r,e){return function(){this[r]=e}}function I0(r,e){return function(){var t=e.apply(this,arguments);t==null?delete this[r]:this[r]=t}}function O0(r,e){return arguments.length>1?this.each((e==null?L0:typeof e=="function"?I0:P0)(r,e)):this.node()[r]}function ed(r){return r.trim().split(/^|\s+/)}function fa(r){return r.classList||new td(r)}function td(r){this._node=r,this._names=ed(r.getAttribute("class")||"")}td.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 rd(r,e){for(var t=fa(r),n=-1,s=e.length;++n<s;)t.add(e[n])}function nd(r,e){for(var t=fa(r),n=-1,s=e.length;++n<s;)t.remove(e[n])}function z0(r){return function(){rd(this,r)}}function $0(r){return function(){nd(this,r)}}function q0(r,e){return function(){(e.apply(this,arguments)?rd:nd)(this,r)}}function U0(r,e){var t=ed(r+"");if(arguments.length<2){for(var n=fa(this.node()),s=-1,i=t.length;++s<i;)if(!n.contains(t[s]))return!1;return!0}return this.each((typeof e=="function"?q0:e?z0:$0)(t,e))}function W0(){this.textContent=""}function H0(r){return function(){this.textContent=r}}function V0(r){return function(){var e=r.apply(this,arguments);this.textContent=e??""}}function G0(r){return arguments.length?this.each(r==null?W0:(typeof r=="function"?V0:H0)(r)):this.node().textContent}function K0(){this.innerHTML=""}function Y0(r){return function(){this.innerHTML=r}}function Q0(r){return function(){var e=r.apply(this,arguments);this.innerHTML=e??""}}function X0(r){return arguments.length?this.each(r==null?K0:(typeof r=="function"?Q0:Y0)(r)):this.node().innerHTML}function J0(){this.nextSibling&&this.parentNode.appendChild(this)}function Z0(){return this.each(J0)}function em(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function tm(){return this.each(em)}function rm(r){var e=typeof r=="function"?r:Kc(r);return this.select(function(){return this.appendChild(e.apply(this,arguments))})}function nm(){return null}function sm(r,e){var t=typeof r=="function"?r:Kc(r),n=e==null?nm:typeof e=="function"?e:da(e);return this.select(function(){return this.insertBefore(t.apply(this,arguments),n.apply(this,arguments)||null)})}function im(){var r=this.parentNode;r&&r.removeChild(this)}function om(){return this.each(im)}function am(){var r=this.cloneNode(!1),e=this.parentNode;return e?e.insertBefore(r,this.nextSibling):r}function lm(){var r=this.cloneNode(!0),e=this.parentNode;return e?e.insertBefore(r,this.nextSibling):r}function um(r){return this.select(r?lm:am)}function cm(r){return arguments.length?this.property("__data__",r):this.node().__data__}function dm(r){return function(e){r.call(this,e,this.__data__)}}function fm(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 hm(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 pm(r,e,t){return function(){var n=this.__on,s,i=dm(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 gm(r,e,t){var n=fm(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?pm:hm,s=0;s<i;++s)this.each(l(n[s],e,t));return this}function sd(r,e,t){var n=Zc(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 mm(r,e){return function(){return sd(this,r,e)}}function ym(r,e){return function(){return sd(this,r,e.apply(this,arguments))}}function xm(r,e){return this.each((typeof e=="function"?ym:mm)(r,e))}function*bm(){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 id=[null];function Dt(r,e){this._groups=r,this._parents=e}function is(){return new Dt([[document.documentElement]],id)}function _m(){return this}Dt.prototype=is.prototype={constructor:Dt,select:Vg,selectAll:Qg,selectChild:e0,selectChildren:s0,filter:i0,data:d0,enter:o0,exit:h0,join:p0,merge:g0,selection:_m,order:m0,sort:y0,call:b0,nodes:_0,node:v0,size:w0,empty:C0,each:S0,attr:B0,style:j0,property:O0,classed:U0,text:G0,html:X0,raise:Z0,lower:tm,append:rm,insert:sm,remove:om,clone:um,datum:cm,on:gm,dispatch:xm,[Symbol.iterator]:bm};function Lt(r){return typeof r=="string"?new Dt([[document.querySelector(r)]],[document.documentElement]):new Dt([[r]],id)}function vm(r){let e;for(;e=r.sourceEvent;)r=e;return r}function wr(r,e){if(r=vm(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 vo={capture:!0,passive:!1};function wo(r){r.preventDefault(),r.stopImmediatePropagation()}function wm(r){var e=r.document.documentElement,t=Lt(r).on("dragstart.drag",wo,vo);"onselectstart"in e?t.on("selectstart.drag",wo,vo):(e.__noselect=e.style.MozUserSelect,e.style.MozUserSelect="none")}function Cm(r,e){var t=r.document.documentElement,n=Lt(r).on("dragstart.drag",null);e&&(n.on("click.drag",wo,vo),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 ha(r,e,t){r.prototype=e.prototype=t,t.constructor=r}function od(r,e){var t=Object.create(r.prototype);for(var n in e)t[n]=e[n];return t}function os(){}var $n=.7,Js=1/$n,Xr="\\s*([+-]?\\d+)\\s*",qn="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Gt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Sm=/^#([0-9a-f]{3,8})$/,km=new RegExp(`^rgb\\(${Xr},${Xr},${Xr}\\)$`),Em=new RegExp(`^rgb\\(${Gt},${Gt},${Gt}\\)$`),Dm=new RegExp(`^rgba\\(${Xr},${Xr},${Xr},${qn}\\)$`),Am=new RegExp(`^rgba\\(${Gt},${Gt},${Gt},${qn}\\)$`),Tm=new RegExp(`^hsl\\(${qn},${Gt},${Gt}\\)$`),Nm=new RegExp(`^hsla\\(${qn},${Gt},${Gt},${qn}\\)$`),$l={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};ha(os,Un,{copy(r){return Object.assign(new this.constructor,this,r)},displayable(){return this.rgb().displayable()},hex:ql,formatHex:ql,formatHex8:Bm,formatHsl:Rm,formatRgb:Ul,toString:Ul});function ql(){return this.rgb().formatHex()}function Bm(){return this.rgb().formatHex8()}function Rm(){return ad(this).formatHsl()}function Ul(){return this.rgb().formatRgb()}function Un(r){var e,t;return r=(r+"").trim().toLowerCase(),(e=Sm.exec(r))?(t=e[1].length,e=parseInt(e[1],16),t===6?Wl(e):t===3?new wt(e>>8&15|e>>4&240,e>>4&15|e&240,(e&15)<<4|e&15,1):t===8?ys(e>>24&255,e>>16&255,e>>8&255,(e&255)/255):t===4?ys(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=km.exec(r))?new wt(e[1],e[2],e[3],1):(e=Em.exec(r))?new wt(e[1]*255/100,e[2]*255/100,e[3]*255/100,1):(e=Dm.exec(r))?ys(e[1],e[2],e[3],e[4]):(e=Am.exec(r))?ys(e[1]*255/100,e[2]*255/100,e[3]*255/100,e[4]):(e=Tm.exec(r))?Gl(e[1],e[2]/100,e[3]/100,1):(e=Nm.exec(r))?Gl(e[1],e[2]/100,e[3]/100,e[4]):$l.hasOwnProperty(r)?Wl($l[r]):r==="transparent"?new wt(NaN,NaN,NaN,0):null}function Wl(r){return new wt(r>>16&255,r>>8&255,r&255,1)}function ys(r,e,t,n){return n<=0&&(r=e=t=NaN),new wt(r,e,t,n)}function Mm(r){return r instanceof os||(r=Un(r)),r?(r=r.rgb(),new wt(r.r,r.g,r.b,r.opacity)):new wt}function Co(r,e,t,n){return arguments.length===1?Mm(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}ha(wt,Co,od(os,{brighter(r){return r=r==null?Js:Math.pow(Js,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),Zs(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:Hl,formatHex:Hl,formatHex8:Fm,formatRgb:Vl,toString:Vl}));function Hl(){return`#${Sr(this.r)}${Sr(this.g)}${Sr(this.b)}`}function Fm(){return`#${Sr(this.r)}${Sr(this.g)}${Sr(this.b)}${Sr((isNaN(this.opacity)?1:this.opacity)*255)}`}function Vl(){const r=Zs(this.opacity);return`${r===1?"rgb(":"rgba("}${Tr(this.r)}, ${Tr(this.g)}, ${Tr(this.b)}${r===1?")":`, ${r})`}`}function Zs(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 Gl(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 ad(r){if(r instanceof Pt)return new Pt(r.h,r.s,r.l,r.opacity);if(r instanceof os||(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 jm(r,e,t,n){return arguments.length===1?ad(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}ha(Pt,jm,od(os,{brighter(r){return r=r==null?Js:Math.pow(Js,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(Ui(r>=240?r-240:r+120,s,n),Ui(r,s,n),Ui(r<120?r+240:r-120,s,n),this.opacity)},clamp(){return new Pt(Kl(this.h),xs(this.s),xs(this.l),Zs(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=Zs(this.opacity);return`${r===1?"hsl(":"hsla("}${Kl(this.h)}, ${xs(this.s)*100}%, ${xs(this.l)*100}%${r===1?")":`, ${r})`}`}}));function Kl(r){return r=(r||0)%360,r<0?r+360:r}function xs(r){return Math.max(0,Math.min(1,r||0))}function Ui(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 ld=r=>()=>r;function Lm(r,e){return function(t){return r+t*e}}function Pm(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 Im(r){return(r=+r)==1?ud:function(e,t){return t-e?Pm(e,t,r):ld(isNaN(e)?t:e)}}function ud(r,e){var t=e-r;return t?Lm(r,t):ld(isNaN(r)?e:r)}const Yl=function r(e){var t=Im(e);function n(s,i){var o=t((s=Co(s)).r,(i=Co(i)).r),l=t(s.g,i.g),a=t(s.b,i.b),u=ud(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 So=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Wi=new RegExp(So.source,"g");function Om(r){return function(){return r}}function zm(r){return function(e){return r(e)+""}}function $m(r,e){var t=So.lastIndex=Wi.lastIndex=0,n,s,i,o=-1,l=[],a=[];for(r=r+"",e=e+"";(n=So.exec(r))&&(s=Wi.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=Wi.lastIndex;return t<e.length&&(i=e.slice(t),l[o]?l[o]+=i:l[++o]=i),l.length<2?a[0]?zm(a[0].x):Om(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 Ql=180/Math.PI,ko={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function cd(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)*Ql,skewX:Math.atan(a)*Ql,scaleX:o,scaleY:l}}var bs;function qm(r){const e=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(r+"");return e.isIdentity?ko:cd(e.a,e.b,e.c,e.d,e.e,e.f)}function Um(r){return r==null||(bs||(bs=document.createElementNS("http://www.w3.org/2000/svg","g")),bs.setAttribute("transform",r),!(r=bs.transform.baseVal.consolidate()))?ko:(r=r.matrix,cd(r.a,r.b,r.c,r.d,r.e,r.f))}function dd(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 Wm=dd(qm,"px, ","px)","deg)"),Hm=dd(Um,", ",")",")"),Vm=1e-12;function Xl(r){return((r=Math.exp(r))+1/r)/2}function Gm(r){return((r=Math.exp(r))-1/r)/2}function Km(r){return((r=Math.exp(2*r))-1)/(r+1)}const Ym=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<Vm)_=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=Xl(D),T=u/(t*y)*(R*Km(e*E+D)-Gm(D));return[l+T*p,a+T*g,u*R/Xl(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,fd=1e3,ei,Sn,ti=0,Lr=0,Ci=0,Wn=typeof performance=="object"&&performance.now?performance:Date,hd=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(r){setTimeout(r,17)};function pa(){return Lr||(hd(Qm),Lr=Wn.now()+Ci)}function Qm(){Lr=0}function ri(){this._call=this._time=this._next=null}ri.prototype=pd.prototype={constructor:ri,restart:function(r,e,t){if(typeof r!="function")throw new TypeError("callback is not a function");t=(t==null?pa():+t)+(e==null?0:+e),!this._next&&Sn!==this&&(Sn?Sn._next=this:ei=this,Sn=this),this._call=r,this._time=t,Eo()},stop:function(){this._call&&(this._call=null,this._time=1/0,Eo())}};function pd(r,e,t){var n=new ri;return n.restart(r,e,t),n}function Xm(){pa(),++nn;for(var r=ei,e;r;)(e=Lr-r._time)>=0&&r._call.call(void 0,e),r=r._next;--nn}function Jl(){Lr=(ti=Wn.now())+Ci,nn=Cn=0;try{Xm()}finally{nn=0,Zm(),Lr=0}}function Jm(){var r=Wn.now(),e=r-ti;e>fd&&(Ci-=e,ti=r)}function Zm(){for(var r,e=ei,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:ei=t);Sn=r,Eo(n)}function Eo(r){if(!nn){Cn&&(Cn=clearTimeout(Cn));var e=r-Lr;e>24?(r<1/0&&(Cn=setTimeout(Jl,r-Wn.now()-Ci)),yn&&(yn=clearInterval(yn))):(yn||(ti=Wn.now(),yn=setInterval(Jm,fd)),nn=1,hd(Jl))}}function Zl(r,e,t){var n=new ri;return e=e==null?0:+e,n.restart(s=>{n.stop(),r(s+e)},e,t),n}var e2=ca("start","end","cancel","interrupt"),t2=[],gd=0,eu=1,Do=2,ks=3,tu=4,Ao=5,Es=6;function Si(r,e,t,n,s,i){var o=r.__transition;if(!o)r.__transition={};else if(t in o)return;r2(r,t,{name:e,index:n,group:s,on:e2,tween:t2,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:gd})}function ga(r,e){var t=qt(r,e);if(t.state>gd)throw new Error("too late; already scheduled");return t}function Jt(r,e){var t=qt(r,e);if(t.state>ks)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 r2(r,e,t){var n=r.__transition,s;n[e]=t,t.timer=pd(i,0,t.time);function i(u){t.state=eu,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!==eu)return a();for(c in n)if(p=n[c],p.name===t.name){if(p.state===ks)return Zl(o);p.state===tu?(p.state=Es,p.timer.stop(),p.on.call("interrupt",r,r.__data__,p.index,p.group),delete n[c]):+c<e&&(p.state=Es,p.timer.stop(),p.on.call("cancel",r,r.__data__,p.index,p.group),delete n[c])}if(Zl(function(){t.state===ks&&(t.state=tu,t.timer.restart(l,t.delay,t.time),l(u))}),t.state=Do,t.on.call("start",r,r.__data__,t.index,t.group),t.state===Do){for(t.state=ks,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=Ao,1),d=-1,f=s.length;++d<f;)s[d].call(r,c);t.state===Ao&&(t.on.call("end",r,r.__data__,t.index,t.group),a())}function a(){t.state=Es,t.timer.stop(),delete n[e];for(var u in n)return;delete r.__transition}}function Ds(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>Do&&n.state<Ao,n.state=Es,n.timer.stop(),n.on.call(s?"interrupt":"cancel",r,r.__data__,n.index,n.group),delete t[o]}i&&delete r.__transition}}function n2(r){return this.each(function(){Ds(this,r)})}function s2(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 i2(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 o2(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?s2:i2)(t,r,e))}function ma(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 md(r,e){var t;return(typeof e=="number"?fr:e instanceof Un?Yl:(t=Un(e))?(e=t,Yl):$m)(r,e)}function a2(r){return function(){this.removeAttribute(r)}}function l2(r){return function(){this.removeAttributeNS(r.space,r.local)}}function u2(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 c2(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 d2(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 f2(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 h2(r,e){var t=wi(r),n=t==="transform"?Hm:md;return this.attrTween(r,typeof e=="function"?(t.local?f2:d2)(t,n,ma(this,"attr."+r,e)):e==null?(t.local?l2:a2)(t):(t.local?c2:u2)(t,n,e))}function p2(r,e){return function(t){this.setAttribute(r,e.call(this,t))}}function g2(r,e){return function(t){this.setAttributeNS(r.space,r.local,e.call(this,t))}}function m2(r,e){var t,n;function s(){var i=e.apply(this,arguments);return i!==n&&(t=(n=i)&&g2(r,i)),t}return s._value=e,s}function y2(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 x2(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=wi(r);return this.tween(t,(n.local?m2:y2)(n,e))}function b2(r,e){return function(){ga(this,r).delay=+e.apply(this,arguments)}}function _2(r,e){return e=+e,function(){ga(this,r).delay=e}}function v2(r){var e=this._id;return arguments.length?this.each((typeof r=="function"?b2:_2)(e,r)):qt(this.node(),e).delay}function w2(r,e){return function(){Jt(this,r).duration=+e.apply(this,arguments)}}function C2(r,e){return e=+e,function(){Jt(this,r).duration=e}}function S2(r){var e=this._id;return arguments.length?this.each((typeof r=="function"?w2:C2)(e,r)):qt(this.node(),e).duration}function k2(r,e){if(typeof e!="function")throw new Error;return function(){Jt(this,r).ease=e}}function E2(r){var e=this._id;return arguments.length?this.each(k2(e,r)):qt(this.node(),e).ease}function D2(r,e){return function(){var t=e.apply(this,arguments);if(typeof t!="function")throw new Error;Jt(this,r).ease=t}}function A2(r){if(typeof r!="function")throw new Error;return this.each(D2(this._id,r))}function T2(r){typeof r!="function"&&(r=Qc(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 N2(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 B2(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 R2(r,e,t){var n,s,i=B2(e)?ga:Jt;return function(){var o=i(this,r),l=o.on;l!==n&&(s=(n=l).copy()).on(e,t),o.on=s}}function M2(r,e){var t=this._id;return arguments.length<2?qt(this.node(),t).on.on(r):this.each(R2(t,r,e))}function F2(r){return function(){var e=this.parentNode;for(var t in this.__transition)if(+t!==r)return;e&&e.removeChild(this)}}function j2(){return this.on("end.remove",F2(this._id))}function L2(r){var e=this._name,t=this._id;typeof r!="function"&&(r=da(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,Si(u[f],e,t,f,u,qt(c,t)));return new ir(i,this._parents,e,t)}function P2(r){var e=this._name,t=this._id;typeof r!="function"&&(r=Yc(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])&&Si(p,e,t,m,f,g);i.push(f),o.push(c)}return new ir(i,o,e,t)}var I2=is.prototype.constructor;function O2(){return new I2(this._groups,this._parents)}function z2(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 yd(r){return function(){this.style.removeProperty(r)}}function $2(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 q2(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 U2(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=yd(e)):void 0;(u!==t||s!==c)&&(n=(t=u).copy()).on(o,s=c),a.on=n}}function W2(r,e,t){var n=(r+="")=="transform"?Wm:md;return e==null?this.styleTween(r,z2(r,n)).on("end.style."+r,yd(r)):typeof e=="function"?this.styleTween(r,q2(r,n,ma(this,"style."+r,e))).each(U2(this._id,r)):this.styleTween(r,$2(r,n,e),t).on("end.style."+r,null)}function H2(r,e,t){return function(n){this.style.setProperty(r,e.call(this,n),t)}}function V2(r,e,t){var n,s;function i(){var o=e.apply(this,arguments);return o!==s&&(n=(s=o)&&H2(r,o,t)),n}return i._value=e,i}function G2(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,V2(r,e,t??""))}function K2(r){return function(){this.textContent=r}}function Y2(r){return function(){var e=r(this);this.textContent=e??""}}function Q2(r){return this.tween("text",typeof r=="function"?Y2(ma(this,"text",r)):K2(r==null?"":r+""))}function X2(r){return function(e){this.textContent=r.call(this,e)}}function J2(r){var e,t;function n(){var s=r.apply(this,arguments);return s!==t&&(e=(t=s)&&X2(s)),e}return n._value=r,n}function Z2(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,J2(r))}function ey(){for(var r=this._name,e=this._id,t=xd(),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);Si(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 ty(){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 ry=0;function ir(r,e,t,n){this._groups=r,this._parents=e,this._name=t,this._id=n}function xd(){return++ry}var tr=is.prototype;ir.prototype={constructor:ir,select:L2,selectAll:P2,selectChild:tr.selectChild,selectChildren:tr.selectChildren,filter:T2,merge:N2,selection:O2,transition:ey,call:tr.call,nodes:tr.nodes,node:tr.node,size:tr.size,empty:tr.empty,each:tr.each,on:M2,attr:h2,attrTween:x2,style:W2,styleTween:G2,text:Q2,textTween:Z2,remove:j2,tween:o2,delay:v2,duration:S2,ease:E2,easeVarying:A2,end:ty,[Symbol.iterator]:tr[Symbol.iterator]};function ny(r){return((r*=2)<=1?r*r*r:(r-=2)*r*r+2)/2}var sy={time:null,delay:0,duration:250,ease:ny};function iy(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 oy(r){var e,t;r instanceof ir?(e=r._id,r=r._name):(e=xd(),(t=sy).time=pa(),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])&&Si(a,r,e,u,o,t||iy(a,e));return new ir(n,this._parents,r,e)}is.prototype.interrupt=n2;is.prototype.transition=oy;const _s=r=>()=>r;function ay(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 ni=new nr(1,0,0);nr.prototype;function Hi(r){r.stopImmediatePropagation()}function xn(r){r.preventDefault(),r.stopImmediatePropagation()}function ly(r){return(!r.ctrlKey||r.type==="wheel")&&!r.button}function uy(){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 ru(){return this.__zoom||ni}function cy(r){return-r.deltaY*(r.deltaMode===1?.05:r.deltaMode?1:.002)*(r.ctrlKey?10:1)}function dy(){return navigator.maxTouchPoints||"ontouchstart"in this}function fy(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 hy(){var r=ly,e=uy,t=fy,n=cy,s=dy,i=[0,1/0],o=[[-1/0,-1/0],[1/0,1/0]],l=250,a=Ym,u=ca("start","zoom","end"),c,d,f,p=500,g=150,m=0,x=10;function _(k){k.property("__zoom",ru).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",ru),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(ni.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 ay(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)],Ds(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;wm(k.view),Hi(k),O.mouse=[U,this.__zoom.invert(U)],Ds(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),Cm(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(Hi(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)),Ds(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(Hi(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:_s(+k),_):n},_.filter=function(k){return arguments.length?(r=typeof k=="function"?k:_s(!!k),_):r},_.touchable=function(k){return arguments.length?(s=typeof k=="function"?k:_s(!!k),_):s},_.extent=function(k){return arguments.length?(e=typeof k=="function"?k:_s([[+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 bd(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=hy().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,ni.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=ni.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 _d(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 vd(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 wd=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 Cd(r,e,t="bezier"){const n=Hn(r),s=Hn(e),i=To(r,s),o=To(e,n);switch(t){case"straight":return`M ${i.x} ${i.y} L ${o.x} ${o.y}`;case"orthogonal":return gy(i,o);case"bezier":default:return py(i,o)}}function py(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 gy(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 Hn(r){const e=r.width||200,t=r.height||100;return{x:r.x+e/2,y:r.y+t/2}}function To(r,e){const t=r.width||200,n=r.height||100,s=Hn(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 Hn(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 Sd=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(()=>Cd(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 kd=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(Sd,{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)),Ed=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}=bd({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}=_d({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}=vd({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(kd,{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(wd,{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(Ed,{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=ua;exports.$isQRCodeNode=bg;exports.AnimatedCardFlip=bf;exports.ApiClient=ou;exports.AudioEditor=Gc;exports.AuthFlow=du;exports.AuthFlowModal=hf;exports.AuthManager=_t;exports.AuthProvider=sf;exports.AuthService=No;exports.Card=mf;exports.ComboBox=Tg;exports.ComboStack=Bg;exports.DataOperations=vs;exports.Detail=yf;exports.ForgotPasswordForm=uu;exports.GraphClient=Rd;exports.ImageEditor=Og;exports.KanbanBoard=Rg;exports.LLMClient=Jd;exports.LoginForm=Ro;exports.LoginModal=lf;exports.Mail=vf;exports.MailClient=iu;exports.MailComposer=Dg;exports.MailEditor=Vc;exports.QMap=Ny;exports.QMapEdgeComponent=Sd;exports.QMapEdgeLayer=kd;exports.QMapNode=wd;exports.QMapSelectionBox=Ed;exports.QRCodeNode=un;exports.RegisterForm=lu;exports.ResetPasswordForm=cu;exports.SelectableList=wf;exports.Stack=gf;exports.Timeline=Pg;exports.VerifyCodeForm=Ki;exports.VoiceTextEditor=Ig;exports.calculateBoundingBox=by;exports.calculateEdgePath=Cd;exports.distance=_y;exports.distanceSquared=vy;exports.getApiClient=Bo;exports.getAuthService=ef;exports.getConnectionPoint=To;exports.getNodeCenter=Hn;exports.getNodeSidePoint=my;exports.initializeApiClient=tf;exports.initializeAuthService=Zd;exports.pointInRect=yy;exports.rectsIntersect=xy;exports.useAuth=of;exports.useMutation=pf;exports.useNodeDrag=_d;exports.useQuery=fu;exports.useSelection=vd;exports.useZoomPan=bd;
|
package/dist/index.esm.js
CHANGED
|
@@ -2,7 +2,7 @@ var vd = Object.defineProperty;
|
|
|
2
2
|
var wd = (r, e, t) => e in r ? vd(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
|
|
3
3
|
var Dt = (r, e, t) => wd(r, typeof e != "symbol" ? e + "" : e, t);
|
|
4
4
|
import * as Fs from "react";
|
|
5
|
-
import Le, { createContext as su, useState as O, useCallback as Q, useEffect as Te, useContext as ou, useRef as me, useMemo as
|
|
5
|
+
import Le, { createContext as su, useState as O, useCallback as Q, useEffect as Te, useContext as ou, useRef as me, useMemo as ct, useLayoutEffect as cn, Suspense as Cd, forwardRef as au, memo as us } from "react";
|
|
6
6
|
import { flushSync as Dd, createPortal as Ed } from "react-dom";
|
|
7
7
|
class py {
|
|
8
8
|
constructor(e) {
|
|
@@ -4911,7 +4911,7 @@ Check the top-level render call using <` + te + ">.");
|
|
|
4911
4911
|
}
|
|
4912
4912
|
}
|
|
4913
4913
|
}
|
|
4914
|
-
function
|
|
4914
|
+
function at(S) {
|
|
4915
4915
|
{
|
|
4916
4916
|
var $ = S.type;
|
|
4917
4917
|
if ($ == null || typeof $ == "string")
|
|
@@ -4990,7 +4990,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
4990
4990
|
<%s key={someKey} {...props} />`, Bs, Er, bd, Er), Ue[Er + Bs] = !0;
|
|
4991
4991
|
}
|
|
4992
4992
|
}
|
|
4993
|
-
return S === n ? Qe(st) :
|
|
4993
|
+
return S === n ? Qe(st) : at(st), st;
|
|
4994
4994
|
}
|
|
4995
4995
|
}
|
|
4996
4996
|
function gt(S, $, te) {
|
|
@@ -6331,7 +6331,7 @@ function Dy({
|
|
|
6331
6331
|
onRefresh: p,
|
|
6332
6332
|
theme: g = {}
|
|
6333
6333
|
}) {
|
|
6334
|
-
const { data: m, loading: x, error: b, refetch: y } = sf(r, e), [_, C] = O(""), [k, w] = O({}), [v, E] = O(1), B =
|
|
6334
|
+
const { data: m, loading: x, error: b, refetch: y } = sf(r, e), [_, C] = O(""), [k, w] = O({}), [v, E] = O(1), B = ct(() => {
|
|
6335
6335
|
if (!m) return { data: [], total: 0, totalPages: 0 };
|
|
6336
6336
|
let D = m;
|
|
6337
6337
|
return l && _ && a.length > 0 && (D = Is.search(D, _, a)), Object.keys(k).length > 0 && (D = Is.filterByFields(D, k)), Is.paginate(D, v, d);
|
|
@@ -6834,13 +6834,13 @@ function Ay({
|
|
|
6834
6834
|
}) {
|
|
6835
6835
|
const v = { ...af, ...w }, [E, B] = O([]), [A, T] = O(!1), [F, R] = O(null), [D, N] = O(/* @__PURE__ */ new Set()), [M, I] = O(null), [V, U] = O(null), [re, q] = O(null), [J, W] = O(!1), [se, ce] = O(""), fe = a !== void 0 ? a : se, ge = (oe) => {
|
|
6836
6836
|
u ? u(oe) : ce(oe);
|
|
6837
|
-
}, Ne =
|
|
6837
|
+
}, Ne = ct(() => {
|
|
6838
6838
|
if (!fe.trim()) return E;
|
|
6839
6839
|
const oe = fe.toLowerCase();
|
|
6840
6840
|
return E.filter(
|
|
6841
6841
|
(de) => Vr(de.from).toLowerCase().includes(oe) || Vr(de.subject).toLowerCase().includes(oe)
|
|
6842
6842
|
);
|
|
6843
|
-
}, [E, fe]), _e =
|
|
6843
|
+
}, [E, fe]), _e = ct(() => e ? new Hd({ baseUrl: r, system_id: e }) : null, [r, e]), Z = Q(async () => {
|
|
6844
6844
|
if (_e) {
|
|
6845
6845
|
T(!0), R(null);
|
|
6846
6846
|
try {
|
|
@@ -7701,7 +7701,7 @@ function Jo(r, e, t, n, i) {
|
|
|
7701
7701
|
const g = ae();
|
|
7702
7702
|
if (!H(g) || t === null || n === null) return void s.setTextContent(l);
|
|
7703
7703
|
if (g.setTextNodeRange(s, t, s, n), s.isSegmented()) {
|
|
7704
|
-
const m =
|
|
7704
|
+
const m = lt(s.getTextContent());
|
|
7705
7705
|
s.replace(m), s = m;
|
|
7706
7706
|
}
|
|
7707
7707
|
s.setTextContent(l);
|
|
@@ -7943,7 +7943,7 @@ function Uu(r, e, t, n, i, s) {
|
|
|
7943
7943
|
o.__parent === e && (P(o) && Uu(o, l, t, n, i, s), t.has(l) || s.delete(l), i.push(l)), o = o.getNextSibling();
|
|
7944
7944
|
}
|
|
7945
7945
|
}
|
|
7946
|
-
let wr, _t, Un, bs, so, oo, Pr, Wt, ao, Wn,
|
|
7946
|
+
let wr, _t, Un, bs, so, oo, Pr, Wt, ao, Wn, ut = "", xt = "", Kt = null, Ot = "", ar = "", Wu = !1, Hn = !1, ki = null;
|
|
7947
7947
|
function Hi(r, e) {
|
|
7948
7948
|
const t = Pr.get(r);
|
|
7949
7949
|
if (e !== null) {
|
|
@@ -7999,27 +7999,27 @@ function Vi(r, e) {
|
|
|
7999
7999
|
})(Gi(t, Wt), l, t, n);
|
|
8000
8000
|
}
|
|
8001
8001
|
const o = t.__format;
|
|
8002
|
-
o !== 0 && Vu(n, o), t.isInline() || Gu(null, t, n), ys(t) && (
|
|
8002
|
+
o !== 0 && Vu(n, o), t.isInline() || Gu(null, t, n), ys(t) && (ut += ur, ar += ur);
|
|
8003
8003
|
} else {
|
|
8004
8004
|
const i = t.getTextContent();
|
|
8005
8005
|
if (We(t)) {
|
|
8006
8006
|
const s = t.decorate(_t, wr);
|
|
8007
8007
|
s !== null && Yu(r, s), n.contentEditable = "false";
|
|
8008
8008
|
} else X(t) && (t.isDirectionless() || (xt += i));
|
|
8009
|
-
|
|
8009
|
+
ut += i, ar += i;
|
|
8010
8010
|
}
|
|
8011
8011
|
return e !== null && e.insertChild(n), Zo(Wn, Un, bs, t, "created"), n;
|
|
8012
8012
|
}
|
|
8013
8013
|
function uo(r, e, t, n, i) {
|
|
8014
|
-
const s =
|
|
8015
|
-
|
|
8014
|
+
const s = ut;
|
|
8015
|
+
ut = "";
|
|
8016
8016
|
let o = t;
|
|
8017
8017
|
for (; o <= n; ++o) {
|
|
8018
8018
|
Vi(r[o], i);
|
|
8019
8019
|
const l = Wt.get(r[o]);
|
|
8020
8020
|
l !== null && X(l) && (Kt === null && (Kt = l.getFormat()), Ot === "" && (Ot = l.getStyle()));
|
|
8021
8021
|
}
|
|
8022
|
-
ys(e) && (
|
|
8022
|
+
ys(e) && (ut += ur), i.element.__lexicalTextContent = ut, ut = s + ut;
|
|
8023
8023
|
}
|
|
8024
8024
|
function Ua(r, e) {
|
|
8025
8025
|
if (r) {
|
|
@@ -8071,8 +8071,8 @@ function oh(r, e, t) {
|
|
|
8071
8071
|
const n = xt;
|
|
8072
8072
|
var i;
|
|
8073
8073
|
xt = "", Kt = null, Ot = "", function(s, o, l) {
|
|
8074
|
-
const a =
|
|
8075
|
-
|
|
8074
|
+
const a = ut, u = s.__size, c = o.__size;
|
|
8075
|
+
ut = "";
|
|
8076
8076
|
const d = l.element;
|
|
8077
8077
|
if (u === 1 && c === 1) {
|
|
8078
8078
|
const f = s.__first, p = o.__first;
|
|
@@ -8125,7 +8125,7 @@ function oh(r, e, t) {
|
|
|
8125
8125
|
} else F && !T && lo(m, B, C, _.element);
|
|
8126
8126
|
})(o, f, p, u, c, l);
|
|
8127
8127
|
}
|
|
8128
|
-
ys(o) && (
|
|
8128
|
+
ys(o) && (ut += ur), d.__lexicalTextContent = ut, ut = a + ut;
|
|
8129
8129
|
}(r, e, e.getDOMSlot(t)), Ku(e, t), an(i = e) && Kt != null && Kt !== i.__textFormat && !Hn && (i.setTextFormat(Kt), i.setTextStyle(Ot)), function(s) {
|
|
8130
8130
|
an(s) && Ot !== "" && Ot !== s.__textStyle && !Hn && s.setTextStyle(Ot);
|
|
8131
8131
|
}(e), xt = n;
|
|
@@ -8147,12 +8147,12 @@ function kn(r, e) {
|
|
|
8147
8147
|
if (t === n && !i) {
|
|
8148
8148
|
if (P(t)) {
|
|
8149
8149
|
const o = s.__lexicalTextContent;
|
|
8150
|
-
o !== void 0 && (
|
|
8150
|
+
o !== void 0 && (ut += o, ar += o);
|
|
8151
8151
|
const l = s.__lexicalDirTextContent;
|
|
8152
8152
|
l !== void 0 && (xt += l);
|
|
8153
8153
|
} else {
|
|
8154
8154
|
const o = t.getTextContent();
|
|
8155
|
-
X(t) && !t.isDirectionless() && (xt += o), ar += o,
|
|
8155
|
+
X(t) && !t.isDirectionless() && (xt += o), ar += o, ut += o;
|
|
8156
8156
|
}
|
|
8157
8157
|
return s;
|
|
8158
8158
|
}
|
|
@@ -8164,14 +8164,14 @@ function kn(r, e) {
|
|
|
8164
8164
|
const o = n.__indent;
|
|
8165
8165
|
o !== t.__indent && Hu(s, o);
|
|
8166
8166
|
const l = n.__format;
|
|
8167
|
-
l !== t.__format && Vu(s, l), i && (oh(t, n, s), bt(n) || n.isInline() || Gu(t, n, s)), ys(n) && (
|
|
8167
|
+
l !== t.__format && Vu(s, l), i && (oh(t, n, s), bt(n) || n.isInline() || Gu(t, n, s)), ys(n) && (ut += ur, ar += ur);
|
|
8168
8168
|
} else {
|
|
8169
8169
|
const o = n.getTextContent();
|
|
8170
8170
|
if (We(n)) {
|
|
8171
8171
|
const l = n.decorate(_t, wr);
|
|
8172
8172
|
l !== null && Yu(r, l);
|
|
8173
8173
|
} else X(n) && !n.isDirectionless() && (xt += o);
|
|
8174
|
-
|
|
8174
|
+
ut += o, ar += o;
|
|
8175
8175
|
}
|
|
8176
8176
|
if (!Hn && bt(n) && n.__cachedText !== ar) {
|
|
8177
8177
|
const o = n.getWritable();
|
|
@@ -8193,7 +8193,7 @@ function qs(r) {
|
|
|
8193
8193
|
return e !== null && e === _t._blockCursorElement && (e = e.nextSibling), e;
|
|
8194
8194
|
}
|
|
8195
8195
|
function ah(r, e, t, n, i, s) {
|
|
8196
|
-
|
|
8196
|
+
ut = "", ar = "", xt = "", Wu = n === sn, ki = null, _t = t, wr = t._config, Un = t._nodes, bs = _t._listeners.mutation, so = i, oo = s, Pr = r._nodeMap, Wt = e._nodeMap, Hn = e._readOnly, ao = new Map(t._keyToDOMMap);
|
|
8197
8197
|
const o = /* @__PURE__ */ new Map();
|
|
8198
8198
|
return Wn = o, kn("root", null), _t = void 0, Un = void 0, so = void 0, oo = void 0, Pr = void 0, Wt = void 0, wr = void 0, ao = void 0, Wn = void 0, o;
|
|
8199
8199
|
}
|
|
@@ -8853,7 +8853,7 @@ class _s {
|
|
|
8853
8853
|
return !1;
|
|
8854
8854
|
}
|
|
8855
8855
|
createParentElementNode() {
|
|
8856
|
-
return
|
|
8856
|
+
return ot();
|
|
8857
8857
|
}
|
|
8858
8858
|
selectStart() {
|
|
8859
8859
|
return this.selectPrevious();
|
|
@@ -9085,7 +9085,7 @@ class dn extends _s {
|
|
|
9085
9085
|
return { "#text": () => ({ conversion: hh, priority: 0 }), b: () => ({ conversion: dh, priority: 0 }), code: () => ({ conversion: pr, priority: 0 }), em: () => ({ conversion: pr, priority: 0 }), i: () => ({ conversion: pr, priority: 0 }), s: () => ({ conversion: pr, priority: 0 }), span: () => ({ conversion: ch, priority: 0 }), strong: () => ({ conversion: pr, priority: 0 }), sub: () => ({ conversion: pr, priority: 0 }), sup: () => ({ conversion: pr, priority: 0 }), u: () => ({ conversion: pr, priority: 0 }) };
|
|
9086
9086
|
}
|
|
9087
9087
|
static importJSON(e) {
|
|
9088
|
-
const t =
|
|
9088
|
+
const t = lt(e.text);
|
|
9089
9089
|
return t.setFormat(e.format), t.setDetail(e.detail), t.setMode(e.mode), t.setStyle(e.style), t;
|
|
9090
9090
|
}
|
|
9091
9091
|
exportDOM(e) {
|
|
@@ -9185,11 +9185,11 @@ class dn extends _s {
|
|
|
9185
9185
|
let p;
|
|
9186
9186
|
const g = t.getFormat(), m = t.getStyle(), x = t.__detail;
|
|
9187
9187
|
let b = !1;
|
|
9188
|
-
t.isSegmented() ? (p =
|
|
9188
|
+
t.isSegmented() ? (p = lt(d), p.__format = g, p.__style = m, p.__detail = x, b = !0) : (p = t.getWritable(), p.__text = d);
|
|
9189
9189
|
const y = ae(), _ = [p];
|
|
9190
9190
|
let C = d.length;
|
|
9191
9191
|
for (let k = 1; k < c; k++) {
|
|
9192
|
-
const w = l[k], v = w.length, E =
|
|
9192
|
+
const w = l[k], v = w.length, E = lt(w).getWritable();
|
|
9193
9193
|
E.__format = g, E.__style = m, E.__detail = x;
|
|
9194
9194
|
const B = E.__key, A = C + v;
|
|
9195
9195
|
if (H(y)) {
|
|
@@ -9255,7 +9255,7 @@ function hh(r) {
|
|
|
9255
9255
|
const l = n[o];
|
|
9256
9256
|
l === `
|
|
9257
9257
|
` || l === `\r
|
|
9258
|
-
` ? i.push(Ir()) : l === " " ? i.push(ni()) : l !== "" && i.push(
|
|
9258
|
+
` ? i.push(Ir()) : l === " " ? i.push(ni()) : l !== "" && i.push(lt(l));
|
|
9259
9259
|
}
|
|
9260
9260
|
return { node: i };
|
|
9261
9261
|
}
|
|
@@ -9280,7 +9280,7 @@ function hh(r) {
|
|
|
9280
9280
|
}
|
|
9281
9281
|
i && (t = t.slice(0, t.length - 1));
|
|
9282
9282
|
}
|
|
9283
|
-
return t === "" ? { node: null } : { node:
|
|
9283
|
+
return t === "" ? { node: null } : { node: lt(t) };
|
|
9284
9284
|
}
|
|
9285
9285
|
function Qa(r, e) {
|
|
9286
9286
|
let t = r;
|
|
@@ -9306,7 +9306,7 @@ function pr(r) {
|
|
|
9306
9306
|
const e = ph[r.nodeName.toLowerCase()];
|
|
9307
9307
|
return e === void 0 ? { node: null } : { forChild: na(r.style, e), node: null };
|
|
9308
9308
|
}
|
|
9309
|
-
function
|
|
9309
|
+
function lt(r = "") {
|
|
9310
9310
|
return rr(new dn(r));
|
|
9311
9311
|
}
|
|
9312
9312
|
function X(r) {
|
|
@@ -9573,7 +9573,7 @@ class Dr {
|
|
|
9573
9573
|
const o = t[s];
|
|
9574
9574
|
o === `
|
|
9575
9575
|
` || o === `\r
|
|
9576
|
-
` ? n.push(Ir()) : o === " " ? n.push(ni()) : n.push(
|
|
9576
|
+
` ? n.push(Ir()) : o === " " ? n.push(ni()) : n.push(lt(o));
|
|
9577
9577
|
}
|
|
9578
9578
|
this.insertNodes(n);
|
|
9579
9579
|
}
|
|
@@ -9581,7 +9581,7 @@ class Dr {
|
|
|
9581
9581
|
const t = this.anchor, n = this.focus, i = this.format, s = this.style;
|
|
9582
9582
|
let o = t, l = n;
|
|
9583
9583
|
!this.isCollapsed() && n.isBefore(t) && (o = n, l = t), o.type === "element" && function(x, b, y, _) {
|
|
9584
|
-
const C = x.getNode(), k = C.getChildAtIndex(x.offset), w =
|
|
9584
|
+
const C = x.getNode(), k = C.getChildAtIndex(x.offset), w = lt(), v = bt(C) ? ot().append(w) : w;
|
|
9585
9585
|
w.setFormat(y), w.setStyle(_), k === null ? C.append(v) : k.insertBefore(v), x.is(b) && b.set(w.__key, 0, "text"), x.set(w.__key, 0, "text");
|
|
9586
9586
|
}(o, l, i, s);
|
|
9587
9587
|
const a = o.offset;
|
|
@@ -9593,12 +9593,12 @@ class Dr {
|
|
|
9593
9593
|
let m = c[d - 1];
|
|
9594
9594
|
if (d === 1 && l.type === "element" && (u = p, l.set(o.key, u, "text")), this.isCollapsed() && a === p && (f.isSegmented() || f.isToken() || !f.canInsertTextAfter() || !g.canInsertTextAfter() && f.getNextSibling() === null)) {
|
|
9595
9595
|
let x = f.getNextSibling();
|
|
9596
|
-
if (X(x) && x.canInsertTextBefore() && !Ar(x) || (x =
|
|
9596
|
+
if (X(x) && x.canInsertTextBefore() && !Ar(x) || (x = lt(), x.setFormat(i), x.setStyle(s), g.canInsertTextAfter() ? f.insertAfter(x) : g.insertAfter(x)), x.select(0, 0), f = x, e !== "") return void this.insertText(e);
|
|
9597
9597
|
} else if (this.isCollapsed() && a === 0 && (f.isSegmented() || f.isToken() || !f.canInsertTextBefore() || !g.canInsertTextBefore() && f.getPreviousSibling() === null)) {
|
|
9598
9598
|
let x = f.getPreviousSibling();
|
|
9599
|
-
if (X(x) && !Ar(x) || (x =
|
|
9599
|
+
if (X(x) && !Ar(x) || (x = lt(), x.setFormat(i), g.canInsertTextBefore() ? f.insertBefore(x) : g.insertBefore(x)), x.select(), f = x, e !== "") return void this.insertText(e);
|
|
9600
9600
|
} else if (f.isSegmented() && a !== p) {
|
|
9601
|
-
const x =
|
|
9601
|
+
const x = lt(f.getTextContent());
|
|
9602
9602
|
x.setFormat(i), f.replace(x), f = x;
|
|
9603
9603
|
} else if (!this.isCollapsed() && e !== "") {
|
|
9604
9604
|
const x = m.getParent();
|
|
@@ -9606,18 +9606,18 @@ class Dr {
|
|
|
9606
9606
|
}
|
|
9607
9607
|
if (d === 1) {
|
|
9608
9608
|
if (f.isToken()) {
|
|
9609
|
-
const _ =
|
|
9609
|
+
const _ = lt(e);
|
|
9610
9610
|
return _.select(), void f.replace(_);
|
|
9611
9611
|
}
|
|
9612
9612
|
const x = f.getFormat(), b = f.getStyle();
|
|
9613
9613
|
if (a !== u || x === i && b === s) {
|
|
9614
9614
|
if (gh(f)) {
|
|
9615
|
-
const _ =
|
|
9615
|
+
const _ = lt(e);
|
|
9616
9616
|
return _.setFormat(i), _.setStyle(s), _.select(), void f.replace(_);
|
|
9617
9617
|
}
|
|
9618
9618
|
} else {
|
|
9619
9619
|
if (f.getTextContent() !== "") {
|
|
9620
|
-
const _ =
|
|
9620
|
+
const _ = lt(e);
|
|
9621
9621
|
if (_.setFormat(i), _.setStyle(s), _.select(), a === 0) f.insertBefore(_, !1);
|
|
9622
9622
|
else {
|
|
9623
9623
|
const [C] = f.splitText(a);
|
|
@@ -9637,7 +9637,7 @@ class Dr {
|
|
|
9637
9637
|
while (y.isInline());
|
|
9638
9638
|
if (l.type === "text" && (u !== 0 || m.getTextContent() === "") || l.type === "element" && m.getIndexWithinParent() < u) if (X(m) && !m.isToken() && u !== m.getTextContentSize()) {
|
|
9639
9639
|
if (m.isSegmented()) {
|
|
9640
|
-
const E =
|
|
9640
|
+
const E = lt(m.getTextContent());
|
|
9641
9641
|
m.replace(E), m = E;
|
|
9642
9642
|
}
|
|
9643
9643
|
bt(l.getNode()) || l.type !== "text" || (m = m.spliceText(0, u, "")), x.add(m.__key);
|
|
@@ -9661,7 +9661,7 @@ class Dr {
|
|
|
9661
9661
|
}
|
|
9662
9662
|
if (f.isToken()) if (a === p) f.select();
|
|
9663
9663
|
else {
|
|
9664
|
-
const E =
|
|
9664
|
+
const E = lt(e);
|
|
9665
9665
|
E.select(), f.replace(E);
|
|
9666
9666
|
}
|
|
9667
9667
|
else f = f.spliceText(a, p - a, e, !0), f.getTextContent() === "" ? f.remove() : f.isComposing() && this.anchor.type === "text" && (this.anchor.offset -= e.length);
|
|
@@ -9682,7 +9682,7 @@ class Dr {
|
|
|
9682
9682
|
const c = (d, f) => {
|
|
9683
9683
|
if (d.getTextContent() === "") d.remove();
|
|
9684
9684
|
else if (f !== 0 && Ar(d)) {
|
|
9685
|
-
const p =
|
|
9685
|
+
const p = lt(d.getTextContent());
|
|
9686
9686
|
return p.setFormat(d.getFormat()), p.setStyle(d.getStyle()), d.replace(p);
|
|
9687
9687
|
}
|
|
9688
9688
|
};
|
|
@@ -9757,7 +9757,7 @@ class Dr {
|
|
|
9757
9757
|
return n.splice(g, 0, e), void i.selectEnd();
|
|
9758
9758
|
}
|
|
9759
9759
|
const s = function(g) {
|
|
9760
|
-
const m =
|
|
9760
|
+
const m = ot();
|
|
9761
9761
|
let x = null;
|
|
9762
9762
|
for (let b = 0; b < g.length; b++) {
|
|
9763
9763
|
const y = g[b], _ = Mr(y);
|
|
@@ -9785,7 +9785,7 @@ class Dr {
|
|
|
9785
9785
|
}
|
|
9786
9786
|
insertParagraph() {
|
|
9787
9787
|
if (this.anchor.key === "root") {
|
|
9788
|
-
const o =
|
|
9788
|
+
const o = ot();
|
|
9789
9789
|
return Xe().splice(this.anchor.offset, 0, [o]), o.select(), o;
|
|
9790
9790
|
}
|
|
9791
9791
|
const e = Gs(this), t = bn(this.anchor.getNode(), gr);
|
|
@@ -10210,7 +10210,7 @@ function Gs(r) {
|
|
|
10210
10210
|
function bh(r, e) {
|
|
10211
10211
|
const t = r.getParent();
|
|
10212
10212
|
if (!t) {
|
|
10213
|
-
const i =
|
|
10213
|
+
const i = ot();
|
|
10214
10214
|
return Xe().append(i), i.select(), [Xe(), 0];
|
|
10215
10215
|
}
|
|
10216
10216
|
if (X(r)) {
|
|
@@ -11100,14 +11100,14 @@ class fn extends hr {
|
|
|
11100
11100
|
return { element: t };
|
|
11101
11101
|
}
|
|
11102
11102
|
static importJSON(e) {
|
|
11103
|
-
const t =
|
|
11103
|
+
const t = ot();
|
|
11104
11104
|
return t.setFormat(e.format), t.setIndent(e.indent), t.setDirection(e.direction), t.setTextFormat(e.textFormat), t;
|
|
11105
11105
|
}
|
|
11106
11106
|
exportJSON() {
|
|
11107
11107
|
return { ...super.exportJSON(), textFormat: this.getTextFormat(), textStyle: this.getTextStyle(), type: "paragraph", version: 1 };
|
|
11108
11108
|
}
|
|
11109
11109
|
insertNewAfter(e, t) {
|
|
11110
|
-
const n =
|
|
11110
|
+
const n = ot();
|
|
11111
11111
|
n.setTextFormat(e.format), n.setTextStyle(e.style);
|
|
11112
11112
|
const i = this.getDirection();
|
|
11113
11113
|
return n.setDirection(i), n.setFormat(this.getFormatType()), n.setStyle(this.getTextStyle()), this.insertAfter(n, t), n;
|
|
@@ -11122,10 +11122,10 @@ class fn extends hr {
|
|
|
11122
11122
|
}
|
|
11123
11123
|
}
|
|
11124
11124
|
function wh(r) {
|
|
11125
|
-
const e =
|
|
11125
|
+
const e = ot();
|
|
11126
11126
|
return r.style && (e.setFormat(r.style.textAlign), ra(r, e)), { node: e };
|
|
11127
11127
|
}
|
|
11128
|
-
function
|
|
11128
|
+
function ot() {
|
|
11129
11129
|
return rr(new fn());
|
|
11130
11130
|
}
|
|
11131
11131
|
function an(r) {
|
|
@@ -11393,14 +11393,14 @@ class Cs {
|
|
|
11393
11393
|
Cs.version = "0.21.0+prod.esm";
|
|
11394
11394
|
const yc = typeof window < "u" && window.document !== void 0 && window.document.createElement !== void 0, Eh = yc ? cn : Te, yi = { tag: "history-merge" };
|
|
11395
11395
|
function kh({ initialConfig: r, children: e }) {
|
|
11396
|
-
const t =
|
|
11396
|
+
const t = ct(() => {
|
|
11397
11397
|
const { theme: n, namespace: i, nodes: s, onError: o, editorState: l, html: a } = r, u = cf(null, n), c = Dh({ editable: r.editable, html: a, namespace: i, nodes: s, onError: (d) => o(d, c), theme: n });
|
|
11398
11398
|
return function(d, f) {
|
|
11399
11399
|
if (f !== null) {
|
|
11400
11400
|
if (f === void 0) d.update(() => {
|
|
11401
11401
|
const p = Xe();
|
|
11402
11402
|
if (p.isEmpty()) {
|
|
11403
|
-
const g =
|
|
11403
|
+
const g = ot();
|
|
11404
11404
|
p.append(g);
|
|
11405
11405
|
const m = yc ? document.activeElement : null;
|
|
11406
11406
|
(ae() !== null || m !== null && m === d.getRootElement()) && g.select();
|
|
@@ -11434,7 +11434,7 @@ function Ah(r) {
|
|
|
11434
11434
|
}
|
|
11435
11435
|
function Th() {
|
|
11436
11436
|
return function(r) {
|
|
11437
|
-
const [e] = Ht(), t =
|
|
11437
|
+
const [e] = Ht(), t = ct(() => r(e), [e, r]), [n, i] = O(() => t.initialValueFn()), s = me(n);
|
|
11438
11438
|
return Sh(() => {
|
|
11439
11439
|
const { initialValueFn: o, subscribe: l } = t, a = o();
|
|
11440
11440
|
return s.current !== a && (s.current = a, i(a)), l((u) => {
|
|
@@ -11736,7 +11736,7 @@ function Sc(r, e, t, n, i = /* @__PURE__ */ new Map(), s) {
|
|
|
11736
11736
|
return c != null && (f = c(f)), Wi(r) && (f = Kh(r, f, p ? () => {
|
|
11737
11737
|
const g = new la();
|
|
11738
11738
|
return t.push(g), g;
|
|
11739
|
-
} :
|
|
11739
|
+
} : ot)), l == null ? f.length > 0 ? o = o.concat(f) : Wi(r) && function(g) {
|
|
11740
11740
|
return g.nextSibling == null || g.previousSibling == null ? !1 : io(g.nextSibling) && io(g.previousSibling);
|
|
11741
11741
|
}(r) && (o = o.concat(Ir())) : P(l) && l.append(...f), o;
|
|
11742
11742
|
}
|
|
@@ -11950,11 +11950,11 @@ class Es extends hr {
|
|
|
11950
11950
|
return { ...super.exportJSON(), type: "quote" };
|
|
11951
11951
|
}
|
|
11952
11952
|
insertNewAfter(e, t) {
|
|
11953
|
-
const n =
|
|
11953
|
+
const n = ot(), i = this.getDirection();
|
|
11954
11954
|
return n.setDirection(i), this.insertAfter(n, t), n;
|
|
11955
11955
|
}
|
|
11956
11956
|
collapseAtStart() {
|
|
11957
|
-
const e =
|
|
11957
|
+
const e = ot();
|
|
11958
11958
|
return this.getChildren().forEach((t) => e.append(t)), this.replace(e), !0;
|
|
11959
11959
|
}
|
|
11960
11960
|
canMergeWhenEmpty() {
|
|
@@ -12013,15 +12013,15 @@ class ks extends hr {
|
|
|
12013
12013
|
return { ...super.exportJSON(), tag: this.getTag(), type: "heading", version: 1 };
|
|
12014
12014
|
}
|
|
12015
12015
|
insertNewAfter(e, t = !0) {
|
|
12016
|
-
const n = e ? e.anchor.offset : 0, i = this.getLastDescendant(), s = !i || e && e.anchor.key === i.getKey() && n === i.getTextContentSize() || !e ?
|
|
12016
|
+
const n = e ? e.anchor.offset : 0, i = this.getLastDescendant(), s = !i || e && e.anchor.key === i.getKey() && n === i.getTextContentSize() || !e ? ot() : Sn(this.getTag()), o = this.getDirection();
|
|
12017
12017
|
if (s.setDirection(o), this.insertAfter(s, t), n === 0 && !this.isEmpty() && e) {
|
|
12018
|
-
const l =
|
|
12018
|
+
const l = ot();
|
|
12019
12019
|
l.select(), this.replace(l, !0);
|
|
12020
12020
|
}
|
|
12021
12021
|
return s;
|
|
12022
12022
|
}
|
|
12023
12023
|
collapseAtStart() {
|
|
12024
|
-
const e = this.isEmpty() ?
|
|
12024
|
+
const e = this.isEmpty() ? ot() : Sn(this.getTag());
|
|
12025
12025
|
return this.getChildren().forEach((t) => e.append(t)), this.replace(e), !0;
|
|
12026
12026
|
}
|
|
12027
12027
|
extractWithChild() {
|
|
@@ -12248,7 +12248,7 @@ function cp({ contentEditable: r, placeholder: e = null, ErrorBoundary: t }) {
|
|
|
12248
12248
|
});
|
|
12249
12249
|
}), [s]), Te(() => {
|
|
12250
12250
|
a(s.getDecorators());
|
|
12251
|
-
}, [s]),
|
|
12251
|
+
}, [s]), ct(() => {
|
|
12252
12252
|
const u = [], c = Object.keys(l);
|
|
12253
12253
|
for (let d = 0; d < c.length; d++) {
|
|
12254
12254
|
const f = c[d], p = h.jsx(o, { onError: (m) => s._onError(m), children: h.jsx(Cd, { fallback: null, children: l[f] }) }), g = s.getElementByKey(f);
|
|
@@ -12282,7 +12282,7 @@ const Tc = typeof window < "u" && window.document !== void 0 && window.document.
|
|
|
12282
12282
|
function fp({ editor: r, ariaActiveDescendant: e, ariaAutoComplete: t, ariaControls: n, ariaDescribedBy: i, ariaErrorMessage: s, ariaExpanded: o, ariaInvalid: l, ariaLabel: a, ariaLabelledBy: u, ariaMultiline: c, ariaOwns: d, ariaRequired: f, autoCapitalize: p, className: g, id: m, role: x = "textbox", spellCheck: b = !0, style: y, tabIndex: _, "data-testid": C, ...k }, w) {
|
|
12283
12283
|
const [v, E] = O(r.isEditable()), B = Q((T) => {
|
|
12284
12284
|
T && T.ownerDocument && T.ownerDocument.defaultView ? r.setRootElement(T) : r.setRootElement(null);
|
|
12285
|
-
}, [r]), A =
|
|
12285
|
+
}, [r]), A = ct(() => /* @__PURE__ */ function(...T) {
|
|
12286
12286
|
return (F) => {
|
|
12287
12287
|
T.forEach((R) => {
|
|
12288
12288
|
typeof R == "function" ? R(F) : R != null && (R.current = F);
|
|
@@ -12408,7 +12408,7 @@ function Cp() {
|
|
|
12408
12408
|
function Dp({ delay: r, externalHistoryState: e }) {
|
|
12409
12409
|
const [t] = Ht();
|
|
12410
12410
|
return function(n, i, s = 1e3) {
|
|
12411
|
-
const o =
|
|
12411
|
+
const o = ct(() => i || Cp(), [i]);
|
|
12412
12412
|
Te(() => wp(n, o, s), [s, n, o]);
|
|
12413
12413
|
}(t, e, r), null;
|
|
12414
12414
|
}
|
|
@@ -12603,7 +12603,7 @@ function Bp(r) {
|
|
|
12603
12603
|
let o = s;
|
|
12604
12604
|
const l = Nc(s);
|
|
12605
12605
|
for (const a of l) {
|
|
12606
|
-
const u =
|
|
12606
|
+
const u = ot();
|
|
12607
12607
|
Or(u, a.getChildren()), o.insertAfter(u), o = u, a.__key === e.anchor.key && e.anchor.set(u.getKey(), 0, "element"), a.__key === e.focus.key && e.focus.set(u.getKey(), 0, "element"), a.remove();
|
|
12608
12608
|
}
|
|
12609
12609
|
s.remove();
|
|
@@ -12660,7 +12660,7 @@ function Rp() {
|
|
|
12660
12660
|
Pe(n) || Qt(40);
|
|
12661
12661
|
const i = n.getParent();
|
|
12662
12662
|
let s;
|
|
12663
|
-
if (er(i)) s =
|
|
12663
|
+
if (er(i)) s = ot(), t.insertAfter(s);
|
|
12664
12664
|
else {
|
|
12665
12665
|
if (!Ze(i)) return !1;
|
|
12666
12666
|
s = Bt(), i.insertAfter(s);
|
|
@@ -12781,7 +12781,7 @@ class Ur extends hr {
|
|
|
12781
12781
|
return this.insertAfter(n, t), n;
|
|
12782
12782
|
}
|
|
12783
12783
|
collapseAtStart(e) {
|
|
12784
|
-
const t =
|
|
12784
|
+
const t = ot();
|
|
12785
12785
|
this.getChildren().forEach((o) => t.append(o));
|
|
12786
12786
|
const n = this.getParentOrThrow(), i = n.getParentOrThrow(), s = Ze(i);
|
|
12787
12787
|
if (n.getChildrenSize() === 1) if (s) n.remove(), i.select();
|
|
@@ -12954,7 +12954,7 @@ class pn extends hr {
|
|
|
12954
12954
|
if (Pe(n)) i.append(n);
|
|
12955
12955
|
else if (P(n)) if (n.isInline()) i.append(n);
|
|
12956
12956
|
else {
|
|
12957
|
-
const s =
|
|
12957
|
+
const s = lt(n.getTextContent());
|
|
12958
12958
|
i.append(s);
|
|
12959
12959
|
}
|
|
12960
12960
|
else i.append(n);
|
|
@@ -14604,7 +14604,7 @@ function ag({ html: r, isExternalUpdate: e, onImportComplete: t }) {
|
|
|
14604
14604
|
() => {
|
|
14605
14605
|
const s = Xe();
|
|
14606
14606
|
s.clear();
|
|
14607
|
-
const o =
|
|
14607
|
+
const o = ot();
|
|
14608
14608
|
s.append(o), o.select();
|
|
14609
14609
|
const a = new DOMParser().parseFromString(r, "text/html"), c = Cc(n, a).filter((d) => d.getParent() === null);
|
|
14610
14610
|
c.length > 0 && lc(c), o.getTextContent() === "" && s.getChildrenSize() > 1 && o.remove(), s.selectEnd();
|
|
@@ -14632,7 +14632,7 @@ function lg({ text: r, trigger: e }) {
|
|
|
14632
14632
|
const a = ae();
|
|
14633
14633
|
H(a) && a.insertText(i);
|
|
14634
14634
|
} else {
|
|
14635
|
-
const a =
|
|
14635
|
+
const a = ot(), u = lt(i);
|
|
14636
14636
|
a.append(u), o.append(a);
|
|
14637
14637
|
}
|
|
14638
14638
|
}
|
|
@@ -15568,7 +15568,7 @@ function jy({
|
|
|
15568
15568
|
className: a = "",
|
|
15569
15569
|
theme: u = {}
|
|
15570
15570
|
}) {
|
|
15571
|
-
const c = { ...hg, ...u }, [d, f] = O(""), [p, g] = O(!1), m = me(null), x = me(null), b =
|
|
15571
|
+
const c = { ...hg, ...u }, [d, f] = O(""), [p, g] = O(!1), m = me(null), x = me(null), b = ct(() => e && r.find((E) => E.id === e) || null, [e, r]), y = ct(() => {
|
|
15572
15572
|
if (!d.trim()) return r;
|
|
15573
15573
|
const E = d.toLowerCase();
|
|
15574
15574
|
return r.filter(
|
|
@@ -15943,12 +15943,12 @@ function Py({
|
|
|
15943
15943
|
className: p = "",
|
|
15944
15944
|
theme: g = {}
|
|
15945
15945
|
}) {
|
|
15946
|
-
const m = { ...pg, ...g }, { allDayItems: x, timedItems: b } =
|
|
15946
|
+
const m = { ...pg, ...g }, { allDayItems: x, timedItems: b } = ct(() => {
|
|
15947
15947
|
const v = [], E = [];
|
|
15948
15948
|
for (const B of r)
|
|
15949
15949
|
l(B) ? v.push(B) : E.push(B);
|
|
15950
15950
|
return { allDayItems: v, timedItems: E };
|
|
15951
|
-
}, [r, l]), y =
|
|
15951
|
+
}, [r, l]), y = ct(() => {
|
|
15952
15952
|
const v = [];
|
|
15953
15953
|
for (let E = t; E <= n; E++)
|
|
15954
15954
|
v.push(E);
|
|
@@ -15963,7 +15963,7 @@ function Py({
|
|
|
15963
15963
|
return { top: D, height: M };
|
|
15964
15964
|
},
|
|
15965
15965
|
[s, o, t, n, i]
|
|
15966
|
-
), k =
|
|
15966
|
+
), k = ct(() => {
|
|
15967
15967
|
if (!f || !yg(e)) return null;
|
|
15968
15968
|
const v = /* @__PURE__ */ new Date(), E = v.getHours(), B = v.getMinutes();
|
|
15969
15969
|
return E < t || E > n ? null : (E - t) * i + B / 60 * i;
|
|
@@ -16153,25 +16153,25 @@ function xg({ onComplete: r, onCancel: e, onTranscribe: t, onTranscriptionComple
|
|
|
16153
16153
|
const it = [];
|
|
16154
16154
|
for (let Qe = 0; Qe < j; Qe++)
|
|
16155
16155
|
it.push(ee.getChannelData(Qe));
|
|
16156
|
-
let
|
|
16156
|
+
let at = 44;
|
|
16157
16157
|
for (let Qe = 0; Qe < ee.length; Qe++)
|
|
16158
16158
|
for (let Ue = 0; Ue < j; Ue++) {
|
|
16159
16159
|
const pt = Math.max(-1, Math.min(1, it[Ue][Qe])), gt = pt < 0 ? pt * 32768 : pt * 32767;
|
|
16160
|
-
Ce.setInt16(
|
|
16160
|
+
Ce.setInt16(at, gt, !0), at += 2;
|
|
16161
16161
|
}
|
|
16162
16162
|
return new Blob([Ve], { type: "audio/wav" });
|
|
16163
16163
|
}, L = async (ee, j, ue, he) => {
|
|
16164
16164
|
const G = new AudioContext(), De = ee.sampleRate, ve = Math.max(ee.numberOfChannels, j.numberOfChannels), we = Math.min(ue, ee.length), Ie = Math.max(0, ee.length - ue), Ve = he === "insert" ? we + j.length + Ie : we + j.length, Ce = G.createBuffer(ve, Ve, De);
|
|
16165
16165
|
for (let Ae = 0; Ae < ve; Ae++) {
|
|
16166
|
-
const it = Ce.getChannelData(Ae),
|
|
16166
|
+
const it = Ce.getChannelData(Ae), at = Ae < ee.numberOfChannels ? ee.getChannelData(Ae) : ee.getChannelData(0);
|
|
16167
16167
|
for (let Ue = 0; Ue < we; Ue++)
|
|
16168
|
-
it[Ue] =
|
|
16168
|
+
it[Ue] = at[Ue];
|
|
16169
16169
|
const Qe = Ae < j.numberOfChannels ? j.getChannelData(Ae) : j.getChannelData(0);
|
|
16170
16170
|
for (let Ue = 0; Ue < j.length; Ue++)
|
|
16171
16171
|
it[we + Ue] = Qe[Ue];
|
|
16172
16172
|
if (he === "insert")
|
|
16173
16173
|
for (let Ue = 0; Ue < Ie; Ue++)
|
|
16174
|
-
it[we + j.length + Ue] =
|
|
16174
|
+
it[we + j.length + Ue] = at[ue + Ue];
|
|
16175
16175
|
}
|
|
16176
16176
|
return await G.close(), Ce;
|
|
16177
16177
|
}, xe = Q(() => {
|
|
@@ -16187,8 +16187,8 @@ function xg({ onComplete: r, onCancel: e, onTranscribe: t, onTranscriptionComple
|
|
|
16187
16187
|
Ae.addColorStop(0, "transparent"), Ae.addColorStop(1, Ve), j.fillStyle = Ae, j.fillRect(0, G - Ie, he, Ie);
|
|
16188
16188
|
const it = j.createLinearGradient(0, 0, Ie, 0);
|
|
16189
16189
|
it.addColorStop(0, Ve), it.addColorStop(1, "transparent"), j.fillStyle = it, j.fillRect(0, 0, Ie, G);
|
|
16190
|
-
const
|
|
16191
|
-
|
|
16190
|
+
const at = j.createLinearGradient(he - Ie, 0, he, 0);
|
|
16191
|
+
at.addColorStop(0, "transparent"), at.addColorStop(1, Ve), j.fillStyle = at, j.fillRect(he - Ie, 0, Ie, G), j.strokeStyle = "#5a6b62", j.lineWidth = 1, j.beginPath(), j.moveTo(0, G / 2), j.lineTo(he, G / 2), j.stroke();
|
|
16192
16192
|
const Qe = he / 2;
|
|
16193
16193
|
if (De.length > 0)
|
|
16194
16194
|
if (a === "recording")
|
|
@@ -16242,13 +16242,13 @@ function xg({ onComplete: r, onCancel: e, onTranscribe: t, onTranscriptionComple
|
|
|
16242
16242
|
let ve, we;
|
|
16243
16243
|
if (Ne.current !== null && _e.current)
|
|
16244
16244
|
try {
|
|
16245
|
-
const Ce = await He(De), Ae = _e.current.sampleRate, it = Math.floor(Ne.current * Ae),
|
|
16245
|
+
const Ce = await He(De), Ae = _e.current.sampleRate, it = Math.floor(Ne.current * Ae), at = await L(
|
|
16246
16246
|
_e.current,
|
|
16247
16247
|
Ce,
|
|
16248
16248
|
it,
|
|
16249
16249
|
ie.current
|
|
16250
16250
|
);
|
|
16251
|
-
ve = Y(
|
|
16251
|
+
ve = Y(at), we = at.length / at.sampleRate, ie.current === "insert" && (ge.current = [
|
|
16252
16252
|
...ge.current,
|
|
16253
16253
|
...Ee.current
|
|
16254
16254
|
]), Ne.current = null, _e.current = null, Z.current = [], Ee.current = [];
|
|
@@ -16380,8 +16380,8 @@ function xg({ onComplete: r, onCancel: e, onTranscribe: t, onTranscriptionComple
|
|
|
16380
16380
|
if (G) {
|
|
16381
16381
|
const De = he.getBoundingClientRect(), ve = De.width, we = De.height, Ie = ge.current, Ve = f || c || 1, Ce = ue.currentTime;
|
|
16382
16382
|
G.fillStyle = "#2d3b35", G.fillRect(0, 0, ve, we);
|
|
16383
|
-
const Ae = 8, it = "rgba(0, 0, 0, 0.4)",
|
|
16384
|
-
|
|
16383
|
+
const Ae = 8, it = "rgba(0, 0, 0, 0.4)", at = G.createLinearGradient(0, 0, 0, Ae);
|
|
16384
|
+
at.addColorStop(0, it), at.addColorStop(1, "transparent"), G.fillStyle = at, G.fillRect(0, 0, ve, Ae);
|
|
16385
16385
|
const Qe = G.createLinearGradient(0, we - Ae, 0, we);
|
|
16386
16386
|
Qe.addColorStop(0, "transparent"), Qe.addColorStop(1, it), G.fillStyle = Qe, G.fillRect(0, we - Ae, ve, Ae);
|
|
16387
16387
|
const Ue = G.createLinearGradient(0, 0, Ae, 0);
|
|
@@ -19390,7 +19390,7 @@ const ey = us(function({
|
|
|
19390
19390
|
width: o,
|
|
19391
19391
|
onClick: l
|
|
19392
19392
|
}) {
|
|
19393
|
-
const [a, u] = O(!1), c =
|
|
19393
|
+
const [a, u] = O(!1), c = ct(() => X2(t, n, i), [t, n, i]), d = Q((x) => {
|
|
19394
19394
|
x.stopPropagation(), l == null || l(e, x);
|
|
19395
19395
|
}, [e, l]), f = Q(() => {
|
|
19396
19396
|
u(!0);
|
|
@@ -19440,7 +19440,7 @@ const ey = us(function({
|
|
|
19440
19440
|
] });
|
|
19441
19441
|
}, (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);
|
|
19442
19442
|
function ty({ pathD: r, label: e, color: t }) {
|
|
19443
|
-
const n =
|
|
19443
|
+
const n = ct(() => `edge-label-${Math.random().toString(36).substr(2, 9)}`, []);
|
|
19444
19444
|
return /* @__PURE__ */ h.jsxs(h.Fragment, { children: [
|
|
19445
19445
|
/* @__PURE__ */ h.jsx("defs", { children: /* @__PURE__ */ h.jsx("path", { id: n, d: r }) }),
|
|
19446
19446
|
/* @__PURE__ */ h.jsx(
|
|
@@ -19471,15 +19471,7 @@ const ry = us(function({
|
|
|
19471
19471
|
defaultWidth: s,
|
|
19472
19472
|
onEdgeClick: o
|
|
19473
19473
|
}) {
|
|
19474
|
-
const l =
|
|
19475
|
-
if (t.size === 0) return "0 0 1000 1000";
|
|
19476
|
-
let u = 1 / 0, c = 1 / 0, d = -1 / 0, f = -1 / 0;
|
|
19477
|
-
for (const p of t.values()) {
|
|
19478
|
-
const g = p.width || 200, m = p.height || 100;
|
|
19479
|
-
u = Math.min(u, p.x - 100), c = Math.min(c, p.y - 100), d = Math.max(d, p.x + g + 100), f = Math.max(f, p.y + m + 100);
|
|
19480
|
-
}
|
|
19481
|
-
return u -= 1e3, c -= 1e3, d += 1e3, f += 1e3, `${u} ${c} ${d - u} ${f - c}`;
|
|
19482
|
-
}, [t]);
|
|
19474
|
+
const l = ct(() => e.filter((a) => t.has(a.source) && t.has(a.target)), [e, t]);
|
|
19483
19475
|
return /* @__PURE__ */ h.jsx(
|
|
19484
19476
|
"svg",
|
|
19485
19477
|
{
|
|
@@ -19487,27 +19479,25 @@ const ry = us(function({
|
|
|
19487
19479
|
position: "absolute",
|
|
19488
19480
|
top: 0,
|
|
19489
19481
|
left: 0,
|
|
19490
|
-
width:
|
|
19491
|
-
height:
|
|
19482
|
+
width: 1,
|
|
19483
|
+
height: 1,
|
|
19492
19484
|
overflow: "visible",
|
|
19493
19485
|
pointerEvents: "none"
|
|
19494
19486
|
},
|
|
19495
|
-
|
|
19496
|
-
|
|
19497
|
-
children: /* @__PURE__ */ h.jsx("g", { style: { pointerEvents: "auto" }, children: l.map((u) => {
|
|
19498
|
-
const c = t.get(u.source), d = t.get(u.target);
|
|
19487
|
+
children: /* @__PURE__ */ h.jsx("g", { style: { pointerEvents: "auto" }, children: l.map((a) => {
|
|
19488
|
+
const u = t.get(a.source), c = t.get(a.target);
|
|
19499
19489
|
return /* @__PURE__ */ h.jsx(
|
|
19500
19490
|
ey,
|
|
19501
19491
|
{
|
|
19502
|
-
edge:
|
|
19503
|
-
sourcePosition:
|
|
19504
|
-
targetPosition:
|
|
19505
|
-
style:
|
|
19506
|
-
color:
|
|
19507
|
-
width:
|
|
19492
|
+
edge: a,
|
|
19493
|
+
sourcePosition: u,
|
|
19494
|
+
targetPosition: c,
|
|
19495
|
+
style: a.style || n,
|
|
19496
|
+
color: a.color || i,
|
|
19497
|
+
width: a.width || s,
|
|
19508
19498
|
onClick: o
|
|
19509
19499
|
},
|
|
19510
|
-
|
|
19500
|
+
a.id
|
|
19511
19501
|
);
|
|
19512
19502
|
}) })
|
|
19513
19503
|
}
|
|
@@ -19516,7 +19506,7 @@ const ry = us(function({
|
|
|
19516
19506
|
box: e,
|
|
19517
19507
|
transform: t
|
|
19518
19508
|
}) {
|
|
19519
|
-
const n =
|
|
19509
|
+
const n = ct(() => ({
|
|
19520
19510
|
x: e.x * t.k + t.x,
|
|
19521
19511
|
y: e.y * t.k + t.y,
|
|
19522
19512
|
width: e.width * t.k,
|
|
@@ -19572,7 +19562,7 @@ function Vy({
|
|
|
19572
19562
|
showGrid: F = !1,
|
|
19573
19563
|
gridSize: R = 20
|
|
19574
19564
|
}) {
|
|
19575
|
-
const D = r.data || { positions: {} }, N = D.positions || {}, M =
|
|
19565
|
+
const D = r.data || { positions: {} }, N = D.positions || {}, M = ct(() => {
|
|
19576
19566
|
const Y = /* @__PURE__ */ new Map();
|
|
19577
19567
|
for (const L of e) {
|
|
19578
19568
|
const xe = N[L._id] || { x: 0, y: 0 };
|
|
@@ -19642,7 +19632,7 @@ function Vy({
|
|
|
19642
19632
|
}), Re = Q((Y) => {
|
|
19643
19633
|
const L = M.get(Y) || { x: 0, y: 0, width: i, height: s }, xe = W.get(Y);
|
|
19644
19634
|
return xe ? { ...L, x: xe.x, y: xe.y } : L;
|
|
19645
|
-
}, [M, W, i, s]), ke =
|
|
19635
|
+
}, [M, W, i, s]), ke = ct(() => {
|
|
19646
19636
|
const Y = /* @__PURE__ */ new Map();
|
|
19647
19637
|
for (const L of M.keys())
|
|
19648
19638
|
Y.set(L, Re(L));
|
package/package.json
CHANGED