@qwanyx/stack 0.2.36 → 0.2.37

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),[y,D]=w.useState(""),x=w.useRef(null),k=w.useRef(null);w.useEffect(()=>{function N(j){x.current&&!x.current.contains(j.target)&&(m(!1),D(""))}return document.addEventListener("mousedown",N),()=>document.removeEventListener("mousedown",N)},[]);const C=r.filter(N=>{var j;return((j=N.label)==null?void 0:j.toLowerCase().includes(y.toLowerCase()))&&!e.includes(N.id)}),S=s&&y.trim()&&!r.some(N=>{var j;return((j=N.label)==null?void 0:j.toLowerCase())===y.toLowerCase()}),v=e.map(N=>r.find(j=>j.id===N)).filter(Boolean),_=w.useCallback(N=>{var j;c>0&&e.length>=c||(t([...e,N]),D(""),(j=k.current)==null||j.focus())},[e,t,c]),E=w.useCallback(N=>{t(e.filter(j=>j!==N))},[e,t]),T=w.useCallback(async()=>{if(!S)return;const N=await(o==null?void 0:o(y.trim()));N&&_(N.id),D("")},[S,y,o,_]),z=w.useCallback(N=>{N.key==="Enter"?(N.preventDefault(),S?T():C.length>0&&_(C[0].id)):N.key==="Backspace"&&!y&&e.length>0?E(e[e.length-1]):N.key==="Escape"&&(m(!1),D(""))},[S,C,y,e,T,_,E]);return p.jsxs("div",{ref:x,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:[v.map(N=>p.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"2px 8px",borderRadius:"4px",fontSize:"13px",background:N.color||h.chipBackground,color:N.color?"#fff":h.chipText},children:[N.label,!u&&p.jsx("button",{type:"button",onClick:j=>{j.stopPropagation(),E(N.id)},style:{border:"none",background:"transparent",cursor:"pointer",padding:"0 2px",fontSize:"14px",color:"inherit",opacity:.7},children:"×"})]},N.id)),p.jsx("input",{ref:k,type:"text",value:y,onChange:N=>{D(N.target.value),g||m(!0)},onFocus:()=>m(!0),onKeyDown:z,placeholder:v.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:C.length===0&&!S?p.jsx("div",{style:{padding:"12px",fontSize:"14px",color:h.textSecondary,textAlign:"center"},children:y?"No matches":"No options available"}):p.jsxs(p.Fragment,{children:[C.map(N=>p.jsxs("div",{onClick:()=>_(N.id),style:{padding:"10px 12px",fontSize:"14px",cursor:"pointer",color:h.text,display:"flex",alignItems:"center",justifyContent:"space-between"},onMouseEnter:j=>{j.currentTarget.style.background=h.hoverBackground||""},onMouseLeave:j=>{j.currentTarget.style.background=""},children:[N.label,i&&l&&p.jsx("button",{type:"button",onClick:j=>{j.stopPropagation(),l(N.id)},style:{border:"none",background:"transparent",cursor:"pointer",padding:"2px",fontSize:"14px",color:h.textSecondary,opacity:.5},onMouseEnter:j=>{j.currentTarget.style.opacity="1",j.currentTarget.style.color="#ef4444"},onMouseLeave:j=>{j.currentTarget.style.opacity="0.5",j.currentTarget.style.color=h.textSecondary||""},children:"×"})]},N.id)),S&&p.jsxs("div",{onClick:T,style:{padding:"10px 12px",fontSize:"14px",cursor:"pointer",color:h.primary,borderTop:C.length>0?`1px solid ${h.border}`:"none"},onMouseEnter:N=>{N.currentTarget.style.background=h.hoverBackground||""},onMouseLeave:N=>{N.currentTarget.style.background=""},children:['+ Create "',y.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),[y,D]=w.useState(null),[x,k]=w.useState(null),C=w.useRef(null),S=e.reduce((j,R)=>{let L=r.filter(O=>n(O)===R.id);return s&&(L=L.sort((O,Y)=>s(O)-s(Y))),j[R.id]=L,j},{}),v=w.useCallback((j,R)=>{const L=t(R),O=n(R);m(L),C.current=O,j.dataTransfer.effectAllowed="move",j.dataTransfer.setData("text/plain",L),requestAnimationFrame(()=>{const Y=j.target;Y.style.opacity="0.5"})},[t,n]),_=w.useCallback(j=>{const R=j.target;R.style.opacity="1",m(null),D(null),k(null),C.current=null},[]),E=w.useCallback((j,R,L)=>{j.preventDefault(),j.dataTransfer.dropEffect="move",D(R),k(L)},[]),T=w.useCallback(j=>{const R=j.relatedTarget;R!=null&&R.closest("[data-kanban-column]")||(D(null),k(null))},[]),z=w.useCallback((j,R,L)=>{if(j.preventDefault(),!g)return;const O=C.current;O===R?l==null||l(g,R,L):O&&i(g,O,R,L),m(null),D(null),k(null),C.current=null},[g,i,l]),N=(j,R)=>p.jsxs("div",{className:"flex items-center justify-between px-3 py-2",children:[p.jsxs("div",{className:"flex items-center gap-2",children:[j.color&&p.jsx("div",{className:"w-2 h-2 rounded-full",style:{backgroundColor:j.color}}),p.jsx("span",{className:"font-medium text-sm text-neutral-700",children:j.label})]}),p.jsx("span",{className:"text-xs text-neutral-400 bg-neutral-100 px-2 py-0.5 rounded-full",children:R})]});return p.jsx("div",{className:`flex gap-4 overflow-x-auto pb-4 ${d}`,style:{minHeight:"400px"},children:e.map(j=>{const R=S[j.id]||[],L=y===j.id;return p.jsxs("div",{"data-kanban-column":j.id,className:`flex-1 min-w-[180px] bg-neutral-50 rounded-xl flex flex-col ${f}`,onDragOver:O=>{O.preventDefault(),g&&!L&&D(j.id)},onDragLeave:T,onDrop:O=>z(O,j.id,x??R.length),children:[p.jsx("div",{className:"flex-shrink-0 border-b border-neutral-200",children:u?u(j,R.length):N(j,R.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:[R.map((O,Y)=>{const ce=t(O),Z=g===ce,Ce=L&&x===Y&&!Z;return p.jsxs("div",{children:[Ce&&p.jsx("div",{className:"h-1 bg-blue-500 rounded-full mb-2 mx-1"}),p.jsx("div",{draggable:!0,onDragStart:ie=>v(ie,O),onDragEnd:_,onDragOver:ie=>E(ie,j.id,Y),onClick:()=>a==null?void 0:a(O),className:`cursor-grab active:cursor-grabbing transition-all ${Z?"opacity-50 scale-95":""} ${h}`,children:o(O,Z)})]},ce)}),p.jsx("div",{className:"min-h-[40px] flex-1",onDragOver:O=>{O.preventDefault(),E(O,j.id,R.length)},children:L&&x===R.length&&p.jsx("div",{className:"h-1 bg-blue-500 rounded-full mx-1 mt-1"})}),R.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(j)})]},j.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:y,timedItems:D}=w.useMemo(()=>{const _=[],E=[];for(const T of r)l(T)?_.push(T):E.push(T);return{allDayItems:_,timedItems:E}},[r,l]),x=w.useMemo(()=>{const _=[];for(let E=t;E<=n;E++)_.push(E);return _},[t,n]),k=(n-t+1)*s,C=w.useCallback(_=>{const E=o(_);if(!E)return null;const T=pf(E);if(!T)return null;const{hours:z,minutes:N}=T,j=Math.max(t,Math.min(n,z)),R=z<t?0:N,L=(j-t)*s+R/60*s,O=i(_),Y=Math.max(20,O/60*s);return{top:L,height:Y}},[o,i,t,n,s]),S=w.useMemo(()=>{if(!f||!mf(e))return null;const _=new Date,E=_.getHours(),T=_.getMinutes();return E<t||E>n?null:(E-t)*s+T/60*s},[e,f,t,n,s]),v=w.useCallback(_=>{if(!d)return;const E=_.currentTarget.getBoundingClientRect(),z=(_.clientY-E.top)/s*60,N=Math.floor(z/60)+t,j=Math.round(z%60/15)*15,R=Math.min(n,Math.max(t,N)),L=j>=60?0:j,O=`${R.toString().padStart(2,"0")}:${L.toString().padStart(2,"0")}`;d(O)},[d,s,t,n]);return p.jsxs("div",{className:h,style:{background:m.background},children:[y.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:y.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:k},children:[x.map((_,E)=>p.jsxs("div",{style:{position:"absolute",top:E*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}}),E<x.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:v}),S!==null&&p.jsxs("div",{style:{position:"absolute",left:"55px",right:0,top:S,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}})]}),D.map(_=>{const E=C(_);return E?p.jsx("div",{style:{position:"absolute",left:"64px",right:"8px",top:E.top,height:E.height,zIndex:10,cursor:c?"pointer":"default"},onClick:T=>{T.stopPropagation(),c==null||c(_)},children:u(_)},a(_)):null})]})]})}function xf({onComplete:r,onCancel:e,onTranscribe:t,transcribing:n,variant:s="widget",hideSaveButton:o=!1}){const i=s==="widget",[l,a]=w.useState("idle"),[u,c]=w.useState(0),[d,f]=w.useState(0),[h,g]=w.useState(!1),[m,y]=w.useState(0),[D,x]=w.useState(null),[k,C]=w.useState(!1),[S,v]=w.useState(null),_=w.useRef(null),E=w.useRef(null),T=w.useRef(null),z=w.useRef(null),N=w.useRef(null),j=w.useRef([]),R=w.useRef(null),L=w.useRef(null),O=w.useRef(null),Y=w.useRef(null),ce=w.useRef(!1),Z=w.useRef([]),Ce=w.useRef(null),ie=w.useRef(null),ye=w.useRef([]),Se=w.useRef([]),je=w.useRef("insert"),Me=w.useRef(!1),ke=w.useRef(0),be=w.useRef(0),We=w.useRef(0),Ae=U=>{const B=Math.floor(U/60),X=Math.floor(U%60);return`${B.toString().padStart(2,"0")}:${X.toString().padStart(2,"0")}`},de=async U=>{const B=await U.arrayBuffer(),X=new AudioContext,J=await X.decodeAudioData(B);return await X.close(),J},qe=U=>{const B=U.numberOfChannels,X=U.sampleRate,J=1,A=16,I=A/8,H=B*I,Q=X*H,te=U.length*H,le=new ArrayBuffer(44+te),ne=new DataView(le),re=(ge,fe)=>{for(let Ie=0;Ie<fe.length;Ie++)ne.setUint8(ge+Ie,fe.charCodeAt(Ie))};re(0,"RIFF"),ne.setUint32(4,36+te,!0),re(8,"WAVE"),re(12,"fmt "),ne.setUint32(16,16,!0),ne.setUint16(20,J,!0),ne.setUint16(22,B,!0),ne.setUint32(24,X,!0),ne.setUint32(28,Q,!0),ne.setUint16(32,H,!0),ne.setUint16(34,A,!0),re(36,"data"),ne.setUint32(40,te,!0);const _e=[];for(let ge=0;ge<B;ge++)_e.push(U.getChannelData(ge));let Be=44;for(let ge=0;ge<U.length;ge++)for(let fe=0;fe<B;fe++){const Ie=Math.max(-1,Math.min(1,_e[fe][ge])),$e=Ie<0?Ie*32768:Ie*32767;ne.setInt16(Be,$e,!0),Be+=2}return new Blob([le],{type:"audio/wav"})},At=async(U,B,X,J)=>{const A=new AudioContext,I=U.sampleRate,H=Math.max(U.numberOfChannels,B.numberOfChannels),Q=Math.min(X,U.length),te=Math.max(0,U.length-X),le=J==="insert"?Q+B.length+te:Q+B.length,ne=A.createBuffer(H,le,I);for(let re=0;re<H;re++){const _e=ne.getChannelData(re),Be=re<U.numberOfChannels?U.getChannelData(re):U.getChannelData(0);for(let fe=0;fe<Q;fe++)_e[fe]=Be[fe];const ge=re<B.numberOfChannels?B.getChannelData(re):B.getChannelData(0);for(let fe=0;fe<B.length;fe++)_e[Q+fe]=ge[fe];if(J==="insert")for(let fe=0;fe<te;fe++)_e[Q+B.length+fe]=Be[X+fe]}return await A.close(),ne},yt=w.useCallback(()=>{const U=_.current;if(!U)return;const B=U.getContext("2d");if(!B)return;const X=U.getBoundingClientRect(),J=X.width,A=X.height,I=Z.current,H=d||u||1,Q=l==="recording"?u:m;B.fillStyle="#2d3b35",B.fillRect(0,0,J,A);const te=8,le="rgba(0, 0, 0, 0.4)",ne=B.createLinearGradient(0,0,0,te);ne.addColorStop(0,le),ne.addColorStop(1,"transparent"),B.fillStyle=ne,B.fillRect(0,0,J,te);const re=B.createLinearGradient(0,A-te,0,A);re.addColorStop(0,"transparent"),re.addColorStop(1,le),B.fillStyle=re,B.fillRect(0,A-te,J,te);const _e=B.createLinearGradient(0,0,te,0);_e.addColorStop(0,le),_e.addColorStop(1,"transparent"),B.fillStyle=_e,B.fillRect(0,0,te,A);const Be=B.createLinearGradient(J-te,0,J,0);Be.addColorStop(0,"transparent"),Be.addColorStop(1,le),B.fillStyle=Be,B.fillRect(J-te,0,te,A),B.strokeStyle="#5a6b62",B.lineWidth=1,B.beginPath(),B.moveTo(0,A/2),B.lineTo(J,A/2),B.stroke();const ge=J/2;if(I.length>0)if(l==="recording")for(let $e=0;$e<I.length;$e++){const it=I.length-1-$e,bt=ge-it*4;if(bt<-3||bt>J)continue;const ut=I[$e]*(A/2-12),Tt=A/2-ut;B.fillStyle="#10b981",B.fillRect(bt,Tt,3,ut*2)}else{const $e=H>0?Q/H*I.length:0;for(let it=0;it<I.length;it++){const bt=$e-it,ut=ge-bt*4;if(ut<-3||ut>J)continue;const Tt=I[it]*(A/2-12),fr=A/2-Tt;B.fillStyle=it<=$e?"#10b981":"#4b5563",B.fillRect(ut,fr,3,Tt*2)}}B.strokeStyle="#ef4444",B.lineWidth=1,B.beginPath(),B.moveTo(ge,0),B.lineTo(ge,A),B.stroke(),B.fillStyle="#fff",B.font="bold 18px monospace",B.textAlign="center",B.fillText(Ae(Q),ge,A-6),l==="recording"&&(B.fillStyle="#ef4444",B.beginPath(),B.arc(20,20,8,0,Math.PI*2),B.fill(),B.fillStyle="#fff",B.font="10px sans-serif",B.textAlign="left",B.fillText("REC",34,24)),B.textAlign="left"},[l,m,u,d]),Pt=()=>{const U=N.current;if(!U||!ce.current)return;const B=U.frequencyBinCount,X=new Uint8Array(B);U.getByteTimeDomainData(X);let J=0;for(let H=0;H<B;H++){const Q=(X[H]-128)/128;J+=Q*Q}const A=Math.sqrt(J/B),I=Math.min(1,A*3);Z.current.push(I),yt(),ce.current&&(L.current=requestAnimationFrame(Pt))},nt=async()=>{try{x(null),C(!1),Ce.current===null&&(Z.current=[]);const U=await navigator.mediaDevices.getUserMedia({audio:!0});T.current=U;const B=new AudioContext;z.current=B;const X=B.createAnalyser();X.fftSize=2048,N.current=X,B.createMediaStreamSource(U).connect(X);const A=new MediaRecorder(U);E.current=A,j.current=[],A.ondataavailable=I=>{I.data.size>0&&j.current.push(I.data)},A.onstop=async()=>{try{if(ce.current=!1,j.current.length===0){x("No audio was recorded. Please try again."),a("idle"),U.getTracks().forEach(ne=>ne.stop());return}const I=new Blob(j.current,{type:"audio/webm"});let H,Q;if(Ce.current!==null&&ie.current)try{const ne=await de(I),re=ie.current.sampleRate,_e=Math.floor(Ce.current*re),Be=await At(ie.current,ne,_e,je.current);H=qe(Be),Q=Be.length/Be.sampleRate,je.current==="insert"&&(Z.current=[...Z.current,...Se.current]),Ce.current=null,ie.current=null,ye.current=[],Se.current=[]}catch{H=I,Q=ke.current>0?ke.current:1}else H=I,Q=ke.current>0?ke.current:1;Y.current=H;const te=URL.createObjectURL(H),le=new Audio(te);le.ontimeupdate=()=>{y(le.currentTime)},le.onended=()=>{g(!1)},O.current=le,f(Q),y(Q),a("editing"),U.getTracks().forEach(ne=>ne.stop())}catch{x("Failed to process recording"),a("idle")}},A.start(100),ce.current=!0,a("recording"),c(0),ke.current=0,R.current=setInterval(()=>{ke.current+=1,c(ke.current)},1e3)}catch{x("Could not access microphone. Please allow microphone access.")}},st=()=>{ce.current=!1,C(!1),v(null),L.current&&(cancelAnimationFrame(L.current),L.current=null),R.current&&(clearInterval(R.current),R.current=null),E.current&&E.current.state!=="inactive"&&E.current.stop()},at=U=>{const B=_.current;if(!B)return;const X=d||u;if(X<=0)return;const J=Z.current;if(J.length===0)return;const A=B.getBoundingClientRect(),I=U-be.current,H=4,Q=A.width/B.width,te=J.length/X*H,le=-I/(te*Q),ne=We.current+le,re=Math.max(0,Math.min(ne,X));O.current&&(O.current.currentTime=re),y(re)},Ot=()=>{O.current&&(O.current.currentTime=0),y(0)},Mt=()=>{const U=d||u;O.current&&(O.current.currentTime=U),y(U)},Ze=()=>{const U=O.current;U&&(h?(U.pause(),y(U.currentTime),g(!1)):(U.currentTime=m,U.play().catch(()=>{}),g(!0)))},et=async U=>{if(!Y.current){nt();return}try{O.current&&(O.current.pause(),g(!1)),je.current=U,ie.current=await de(Y.current);const B=d||u;Ce.current=m;const X=B>0?m/B:0,J=Math.floor(X*Z.current.length);ye.current=Z.current.slice(0,J),Se.current=Z.current.slice(J),Z.current=[...ye.current],nt()}catch{x("Failed to prepare recording. Please try again.")}},It=()=>{O.current&&(O.current.pause(),O.current=null),Y.current=null,ie.current=null,Ce.current=null,ye.current=[],g(!1),y(0),f(0),c(0),nt()},V=()=>{Y.current?r(Y.current,d||u):alert("No audio recorded yet!")};if(w.useEffect(()=>{l==="recording"&&_.current&&N.current&&ce.current&&(L.current=requestAnimationFrame(Pt))},[l]),w.useEffect(()=>{const U=_.current;if(!U)return;const B=()=>{const X=window.devicePixelRatio||1,J=U.getBoundingClientRect();U.width=J.width*X,U.height=J.height*X;const A=U.getContext("2d");A&&A.scale(X,X)};return B(),window.addEventListener("resize",B),()=>window.removeEventListener("resize",B)},[]),w.useEffect(()=>{if(l==="idle"){const U=_.current;if(!U)return;const B=U.getContext("2d");if(!B)return;const X=U.getBoundingClientRect(),J=X.width,A=X.height;B.fillStyle="#2d3b35",B.fillRect(0,0,J,A);const I=8,H="rgba(0, 0, 0, 0.4)",Q=B.createLinearGradient(0,0,0,I);Q.addColorStop(0,H),Q.addColorStop(1,"transparent"),B.fillStyle=Q,B.fillRect(0,0,J,I);const te=B.createLinearGradient(0,A-I,0,A);te.addColorStop(0,"transparent"),te.addColorStop(1,H),B.fillStyle=te,B.fillRect(0,A-I,J,I);const le=B.createLinearGradient(0,0,I,0);le.addColorStop(0,H),le.addColorStop(1,"transparent"),B.fillStyle=le,B.fillRect(0,0,I,A);const ne=B.createLinearGradient(J-I,0,J,0);ne.addColorStop(0,"transparent"),ne.addColorStop(1,H),B.fillStyle=ne,B.fillRect(J-I,0,I,A),B.strokeStyle="#5a6b62",B.lineWidth=1,B.beginPath(),B.moveTo(0,A/2),B.lineTo(J,A/2),B.stroke();const re=J/2;B.strokeStyle="#ef4444",B.lineWidth=1,B.beginPath(),B.moveTo(re,0),B.lineTo(re,A),B.stroke(),B.fillStyle="#fff",B.font="bold 18px monospace",B.textAlign="center",B.fillText("00:00",re,A-6)}},[l]),w.useEffect(()=>()=>{ce.current=!1,R.current&&clearInterval(R.current),L.current&&cancelAnimationFrame(L.current),T.current&&T.current.getTracks().forEach(U=>U.stop()),z.current&&z.current.state!=="closed"&&z.current.close()},[]),w.useEffect(()=>{if(l==="editing"&&h){let U;const B=()=>{const X=O.current;if(X&&h){const J=_.current;if(J){const A=J.getContext("2d");if(A){const I=J.getBoundingClientRect(),H=I.width,Q=I.height,te=Z.current,le=d||u||1,ne=X.currentTime;A.fillStyle="#2d3b35",A.fillRect(0,0,H,Q);const re=8,_e="rgba(0, 0, 0, 0.4)",Be=A.createLinearGradient(0,0,0,re);Be.addColorStop(0,_e),Be.addColorStop(1,"transparent"),A.fillStyle=Be,A.fillRect(0,0,H,re);const ge=A.createLinearGradient(0,Q-re,0,Q);ge.addColorStop(0,"transparent"),ge.addColorStop(1,_e),A.fillStyle=ge,A.fillRect(0,Q-re,H,re);const fe=A.createLinearGradient(0,0,re,0);fe.addColorStop(0,_e),fe.addColorStop(1,"transparent"),A.fillStyle=fe,A.fillRect(0,0,re,Q);const Ie=A.createLinearGradient(H-re,0,H,0);Ie.addColorStop(0,"transparent"),Ie.addColorStop(1,_e),A.fillStyle=Ie,A.fillRect(H-re,0,re,Q),A.strokeStyle="#5a6b62",A.lineWidth=1,A.beginPath(),A.moveTo(0,Q/2),A.lineTo(H,Q/2),A.stroke();const $e=H/2,it=3,bt=4,ut=le>0?ne/le*te.length:0;for(let Qt=0;Qt<te.length;Qt++){const ys=ut-Qt,hr=$e-ys*bt;if(hr<-it||hr>H)continue;const Fr=te[Qt]*(Q/2-12),xs=Q/2-Fr;A.fillStyle=Qt<=ut?"#10b981":"#4b5563",A.fillRect(hr,xs,it,Fr*2)}A.strokeStyle="#ef4444",A.lineWidth=1,A.beginPath(),A.moveTo($e,0),A.lineTo($e,Q),A.stroke(),A.fillStyle="#fff",A.font="bold 18px monospace",A.textAlign="center";const Tt=Math.floor(ne/60),fr=Math.floor(ne%60);A.fillText(`${Tt.toString().padStart(2,"0")}:${fr.toString().padStart(2,"0")}`,$e,Q-6),A.textAlign="left"}}U=requestAnimationFrame(B)}};return U=requestAnimationFrame(B),()=>cancelAnimationFrame(U)}},[l,h,d,u]),w.useEffect(()=>{l==="editing"&&!h&&yt()},[l,m,h,yt]),D)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:D}),p.jsx("button",{onClick:()=>{x(null),nt()},style:{padding:"8px 16px",fontSize:"14px",background:"#171717",color:"white",borderRadius:"8px",border:"none",cursor:"pointer"},children:"Try Again"})]});const xe={padding:"8px",borderRadius:"8px",border:"none",background:"transparent",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",transition:"background 0.15s"},Te={...xe,opacity:.3,cursor:"not-allowed"},xt=i?{border:"1px solid #e5e5e5",borderRadius:"12px",overflow:"hidden",background:"white"}:{overflow:"hidden",background:"white",height:"100%",display:"flex",flexDirection:"column"};return p.jsxs("div",{style:xt,children:[p.jsx("canvas",{ref:_,style:{width:"100%",height:"64px",cursor:"pointer",flexShrink:0},onMouseDown:U=>{if(l==="editing"){Me.current=!0,be.current=U.clientX,We.current=m;const B=J=>{Me.current&&at(J.clientX)},X=()=>{Me.current=!1,window.removeEventListener("mousemove",B),window.removeEventListener("mouseup",X)};window.addEventListener("mousemove",B),window.addEventListener("mouseup",X)}}}),p.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:i?"10px 12px":"8px",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:Ot,disabled:l==="idle"||l==="recording",style:l==="idle"||l==="recording"?Te:xe,title:"Go to start",children:p.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:"#171717"},children:"first_page"})}),p.jsx("button",{onClick:()=>{if(l==="recording"){const U=E.current;U&&(U.state==="recording"?(U.pause(),C(!0)):U.state==="paused"&&(U.resume(),C(!1)))}else Ze()},disabled:l==="idle",style:l==="idle"?Te:xe,title:h||l==="recording"&&!k?"Pause":"Play",children:p.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:"#171717"},children:h||l==="recording"&&!k?"pause":"play_arrow"})}),p.jsx("button",{onClick:Mt,disabled:l==="idle"||l==="recording",style:l==="idle"||l==="recording"?Te:xe,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:()=>{S==="insert"?st():l==="idle"?(v("insert"),nt()):l==="editing"&&(v("insert"),et("insert"))},disabled:l==="recording"&&S!=="insert"||h,style:l==="recording"&&S!=="insert"||h?Te:xe,title:S==="insert"?"Stop recording":"Insert recording",children:p.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:S==="insert"?"#ef4444":"#171717"},children:"add"})}),p.jsx("button",{onClick:()=>{S==="mic"?st():l==="idle"?(v("mic"),nt()):l==="editing"&&(v("mic"),et("replace"))},disabled:l==="recording"&&S!=="mic"||h,style:l==="recording"&&S!=="mic"||h?Te:xe,title:S==="mic"?"Stop recording":"Record",children:p.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:S==="mic"?"#ef4444":"#171717"},children:"mic"})}),p.jsx("button",{onClick:()=>{S==="startover"?st():l==="editing"&&(v("startover"),It())},disabled:l==="idle"||l==="recording"&&S!=="startover"||h,style:l==="idle"||l==="recording"&&S!=="startover"||h?Te:xe,title:S==="startover"?"Stop recording":"Start over",children:p.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:S==="startover"?"#ef4444":"#171717"},children:"refresh"})})]}),p.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px"},children:[t&&p.jsx("button",{onClick:()=>Y.current&&t(Y.current),disabled:l!=="editing"||n,style:l!=="editing"||n?Te:xe,title:n?"Transcribing...":"Transcribe audio",children:p.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:"#171717"},children:n?"hourglass_empty":"subtitles"})}),!o&&p.jsx("button",{onClick:V,disabled:l!=="editing",style:l!=="editing"?Te:xe,title:"Save recording",children:p.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:"#171717"},children:"save"})})]})]})]})}exports.AnimatedCardFlip=hu;exports.ApiClient=al;exports.AudioEditor=xf;exports.AuthManager=ll;exports.Card=cu;exports.ComboBox=df;exports.DataOperations=Bn;exports.Detail=du;exports.GraphClient=Ia;exports.KanbanBoard=ff;exports.Mail=gu;exports.MailClient=ol;exports.MailComposer=uf;exports.MailEditor=Ba;exports.SelectableList=mu;exports.Stack=uu;exports.Timeline=yf;exports.getApiClient=oi;exports.initializeApiClient=iu;exports.useMutation=ou;exports.useQuery=ul;
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),[y,D]=w.useState(""),x=w.useRef(null),k=w.useRef(null);w.useEffect(()=>{function N(j){x.current&&!x.current.contains(j.target)&&(m(!1),D(""))}return document.addEventListener("mousedown",N),()=>document.removeEventListener("mousedown",N)},[]);const C=r.filter(N=>{var j;return((j=N.label)==null?void 0:j.toLowerCase().includes(y.toLowerCase()))&&!e.includes(N.id)}),S=s&&y.trim()&&!r.some(N=>{var j;return((j=N.label)==null?void 0:j.toLowerCase())===y.toLowerCase()}),v=e.map(N=>r.find(j=>j.id===N)).filter(Boolean),_=w.useCallback(N=>{var j;c>0&&e.length>=c||(t([...e,N]),D(""),(j=k.current)==null||j.focus())},[e,t,c]),E=w.useCallback(N=>{t(e.filter(j=>j!==N))},[e,t]),T=w.useCallback(async()=>{if(!S)return;const N=await(o==null?void 0:o(y.trim()));N&&_(N.id),D("")},[S,y,o,_]),z=w.useCallback(N=>{N.key==="Enter"?(N.preventDefault(),S?T():C.length>0&&_(C[0].id)):N.key==="Backspace"&&!y&&e.length>0?E(e[e.length-1]):N.key==="Escape"&&(m(!1),D(""))},[S,C,y,e,T,_,E]);return p.jsxs("div",{ref:x,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:[v.map(N=>p.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"2px 8px",borderRadius:"4px",fontSize:"13px",background:N.color||h.chipBackground,color:N.color?"#fff":h.chipText},children:[N.label,!u&&p.jsx("button",{type:"button",onClick:j=>{j.stopPropagation(),E(N.id)},style:{border:"none",background:"transparent",cursor:"pointer",padding:"0 2px",fontSize:"14px",color:"inherit",opacity:.7},children:"×"})]},N.id)),p.jsx("input",{ref:k,type:"text",value:y,onChange:N=>{D(N.target.value),g||m(!0)},onFocus:()=>m(!0),onKeyDown:z,placeholder:v.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:C.length===0&&!S?p.jsx("div",{style:{padding:"12px",fontSize:"14px",color:h.textSecondary,textAlign:"center"},children:y?"No matches":"No options available"}):p.jsxs(p.Fragment,{children:[C.map(N=>p.jsxs("div",{onClick:()=>_(N.id),style:{padding:"10px 12px",fontSize:"14px",cursor:"pointer",color:h.text,display:"flex",alignItems:"center",justifyContent:"space-between"},onMouseEnter:j=>{j.currentTarget.style.background=h.hoverBackground||""},onMouseLeave:j=>{j.currentTarget.style.background=""},children:[N.label,i&&l&&p.jsx("button",{type:"button",onClick:j=>{j.stopPropagation(),l(N.id)},style:{border:"none",background:"transparent",cursor:"pointer",padding:"2px",fontSize:"14px",color:h.textSecondary,opacity:.5},onMouseEnter:j=>{j.currentTarget.style.opacity="1",j.currentTarget.style.color="#ef4444"},onMouseLeave:j=>{j.currentTarget.style.opacity="0.5",j.currentTarget.style.color=h.textSecondary||""},children:"×"})]},N.id)),S&&p.jsxs("div",{onClick:T,style:{padding:"10px 12px",fontSize:"14px",cursor:"pointer",color:h.primary,borderTop:C.length>0?`1px solid ${h.border}`:"none"},onMouseEnter:N=>{N.currentTarget.style.background=h.hoverBackground||""},onMouseLeave:N=>{N.currentTarget.style.background=""},children:['+ Create "',y.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),[y,D]=w.useState(null),[x,k]=w.useState(null),C=w.useRef(null),S=e.reduce((j,R)=>{let L=r.filter(O=>n(O)===R.id);return s&&(L=L.sort((O,Y)=>s(O)-s(Y))),j[R.id]=L,j},{}),v=w.useCallback((j,R)=>{const L=t(R),O=n(R);m(L),C.current=O,j.dataTransfer.effectAllowed="move",j.dataTransfer.setData("text/plain",L),requestAnimationFrame(()=>{const Y=j.target;Y.style.opacity="0.5"})},[t,n]),_=w.useCallback(j=>{const R=j.target;R.style.opacity="1",m(null),D(null),k(null),C.current=null},[]),E=w.useCallback((j,R,L)=>{j.preventDefault(),j.dataTransfer.dropEffect="move",D(R),k(L)},[]),T=w.useCallback(j=>{const R=j.relatedTarget;R!=null&&R.closest("[data-kanban-column]")||(D(null),k(null))},[]),z=w.useCallback((j,R,L)=>{if(j.preventDefault(),!g)return;const O=C.current;O===R?l==null||l(g,R,L):O&&i(g,O,R,L),m(null),D(null),k(null),C.current=null},[g,i,l]),N=(j,R)=>p.jsxs("div",{className:"flex items-center justify-between px-3 py-2",children:[p.jsxs("div",{className:"flex items-center gap-2",children:[j.color&&p.jsx("div",{className:"w-2 h-2 rounded-full",style:{backgroundColor:j.color}}),p.jsx("span",{className:"font-medium text-sm text-neutral-700",children:j.label})]}),p.jsx("span",{className:"text-xs text-neutral-400 bg-neutral-100 px-2 py-0.5 rounded-full",children:R})]});return p.jsx("div",{className:`flex gap-4 overflow-x-auto pb-4 ${d}`,style:{minHeight:"400px"},children:e.map(j=>{const R=S[j.id]||[],L=y===j.id;return p.jsxs("div",{"data-kanban-column":j.id,className:`flex-1 min-w-[180px] bg-neutral-50 rounded-xl flex flex-col ${f}`,onDragOver:O=>{O.preventDefault(),g&&!L&&D(j.id)},onDragLeave:T,onDrop:O=>z(O,j.id,x??R.length),children:[p.jsx("div",{className:"flex-shrink-0 border-b border-neutral-200",children:u?u(j,R.length):N(j,R.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:[R.map((O,Y)=>{const ce=t(O),Z=g===ce,Ce=L&&x===Y&&!Z;return p.jsxs("div",{children:[Ce&&p.jsx("div",{className:"h-1 bg-blue-500 rounded-full mb-2 mx-1"}),p.jsx("div",{draggable:!0,onDragStart:ie=>v(ie,O),onDragEnd:_,onDragOver:ie=>E(ie,j.id,Y),onClick:()=>a==null?void 0:a(O),className:`cursor-grab active:cursor-grabbing transition-all ${Z?"opacity-50 scale-95":""} ${h}`,children:o(O,Z)})]},ce)}),p.jsx("div",{className:"min-h-[40px] flex-1",onDragOver:O=>{O.preventDefault(),E(O,j.id,R.length)},children:L&&x===R.length&&p.jsx("div",{className:"h-1 bg-blue-500 rounded-full mx-1 mt-1"})}),R.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(j)})]},j.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:y,timedItems:D}=w.useMemo(()=>{const _=[],E=[];for(const T of r)l(T)?_.push(T):E.push(T);return{allDayItems:_,timedItems:E}},[r,l]),x=w.useMemo(()=>{const _=[];for(let E=t;E<=n;E++)_.push(E);return _},[t,n]),k=(n-t+1)*s,C=w.useCallback(_=>{const E=o(_);if(!E)return null;const T=pf(E);if(!T)return null;const{hours:z,minutes:N}=T,j=Math.max(t,Math.min(n,z)),R=z<t?0:N,L=(j-t)*s+R/60*s,O=i(_),Y=Math.max(20,O/60*s);return{top:L,height:Y}},[o,i,t,n,s]),S=w.useMemo(()=>{if(!f||!mf(e))return null;const _=new Date,E=_.getHours(),T=_.getMinutes();return E<t||E>n?null:(E-t)*s+T/60*s},[e,f,t,n,s]),v=w.useCallback(_=>{if(!d)return;const E=_.currentTarget.getBoundingClientRect(),z=(_.clientY-E.top)/s*60,N=Math.floor(z/60)+t,j=Math.round(z%60/15)*15,R=Math.min(n,Math.max(t,N)),L=j>=60?0:j,O=`${R.toString().padStart(2,"0")}:${L.toString().padStart(2,"0")}`;d(O)},[d,s,t,n]);return p.jsxs("div",{className:h,style:{background:m.background},children:[y.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:y.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:k},children:[x.map((_,E)=>p.jsxs("div",{style:{position:"absolute",top:E*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}}),E<x.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:v}),S!==null&&p.jsxs("div",{style:{position:"absolute",left:"55px",right:0,top:S,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}})]}),D.map(_=>{const E=C(_);return E?p.jsx("div",{style:{position:"absolute",left:"64px",right:"8px",top:E.top,height:E.height,zIndex:10,cursor:c?"pointer":"default"},onClick:T=>{T.stopPropagation(),c==null||c(_)},children:u(_)},a(_)):null})]})]})}function xf({onComplete:r,onCancel:e,onTranscribe:t,transcribing:n,variant:s="widget",hideSaveButton:o=!1}){const i=s==="widget",[l,a]=w.useState("idle"),[u,c]=w.useState(0),[d,f]=w.useState(0),[h,g]=w.useState(!1),[m,y]=w.useState(0),[D,x]=w.useState(null),[k,C]=w.useState(!1),[S,v]=w.useState(null),_=w.useRef(null),E=w.useRef(null),T=w.useRef(null),z=w.useRef(null),N=w.useRef(null),j=w.useRef([]),R=w.useRef(null),L=w.useRef(null),O=w.useRef(null),Y=w.useRef(null),ce=w.useRef(!1),Z=w.useRef([]),Ce=w.useRef(null),ie=w.useRef(null),ye=w.useRef([]),Se=w.useRef([]),je=w.useRef("insert"),Me=w.useRef(!1),ke=w.useRef(0),be=w.useRef(0),We=w.useRef(0),Ae=U=>{const B=Math.floor(U/60),X=Math.floor(U%60);return`${B.toString().padStart(2,"0")}:${X.toString().padStart(2,"0")}`},de=async U=>{const B=await U.arrayBuffer(),X=new AudioContext,J=await X.decodeAudioData(B);return await X.close(),J},qe=U=>{const B=U.numberOfChannels,X=U.sampleRate,J=1,A=16,I=A/8,H=B*I,Q=X*H,te=U.length*H,le=new ArrayBuffer(44+te),ne=new DataView(le),re=(ge,fe)=>{for(let Ie=0;Ie<fe.length;Ie++)ne.setUint8(ge+Ie,fe.charCodeAt(Ie))};re(0,"RIFF"),ne.setUint32(4,36+te,!0),re(8,"WAVE"),re(12,"fmt "),ne.setUint32(16,16,!0),ne.setUint16(20,J,!0),ne.setUint16(22,B,!0),ne.setUint32(24,X,!0),ne.setUint32(28,Q,!0),ne.setUint16(32,H,!0),ne.setUint16(34,A,!0),re(36,"data"),ne.setUint32(40,te,!0);const _e=[];for(let ge=0;ge<B;ge++)_e.push(U.getChannelData(ge));let Be=44;for(let ge=0;ge<U.length;ge++)for(let fe=0;fe<B;fe++){const Ie=Math.max(-1,Math.min(1,_e[fe][ge])),$e=Ie<0?Ie*32768:Ie*32767;ne.setInt16(Be,$e,!0),Be+=2}return new Blob([le],{type:"audio/wav"})},At=async(U,B,X,J)=>{const A=new AudioContext,I=U.sampleRate,H=Math.max(U.numberOfChannels,B.numberOfChannels),Q=Math.min(X,U.length),te=Math.max(0,U.length-X),le=J==="insert"?Q+B.length+te:Q+B.length,ne=A.createBuffer(H,le,I);for(let re=0;re<H;re++){const _e=ne.getChannelData(re),Be=re<U.numberOfChannels?U.getChannelData(re):U.getChannelData(0);for(let fe=0;fe<Q;fe++)_e[fe]=Be[fe];const ge=re<B.numberOfChannels?B.getChannelData(re):B.getChannelData(0);for(let fe=0;fe<B.length;fe++)_e[Q+fe]=ge[fe];if(J==="insert")for(let fe=0;fe<te;fe++)_e[Q+B.length+fe]=Be[X+fe]}return await A.close(),ne},yt=w.useCallback(()=>{const U=_.current;if(!U)return;const B=U.getContext("2d");if(!B)return;const X=U.getBoundingClientRect(),J=X.width,A=X.height,I=Z.current,H=d||u||1,Q=l==="recording"?u:m;B.fillStyle="#2d3b35",B.fillRect(0,0,J,A);const te=8,le="rgba(0, 0, 0, 0.4)",ne=B.createLinearGradient(0,0,0,te);ne.addColorStop(0,le),ne.addColorStop(1,"transparent"),B.fillStyle=ne,B.fillRect(0,0,J,te);const re=B.createLinearGradient(0,A-te,0,A);re.addColorStop(0,"transparent"),re.addColorStop(1,le),B.fillStyle=re,B.fillRect(0,A-te,J,te);const _e=B.createLinearGradient(0,0,te,0);_e.addColorStop(0,le),_e.addColorStop(1,"transparent"),B.fillStyle=_e,B.fillRect(0,0,te,A);const Be=B.createLinearGradient(J-te,0,J,0);Be.addColorStop(0,"transparent"),Be.addColorStop(1,le),B.fillStyle=Be,B.fillRect(J-te,0,te,A),B.strokeStyle="#5a6b62",B.lineWidth=1,B.beginPath(),B.moveTo(0,A/2),B.lineTo(J,A/2),B.stroke();const ge=J/2;if(I.length>0)if(l==="recording")for(let $e=0;$e<I.length;$e++){const it=I.length-1-$e,bt=ge-it*4;if(bt<-3||bt>J)continue;const ut=I[$e]*(A/2-12),Tt=A/2-ut;B.fillStyle="#10b981",B.fillRect(bt,Tt,3,ut*2)}else{const $e=H>0?Q/H*I.length:0;for(let it=0;it<I.length;it++){const bt=$e-it,ut=ge-bt*4;if(ut<-3||ut>J)continue;const Tt=I[it]*(A/2-12),fr=A/2-Tt;B.fillStyle=it<=$e?"#10b981":"#4b5563",B.fillRect(ut,fr,3,Tt*2)}}B.strokeStyle="#ef4444",B.lineWidth=1,B.beginPath(),B.moveTo(ge,0),B.lineTo(ge,A),B.stroke(),B.fillStyle="#fff",B.font="bold 18px monospace",B.textAlign="center",B.fillText(Ae(Q),ge,A-6),l==="recording"&&(B.fillStyle="#ef4444",B.beginPath(),B.arc(20,20,8,0,Math.PI*2),B.fill(),B.fillStyle="#fff",B.font="10px sans-serif",B.textAlign="left",B.fillText("REC",34,24)),B.textAlign="left"},[l,m,u,d]),Pt=()=>{const U=N.current;if(!U||!ce.current)return;const B=U.frequencyBinCount,X=new Uint8Array(B);U.getByteTimeDomainData(X);let J=0;for(let H=0;H<B;H++){const Q=(X[H]-128)/128;J+=Q*Q}const A=Math.sqrt(J/B),I=Math.min(1,A*3);Z.current.push(I),yt(),ce.current&&(L.current=requestAnimationFrame(Pt))},nt=async()=>{try{x(null),C(!1),Ce.current===null&&(Z.current=[]);const U=await navigator.mediaDevices.getUserMedia({audio:!0});T.current=U;const B=new AudioContext;z.current=B;const X=B.createAnalyser();X.fftSize=2048,N.current=X,B.createMediaStreamSource(U).connect(X);const A=new MediaRecorder(U);E.current=A,j.current=[],A.ondataavailable=I=>{I.data.size>0&&j.current.push(I.data)},A.onstop=async()=>{try{if(ce.current=!1,j.current.length===0){x("No audio was recorded. Please try again."),a("idle"),U.getTracks().forEach(ne=>ne.stop());return}const I=new Blob(j.current,{type:"audio/webm"});let H,Q;if(Ce.current!==null&&ie.current)try{const ne=await de(I),re=ie.current.sampleRate,_e=Math.floor(Ce.current*re),Be=await At(ie.current,ne,_e,je.current);H=qe(Be),Q=Be.length/Be.sampleRate,je.current==="insert"&&(Z.current=[...Z.current,...Se.current]),Ce.current=null,ie.current=null,ye.current=[],Se.current=[]}catch{H=I,Q=ke.current>0?ke.current:1}else H=I,Q=ke.current>0?ke.current:1;Y.current=H;const te=URL.createObjectURL(H),le=new Audio(te);le.ontimeupdate=()=>{y(le.currentTime)},le.onended=()=>{g(!1)},O.current=le,f(Q),y(Q),a("editing"),U.getTracks().forEach(ne=>ne.stop())}catch{x("Failed to process recording"),a("idle")}},A.start(100),ce.current=!0,a("recording"),c(0),ke.current=0,R.current=setInterval(()=>{ke.current+=1,c(ke.current)},1e3)}catch{x("Could not access microphone. Please allow microphone access.")}},st=()=>{ce.current=!1,C(!1),v(null),L.current&&(cancelAnimationFrame(L.current),L.current=null),R.current&&(clearInterval(R.current),R.current=null),E.current&&E.current.state!=="inactive"&&E.current.stop()},at=U=>{const B=_.current;if(!B)return;const X=d||u;if(X<=0)return;const J=Z.current;if(J.length===0)return;const A=B.getBoundingClientRect(),I=U-be.current,H=4,Q=A.width/B.width,te=J.length/X*H,le=-I/(te*Q),ne=We.current+le,re=Math.max(0,Math.min(ne,X));O.current&&(O.current.currentTime=re),y(re)},Ot=()=>{O.current&&(O.current.currentTime=0),y(0)},Mt=()=>{const U=d||u;O.current&&(O.current.currentTime=U),y(U)},Ze=()=>{const U=O.current;U&&(h?(U.pause(),y(U.currentTime),g(!1)):(U.currentTime=m,U.play().catch(()=>{}),g(!0)))},et=async U=>{if(!Y.current){nt();return}try{O.current&&(O.current.pause(),g(!1)),je.current=U,ie.current=await de(Y.current);const B=d||u;Ce.current=m;const X=B>0?m/B:0,J=Math.floor(X*Z.current.length);ye.current=Z.current.slice(0,J),Se.current=Z.current.slice(J),Z.current=[...ye.current],nt()}catch{x("Failed to prepare recording. Please try again.")}},It=()=>{O.current&&(O.current.pause(),O.current=null),Y.current=null,ie.current=null,Ce.current=null,ye.current=[],g(!1),y(0),f(0),c(0),nt()},V=()=>{Y.current?r(Y.current,d||u):alert("No audio recorded yet!")};if(w.useEffect(()=>{l==="recording"&&_.current&&N.current&&ce.current&&(L.current=requestAnimationFrame(Pt))},[l]),w.useEffect(()=>{const U=_.current;if(!U)return;const B=()=>{const X=window.devicePixelRatio||1,J=U.getBoundingClientRect();U.width=J.width*X,U.height=J.height*X;const A=U.getContext("2d");A&&A.scale(X,X)};return B(),window.addEventListener("resize",B),()=>window.removeEventListener("resize",B)},[]),w.useEffect(()=>{if(l==="idle"){const U=_.current;if(!U)return;const B=U.getContext("2d");if(!B)return;const X=U.getBoundingClientRect(),J=X.width,A=X.height;B.fillStyle="#2d3b35",B.fillRect(0,0,J,A);const I=8,H="rgba(0, 0, 0, 0.4)",Q=B.createLinearGradient(0,0,0,I);Q.addColorStop(0,H),Q.addColorStop(1,"transparent"),B.fillStyle=Q,B.fillRect(0,0,J,I);const te=B.createLinearGradient(0,A-I,0,A);te.addColorStop(0,"transparent"),te.addColorStop(1,H),B.fillStyle=te,B.fillRect(0,A-I,J,I);const le=B.createLinearGradient(0,0,I,0);le.addColorStop(0,H),le.addColorStop(1,"transparent"),B.fillStyle=le,B.fillRect(0,0,I,A);const ne=B.createLinearGradient(J-I,0,J,0);ne.addColorStop(0,"transparent"),ne.addColorStop(1,H),B.fillStyle=ne,B.fillRect(J-I,0,I,A),B.strokeStyle="#5a6b62",B.lineWidth=1,B.beginPath(),B.moveTo(0,A/2),B.lineTo(J,A/2),B.stroke();const re=J/2;B.strokeStyle="#ef4444",B.lineWidth=1,B.beginPath(),B.moveTo(re,0),B.lineTo(re,A),B.stroke(),B.fillStyle="#fff",B.font="bold 18px monospace",B.textAlign="center",B.fillText("00:00",re,A-6)}},[l]),w.useEffect(()=>()=>{ce.current=!1,R.current&&clearInterval(R.current),L.current&&cancelAnimationFrame(L.current),T.current&&T.current.getTracks().forEach(U=>U.stop()),z.current&&z.current.state!=="closed"&&z.current.close()},[]),w.useEffect(()=>{if(l==="editing"&&h){let U;const B=()=>{const X=O.current;if(X&&h){const J=_.current;if(J){const A=J.getContext("2d");if(A){const I=J.getBoundingClientRect(),H=I.width,Q=I.height,te=Z.current,le=d||u||1,ne=X.currentTime;A.fillStyle="#2d3b35",A.fillRect(0,0,H,Q);const re=8,_e="rgba(0, 0, 0, 0.4)",Be=A.createLinearGradient(0,0,0,re);Be.addColorStop(0,_e),Be.addColorStop(1,"transparent"),A.fillStyle=Be,A.fillRect(0,0,H,re);const ge=A.createLinearGradient(0,Q-re,0,Q);ge.addColorStop(0,"transparent"),ge.addColorStop(1,_e),A.fillStyle=ge,A.fillRect(0,Q-re,H,re);const fe=A.createLinearGradient(0,0,re,0);fe.addColorStop(0,_e),fe.addColorStop(1,"transparent"),A.fillStyle=fe,A.fillRect(0,0,re,Q);const Ie=A.createLinearGradient(H-re,0,H,0);Ie.addColorStop(0,"transparent"),Ie.addColorStop(1,_e),A.fillStyle=Ie,A.fillRect(H-re,0,re,Q),A.strokeStyle="#5a6b62",A.lineWidth=1,A.beginPath(),A.moveTo(0,Q/2),A.lineTo(H,Q/2),A.stroke();const $e=H/2,it=3,bt=4,ut=le>0?ne/le*te.length:0;for(let Qt=0;Qt<te.length;Qt++){const ys=ut-Qt,hr=$e-ys*bt;if(hr<-it||hr>H)continue;const Fr=te[Qt]*(Q/2-12),xs=Q/2-Fr;A.fillStyle=Qt<=ut?"#10b981":"#4b5563",A.fillRect(hr,xs,it,Fr*2)}A.strokeStyle="#ef4444",A.lineWidth=1,A.beginPath(),A.moveTo($e,0),A.lineTo($e,Q),A.stroke(),A.fillStyle="#fff",A.font="bold 18px monospace",A.textAlign="center";const Tt=Math.floor(ne/60),fr=Math.floor(ne%60);A.fillText(`${Tt.toString().padStart(2,"0")}:${fr.toString().padStart(2,"0")}`,$e,Q-6),A.textAlign="left"}}U=requestAnimationFrame(B)}};return U=requestAnimationFrame(B),()=>cancelAnimationFrame(U)}},[l,h,d,u]),w.useEffect(()=>{l==="editing"&&!h&&yt()},[l,m,h,yt]),D)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:D}),p.jsx("button",{onClick:()=>{x(null),nt()},style:{padding:"8px 16px",fontSize:"14px",background:"#171717",color:"white",borderRadius:"8px",border:"none",cursor:"pointer"},children:"Try Again"})]});const xe={padding:"8px",borderRadius:"8px",border:"none",background:"transparent",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",transition:"background 0.15s"},Te={...xe,opacity:.3,cursor:"not-allowed"},xt=i?{border:"1px solid #e5e5e5",borderRadius:"12px",overflow:"hidden",background:"white"}:{overflow:"hidden",background:"white",flexShrink:0};return p.jsxs("div",{style:xt,children:[p.jsx("canvas",{ref:_,style:{width:"100%",height:"64px",cursor:"pointer",flexShrink:0},onMouseDown:U=>{if(l==="editing"){Me.current=!0,be.current=U.clientX,We.current=m;const B=J=>{Me.current&&at(J.clientX)},X=()=>{Me.current=!1,window.removeEventListener("mousemove",B),window.removeEventListener("mouseup",X)};window.addEventListener("mousemove",B),window.addEventListener("mouseup",X)}}}),p.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:i?"10px 12px":"8px",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:Ot,disabled:l==="idle"||l==="recording",style:l==="idle"||l==="recording"?Te:xe,title:"Go to start",children:p.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:"#171717"},children:"first_page"})}),p.jsx("button",{onClick:()=>{if(l==="recording"){const U=E.current;U&&(U.state==="recording"?(U.pause(),C(!0)):U.state==="paused"&&(U.resume(),C(!1)))}else Ze()},disabled:l==="idle",style:l==="idle"?Te:xe,title:h||l==="recording"&&!k?"Pause":"Play",children:p.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:"#171717"},children:h||l==="recording"&&!k?"pause":"play_arrow"})}),p.jsx("button",{onClick:Mt,disabled:l==="idle"||l==="recording",style:l==="idle"||l==="recording"?Te:xe,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:()=>{S==="insert"?st():l==="idle"?(v("insert"),nt()):l==="editing"&&(v("insert"),et("insert"))},disabled:l==="recording"&&S!=="insert"||h,style:l==="recording"&&S!=="insert"||h?Te:xe,title:S==="insert"?"Stop recording":"Insert recording",children:p.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:S==="insert"?"#ef4444":"#171717"},children:"add"})}),p.jsx("button",{onClick:()=>{S==="mic"?st():l==="idle"?(v("mic"),nt()):l==="editing"&&(v("mic"),et("replace"))},disabled:l==="recording"&&S!=="mic"||h,style:l==="recording"&&S!=="mic"||h?Te:xe,title:S==="mic"?"Stop recording":"Record",children:p.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:S==="mic"?"#ef4444":"#171717"},children:"mic"})}),p.jsx("button",{onClick:()=>{S==="startover"?st():l==="editing"&&(v("startover"),It())},disabled:l==="idle"||l==="recording"&&S!=="startover"||h,style:l==="idle"||l==="recording"&&S!=="startover"||h?Te:xe,title:S==="startover"?"Stop recording":"Start over",children:p.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:S==="startover"?"#ef4444":"#171717"},children:"refresh"})})]}),p.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px"},children:[t&&p.jsx("button",{onClick:()=>Y.current&&t(Y.current),disabled:l!=="editing"||n,style:l!=="editing"||n?Te:xe,title:n?"Transcribing...":"Transcribe audio",children:p.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:"#171717"},children:n?"hourglass_empty":"subtitles"})}),!o&&p.jsx("button",{onClick:V,disabled:l!=="editing",style:l!=="editing"?Te:xe,title:"Save recording",children:p.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:"#171717"},children:"save"})})]})]})]})}exports.AnimatedCardFlip=hu;exports.ApiClient=al;exports.AudioEditor=xf;exports.AuthManager=ll;exports.Card=cu;exports.ComboBox=df;exports.DataOperations=Bn;exports.Detail=du;exports.GraphClient=Ia;exports.KanbanBoard=ff;exports.Mail=gu;exports.MailClient=ol;exports.MailComposer=uf;exports.MailEditor=Ba;exports.SelectableList=mu;exports.Stack=uu;exports.Timeline=yf;exports.getApiClient=oi;exports.initializeApiClient=iu;exports.useMutation=ou;exports.useQuery=ul;
package/dist/index.esm.js CHANGED
@@ -13569,7 +13569,7 @@ function Nf({ onComplete: r, onCancel: e, onTranscribe: t, transcribing: n, vari
13569
13569
  ..._e,
13570
13570
  opacity: 0.3,
13571
13571
  cursor: "not-allowed"
13572
- }, Ct = i ? { border: "1px solid #e5e5e5", borderRadius: "12px", overflow: "hidden", background: "white" } : { overflow: "hidden", background: "white", height: "100%", display: "flex", flexDirection: "column" };
13572
+ }, Ct = i ? { border: "1px solid #e5e5e5", borderRadius: "12px", overflow: "hidden", background: "white" } : { overflow: "hidden", background: "white", flexShrink: 0 };
13573
13573
  return /* @__PURE__ */ p.jsxs("div", { style: Ct, children: [
13574
13574
  /* @__PURE__ */ p.jsx(
13575
13575
  "canvas",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qwanyx/stack",
3
- "version": "0.2.36",
3
+ "version": "0.2.37",
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",