@qwanyx/stack 0.2.69 → 0.2.70

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.
@@ -22,8 +22,8 @@ export interface ComboStackProps {
22
22
  onItemClick?: (option: ComboStackOption) => void;
23
23
  /** Called when selection is cleared */
24
24
  onClear?: () => void;
25
- /** Called when + is clicked to create new item */
26
- onCreate?: () => void;
25
+ /** Called when + is clicked to create new item (receives search text) */
26
+ onCreate?: (searchText?: string) => void;
27
27
  /** Max height before scrolling (default: 300px) */
28
28
  maxHeight?: number | string;
29
29
  /** Additional CSS class */
package/dist/index.cjs.js CHANGED
@@ -180,7 +180,7 @@ React keys must be passed directly to JSX without using spread:
180
180
  from { transform: rotate(0deg); }
181
181
  to { transform: rotate(360deg); }
182
182
  }
183
- `})]})}const kg={background:"#ffffff",text:"#111827",textSecondary:"#6b7280",border:"#e5e7eb",primary:"#3b82f6",chipBackground:"#f3f4f6",chipText:"#374151",hoverBackground:"#f9fafb"};function Dg({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={...kg,...d},[g,m]=_.useState(!1),[x,v]=_.useState(""),b=_.useRef(null),C=_.useRef(null);_.useEffect(()=>{function T(M){b.current&&!b.current.contains(M.target)&&(m(!1),v(""))}return document.addEventListener("mousedown",T),()=>document.removeEventListener("mousedown",T)},[]);const S=r.filter(T=>{var M;return((M=T.label)==null?void 0:M.toLowerCase().includes(x.toLowerCase()))&&!e.includes(T.id)}),D=s&&x.trim()&&!r.some(T=>{var M;return((M=T.label)==null?void 0:M.toLowerCase())===x.toLowerCase()}),w=e.map(T=>r.find(M=>M.id===T)).filter(Boolean),y=_.useCallback(T=>{var M;c>0&&e.length>=c||(t([...e,T]),v(""),c===1?m(!1):(M=C.current)==null||M.focus())},[e,t,c]),k=_.useCallback(T=>{t(e.filter(M=>M!==T))},[e,t]),N=_.useCallback(async()=>{if(!D)return;const T=await(i==null?void 0:i(x.trim()));T&&y(T.id),v("")},[D,x,i,y]),F=_.useCallback(T=>{T.key==="Enter"?(T.preventDefault(),D?N():S.length>0&&y(S[0].id)):T.key==="Backspace"&&!x&&e.length>0?k(e[e.length-1]):T.key==="Escape"&&(m(!1),v(""))},[D,S,x,e,N,y,k]);return h.jsxs("div",{ref:b,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:[w.map(T=>h.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"2px 8px",borderRadius:"4px",fontSize:"13px",background:T.color||p.chipBackground,color:T.color?"#fff":p.chipText},children:[T.label,!u&&h.jsx("button",{type:"button",onClick:M=>{M.stopPropagation(),k(T.id)},style:{border:"none",background:"transparent",cursor:"pointer",padding:"0 2px",fontSize:"14px",color:"inherit",opacity:.7},children:"×"})]},T.id)),h.jsx("input",{ref:C,type:"text",value:x,onChange:T=>{v(T.target.value),g||m(!0)},onFocus:()=>m(!0),onKeyDown:F,placeholder:w.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(T=>h.jsxs("div",{onClick:()=>y(T.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:[T.label,o&&l&&h.jsx("button",{type:"button",onClick:M=>{M.stopPropagation(),l(T.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:"×"})]},T.id)),D&&h.jsxs("div",{onClick:N,style:{padding:"10px 12px",fontSize:"14px",cursor:"pointer",color:p.primary,borderTop:S.length>0?`1px solid ${p.border}`:"none"},onMouseEnter:T=>{T.currentTarget.style.background=p.hoverBackground||""},onMouseLeave:T=>{T.currentTarget.style.background=""},children:['+ Create "',x.trim(),'"']})]})})]})}const Ag={background:"#ffffff",cardBackground:"#f9fafb",cardHover:"#f3f4f6",text:"#111827",textSecondary:"#6b7280",border:"#e5e7eb",primary:"#3b82f6"};function Tg({options:r,value:e,type:t,placeholder:n="Search...",onItemClick:s,onClear:i,onCreate:o,maxHeight:l=300,className:a="",theme:u={}}){const c={...Ag,...u},[d,f]=_.useState(""),[p,g]=_.useState(!1),m=_.useRef(null),x=_.useRef(null),v=_.useMemo(()=>e&&r.find(y=>y.id===e)||null,[e,r]),b=_.useMemo(()=>{if(!d.trim())return r;const y=d.toLowerCase();return r.filter(k=>{var N,F;return((N=k.label)==null?void 0:N.toLowerCase().includes(y))||((F=k.notes)==null?void 0:F.toLowerCase().includes(y))})},[r,d]);_.useEffect(()=>{const y=k=>{m.current&&!m.current.contains(k.target)&&g(!1)};return document.addEventListener("mousedown",y),()=>document.removeEventListener("mousedown",y)},[]);const C=y=>{s&&s(y),g(!1),f("")},S=()=>{o&&o(),g(!1)},D=()=>{g(!0)},w=y=>{f(y.target.value),p||g(!0)};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:v&&!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:v.label}),v.notes&&h.jsx("div",{style:{fontSize:"11px",color:c.textSecondary,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:v.notes})]}),i&&h.jsx("button",{onClick:y=>{y.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:w,onFocus:D,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:y=>{y.currentTarget.style.background=c.cardHover||"#f3f4f6"},onMouseLeave:y=>{y.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:b.length===0?h.jsx("div",{style:{padding:"16px",textAlign:"center",color:c.textSecondary,fontSize:"14px"},children:d?`No results for "${d}"`:"No items"}):b.map((y,k)=>h.jsxs("div",{onClick:()=>C(y),style:{padding:"10px 14px",cursor:"pointer",borderBottom:k<b.length-1?`1px solid ${c.border}`:"none",background:c.cardBackground,transition:"background 0.15s"},onMouseEnter:N=>{N.currentTarget.style.background=c.cardHover||"#f3f4f6"},onMouseLeave:N=>{N.currentTarget.style.background=c.cardBackground||"#f9fafb"},children:[h.jsx("div",{style:{fontSize:"14px",fontWeight:500,color:y.color||c.text,marginBottom:y.notes?"2px":0},children:y.label}),y.notes&&h.jsx("div",{style:{fontSize:"12px",color:c.textSecondary,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:y.notes})]},y.id))})]})}function Ng({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]=_.useState(null),[x,v]=_.useState(null),[b,C]=_.useState(null),S=_.useRef(null),D=e.reduce((M,L)=>{let E=r.filter(B=>n(B)===L.id);return s&&(E=E.sort((B,R)=>s(B)-s(R))),M[L.id]=E,M},{}),w=_.useCallback((M,L)=>{const E=t(L),B=n(L);m(E),S.current=B,M.dataTransfer.effectAllowed="move",M.dataTransfer.setData("text/plain",E),requestAnimationFrame(()=>{const R=M.target;R.style.opacity="0.5"})},[t,n]),y=_.useCallback(M=>{const L=M.target;L.style.opacity="1",m(null),v(null),C(null),S.current=null},[]),k=_.useCallback((M,L,E)=>{M.preventDefault(),M.dataTransfer.dropEffect="move",v(L),C(E)},[]),N=_.useCallback(M=>{const L=M.relatedTarget;L!=null&&L.closest("[data-kanban-column]")||(v(null),C(null))},[]),F=_.useCallback((M,L,E)=>{if(M.preventDefault(),!g)return;const B=S.current;B===L?l==null||l(g,L,E):B&&o(g,B,L,E),m(null),v(null),C(null),S.current=null},[g,o,l]),T=(M,L)=>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:L})]});return h.jsx("div",{className:`flex gap-4 overflow-x-auto pb-4 ${d}`,style:{minHeight:"400px"},children:e.map(M=>{const L=D[M.id]||[],E=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&&!E&&v(M.id)},onDragLeave:N,onDrop:B=>F(B,M.id,b??L.length),children:[h.jsx("div",{className:"flex-shrink-0 border-b border-neutral-200",children:u?u(M,L.length):T(M,L.length)}),h.jsxs("div",{className:`flex-1 overflow-y-auto p-2 space-y-2 min-h-[100px] transition-colors ${E?"bg-blue-50":""}`,children:[L.map((B,R)=>{const O=t(B),H=g===O,U=E&&b===R&&!H;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:Z=>w(Z,B),onDragEnd:y,onDragOver:Z=>k(Z,M.id,R),onClick:()=>a==null?void 0:a(B),className:`cursor-grab active:cursor-grabbing transition-all ${H?"opacity-50 scale-95":""} ${p}`,children:i(B,H)})]},O)}),h.jsx("div",{className:"min-h-[40px] flex-1",onDragOver:B=>{B.preventDefault(),k(B,M.id,L.length)},children:E&&b===L.length&&h.jsx("div",{className:"h-1 bg-blue-500 rounded-full mx-1 mt-1"})}),L.length===0&&E&&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 Bg={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 Rg(r){const e=r%12||12,t=r<12?"AM":"PM";return`${e} ${t}`}function Mg(r){const e=new Date;return r.getDate()===e.getDate()&&r.getMonth()===e.getMonth()&&r.getFullYear()===e.getFullYear()}function jg({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={...Bg,...g},{allDayItems:x,timedItems:v}=_.useMemo(()=>{const y=[],k=[];for(const N of r)l(N)?y.push(N):k.push(N);return{allDayItems:y,timedItems:k}},[r,l]),b=_.useMemo(()=>{const y=[];for(let k=t;k<=n;k++)y.push(k);return y},[t,n]),C=(n-t+1)*s,S=_.useCallback(y=>{const k=i(y);if(!k)return null;const N=Fg(k);if(!N)return null;const{hours:F,minutes:T}=N,M=Math.max(t,Math.min(n,F)),L=F<t?0:T,E=(M-t)*s+L/60*s,B=o(y),R=Math.max(20,B/60*s);return{top:E,height:R}},[i,o,t,n,s]),D=_.useMemo(()=>{if(!f||!Mg(e))return null;const y=new Date,k=y.getHours(),N=y.getMinutes();return k<t||k>n?null:(k-t)*s+N/60*s},[e,f,t,n,s]),w=_.useCallback(y=>{if(!d)return;const k=y.currentTarget.getBoundingClientRect(),F=(y.clientY-k.top)/s*60,T=Math.floor(F/60)+t,M=Math.round(F%60/15)*15,L=Math.min(n,Math.max(t,T)),E=M>=60?0:M,B=`${L.toString().padStart(2,"0")}:${E.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(y=>h.jsx("div",{onClick:()=>c==null?void 0:c(y),style:{cursor:c?"pointer":"default"},children:u(y)},a(y)))})]}),h.jsxs("div",{style:{position:"relative",height:C},children:[b.map((y,k)=>h.jsxs("div",{style:{position:"absolute",top:k*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:Rg(y)}),h.jsx("div",{style:{position:"absolute",left:"60px",right:0,top:0,height:"1px",background:m.hourLineColor}}),k<b.length-1&&h.jsx("div",{style:{position:"absolute",left:"60px",right:0,top:s/2,height:"1px",background:m.halfHourLineColor}})]},y)),h.jsx("div",{style:{position:"absolute",left:"60px",right:0,top:0,bottom:0,cursor:d?"pointer":"default"},onClick:w}),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}})]}),v.map(y=>{const k=S(y);return k?h.jsx("div",{style:{position:"absolute",left:"64px",right:"8px",top:k.top,height:k.height,zIndex:10,cursor:c?"pointer":"default"},onClick:N=>{N.stopPropagation(),c==null||c(y)},children:u(y)},a(y)):null})]})]})}function Hc({onComplete:r,onCancel:e,onTranscribe:t,onTranscriptionComplete:n,variant:s="widget",hideSaveButton:i=!1,maxDuration:o=180}){const l=s==="widget",[a,u]=_.useState("idle"),[c,d]=_.useState(0),[f,p]=_.useState(0),[g,m]=_.useState(!1),[x,v]=_.useState(0),[b,C]=_.useState(null),[S,D]=_.useState(!1),[w,y]=_.useState(null),[k,N]=_.useState(!0),[F,T]=_.useState([]),[M,L]=_.useState({completed:0,total:0}),E=_.useRef(!1),B=_.useRef(!0);_.useEffect(()=>{B.current=k},[k]);const R=_.useRef(null),O=_.useRef(null),H=_.useRef(null),U=_.useRef(null),Z=_.useRef(null),q=_.useRef([]),K=_.useRef(null),$=_.useRef(null),re=_.useRef(null),ae=_.useRef(null),le=_.useRef(!1),ce=_.useRef([]),ve=_.useRef(null),pe=_.useRef(null),Fe=_.useRef([]),et=_.useRef([]),ct=_.useRef("insert"),kt=_.useRef(!1),tt=_.useRef(0),xt=_.useRef(0),dt=_.useRef(0),It=Y=>{const j=Math.floor(Y/60),ne=Math.floor(Y%60);return`${j.toString().padStart(2,"0")}:${ne.toString().padStart(2,"0")}`},ue=async Y=>{const j=await Y.arrayBuffer(),ne=new AudioContext,ie=await ne.decodeAudioData(j);return await ne.close(),ie},_e=Y=>{const j=Y.numberOfChannels,ne=Y.sampleRate,ie=1,W=16,ge=W/8,de=j*ge,fe=ne*de,Se=Y.length*de,Be=new ArrayBuffer(44+Se),he=new DataView(Be),me=(Le,De)=>{for(let rt=0;rt<De.length;rt++)he.setUint8(Le+rt,De.charCodeAt(rt))};me(0,"RIFF"),he.setUint32(4,36+Se,!0),me(8,"WAVE"),me(12,"fmt "),he.setUint32(16,16,!0),he.setUint16(20,ie,!0),he.setUint16(22,j,!0),he.setUint32(24,ne,!0),he.setUint32(28,fe,!0),he.setUint16(32,de,!0),he.setUint16(34,W,!0),me(36,"data"),he.setUint32(40,Se,!0);const We=[];for(let Le=0;Le<j;Le++)We.push(Y.getChannelData(Le));let Ge=44;for(let Le=0;Le<Y.length;Le++)for(let De=0;De<j;De++){const rt=Math.max(-1,Math.min(1,We[De][Le])),nt=rt<0?rt*32768:rt*32767;he.setInt16(Ge,nt,!0),Ge+=2}return new Blob([Be],{type:"audio/wav"})},Te=async(Y,j,ne,ie)=>{const W=new AudioContext,ge=Y.sampleRate,de=Math.max(Y.numberOfChannels,j.numberOfChannels),fe=Math.min(ne,Y.length),Se=Math.max(0,Y.length-ne),Be=ie==="insert"?fe+j.length+Se:fe+j.length,he=W.createBuffer(de,Be,ge);for(let me=0;me<de;me++){const We=he.getChannelData(me),Ge=me<Y.numberOfChannels?Y.getChannelData(me):Y.getChannelData(0);for(let De=0;De<fe;De++)We[De]=Ge[De];const Le=me<j.numberOfChannels?j.getChannelData(me):j.getChannelData(0);for(let De=0;De<j.length;De++)We[fe+De]=Le[De];if(ie==="insert")for(let De=0;De<Se;De++)We[fe+j.length+De]=Ge[ne+De]}return await W.close(),he},it=_.useCallback(()=>{const Y=R.current;if(!Y)return;const j=Y.getContext("2d");if(!j)return;const ne=Y.getBoundingClientRect(),ie=ne.width,W=ne.height,ge=ce.current,de=f||c||1,fe=a==="recording"?c:x;j.fillStyle="#2d3b35",j.fillRect(0,0,ie,W);const Se=8,Be="rgba(0, 0, 0, 0.4)",he=j.createLinearGradient(0,0,0,Se);he.addColorStop(0,Be),he.addColorStop(1,"transparent"),j.fillStyle=he,j.fillRect(0,0,ie,Se);const me=j.createLinearGradient(0,W-Se,0,W);me.addColorStop(0,"transparent"),me.addColorStop(1,Be),j.fillStyle=me,j.fillRect(0,W-Se,ie,Se);const We=j.createLinearGradient(0,0,Se,0);We.addColorStop(0,Be),We.addColorStop(1,"transparent"),j.fillStyle=We,j.fillRect(0,0,Se,W);const Ge=j.createLinearGradient(ie-Se,0,ie,0);Ge.addColorStop(0,"transparent"),Ge.addColorStop(1,Be),j.fillStyle=Ge,j.fillRect(ie-Se,0,Se,W),j.strokeStyle="#5a6b62",j.lineWidth=1,j.beginPath(),j.moveTo(0,W/2),j.lineTo(ie,W/2),j.stroke();const Le=ie/2;if(ge.length>0)if(a==="recording")for(let nt=0;nt<ge.length;nt++){const wt=ge.length-1-nt,Zt=Le-wt*4;if(Zt<-3||Zt>ie)continue;const At=ge[nt]*(W/2-12),A=W/2-At;j.fillStyle="#10b981",j.fillRect(Zt,A,3,At*2)}else{const nt=de>0?fe/de*ge.length:0;for(let wt=0;wt<ge.length;wt++){const Zt=nt-wt,At=Le-Zt*4;if(At<-3||At>ie)continue;const A=ge[wt]*(W/2-12),I=W/2-A;j.fillStyle=wt<=nt?"#10b981":"#4b5563",j.fillRect(At,I,3,A*2)}}j.strokeStyle="#ef4444",j.lineWidth=1,j.beginPath(),j.moveTo(Le,0),j.lineTo(Le,W),j.stroke(),j.fillStyle="#fff",j.font="bold 18px monospace",j.textAlign="center",j.fillText(It(fe),Le,W-6),a==="recording"&&(j.fillStyle="#ef4444",j.beginPath(),j.arc(20,20,8,0,Math.PI*2),j.fill(),j.fillStyle="#fff",j.font="10px sans-serif",j.textAlign="left",j.fillText("REC",34,24)),j.textAlign="left"},[a,x,c,f]),Je=()=>{const Y=Z.current;if(!Y||!le.current)return;const j=Y.frequencyBinCount,ne=new Uint8Array(j);Y.getByteTimeDomainData(ne);let ie=0;for(let de=0;de<j;de++){const fe=(ne[de]-128)/128;ie+=fe*fe}const W=Math.sqrt(ie/j),ge=Math.min(1,W*3);ce.current.push(ge),it(),le.current&&($.current=requestAnimationFrame(Je))},X=async()=>{try{C(null),D(!1),ve.current===null&&(ce.current=[]);const Y=await navigator.mediaDevices.getUserMedia({audio:!0});H.current=Y;const j=new AudioContext;U.current=j;const ne=j.createAnalyser();ne.fftSize=2048,Z.current=ne,j.createMediaStreamSource(Y).connect(ne);const W=new MediaRecorder(Y);O.current=W,q.current=[],W.ondataavailable=ge=>{ge.data.size>0&&q.current.push(ge.data)},W.onstop=async()=>{try{if(le.current=!1,q.current.length===0){C("No audio was recorded. Please try again."),u("idle"),Y.getTracks().forEach(he=>he.stop());return}const ge=new Blob(q.current,{type:"audio/webm"});let de,fe;if(ve.current!==null&&pe.current)try{const he=await ue(ge),me=pe.current.sampleRate,We=Math.floor(ve.current*me),Ge=await Te(pe.current,he,We,ct.current);de=_e(Ge),fe=Ge.length/Ge.sampleRate,ct.current==="insert"&&(ce.current=[...ce.current,...et.current]),ve.current=null,pe.current=null,Fe.current=[],et.current=[]}catch{de=ge,fe=tt.current>0?tt.current:1}else de=ge,fe=tt.current>0?tt.current:1;if(ae.current=de,Y.getTracks().forEach(he=>he.stop()),B.current&&t){T(he=>[...he,de]),L(he=>({...he,total:he.total+1})),ae.current=null,ce.current=[],v(0),p(0),d(0),u("idle");return}const Se=URL.createObjectURL(de),Be=new Audio(Se);Be.ontimeupdate=()=>{v(Be.currentTime)},Be.onended=()=>{m(!1)},re.current=Be,p(fe),v(fe),u("editing")}catch{C("Failed to process recording"),u("idle")}},W.start(100),le.current=!0,u("recording"),d(0),tt.current=0,K.current=setInterval(()=>{tt.current+=1,d(tt.current),tt.current>=o&&(O.current&&O.current.state!=="inactive"&&O.current.stop(),le.current=!1,y(null),K.current&&(clearInterval(K.current),K.current=null),$.current&&(cancelAnimationFrame($.current),$.current=null),setTimeout(()=>{alert(`Maximum recording time of ${Math.floor(o/60)} minutes reached.`)},100))},1e3)}catch{C("Could not access microphone. Please allow microphone access.")}},Ne=()=>{le.current=!1,D(!1),y(null),$.current&&(cancelAnimationFrame($.current),$.current=null),K.current&&(clearInterval(K.current),K.current=null),O.current&&O.current.state!=="inactive"&&O.current.stop()},Me=Y=>{const j=R.current;if(!j)return;const ne=f||c;if(ne<=0)return;const ie=ce.current;if(ie.length===0)return;const W=j.getBoundingClientRect(),ge=Y-xt.current,de=4,fe=W.width/j.width,Se=ie.length/ne*de,Be=-ge/(Se*fe),he=dt.current+Be,me=Math.max(0,Math.min(he,ne));re.current&&(re.current.currentTime=me),v(me)},Re=()=>{re.current&&(re.current.currentTime=0),v(0)},zt=()=>{const Y=f||c;re.current&&(re.current.currentTime=Y),v(Y)},$t=()=>{const Y=re.current;Y&&(g?(Y.pause(),v(Y.currentTime),m(!1)):(Y.currentTime=x,Y.play().catch(()=>{}),m(!0)))},Jt=async Y=>{if(!ae.current){X();return}try{re.current&&(re.current.pause(),m(!1)),ct.current=Y,pe.current=await ue(ae.current);const j=f||c;ve.current=x;const ne=j>0?x/j:0,ie=Math.floor(ne*ce.current.length);Fe.current=ce.current.slice(0,ie),et.current=ce.current.slice(ie),ce.current=[...Fe.current],X()}catch{C("Failed to prepare recording. Please try again.")}},ee=()=>{re.current&&(re.current.pause(),re.current=null),ae.current=null,pe.current=null,ve.current=null,Fe.current=[],m(!1),v(0),p(0),d(0),X()},se=()=>{ae.current?r(ae.current,f||c):alert("No audio recorded yet!")};_.useEffect(()=>{a==="recording"&&R.current&&Z.current&&le.current&&($.current=requestAnimationFrame(Je))},[a]),_.useEffect(()=>{const Y=R.current;if(!Y)return;const j=()=>{const ne=window.devicePixelRatio||1,ie=Y.getBoundingClientRect();Y.width=ie.width*ne,Y.height=ie.height*ne;const W=Y.getContext("2d");W&&W.scale(ne,ne)};return j(),window.addEventListener("resize",j),()=>window.removeEventListener("resize",j)},[]),_.useEffect(()=>{if(a==="idle"){const Y=R.current;if(!Y)return;const j=Y.getContext("2d");if(!j)return;const ne=Y.getBoundingClientRect(),ie=ne.width,W=ne.height;j.fillStyle="#2d3b35",j.fillRect(0,0,ie,W);const ge=8,de="rgba(0, 0, 0, 0.4)",fe=j.createLinearGradient(0,0,0,ge);fe.addColorStop(0,de),fe.addColorStop(1,"transparent"),j.fillStyle=fe,j.fillRect(0,0,ie,ge);const Se=j.createLinearGradient(0,W-ge,0,W);Se.addColorStop(0,"transparent"),Se.addColorStop(1,de),j.fillStyle=Se,j.fillRect(0,W-ge,ie,ge);const Be=j.createLinearGradient(0,0,ge,0);Be.addColorStop(0,de),Be.addColorStop(1,"transparent"),j.fillStyle=Be,j.fillRect(0,0,ge,W);const he=j.createLinearGradient(ie-ge,0,ie,0);he.addColorStop(0,"transparent"),he.addColorStop(1,de),j.fillStyle=he,j.fillRect(ie-ge,0,ge,W),j.strokeStyle="#5a6b62",j.lineWidth=1,j.beginPath(),j.moveTo(0,W/2),j.lineTo(ie,W/2),j.stroke();const me=ie/2;j.strokeStyle="#ef4444",j.lineWidth=1,j.beginPath(),j.moveTo(me,0),j.lineTo(me,W),j.stroke(),j.fillStyle="#fff",j.font="bold 18px monospace",j.textAlign="center",j.fillText("00:00",me,W-6)}},[a]);const je=_.useCallback(Y=>{T(j=>[...j,Y]),L(j=>({...j,total:j.total+1}))},[]);if(_.useEffect(()=>{(async()=>{if(E.current||F.length===0||!t)return;E.current=!0;const j=F[0];try{const ne=await t(j);ne&&n&&n(ne)}catch(ne){console.error("Transcription failed:",ne)}finally{T(ne=>ne.slice(1)),L(ne=>({...ne,completed:ne.completed+1})),E.current=!1}})()},[F,t,n]),_.useEffect(()=>()=>{le.current=!1,K.current&&clearInterval(K.current),$.current&&cancelAnimationFrame($.current),H.current&&H.current.getTracks().forEach(Y=>Y.stop()),U.current&&U.current.state!=="closed"&&U.current.close()},[]),_.useEffect(()=>{if(a==="editing"&&g){let Y;const j=()=>{const ne=re.current;if(ne&&g){const ie=R.current;if(ie){const W=ie.getContext("2d");if(W){const ge=ie.getBoundingClientRect(),de=ge.width,fe=ge.height,Se=ce.current,Be=f||c||1,he=ne.currentTime;W.fillStyle="#2d3b35",W.fillRect(0,0,de,fe);const me=8,We="rgba(0, 0, 0, 0.4)",Ge=W.createLinearGradient(0,0,0,me);Ge.addColorStop(0,We),Ge.addColorStop(1,"transparent"),W.fillStyle=Ge,W.fillRect(0,0,de,me);const Le=W.createLinearGradient(0,fe-me,0,fe);Le.addColorStop(0,"transparent"),Le.addColorStop(1,We),W.fillStyle=Le,W.fillRect(0,fe-me,de,me);const De=W.createLinearGradient(0,0,me,0);De.addColorStop(0,We),De.addColorStop(1,"transparent"),W.fillStyle=De,W.fillRect(0,0,me,fe);const rt=W.createLinearGradient(de-me,0,de,0);rt.addColorStop(0,"transparent"),rt.addColorStop(1,We),W.fillStyle=rt,W.fillRect(de-me,0,me,fe),W.strokeStyle="#5a6b62",W.lineWidth=1,W.beginPath(),W.moveTo(0,fe/2),W.lineTo(de,fe/2),W.stroke();const nt=de/2,wt=3,Zt=4,At=Be>0?he/Be*Se.length:0;for(let Q=0;Q<Se.length;Q++){const oe=At-Q,we=nt-oe*Zt;if(we<-wt||we>de)continue;const ke=Se[Q]*(fe/2-12),xe=fe/2-ke;W.fillStyle=Q<=At?"#10b981":"#4b5563",W.fillRect(we,xe,wt,ke*2)}W.strokeStyle="#ef4444",W.lineWidth=1,W.beginPath(),W.moveTo(nt,0),W.lineTo(nt,fe),W.stroke(),W.fillStyle="#fff",W.font="bold 18px monospace",W.textAlign="center";const A=Math.floor(he/60),I=Math.floor(he%60);W.fillText(`${A.toString().padStart(2,"0")}:${I.toString().padStart(2,"0")}`,nt,fe-6),W.textAlign="left"}}Y=requestAnimationFrame(j)}};return Y=requestAnimationFrame(j),()=>cancelAnimationFrame(Y)}},[a,g,f,c]),_.useEffect(()=>{a==="editing"&&!g&&it()},[a,x,g,it]),b)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:b}),h.jsx("button",{onClick:()=>{C(null),X()},style:{padding:"8px 16px",fontSize:"14px",background:"#171717",color:"white",borderRadius:"8px",border:"none",cursor:"pointer"},children:"Try Again"})]});const $e={padding:"8px",borderRadius:"8px",border:"none",background:"transparent",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",transition:"background 0.15s"},qe={...$e,opacity:.3,cursor:"not-allowed"},Dt=l?{border:"1px solid #e5e5e5",borderRadius:"12px",overflow:"hidden",background:"white"}:{overflow:"hidden",background:"white",flexShrink:0};return h.jsxs("div",{style:Dt,children:[h.jsx("canvas",{ref:R,style:{width:"100%",height:"32px",cursor:"pointer",flexShrink:0},onMouseDown:Y=>{if(a==="editing"){kt.current=!0,xt.current=Y.clientX,dt.current=x;const j=ie=>{kt.current&&Me(ie.clientX)},ne=()=>{kt.current=!1,window.removeEventListener("mousemove",j),window.removeEventListener("mouseup",ne)};window.addEventListener("mousemove",j),window.addEventListener("mouseup",ne)}}}),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:Re,disabled:a==="idle"||a==="recording",style:a==="idle"||a==="recording"?qe:$e,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 Y=O.current;Y&&(Y.state==="recording"?(Y.pause(),D(!0)):Y.state==="paused"&&(Y.resume(),D(!1)))}else $t()},disabled:a==="idle",style:a==="idle"?qe:$e,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:zt,disabled:a==="idle"||a==="recording",style:a==="idle"||a==="recording"?qe:$e,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:()=>{w==="insert"?Ne():a==="idle"?(y("insert"),X()):a==="editing"&&(y("insert"),Jt("insert"))},disabled:a==="recording"&&w!=="insert"||g,style:a==="recording"&&w!=="insert"||g?qe:$e,title:w==="insert"?"Stop recording":"Insert recording",children:h.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:w==="insert"?"#ef4444":"#171717"},children:"add"})}),h.jsx("button",{onClick:()=>{B.current||(w==="mic"?Ne():a==="idle"?(y("mic"),X()):a==="editing"&&(y("mic"),Jt("replace")))},onMouseDown:()=>{B.current&&a==="idle"&&!g&&(y("mic"),X())},onMouseUp:()=>{B.current&&a==="recording"&&w==="mic"&&Ne()},onMouseLeave:()=>{B.current&&a==="recording"&&w==="mic"&&Ne()},onTouchStart:()=>{B.current&&a==="idle"&&!g&&(y("mic"),X())},onTouchEnd:()=>{B.current&&a==="recording"&&w==="mic"&&Ne()},disabled:a==="recording"&&w!=="mic"||g,style:a==="recording"&&w!=="mic"||g?qe:$e,title:k?"Hold to record (walkie-talkie)":w==="mic"?"Stop recording":"Record",children:h.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:w==="mic"?"#ef4444":"#171717"},children:"mic"})}),h.jsx("button",{onClick:()=>{w==="startover"?Ne():a==="editing"&&(y("startover"),ee())},disabled:a==="idle"||a==="recording"&&w!=="startover"||g,style:a==="idle"||a==="recording"&&w!=="startover"||g?qe:$e,title:w==="startover"?"Stop recording":"Start over",children:h.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:w==="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:()=>N(!k),style:{width:"28px",height:"16px",borderRadius:"8px",border:"none",background:k?"#10b981":"#9ca3af",cursor:"pointer",position:"relative",transition:"background 0.2s",padding:0},title:k?"Auto-transcribe ON":"Auto-transcribe OFF",children:h.jsx("div",{style:{width:"12px",height:"12px",borderRadius:"50%",background:"white",position:"absolute",top:"2px",left:k?"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"&&ae.current&&je(ae.current)},disabled:a!=="editing",style:a!=="editing"?qe:$e,title:"Transcribe audio",children:h.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:k?"#10b981":"#171717"},children:"subtitles"})})]}),!i&&h.jsx("button",{onClick:se,disabled:a!=="editing",style:a!=="editing"?qe:$e,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 Lg({label:r,value:e,onChange:t,onTranscribe:n,onAIAction:s,placeholder:i="Type or record...",className:o="",rows:l}){const[a,u]=_.useState(!1),[c,d]=_.useState(null),[f,p]=_.useState(!1),g=_.useRef(null),m=b=>{t(e?`${e}
183
+ `})]})}const kg={background:"#ffffff",text:"#111827",textSecondary:"#6b7280",border:"#e5e7eb",primary:"#3b82f6",chipBackground:"#f3f4f6",chipText:"#374151",hoverBackground:"#f9fafb"};function Dg({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={...kg,...d},[g,m]=_.useState(!1),[x,v]=_.useState(""),b=_.useRef(null),C=_.useRef(null);_.useEffect(()=>{function T(M){b.current&&!b.current.contains(M.target)&&(m(!1),v(""))}return document.addEventListener("mousedown",T),()=>document.removeEventListener("mousedown",T)},[]);const S=r.filter(T=>{var M;return((M=T.label)==null?void 0:M.toLowerCase().includes(x.toLowerCase()))&&!e.includes(T.id)}),D=s&&x.trim()&&!r.some(T=>{var M;return((M=T.label)==null?void 0:M.toLowerCase())===x.toLowerCase()}),w=e.map(T=>r.find(M=>M.id===T)).filter(Boolean),y=_.useCallback(T=>{var M;c>0&&e.length>=c||(t([...e,T]),v(""),c===1?m(!1):(M=C.current)==null||M.focus())},[e,t,c]),k=_.useCallback(T=>{t(e.filter(M=>M!==T))},[e,t]),N=_.useCallback(async()=>{if(!D)return;const T=await(i==null?void 0:i(x.trim()));T&&y(T.id),v("")},[D,x,i,y]),F=_.useCallback(T=>{T.key==="Enter"?(T.preventDefault(),D?N():S.length>0&&y(S[0].id)):T.key==="Backspace"&&!x&&e.length>0?k(e[e.length-1]):T.key==="Escape"&&(m(!1),v(""))},[D,S,x,e,N,y,k]);return h.jsxs("div",{ref:b,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:[w.map(T=>h.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"2px 8px",borderRadius:"4px",fontSize:"13px",background:T.color||p.chipBackground,color:T.color?"#fff":p.chipText},children:[T.label,!u&&h.jsx("button",{type:"button",onClick:M=>{M.stopPropagation(),k(T.id)},style:{border:"none",background:"transparent",cursor:"pointer",padding:"0 2px",fontSize:"14px",color:"inherit",opacity:.7},children:"×"})]},T.id)),h.jsx("input",{ref:C,type:"text",value:x,onChange:T=>{v(T.target.value),g||m(!0)},onFocus:()=>m(!0),onKeyDown:F,placeholder:w.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(T=>h.jsxs("div",{onClick:()=>y(T.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:[T.label,o&&l&&h.jsx("button",{type:"button",onClick:M=>{M.stopPropagation(),l(T.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:"×"})]},T.id)),D&&h.jsxs("div",{onClick:N,style:{padding:"10px 12px",fontSize:"14px",cursor:"pointer",color:p.primary,borderTop:S.length>0?`1px solid ${p.border}`:"none"},onMouseEnter:T=>{T.currentTarget.style.background=p.hoverBackground||""},onMouseLeave:T=>{T.currentTarget.style.background=""},children:['+ Create "',x.trim(),'"']})]})})]})}const Ag={background:"#ffffff",cardBackground:"#f9fafb",cardHover:"#f3f4f6",text:"#111827",textSecondary:"#6b7280",border:"#e5e7eb",primary:"#3b82f6"};function Tg({options:r,value:e,type:t,placeholder:n="Search...",onItemClick:s,onClear:i,onCreate:o,maxHeight:l=300,className:a="",theme:u={}}){const c={...Ag,...u},[d,f]=_.useState(""),[p,g]=_.useState(!1),m=_.useRef(null),x=_.useRef(null),v=_.useMemo(()=>e&&r.find(y=>y.id===e)||null,[e,r]),b=_.useMemo(()=>{if(!d.trim())return r;const y=d.toLowerCase();return r.filter(k=>{var N,F;return((N=k.label)==null?void 0:N.toLowerCase().includes(y))||((F=k.notes)==null?void 0:F.toLowerCase().includes(y))})},[r,d]);_.useEffect(()=>{const y=k=>{m.current&&!m.current.contains(k.target)&&g(!1)};return document.addEventListener("mousedown",y),()=>document.removeEventListener("mousedown",y)},[]);const C=y=>{s&&s(y),g(!1),f("")},S=()=>{o&&o(d.trim()||void 0),g(!1),f("")},D=()=>{g(!0)},w=y=>{f(y.target.value),p||g(!0)};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:v&&!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:v.label}),v.notes&&h.jsx("div",{style:{fontSize:"11px",color:c.textSecondary,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:v.notes})]}),i&&h.jsx("button",{onClick:y=>{y.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:w,onFocus:D,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:y=>{y.currentTarget.style.background=c.cardHover||"#f3f4f6"},onMouseLeave:y=>{y.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:b.length===0?h.jsx("div",{style:{padding:"16px",textAlign:"center",color:c.textSecondary,fontSize:"14px"},children:d?`No results for "${d}"`:"No items"}):b.map((y,k)=>h.jsxs("div",{onClick:()=>C(y),style:{padding:"10px 14px",cursor:"pointer",borderBottom:k<b.length-1?`1px solid ${c.border}`:"none",background:c.cardBackground,transition:"background 0.15s"},onMouseEnter:N=>{N.currentTarget.style.background=c.cardHover||"#f3f4f6"},onMouseLeave:N=>{N.currentTarget.style.background=c.cardBackground||"#f9fafb"},children:[h.jsx("div",{style:{fontSize:"14px",fontWeight:500,color:y.color||c.text,marginBottom:y.notes?"2px":0},children:y.label}),y.notes&&h.jsx("div",{style:{fontSize:"12px",color:c.textSecondary,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:y.notes})]},y.id))})]})}function Ng({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]=_.useState(null),[x,v]=_.useState(null),[b,C]=_.useState(null),S=_.useRef(null),D=e.reduce((M,L)=>{let E=r.filter(B=>n(B)===L.id);return s&&(E=E.sort((B,R)=>s(B)-s(R))),M[L.id]=E,M},{}),w=_.useCallback((M,L)=>{const E=t(L),B=n(L);m(E),S.current=B,M.dataTransfer.effectAllowed="move",M.dataTransfer.setData("text/plain",E),requestAnimationFrame(()=>{const R=M.target;R.style.opacity="0.5"})},[t,n]),y=_.useCallback(M=>{const L=M.target;L.style.opacity="1",m(null),v(null),C(null),S.current=null},[]),k=_.useCallback((M,L,E)=>{M.preventDefault(),M.dataTransfer.dropEffect="move",v(L),C(E)},[]),N=_.useCallback(M=>{const L=M.relatedTarget;L!=null&&L.closest("[data-kanban-column]")||(v(null),C(null))},[]),F=_.useCallback((M,L,E)=>{if(M.preventDefault(),!g)return;const B=S.current;B===L?l==null||l(g,L,E):B&&o(g,B,L,E),m(null),v(null),C(null),S.current=null},[g,o,l]),T=(M,L)=>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:L})]});return h.jsx("div",{className:`flex gap-4 overflow-x-auto pb-4 ${d}`,style:{minHeight:"400px"},children:e.map(M=>{const L=D[M.id]||[],E=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&&!E&&v(M.id)},onDragLeave:N,onDrop:B=>F(B,M.id,b??L.length),children:[h.jsx("div",{className:"flex-shrink-0 border-b border-neutral-200",children:u?u(M,L.length):T(M,L.length)}),h.jsxs("div",{className:`flex-1 overflow-y-auto p-2 space-y-2 min-h-[100px] transition-colors ${E?"bg-blue-50":""}`,children:[L.map((B,R)=>{const O=t(B),H=g===O,U=E&&b===R&&!H;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:Z=>w(Z,B),onDragEnd:y,onDragOver:Z=>k(Z,M.id,R),onClick:()=>a==null?void 0:a(B),className:`cursor-grab active:cursor-grabbing transition-all ${H?"opacity-50 scale-95":""} ${p}`,children:i(B,H)})]},O)}),h.jsx("div",{className:"min-h-[40px] flex-1",onDragOver:B=>{B.preventDefault(),k(B,M.id,L.length)},children:E&&b===L.length&&h.jsx("div",{className:"h-1 bg-blue-500 rounded-full mx-1 mt-1"})}),L.length===0&&E&&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 Bg={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 Rg(r){const e=r%12||12,t=r<12?"AM":"PM";return`${e} ${t}`}function Mg(r){const e=new Date;return r.getDate()===e.getDate()&&r.getMonth()===e.getMonth()&&r.getFullYear()===e.getFullYear()}function jg({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={...Bg,...g},{allDayItems:x,timedItems:v}=_.useMemo(()=>{const y=[],k=[];for(const N of r)l(N)?y.push(N):k.push(N);return{allDayItems:y,timedItems:k}},[r,l]),b=_.useMemo(()=>{const y=[];for(let k=t;k<=n;k++)y.push(k);return y},[t,n]),C=(n-t+1)*s,S=_.useCallback(y=>{const k=i(y);if(!k)return null;const N=Fg(k);if(!N)return null;const{hours:F,minutes:T}=N,M=Math.max(t,Math.min(n,F)),L=F<t?0:T,E=(M-t)*s+L/60*s,B=o(y),R=Math.max(20,B/60*s);return{top:E,height:R}},[i,o,t,n,s]),D=_.useMemo(()=>{if(!f||!Mg(e))return null;const y=new Date,k=y.getHours(),N=y.getMinutes();return k<t||k>n?null:(k-t)*s+N/60*s},[e,f,t,n,s]),w=_.useCallback(y=>{if(!d)return;const k=y.currentTarget.getBoundingClientRect(),F=(y.clientY-k.top)/s*60,T=Math.floor(F/60)+t,M=Math.round(F%60/15)*15,L=Math.min(n,Math.max(t,T)),E=M>=60?0:M,B=`${L.toString().padStart(2,"0")}:${E.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(y=>h.jsx("div",{onClick:()=>c==null?void 0:c(y),style:{cursor:c?"pointer":"default"},children:u(y)},a(y)))})]}),h.jsxs("div",{style:{position:"relative",height:C},children:[b.map((y,k)=>h.jsxs("div",{style:{position:"absolute",top:k*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:Rg(y)}),h.jsx("div",{style:{position:"absolute",left:"60px",right:0,top:0,height:"1px",background:m.hourLineColor}}),k<b.length-1&&h.jsx("div",{style:{position:"absolute",left:"60px",right:0,top:s/2,height:"1px",background:m.halfHourLineColor}})]},y)),h.jsx("div",{style:{position:"absolute",left:"60px",right:0,top:0,bottom:0,cursor:d?"pointer":"default"},onClick:w}),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}})]}),v.map(y=>{const k=S(y);return k?h.jsx("div",{style:{position:"absolute",left:"64px",right:"8px",top:k.top,height:k.height,zIndex:10,cursor:c?"pointer":"default"},onClick:N=>{N.stopPropagation(),c==null||c(y)},children:u(y)},a(y)):null})]})]})}function Hc({onComplete:r,onCancel:e,onTranscribe:t,onTranscriptionComplete:n,variant:s="widget",hideSaveButton:i=!1,maxDuration:o=180}){const l=s==="widget",[a,u]=_.useState("idle"),[c,d]=_.useState(0),[f,p]=_.useState(0),[g,m]=_.useState(!1),[x,v]=_.useState(0),[b,C]=_.useState(null),[S,D]=_.useState(!1),[w,y]=_.useState(null),[k,N]=_.useState(!0),[F,T]=_.useState([]),[M,L]=_.useState({completed:0,total:0}),E=_.useRef(!1),B=_.useRef(!0);_.useEffect(()=>{B.current=k},[k]);const R=_.useRef(null),O=_.useRef(null),H=_.useRef(null),U=_.useRef(null),Z=_.useRef(null),q=_.useRef([]),K=_.useRef(null),$=_.useRef(null),re=_.useRef(null),ae=_.useRef(null),le=_.useRef(!1),ce=_.useRef([]),ve=_.useRef(null),pe=_.useRef(null),Fe=_.useRef([]),et=_.useRef([]),ct=_.useRef("insert"),kt=_.useRef(!1),tt=_.useRef(0),xt=_.useRef(0),dt=_.useRef(0),It=Y=>{const j=Math.floor(Y/60),ne=Math.floor(Y%60);return`${j.toString().padStart(2,"0")}:${ne.toString().padStart(2,"0")}`},ue=async Y=>{const j=await Y.arrayBuffer(),ne=new AudioContext,ie=await ne.decodeAudioData(j);return await ne.close(),ie},_e=Y=>{const j=Y.numberOfChannels,ne=Y.sampleRate,ie=1,W=16,ge=W/8,de=j*ge,fe=ne*de,Se=Y.length*de,Be=new ArrayBuffer(44+Se),he=new DataView(Be),me=(Le,De)=>{for(let rt=0;rt<De.length;rt++)he.setUint8(Le+rt,De.charCodeAt(rt))};me(0,"RIFF"),he.setUint32(4,36+Se,!0),me(8,"WAVE"),me(12,"fmt "),he.setUint32(16,16,!0),he.setUint16(20,ie,!0),he.setUint16(22,j,!0),he.setUint32(24,ne,!0),he.setUint32(28,fe,!0),he.setUint16(32,de,!0),he.setUint16(34,W,!0),me(36,"data"),he.setUint32(40,Se,!0);const We=[];for(let Le=0;Le<j;Le++)We.push(Y.getChannelData(Le));let Ge=44;for(let Le=0;Le<Y.length;Le++)for(let De=0;De<j;De++){const rt=Math.max(-1,Math.min(1,We[De][Le])),nt=rt<0?rt*32768:rt*32767;he.setInt16(Ge,nt,!0),Ge+=2}return new Blob([Be],{type:"audio/wav"})},Te=async(Y,j,ne,ie)=>{const W=new AudioContext,ge=Y.sampleRate,de=Math.max(Y.numberOfChannels,j.numberOfChannels),fe=Math.min(ne,Y.length),Se=Math.max(0,Y.length-ne),Be=ie==="insert"?fe+j.length+Se:fe+j.length,he=W.createBuffer(de,Be,ge);for(let me=0;me<de;me++){const We=he.getChannelData(me),Ge=me<Y.numberOfChannels?Y.getChannelData(me):Y.getChannelData(0);for(let De=0;De<fe;De++)We[De]=Ge[De];const Le=me<j.numberOfChannels?j.getChannelData(me):j.getChannelData(0);for(let De=0;De<j.length;De++)We[fe+De]=Le[De];if(ie==="insert")for(let De=0;De<Se;De++)We[fe+j.length+De]=Ge[ne+De]}return await W.close(),he},it=_.useCallback(()=>{const Y=R.current;if(!Y)return;const j=Y.getContext("2d");if(!j)return;const ne=Y.getBoundingClientRect(),ie=ne.width,W=ne.height,ge=ce.current,de=f||c||1,fe=a==="recording"?c:x;j.fillStyle="#2d3b35",j.fillRect(0,0,ie,W);const Se=8,Be="rgba(0, 0, 0, 0.4)",he=j.createLinearGradient(0,0,0,Se);he.addColorStop(0,Be),he.addColorStop(1,"transparent"),j.fillStyle=he,j.fillRect(0,0,ie,Se);const me=j.createLinearGradient(0,W-Se,0,W);me.addColorStop(0,"transparent"),me.addColorStop(1,Be),j.fillStyle=me,j.fillRect(0,W-Se,ie,Se);const We=j.createLinearGradient(0,0,Se,0);We.addColorStop(0,Be),We.addColorStop(1,"transparent"),j.fillStyle=We,j.fillRect(0,0,Se,W);const Ge=j.createLinearGradient(ie-Se,0,ie,0);Ge.addColorStop(0,"transparent"),Ge.addColorStop(1,Be),j.fillStyle=Ge,j.fillRect(ie-Se,0,Se,W),j.strokeStyle="#5a6b62",j.lineWidth=1,j.beginPath(),j.moveTo(0,W/2),j.lineTo(ie,W/2),j.stroke();const Le=ie/2;if(ge.length>0)if(a==="recording")for(let nt=0;nt<ge.length;nt++){const wt=ge.length-1-nt,Zt=Le-wt*4;if(Zt<-3||Zt>ie)continue;const At=ge[nt]*(W/2-12),A=W/2-At;j.fillStyle="#10b981",j.fillRect(Zt,A,3,At*2)}else{const nt=de>0?fe/de*ge.length:0;for(let wt=0;wt<ge.length;wt++){const Zt=nt-wt,At=Le-Zt*4;if(At<-3||At>ie)continue;const A=ge[wt]*(W/2-12),I=W/2-A;j.fillStyle=wt<=nt?"#10b981":"#4b5563",j.fillRect(At,I,3,A*2)}}j.strokeStyle="#ef4444",j.lineWidth=1,j.beginPath(),j.moveTo(Le,0),j.lineTo(Le,W),j.stroke(),j.fillStyle="#fff",j.font="bold 18px monospace",j.textAlign="center",j.fillText(It(fe),Le,W-6),a==="recording"&&(j.fillStyle="#ef4444",j.beginPath(),j.arc(20,20,8,0,Math.PI*2),j.fill(),j.fillStyle="#fff",j.font="10px sans-serif",j.textAlign="left",j.fillText("REC",34,24)),j.textAlign="left"},[a,x,c,f]),Je=()=>{const Y=Z.current;if(!Y||!le.current)return;const j=Y.frequencyBinCount,ne=new Uint8Array(j);Y.getByteTimeDomainData(ne);let ie=0;for(let de=0;de<j;de++){const fe=(ne[de]-128)/128;ie+=fe*fe}const W=Math.sqrt(ie/j),ge=Math.min(1,W*3);ce.current.push(ge),it(),le.current&&($.current=requestAnimationFrame(Je))},X=async()=>{try{C(null),D(!1),ve.current===null&&(ce.current=[]);const Y=await navigator.mediaDevices.getUserMedia({audio:!0});H.current=Y;const j=new AudioContext;U.current=j;const ne=j.createAnalyser();ne.fftSize=2048,Z.current=ne,j.createMediaStreamSource(Y).connect(ne);const W=new MediaRecorder(Y);O.current=W,q.current=[],W.ondataavailable=ge=>{ge.data.size>0&&q.current.push(ge.data)},W.onstop=async()=>{try{if(le.current=!1,q.current.length===0){C("No audio was recorded. Please try again."),u("idle"),Y.getTracks().forEach(he=>he.stop());return}const ge=new Blob(q.current,{type:"audio/webm"});let de,fe;if(ve.current!==null&&pe.current)try{const he=await ue(ge),me=pe.current.sampleRate,We=Math.floor(ve.current*me),Ge=await Te(pe.current,he,We,ct.current);de=_e(Ge),fe=Ge.length/Ge.sampleRate,ct.current==="insert"&&(ce.current=[...ce.current,...et.current]),ve.current=null,pe.current=null,Fe.current=[],et.current=[]}catch{de=ge,fe=tt.current>0?tt.current:1}else de=ge,fe=tt.current>0?tt.current:1;if(ae.current=de,Y.getTracks().forEach(he=>he.stop()),B.current&&t){T(he=>[...he,de]),L(he=>({...he,total:he.total+1})),ae.current=null,ce.current=[],v(0),p(0),d(0),u("idle");return}const Se=URL.createObjectURL(de),Be=new Audio(Se);Be.ontimeupdate=()=>{v(Be.currentTime)},Be.onended=()=>{m(!1)},re.current=Be,p(fe),v(fe),u("editing")}catch{C("Failed to process recording"),u("idle")}},W.start(100),le.current=!0,u("recording"),d(0),tt.current=0,K.current=setInterval(()=>{tt.current+=1,d(tt.current),tt.current>=o&&(O.current&&O.current.state!=="inactive"&&O.current.stop(),le.current=!1,y(null),K.current&&(clearInterval(K.current),K.current=null),$.current&&(cancelAnimationFrame($.current),$.current=null),setTimeout(()=>{alert(`Maximum recording time of ${Math.floor(o/60)} minutes reached.`)},100))},1e3)}catch{C("Could not access microphone. Please allow microphone access.")}},Ne=()=>{le.current=!1,D(!1),y(null),$.current&&(cancelAnimationFrame($.current),$.current=null),K.current&&(clearInterval(K.current),K.current=null),O.current&&O.current.state!=="inactive"&&O.current.stop()},Me=Y=>{const j=R.current;if(!j)return;const ne=f||c;if(ne<=0)return;const ie=ce.current;if(ie.length===0)return;const W=j.getBoundingClientRect(),ge=Y-xt.current,de=4,fe=W.width/j.width,Se=ie.length/ne*de,Be=-ge/(Se*fe),he=dt.current+Be,me=Math.max(0,Math.min(he,ne));re.current&&(re.current.currentTime=me),v(me)},Re=()=>{re.current&&(re.current.currentTime=0),v(0)},zt=()=>{const Y=f||c;re.current&&(re.current.currentTime=Y),v(Y)},$t=()=>{const Y=re.current;Y&&(g?(Y.pause(),v(Y.currentTime),m(!1)):(Y.currentTime=x,Y.play().catch(()=>{}),m(!0)))},Jt=async Y=>{if(!ae.current){X();return}try{re.current&&(re.current.pause(),m(!1)),ct.current=Y,pe.current=await ue(ae.current);const j=f||c;ve.current=x;const ne=j>0?x/j:0,ie=Math.floor(ne*ce.current.length);Fe.current=ce.current.slice(0,ie),et.current=ce.current.slice(ie),ce.current=[...Fe.current],X()}catch{C("Failed to prepare recording. Please try again.")}},ee=()=>{re.current&&(re.current.pause(),re.current=null),ae.current=null,pe.current=null,ve.current=null,Fe.current=[],m(!1),v(0),p(0),d(0),X()},se=()=>{ae.current?r(ae.current,f||c):alert("No audio recorded yet!")};_.useEffect(()=>{a==="recording"&&R.current&&Z.current&&le.current&&($.current=requestAnimationFrame(Je))},[a]),_.useEffect(()=>{const Y=R.current;if(!Y)return;const j=()=>{const ne=window.devicePixelRatio||1,ie=Y.getBoundingClientRect();Y.width=ie.width*ne,Y.height=ie.height*ne;const W=Y.getContext("2d");W&&W.scale(ne,ne)};return j(),window.addEventListener("resize",j),()=>window.removeEventListener("resize",j)},[]),_.useEffect(()=>{if(a==="idle"){const Y=R.current;if(!Y)return;const j=Y.getContext("2d");if(!j)return;const ne=Y.getBoundingClientRect(),ie=ne.width,W=ne.height;j.fillStyle="#2d3b35",j.fillRect(0,0,ie,W);const ge=8,de="rgba(0, 0, 0, 0.4)",fe=j.createLinearGradient(0,0,0,ge);fe.addColorStop(0,de),fe.addColorStop(1,"transparent"),j.fillStyle=fe,j.fillRect(0,0,ie,ge);const Se=j.createLinearGradient(0,W-ge,0,W);Se.addColorStop(0,"transparent"),Se.addColorStop(1,de),j.fillStyle=Se,j.fillRect(0,W-ge,ie,ge);const Be=j.createLinearGradient(0,0,ge,0);Be.addColorStop(0,de),Be.addColorStop(1,"transparent"),j.fillStyle=Be,j.fillRect(0,0,ge,W);const he=j.createLinearGradient(ie-ge,0,ie,0);he.addColorStop(0,"transparent"),he.addColorStop(1,de),j.fillStyle=he,j.fillRect(ie-ge,0,ge,W),j.strokeStyle="#5a6b62",j.lineWidth=1,j.beginPath(),j.moveTo(0,W/2),j.lineTo(ie,W/2),j.stroke();const me=ie/2;j.strokeStyle="#ef4444",j.lineWidth=1,j.beginPath(),j.moveTo(me,0),j.lineTo(me,W),j.stroke(),j.fillStyle="#fff",j.font="bold 18px monospace",j.textAlign="center",j.fillText("00:00",me,W-6)}},[a]);const je=_.useCallback(Y=>{T(j=>[...j,Y]),L(j=>({...j,total:j.total+1}))},[]);if(_.useEffect(()=>{(async()=>{if(E.current||F.length===0||!t)return;E.current=!0;const j=F[0];try{const ne=await t(j);ne&&n&&n(ne)}catch(ne){console.error("Transcription failed:",ne)}finally{T(ne=>ne.slice(1)),L(ne=>({...ne,completed:ne.completed+1})),E.current=!1}})()},[F,t,n]),_.useEffect(()=>()=>{le.current=!1,K.current&&clearInterval(K.current),$.current&&cancelAnimationFrame($.current),H.current&&H.current.getTracks().forEach(Y=>Y.stop()),U.current&&U.current.state!=="closed"&&U.current.close()},[]),_.useEffect(()=>{if(a==="editing"&&g){let Y;const j=()=>{const ne=re.current;if(ne&&g){const ie=R.current;if(ie){const W=ie.getContext("2d");if(W){const ge=ie.getBoundingClientRect(),de=ge.width,fe=ge.height,Se=ce.current,Be=f||c||1,he=ne.currentTime;W.fillStyle="#2d3b35",W.fillRect(0,0,de,fe);const me=8,We="rgba(0, 0, 0, 0.4)",Ge=W.createLinearGradient(0,0,0,me);Ge.addColorStop(0,We),Ge.addColorStop(1,"transparent"),W.fillStyle=Ge,W.fillRect(0,0,de,me);const Le=W.createLinearGradient(0,fe-me,0,fe);Le.addColorStop(0,"transparent"),Le.addColorStop(1,We),W.fillStyle=Le,W.fillRect(0,fe-me,de,me);const De=W.createLinearGradient(0,0,me,0);De.addColorStop(0,We),De.addColorStop(1,"transparent"),W.fillStyle=De,W.fillRect(0,0,me,fe);const rt=W.createLinearGradient(de-me,0,de,0);rt.addColorStop(0,"transparent"),rt.addColorStop(1,We),W.fillStyle=rt,W.fillRect(de-me,0,me,fe),W.strokeStyle="#5a6b62",W.lineWidth=1,W.beginPath(),W.moveTo(0,fe/2),W.lineTo(de,fe/2),W.stroke();const nt=de/2,wt=3,Zt=4,At=Be>0?he/Be*Se.length:0;for(let Q=0;Q<Se.length;Q++){const oe=At-Q,we=nt-oe*Zt;if(we<-wt||we>de)continue;const ke=Se[Q]*(fe/2-12),xe=fe/2-ke;W.fillStyle=Q<=At?"#10b981":"#4b5563",W.fillRect(we,xe,wt,ke*2)}W.strokeStyle="#ef4444",W.lineWidth=1,W.beginPath(),W.moveTo(nt,0),W.lineTo(nt,fe),W.stroke(),W.fillStyle="#fff",W.font="bold 18px monospace",W.textAlign="center";const A=Math.floor(he/60),I=Math.floor(he%60);W.fillText(`${A.toString().padStart(2,"0")}:${I.toString().padStart(2,"0")}`,nt,fe-6),W.textAlign="left"}}Y=requestAnimationFrame(j)}};return Y=requestAnimationFrame(j),()=>cancelAnimationFrame(Y)}},[a,g,f,c]),_.useEffect(()=>{a==="editing"&&!g&&it()},[a,x,g,it]),b)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:b}),h.jsx("button",{onClick:()=>{C(null),X()},style:{padding:"8px 16px",fontSize:"14px",background:"#171717",color:"white",borderRadius:"8px",border:"none",cursor:"pointer"},children:"Try Again"})]});const $e={padding:"8px",borderRadius:"8px",border:"none",background:"transparent",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",transition:"background 0.15s"},qe={...$e,opacity:.3,cursor:"not-allowed"},Dt=l?{border:"1px solid #e5e5e5",borderRadius:"12px",overflow:"hidden",background:"white"}:{overflow:"hidden",background:"white",flexShrink:0};return h.jsxs("div",{style:Dt,children:[h.jsx("canvas",{ref:R,style:{width:"100%",height:"32px",cursor:"pointer",flexShrink:0},onMouseDown:Y=>{if(a==="editing"){kt.current=!0,xt.current=Y.clientX,dt.current=x;const j=ie=>{kt.current&&Me(ie.clientX)},ne=()=>{kt.current=!1,window.removeEventListener("mousemove",j),window.removeEventListener("mouseup",ne)};window.addEventListener("mousemove",j),window.addEventListener("mouseup",ne)}}}),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:Re,disabled:a==="idle"||a==="recording",style:a==="idle"||a==="recording"?qe:$e,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 Y=O.current;Y&&(Y.state==="recording"?(Y.pause(),D(!0)):Y.state==="paused"&&(Y.resume(),D(!1)))}else $t()},disabled:a==="idle",style:a==="idle"?qe:$e,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:zt,disabled:a==="idle"||a==="recording",style:a==="idle"||a==="recording"?qe:$e,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:()=>{w==="insert"?Ne():a==="idle"?(y("insert"),X()):a==="editing"&&(y("insert"),Jt("insert"))},disabled:a==="recording"&&w!=="insert"||g,style:a==="recording"&&w!=="insert"||g?qe:$e,title:w==="insert"?"Stop recording":"Insert recording",children:h.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:w==="insert"?"#ef4444":"#171717"},children:"add"})}),h.jsx("button",{onClick:()=>{B.current||(w==="mic"?Ne():a==="idle"?(y("mic"),X()):a==="editing"&&(y("mic"),Jt("replace")))},onMouseDown:()=>{B.current&&a==="idle"&&!g&&(y("mic"),X())},onMouseUp:()=>{B.current&&a==="recording"&&w==="mic"&&Ne()},onMouseLeave:()=>{B.current&&a==="recording"&&w==="mic"&&Ne()},onTouchStart:()=>{B.current&&a==="idle"&&!g&&(y("mic"),X())},onTouchEnd:()=>{B.current&&a==="recording"&&w==="mic"&&Ne()},disabled:a==="recording"&&w!=="mic"||g,style:a==="recording"&&w!=="mic"||g?qe:$e,title:k?"Hold to record (walkie-talkie)":w==="mic"?"Stop recording":"Record",children:h.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:w==="mic"?"#ef4444":"#171717"},children:"mic"})}),h.jsx("button",{onClick:()=>{w==="startover"?Ne():a==="editing"&&(y("startover"),ee())},disabled:a==="idle"||a==="recording"&&w!=="startover"||g,style:a==="idle"||a==="recording"&&w!=="startover"||g?qe:$e,title:w==="startover"?"Stop recording":"Start over",children:h.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:w==="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:()=>N(!k),style:{width:"28px",height:"16px",borderRadius:"8px",border:"none",background:k?"#10b981":"#9ca3af",cursor:"pointer",position:"relative",transition:"background 0.2s",padding:0},title:k?"Auto-transcribe ON":"Auto-transcribe OFF",children:h.jsx("div",{style:{width:"12px",height:"12px",borderRadius:"50%",background:"white",position:"absolute",top:"2px",left:k?"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"&&ae.current&&je(ae.current)},disabled:a!=="editing",style:a!=="editing"?qe:$e,title:"Transcribe audio",children:h.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:k?"#10b981":"#171717"},children:"subtitles"})})]}),!i&&h.jsx("button",{onClick:se,disabled:a!=="editing",style:a!=="editing"?qe:$e,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 Lg({label:r,value:e,onChange:t,onTranscribe:n,onAIAction:s,placeholder:i="Type or record...",className:o="",rows:l}){const[a,u]=_.useState(!1),[c,d]=_.useState(null),[f,p]=_.useState(!1),g=_.useRef(null),m=b=>{t(e?`${e}
184
184
 
185
185
  ${b}`:b)},x=async b=>{if(!(!e.trim()||a||!s)){u(!0),d(b),p(!1);try{const C=await s(b,e);t(C)}catch(C){console.error(`${b} failed:`,C)}finally{u(!1),d(null)}}},v=()=>{setTimeout(()=>{var b;(b=g.current)!=null&&b.contains(document.activeElement)||p(!1)},150)};return h.jsxs("div",{className:`flex flex-col flex-1 min-h-0 ${o}`,children:[h.jsx(Hc,{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:v,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:b=>t(b.target.value),onKeyDown:b=>b.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"})]})}var Pg={value:()=>{}};function ua(){for(var r=0,e=arguments.length,t={},n;r<e;++r){if(!(n=arguments[r]+"")||n in t||/[\s.]/.test(n))throw new Error("illegal type: "+n);t[n]=[]}return new Cs(t)}function Cs(r){this._=r}function Og(r,e){return r.trim().split(/^|\s+/).map(function(t){var n="",s=t.indexOf(".");if(s>=0&&(n=t.slice(s+1),t=t.slice(0,s)),t&&!e.hasOwnProperty(t))throw new Error("unknown type: "+t);return{type:t,name:n}})}Cs.prototype=ua.prototype={constructor:Cs,on:function(r,e){var t=this._,n=Og(r+"",t),s,i=-1,o=n.length;if(arguments.length<2){for(;++i<o;)if((s=(r=n[i]).type)&&(s=Ig(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 Cs(r)},call:function(r,e){if((s=arguments.length-2)>0)for(var t=new Array(s),n=0,s,i;n<s;++n)t[n]=arguments[n+2];if(!this._.hasOwnProperty(r))throw new Error("unknown type: "+r);for(i=this._[r],n=0,s=i.length;n<s;++n)i[n].value.apply(e,t)},apply:function(r,e,t){if(!this._.hasOwnProperty(r))throw new Error("unknown type: "+r);for(var n=this._[r],s=0,i=n.length;s<i;++s)n[s].value.apply(e,t)}};function Ig(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]=Pg,r=r.slice(0,n).concat(r.slice(n+1));break}return t!=null&&r.push({name:e,value:t}),r}var bo="http://www.w3.org/1999/xhtml";const Il={svg:"http://www.w3.org/2000/svg",xhtml:bo,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function vi(r){var e=r+="",t=e.indexOf(":");return t>=0&&(e=r.slice(0,t))!=="xmlns"&&(r=r.slice(t+1)),Il.hasOwnProperty(e)?{space:Il[e],local:r}:r}function zg(r){return function(){var e=this.ownerDocument,t=this.namespaceURI;return t===bo&&e.documentElement.namespaceURI===bo?e.createElement(r):e.createElementNS(t,r)}}function $g(r){return function(){return this.ownerDocument.createElementNS(r.space,r.local)}}function Gc(r){var e=vi(r);return(e.local?$g:zg)(e)}function qg(){}function ca(r){return r==null?qg:function(){return this.querySelector(r)}}function Ug(r){typeof r!="function"&&(r=ca(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 vt(n,this._parents)}function Wg(r){return r==null?[]:Array.isArray(r)?r:Array.from(r)}function Vg(){return[]}function Kc(r){return r==null?Vg:function(){return this.querySelectorAll(r)}}function Hg(r){return function(){return Wg(r.apply(this,arguments))}}function Gg(r){typeof r=="function"?r=Hg(r):r=Kc(r);for(var e=this._groups,t=e.length,n=[],s=[],i=0;i<t;++i)for(var o=e[i],l=o.length,a,u=0;u<l;++u)(a=o[u])&&(n.push(r.call(a,a.__data__,u,o)),s.push(a));return new vt(n,s)}function Yc(r){return function(){return this.matches(r)}}function Qc(r){return function(e){return e.matches(r)}}var Kg=Array.prototype.find;function Yg(r){return function(){return Kg.call(this.children,r)}}function Qg(){return this.firstElementChild}function Xg(r){return this.select(r==null?Qg:Yg(typeof r=="function"?r:Qc(r)))}var Jg=Array.prototype.filter;function Zg(){return Array.from(this.children)}function e0(r){return function(){return Jg.call(this.children,r)}}function t0(r){return this.selectAll(r==null?Zg:e0(typeof r=="function"?r:Qc(r)))}function r0(r){typeof r!="function"&&(r=Yc(r));for(var e=this._groups,t=e.length,n=new Array(t),s=0;s<t;++s)for(var i=e[s],o=i.length,l=n[s]=[],a,u=0;u<o;++u)(a=i[u])&&r.call(a,a.__data__,u,i)&&l.push(a);return new vt(n,this._parents)}function Xc(r){return new Array(r.length)}function n0(){return new vt(this._enter||this._groups.map(Xc),this._parents)}function Qs(r,e){this.ownerDocument=r.ownerDocument,this.namespaceURI=r.namespaceURI,this._next=null,this._parent=r,this.__data__=e}Qs.prototype={constructor:Qs,appendChild:function(r){return this._parent.insertBefore(r,this._next)},insertBefore:function(r,e){return this._parent.insertBefore(r,e)},querySelector:function(r){return this._parent.querySelector(r)},querySelectorAll:function(r){return this._parent.querySelectorAll(r)}};function s0(r){return function(){return r}}function i0(r,e,t,n,s,i){for(var o=0,l,a=e.length,u=i.length;o<u;++o)(l=e[o])?(l.__data__=i[o],n[o]=l):t[o]=new Qs(r,i[o]);for(;o<a;++o)(l=e[o])&&(s[o]=l)}function o0(r,e,t,n,s,i,o){var l,a,u=new Map,c=e.length,d=i.length,f=new Array(c),p;for(l=0;l<c;++l)(a=e[l])&&(f[l]=p=o.call(a,a.__data__,l,e)+"",u.has(p)?s[l]=a:u.set(p,a));for(l=0;l<d;++l)p=o.call(r,i[l],l,i)+"",(a=u.get(p))?(n[l]=a,a.__data__=i[l],u.delete(p)):t[l]=new Qs(r,i[l]);for(l=0;l<c;++l)(a=e[l])&&u.get(f[l])===a&&(s[l]=a)}function a0(r){return r.__data__}function l0(r,e){if(!arguments.length)return Array.from(this,a0);var t=e?o0:i0,n=this._parents,s=this._groups;typeof r!="function"&&(r=s0(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=u0(r.call(c,c&&c.__data__,u,n)),g=p.length,m=l[u]=new Array(g),x=o[u]=new Array(g),v=a[u]=new Array(f);t(c,d,m,x,v,p,e);for(var b=0,C=0,S,D;b<g;++b)if(S=m[b]){for(b>=C&&(C=b+1);!(D=x[C])&&++C<g;);S._next=D||null}}return o=new vt(o,n),o._enter=l,o._exit=a,o}function u0(r){return typeof r=="object"&&"length"in r?r:Array.from(r)}function c0(){return new vt(this._exit||this._groups.map(Xc),this._parents)}function d0(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 f0(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 vt(l,this._parents)}function h0(){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 p0(r){r||(r=g0);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 vt(s,this._parents).order()}function g0(r,e){return r<e?-1:r>e?1:r>=e?0:NaN}function m0(){var r=arguments[0];return arguments[0]=this,r.apply(null,arguments),this}function y0(){return Array.from(this)}function x0(){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 b0(){let r=0;for(const e of this)++r;return r}function _0(){return!this.node()}function v0(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 w0(r){return function(){this.removeAttribute(r)}}function C0(r){return function(){this.removeAttributeNS(r.space,r.local)}}function S0(r,e){return function(){this.setAttribute(r,e)}}function E0(r,e){return function(){this.setAttributeNS(r.space,r.local,e)}}function k0(r,e){return function(){var t=e.apply(this,arguments);t==null?this.removeAttribute(r):this.setAttribute(r,t)}}function D0(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 A0(r,e){var t=vi(r);if(arguments.length<2){var n=this.node();return t.local?n.getAttributeNS(t.space,t.local):n.getAttribute(t)}return this.each((e==null?t.local?C0:w0:typeof e=="function"?t.local?D0:k0:t.local?E0:S0)(t,e))}function Jc(r){return r.ownerDocument&&r.ownerDocument.defaultView||r.document&&r||r.defaultView}function T0(r){return function(){this.style.removeProperty(r)}}function N0(r,e,t){return function(){this.style.setProperty(r,e,t)}}function B0(r,e,t){return function(){var n=e.apply(this,arguments);n==null?this.style.removeProperty(r):this.style.setProperty(r,n,t)}}function F0(r,e,t){return arguments.length>1?this.each((e==null?T0:typeof e=="function"?B0:N0)(r,e,t??"")):rn(this.node(),r)}function rn(r,e){return r.style.getPropertyValue(e)||Jc(r).getComputedStyle(r,null).getPropertyValue(e)}function R0(r){return function(){delete this[r]}}function M0(r,e){return function(){this[r]=e}}function j0(r,e){return function(){var t=e.apply(this,arguments);t==null?delete this[r]:this[r]=t}}function L0(r,e){return arguments.length>1?this.each((e==null?R0:typeof e=="function"?j0:M0)(r,e)):this.node()[r]}function Zc(r){return r.trim().split(/^|\s+/)}function da(r){return r.classList||new ed(r)}function ed(r){this._node=r,this._names=Zc(r.getAttribute("class")||"")}ed.prototype={add:function(r){var e=this._names.indexOf(r);e<0&&(this._names.push(r),this._node.setAttribute("class",this._names.join(" ")))},remove:function(r){var e=this._names.indexOf(r);e>=0&&(this._names.splice(e,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(r){return this._names.indexOf(r)>=0}};function td(r,e){for(var t=da(r),n=-1,s=e.length;++n<s;)t.add(e[n])}function rd(r,e){for(var t=da(r),n=-1,s=e.length;++n<s;)t.remove(e[n])}function P0(r){return function(){td(this,r)}}function O0(r){return function(){rd(this,r)}}function I0(r,e){return function(){(e.apply(this,arguments)?td:rd)(this,r)}}function z0(r,e){var t=Zc(r+"");if(arguments.length<2){for(var n=da(this.node()),s=-1,i=t.length;++s<i;)if(!n.contains(t[s]))return!1;return!0}return this.each((typeof e=="function"?I0:e?P0:O0)(t,e))}function $0(){this.textContent=""}function q0(r){return function(){this.textContent=r}}function U0(r){return function(){var e=r.apply(this,arguments);this.textContent=e??""}}function W0(r){return arguments.length?this.each(r==null?$0:(typeof r=="function"?U0:q0)(r)):this.node().textContent}function V0(){this.innerHTML=""}function H0(r){return function(){this.innerHTML=r}}function G0(r){return function(){var e=r.apply(this,arguments);this.innerHTML=e??""}}function K0(r){return arguments.length?this.each(r==null?V0:(typeof r=="function"?G0:H0)(r)):this.node().innerHTML}function Y0(){this.nextSibling&&this.parentNode.appendChild(this)}function Q0(){return this.each(Y0)}function X0(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function J0(){return this.each(X0)}function Z0(r){var e=typeof r=="function"?r:Gc(r);return this.select(function(){return this.appendChild(e.apply(this,arguments))})}function em(){return null}function tm(r,e){var t=typeof r=="function"?r:Gc(r),n=e==null?em:typeof e=="function"?e:ca(e);return this.select(function(){return this.insertBefore(t.apply(this,arguments),n.apply(this,arguments)||null)})}function rm(){var r=this.parentNode;r&&r.removeChild(this)}function nm(){return this.each(rm)}function sm(){var r=this.cloneNode(!1),e=this.parentNode;return e?e.insertBefore(r,this.nextSibling):r}function im(){var r=this.cloneNode(!0),e=this.parentNode;return e?e.insertBefore(r,this.nextSibling):r}function om(r){return this.select(r?im:sm)}function am(r){return arguments.length?this.property("__data__",r):this.node().__data__}function lm(r){return function(e){r.call(this,e,this.__data__)}}function um(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 cm(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 dm(r,e,t){return function(){var n=this.__on,s,i=lm(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 fm(r,e,t){var n=um(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?dm:cm,s=0;s<i;++s)this.each(l(n[s],e,t));return this}function nd(r,e,t){var n=Jc(r),s=n.CustomEvent;typeof s=="function"?s=new s(e,t):(s=n.document.createEvent("Event"),t?(s.initEvent(e,t.bubbles,t.cancelable),s.detail=t.detail):s.initEvent(e,!1,!1)),r.dispatchEvent(s)}function hm(r,e){return function(){return nd(this,r,e)}}function pm(r,e){return function(){return nd(this,r,e.apply(this,arguments))}}function gm(r,e){return this.each((typeof e=="function"?pm:hm)(r,e))}function*mm(){for(var r=this._groups,e=0,t=r.length;e<t;++e)for(var n=r[e],s=0,i=n.length,o;s<i;++s)(o=n[s])&&(yield o)}var sd=[null];function vt(r,e){this._groups=r,this._parents=e}function is(){return new vt([[document.documentElement]],sd)}function ym(){return this}vt.prototype=is.prototype={constructor:vt,select:Ug,selectAll:Gg,selectChild:Xg,selectChildren:t0,filter:r0,data:l0,enter:n0,exit:c0,join:d0,merge:f0,selection:ym,order:h0,sort:p0,call:m0,nodes:y0,node:x0,size:b0,empty:_0,each:v0,attr:A0,style:F0,property:L0,classed:z0,text:W0,html:K0,raise:Q0,lower:J0,append:Z0,insert:tm,remove:nm,clone:om,datum:am,on:fm,dispatch:gm,[Symbol.iterator]:mm};function Ft(r){return typeof r=="string"?new vt([[document.querySelector(r)]],[document.documentElement]):new vt([[r]],sd)}function xm(r){let e;for(;e=r.sourceEvent;)r=e;return r}function wr(r,e){if(r=xm(r),e===void 0&&(e=r.currentTarget),e){var t=e.ownerSVGElement||e;if(t.createSVGPoint){var n=t.createSVGPoint();return n.x=r.clientX,n.y=r.clientY,n=n.matrixTransform(e.getScreenCTM().inverse()),[n.x,n.y]}if(e.getBoundingClientRect){var s=e.getBoundingClientRect();return[r.clientX-s.left-e.clientLeft,r.clientY-s.top-e.clientTop]}}return[r.pageX,r.pageY]}const _o={capture:!0,passive:!1};function vo(r){r.preventDefault(),r.stopImmediatePropagation()}function bm(r){var e=r.document.documentElement,t=Ft(r).on("dragstart.drag",vo,_o);"onselectstart"in e?t.on("selectstart.drag",vo,_o):(e.__noselect=e.style.MozUserSelect,e.style.MozUserSelect="none")}function _m(r,e){var t=r.document.documentElement,n=Ft(r).on("dragstart.drag",null);e&&(n.on("click.drag",vo,_o),setTimeout(function(){n.on("click.drag",null)},0)),"onselectstart"in t?n.on("selectstart.drag",null):(t.style.MozUserSelect=t.__noselect,delete t.__noselect)}function fa(r,e,t){r.prototype=e.prototype=t,t.constructor=r}function id(r,e){var t=Object.create(r.prototype);for(var n in e)t[n]=e[n];return t}function os(){}var $n=.7,Xs=1/$n,Xr="\\s*([+-]?\\d+)\\s*",qn="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Ht="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",vm=/^#([0-9a-f]{3,8})$/,wm=new RegExp(`^rgb\\(${Xr},${Xr},${Xr}\\)$`),Cm=new RegExp(`^rgb\\(${Ht},${Ht},${Ht}\\)$`),Sm=new RegExp(`^rgba\\(${Xr},${Xr},${Xr},${qn}\\)$`),Em=new RegExp(`^rgba\\(${Ht},${Ht},${Ht},${qn}\\)$`),km=new RegExp(`^hsl\\(${qn},${Ht},${Ht}\\)$`),Dm=new RegExp(`^hsla\\(${qn},${Ht},${Ht},${qn}\\)$`),zl={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};fa(os,Un,{copy(r){return Object.assign(new this.constructor,this,r)},displayable(){return this.rgb().displayable()},hex:$l,formatHex:$l,formatHex8:Am,formatHsl:Tm,formatRgb:ql,toString:ql});function $l(){return this.rgb().formatHex()}function Am(){return this.rgb().formatHex8()}function Tm(){return od(this).formatHsl()}function ql(){return this.rgb().formatRgb()}function Un(r){var e,t;return r=(r+"").trim().toLowerCase(),(e=vm.exec(r))?(t=e[1].length,e=parseInt(e[1],16),t===6?Ul(e):t===3?new gt(e>>8&15|e>>4&240,e>>4&15|e&240,(e&15)<<4|e&15,1):t===8?ms(e>>24&255,e>>16&255,e>>8&255,(e&255)/255):t===4?ms(e>>12&15|e>>8&240,e>>8&15|e>>4&240,e>>4&15|e&240,((e&15)<<4|e&15)/255):null):(e=wm.exec(r))?new gt(e[1],e[2],e[3],1):(e=Cm.exec(r))?new gt(e[1]*255/100,e[2]*255/100,e[3]*255/100,1):(e=Sm.exec(r))?ms(e[1],e[2],e[3],e[4]):(e=Em.exec(r))?ms(e[1]*255/100,e[2]*255/100,e[3]*255/100,e[4]):(e=km.exec(r))?Hl(e[1],e[2]/100,e[3]/100,1):(e=Dm.exec(r))?Hl(e[1],e[2]/100,e[3]/100,e[4]):zl.hasOwnProperty(r)?Ul(zl[r]):r==="transparent"?new gt(NaN,NaN,NaN,0):null}function Ul(r){return new gt(r>>16&255,r>>8&255,r&255,1)}function ms(r,e,t,n){return n<=0&&(r=e=t=NaN),new gt(r,e,t,n)}function Nm(r){return r instanceof os||(r=Un(r)),r?(r=r.rgb(),new gt(r.r,r.g,r.b,r.opacity)):new gt}function wo(r,e,t,n){return arguments.length===1?Nm(r):new gt(r,e,t,n??1)}function gt(r,e,t,n){this.r=+r,this.g=+e,this.b=+t,this.opacity=+n}fa(gt,wo,id(os,{brighter(r){return r=r==null?Xs:Math.pow(Xs,r),new gt(this.r*r,this.g*r,this.b*r,this.opacity)},darker(r){return r=r==null?$n:Math.pow($n,r),new gt(this.r*r,this.g*r,this.b*r,this.opacity)},rgb(){return this},clamp(){return new gt(Tr(this.r),Tr(this.g),Tr(this.b),Js(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:Wl,formatHex:Wl,formatHex8:Bm,formatRgb:Vl,toString:Vl}));function Wl(){return`#${Sr(this.r)}${Sr(this.g)}${Sr(this.b)}`}function Bm(){return`#${Sr(this.r)}${Sr(this.g)}${Sr(this.b)}${Sr((isNaN(this.opacity)?1:this.opacity)*255)}`}function Vl(){const r=Js(this.opacity);return`${r===1?"rgb(":"rgba("}${Tr(this.r)}, ${Tr(this.g)}, ${Tr(this.b)}${r===1?")":`, ${r})`}`}function Js(r){return isNaN(r)?1:Math.max(0,Math.min(1,r))}function Tr(r){return Math.max(0,Math.min(255,Math.round(r)||0))}function Sr(r){return r=Tr(r),(r<16?"0":"")+r.toString(16)}function Hl(r,e,t,n){return n<=0?r=e=t=NaN:t<=0||t>=1?r=e=NaN:e<=0&&(r=NaN),new Rt(r,e,t,n)}function od(r){if(r instanceof Rt)return new Rt(r.h,r.s,r.l,r.opacity);if(r instanceof os||(r=Un(r)),!r)return new Rt;if(r instanceof Rt)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 Rt(o,l,a,r.opacity)}function Fm(r,e,t,n){return arguments.length===1?od(r):new Rt(r,e,t,n??1)}function Rt(r,e,t,n){this.h=+r,this.s=+e,this.l=+t,this.opacity=+n}fa(Rt,Fm,id(os,{brighter(r){return r=r==null?Xs:Math.pow(Xs,r),new Rt(this.h,this.s,this.l*r,this.opacity)},darker(r){return r=r==null?$n:Math.pow($n,r),new Rt(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 gt(qi(r>=240?r-240:r+120,s,n),qi(r,s,n),qi(r<120?r+240:r-120,s,n),this.opacity)},clamp(){return new Rt(Gl(this.h),ys(this.s),ys(this.l),Js(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const r=Js(this.opacity);return`${r===1?"hsl(":"hsla("}${Gl(this.h)}, ${ys(this.s)*100}%, ${ys(this.l)*100}%${r===1?")":`, ${r})`}`}}));function Gl(r){return r=(r||0)%360,r<0?r+360:r}function ys(r){return Math.max(0,Math.min(1,r||0))}function qi(r,e,t){return(r<60?e+(t-e)*r/60:r<180?t:r<240?e+(t-e)*(240-r)/60:e)*255}const ad=r=>()=>r;function Rm(r,e){return function(t){return r+t*e}}function Mm(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 jm(r){return(r=+r)==1?ld:function(e,t){return t-e?Mm(e,t,r):ad(isNaN(e)?t:e)}}function ld(r,e){var t=e-r;return t?Rm(r,t):ad(isNaN(r)?e:r)}const Kl=function r(e){var t=jm(e);function n(s,i){var o=t((s=wo(s)).r,(i=wo(i)).r),l=t(s.g,i.g),a=t(s.b,i.b),u=ld(s.opacity,i.opacity);return function(c){return s.r=o(c),s.g=l(c),s.b=a(c),s.opacity=u(c),s+""}}return n.gamma=r,n}(1);function fr(r,e){return r=+r,e=+e,function(t){return r*(1-t)+e*t}}var Co=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Ui=new RegExp(Co.source,"g");function Lm(r){return function(){return r}}function Pm(r){return function(e){return r(e)+""}}function Om(r,e){var t=Co.lastIndex=Ui.lastIndex=0,n,s,i,o=-1,l=[],a=[];for(r=r+"",e=e+"";(n=Co.exec(r))&&(s=Ui.exec(e));)(i=s.index)>t&&(i=e.slice(t,i),l[o]?l[o]+=i:l[++o]=i),(n=n[0])===(s=s[0])?l[o]?l[o]+=s:l[++o]=s:(l[++o]=null,a.push({i:o,x:fr(n,s)})),t=Ui.lastIndex;return t<e.length&&(i=e.slice(t),l[o]?l[o]+=i:l[++o]=i),l.length<2?a[0]?Pm(a[0].x):Lm(e):(e=a.length,function(u){for(var c=0,d;c<e;++c)l[(d=a[c]).i]=d.x(u);return l.join("")})}var Yl=180/Math.PI,So={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function ud(r,e,t,n,s,i){var o,l,a;return(o=Math.sqrt(r*r+e*e))&&(r/=o,e/=o),(a=r*t+e*n)&&(t-=r*a,n-=e*a),(l=Math.sqrt(t*t+n*n))&&(t/=l,n/=l,a/=l),r*n<e*t&&(r=-r,e=-e,a=-a,o=-o),{translateX:s,translateY:i,rotate:Math.atan2(e,r)*Yl,skewX:Math.atan(a)*Yl,scaleX:o,scaleY:l}}var xs;function Im(r){const e=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(r+"");return e.isIdentity?So:ud(e.a,e.b,e.c,e.d,e.e,e.f)}function zm(r){return r==null||(xs||(xs=document.createElementNS("http://www.w3.org/2000/svg","g")),xs.setAttribute("transform",r),!(r=xs.transform.baseVal.consolidate()))?So:(r=r.matrix,ud(r.a,r.b,r.c,r.d,r.e,r.f))}function cd(r,e,t,n){function s(u){return u.length?u.pop()+" ":""}function i(u,c,d,f,p,g){if(u!==d||c!==f){var m=p.push("translate(",null,e,null,t);g.push({i:m-4,x:fr(u,d)},{i:m-2,x:fr(c,f)})}else(d||f)&&p.push("translate("+d+e+f+t)}function o(u,c,d,f){u!==c?(u-c>180?c+=360:c-u>180&&(u+=360),f.push({i:d.push(s(d)+"rotate(",null,n)-2,x:fr(u,c)})):c&&d.push(s(d)+"rotate("+c+n)}function l(u,c,d,f){u!==c?f.push({i:d.push(s(d)+"skewX(",null,n)-2,x:fr(u,c)}):c&&d.push(s(d)+"skewX("+c+n)}function a(u,c,d,f,p,g){if(u!==d||c!==f){var m=p.push(s(p)+"scale(",null,",",null,")");g.push({i:m-4,x:fr(u,d)},{i:m-2,x:fr(c,f)})}else(d!==1||f!==1)&&p.push(s(p)+"scale("+d+","+f+")")}return function(u,c){var d=[],f=[];return u=r(u),c=r(c),i(u.translateX,u.translateY,c.translateX,c.translateY,d,f),o(u.rotate,c.rotate,d,f),l(u.skewX,c.skewX,d,f),a(u.scaleX,u.scaleY,c.scaleX,c.scaleY,d,f),u=c=null,function(p){for(var g=-1,m=f.length,x;++g<m;)d[(x=f[g]).i]=x.x(p);return d.join("")}}}var $m=cd(Im,"px, ","px)","deg)"),qm=cd(zm,", ",")",")"),Um=1e-12;function Ql(r){return((r=Math.exp(r))+1/r)/2}function Wm(r){return((r=Math.exp(r))-1/r)/2}function Vm(r){return((r=Math.exp(2*r))-1)/(r+1)}const Hm=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,v;if(m<Um)v=Math.log(f/u)/e,x=function(y){return[l+y*p,a+y*g,u*Math.exp(e*y*v)]};else{var b=Math.sqrt(m),C=(f*f-u*u+n*m)/(2*u*t*b),S=(f*f-u*u-n*m)/(2*f*t*b),D=Math.log(Math.sqrt(C*C+1)-C),w=Math.log(Math.sqrt(S*S+1)-S);v=(w-D)/e,x=function(y){var k=y*v,N=Ql(D),F=u/(t*b)*(N*Vm(e*k+D)-Wm(D));return[l+F*p,a+F*g,u*N/Ql(e*k+D)]}}return x.duration=v*1e3*e/Math.SQRT2,x}return s.rho=function(i){var o=Math.max(.001,+i),l=o*o,a=l*l;return r(o,l,a)},s}(Math.SQRT2,2,4);var nn=0,Cn=0,yn=0,dd=1e3,Zs,Sn,ei=0,Lr=0,wi=0,Wn=typeof performance=="object"&&performance.now?performance:Date,fd=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(r){setTimeout(r,17)};function ha(){return Lr||(fd(Gm),Lr=Wn.now()+wi)}function Gm(){Lr=0}function ti(){this._call=this._time=this._next=null}ti.prototype=hd.prototype={constructor:ti,restart:function(r,e,t){if(typeof r!="function")throw new TypeError("callback is not a function");t=(t==null?ha():+t)+(e==null?0:+e),!this._next&&Sn!==this&&(Sn?Sn._next=this:Zs=this,Sn=this),this._call=r,this._time=t,Eo()},stop:function(){this._call&&(this._call=null,this._time=1/0,Eo())}};function hd(r,e,t){var n=new ti;return n.restart(r,e,t),n}function Km(){ha(),++nn;for(var r=Zs,e;r;)(e=Lr-r._time)>=0&&r._call.call(void 0,e),r=r._next;--nn}function Xl(){Lr=(ei=Wn.now())+wi,nn=Cn=0;try{Km()}finally{nn=0,Qm(),Lr=0}}function Ym(){var r=Wn.now(),e=r-ei;e>dd&&(wi-=e,ei=r)}function Qm(){for(var r,e=Zs,t,n=1/0;e;)e._call?(n>e._time&&(n=e._time),r=e,e=e._next):(t=e._next,e._next=null,e=r?r._next=t:Zs=t);Sn=r,Eo(n)}function Eo(r){if(!nn){Cn&&(Cn=clearTimeout(Cn));var e=r-Lr;e>24?(r<1/0&&(Cn=setTimeout(Xl,r-Wn.now()-wi)),yn&&(yn=clearInterval(yn))):(yn||(ei=Wn.now(),yn=setInterval(Ym,dd)),nn=1,fd(Xl))}}function Jl(r,e,t){var n=new ti;return e=e==null?0:+e,n.restart(s=>{n.stop(),r(s+e)},e,t),n}var Xm=ua("start","end","cancel","interrupt"),Jm=[],pd=0,Zl=1,ko=2,Ss=3,eu=4,Do=5,Es=6;function Ci(r,e,t,n,s,i){var o=r.__transition;if(!o)r.__transition={};else if(t in o)return;Zm(r,t,{name:e,index:n,group:s,on:Xm,tween:Jm,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:pd})}function pa(r,e){var t=Ot(r,e);if(t.state>pd)throw new Error("too late; already scheduled");return t}function Xt(r,e){var t=Ot(r,e);if(t.state>Ss)throw new Error("too late; already running");return t}function Ot(r,e){var t=r.__transition;if(!t||!(t=t[e]))throw new Error("transition not found");return t}function Zm(r,e,t){var n=r.__transition,s;n[e]=t,t.timer=hd(i,0,t.time);function i(u){t.state=Zl,t.timer.restart(o,t.delay,t.time),t.delay<=u&&o(u-t.delay)}function o(u){var c,d,f,p;if(t.state!==Zl)return a();for(c in n)if(p=n[c],p.name===t.name){if(p.state===Ss)return Jl(o);p.state===eu?(p.state=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(Jl(function(){t.state===Ss&&(t.state=eu,t.timer.restart(l,t.delay,t.time),l(u))}),t.state=ko,t.on.call("start",r,r.__data__,t.index,t.group),t.state===ko){for(t.state=Ss,s=new Array(f=t.tween.length),c=0,d=-1;c<f;++c)(p=t.tween[c].value.call(r,r.__data__,t.index,t.group))&&(s[++d]=p);s.length=d+1}}function l(u){for(var c=u<t.duration?t.ease.call(null,u/t.duration):(t.timer.restart(a),t.state=Do,1),d=-1,f=s.length;++d<f;)s[d].call(r,c);t.state===Do&&(t.on.call("end",r,r.__data__,t.index,t.group),a())}function a(){t.state=Es,t.timer.stop(),delete n[e];for(var u in n)return;delete r.__transition}}function ks(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>ko&&n.state<Do,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 e2(r){return this.each(function(){ks(this,r)})}function t2(r,e){var t,n;return function(){var s=Xt(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 r2(r,e,t){var n,s;if(typeof t!="function")throw new Error;return function(){var i=Xt(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 n2(r,e){var t=this._id;if(r+="",arguments.length<2){for(var n=Ot(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?t2:r2)(t,r,e))}function ga(r,e,t){var n=r._id;return r.each(function(){var s=Xt(this,n);(s.value||(s.value={}))[e]=t.apply(this,arguments)}),function(s){return Ot(s,n).value[e]}}function gd(r,e){var t;return(typeof e=="number"?fr:e instanceof Un?Kl:(t=Un(e))?(e=t,Kl):Om)(r,e)}function s2(r){return function(){this.removeAttribute(r)}}function i2(r){return function(){this.removeAttributeNS(r.space,r.local)}}function o2(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 a2(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 l2(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 u2(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 c2(r,e){var t=vi(r),n=t==="transform"?qm:gd;return this.attrTween(r,typeof e=="function"?(t.local?u2:l2)(t,n,ga(this,"attr."+r,e)):e==null?(t.local?i2:s2)(t):(t.local?a2:o2)(t,n,e))}function d2(r,e){return function(t){this.setAttribute(r,e.call(this,t))}}function f2(r,e){return function(t){this.setAttributeNS(r.space,r.local,e.call(this,t))}}function h2(r,e){var t,n;function s(){var i=e.apply(this,arguments);return i!==n&&(t=(n=i)&&f2(r,i)),t}return s._value=e,s}function p2(r,e){var t,n;function s(){var i=e.apply(this,arguments);return i!==n&&(t=(n=i)&&d2(r,i)),t}return s._value=e,s}function g2(r,e){var t="attr."+r;if(arguments.length<2)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!="function")throw new Error;var n=vi(r);return this.tween(t,(n.local?h2:p2)(n,e))}function m2(r,e){return function(){pa(this,r).delay=+e.apply(this,arguments)}}function y2(r,e){return e=+e,function(){pa(this,r).delay=e}}function x2(r){var e=this._id;return arguments.length?this.each((typeof r=="function"?m2:y2)(e,r)):Ot(this.node(),e).delay}function b2(r,e){return function(){Xt(this,r).duration=+e.apply(this,arguments)}}function _2(r,e){return e=+e,function(){Xt(this,r).duration=e}}function v2(r){var e=this._id;return arguments.length?this.each((typeof r=="function"?b2:_2)(e,r)):Ot(this.node(),e).duration}function w2(r,e){if(typeof e!="function")throw new Error;return function(){Xt(this,r).ease=e}}function C2(r){var e=this._id;return arguments.length?this.each(w2(e,r)):Ot(this.node(),e).ease}function S2(r,e){return function(){var t=e.apply(this,arguments);if(typeof t!="function")throw new Error;Xt(this,r).ease=t}}function E2(r){if(typeof r!="function")throw new Error;return this.each(S2(this._id,r))}function k2(r){typeof r!="function"&&(r=Yc(r));for(var e=this._groups,t=e.length,n=new Array(t),s=0;s<t;++s)for(var i=e[s],o=i.length,l=n[s]=[],a,u=0;u<o;++u)(a=i[u])&&r.call(a,a.__data__,u,i)&&l.push(a);return new ir(n,this._parents,this._name,this._id)}function D2(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 A2(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 T2(r,e,t){var n,s,i=A2(e)?pa:Xt;return function(){var o=i(this,r),l=o.on;l!==n&&(s=(n=l).copy()).on(e,t),o.on=s}}function N2(r,e){var t=this._id;return arguments.length<2?Ot(this.node(),t).on.on(r):this.each(T2(t,r,e))}function B2(r){return function(){var e=this.parentNode;for(var t in this.__transition)if(+t!==r)return;e&&e.removeChild(this)}}function F2(){return this.on("end.remove",B2(this._id))}function R2(r){var e=this._name,t=this._id;typeof r!="function"&&(r=ca(r));for(var n=this._groups,s=n.length,i=new Array(s),o=0;o<s;++o)for(var l=n[o],a=l.length,u=i[o]=new Array(a),c,d,f=0;f<a;++f)(c=l[f])&&(d=r.call(c,c.__data__,f,l))&&("__data__"in c&&(d.__data__=c.__data__),u[f]=d,Ci(u[f],e,t,f,u,Ot(c,t)));return new ir(i,this._parents,e,t)}function M2(r){var e=this._name,t=this._id;typeof r!="function"&&(r=Kc(r));for(var n=this._groups,s=n.length,i=[],o=[],l=0;l<s;++l)for(var a=n[l],u=a.length,c,d=0;d<u;++d)if(c=a[d]){for(var f=r.call(c,c.__data__,d,a),p,g=Ot(c,t),m=0,x=f.length;m<x;++m)(p=f[m])&&Ci(p,e,t,m,f,g);i.push(f),o.push(c)}return new ir(i,o,e,t)}var j2=is.prototype.constructor;function L2(){return new j2(this._groups,this._parents)}function P2(r,e){var t,n,s;return function(){var i=rn(this,r),o=(this.style.removeProperty(r),rn(this,r));return i===o?null:i===t&&o===n?s:s=e(t=i,n=o)}}function md(r){return function(){this.style.removeProperty(r)}}function O2(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 I2(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 z2(r,e){var t,n,s,i="style."+e,o="end."+i,l;return function(){var a=Xt(this,r),u=a.on,c=a.value[i]==null?l||(l=md(e)):void 0;(u!==t||s!==c)&&(n=(t=u).copy()).on(o,s=c),a.on=n}}function $2(r,e,t){var n=(r+="")=="transform"?$m:gd;return e==null?this.styleTween(r,P2(r,n)).on("end.style."+r,md(r)):typeof e=="function"?this.styleTween(r,I2(r,n,ga(this,"style."+r,e))).each(z2(this._id,r)):this.styleTween(r,O2(r,n,e),t).on("end.style."+r,null)}function q2(r,e,t){return function(n){this.style.setProperty(r,e.call(this,n),t)}}function U2(r,e,t){var n,s;function i(){var o=e.apply(this,arguments);return o!==s&&(n=(s=o)&&q2(r,o,t)),n}return i._value=e,i}function W2(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,U2(r,e,t??""))}function V2(r){return function(){this.textContent=r}}function H2(r){return function(){var e=r(this);this.textContent=e??""}}function G2(r){return this.tween("text",typeof r=="function"?H2(ga(this,"text",r)):V2(r==null?"":r+""))}function K2(r){return function(e){this.textContent=r.call(this,e)}}function Y2(r){var e,t;function n(){var s=r.apply(this,arguments);return s!==t&&(e=(t=s)&&K2(s)),e}return n._value=r,n}function Q2(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,Y2(r))}function X2(){for(var r=this._name,e=this._id,t=yd(),n=this._groups,s=n.length,i=0;i<s;++i)for(var o=n[i],l=o.length,a,u=0;u<l;++u)if(a=o[u]){var c=Ot(a,e);Ci(a,r,t,u,o,{time:c.time+c.delay+c.duration,delay:0,duration:c.duration,ease:c.ease})}return new ir(n,this._parents,r,t)}function J2(){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=Xt(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 Z2=0;function ir(r,e,t,n){this._groups=r,this._parents=e,this._name=t,this._id=n}function yd(){return++Z2}var tr=is.prototype;ir.prototype={constructor:ir,select:R2,selectAll:M2,selectChild:tr.selectChild,selectChildren:tr.selectChildren,filter:k2,merge:D2,selection:L2,transition:X2,call:tr.call,nodes:tr.nodes,node:tr.node,size:tr.size,empty:tr.empty,each:tr.each,on:N2,attr:c2,attrTween:g2,style:$2,styleTween:W2,text:G2,textTween:Q2,remove:F2,tween:n2,delay:x2,duration:v2,ease:C2,easeVarying:E2,end:J2,[Symbol.iterator]:tr[Symbol.iterator]};function ey(r){return((r*=2)<=1?r*r*r:(r-=2)*r*r+2)/2}var ty={time:null,delay:0,duration:250,ease:ey};function ry(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 ny(r){var e,t;r instanceof ir?(e=r._id,r=r._name):(e=yd(),(t=ty).time=ha(),r=r==null?null:r+"");for(var n=this._groups,s=n.length,i=0;i<s;++i)for(var o=n[i],l=o.length,a,u=0;u<l;++u)(a=o[u])&&Ci(a,r,e,u,o,t||ry(a,e));return new ir(n,this._parents,r,e)}is.prototype.interrupt=e2;is.prototype.transition=ny;const bs=r=>()=>r;function sy(r,{sourceEvent:e,target:t,transform:n,dispatch:s}){Object.defineProperties(this,{type:{value:r,enumerable:!0,configurable:!0},sourceEvent:{value:e,enumerable:!0,configurable:!0},target:{value:t,enumerable:!0,configurable:!0},transform:{value:n,enumerable:!0,configurable:!0},_:{value:s}})}function nr(r,e,t){this.k=r,this.x=e,this.y=t}nr.prototype={constructor:nr,scale:function(r){return r===1?this:new nr(this.k*r,this.x,this.y)},translate:function(r,e){return r===0&e===0?this:new nr(this.k,this.x+this.k*r,this.y+this.k*e)},apply:function(r){return[r[0]*this.k+this.x,r[1]*this.k+this.y]},applyX:function(r){return r*this.k+this.x},applyY:function(r){return r*this.k+this.y},invert:function(r){return[(r[0]-this.x)/this.k,(r[1]-this.y)/this.k]},invertX:function(r){return(r-this.x)/this.k},invertY:function(r){return(r-this.y)/this.k},rescaleX:function(r){return r.copy().domain(r.range().map(this.invertX,this).map(r.invert,r))},rescaleY:function(r){return r.copy().domain(r.range().map(this.invertY,this).map(r.invert,r))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var ri=new nr(1,0,0);nr.prototype;function Wi(r){r.stopImmediatePropagation()}function xn(r){r.preventDefault(),r.stopImmediatePropagation()}function iy(r){return(!r.ctrlKey||r.type==="wheel")&&!r.button}function oy(){var r=this;return r instanceof SVGElement?(r=r.ownerSVGElement||r,r.hasAttribute("viewBox")?(r=r.viewBox.baseVal,[[r.x,r.y],[r.x+r.width,r.y+r.height]]):[[0,0],[r.width.baseVal.value,r.height.baseVal.value]]):[[0,0],[r.clientWidth,r.clientHeight]]}function tu(){return this.__zoom||ri}function ay(r){return-r.deltaY*(r.deltaMode===1?.05:r.deltaMode?1:.002)*(r.ctrlKey?10:1)}function ly(){return navigator.maxTouchPoints||"ontouchstart"in this}function uy(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 cy(){var r=iy,e=oy,t=uy,n=ay,s=ly,i=[0,1/0],o=[[-1/0,-1/0],[1/0,1/0]],l=250,a=Hm,u=ua("start","zoom","end"),c,d,f,p=500,g=150,m=0,x=10;function v(E){E.property("__zoom",tu).on("wheel.zoom",k,{passive:!1}).on("mousedown.zoom",N).on("dblclick.zoom",F).filter(s).on("touchstart.zoom",T).on("touchmove.zoom",M).on("touchend.zoom touchcancel.zoom",L).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}v.transform=function(E,B,R,O){var H=E.selection?E.selection():E;H.property("__zoom",tu),E!==H?D(E,B,R,O):H.interrupt().each(function(){w(this,arguments).event(O).start().zoom(null,typeof B=="function"?B.apply(this,arguments):B).end()})},v.scaleBy=function(E,B,R,O){v.scaleTo(E,function(){var H=this.__zoom.k,U=typeof B=="function"?B.apply(this,arguments):B;return H*U},R,O)},v.scaleTo=function(E,B,R,O){v.transform(E,function(){var H=e.apply(this,arguments),U=this.__zoom,Z=R==null?S(H):typeof R=="function"?R.apply(this,arguments):R,q=U.invert(Z),K=typeof B=="function"?B.apply(this,arguments):B;return t(C(b(U,K),Z,q),H,o)},R,O)},v.translateBy=function(E,B,R,O){v.transform(E,function(){return t(this.__zoom.translate(typeof B=="function"?B.apply(this,arguments):B,typeof R=="function"?R.apply(this,arguments):R),e.apply(this,arguments),o)},null,O)},v.translateTo=function(E,B,R,O,H){v.transform(E,function(){var U=e.apply(this,arguments),Z=this.__zoom,q=O==null?S(U):typeof O=="function"?O.apply(this,arguments):O;return t(ri.translate(q[0],q[1]).scale(Z.k).translate(typeof B=="function"?-B.apply(this,arguments):-B,typeof R=="function"?-R.apply(this,arguments):-R),U,o)},O,H)};function b(E,B){return B=Math.max(i[0],Math.min(i[1],B)),B===E.k?E:new nr(B,E.x,E.y)}function C(E,B,R){var O=B[0]-R[0]*E.k,H=B[1]-R[1]*E.k;return O===E.x&&H===E.y?E:new nr(E.k,O,H)}function S(E){return[(+E[0][0]+ +E[1][0])/2,(+E[0][1]+ +E[1][1])/2]}function D(E,B,R,O){E.on("start.zoom",function(){w(this,arguments).event(O).start()}).on("interrupt.zoom end.zoom",function(){w(this,arguments).event(O).end()}).tween("zoom",function(){var H=this,U=arguments,Z=w(H,U).event(O),q=e.apply(H,U),K=R==null?S(q):typeof R=="function"?R.apply(H,U):R,$=Math.max(q[1][0]-q[0][0],q[1][1]-q[0][1]),re=H.__zoom,ae=typeof B=="function"?B.apply(H,U):B,le=a(re.invert(K).concat($/re.k),ae.invert(K).concat($/ae.k));return function(ce){if(ce===1)ce=ae;else{var ve=le(ce),pe=$/ve[2];ce=new nr(pe,K[0]-ve[0]*pe,K[1]-ve[1]*pe)}Z.zoom(null,ce)}})}function w(E,B,R){return!R&&E.__zooming||new y(E,B)}function y(E,B){this.that=E,this.args=B,this.active=0,this.sourceEvent=null,this.extent=e.apply(E,B),this.taps=0}y.prototype={event:function(E){return E&&(this.sourceEvent=E),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(E,B){return this.mouse&&E!=="mouse"&&(this.mouse[1]=B.invert(this.mouse[0])),this.touch0&&E!=="touch"&&(this.touch0[1]=B.invert(this.touch0[0])),this.touch1&&E!=="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(E){var B=Ft(this.that).datum();u.call(E,this.that,new sy(E,{sourceEvent:this.sourceEvent,target:v,transform:this.that.__zoom,dispatch:u}),B)}};function k(E,...B){if(!r.apply(this,arguments))return;var R=w(this,B).event(E),O=this.__zoom,H=Math.max(i[0],Math.min(i[1],O.k*Math.pow(2,n.apply(this,arguments)))),U=wr(E);if(R.wheel)(R.mouse[0][0]!==U[0]||R.mouse[0][1]!==U[1])&&(R.mouse[1]=O.invert(R.mouse[0]=U)),clearTimeout(R.wheel);else{if(O.k===H)return;R.mouse=[U,O.invert(U)],ks(this),R.start()}xn(E),R.wheel=setTimeout(Z,g),R.zoom("mouse",t(C(b(O,H),R.mouse[0],R.mouse[1]),R.extent,o));function Z(){R.wheel=null,R.end()}}function N(E,...B){if(f||!r.apply(this,arguments))return;var R=E.currentTarget,O=w(this,B,!0).event(E),H=Ft(E.view).on("mousemove.zoom",K,!0).on("mouseup.zoom",$,!0),U=wr(E,R),Z=E.clientX,q=E.clientY;bm(E.view),Wi(E),O.mouse=[U,this.__zoom.invert(U)],ks(this),O.start();function K(re){if(xn(re),!O.moved){var ae=re.clientX-Z,le=re.clientY-q;O.moved=ae*ae+le*le>m}O.event(re).zoom("mouse",t(C(O.that.__zoom,O.mouse[0]=wr(re,R),O.mouse[1]),O.extent,o))}function $(re){H.on("mousemove.zoom mouseup.zoom",null),_m(re.view,O.moved),xn(re),O.event(re).end()}}function F(E,...B){if(r.apply(this,arguments)){var R=this.__zoom,O=wr(E.changedTouches?E.changedTouches[0]:E,this),H=R.invert(O),U=R.k*(E.shiftKey?.5:2),Z=t(C(b(R,U),O,H),e.apply(this,B),o);xn(E),l>0?Ft(this).transition().duration(l).call(D,Z,O,E):Ft(this).call(v.transform,Z,O,E)}}function T(E,...B){if(r.apply(this,arguments)){var R=E.touches,O=R.length,H=w(this,B,E.changedTouches.length===O).event(E),U,Z,q,K;for(Wi(E),Z=0;Z<O;++Z)q=R[Z],K=wr(q,this),K=[K,this.__zoom.invert(K),q.identifier],H.touch0?!H.touch1&&H.touch0[2]!==K[2]&&(H.touch1=K,H.taps=0):(H.touch0=K,U=!0,H.taps=1+!!c);c&&(c=clearTimeout(c)),U&&(H.taps<2&&(d=K[0],c=setTimeout(function(){c=null},p)),ks(this),H.start())}}function M(E,...B){if(this.__zooming){var R=w(this,B).event(E),O=E.changedTouches,H=O.length,U,Z,q,K;for(xn(E),U=0;U<H;++U)Z=O[U],q=wr(Z,this),R.touch0&&R.touch0[2]===Z.identifier?R.touch0[0]=q:R.touch1&&R.touch1[2]===Z.identifier&&(R.touch1[0]=q);if(Z=R.that.__zoom,R.touch1){var $=R.touch0[0],re=R.touch0[1],ae=R.touch1[0],le=R.touch1[1],ce=(ce=ae[0]-$[0])*ce+(ce=ae[1]-$[1])*ce,ve=(ve=le[0]-re[0])*ve+(ve=le[1]-re[1])*ve;Z=b(Z,Math.sqrt(ce/ve)),q=[($[0]+ae[0])/2,($[1]+ae[1])/2],K=[(re[0]+le[0])/2,(re[1]+le[1])/2]}else if(R.touch0)q=R.touch0[0],K=R.touch0[1];else return;R.zoom("touch",t(C(Z,q,K),R.extent,o))}}function L(E,...B){if(this.__zooming){var R=w(this,B).event(E),O=E.changedTouches,H=O.length,U,Z;for(Wi(E),f&&clearTimeout(f),f=setTimeout(function(){f=null},p),U=0;U<H;++U)Z=O[U],R.touch0&&R.touch0[2]===Z.identifier?delete R.touch0:R.touch1&&R.touch1[2]===Z.identifier&&delete R.touch1;if(R.touch1&&!R.touch0&&(R.touch0=R.touch1,delete R.touch1),R.touch0)R.touch0[1]=this.__zoom.invert(R.touch0[0]);else if(R.end(),R.taps===2&&(Z=wr(Z,this),Math.hypot(d[0]-Z[0],d[1]-Z[1])<x)){var q=Ft(this).on("dblclick.zoom");q&&q.apply(this,arguments)}}}return v.wheelDelta=function(E){return arguments.length?(n=typeof E=="function"?E:bs(+E),v):n},v.filter=function(E){return arguments.length?(r=typeof E=="function"?E:bs(!!E),v):r},v.touchable=function(E){return arguments.length?(s=typeof E=="function"?E:bs(!!E),v):s},v.extent=function(E){return arguments.length?(e=typeof E=="function"?E:bs([[+E[0][0],+E[0][1]],[+E[1][0],+E[1][1]]]),v):e},v.scaleExtent=function(E){return arguments.length?(i[0]=+E[0],i[1]=+E[1],v):[i[0],i[1]]},v.translateExtent=function(E){return arguments.length?(o[0][0]=+E[0][0],o[1][0]=+E[1][0],o[0][1]=+E[0][1],o[1][1]=+E[1][1],v):[[o[0][0],o[0][1]],[o[1][0],o[1][1]]]},v.constrain=function(E){return arguments.length?(t=E,v):t},v.duration=function(E){return arguments.length?(l=+E,v):l},v.interpolate=function(E){return arguments.length?(a=E,v):a},v.on=function(){var E=u.on.apply(u,arguments);return E===u?v:E},v.clickDistance=function(E){return arguments.length?(m=(E=+E)*E,v):Math.sqrt(m)},v.tapDistance=function(E){return arguments.length?(x=+E,v):x},v}function xd(r={}){const{minZoom:e=.1,maxZoom:t=4,initialTransform:n,zoomable:s=!0,pannable:i=!0,onTransformChange:o}=r,l=_.useRef(null),a=_.useRef(),[u,c]=_.useState(n||{x:0,y:0,k:1});_.useEffect(()=>{if(!l.current)return;const x=cy().scaleExtent([e,t]).filter(b=>!s&&b.type==="wheel"||!i&&(b.type==="mousedown"||b.type==="touchstart")?!1:b.type==="wheel"?s:b.type==="mousedown"||b.type==="touchstart"?b.target.closest("[data-qmap-node]")?!1:i:!0).on("zoom",b=>{const C={x:b.transform.x,y:b.transform.y,k:b.transform.k};c(C),o==null||o(C)});a.current=x;const v=Ft(l.current);return v.call(x),v.on("dblclick.zoom",null),n&&v.call(x.transform,ri.translate(n.x,n.y).scale(n.k)),()=>{v.on(".zoom",null)}},[e,t,s,i]),_.useEffect(()=>{a.current&&a.current.on("zoom",x=>{const v={x:x.transform.x,y:x.transform.y,k:x.transform.k};c(v),o==null||o(v)})},[o]);const d=_.useCallback((x,v,b,C=!0)=>{if(!l.current||!a.current)return;const S=Ft(l.current),D=ri.translate(x,v).scale(b);S.call(a.current.transform,D)},[]),f=_.useCallback(()=>{!l.current||!a.current||Ft(l.current).call(a.current.scaleBy,1.3)},[]),p=_.useCallback(()=>{!l.current||!a.current||Ft(l.current).call(a.current.scaleBy,.7)},[]),g=_.useCallback(()=>{d(0,0,1,!0)},[d]),m=_.useCallback((x,v=50)=>{if(!l.current||!a.current||x.length===0)return;const C=l.current.getBoundingClientRect();let S=1/0,D=1/0,w=-1/0,y=-1/0;for(const O of x){const H=O.width||200,U=O.height||100;S=Math.min(S,O.x),D=Math.min(D,O.y),w=Math.max(w,O.x+H),y=Math.max(y,O.y+U)}const k=w-S,N=y-D,F=(C.width-v*2)/k,T=(C.height-v*2)/N,M=Math.min(F,T,t),L=(S+w)/2,E=(D+y)/2,B=C.width/2-L*M,R=C.height/2-E*M;d(B,R,M,!0)},[t,d]);return{transform:u,containerRef:l,zoomTo:d,zoomIn:f,zoomOut:p,resetZoom:g,fitToContent:m}}function bd(r){const{transform:e,onDragStart:t,onDragMove:n,onDragEnd:s,disabled:i=!1}=r,[o,l]=_.useState(null),[a,u]=_.useState(!1),[c,d]=_.useState({x:0,y:0}),f=_.useRef(null),p=_.useRef({x:0,y:0}),g=_.useRef(e);_.useEffect(()=>{g.current=e},[e]);const m=_.useCallback((C,S)=>{const D=g.current;return{x:(C-D.x)/D.k,y:(S-D.y)/D.k}},[]),x=_.useCallback((C,S)=>{if(i)return;S.preventDefault(),S.stopPropagation();const D=S.currentTarget,w=parseFloat(D.dataset.x||"0"),y=parseFloat(D.dataset.y||"0");f.current={x:S.clientX,y:S.clientY,nodeX:w,nodeY:y},p.current={x:w,y},l(C),u(!0),d({x:0,y:0}),t==null||t(C)},[i,m,t]),v=_.useCallback(C=>{if(!a||!o||!f.current)return;const S=g.current,D=f.current,w=C.clientX-D.x,y=C.clientY-D.y,k=w/S.k,N=y/S.k,F=D.nodeX+k,T=D.nodeY+N;p.current={x:F,y:T},d({x:k,y:N}),n==null||n(o,F,T,k,N)},[a,o,n]),b=_.useCallback(()=>{if(!a||!o)return;const C=p.current;s==null||s(o,C.x,C.y),l(null),u(!1),d({x:0,y:0}),f.current=null},[a,o,s]);return _.useEffect(()=>{if(!a)return;const C=D=>{v(D)},S=()=>{b()};return window.addEventListener("mousemove",C),window.addEventListener("mouseup",S),()=>{window.removeEventListener("mousemove",C),window.removeEventListener("mouseup",S)}},[a,v,b]),{draggedNodeId:o,isDragging:a,dragOffset:c,startDrag:x,updateDrag:v,endDrag:b}}function _d(r){const{transform:e,nodePositions:t,disabled:n=!1,onSelectionChange:s}=r,[i,o]=_.useState(new Set),[l,a]=_.useState(null),[u,c]=_.useState(!1),d=_.useRef(null),f=_.useRef(e),p=_.useRef(t);_.useEffect(()=>{f.current=e},[e]),_.useEffect(()=>{p.current=t},[t]);const g=_.useCallback((w,y)=>{const k=f.current;return{x:(w-k.x)/k.k,y:(y-k.y)/k.k}},[]),m=_.useCallback((w,y)=>{const k=p.current.get(w);if(!k)return!1;const N=k.width||200,F=k.height||100;return k.x<y.x+y.width&&k.x+N>y.x&&k.y<y.y+y.height&&k.y+F>y.y},[]),x=_.useCallback(w=>{if(n||w.target.closest("[data-qmap-node]"))return;w.preventDefault();const k=g(w.clientX,w.clientY);d.current=k,a({x:k.x,y:k.y,width:0,height:0}),c(!0),w.shiftKey||o(new Set)},[n,g]),v=_.useCallback(w=>{if(!u||!d.current)return;const y=d.current,k=g(w.clientX,w.clientY),N={x:Math.min(y.x,k.x),y:Math.min(y.y,k.y),width:Math.abs(k.x-y.x),height:Math.abs(k.y-y.y)};a(N);const F=new Set;for(const[T]of p.current)m(T,N)&&F.add(T);o(F)},[u,g,m]),b=_.useCallback(()=>{u&&(s==null||s(Array.from(i)),c(!1),a(null),d.current=null)},[u,i,s]);_.useEffect(()=>{if(!u)return;const w=k=>{v(k)},y=()=>{b()};return window.addEventListener("mousemove",w),window.addEventListener("mouseup",y),()=>{window.removeEventListener("mousemove",w),window.removeEventListener("mouseup",y)}},[u,v,b]);const C=_.useCallback((w,y=!1)=>{o(k=>{const N=new Set(y?k:[]);return k.has(w)&&y?N.delete(w):N.add(w),s==null||s(Array.from(N)),N})},[s]),S=_.useCallback(()=>{const w=new Set(p.current.keys());o(w),s==null||s(Array.from(w))},[s]),D=_.useCallback(()=>{o(new Set),s==null||s([])},[s]);return{selectedIds:i,setSelectedIds:o,selectionBox:l,isSelecting:u,startSelection:x,updateSelection:v,endSelection:b,toggleSelect:C,selectAll:S,clearSelection:D}}const vd=_.memo(function({nodeId:e,position:t,isSelected:n,isDragging:s,draggable:i,onDragStart:o,onClick:l,onDoubleClick:a,onContextMenu:u,children:c}){const d=_.useCallback(b=>{i&&b.button===0&&o(e,b)},[e,i,o]),f=_.useCallback(b=>{s||l==null||l(b)},[s,l]),p=_.useCallback(b=>{b.stopPropagation(),a==null||a(b)},[a]),g=_.useCallback(b=>{b.preventDefault(),b.stopPropagation(),u==null||u(b)},[u]),m=t.width||200,x=t.height||100,v=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:v!==0?`rotate(${v}deg)`:void 0,transformOrigin:"center center",cursor:i?s?"grabbing":"grab":"pointer",userSelect:"none",outline:n?"2px solid #3b82f6":void 0,outlineOffset:"2px",opacity:s?.8:1,zIndex:s?1e3:n?100:1,WebkitUserSelect:"none",MozUserSelect:"none",msUserSelect:"none"},onMouseDown:d,onClick:f,onDoubleClick:p,onContextMenu:g,children:c})},(r,e)=>r.nodeId===e.nodeId&&r.position.x===e.position.x&&r.position.y===e.position.y&&r.position.width===e.position.width&&r.position.height===e.position.height&&r.position.rotation===e.position.rotation&&r.isSelected===e.isSelected&&r.isDragging===e.isDragging&&r.draggable===e.draggable&&r.children===e.children);function wd(r,e,t="bezier"){const n=Vn(r),s=Vn(e),i=Ao(r,s),o=Ao(e,n);switch(t){case"straight":return`M ${i.x} ${i.y} L ${o.x} ${o.y}`;case"orthogonal":return fy(i,o);case"bezier":default:return dy(i,o)}}function dy(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 fy(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 Vn(r){const e=r.width||200,t=r.height||100;return{x:r.x+e/2,y:r.y+t/2}}function Ao(r,e){const t=r.width||200,n=r.height||100,s=Vn(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 hy(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 Vn(r)}}function py(r,e){return r.x>=e.x&&r.x<=e.x+e.width&&r.y>=e.y&&r.y<=e.y+e.height}function gy(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 my(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 yy(r,e){const t=e.x-r.x,n=e.y-r.y;return Math.sqrt(t*t+n*n)}function xy(r,e){const t=e.x-r.x,n=e.y-r.y;return t*t+n*n}const Cd=_.memo(function({edge:e,sourcePosition:t,targetPosition:n,style:s,color:i,width:o,onClick:l}){const[a,u]=_.useState(!1),c=_.useMemo(()=>wd(t,n,s),[t,n,s]),d=_.useCallback(x=>{x.stopPropagation(),l==null||l(e,x)},[e,l]),f=_.useCallback(()=>{u(!0)},[]),p=_.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(by,{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 by({pathD:r,label:e,color:t}){const n=_.useMemo(()=>`edge-label-${Math.random().toString(36).substr(2,9)}`,[]);return h.jsxs(h.Fragment,{children:[h.jsx("defs",{children:h.jsx("path",{id:n,d:r})}),h.jsx("text",{fill:t,fontSize:"12",fontFamily:"system-ui, sans-serif",style:{pointerEvents:"none"},children:h.jsx("textPath",{href:`#${n}`,startOffset:"50%",textAnchor:"middle",children:e})})]})}const Sd=_.memo(function({edges:e,nodePositions:t,defaultStyle:n,defaultColor:s,defaultWidth:i,onEdgeClick:o}){const l=_.useMemo(()=>e.filter(u=>t.has(u.source)&&t.has(u.target)),[e,t]),a=_.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(Cd,{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=_.memo(function({box:e,transform:t}){const n=_.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}})}),_y=200,vy=100,wy="bezier",Cy="#94a3b8",Sy=2,Ey=.1,ky=4;function Dy({viewNode:r,nodes:e,edges:t,renderNode:n,defaultNodeWidth:s=_y,defaultNodeHeight:i=vy,onNodeMove:o,onNodeClick:l,onNodeDoubleClick:a,onNodeContextMenu:u,onSelectionChange:c,onEdgeClick:d,onViewChange:f,onTransformChange:p,minZoom:g=Ey,maxZoom:m=ky,initialTransform:x,defaultEdgeStyle:v=wy,defaultEdgeColor:b=Cy,defaultEdgeWidth:C=Sy,draggable:S=!0,selectable:D=!0,zoomable:w=!0,pannable:y=!0,className:k="",style:N,background:F="#f8fafc",showGrid:T=!1,gridSize:M=20}){const L=r.data||{positions:{}},E=L.positions||{},B=_.useMemo(()=>{const ue=new Map;for(const _e of e){const Te=E[_e._id]||{x:0,y:0};ue.set(_e._id,{x:Te.x,y:Te.y,width:Te.width||s,height:Te.height||i,rotation:Te.rotation||0})}return ue},[e,E,s,i]),{transform:R,containerRef:O,zoomIn:H,zoomOut:U,resetZoom:Z,fitToContent:q}=xd({minZoom:g,maxZoom:m,initialTransform:x||L.transform,zoomable:w,pannable:y,onTransformChange:ue=>{p==null||p(ue);const _e={...L,transform:ue};f==null||f(_e)}}),[K,$]=_.useState(new Map),{draggedNodeId:re,startDrag:ae}=bd({transform:R,disabled:!S,onDragStart:ue=>{const _e=B.get(ue);_e&&$(new Map([[ue,{x:_e.x,y:_e.y}]]))},onDragMove:(ue,_e,Te)=>{$(new Map([[ue,{x:_e,y:Te}]]))},onDragEnd:(ue,_e,Te)=>{$(new Map),o==null||o(ue,_e,Te)}}),{selectedIds:le,selectionBox:ce,isSelecting:ve,startSelection:pe,toggleSelect:Fe,clearSelection:et}=_d({transform:R,nodePositions:B,disabled:!D,onSelectionChange:c}),ct=_.useCallback(ue=>{const _e=B.get(ue)||{x:0,y:0,width:s,height:i},Te=K.get(ue);return Te?{..._e,x:Te.x,y:Te.y}:_e},[B,K,s,i]),kt=_.useMemo(()=>{const ue=new Map;for(const _e of B.keys())ue.set(_e,ct(_e));return ue},[B,ct]),tt=_.useCallback((ue,_e)=>{Fe(ue._id,_e.shiftKey),l==null||l(ue,_e)},[Fe,l]),xt=_.useCallback(ue=>{ue.target.closest("[data-qmap-node]")||et()},[et]),dt=_.useCallback(ue=>{ue.button===0&&(ue.target.closest("[data-qmap-node]")||pe(ue))},[pe]),It=T?`
186
186
  linear-gradient(to right, rgba(0,0,0,0.05) 1px, transparent 1px),
package/dist/index.esm.js CHANGED
@@ -15450,7 +15450,7 @@ function Ry({
15450
15450
  const w = (y) => {
15451
15451
  i && i(y), g(!1), f("");
15452
15452
  }, C = () => {
15453
- o && o(), g(!1);
15453
+ o && o(d.trim() || void 0), g(!1), f("");
15454
15454
  }, S = () => {
15455
15455
  g(!0);
15456
15456
  }, v = (y) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qwanyx/stack",
3
- "version": "0.2.69",
3
+ "version": "0.2.70",
4
4
  "description": "Modern HyperCard for React - All-in-one data management (REST + Graph API + Auth + Hooks + UI)",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.esm.js",