@qwanyx/stack 0.2.50 → 0.2.52

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs.js CHANGED
@@ -150,4 +150,4 @@ React keys must be passed directly to JSX without using spread:
150
150
  from { transform: rotate(0deg); }
151
151
  to { transform: rotate(360deg); }
152
152
  }
153
- `})]})}const cf={background:"#ffffff",text:"#111827",textSecondary:"#6b7280",border:"#e5e7eb",primary:"#3b82f6",chipBackground:"#f3f4f6",chipText:"#374151",hoverBackground:"#f9fafb"};function df({options:r,value:e,onChange:t,placeholder:n="Search or select...",allowCreate:s=!0,onCreate:o,allowDelete:i=!1,onDelete:l,label:a,disabled:u=!1,max:c=0,theme:d={},className:f=""}){const h={...cf,...d},[g,m]=w.useState(!1),[b,C]=w.useState(""),v=w.useRef(null),E=w.useRef(null);w.useEffect(()=>{function B(N){v.current&&!v.current.contains(N.target)&&(m(!1),C(""))}return document.addEventListener("mousedown",B),()=>document.removeEventListener("mousedown",B)},[]);const D=r.filter(B=>{var N;return((N=B.label)==null?void 0:N.toLowerCase().includes(b.toLowerCase()))&&!e.includes(B.id)}),k=s&&b.trim()&&!r.some(B=>{var N;return((N=B.label)==null?void 0:N.toLowerCase())===b.toLowerCase()}),y=e.map(B=>r.find(N=>N.id===B)).filter(Boolean),_=w.useCallback(B=>{var N;c>0&&e.length>=c||(t([...e,B]),C(""),(N=E.current)==null||N.focus())},[e,t,c]),S=w.useCallback(B=>{t(e.filter(N=>N!==B))},[e,t]),A=w.useCallback(async()=>{if(!k)return;const B=await(o==null?void 0:o(b.trim()));B&&_(B.id),C("")},[k,b,o,_]),I=w.useCallback(B=>{B.key==="Enter"?(B.preventDefault(),k?A():D.length>0&&_(D[0].id)):B.key==="Backspace"&&!b&&e.length>0?S(e[e.length-1]):B.key==="Escape"&&(m(!1),C(""))},[k,D,b,e,A,_,S]);return p.jsxs("div",{ref:v,className:f,style:{position:"relative"},children:[a&&p.jsx("label",{style:{display:"block",fontSize:"12px",textTransform:"uppercase",color:h.textSecondary,marginBottom:"4px"},children:a}),p.jsxs("div",{onClick:()=>!u&&m(!0),style:{display:"flex",flexWrap:"wrap",gap:"6px",padding:"8px 12px",border:`1px solid ${g?h.primary:h.border}`,borderRadius:"8px",background:u?h.hoverBackground:h.background,cursor:u?"not-allowed":"text",minHeight:"42px",alignItems:"center"},children:[y.map(B=>p.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"2px 8px",borderRadius:"4px",fontSize:"13px",background:B.color||h.chipBackground,color:B.color?"#fff":h.chipText},children:[B.label,!u&&p.jsx("button",{type:"button",onClick:N=>{N.stopPropagation(),S(B.id)},style:{border:"none",background:"transparent",cursor:"pointer",padding:"0 2px",fontSize:"14px",color:"inherit",opacity:.7},children:"×"})]},B.id)),p.jsx("input",{ref:E,type:"text",value:b,onChange:B=>{C(B.target.value),g||m(!0)},onFocus:()=>m(!0),onKeyDown:I,placeholder:y.length===0?n:"",disabled:u||c>0&&e.length>=c,style:{flex:1,minWidth:"60px",border:"none",outline:"none",fontSize:"14px",background:"transparent",color:h.text}})]}),g&&!u&&p.jsx("div",{style:{position:"absolute",top:"100%",left:0,right:0,marginTop:"4px",background:h.background,border:`1px solid ${h.border}`,borderRadius:"8px",boxShadow:"0 4px 12px rgba(0,0,0,0.1)",maxHeight:"200px",overflowY:"auto",zIndex:50},children:D.length===0&&!k?p.jsx("div",{style:{padding:"12px",fontSize:"14px",color:h.textSecondary,textAlign:"center"},children:b?"No matches":"No options available"}):p.jsxs(p.Fragment,{children:[D.map(B=>p.jsxs("div",{onClick:()=>_(B.id),style:{padding:"10px 12px",fontSize:"14px",cursor:"pointer",color:h.text,display:"flex",alignItems:"center",justifyContent:"space-between"},onMouseEnter:N=>{N.currentTarget.style.background=h.hoverBackground||""},onMouseLeave:N=>{N.currentTarget.style.background=""},children:[B.label,i&&l&&p.jsx("button",{type:"button",onClick:N=>{N.stopPropagation(),l(B.id)},style:{border:"none",background:"transparent",cursor:"pointer",padding:"2px",fontSize:"14px",color:h.textSecondary,opacity:.5},onMouseEnter:N=>{N.currentTarget.style.opacity="1",N.currentTarget.style.color="#ef4444"},onMouseLeave:N=>{N.currentTarget.style.opacity="0.5",N.currentTarget.style.color=h.textSecondary||""},children:"×"})]},B.id)),k&&p.jsxs("div",{onClick:A,style:{padding:"10px 12px",fontSize:"14px",cursor:"pointer",color:h.primary,borderTop:D.length>0?`1px solid ${h.border}`:"none"},onMouseEnter:B=>{B.currentTarget.style.background=h.hoverBackground||""},onMouseLeave:B=>{B.currentTarget.style.background=""},children:['+ Create "',b.trim(),'"']})]})})]})}function ff({items:r,columns:e,getItemId:t,getItemColumn:n,getItemOrder:s,renderItem:o,onItemMove:i,onItemReorder:l,onItemClick:a,renderColumnHeader:u,renderColumnFooter:c,className:d="",columnClassName:f="",itemClassName:h=""}){const[g,m]=w.useState(null),[b,C]=w.useState(null),[v,E]=w.useState(null),D=w.useRef(null),k=e.reduce((N,j)=>{let L=r.filter($=>n($)===j.id);return s&&(L=L.sort(($,X)=>s($)-s(X))),N[j.id]=L,N},{}),y=w.useCallback((N,j)=>{const L=t(j),$=n(j);m(L),D.current=$,N.dataTransfer.effectAllowed="move",N.dataTransfer.setData("text/plain",L),requestAnimationFrame(()=>{const X=N.target;X.style.opacity="0.5"})},[t,n]),_=w.useCallback(N=>{const j=N.target;j.style.opacity="1",m(null),C(null),E(null),D.current=null},[]),S=w.useCallback((N,j,L)=>{N.preventDefault(),N.dataTransfer.dropEffect="move",C(j),E(L)},[]),A=w.useCallback(N=>{const j=N.relatedTarget;j!=null&&j.closest("[data-kanban-column]")||(C(null),E(null))},[]),I=w.useCallback((N,j,L)=>{if(N.preventDefault(),!g)return;const $=D.current;$===j?l==null||l(g,j,L):$&&i(g,$,j,L),m(null),C(null),E(null),D.current=null},[g,i,l]),B=(N,j)=>p.jsxs("div",{className:"flex items-center justify-between px-3 py-2",children:[p.jsxs("div",{className:"flex items-center gap-2",children:[N.color&&p.jsx("div",{className:"w-2 h-2 rounded-full",style:{backgroundColor:N.color}}),p.jsx("span",{className:"font-medium text-sm text-neutral-700",children:N.label})]}),p.jsx("span",{className:"text-xs text-neutral-400 bg-neutral-100 px-2 py-0.5 rounded-full",children:j})]});return p.jsx("div",{className:`flex gap-4 overflow-x-auto pb-4 ${d}`,style:{minHeight:"400px"},children:e.map(N=>{const j=k[N.id]||[],L=b===N.id;return p.jsxs("div",{"data-kanban-column":N.id,className:`flex-1 min-w-[180px] bg-neutral-50 rounded-xl flex flex-col ${f}`,onDragOver:$=>{$.preventDefault(),g&&!L&&C(N.id)},onDragLeave:A,onDrop:$=>I($,N.id,v??j.length),children:[p.jsx("div",{className:"flex-shrink-0 border-b border-neutral-200",children:u?u(N,j.length):B(N,j.length)}),p.jsxs("div",{className:`flex-1 overflow-y-auto p-2 space-y-2 min-h-[100px] transition-colors ${L?"bg-blue-50":""}`,children:[j.map(($,X)=>{const ce=t($),ve=g===ce,le=L&&v===X&&!ve;return p.jsxs("div",{children:[le&&p.jsx("div",{className:"h-1 bg-blue-500 rounded-full mb-2 mx-1"}),p.jsx("div",{draggable:!0,onDragStart:Le=>y(Le,$),onDragEnd:_,onDragOver:Le=>S(Le,N.id,X),onClick:()=>a==null?void 0:a($),className:`cursor-grab active:cursor-grabbing transition-all ${ve?"opacity-50 scale-95":""} ${h}`,children:o($,ve)})]},ce)}),p.jsx("div",{className:"min-h-[40px] flex-1",onDragOver:$=>{$.preventDefault(),S($,N.id,j.length)},children:L&&v===j.length&&p.jsx("div",{className:"h-1 bg-blue-500 rounded-full mx-1 mt-1"})}),j.length===0&&L&&p.jsx("div",{className:"h-20 border-2 border-dashed border-blue-300 rounded-lg bg-blue-50/50 flex items-center justify-center",children:p.jsx("span",{className:"text-sm text-blue-400",children:"Drop here"})})]}),c&&p.jsx("div",{className:"flex-shrink-0 border-t border-neutral-200 p-2",children:c(N)})]},N.id)})})}const hf={background:"#ffffff",hourLineColor:"#e5e7eb",halfHourLineColor:"#f3f4f6",hourTextColor:"#9ca3af",currentTimeColor:"#ef4444",allDayBackground:"#f9fafb",allDayBorder:"#e5e7eb"};function pf(r){const e=r.match(/^(\d{1,2}):(\d{2})$/);return e?{hours:parseInt(e[1],10),minutes:parseInt(e[2],10)}:null}function gf(r){const e=r%12||12,t=r<12?"AM":"PM";return`${e} ${t}`}function mf(r){const e=new Date;return r.getDate()===e.getDate()&&r.getMonth()===e.getMonth()&&r.getFullYear()===e.getFullYear()}function yf({items:r,date:e,startHour:t=7,endHour:n=22,hourHeight:s=60,getItemTime:o,getItemDuration:i,getItemIsAllDay:l,getItemId:a,renderItem:u,onItemClick:c,onTimeSlotClick:d,showCurrentTime:f=!0,className:h="",theme:g={}}){const m={...hf,...g},{allDayItems:b,timedItems:C}=w.useMemo(()=>{const _=[],S=[];for(const A of r)l(A)?_.push(A):S.push(A);return{allDayItems:_,timedItems:S}},[r,l]),v=w.useMemo(()=>{const _=[];for(let S=t;S<=n;S++)_.push(S);return _},[t,n]),E=(n-t+1)*s,D=w.useCallback(_=>{const S=o(_);if(!S)return null;const A=pf(S);if(!A)return null;const{hours:I,minutes:B}=A,N=Math.max(t,Math.min(n,I)),j=I<t?0:B,L=(N-t)*s+j/60*s,$=i(_),X=Math.max(20,$/60*s);return{top:L,height:X}},[o,i,t,n,s]),k=w.useMemo(()=>{if(!f||!mf(e))return null;const _=new Date,S=_.getHours(),A=_.getMinutes();return S<t||S>n?null:(S-t)*s+A/60*s},[e,f,t,n,s]),y=w.useCallback(_=>{if(!d)return;const S=_.currentTarget.getBoundingClientRect(),I=(_.clientY-S.top)/s*60,B=Math.floor(I/60)+t,N=Math.round(I%60/15)*15,j=Math.min(n,Math.max(t,B)),L=N>=60?0:N,$=`${j.toString().padStart(2,"0")}:${L.toString().padStart(2,"0")}`;d($)},[d,s,t,n]);return p.jsxs("div",{className:h,style:{background:m.background},children:[b.length>0&&p.jsxs("div",{style:{padding:"8px 0 8px 60px",borderBottom:`1px solid ${m.allDayBorder}`,background:m.allDayBackground},children:[p.jsx("div",{style:{fontSize:"11px",color:m.hourTextColor,marginBottom:"4px",textTransform:"uppercase",letterSpacing:"0.05em"},children:"All Day"}),p.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"4px"},children:b.map(_=>p.jsx("div",{onClick:()=>c==null?void 0:c(_),style:{cursor:c?"pointer":"default"},children:u(_)},a(_)))})]}),p.jsxs("div",{style:{position:"relative",height:E},children:[v.map((_,S)=>p.jsxs("div",{style:{position:"absolute",top:S*s,left:0,right:0},children:[p.jsx("div",{style:{position:"absolute",left:0,top:-8,width:"50px",textAlign:"right",paddingRight:"10px",fontSize:"11px",color:m.hourTextColor},children:gf(_)}),p.jsx("div",{style:{position:"absolute",left:"60px",right:0,top:0,height:"1px",background:m.hourLineColor}}),S<v.length-1&&p.jsx("div",{style:{position:"absolute",left:"60px",right:0,top:s/2,height:"1px",background:m.halfHourLineColor}})]},_)),p.jsx("div",{style:{position:"absolute",left:"60px",right:0,top:0,bottom:0,cursor:d?"pointer":"default"},onClick:y}),k!==null&&p.jsxs("div",{style:{position:"absolute",left:"55px",right:0,top:k,zIndex:20,pointerEvents:"none"},children:[p.jsx("div",{style:{width:"10px",height:"10px",borderRadius:"50%",background:m.currentTimeColor,marginLeft:"-5px",marginTop:"-5px",position:"absolute"}}),p.jsx("div",{style:{marginLeft:"5px",height:"2px",background:m.currentTimeColor}})]}),C.map(_=>{const S=D(_);return S?p.jsx("div",{style:{position:"absolute",left:"64px",right:"8px",top:S.top,height:S.height,zIndex:10,cursor:c?"pointer":"default"},onClick:A=>{A.stopPropagation(),c==null||c(_)},children:u(_)},a(_)):null})]})]})}function xf({onComplete:r,onCancel:e,onTranscribe:t,onTranscriptionComplete:n,variant:s="widget",hideSaveButton:o=!1,maxDuration:i=180}){const l=s==="widget",[a,u]=w.useState("idle"),[c,d]=w.useState(0),[f,h]=w.useState(0),[g,m]=w.useState(!1),[b,C]=w.useState(0),[v,E]=w.useState(null),[D,k]=w.useState(!1),[y,_]=w.useState(null),[S,A]=w.useState(!1),[I,B]=w.useState([]),[N,j]=w.useState({completed:0,total:0}),L=w.useRef(!1),$=w.useRef(!1);w.useEffect(()=>{$.current=S},[S]);const X=w.useRef(null),ce=w.useRef(null),ve=w.useRef(null),le=w.useRef(null),Le=w.useRef(null),me=w.useRef([]),he=w.useRef(null),ye=w.useRef(null),xe=w.useRef(null),Se=w.useRef(null),pe=w.useRef(!1),Ce=w.useRef([]),Ne=w.useRef(null),ae=w.useRef(null),Re=w.useRef([]),ot=w.useRef([]),St=w.useRef("insert"),Mt=w.useRef(!1),tt=w.useRef(0),pt=w.useRef(0),ct=w.useRef(0),Ht=q=>{const T=Math.floor(q/60),H=Math.floor(q%60);return`${T.toString().padStart(2,"0")}:${H.toString().padStart(2,"0")}`},It=async q=>{const T=await q.arrayBuffer(),H=new AudioContext,Q=await H.decodeAudioData(T);return await H.close(),Q},Et=q=>{const T=q.numberOfChannels,H=q.sampleRate,Q=1,O=16,re=O/8,Z=T*re,ee=H*Z,de=q.length*Z,De=new ArrayBuffer(44+de),te=new DataView(De),ne=(Te,be)=>{for(let He=0;He<be.length;He++)te.setUint8(Te+He,be.charCodeAt(He))};ne(0,"RIFF"),te.setUint32(4,36+de,!0),ne(8,"WAVE"),ne(12,"fmt "),te.setUint32(16,16,!0),te.setUint16(20,Q,!0),te.setUint16(22,T,!0),te.setUint32(24,H,!0),te.setUint32(28,ee,!0),te.setUint16(32,Z,!0),te.setUint16(34,O,!0),ne(36,"data"),te.setUint32(40,de,!0);const Ie=[];for(let Te=0;Te<T;Te++)Ie.push(q.getChannelData(Te));let qe=44;for(let Te=0;Te<q.length;Te++)for(let be=0;be<T;be++){const He=Math.max(-1,Math.min(1,Ie[be][Te])),Je=He<0?He*32768:He*32767;te.setInt16(qe,Je,!0),qe+=2}return new Blob([De],{type:"audio/wav"})},kt=async(q,T,H,Q)=>{const O=new AudioContext,re=q.sampleRate,Z=Math.max(q.numberOfChannels,T.numberOfChannels),ee=Math.min(H,q.length),de=Math.max(0,q.length-H),De=Q==="insert"?ee+T.length+de:ee+T.length,te=O.createBuffer(Z,De,re);for(let ne=0;ne<Z;ne++){const Ie=te.getChannelData(ne),qe=ne<q.numberOfChannels?q.getChannelData(ne):q.getChannelData(0);for(let be=0;be<ee;be++)Ie[be]=qe[be];const Te=ne<T.numberOfChannels?T.getChannelData(ne):T.getChannelData(0);for(let be=0;be<T.length;be++)Ie[ee+be]=Te[be];if(Q==="insert")for(let be=0;be<de;be++)Ie[ee+T.length+be]=qe[H+be]}return await O.close(),te},lt=w.useCallback(()=>{const q=X.current;if(!q)return;const T=q.getContext("2d");if(!T)return;const H=q.getBoundingClientRect(),Q=H.width,O=H.height,re=Ce.current,Z=f||c||1,ee=a==="recording"?c:b;T.fillStyle="#2d3b35",T.fillRect(0,0,Q,O);const de=8,De="rgba(0, 0, 0, 0.4)",te=T.createLinearGradient(0,0,0,de);te.addColorStop(0,De),te.addColorStop(1,"transparent"),T.fillStyle=te,T.fillRect(0,0,Q,de);const ne=T.createLinearGradient(0,O-de,0,O);ne.addColorStop(0,"transparent"),ne.addColorStop(1,De),T.fillStyle=ne,T.fillRect(0,O-de,Q,de);const Ie=T.createLinearGradient(0,0,de,0);Ie.addColorStop(0,De),Ie.addColorStop(1,"transparent"),T.fillStyle=Ie,T.fillRect(0,0,de,O);const qe=T.createLinearGradient(Q-de,0,Q,0);qe.addColorStop(0,"transparent"),qe.addColorStop(1,De),T.fillStyle=qe,T.fillRect(Q-de,0,de,O),T.strokeStyle="#5a6b62",T.lineWidth=1,T.beginPath(),T.moveTo(0,O/2),T.lineTo(Q,O/2),T.stroke();const Te=Q/2;if(re.length>0)if(a==="recording")for(let Je=0;Je<re.length;Je++){const dt=re.length-1-Je,zt=Te-dt*4;if(zt<-3||zt>Q)continue;const yt=re[Je]*(O/2-12),x=O/2-yt;T.fillStyle="#10b981",T.fillRect(zt,x,3,yt*2)}else{const Je=Z>0?ee/Z*re.length:0;for(let dt=0;dt<re.length;dt++){const zt=Je-dt,yt=Te-zt*4;if(yt<-3||yt>Q)continue;const x=re[dt]*(O/2-12),R=O/2-x;T.fillStyle=dt<=Je?"#10b981":"#4b5563",T.fillRect(yt,R,3,x*2)}}T.strokeStyle="#ef4444",T.lineWidth=1,T.beginPath(),T.moveTo(Te,0),T.lineTo(Te,O),T.stroke(),T.fillStyle="#fff",T.font="bold 18px monospace",T.textAlign="center",T.fillText(Ht(ee),Te,O-6),a==="recording"&&(T.fillStyle="#ef4444",T.beginPath(),T.arc(20,20,8,0,Math.PI*2),T.fill(),T.fillStyle="#fff",T.font="10px sans-serif",T.textAlign="left",T.fillText("REC",34,24)),T.textAlign="left"},[a,b,c,f]),gt=()=>{const q=Le.current;if(!q||!pe.current)return;const T=q.frequencyBinCount,H=new Uint8Array(T);q.getByteTimeDomainData(H);let Q=0;for(let Z=0;Z<T;Z++){const ee=(H[Z]-128)/128;Q+=ee*ee}const O=Math.sqrt(Q/T),re=Math.min(1,O*3);Ce.current.push(re),lt(),pe.current&&(ye.current=requestAnimationFrame(gt))},W=async()=>{try{E(null),k(!1),Ne.current===null&&(Ce.current=[]);const q=await navigator.mediaDevices.getUserMedia({audio:!0});ve.current=q;const T=new AudioContext;le.current=T;const H=T.createAnalyser();H.fftSize=2048,Le.current=H,T.createMediaStreamSource(q).connect(H);const O=new MediaRecorder(q);ce.current=O,me.current=[],O.ondataavailable=re=>{re.data.size>0&&me.current.push(re.data)},O.onstop=async()=>{try{if(pe.current=!1,me.current.length===0){E("No audio was recorded. Please try again."),u("idle"),q.getTracks().forEach(te=>te.stop());return}const re=new Blob(me.current,{type:"audio/webm"});let Z,ee;if(Ne.current!==null&&ae.current)try{const te=await It(re),ne=ae.current.sampleRate,Ie=Math.floor(Ne.current*ne),qe=await kt(ae.current,te,Ie,St.current);Z=Et(qe),ee=qe.length/qe.sampleRate,St.current==="insert"&&(Ce.current=[...Ce.current,...ot.current]),Ne.current=null,ae.current=null,Re.current=[],ot.current=[]}catch{Z=re,ee=tt.current>0?tt.current:1}else Z=re,ee=tt.current>0?tt.current:1;if(Se.current=Z,q.getTracks().forEach(te=>te.stop()),$.current&&t){B(te=>[...te,Z]),j(te=>({...te,total:te.total+1})),Se.current=null,Ce.current=[],C(0),h(0),d(0),u("idle");return}const de=URL.createObjectURL(Z),De=new Audio(de);De.ontimeupdate=()=>{C(De.currentTime)},De.onended=()=>{m(!1)},xe.current=De,h(ee),C(ee),u("editing")}catch{E("Failed to process recording"),u("idle")}},O.start(100),pe.current=!0,u("recording"),d(0),tt.current=0,he.current=setInterval(()=>{tt.current+=1,d(tt.current),tt.current>=i&&(ce.current&&ce.current.state!=="inactive"&&ce.current.stop(),pe.current=!1,_(null),he.current&&(clearInterval(he.current),he.current=null),ye.current&&(cancelAnimationFrame(ye.current),ye.current=null),setTimeout(()=>{alert(`Maximum recording time of ${Math.floor(i/60)} minutes reached.`)},100))},1e3)}catch{E("Could not access microphone. Please allow microphone access.")}},we=()=>{pe.current=!1,k(!1),_(null),ye.current&&(cancelAnimationFrame(ye.current),ye.current=null),he.current&&(clearInterval(he.current),he.current=null),ce.current&&ce.current.state!=="inactive"&&ce.current.stop()},ke=q=>{const T=X.current;if(!T)return;const H=f||c;if(H<=0)return;const Q=Ce.current;if(Q.length===0)return;const O=T.getBoundingClientRect(),re=q-pt.current,Z=4,ee=O.width/T.width,de=Q.length/H*Z,De=-re/(de*ee),te=ct.current+De,ne=Math.max(0,Math.min(te,H));xe.current&&(xe.current.currentTime=ne),C(ne)},Ee=()=>{xe.current&&(xe.current.currentTime=0),C(0)},At=()=>{const q=f||c;xe.current&&(xe.current.currentTime=q),C(q)},Tt=()=>{const q=xe.current;q&&(g?(q.pause(),C(q.currentTime),m(!1)):(q.currentTime=b,q.play().catch(()=>{}),m(!0)))},$t=async q=>{if(!Se.current){W();return}try{xe.current&&(xe.current.pause(),m(!1)),St.current=q,ae.current=await It(Se.current);const T=f||c;Ne.current=b;const H=T>0?b/T:0,Q=Math.floor(H*Ce.current.length);Re.current=Ce.current.slice(0,Q),ot.current=Ce.current.slice(Q),Ce.current=[...Re.current],W()}catch{E("Failed to prepare recording. Please try again.")}},K=()=>{xe.current&&(xe.current.pause(),xe.current=null),Se.current=null,ae.current=null,Ne.current=null,Re.current=[],m(!1),C(0),h(0),d(0),W()},J=()=>{Se.current?r(Se.current,f||c):alert("No audio recorded yet!")};w.useEffect(()=>{a==="recording"&&X.current&&Le.current&&pe.current&&(ye.current=requestAnimationFrame(gt))},[a]),w.useEffect(()=>{const q=X.current;if(!q)return;const T=()=>{const H=window.devicePixelRatio||1,Q=q.getBoundingClientRect();q.width=Q.width*H,q.height=Q.height*H;const O=q.getContext("2d");O&&O.scale(H,H)};return T(),window.addEventListener("resize",T),()=>window.removeEventListener("resize",T)},[]),w.useEffect(()=>{if(a==="idle"){const q=X.current;if(!q)return;const T=q.getContext("2d");if(!T)return;const H=q.getBoundingClientRect(),Q=H.width,O=H.height;T.fillStyle="#2d3b35",T.fillRect(0,0,Q,O);const re=8,Z="rgba(0, 0, 0, 0.4)",ee=T.createLinearGradient(0,0,0,re);ee.addColorStop(0,Z),ee.addColorStop(1,"transparent"),T.fillStyle=ee,T.fillRect(0,0,Q,re);const de=T.createLinearGradient(0,O-re,0,O);de.addColorStop(0,"transparent"),de.addColorStop(1,Z),T.fillStyle=de,T.fillRect(0,O-re,Q,re);const De=T.createLinearGradient(0,0,re,0);De.addColorStop(0,Z),De.addColorStop(1,"transparent"),T.fillStyle=De,T.fillRect(0,0,re,O);const te=T.createLinearGradient(Q-re,0,Q,0);te.addColorStop(0,"transparent"),te.addColorStop(1,Z),T.fillStyle=te,T.fillRect(Q-re,0,re,O),T.strokeStyle="#5a6b62",T.lineWidth=1,T.beginPath(),T.moveTo(0,O/2),T.lineTo(Q,O/2),T.stroke();const ne=Q/2;T.strokeStyle="#ef4444",T.lineWidth=1,T.beginPath(),T.moveTo(ne,0),T.lineTo(ne,O),T.stroke(),T.fillStyle="#fff",T.font="bold 18px monospace",T.textAlign="center",T.fillText("00:00",ne,O-6)}},[a]);const Ae=w.useCallback(q=>{B(T=>[...T,q]),j(T=>({...T,total:T.total+1}))},[]);if(w.useEffect(()=>{(async()=>{if(L.current||I.length===0||!t)return;L.current=!0;const T=I[0];try{const H=await t(T);H&&n&&n(H)}catch(H){console.error("Transcription failed:",H)}finally{B(H=>H.slice(1)),j(H=>({...H,completed:H.completed+1})),L.current=!1}})()},[I,t,n]),w.useEffect(()=>()=>{pe.current=!1,he.current&&clearInterval(he.current),ye.current&&cancelAnimationFrame(ye.current),ve.current&&ve.current.getTracks().forEach(q=>q.stop()),le.current&&le.current.state!=="closed"&&le.current.close()},[]),w.useEffect(()=>{if(a==="editing"&&g){let q;const T=()=>{const H=xe.current;if(H&&g){const Q=X.current;if(Q){const O=Q.getContext("2d");if(O){const re=Q.getBoundingClientRect(),Z=re.width,ee=re.height,de=Ce.current,De=f||c||1,te=H.currentTime;O.fillStyle="#2d3b35",O.fillRect(0,0,Z,ee);const ne=8,Ie="rgba(0, 0, 0, 0.4)",qe=O.createLinearGradient(0,0,0,ne);qe.addColorStop(0,Ie),qe.addColorStop(1,"transparent"),O.fillStyle=qe,O.fillRect(0,0,Z,ne);const Te=O.createLinearGradient(0,ee-ne,0,ee);Te.addColorStop(0,"transparent"),Te.addColorStop(1,Ie),O.fillStyle=Te,O.fillRect(0,ee-ne,Z,ne);const be=O.createLinearGradient(0,0,ne,0);be.addColorStop(0,Ie),be.addColorStop(1,"transparent"),O.fillStyle=be,O.fillRect(0,0,ne,ee);const He=O.createLinearGradient(Z-ne,0,Z,0);He.addColorStop(0,"transparent"),He.addColorStop(1,Ie),O.fillStyle=He,O.fillRect(Z-ne,0,ne,ee),O.strokeStyle="#5a6b62",O.lineWidth=1,O.beginPath(),O.moveTo(0,ee/2),O.lineTo(Z,ee/2),O.stroke();const Je=Z/2,dt=3,zt=4,yt=De>0?te/De*de.length:0;for(let U=0;U<de.length;U++){const Y=yt-U,oe=Je-Y*zt;if(oe<-dt||oe>Z)continue;const ge=de[U]*(ee/2-12),se=ee/2-ge;O.fillStyle=U<=yt?"#10b981":"#4b5563",O.fillRect(oe,se,dt,ge*2)}O.strokeStyle="#ef4444",O.lineWidth=1,O.beginPath(),O.moveTo(Je,0),O.lineTo(Je,ee),O.stroke(),O.fillStyle="#fff",O.font="bold 18px monospace",O.textAlign="center";const x=Math.floor(te/60),R=Math.floor(te%60);O.fillText(`${x.toString().padStart(2,"0")}:${R.toString().padStart(2,"0")}`,Je,ee-6),O.textAlign="left"}}q=requestAnimationFrame(T)}};return q=requestAnimationFrame(T),()=>cancelAnimationFrame(q)}},[a,g,f,c]),w.useEffect(()=>{a==="editing"&&!g&&lt()},[a,b,g,lt]),v)return p.jsxs("div",{style:{border:"1px solid #fecaca",borderRadius:"12px",padding:"16px",background:"#fef2f2"},children:[p.jsx("p",{style:{fontSize:"14px",color:"#dc2626",marginBottom:"12px"},children:v}),p.jsx("button",{onClick:()=>{E(null),W()},style:{padding:"8px 16px",fontSize:"14px",background:"#171717",color:"white",borderRadius:"8px",border:"none",cursor:"pointer"},children:"Try Again"})]});const Pe={padding:"8px",borderRadius:"8px",border:"none",background:"transparent",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",transition:"background 0.15s"},Oe={...Pe,opacity:.3,cursor:"not-allowed"},mt=l?{border:"1px solid #e5e5e5",borderRadius:"12px",overflow:"hidden",background:"white"}:{overflow:"hidden",background:"white",flexShrink:0};return p.jsxs("div",{style:mt,children:[p.jsx("canvas",{ref:X,style:{width:"100%",height:"32px",cursor:"pointer",flexShrink:0},onMouseDown:q=>{if(a==="editing"){Mt.current=!0,pt.current=q.clientX,ct.current=b;const T=Q=>{Mt.current&&ke(Q.clientX)},H=()=>{Mt.current=!1,window.removeEventListener("mousemove",T),window.removeEventListener("mouseup",H)};window.addEventListener("mousemove",T),window.addEventListener("mouseup",H)}}}),p.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:[p.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px"},children:[p.jsx("button",{onClick:Ee,disabled:a==="idle"||a==="recording",style:a==="idle"||a==="recording"?Oe:Pe,title:"Go to start",children:p.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:"#171717"},children:"first_page"})}),p.jsx("button",{onClick:()=>{if(a==="recording"){const q=ce.current;q&&(q.state==="recording"?(q.pause(),k(!0)):q.state==="paused"&&(q.resume(),k(!1)))}else Tt()},disabled:a==="idle",style:a==="idle"?Oe:Pe,title:g||a==="recording"&&!D?"Pause":"Play",children:p.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:"#171717"},children:g||a==="recording"&&!D?"pause":"play_arrow"})}),p.jsx("button",{onClick:At,disabled:a==="idle"||a==="recording",style:a==="idle"||a==="recording"?Oe:Pe,title:"Go to end",children:p.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:"#171717"},children:"last_page"})}),p.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))"}}),p.jsx("button",{onClick:()=>{y==="insert"?we():a==="idle"?(_("insert"),W()):a==="editing"&&(_("insert"),$t("insert"))},disabled:a==="recording"&&y!=="insert"||g,style:a==="recording"&&y!=="insert"||g?Oe:Pe,title:y==="insert"?"Stop recording":"Insert recording",children:p.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:y==="insert"?"#ef4444":"#171717"},children:"add"})}),p.jsx("button",{onClick:()=>{$.current||(y==="mic"?we():a==="idle"?(_("mic"),W()):a==="editing"&&(_("mic"),$t("replace")))},onMouseDown:()=>{$.current&&a==="idle"&&!g&&(_("mic"),W())},onMouseUp:()=>{$.current&&a==="recording"&&y==="mic"&&we()},onMouseLeave:()=>{$.current&&a==="recording"&&y==="mic"&&we()},onTouchStart:()=>{$.current&&a==="idle"&&!g&&(_("mic"),W())},onTouchEnd:()=>{$.current&&a==="recording"&&y==="mic"&&we()},disabled:a==="recording"&&y!=="mic"||g,style:a==="recording"&&y!=="mic"||g?Oe:Pe,title:S?"Hold to record (walkie-talkie)":y==="mic"?"Stop recording":"Record",children:p.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:y==="mic"?"#ef4444":"#171717"},children:"mic"})}),p.jsx("button",{onClick:()=>{y==="startover"?we():a==="editing"&&(_("startover"),K())},disabled:a==="idle"||a==="recording"&&y!=="startover"||g,style:a==="idle"||a==="recording"&&y!=="startover"||g?Oe:Pe,title:y==="startover"?"Stop recording":"Start over",children:p.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:y==="startover"?"#ef4444":"#171717"},children:"refresh"})})]}),p.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px"},children:[N.total>0&&N.completed<N.total&&p.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:[p.jsx("span",{className:"material-icons",style:{fontSize:"14px",animation:"spin 1s linear infinite"},children:"sync"}),N.completed,"/",N.total]}),t&&p.jsxs(p.Fragment,{children:[p.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px",marginRight:"4px"},children:[p.jsx("button",{onClick:()=>A(!S),style:{width:"28px",height:"16px",borderRadius:"8px",border:"none",background:S?"#10b981":"#9ca3af",cursor:"pointer",position:"relative",transition:"background 0.2s",padding:0},title:S?"Auto-transcribe ON":"Auto-transcribe OFF",children:p.jsx("div",{style:{width:"12px",height:"12px",borderRadius:"50%",background:"white",position:"absolute",top:"2px",left:S?"14px":"2px",transition:"left 0.2s",boxShadow:"0 1px 2px rgba(0,0,0,0.2)"}})}),p.jsx("span",{style:{fontSize:"10px",color:"#666"},children:"auto"})]}),p.jsx("button",{onClick:()=>{a==="editing"&&Se.current&&Ae(Se.current)},disabled:a!=="editing",style:a!=="editing"?Oe:Pe,title:"Transcribe audio",children:p.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:S?"#10b981":"#171717"},children:"subtitles"})})]}),!o&&p.jsx("button",{onClick:J,disabled:a!=="editing",style:a!=="editing"?Oe:Pe,title:"Save recording",children:p.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:"#171717"},children:"save"})})]})]}),N.total>0&&N.completed<N.total&&p.jsx("div",{style:{height:"3px",background:"#e5e5e5",overflow:"hidden"},children:p.jsx("div",{style:{height:"100%",background:"#10b981",width:`${N.completed/N.total*100}%`,transition:"width 0.3s ease"}})})]})}exports.AnimatedCardFlip=hu;exports.ApiClient=dl;exports.AudioEditor=xf;exports.AuthManager=cl;exports.Card=cu;exports.ComboBox=df;exports.DataOperations=Rn;exports.Detail=du;exports.GraphClient=Ia;exports.KanbanBoard=ff;exports.Mail=gu;exports.MailClient=ul;exports.MailComposer=uf;exports.MailEditor=ja;exports.SelectableList=mu;exports.Stack=uu;exports.Timeline=yf;exports.getApiClient=ui;exports.initializeApiClient=iu;exports.useMutation=ou;exports.useQuery=fl;
153
+ `})]})}const cf={background:"#ffffff",text:"#111827",textSecondary:"#6b7280",border:"#e5e7eb",primary:"#3b82f6",chipBackground:"#f3f4f6",chipText:"#374151",hoverBackground:"#f9fafb"};function df({options:r,value:e,onChange:t,placeholder:n="Search or select...",allowCreate:s=!0,onCreate:o,allowDelete:i=!1,onDelete:l,label:a,disabled:u=!1,max:c=0,theme:d={},className:f=""}){const h={...cf,...d},[g,m]=w.useState(!1),[b,C]=w.useState(""),v=w.useRef(null),E=w.useRef(null);w.useEffect(()=>{function B(N){v.current&&!v.current.contains(N.target)&&(m(!1),C(""))}return document.addEventListener("mousedown",B),()=>document.removeEventListener("mousedown",B)},[]);const D=r.filter(B=>{var N;return((N=B.label)==null?void 0:N.toLowerCase().includes(b.toLowerCase()))&&!e.includes(B.id)}),k=s&&b.trim()&&!r.some(B=>{var N;return((N=B.label)==null?void 0:N.toLowerCase())===b.toLowerCase()}),y=e.map(B=>r.find(N=>N.id===B)).filter(Boolean),_=w.useCallback(B=>{var N;c>0&&e.length>=c||(t([...e,B]),C(""),c===1?m(!1):(N=E.current)==null||N.focus())},[e,t,c]),S=w.useCallback(B=>{t(e.filter(N=>N!==B))},[e,t]),A=w.useCallback(async()=>{if(!k)return;const B=await(o==null?void 0:o(b.trim()));B&&_(B.id),C("")},[k,b,o,_]),I=w.useCallback(B=>{B.key==="Enter"?(B.preventDefault(),k?A():D.length>0&&_(D[0].id)):B.key==="Backspace"&&!b&&e.length>0?S(e[e.length-1]):B.key==="Escape"&&(m(!1),C(""))},[k,D,b,e,A,_,S]);return p.jsxs("div",{ref:v,className:f,style:{position:"relative"},children:[a&&p.jsx("label",{style:{display:"block",fontSize:"12px",textTransform:"uppercase",color:h.textSecondary,marginBottom:"4px"},children:a}),p.jsxs("div",{onClick:()=>!u&&m(!0),style:{display:"flex",flexWrap:"wrap",gap:"6px",padding:"8px 12px",border:`1px solid ${g?h.primary:h.border}`,borderRadius:"8px",background:u?h.hoverBackground:h.background,cursor:u?"not-allowed":"text",minHeight:"42px",alignItems:"center"},children:[y.map(B=>p.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"2px 8px",borderRadius:"4px",fontSize:"13px",background:B.color||h.chipBackground,color:B.color?"#fff":h.chipText},children:[B.label,!u&&p.jsx("button",{type:"button",onClick:N=>{N.stopPropagation(),S(B.id)},style:{border:"none",background:"transparent",cursor:"pointer",padding:"0 2px",fontSize:"14px",color:"inherit",opacity:.7},children:"×"})]},B.id)),p.jsx("input",{ref:E,type:"text",value:b,onChange:B=>{C(B.target.value),g||m(!0)},onFocus:()=>m(!0),onKeyDown:I,placeholder:y.length===0?n:"",disabled:u||c>0&&e.length>=c,style:{flex:1,minWidth:"60px",border:"none",outline:"none",fontSize:"14px",background:"transparent",color:h.text}})]}),g&&!u&&p.jsx("div",{style:{position:"absolute",top:"100%",left:0,right:0,marginTop:"4px",background:h.background,border:`1px solid ${h.border}`,borderRadius:"8px",boxShadow:"0 4px 12px rgba(0,0,0,0.1)",maxHeight:"200px",overflowY:"auto",zIndex:50},children:D.length===0&&!k?p.jsx("div",{style:{padding:"12px",fontSize:"14px",color:h.textSecondary,textAlign:"center"},children:b?"No matches":"No options available"}):p.jsxs(p.Fragment,{children:[D.map(B=>p.jsxs("div",{onClick:()=>_(B.id),style:{padding:"10px 12px",fontSize:"14px",cursor:"pointer",color:h.text,display:"flex",alignItems:"center",justifyContent:"space-between"},onMouseEnter:N=>{N.currentTarget.style.background=h.hoverBackground||""},onMouseLeave:N=>{N.currentTarget.style.background=""},children:[B.label,i&&l&&p.jsx("button",{type:"button",onClick:N=>{N.stopPropagation(),l(B.id)},style:{border:"none",background:"transparent",cursor:"pointer",padding:"2px",fontSize:"14px",color:h.textSecondary,opacity:.5},onMouseEnter:N=>{N.currentTarget.style.opacity="1",N.currentTarget.style.color="#ef4444"},onMouseLeave:N=>{N.currentTarget.style.opacity="0.5",N.currentTarget.style.color=h.textSecondary||""},children:"×"})]},B.id)),k&&p.jsxs("div",{onClick:A,style:{padding:"10px 12px",fontSize:"14px",cursor:"pointer",color:h.primary,borderTop:D.length>0?`1px solid ${h.border}`:"none"},onMouseEnter:B=>{B.currentTarget.style.background=h.hoverBackground||""},onMouseLeave:B=>{B.currentTarget.style.background=""},children:['+ Create "',b.trim(),'"']})]})})]})}function ff({items:r,columns:e,getItemId:t,getItemColumn:n,getItemOrder:s,renderItem:o,onItemMove:i,onItemReorder:l,onItemClick:a,renderColumnHeader:u,renderColumnFooter:c,className:d="",columnClassName:f="",itemClassName:h=""}){const[g,m]=w.useState(null),[b,C]=w.useState(null),[v,E]=w.useState(null),D=w.useRef(null),k=e.reduce((N,j)=>{let L=r.filter($=>n($)===j.id);return s&&(L=L.sort(($,X)=>s($)-s(X))),N[j.id]=L,N},{}),y=w.useCallback((N,j)=>{const L=t(j),$=n(j);m(L),D.current=$,N.dataTransfer.effectAllowed="move",N.dataTransfer.setData("text/plain",L),requestAnimationFrame(()=>{const X=N.target;X.style.opacity="0.5"})},[t,n]),_=w.useCallback(N=>{const j=N.target;j.style.opacity="1",m(null),C(null),E(null),D.current=null},[]),S=w.useCallback((N,j,L)=>{N.preventDefault(),N.dataTransfer.dropEffect="move",C(j),E(L)},[]),A=w.useCallback(N=>{const j=N.relatedTarget;j!=null&&j.closest("[data-kanban-column]")||(C(null),E(null))},[]),I=w.useCallback((N,j,L)=>{if(N.preventDefault(),!g)return;const $=D.current;$===j?l==null||l(g,j,L):$&&i(g,$,j,L),m(null),C(null),E(null),D.current=null},[g,i,l]),B=(N,j)=>p.jsxs("div",{className:"flex items-center justify-between px-3 py-2",children:[p.jsxs("div",{className:"flex items-center gap-2",children:[N.color&&p.jsx("div",{className:"w-2 h-2 rounded-full",style:{backgroundColor:N.color}}),p.jsx("span",{className:"font-medium text-sm text-neutral-700",children:N.label})]}),p.jsx("span",{className:"text-xs text-neutral-400 bg-neutral-100 px-2 py-0.5 rounded-full",children:j})]});return p.jsx("div",{className:`flex gap-4 overflow-x-auto pb-4 ${d}`,style:{minHeight:"400px"},children:e.map(N=>{const j=k[N.id]||[],L=b===N.id;return p.jsxs("div",{"data-kanban-column":N.id,className:`flex-1 min-w-[180px] bg-neutral-50 rounded-xl flex flex-col ${f}`,onDragOver:$=>{$.preventDefault(),g&&!L&&C(N.id)},onDragLeave:A,onDrop:$=>I($,N.id,v??j.length),children:[p.jsx("div",{className:"flex-shrink-0 border-b border-neutral-200",children:u?u(N,j.length):B(N,j.length)}),p.jsxs("div",{className:`flex-1 overflow-y-auto p-2 space-y-2 min-h-[100px] transition-colors ${L?"bg-blue-50":""}`,children:[j.map(($,X)=>{const ce=t($),ve=g===ce,le=L&&v===X&&!ve;return p.jsxs("div",{children:[le&&p.jsx("div",{className:"h-1 bg-blue-500 rounded-full mb-2 mx-1"}),p.jsx("div",{draggable:!0,onDragStart:Le=>y(Le,$),onDragEnd:_,onDragOver:Le=>S(Le,N.id,X),onClick:()=>a==null?void 0:a($),className:`cursor-grab active:cursor-grabbing transition-all ${ve?"opacity-50 scale-95":""} ${h}`,children:o($,ve)})]},ce)}),p.jsx("div",{className:"min-h-[40px] flex-1",onDragOver:$=>{$.preventDefault(),S($,N.id,j.length)},children:L&&v===j.length&&p.jsx("div",{className:"h-1 bg-blue-500 rounded-full mx-1 mt-1"})}),j.length===0&&L&&p.jsx("div",{className:"h-20 border-2 border-dashed border-blue-300 rounded-lg bg-blue-50/50 flex items-center justify-center",children:p.jsx("span",{className:"text-sm text-blue-400",children:"Drop here"})})]}),c&&p.jsx("div",{className:"flex-shrink-0 border-t border-neutral-200 p-2",children:c(N)})]},N.id)})})}const hf={background:"#ffffff",hourLineColor:"#e5e7eb",halfHourLineColor:"#f3f4f6",hourTextColor:"#9ca3af",currentTimeColor:"#ef4444",allDayBackground:"#f9fafb",allDayBorder:"#e5e7eb"};function pf(r){const e=r.match(/^(\d{1,2}):(\d{2})$/);return e?{hours:parseInt(e[1],10),minutes:parseInt(e[2],10)}:null}function gf(r){const e=r%12||12,t=r<12?"AM":"PM";return`${e} ${t}`}function mf(r){const e=new Date;return r.getDate()===e.getDate()&&r.getMonth()===e.getMonth()&&r.getFullYear()===e.getFullYear()}function yf({items:r,date:e,startHour:t=7,endHour:n=22,hourHeight:s=60,getItemTime:o,getItemDuration:i,getItemIsAllDay:l,getItemId:a,renderItem:u,onItemClick:c,onTimeSlotClick:d,showCurrentTime:f=!0,className:h="",theme:g={}}){const m={...hf,...g},{allDayItems:b,timedItems:C}=w.useMemo(()=>{const _=[],S=[];for(const A of r)l(A)?_.push(A):S.push(A);return{allDayItems:_,timedItems:S}},[r,l]),v=w.useMemo(()=>{const _=[];for(let S=t;S<=n;S++)_.push(S);return _},[t,n]),E=(n-t+1)*s,D=w.useCallback(_=>{const S=o(_);if(!S)return null;const A=pf(S);if(!A)return null;const{hours:I,minutes:B}=A,N=Math.max(t,Math.min(n,I)),j=I<t?0:B,L=(N-t)*s+j/60*s,$=i(_),X=Math.max(20,$/60*s);return{top:L,height:X}},[o,i,t,n,s]),k=w.useMemo(()=>{if(!f||!mf(e))return null;const _=new Date,S=_.getHours(),A=_.getMinutes();return S<t||S>n?null:(S-t)*s+A/60*s},[e,f,t,n,s]),y=w.useCallback(_=>{if(!d)return;const S=_.currentTarget.getBoundingClientRect(),I=(_.clientY-S.top)/s*60,B=Math.floor(I/60)+t,N=Math.round(I%60/15)*15,j=Math.min(n,Math.max(t,B)),L=N>=60?0:N,$=`${j.toString().padStart(2,"0")}:${L.toString().padStart(2,"0")}`;d($)},[d,s,t,n]);return p.jsxs("div",{className:h,style:{background:m.background},children:[b.length>0&&p.jsxs("div",{style:{padding:"8px 0 8px 60px",borderBottom:`1px solid ${m.allDayBorder}`,background:m.allDayBackground},children:[p.jsx("div",{style:{fontSize:"11px",color:m.hourTextColor,marginBottom:"4px",textTransform:"uppercase",letterSpacing:"0.05em"},children:"All Day"}),p.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"4px"},children:b.map(_=>p.jsx("div",{onClick:()=>c==null?void 0:c(_),style:{cursor:c?"pointer":"default"},children:u(_)},a(_)))})]}),p.jsxs("div",{style:{position:"relative",height:E},children:[v.map((_,S)=>p.jsxs("div",{style:{position:"absolute",top:S*s,left:0,right:0},children:[p.jsx("div",{style:{position:"absolute",left:0,top:-8,width:"50px",textAlign:"right",paddingRight:"10px",fontSize:"11px",color:m.hourTextColor},children:gf(_)}),p.jsx("div",{style:{position:"absolute",left:"60px",right:0,top:0,height:"1px",background:m.hourLineColor}}),S<v.length-1&&p.jsx("div",{style:{position:"absolute",left:"60px",right:0,top:s/2,height:"1px",background:m.halfHourLineColor}})]},_)),p.jsx("div",{style:{position:"absolute",left:"60px",right:0,top:0,bottom:0,cursor:d?"pointer":"default"},onClick:y}),k!==null&&p.jsxs("div",{style:{position:"absolute",left:"55px",right:0,top:k,zIndex:20,pointerEvents:"none"},children:[p.jsx("div",{style:{width:"10px",height:"10px",borderRadius:"50%",background:m.currentTimeColor,marginLeft:"-5px",marginTop:"-5px",position:"absolute"}}),p.jsx("div",{style:{marginLeft:"5px",height:"2px",background:m.currentTimeColor}})]}),C.map(_=>{const S=D(_);return S?p.jsx("div",{style:{position:"absolute",left:"64px",right:"8px",top:S.top,height:S.height,zIndex:10,cursor:c?"pointer":"default"},onClick:A=>{A.stopPropagation(),c==null||c(_)},children:u(_)},a(_)):null})]})]})}function xf({onComplete:r,onCancel:e,onTranscribe:t,onTranscriptionComplete:n,variant:s="widget",hideSaveButton:o=!1,maxDuration:i=180}){const l=s==="widget",[a,u]=w.useState("idle"),[c,d]=w.useState(0),[f,h]=w.useState(0),[g,m]=w.useState(!1),[b,C]=w.useState(0),[v,E]=w.useState(null),[D,k]=w.useState(!1),[y,_]=w.useState(null),[S,A]=w.useState(!0),[I,B]=w.useState([]),[N,j]=w.useState({completed:0,total:0}),L=w.useRef(!1),$=w.useRef(!0);w.useEffect(()=>{$.current=S},[S]);const X=w.useRef(null),ce=w.useRef(null),ve=w.useRef(null),le=w.useRef(null),Le=w.useRef(null),me=w.useRef([]),he=w.useRef(null),ye=w.useRef(null),xe=w.useRef(null),Se=w.useRef(null),pe=w.useRef(!1),Ce=w.useRef([]),Ne=w.useRef(null),ae=w.useRef(null),Re=w.useRef([]),ot=w.useRef([]),St=w.useRef("insert"),Mt=w.useRef(!1),tt=w.useRef(0),pt=w.useRef(0),ct=w.useRef(0),Ht=q=>{const T=Math.floor(q/60),H=Math.floor(q%60);return`${T.toString().padStart(2,"0")}:${H.toString().padStart(2,"0")}`},It=async q=>{const T=await q.arrayBuffer(),H=new AudioContext,Q=await H.decodeAudioData(T);return await H.close(),Q},Et=q=>{const T=q.numberOfChannels,H=q.sampleRate,Q=1,O=16,re=O/8,Z=T*re,ee=H*Z,de=q.length*Z,De=new ArrayBuffer(44+de),te=new DataView(De),ne=(Te,be)=>{for(let He=0;He<be.length;He++)te.setUint8(Te+He,be.charCodeAt(He))};ne(0,"RIFF"),te.setUint32(4,36+de,!0),ne(8,"WAVE"),ne(12,"fmt "),te.setUint32(16,16,!0),te.setUint16(20,Q,!0),te.setUint16(22,T,!0),te.setUint32(24,H,!0),te.setUint32(28,ee,!0),te.setUint16(32,Z,!0),te.setUint16(34,O,!0),ne(36,"data"),te.setUint32(40,de,!0);const Ie=[];for(let Te=0;Te<T;Te++)Ie.push(q.getChannelData(Te));let qe=44;for(let Te=0;Te<q.length;Te++)for(let be=0;be<T;be++){const He=Math.max(-1,Math.min(1,Ie[be][Te])),Je=He<0?He*32768:He*32767;te.setInt16(qe,Je,!0),qe+=2}return new Blob([De],{type:"audio/wav"})},kt=async(q,T,H,Q)=>{const O=new AudioContext,re=q.sampleRate,Z=Math.max(q.numberOfChannels,T.numberOfChannels),ee=Math.min(H,q.length),de=Math.max(0,q.length-H),De=Q==="insert"?ee+T.length+de:ee+T.length,te=O.createBuffer(Z,De,re);for(let ne=0;ne<Z;ne++){const Ie=te.getChannelData(ne),qe=ne<q.numberOfChannels?q.getChannelData(ne):q.getChannelData(0);for(let be=0;be<ee;be++)Ie[be]=qe[be];const Te=ne<T.numberOfChannels?T.getChannelData(ne):T.getChannelData(0);for(let be=0;be<T.length;be++)Ie[ee+be]=Te[be];if(Q==="insert")for(let be=0;be<de;be++)Ie[ee+T.length+be]=qe[H+be]}return await O.close(),te},lt=w.useCallback(()=>{const q=X.current;if(!q)return;const T=q.getContext("2d");if(!T)return;const H=q.getBoundingClientRect(),Q=H.width,O=H.height,re=Ce.current,Z=f||c||1,ee=a==="recording"?c:b;T.fillStyle="#2d3b35",T.fillRect(0,0,Q,O);const de=8,De="rgba(0, 0, 0, 0.4)",te=T.createLinearGradient(0,0,0,de);te.addColorStop(0,De),te.addColorStop(1,"transparent"),T.fillStyle=te,T.fillRect(0,0,Q,de);const ne=T.createLinearGradient(0,O-de,0,O);ne.addColorStop(0,"transparent"),ne.addColorStop(1,De),T.fillStyle=ne,T.fillRect(0,O-de,Q,de);const Ie=T.createLinearGradient(0,0,de,0);Ie.addColorStop(0,De),Ie.addColorStop(1,"transparent"),T.fillStyle=Ie,T.fillRect(0,0,de,O);const qe=T.createLinearGradient(Q-de,0,Q,0);qe.addColorStop(0,"transparent"),qe.addColorStop(1,De),T.fillStyle=qe,T.fillRect(Q-de,0,de,O),T.strokeStyle="#5a6b62",T.lineWidth=1,T.beginPath(),T.moveTo(0,O/2),T.lineTo(Q,O/2),T.stroke();const Te=Q/2;if(re.length>0)if(a==="recording")for(let Je=0;Je<re.length;Je++){const dt=re.length-1-Je,zt=Te-dt*4;if(zt<-3||zt>Q)continue;const yt=re[Je]*(O/2-12),x=O/2-yt;T.fillStyle="#10b981",T.fillRect(zt,x,3,yt*2)}else{const Je=Z>0?ee/Z*re.length:0;for(let dt=0;dt<re.length;dt++){const zt=Je-dt,yt=Te-zt*4;if(yt<-3||yt>Q)continue;const x=re[dt]*(O/2-12),R=O/2-x;T.fillStyle=dt<=Je?"#10b981":"#4b5563",T.fillRect(yt,R,3,x*2)}}T.strokeStyle="#ef4444",T.lineWidth=1,T.beginPath(),T.moveTo(Te,0),T.lineTo(Te,O),T.stroke(),T.fillStyle="#fff",T.font="bold 18px monospace",T.textAlign="center",T.fillText(Ht(ee),Te,O-6),a==="recording"&&(T.fillStyle="#ef4444",T.beginPath(),T.arc(20,20,8,0,Math.PI*2),T.fill(),T.fillStyle="#fff",T.font="10px sans-serif",T.textAlign="left",T.fillText("REC",34,24)),T.textAlign="left"},[a,b,c,f]),gt=()=>{const q=Le.current;if(!q||!pe.current)return;const T=q.frequencyBinCount,H=new Uint8Array(T);q.getByteTimeDomainData(H);let Q=0;for(let Z=0;Z<T;Z++){const ee=(H[Z]-128)/128;Q+=ee*ee}const O=Math.sqrt(Q/T),re=Math.min(1,O*3);Ce.current.push(re),lt(),pe.current&&(ye.current=requestAnimationFrame(gt))},W=async()=>{try{E(null),k(!1),Ne.current===null&&(Ce.current=[]);const q=await navigator.mediaDevices.getUserMedia({audio:!0});ve.current=q;const T=new AudioContext;le.current=T;const H=T.createAnalyser();H.fftSize=2048,Le.current=H,T.createMediaStreamSource(q).connect(H);const O=new MediaRecorder(q);ce.current=O,me.current=[],O.ondataavailable=re=>{re.data.size>0&&me.current.push(re.data)},O.onstop=async()=>{try{if(pe.current=!1,me.current.length===0){E("No audio was recorded. Please try again."),u("idle"),q.getTracks().forEach(te=>te.stop());return}const re=new Blob(me.current,{type:"audio/webm"});let Z,ee;if(Ne.current!==null&&ae.current)try{const te=await It(re),ne=ae.current.sampleRate,Ie=Math.floor(Ne.current*ne),qe=await kt(ae.current,te,Ie,St.current);Z=Et(qe),ee=qe.length/qe.sampleRate,St.current==="insert"&&(Ce.current=[...Ce.current,...ot.current]),Ne.current=null,ae.current=null,Re.current=[],ot.current=[]}catch{Z=re,ee=tt.current>0?tt.current:1}else Z=re,ee=tt.current>0?tt.current:1;if(Se.current=Z,q.getTracks().forEach(te=>te.stop()),$.current&&t){B(te=>[...te,Z]),j(te=>({...te,total:te.total+1})),Se.current=null,Ce.current=[],C(0),h(0),d(0),u("idle");return}const de=URL.createObjectURL(Z),De=new Audio(de);De.ontimeupdate=()=>{C(De.currentTime)},De.onended=()=>{m(!1)},xe.current=De,h(ee),C(ee),u("editing")}catch{E("Failed to process recording"),u("idle")}},O.start(100),pe.current=!0,u("recording"),d(0),tt.current=0,he.current=setInterval(()=>{tt.current+=1,d(tt.current),tt.current>=i&&(ce.current&&ce.current.state!=="inactive"&&ce.current.stop(),pe.current=!1,_(null),he.current&&(clearInterval(he.current),he.current=null),ye.current&&(cancelAnimationFrame(ye.current),ye.current=null),setTimeout(()=>{alert(`Maximum recording time of ${Math.floor(i/60)} minutes reached.`)},100))},1e3)}catch{E("Could not access microphone. Please allow microphone access.")}},we=()=>{pe.current=!1,k(!1),_(null),ye.current&&(cancelAnimationFrame(ye.current),ye.current=null),he.current&&(clearInterval(he.current),he.current=null),ce.current&&ce.current.state!=="inactive"&&ce.current.stop()},ke=q=>{const T=X.current;if(!T)return;const H=f||c;if(H<=0)return;const Q=Ce.current;if(Q.length===0)return;const O=T.getBoundingClientRect(),re=q-pt.current,Z=4,ee=O.width/T.width,de=Q.length/H*Z,De=-re/(de*ee),te=ct.current+De,ne=Math.max(0,Math.min(te,H));xe.current&&(xe.current.currentTime=ne),C(ne)},Ee=()=>{xe.current&&(xe.current.currentTime=0),C(0)},At=()=>{const q=f||c;xe.current&&(xe.current.currentTime=q),C(q)},Tt=()=>{const q=xe.current;q&&(g?(q.pause(),C(q.currentTime),m(!1)):(q.currentTime=b,q.play().catch(()=>{}),m(!0)))},$t=async q=>{if(!Se.current){W();return}try{xe.current&&(xe.current.pause(),m(!1)),St.current=q,ae.current=await It(Se.current);const T=f||c;Ne.current=b;const H=T>0?b/T:0,Q=Math.floor(H*Ce.current.length);Re.current=Ce.current.slice(0,Q),ot.current=Ce.current.slice(Q),Ce.current=[...Re.current],W()}catch{E("Failed to prepare recording. Please try again.")}},K=()=>{xe.current&&(xe.current.pause(),xe.current=null),Se.current=null,ae.current=null,Ne.current=null,Re.current=[],m(!1),C(0),h(0),d(0),W()},J=()=>{Se.current?r(Se.current,f||c):alert("No audio recorded yet!")};w.useEffect(()=>{a==="recording"&&X.current&&Le.current&&pe.current&&(ye.current=requestAnimationFrame(gt))},[a]),w.useEffect(()=>{const q=X.current;if(!q)return;const T=()=>{const H=window.devicePixelRatio||1,Q=q.getBoundingClientRect();q.width=Q.width*H,q.height=Q.height*H;const O=q.getContext("2d");O&&O.scale(H,H)};return T(),window.addEventListener("resize",T),()=>window.removeEventListener("resize",T)},[]),w.useEffect(()=>{if(a==="idle"){const q=X.current;if(!q)return;const T=q.getContext("2d");if(!T)return;const H=q.getBoundingClientRect(),Q=H.width,O=H.height;T.fillStyle="#2d3b35",T.fillRect(0,0,Q,O);const re=8,Z="rgba(0, 0, 0, 0.4)",ee=T.createLinearGradient(0,0,0,re);ee.addColorStop(0,Z),ee.addColorStop(1,"transparent"),T.fillStyle=ee,T.fillRect(0,0,Q,re);const de=T.createLinearGradient(0,O-re,0,O);de.addColorStop(0,"transparent"),de.addColorStop(1,Z),T.fillStyle=de,T.fillRect(0,O-re,Q,re);const De=T.createLinearGradient(0,0,re,0);De.addColorStop(0,Z),De.addColorStop(1,"transparent"),T.fillStyle=De,T.fillRect(0,0,re,O);const te=T.createLinearGradient(Q-re,0,Q,0);te.addColorStop(0,"transparent"),te.addColorStop(1,Z),T.fillStyle=te,T.fillRect(Q-re,0,re,O),T.strokeStyle="#5a6b62",T.lineWidth=1,T.beginPath(),T.moveTo(0,O/2),T.lineTo(Q,O/2),T.stroke();const ne=Q/2;T.strokeStyle="#ef4444",T.lineWidth=1,T.beginPath(),T.moveTo(ne,0),T.lineTo(ne,O),T.stroke(),T.fillStyle="#fff",T.font="bold 18px monospace",T.textAlign="center",T.fillText("00:00",ne,O-6)}},[a]);const Ae=w.useCallback(q=>{B(T=>[...T,q]),j(T=>({...T,total:T.total+1}))},[]);if(w.useEffect(()=>{(async()=>{if(L.current||I.length===0||!t)return;L.current=!0;const T=I[0];try{const H=await t(T);H&&n&&n(H)}catch(H){console.error("Transcription failed:",H)}finally{B(H=>H.slice(1)),j(H=>({...H,completed:H.completed+1})),L.current=!1}})()},[I,t,n]),w.useEffect(()=>()=>{pe.current=!1,he.current&&clearInterval(he.current),ye.current&&cancelAnimationFrame(ye.current),ve.current&&ve.current.getTracks().forEach(q=>q.stop()),le.current&&le.current.state!=="closed"&&le.current.close()},[]),w.useEffect(()=>{if(a==="editing"&&g){let q;const T=()=>{const H=xe.current;if(H&&g){const Q=X.current;if(Q){const O=Q.getContext("2d");if(O){const re=Q.getBoundingClientRect(),Z=re.width,ee=re.height,de=Ce.current,De=f||c||1,te=H.currentTime;O.fillStyle="#2d3b35",O.fillRect(0,0,Z,ee);const ne=8,Ie="rgba(0, 0, 0, 0.4)",qe=O.createLinearGradient(0,0,0,ne);qe.addColorStop(0,Ie),qe.addColorStop(1,"transparent"),O.fillStyle=qe,O.fillRect(0,0,Z,ne);const Te=O.createLinearGradient(0,ee-ne,0,ee);Te.addColorStop(0,"transparent"),Te.addColorStop(1,Ie),O.fillStyle=Te,O.fillRect(0,ee-ne,Z,ne);const be=O.createLinearGradient(0,0,ne,0);be.addColorStop(0,Ie),be.addColorStop(1,"transparent"),O.fillStyle=be,O.fillRect(0,0,ne,ee);const He=O.createLinearGradient(Z-ne,0,Z,0);He.addColorStop(0,"transparent"),He.addColorStop(1,Ie),O.fillStyle=He,O.fillRect(Z-ne,0,ne,ee),O.strokeStyle="#5a6b62",O.lineWidth=1,O.beginPath(),O.moveTo(0,ee/2),O.lineTo(Z,ee/2),O.stroke();const Je=Z/2,dt=3,zt=4,yt=De>0?te/De*de.length:0;for(let U=0;U<de.length;U++){const Y=yt-U,oe=Je-Y*zt;if(oe<-dt||oe>Z)continue;const ge=de[U]*(ee/2-12),se=ee/2-ge;O.fillStyle=U<=yt?"#10b981":"#4b5563",O.fillRect(oe,se,dt,ge*2)}O.strokeStyle="#ef4444",O.lineWidth=1,O.beginPath(),O.moveTo(Je,0),O.lineTo(Je,ee),O.stroke(),O.fillStyle="#fff",O.font="bold 18px monospace",O.textAlign="center";const x=Math.floor(te/60),R=Math.floor(te%60);O.fillText(`${x.toString().padStart(2,"0")}:${R.toString().padStart(2,"0")}`,Je,ee-6),O.textAlign="left"}}q=requestAnimationFrame(T)}};return q=requestAnimationFrame(T),()=>cancelAnimationFrame(q)}},[a,g,f,c]),w.useEffect(()=>{a==="editing"&&!g&&lt()},[a,b,g,lt]),v)return p.jsxs("div",{style:{border:"1px solid #fecaca",borderRadius:"12px",padding:"16px",background:"#fef2f2"},children:[p.jsx("p",{style:{fontSize:"14px",color:"#dc2626",marginBottom:"12px"},children:v}),p.jsx("button",{onClick:()=>{E(null),W()},style:{padding:"8px 16px",fontSize:"14px",background:"#171717",color:"white",borderRadius:"8px",border:"none",cursor:"pointer"},children:"Try Again"})]});const Pe={padding:"8px",borderRadius:"8px",border:"none",background:"transparent",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",transition:"background 0.15s"},Oe={...Pe,opacity:.3,cursor:"not-allowed"},mt=l?{border:"1px solid #e5e5e5",borderRadius:"12px",overflow:"hidden",background:"white"}:{overflow:"hidden",background:"white",flexShrink:0};return p.jsxs("div",{style:mt,children:[p.jsx("canvas",{ref:X,style:{width:"100%",height:"32px",cursor:"pointer",flexShrink:0},onMouseDown:q=>{if(a==="editing"){Mt.current=!0,pt.current=q.clientX,ct.current=b;const T=Q=>{Mt.current&&ke(Q.clientX)},H=()=>{Mt.current=!1,window.removeEventListener("mousemove",T),window.removeEventListener("mouseup",H)};window.addEventListener("mousemove",T),window.addEventListener("mouseup",H)}}}),p.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:[p.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px"},children:[p.jsx("button",{onClick:Ee,disabled:a==="idle"||a==="recording",style:a==="idle"||a==="recording"?Oe:Pe,title:"Go to start",children:p.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:"#171717"},children:"first_page"})}),p.jsx("button",{onClick:()=>{if(a==="recording"){const q=ce.current;q&&(q.state==="recording"?(q.pause(),k(!0)):q.state==="paused"&&(q.resume(),k(!1)))}else Tt()},disabled:a==="idle",style:a==="idle"?Oe:Pe,title:g||a==="recording"&&!D?"Pause":"Play",children:p.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:"#171717"},children:g||a==="recording"&&!D?"pause":"play_arrow"})}),p.jsx("button",{onClick:At,disabled:a==="idle"||a==="recording",style:a==="idle"||a==="recording"?Oe:Pe,title:"Go to end",children:p.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:"#171717"},children:"last_page"})}),p.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))"}}),p.jsx("button",{onClick:()=>{y==="insert"?we():a==="idle"?(_("insert"),W()):a==="editing"&&(_("insert"),$t("insert"))},disabled:a==="recording"&&y!=="insert"||g,style:a==="recording"&&y!=="insert"||g?Oe:Pe,title:y==="insert"?"Stop recording":"Insert recording",children:p.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:y==="insert"?"#ef4444":"#171717"},children:"add"})}),p.jsx("button",{onClick:()=>{$.current||(y==="mic"?we():a==="idle"?(_("mic"),W()):a==="editing"&&(_("mic"),$t("replace")))},onMouseDown:()=>{$.current&&a==="idle"&&!g&&(_("mic"),W())},onMouseUp:()=>{$.current&&a==="recording"&&y==="mic"&&we()},onMouseLeave:()=>{$.current&&a==="recording"&&y==="mic"&&we()},onTouchStart:()=>{$.current&&a==="idle"&&!g&&(_("mic"),W())},onTouchEnd:()=>{$.current&&a==="recording"&&y==="mic"&&we()},disabled:a==="recording"&&y!=="mic"||g,style:a==="recording"&&y!=="mic"||g?Oe:Pe,title:S?"Hold to record (walkie-talkie)":y==="mic"?"Stop recording":"Record",children:p.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:y==="mic"?"#ef4444":"#171717"},children:"mic"})}),p.jsx("button",{onClick:()=>{y==="startover"?we():a==="editing"&&(_("startover"),K())},disabled:a==="idle"||a==="recording"&&y!=="startover"||g,style:a==="idle"||a==="recording"&&y!=="startover"||g?Oe:Pe,title:y==="startover"?"Stop recording":"Start over",children:p.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:y==="startover"?"#ef4444":"#171717"},children:"refresh"})})]}),p.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px"},children:[N.total>0&&N.completed<N.total&&p.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:[p.jsx("span",{className:"material-icons",style:{fontSize:"14px",animation:"spin 1s linear infinite"},children:"sync"}),N.completed,"/",N.total]}),t&&p.jsxs(p.Fragment,{children:[p.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px",marginRight:"4px"},children:[p.jsx("button",{onClick:()=>A(!S),style:{width:"28px",height:"16px",borderRadius:"8px",border:"none",background:S?"#10b981":"#9ca3af",cursor:"pointer",position:"relative",transition:"background 0.2s",padding:0},title:S?"Auto-transcribe ON":"Auto-transcribe OFF",children:p.jsx("div",{style:{width:"12px",height:"12px",borderRadius:"50%",background:"white",position:"absolute",top:"2px",left:S?"14px":"2px",transition:"left 0.2s",boxShadow:"0 1px 2px rgba(0,0,0,0.2)"}})}),p.jsx("span",{style:{fontSize:"10px",color:"#666"},children:"auto"})]}),p.jsx("button",{onClick:()=>{a==="editing"&&Se.current&&Ae(Se.current)},disabled:a!=="editing",style:a!=="editing"?Oe:Pe,title:"Transcribe audio",children:p.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:S?"#10b981":"#171717"},children:"subtitles"})})]}),!o&&p.jsx("button",{onClick:J,disabled:a!=="editing",style:a!=="editing"?Oe:Pe,title:"Save recording",children:p.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:"#171717"},children:"save"})})]})]}),N.total>0&&N.completed<N.total&&p.jsx("div",{style:{height:"3px",background:"#e5e5e5",overflow:"hidden"},children:p.jsx("div",{style:{height:"100%",background:"#10b981",width:`${N.completed/N.total*100}%`,transition:"width 0.3s ease"}})})]})}exports.AnimatedCardFlip=hu;exports.ApiClient=dl;exports.AudioEditor=xf;exports.AuthManager=cl;exports.Card=cu;exports.ComboBox=df;exports.DataOperations=Rn;exports.Detail=du;exports.GraphClient=Ia;exports.KanbanBoard=ff;exports.Mail=gu;exports.MailClient=ul;exports.MailComposer=uf;exports.MailEditor=ja;exports.SelectableList=mu;exports.Stack=uu;exports.Timeline=yf;exports.getApiClient=ui;exports.initializeApiClient=iu;exports.useMutation=ou;exports.useQuery=fl;
package/dist/index.esm.js CHANGED
@@ -12747,7 +12747,7 @@ function kf({
12747
12747
  return ((B = T.label) == null ? void 0 : B.toLowerCase()) === b.toLowerCase();
12748
12748
  }), y = e.map((T) => r.find((B) => B.id === T)).filter(Boolean), _ = re((T) => {
12749
12749
  var B;
12750
- c > 0 && e.length >= c || (t([...e, T]), w(""), (B = A.current) == null || B.focus());
12750
+ c > 0 && e.length >= c || (t([...e, T]), w(""), c === 1 ? m(!1) : (B = A.current) == null || B.focus());
12751
12751
  }, [e, t, c]), D = re((T) => {
12752
12752
  t(e.filter((B) => B !== T));
12753
12753
  }, [e, t]), S = re(async () => {
@@ -13308,7 +13308,7 @@ function Bf({
13308
13308
  ] });
13309
13309
  }
13310
13310
  function Nf({ onComplete: r, onCancel: e, onTranscribe: t, onTranscriptionComplete: n, variant: s = "widget", hideSaveButton: o = !1, maxDuration: i = 180 }) {
13311
- const l = s === "widget", [a, u] = H("idle"), [c, d] = H(0), [f, h] = H(0), [g, m] = H(!1), [b, w] = H(0), [v, A] = H(null), [C, E] = H(!1), [y, _] = H(null), [D, S] = H(!1), [M, T] = H([]), [B, F] = H({ completed: 0, total: 0 }), j = ye(!1), I = ye(!1);
13311
+ const l = s === "widget", [a, u] = H("idle"), [c, d] = H(0), [f, h] = H(0), [g, m] = H(!1), [b, w] = H(0), [v, A] = H(null), [C, E] = H(!1), [y, _] = H(null), [D, S] = H(!0), [M, T] = H([]), [B, F] = H({ completed: 0, total: 0 }), j = ye(!1), I = ye(!0);
13312
13312
  Se(() => {
13313
13313
  I.current = D;
13314
13314
  }, [D]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qwanyx/stack",
3
- "version": "0.2.50",
3
+ "version": "0.2.52",
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",