PageSourceSearch

https://turbo-social-sistem.lovable.app/assets/_app.creator-kanban-PxIz4fQ_.js

js turbo-social-sistem.lovable.app collected 2026-10-03 05:38:11 UTC 93,244 bytes, 11 lines download raw bytes

1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/apify-instagram.functions-D1vxgNEl.js","assets/auth-middleware-PisxvbeK.js","assets/index-DUjTBDAw.js","assets/createServerFn-DewbeZsU.js","assets/client-campaign.functions-Btgp8E1k.js","assets/google-calendar.functions-DVu7I7a2.js"])))=>i.map(i=>d[i]);
2import{c as Kn,r as i,al as K,ai as Nt,j as n,B as q,T as ot,s as A,t as L,u as kr,an as ut}from"./index-DUjTBDAw.js";import{I as ge}from"./input-D1zqKC5g.js";import{T as wt}from"./textarea-4FLAyV7t.js";import{L as se}from"./label-CqjUiLe_.js";import{S as Cr}from"./switch-M3k0tSwH.js";import{D as Yn,a as qn,b as Xn,c as Wn,e as Gn}from"./dialog-Bdeu2XHV.js";import{T as Dr,a as Er,b as an,c as on}from"./tabs-B8ZDMR0b.js";import{A as mn,a as Jn,b as hn}from"./avatar-wIvQjBUl.js";import{S as Bt,a as Ut,b as Ht,c as Vt,d as ne}from"./select-TmllBw2C.js";import{B as Qn}from"./badge-CXzgzJAM.js";import{m as Rn}from"./media-url-CMKjifdw.js";import{P as pn}from"./plus-DgzByaHb.js";import{L as Me}from"./loader-circle-C_hZKJH-.js";import{C as bn}from"./circle-check-DI8JEp6r.js";import{C as jt}from"./chevron-down-0_iIJDrP.js";import{I as An}from"./instagram-D8J3WiL7.js";import{E as ln}from"./external-link-DnVDtagr.js";import{R as _r}from"./refresh-cw-hxz2bMGg.js";import{H as Rr}from"./heart-BqVW2XEB.js";import{M as Ar}from"./message-circle-BmR1_pvo.js";import{L as Tr}from"./link-C5usHKPA.js";import{U as Tn}from"./upload-DOo4EiCG.js";import{F as Mr}from"./file-text-eb2LJ2y0.js";import{M as Pr}from"./message-square-4I0QNCqa.js";import{A as Or}from"./activity-Bcv43tBg.js";import{S as Lr}from"./send-CorqddGL.js";import{C as Ir}from"./circle-DCic2ZH3.js";import"./index-C1bIQB6s.js";import"./index-CVvrTIwl.js";import"./x-CQ33KZgR.js";import"./index-B2hkrpO_.js";import"./index-CmpVwWb7.js";import"./index-CFRUpRML.js";import"./check-BzGlD8RL.js";import"./auth-middleware-PisxvbeK.js";import"./createServerFn-DewbeZsU.js";const $r=[["path",{d:"m12.296 3.464 3.02 3.956",key:"qash78"}],["path",{d:"M20.2 6 3 11l-.9-2.4c-.3-1.1.3-2.2 1.3-2.5l13.5-4c1.1-.3 2.2.3 2.5 1.3z",key:"1h7j8b"}],["path",{d:"M3 11h18v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",key:"4lm6w1"}],["path",{d:"m6.18 5.276 3.1 3.899",key:"zjj9t3"}]],zr=Kn("clapperboard",$r);const Fr=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]],Br=Kn("history",Fr),Jt=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function mt(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function yn(e){return"nodeType"in e}function ue(e){var t,r;return e?mt(e)?e:yn(e)&&(t=(r=e.ownerDocument)==null?void 0:r.defaultView)!=null?t:window:window}function wn(e){const{Document:t}=ue(e);return e instanceof t}function At(e){return mt(e)?!1:e instanceof ue(e).HTMLElement}function Zn(e){return e instanceof ue(e).SVGElement}function ht(e){return e?mt(e)?e.document:yn(e)?wn(e)?e:At(e)||Zn(e)?e.ownerDocument:document:document:document}const He=Jt?i.useLayoutEffect:i.useEffect;function Qt(e){const t=i.useRef(e);return He(()=>{t.current=e}),i.useCallback(function(){for(var r=arguments.length,s=new Array(r),a=0;a<r;a++)s[a]=arguments[a];return t.current==null?void 0:t.current(...s)},[])}function Ur(){const e=i.useRef(null),t=i.useCallback((s,a)=>{e.current=setInterval(s,a)},[]),r=i.useCallback(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[]);return[t,r]}function Et(e,t){t===void 0&&(t=[e]);const r=i.useRef(e);return He(()=>{r.current!==e&&(r.current=e)},t),r}function Tt(e,t){const r=i.useRef();return i.useMemo(()=>{const s=e(r.current);return r.current=s,s},[...t])}function Kt(e){const t=Qt(e),r=i.useRef(null),s=i.useCallback(a=>{a!==r.current&&t?.(a,r.current),r.current=a},[]);return[r,s]}function Yt(e){const t=i.useRef();return i.useEffect(()=>{t.current=e},[e]),t.current}let cn={};function Zt(e,t){return i.useMemo(()=>{if(t)return t;const r=cn[e]==null?0:cn[e]+1;return cn[e]=r,e+"-"+r},[e,t])}function er(e){return function(t){for(var r=arguments.length,s=new Array(r>1?r-1:0),a=1;a<r;a++)s[a-1]=arguments[a];return s.reduce((l,c)=>{const d=Object.entries(c);for(const[u,m]of d){const p=l[u];p!=null&&(l[u]=p+e*m)}return l},{...t})}}const ft=er(1),qt=er(-1);function Hr(e){return"clientX"in e&&"clientY"in e}function jn(e){if(!e)return!1;const{KeyboardEvent:t}=ue(e.target);return t&&e instanceof t}function Vr(e){if(!e)return!1;const{TouchEvent:t}=ue(e.target);return t&&e instanceof t}function Xt(e){if(Vr(e)){if(e.touches&&e.touches.length){const{clientX:t,clientY:r}=e.touches[0];return{x:t,y:r}}else if(e.changedTouches&&e.changedTouches.length){const{clientX:t,clientY:r}=e.changedTouches[0];return{x:t,y:r}}}return Hr(e)?{x:e.clientX,y:e.clientY}:null}const _t=Object.freeze({Translate:{toString(e){if(!e)return;const{x:t,y:r}=e;return"translate3d("+(t?Math.round(t):0)+"px, "+(r?Math.round(r):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;const{scaleX:t,scaleY:r}=e;return"scaleX("+t+") scaleY("+r+")"}},Transform:{toString(e){if(e)return[_t.Translate.toString(e),_t.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:r,easing:s}=e;return t+" "+r+"ms "+s}}}),Mn="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function Kr(e){return e.matches(Mn)?e:e.querySelector(Mn)}const Yr={display:"none"};function qr(e){let{id:t,value:r}=e;return K.createElement("div",{id:t,style:Yr},r)}function Xr(e){let{id:t,announcement:r,ariaLiveType:s="assertive"}=e;const a={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return K.createElement("div",{id:t,style:a,role:"status","aria-live":s,"aria-atomic":!0},r)}function Wr(){const[e,t]=i.useState("");return{announce:i.useCallback(s=>{s!=null&&t(s)},[]),announcement:e}}const tr=i.createContext(null);function Gr(e){const t=i.useContext(tr);i.useEffect(()=>{if(!t)throw new Error("useDndMonitor must be used within a children of <DndContext>");return t(e)},[e,t])}function Jr(){const[e]=i.useState(()=>new Set),t=i.useCallback(s=>(e.add(s),()=>e.delete(s)),[e]);return[i.useCallback(s=>{let{type:a,event:l}=s;e.forEach(c=>{var d;
2return(d=c[a])==null?void 0:d.call(c,l)})},[e]),t]}const Qr={draggable:`
3    To pick up a draggable item, press the space bar.
4    While dragging, use the arrow keys to move the item.
5    Press space again to drop the item in its new position, or press escape to cancel.
6  `},Zr={onDragStart(e){let{active:t}=e;return"Picked up draggable item "+t.id+"."},onDragOver(e){let{active:t,over:r}=e;return r?"Draggable item "+t.id+" was moved over droppable area "+r.id+".":"Draggable item "+t.id+" is no longer over a droppable area."},onDragEnd(e){let{active:t,over:r}=e;return r?"Draggable item "+t.id+" was dropped over droppable area "+r.id:"Draggable item "+t.id+" was dropped."},onDragCancel(e){let{active:t}=e;return"Dragging was cancelled. Draggable item "+t.id+" was dropped."}};function es(e){let{announcements:t=Zr,container:r,hiddenTextDescribedById:s,screenReaderInstructions:a=Qr}=e;const{announce:l,announcement:c}=Wr(),d=Zt("DndLiveRegion"),[u,m]=i.useState(!1);if(i.useEffect(()=>{m(!0)},[]),Gr(i.useMemo(()=>({onDragStart(h){let{active:x}=h;l(t.onDragStart({active:x}))},onDragMove(h){let{active:x,over:v}=h;t.onDragMove&&l(t.onDragMove({active:x,over:v}))},onDragOver(h){let{active:x,over:v}=h;l(t.onDragOver({active:x,over:v}))},onDragEnd(h){let{active:x,over:v}=h;l(t.onDragEnd({active:x,over:v}))},onDragCancel(h){let{active:x,over:v}=h;l(t.onDragCancel({active:x,over:v}))}}),[l,t])),!u)return null;const p=K.createElement(K.Fragment,null,K.createElement(qr,{id:s,value:a.draggable}),K.createElement(Xr,{id:d,announcement:c}));return r?Nt.createPortal(p,r):p}var G;(function(e){e.DragStart="dragStart",e.DragMove="dragMove",e.DragEnd="dragEnd",e.DragCancel="dragCancel",e.DragOver="dragOver",e.RegisterDroppable="registerDroppable",e.SetDroppableDisabled="setDroppableDisabled",e.UnregisterDroppable="unregisterDroppable"})(G||(G={}));function Wt(){}function ts(e,t){return i.useMemo(()=>({sensor:e,options:t??{}}),[e,t])}function ns(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return i.useMemo(()=>[...t].filter(s=>s!=null),[...t])}const _e=Object.freeze({x:0,y:0});function rs(e,t){const r=Xt(e);if(!r)return"0 0";const s={x:(r.x-t.left)/t.width*100,y:(r.y-t.top)/t.height*100};return s.x+"% "+s.y+"%"}function ss(e,t){let{data:{value:r}}=e,{data:{value:s}}=t;return s-r}function as(e,t){if(!e||e.length===0)return null;const[r]=e;return r[t]}function os(e,t){const r=Math.max(t.top,e.top),s=Math.max(t.left,e.left),a=Math.min(t.left+t.width,e.left+e.width),l=Math.min(t.top+t.height,e.top+e.height),c=a-s,d=l-r;if(s<a&&r<l){const u=t.width*t.height,m=e.width*e.height,p=c*d,h=p/(u+m-p);return Number(h.toFixed(4))}return 0}const is=e=>{let{collisionRect:t,droppableRects:r,droppableContainers:s}=e;const a=[];for(const l of s){const{id:c}=l,d=r.get(c);if(d){const u=os(d,t);u>0&&a.push({id:c,data:{droppableContainer:l,value:u}})}}return a.sort(ss)};function ls(e,t,r){return{...e,scaleX:t&&r?t.width/r.width:1,scaleY:t&&r?t.height/r.height:1}}function nr(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:_e}function cs(e){return function(r){for(var s=arguments.length,a=new Array(s>1?s-1:0),l=1;l<s;l++)a[l-1]=arguments[l];return a.reduce((c,d)=>({...c,top:c.top+e*d.y,bottom:c.bottom+e*d.y,left:c.left+e*d.x,right:c.right+e*d.x}),{...r})}}const ds=cs(1);function rr(e){if(e.startsWith("matrix3d(")){const t=e.slice(9,-1).split(/, /);return{x:+t[12],y:+t[13],scaleX:+t[0],scaleY:+t[5]}}else if(e.startsWith("matrix(")){const t=e.slice(7,-1).split(/, /);return{x:+t[4],y:+t[5],scaleX:+t[0],scaleY:+t[3]}}return null}function us(e,t,r){const s=rr(t);if(!s)return e;const{scaleX:a,scaleY:l,x:c,y:d}=s,u=e.left-c-(1-a)*parseFloat(r),m=e.top-d-(1-l)*parseFloat(r.slice(r.indexOf(" ")+1)),p=a?e.width/a:e.width,h=l?e.height/l:e.height;return{width:p,height:h,top:m,right:u+p,bottom:m+h,left:u}}const fs={ignoreTransform:!1};function Mt(e,t){t===void 0&&(t=fs);let r=e.getBoundingClientRect();if(t.ignoreTransform){const{transform:m,transformOrigin:p}=ue(e).getComputedStyle(e);m&&(r=us(r,m,p))}const{top:s,left:a,width:l,height:c,bottom:d,right:u}=r;return{top:s,left:a,width:l,height:c,bottom:d,right:u}}function Pn(e){return Mt(e,{ignoreTransform:!0})}
6function ms(e){const t=e.innerWidth,r=e.innerHeight;return{top:0,left:0,right:t,bottom:r,width:t,height:r}}function hs(e,t){return t===void 0&&(t=ue(e).getComputedStyle(e)),t.position==="fixed"}function ps(e,t){t===void 0&&(t=ue(e).getComputedStyle(e));const r=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(a=>{const l=t[a];return typeof l=="string"?r.test(l):!1})}function Nn(e,t){const r=[];function s(a){if(t!=null&&r.length>=t||!a)return r;if(wn(a)&&a.scrollingElement!=null&&!r.includes(a.scrollingElement))return r.push(a.scrollingElement),r;if(!At(a)||Zn(a)||r.includes(a))return r;const l=ue(e).getComputedStyle(a);return a!==e&&ps(a,l)&&r.push(a),hs(a,l)?r:s(a.parentNode)}return e?s(e):r}function sr(e){const[t]=Nn(e,1);return t??null}function dn(e){return!Jt||!e?null:mt(e)?e:yn(e)?wn(e)||e===ht(e).scrollingElement?window:At(e)?e:null:null}function ar(e){return mt(e)?e.scrollX:e.scrollLeft}function or(e){return mt(e)?e.scrollY:e.scrollTop}function gn(e){return{x:ar(e),y:or(e)}}var Z;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(Z||(Z={}));function ir(e){return!Jt||!e?!1:e===document.scrollingElement}function lr(e){const t={x:0,y:0},r=ir(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},s={x:e.scrollWidth-r.width,y:e.scrollHeight-r.height},a=e.scrollTop<=t.y,l=e.scrollLeft<=t.x,c=e.scrollTop>=s.y,d=e.scrollLeft>=s.x;return{isTop:a,isLeft:l,isBottom:c,isRight:d,maxScroll:s,minScroll:t}}const gs={x:.2,y:.2};function xs(e,t,r,s,a){let{top:l,left:c,right:d,bottom:u}=r;s===void 0&&(s=10),a===void 0&&(a=gs);const{isTop:m,isBottom:p,isLeft:h,isRight:x}=lr(e),v={x:0,y:0},_={x:0,y:0},y={height:t.height*a.y,width:t.width*a.x};return!m&&l<=t.top+y.height?(v.y=Z.Backward,_.y=s*Math.abs((t.top+y.height-l)/y.height)):!p&&u>=t.bottom-y.height&&(v.y=Z.Forward,_.y=s*Math.abs((t.bottom-y.height-u)/y.height)),!x&&d>=t.right-y.width?(v.x=Z.Forward,_.x=s*Math.abs((t.right-y.width-d)/y.width)):!h&&c<=t.left+y.width&&(v.x=Z.Backward,_.x=s*Math.abs((t.left+y.width-c)/y.width)),{direction:v,speed:_}}function vs(e){if(e===document.scrollingElement){const{innerWidth:l,innerHeight:c}=window;return{top:0,left:0,right:l,bottom:c,width:l,height:c}}const{top:t,left:r,right:s,bottom:a}=e.getBoundingClientRect();return{top:t,left:r,right:s,bottom:a,width:e.clientWidth,height:e.clientHeight}}function cr(e){return e.reduce((t,r)=>ft(t,gn(r)),_e)}function bs(e){return e.reduce((t,r)=>t+ar(r),0)}function ys(e){return e.reduce((t,r)=>t+or(r),0)}function dr(e,t){if(t===void 0&&(t=Mt),!e)return;const{top:r,left:s,bottom:a,right:l}=t(e);sr(e)&&(a<=0||l<=0||r>=window.innerHeight||s>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}const ws=[["x",["left","right"],bs],["y",["top","bottom"],ys]];class Sn{constructor(t,r){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;const s=Nn(r),a=cr(s);this.rect={...t},this.width=t.width,this.height=t.height;for(const[l,c,d]of ws)for(const u of c)Object.defineProperty(this,u,{get:()=>{const m=d(s),p=a[l]-m;return this.rect[u]+p},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class kt{constructor(t){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(r=>{var s;return(s=this.target)==null?void 0:s.removeEventListener(...r)})},this.target=t}add(t,r,s){var a;(a=this.target)==null||a.addEventListener(t,r,s),this.listeners.push([t,r,s])}}function js(e){const{EventTarget:t}=ue(e);return e instanceof t?e:ht(e)}function un(e,t){const r=Math.abs(e.x),s=Math.abs(e.y);return typeof t=="number"?Math.sqrt(r**2+s**2)>t:"x"in t&&"y"in t?r>t.x&&s>t.y:"x"in t?r>t.x:"y"in t?s>t.y:!1}var Se;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(Se||(Se={}));function On(e){e.preventDefault()}function Ns(e){e.stopPropagation()}var z;(function(e){e.Space="Space",e.Down="ArrowDown",e.Right="ArrowRight",e.Left="ArrowLeft",e.Up="ArrowUp",e.Esc="Escape",e.Enter="Enter",e.Tab="Tab"})(z||(z={}));const ur={start:[z.Space,z.Enter],cancel:[z.Esc],end:[z.Space,z.Enter,z.Tab]},Ss=(e,t)=>{let{currentCoordinates:r}=t;switch(e.code){case z.Right:return{...r,x:r.x+25};case z.Left:return{...r,x:r.x-25};case z.Down:return{...r,y:r.y+25};case z.Up:return{...r,y:r.y-25}}};
6class fr{constructor(t){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=t;const{event:{target:r}}=t;this.props=t,this.listeners=new kt(ht(r)),this.windowListeners=new kt(ue(r)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(Se.Resize,this.handleCancel),this.windowListeners.add(Se.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(Se.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:t,onStart:r}=this.props,s=t.node.current;s&&dr(s),r(_e)}handleKeyDown(t){if(jn(t)){const{active:r,context:s,options:a}=this.props,{keyboardCodes:l=ur,coordinateGetter:c=Ss,scrollBehavior:d="smooth"}=a,{code:u}=t;if(l.end.includes(u)){this.handleEnd(t);return}if(l.cancel.includes(u)){this.handleCancel(t);return}const{collisionRect:m}=s.current,p=m?{x:m.left,y:m.top}:_e;this.referenceCoordinates||(this.referenceCoordinates=p);const h=c(t,{active:r,context:s.current,currentCoordinates:p});if(h){const x=qt(h,p),v={x:0,y:0},{scrollableAncestors:_}=s.current;for(const y of _){const w=t.code,{isTop:k,isRight:j,isLeft:C,isBottom:E,maxScroll:R,minScroll:T}=lr(y),S=vs(y),D={x:Math.min(w===z.Right?S.right-S.width/2:S.right,Math.max(w===z.Right?S.left:S.left+S.width/2,h.x)),y:Math.min(w===z.Down?S.bottom-S.height/2:S.bottom,Math.max(w===z.Down?S.top:S.top+S.height/2,h.y))},I=w===z.Right&&!j||w===z.Left&&!C,O=w===z.Down&&!E||w===z.Up&&!k;if(I&&D.x!==h.x){const $=y.scrollLeft+x.x,ae=w===z.Right&&$<=R.x||w===z.Left&&$>=T.x;if(ae&&!x.y){y.scrollTo({left:$,behavior:d});return}ae?v.x=y.scrollLeft-$:v.x=w===z.Right?y.scrollLeft-R.x:y.scrollLeft-T.x,v.x&&y.scrollBy({left:-v.x,behavior:d});break}
6else if(O&&D.y!==h.y){const $=y.scrollTop+x.y,ae=w===z.Down&&$<=R.y||w===z.Up&&$>=T.y;if(ae&&!x.x){y.scrollTo({top:$,behavior:d});return}ae?v.y=y.scrollTop-$:v.y=w===z.Down?y.scrollTop-R.y:y.scrollTop-T.y,v.y&&y.scrollBy({top:-v.y,behavior:d});break}}this.handleMove(t,ft(qt(h,this.referenceCoordinates),v))}}}handleMove(t,r){const{onMove:s}=this.props;t.preventDefault(),s(r)}handleEnd(t){const{onEnd:r}=this.props;t.preventDefault(),this.detach(),r()}handleCancel(t){const{onCancel:r}=this.props;t.preventDefault(),this.detach(),r()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}fr.activators=[{eventName:"onKeyDown",handler:(e,t,r)=>{let{keyboardCodes:s=ur,onActivation:a}=t,{active:l}=r;const{code:c}=e.nativeEvent;if(s.start.includes(c)){const d=l.activatorNode.current;return d&&e.target!==d?!1:(e.preventDefault(),a?.({event:e.nativeEvent}),!0)}return!1}}];function Ln(e){return!!(e&&"distance"in e)}function In(e){return!!(e&&"delay"in e)}class kn{constructor(t,r,s){var a;s===void 0&&(s=js(t.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=t,this.events=r;const{event:l}=t,{target:c}=l;this.props=t,this.events=r,this.document=ht(c),this.documentListeners=new kt(this.document),this.listeners=new kt(s),this.windowListeners=new kt(ue(c)),this.initialCoordinates=(a=Xt(l))!=null?a:_e,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){const{events:t,props:{options:{activationConstraint:r,bypassActivationConstraint:s}}}=this;if(this.listeners.add(t.move.name,this.handleMove,{passive:!1}),this.listeners.add(t.end.name,this.handleEnd),t.cancel&&this.listeners.add(t.cancel.name,this.handleCancel),this.windowListeners.add(Se.Resize,this.handleCancel),this.windowListeners.add(Se.DragStart,On),this.windowListeners.add(Se.VisibilityChange,this.handleCancel),this.windowListeners.add(Se.ContextMenu,On),this.documentListeners.add(Se.Keydown,this.handleKeydown),r){if(s!=null&&s({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(In(r)){this.timeoutId=setTimeout(this.handleStart,r.delay),this.handlePending(r);return}if(Ln(r)){this.handlePending(r);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(t,r){const{active:s,onPending:a}=this.props;a(s,t,this.initialCoordinates,r)}handleStart(){const{initialCoordinates:t}=this,{onStart:r}=this.props;t&&(this.activated=!0,this.documentListeners.add(Se.Click,Ns,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(Se.SelectionChange,this.removeTextSelection),r(t))}handleMove(t){var r;const{activated:s,initialCoordinates:a,props:l}=this,{onMove:c,options:{activationConstraint:d}}=l;if(!a)return;const u=(r=Xt(t))!=null?r:_e,m=qt(a,u);if(!s&&d){if(Ln(d)){if(d.tolerance!=null&&un(m,d.tolerance))return this.handleCancel();if(un(m,d.distance))return this.handleStart()}if(In(d)&&un(m,d.tolerance))return this.handleCancel();this.handlePending(d,m);return}t.cancelable&&t.preventDefault(),c(u)}handleEnd(){const{onAbort:t,onEnd:r}=this.props;this.detach(),this.activated||t(this.props.active),r()}handleCancel(){const{onAbort:t,onCancel:r}=this.props;this.detach(),this.activated||t(this.props.active),r()}handleKeydown(t){t.code===z.Esc&&this.handleCancel()}removeTextSelection(){var t;(t=this.document.getSelection())==null||t.removeAllRanges()}}const ks={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class Cn extends kn{constructor(t){const{event:r}=t,s=ht(r.target);super(t,ks,s)}}Cn.activators=[{eventName:"onPointerDown",handler:(e,t)=>{let{nativeEvent:r}=e,{onActivation:s}=t;return!r.isPrimary||r.button!==0?!1:(s?.({event:r}),!0)}}];const Cs={move:{name:"mousemove"},end:{name:"mouseup"}};var xn;(function(e){e[e.RightClick=2]="RightClick"})(xn||(xn={}));class Ds extends kn{constructor(t){super(t,Cs,ht(t.event.target))}}Ds.activators=[{eventName:"onMouseDown",handler:(e,t)=>{let{nativeEvent:r}=e,{onActivation:s}=t;return r.button===xn.RightClick?!1:(s?.({event:r}),!0)}}];const fn={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class Es extends kn{constructor(t){super(t,fn)}static setup(){return window.addEventListener(fn.move.name,t,{capture:!1,passive:!1}),function(){window.removeEventListener(fn.move.name,t)};function t(){}}}Es.activators=[{eventName:"onTouchStart",handler:(e,t)=>{let{nativeEvent:r}=e,{onActivation:s}=t;const{touches:a}=r;return a.length>1?!1:(s?.({event:r}),!0)}}];
6var Ct;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})(Ct||(Ct={}));var Gt;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"})(Gt||(Gt={}));function _s(e){let{acceleration:t,activator:r=Ct.Pointer,canScroll:s,draggingRect:a,enabled:l,interval:c=5,order:d=Gt.TreeOrder,pointerCoordinates:u,scrollableAncestors:m,scrollableAncestorRects:p,delta:h,threshold:x}=e;const v=As({delta:h,disabled:!l}),[_,y]=Ur(),w=i.useRef({x:0,y:0}),k=i.useRef({x:0,y:0}),j=i.useMemo(()=>{switch(r){case Ct.Pointer:return u?{top:u.y,bottom:u.y,left:u.x,right:u.x}:null;case Ct.DraggableRect:return a}},[r,a,u]),C=i.useRef(null),E=i.useCallback(()=>{const T=C.current;if(!T)return;const S=w.current.x*k.current.x,D=w.current.y*k.current.y;T.scrollBy(S,D)},[]),R=i.useMemo(()=>d===Gt.TreeOrder?[...m].reverse():m,[d,m]);i.useEffect(()=>{if(!l||!m.length||!j){y();return}for(const T of R){if(s?.(T)===!1)continue;const S=m.indexOf(T),D=p[S];if(!D)continue;const{direction:I,speed:O}=xs(T,D,j,t,x);for(const $ of["x","y"])v[$][I[$]]||(O[$]=0,I[$]=0);if(O.x>0||O.y>0){y(),C.current=T,_(E,c),w.current=O,k.current=I;return}}w.current={x:0,y:0},k.current={x:0,y:0},y()},[t,E,s,y,l,c,JSON.stringify(j),JSON.stringify(v),_,m,R,p,JSON.stringify(x)])}const Rs={x:{[Z.Backward]:!1,[Z.Forward]:!1},y:{[Z.Backward]:!1,[Z.Forward]:!1}};function As(e){let{delta:t,disabled:r}=e;const s=Yt(t);return Tt(a=>{if(r||!s||!a)return Rs;const l={x:Math.sign(t.x-s.x),y:Math.sign(t.y-s.y)};return{x:{[Z.Backward]:a.x[Z.Backward]||l.x===-1,[Z.Forward]:a.x[Z.Forward]||l.x===1},y:{[Z.Backward]:a.y[Z.Backward]||l.y===-1,[Z.Forward]:a.y[Z.Forward]||l.y===1}}},[r,t,s])}function Ts(e,t){const r=t!=null?e.get(t):void 0,s=r?r.node.current:null;return Tt(a=>{var l;return t==null?null:(l=s??a)!=null?l:null},[s,t])}function Ms(e,t){return i.useMemo(()=>e.reduce((r,s)=>{const{sensor:a}=s,l=a.activators.map(c=>({eventName:c.eventName,handler:t(c.handler,s)}));return[...r,...l]},[]),[e,t])}var Rt;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})(Rt||(Rt={}));var vn;(function(e){e.Optimized="optimized"})(vn||(vn={}));const $n=new Map;function Ps(e,t){let{dragging:r,dependencies:s,config:a}=t;const[l,c]=i.useState(null),{frequency:d,measure:u,strategy:m}=a,p=i.useRef(e),h=w(),x=Et(h),v=i.useCallback(function(k){k===void 0&&(k=[]),!x.current&&c(j=>j===null?k:j.concat(k.filter(C=>!j.includes(C))))},[x]),_=i.useRef(null),y=Tt(k=>{if(h&&!r)return $n;if(!k||k===$n||p.current!==e||l!=null){const j=new Map;for(let C of e){if(!C)continue;if(l&&l.length>0&&!l.includes(C.id)&&C.rect.current){j.set(C.id,C.rect.current);continue}const E=C.node.current,R=E?new Sn(u(E),E):null;C.rect.current=R,R&&j.set(C.id,R)}return j}return k},[e,l,r,h,u]);return i.useEffect(()=>{p.current=e},[e]),i.useEffect(()=>{h||v()},[r,h]),i.useEffect(()=>{l&&l.length>0&&c(null)},[JSON.stringify(l)]),i.useEffect(()=>{h||typeof d!="number"||_.current!==null||(_.current=setTimeout(()=>{v(),_.current=null},d))},[d,h,v,...s]),{droppableRects:y,measureDroppableContainers:v,measuringScheduled:l!=null};function w(){switch(m){case Rt.Always:return!1;case Rt.BeforeDragging:return r;default:return!r}}}function Dn(e,t){return Tt(r=>e?r||(typeof t=="function"?t(e):e):null,[t,e])}function Os(e,t){return Dn(e,t)}function Ls(e){let{callback:t,disabled:r}=e;const s=Qt(t),a=i.useMemo(()=>{if(r||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:l}=window;return new l(s)},[s,r]);return i.useEffect(()=>()=>a?.disconnect(),[a]),a}function en(e){let{callback:t,disabled:r}=e;const s=Qt(t),a=i.useMemo(()=>{if(r||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:l}=window;return new l(s)},[r]);return i.useEffect(()=>()=>a?.disconnect(),[a]),a}function Is(e){return new Sn(Mt(e),e)}function zn(e,t,r){t===void 0&&(t=Is);const[s,a]=i.useState(null);function l(){a(u=>{if(!e)return null;if(e.isConnected===!1){var m;return(m=u??r)!=null?m:null}const p=t(e);return JSON.stringify(u)===JSON.stringify(p)?u:p})}const c=Ls({callback(u){if(e)for(const m of u){const{type:p,target:h}=m;if(p==="childList"&&h instanceof HTMLElement&&h.contains(e)){l();break}}}}),d=en({callback:l});return He(()=>{l(),e?(d?.observe(e),c?.observe(document.body,{childList:!0,subtree:!0})):(d?.disconnect(),c?.disconnect())},[e]),s}function $s(e){const t=Dn(e);return nr(e,t)}const Fn=[];function zs(e){const t=i.useRef(e),r=Tt(s=>e?s&&s!==Fn&&e&&t.current&&e.parentNode===t.current.parentNode?s:Nn(e):Fn,[e]);return i.useEffect(()=>{t.current=e},[e]),r}function Fs(e){const[t,r]=i.useState(null),s=i.useRef(e),a=i.useCallback(l=>{const c=dn(l.target);c&&r(d=>d?(d.set(c,gn(c)),new Map(d)):null)},[]);return i.useEffect(()=>{const l=s.current;if(e!==l){c(l);const d=e.map(u=>{const m=dn(u);return m?(m.addEventListener("scroll",a,{passive:!0}),[m,gn(m)]):null}).filter(u=>u!=null);r(d.length?new Map(d):null),s.current=e}return()=>{c(e),c(l)};function c(d){d.forEach(u=>{const m=dn(u);m?.removeEventListener("scroll",a)})}},[a,e]),i.useMemo(()=>e.length?t?Array.from(t.values()).reduce((l,c)=>ft(l,c),_e):cr(e):_e,[e,t])}function Bn(e,t){t===void 0&&(t=[]);const r=i.useRef(null);return i.useEffect(()=>{r.current=null},t),i.useEffect(()=>{const s=e!==_e;s&&!r.current&&(r.current=e),!s&&r.current&&(r.current=null)},[e]),r.current?qt(e,r.current):_e}function Bs(e){i.useEffect(()=>{if(!Jt)return;const t=e.map(r=>{let{sensor:s}=r;return s.setup==null?void 0:s.setup()});return()=>{for(const r of t)r?.()}},e.map(t=>{let{sensor:r}=t;return r}))}function Us(e,t){return i.useMemo(()=>e.reduce((r,s)=>{let{eventName:a,handler:l}=s;return r[a]=c=>{l(c,t)},r},{}),[e,t])}function mr(e){return i.useMemo(()=>e?ms(e):null,[e])}const Un=[];function Hs(e,t){t===void 0&&(t=Mt);const[r]=e,s=mr(r?ue(r):null),[a,l]=i.useState(Un);function c(){l(()=>e.length?e.map(u=>ir(u)?s:new Sn(t(u),u)):Un)}const d=en({callback:c});return He(()=>{d?.disconnect(),c(),e.forEach(u=>d?.observe(u))},[e]),a}function hr(e){if(!e)return null;if(e.children.length>1)return e;const t=e.children[0];return At(t)?t:e}function Vs(e){let{measure:t}=e;const[r,s]=i.useState(null),a=i.useCallback(m=>{for(const{target:p}of m)if(At(p)){s(h=>{const x=t(p);return h?{...h,width:x.width,height:x.height}:x});break}},[t]),l=en({callback:a}),c=i.useCallback(m=>{const p=hr(m);l?.disconnect(),p&&l?.observe(p),s(p?t(p):null)},[t,l]),[d,u]=Kt(c);return i.useMemo(()=>({nodeRef:d,rect:r,setRef:u}),[r,d,u])}const Ks=[{sensor:Cn,options:{}},{sensor:fr,options:{}}],Ys={current:{}},Ft={draggable:{measure:Pn},droppable:{measure:Pn,strategy:Rt.WhileDragging,frequency:vn.Optimized},dragOverlay:{measure:Mt}};class Dt extends Map{get(t){var r;return t!=null&&(r=super.get(t))!=null?r:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(t=>{let{disabled:r}=t;return!r})}getNodeFor(t){var r,s;return(r=(s=this.get(t))==null?void 0:s.node.current)!=null?r:void 0}}const qs={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new Dt,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:Wt},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:Ft,measureDroppableContainers:Wt,windowRect:null,measuringScheduled:!1},pr={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:Wt,draggableNodes:new Map,over:null,measureDroppableContainers:Wt},Pt=i.createContext(pr),gr=i.createContext(qs);function Xs(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new Dt}}}function Ws(e,t){switch(t.type){case G.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case G.DragMove:return e.draggable.active==null?e:{...e,draggable:{...e.draggable,translate:{x:t.coordinates.x-e.draggable.initialCoordinates.x,y:t.coordinates.y-e.draggable.initialCoordinates.y}}};case G.DragEnd:case G.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case G.RegisterDroppable:{const{element:r}=t,{id:s}
6=r,a=new Dt(e.droppable.containers);return a.set(s,r),{...e,droppable:{...e.droppable,containers:a}}}case G.SetDroppableDisabled:{const{id:r,key:s,disabled:a}=t,l=e.droppable.containers.get(r);if(!l||s!==l.key)return e;const c=new Dt(e.droppable.containers);return c.set(r,{...l,disabled:a}),{...e,droppable:{...e.droppable,containers:c}}}case G.UnregisterDroppable:{const{id:r,key:s}=t,a=e.droppable.containers.get(r);if(!a||s!==a.key)return e;const l=new Dt(e.droppable.containers);return l.delete(r),{...e,droppable:{...e.droppable,containers:l}}}default:return e}}function Gs(e){let{disabled:t}=e;const{active:r,activatorEvent:s,draggableNodes:a}=i.useContext(Pt),l=Yt(s),c=Yt(r?.id);return i.useEffect(()=>{if(!t&&!s&&l&&c!=null){if(!jn(l)||document.activeElement===l.target)return;const d=a.get(c);if(!d)return;const{activatorNode:u,node:m}=d;if(!u.current&&!m.current)return;requestAnimationFrame(()=>{for(const p of[u.current,m.current]){if(!p)continue;const h=Kr(p);if(h){h.focus();break}}})}},[s,t,a,c,l]),null}function xr(e,t){let{transform:r,...s}=t;return e!=null&&e.length?e.reduce((a,l)=>l({transform:a,...s}),r):r}function Js(e){return i.useMemo(()=>({draggable:{...Ft.draggable,...e?.draggable},droppable:{...Ft.droppable,...e?.droppable},dragOverlay:{...Ft.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function Qs(e){let{activeNode:t,measure:r,initialRect:s,config:a=!0}=e;const l=i.useRef(!1),{x:c,y:d}=typeof a=="boolean"?{x:a,y:a}:a;He(()=>{if(!c&&!d||!t){l.current=!1;return}if(l.current||!s)return;const m=t?.node.current;if(!m||m.isConnected===!1)return;const p=r(m),h=nr(p,s);if(c||(h.x=0),d||(h.y=0),l.current=!0,Math.abs(h.x)>0||Math.abs(h.y)>0){const x=sr(m);x&&x.scrollBy({top:h.y,left:h.x})}},[t,c,d,s,r])}const tn=i.createContext({..._e,scaleX:1,scaleY:1});var Ge;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})(Ge||(Ge={}));const Zs=i.memo(function(t){var r,s,a,l;let{id:c,accessibility:d,autoScroll:u=!0,children:m,sensors:p=Ks,collisionDetection:h=is,measuring:x,modifiers:v,..._}=t;const y=i.useReducer(Ws,void 0,Xs),[w,k]=y,[j,C]=Jr(),[E,R]=i.useState(Ge.Uninitialized),T=E===Ge.Initialized,{draggable:{active:S,nodes:D,translate:I},droppable:{containers:O}}=w,$=S!=null?D.get(S):null,ae=i.useRef({initial:null,translated:null}),oe=i.useMemo(()=>{var Y;return S!=null?{id:S,data:(Y=$?.data)!=null?Y:Ys,rect:ae}:null},[S,$]),X=i.useRef(null),[Oe,Le]=i.useState(null),[fe,Ve]=i.useState(null),xe=Et(_,Object.values(_)),Ie=Zt("DndDescribedBy",c),Je=i.useMemo(()=>O.getEnabled(),[O]),g=Js(x),{droppableRects:N,measureDroppableContainers:B,measuringScheduled:ve}=Ps(Je,{dragging:T,dependencies:[I.x,I.y],config:g.droppable}),F=Ts(D,S),me=i.useMemo(()=>fe?Xt(fe):null,[fe]),J=rn(),ie=Os(F,g.draggable.measure);Qs({activeNode:S!=null?D.get(S):null,config:J.layoutShiftCompensation,initialRect:ie,measure:g.draggable.measure});const W=zn(F,g.draggable.measure,ie),U=zn(F?F.parentElement:null),H=i.useRef({activatorEvent:null,active:null,activeNode:F,collisionRect:null,collisions:null,droppableRects:N,draggableNodes:D,draggingNode:null,draggingNodeRect:null,droppableContainers:O,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),be=O.getNodeFor((r=H.current.over)==null?void 0:r.id),$e=Vs({measure:g.dragOverlay.measure}),Re=(s=$e.nodeRef.current)!=null?s:F,ze=T?(a=$e.rect)!=null?a:W:null,pt=!!($e.nodeRef.current&&$e.rect),Ke=$s(pt?null:W),it=mr(Re?ue(Re):null),ke=zs(T?be??F:null),Qe=Hs(ke),ee=xr(v,{transform:{x:I.x-Ke.x,y:I.y-Ke.y,scaleX:1,scaleY:1},activatorEvent:fe,active:oe,activeNodeRect:W,containerNodeRect:U,draggingNodeRect:ze,over:H.current.over,overlayNodeRect:$e.rect,scrollableAncestors:ke,scrollableAncestorRects:Qe,windowRect:it}),lt=me?ft(me,I):null,Ze=Fs(ke),Ot=Bn(Ze),Lt=Bn(Ze,[W]),Ye=ft(ee,Ot),Fe=ze?ds(ze,ee):null,qe=oe&&Fe?h({active:oe,collisionRect:Fe,droppableRects:N,droppableContainers:Je,pointerCoordinates:lt}):null,gt=as(qe,"id"),[Ce,Xe]=i.useState(null),xt=pt?ee:ft(ee,Lt),It=ls(xt,(l=Ce?.rect)!=null?l:null,W),ct=i.useRef(null),$t=i.useCallback((Y,re)=>{let{sensor:Q,options:Ae}=re;if(X.current==null)return;const he=D.get(X.current);if(!he)return;const le=Y.nativeEvent,je=new Q({active:X.current,activeNode:he,event:le,options:Ae,context:H,onAbort(V){if(!D.get(V))return;const{onDragAbort:ye}=xe.current,pe={id:V};ye?.(pe),j({type:"onDragAbort",event:pe})},onPending(V,ce,ye,pe){if(!D.get(V))return;const{onDragPending:tt}=xe.current,Te={id:V,constraint:ce,initialCoordinates:ye,offset:pe};tt?.(Te),j({type:"onDragPending",event:Te})},onStart(V){const ce=X.current;if(ce==null)return;const ye=D.get(ce);if(!ye)return;const{onDragStart:pe}=xe.current,et={activatorEvent:le,active:{id:ce,data:ye.data,rect:ae}};Nt.unstable_batchedUpdates(()=>{pe?.(et),R(Ge.Initializing),k({type:G.DragStart,initialCoordinates:V,active:ce}),j({type:"onDragStart",event:et}),Le(ct.current),Ve(le)})},onMove(V){k({type:G.DragMove,coordinates:V})},onEnd:We(G.DragEnd),onCancel:We(G.DragCancel)});ct.current=je;function We(V){return async function(){const{active:ye,collisions:pe,over:et,scrollAdjustedTranslate:tt}=H.current;let Te=null;if(ye&&tt){const{cancelDrop:nt}=xe.current;Te={activatorEvent:le,active:ye,collisions:pe,delta:tt,over:et},V===G.DragEnd&&typeof nt=="function"&&await Promise.resolve(nt(Te))&&(V=G.DragCancel)}X.current=null,Nt.unstable_batchedUpdates(()=>{k({type:V}),R(Ge.Uninitialized),Xe(null),Le(null),Ve(null),ct.current=null;const nt=V===G.DragEnd?"onDragEnd":"onDragCancel";if(Te){const bt=xe.current[nt];bt?.(Te),j({type:nt,event:Te})}})}}},[D]),vt=i.useCallback((Y,re)=>(Q,Ae)=>{const he=Q.nativeEvent,le=D.get(Ae);if(X.current!==null||!le||he.dndKit||he.defaultPrevented)return;const je={active:le};Y(Q,re.options,je)===!0&&(he.dndKit={capturedBy:re.sensor},X.current=Ae,$t(Q,re))},[D,$t]),dt=Ms(p,vt);Bs(p),He(()=>{W&&E===Ge.Initializing&&R(Ge.Initialized)},[W,E]),i.useEffect(()=>{const{onDragMove:Y}=xe.current,{active:re,activatorEvent:Q,collisions:Ae,over:he}=H.current;if(!re||!Q)return;const le={active:re,activatorEvent:Q,collisions:Ae,delta:{x:Ye.x,y:Ye.y},over:he};Nt.unstable_batchedUpdates(()=>{Y?.(le),j({type:"onDragMove",event:le})})},[Ye.x,Ye.y]),i.useEffect(()=>{const{active:Y,activatorEvent:re,collisions:Q,droppableContainers:Ae,scrollAdjustedTranslate:he}
6=H.current;if(!Y||X.current==null||!re||!he)return;const{onDragOver:le}=xe.current,je=Ae.get(gt),We=je&&je.rect.current?{id:je.id,rect:je.rect.current,data:je.data,disabled:je.disabled}:null,V={active:Y,activatorEvent:re,collisions:Q,delta:{x:he.x,y:he.y},over:We};Nt.unstable_batchedUpdates(()=>{Xe(We),le?.(V),j({type:"onDragOver",event:V})})},[gt]),He(()=>{H.current={activatorEvent:fe,active:oe,activeNode:F,collisionRect:Fe,collisions:qe,droppableRects:N,draggableNodes:D,draggingNode:Re,draggingNodeRect:ze,droppableContainers:O,over:Ce,scrollableAncestors:ke,scrollAdjustedTranslate:Ye},ae.current={initial:ze,translated:Fe}},[oe,F,qe,Fe,D,Re,ze,N,O,Ce,ke,Ye]),_s({...J,delta:I,draggingRect:Fe,pointerCoordinates:lt,scrollableAncestors:ke,scrollableAncestorRects:Qe});const zt=i.useMemo(()=>({active:oe,activeNode:F,activeNodeRect:W,activatorEvent:fe,collisions:qe,containerNodeRect:U,dragOverlay:$e,draggableNodes:D,droppableContainers:O,droppableRects:N,over:Ce,measureDroppableContainers:B,scrollableAncestors:ke,scrollableAncestorRects:Qe,measuringConfiguration:g,measuringScheduled:ve,windowRect:it}),[oe,F,W,fe,qe,U,$e,D,O,N,Ce,B,ke,Qe,g,ve,it]),nn=i.useMemo(()=>({activatorEvent:fe,activators:dt,active:oe,activeNodeRect:W,ariaDescribedById:{draggable:Ie},dispatch:k,draggableNodes:D,over:Ce,measureDroppableContainers:B}),[fe,dt,oe,W,k,Ie,D,Ce,B]);return K.createElement(tr.Provider,{value:C},K.createElement(Pt.Provider,{value:nn},K.createElement(gr.Provider,{value:zt},K.createElement(tn.Provider,{value:It},m)),K.createElement(Gs,{disabled:d?.restoreFocus===!1})),K.createElement(es,{...d,hiddenTextDescribedById:Ie}));function rn(){const Y=Oe?.autoScrollEnabled===!1,re=typeof u=="object"?u.enabled===!1:u===!1,Q=T&&!Y&&!re;return typeof u=="object"?{...u,enabled:Q}:{enabled:Q}}}),ea=i.createContext(null),Hn="button",ta="Draggable";function na(e){let{id:t,data:r,disabled:s=!1,attributes:a}=e;const l=Zt(ta),{activators:c,activatorEvent:d,active:u,activeNodeRect:m,ariaDescribedById:p,draggableNodes:h,over:x}=i.useContext(Pt),{role:v=Hn,roleDescription:_="draggable",tabIndex:y=0}=a??{},w=u?.id===t,k=i.useContext(w?tn:ea),[j,C]=Kt(),[E,R]=Kt(),T=Us(c,t),S=Et(r);He(()=>(h.set(t,{id:t,key:l,node:j,activatorNode:E,data:S}),()=>{const I=h.get(t);I&&I.key===l&&h.delete(t)}),[h,t]);const D=i.useMemo(()=>({role:v,tabIndex:y,"aria-disabled":s,"aria-pressed":w&&v===Hn?!0:void 0,"aria-roledescription":_,"aria-describedby":p.draggable}),[s,v,y,w,_,p.draggable]);return{active:u,activatorEvent:d,activeNodeRect:m,attributes:D,isDragging:w,listeners:s?void 0:T,node:j,over:x,setNodeRef:C,setActivatorNodeRef:R,transform:k}}function ra(){return i.useContext(gr)}const sa="Droppable",aa={timeout:25};function oa(e){let{data:t,disabled:r=!1,id:s,resizeObserverConfig:a}=e;const l=Zt(sa),{active:c,dispatch:d,over:u,measureDroppableContainers:m}=i.useContext(Pt),p=i.useRef({disabled:r}),h=i.useRef(!1),x=i.useRef(null),v=i.useRef(null),{disabled:_,updateMeasurementsFor:y,timeout:w}={...aa,...a},k=Et(y??s),j=i.useCallback(()=>{if(!h.current){h.current=!0;return}v.current!=null&&clearTimeout(v.current),v.current=setTimeout(()=>{m(Array.isArray(k.current)?k.current:[k.current]),v.current=null},w)},[w]),C=en({callback:j,disabled:_||!c}),E=i.useCallback((D,I)=>{C&&(I&&(C.unobserve(I),h.current=!1),D&&C.observe(D))},[C]),[R,T]=Kt(E),S=Et(t);return i.useEffect(()=>{!C||!R.current||(C.disconnect(),h.current=!1,C.observe(R.current))},[R,C]),i.useEffect(()=>(d({type:G.RegisterDroppable,element:{id:s,key:l,disabled:r,node:R,rect:x,data:S}}),()=>d({type:G.UnregisterDroppable,key:l,id:s})),[s]),i.useEffect(()=>{r!==p.current.disabled&&(d({type:G.SetDroppableDisabled,id:s,key:l,disabled:r}),p.current.disabled=r)},[s,l,r,d]),{active:c,rect:x,isOver:u?.id===s,node:R,over:u,setNodeRef:T}}function ia(e){let{animation:t,children:r}=e;const[s,a]=i.useState(null),[l,c]=i.useState(null),d=Yt(r);return!r&&!s&&d&&a(d),He(()=>{if(!l)return;const u=s?.key,m=s?.props.id;if(u==null||m==null){a(null);return}Promise.resolve(t(m,l)).then(()=>{a(null)})},[t,s,l]),K.createElement(K.Fragment,null,r,s?i.cloneElement(s,{ref:c}):null)}const la={x:0,y:0,scaleX:1,scaleY:1};function ca(e){let{children:t}=e;return K.createElement(Pt.Provider,{value:pr},K.createElement(tn.Provider,{value:la},t))}const da={position:"fixed",touchAction:"none"},ua=e=>
6jn(e)?"transform 250ms ease":void 0,fa=i.forwardRef((e,t)=>{let{as:r,activatorEvent:s,adjustScale:a,children:l,className:c,rect:d,style:u,transform:m,transition:p=ua}=e;if(!d)return null;const h=a?m:{...m,scaleX:1,scaleY:1},x={...da,width:d.width,height:d.height,top:d.top,left:d.left,transform:_t.Transform.toString(h),transformOrigin:a&&s?rs(s,d):void 0,transition:typeof p=="function"?p(s):p,...u};return K.createElement(r,{className:c,style:x,ref:t},l)}),ma=e=>t=>{let{active:r,dragOverlay:s}=t;const a={},{styles:l,className:c}=e;if(l!=null&&l.active)for(const[d,u]of Object.entries(l.active))u!==void 0&&(a[d]=r.node.style.getPropertyValue(d),r.node.style.setProperty(d,u));if(l!=null&&l.dragOverlay)for(const[d,u]of Object.entries(l.dragOverlay))u!==void 0&&s.node.style.setProperty(d,u);return c!=null&&c.active&&r.node.classList.add(c.active),c!=null&&c.dragOverlay&&s.node.classList.add(c.dragOverlay),function(){for(const[u,m]of Object.entries(a))r.node.style.setProperty(u,m);c!=null&&c.active&&r.node.classList.remove(c.active)}},ha=e=>{let{transform:{initial:t,final:r}}=e;return[{transform:_t.Transform.toString(t)},{transform:_t.Transform.toString(r)}]},pa={duration:250,easing:"ease",keyframes:ha,sideEffects:ma({styles:{active:{opacity:"0"}}})};function ga(e){let{config:t,draggableNodes:r,droppableContainers:s,measuringConfiguration:a}=e;return Qt((l,c)=>{if(t===null)return;const d=r.get(l);if(!d)return;const u=d.node.current;if(!u)return;const m=hr(c);if(!m)return;const{transform:p}=ue(c).getComputedStyle(c),h=rr(p);if(!h)return;const x=typeof t=="function"?t:xa(t);return dr(u,a.draggable.measure),x({active:{id:l,data:d.data,node:u,rect:a.draggable.measure(u)},draggableNodes:r,dragOverlay:{node:c,rect:a.dragOverlay.measure(m)},droppableContainers:s,measuringConfiguration:a,transform:h})})}function xa(e){const{duration:t,easing:r,sideEffects:s,keyframes:a}={...pa,...e};return l=>{let{active:c,dragOverlay:d,transform:u,...m}=l;if(!t)return;const p={x:d.rect.left-c.rect.left,y:d.rect.top-c.rect.top},h={scaleX:u.scaleX!==1?c.rect.width*u.scaleX/d.rect.width:1,scaleY:u.scaleY!==1?c.rect.height*u.scaleY/d.rect.height:1},x={x:u.x-p.x,y:u.y-p.y,...h},v=a({...m,active:c,dragOverlay:d,transform:{initial:u,final:x}}),[_]=v,y=v[v.length-1];if(JSON.stringify(_)===JSON.stringify(y))return;const w=s?.({active:c,dragOverlay:d,...m}),k=d.node.animate(v,{duration:t,easing:r,fill:"forwards"});return new Promise(j=>{k.onfinish=()=>{w?.(),j()}})}}let Vn=0;function va(e){return i.useMemo(()=>{if(e!=null)return Vn++,Vn},[e])}const ba=K.memo(e=>
6{let{adjustScale:t=!1,children:r,dropAnimation:s,style:a,transition:l,modifiers:c,wrapperElement:d="div",className:u,zIndex:m=999}=e;const{activatorEvent:p,active:h,activeNodeRect:x,containerNodeRect:v,draggableNodes:_,droppableContainers:y,dragOverlay:w,over:k,measuringConfiguration:j,scrollableAncestors:C,scrollableAncestorRects:E,windowRect:R}=ra(),T=i.useContext(tn),S=va(h?.id),D=xr(c,{activatorEvent:p,active:h,activeNodeRect:x,containerNodeRect:v,draggingNodeRect:w.rect,over:k,overlayNodeRect:w.rect,scrollableAncestors:C,scrollableAncestorRects:E,transform:T,windowRect:R}),I=Dn(x),O=ga({config:s,draggableNodes:_,droppableContainers:y,measuringConfiguration:j}),$=I?w.setRef:void 0;return K.createElement(ca,null,K.createElement(ia,{animation:O},h&&S?K.createElement(fa,{key:S,id:h.id,ref:$,as:d,activatorEvent:p,adjustScale:t,className:u,transition:l,rect:I,style:{zIndex:m,...a},transform:D},r):null))}),Pe=[{key:"mapeamento",label:"Mapeamento",group:"inicio"},{key:"em_aprovacao",label:"Em aprovação",group:"inicio"},{key:"pre_aprovacao",label:"Pré Aprovação",group:"inicio"},{key:"selecionado",label:"Aprovado",group:"inicio"},{key:"contrato",label:"Contrato",group:"inicio"},{key:"envio_produto",label:"Envio do produto",group:"producao"},{key:"roteiro_aprovacao",label:"Roteiro em aprovação",group:"producao"},{key:"aguardando_gravacao",label:"Aguardando gravação",group:"producao"},{key:"pronto_edicao",label:"Pronto para edição",group:"producao"},{key:"editando",label:"Editando",group:"producao"},{key:"aguardando_aprovacao",label:"Aguardando aprovação",group:"producao"},{key:"aprovado",label:"Aprovado",group:"financeiro"},{key:"envio_nf",label:"Envio de nota fiscal",group:"financeiro"},{key:"pago",label:"Pago",group:"financeiro"}],ya={inicio:{header:"bg-sky-50 text-sky-900 border-sky-200",column:"bg-sky-50/40 border-sky-100",ring:"ring-sky-200"},producao:{header:"bg-amber-50 text-amber-900 border-amber-200",column:"bg-amber-50/40 border-amber-100",ring:"ring-amber-200"},financeiro:{header:"bg-emerald-50 text-emerald-900 border-emerald-200",column:"bg-emerald-50/40 border-emerald-100",ring:"ring-emerald-200"}};function St(e){return Pe.find(t=>t.key===e)?.label??e}function lo(){const[e,t]=i.useState([]),[r,s]=i.useState([]),[a,l]=i.useState([]),[c,d]=i.useState("all"),[u,m]=i.useState("all"),[p,h]=i.useState(""),[x,v]=i.useState(!0),[_,y]=i.useState(!1),[w,k]=i.useState(null),[j,C]=i.useState(null),[E,R]=i.useState(new Set),[T,S]=i.useState(!1),D=ns(ts(Cn,{activationConstraint:{distance:6}})),I=g=>{R(N=>{const B=new Set(N);return B.has(g)?B.delete(g):B.add(g),B})},O=()=>R(new Set),$=async()=>{if(E.size===0||!window.confirm(`Remover ${E.size} card(s) selecionado(s)? Esta ação não pode ser desfeita.`))return;S(!0);const g=Array.from(E),{error:N}=await A.from("creator_kanban_cards").delete().in("id",g);if(S(!1),N){L.error("Erro ao remover cards");return}L.success(`${g.length} card(s) removidos`),O(),X()},ae=i.useMemo(()=>{const g=new Map;return r.forEach(N=>g.set(N.id,{name:N.name,contract_type:N.contract_type??null})),g},[r]),oe=async()=>{const N=[];for(let B=0;;B+=1e3){const{data:ve,error:F}=await A.from("creator_kanban_cards").select("*").order("stage",{ascending:!0}).order("ordem",{ascending:!0}).order("id",{ascending:!0}).range(B,B+1e3-1);if(F)return{data:null,error:F};const me=ve??[];if(N.push(...me),me.length<1e3)break}return{data:N,error:null}},X=async()=>{v(!0);const[g,N,B]=await Promise.all([oe(),A.from("clients").select("id, name, contract_type").order("name",{ascending:!0}),A.from("member_listings").select("id, company_name").order("company_name",{ascending:!0})]);if(g.error)L.error("Erro ao carregar kanban");else{const ve=g.data??[],F=Array.from(new Set(ve.map(J=>J.creator_bank_id).filter(Boolean)));let me=new Map;if(F.length>0){const{data:J}=await A.from("creators_bank").select("id, photo_url, user_id").in("id",F),ie=Array.from(new Set((J??[]).map(U=>U.user_id).filter(Boolean)));let W=new Map;if(ie.length>0){const{data:U}=await A.from("profiles").select("user_id, avatar_url").in("user_id",ie);
6(U??[]).forEach(H=>{H.avatar_url&&W.set(H.user_id,H.avatar_url)})}(J??[]).forEach(U=>{const H=U.photo_url||(U.user_id?W.get(U.user_id):null);H&&me.set(U.id,H)})}t(ve.map(J=>({...J,avatar_url:J.avatar_url||(J.creator_bank_id?me.get(J.creator_bank_id)??null:null)})))}N.error||s(N.data??[]),B.error||l(B.data??[]),v(!1)};i.useEffect(()=>{X()},[]);const Oe=i.useMemo(()=>{const g=c==="all"?e:c==="none"?e.filter(N=>!N.listing_id):e.filter(N=>N.listing_id===c);return u==="all"?g:g.filter(N=>String(N.round_number??1)===u)},[e,c,u]),Le=i.useMemo(()=>{const g=new Set;for(const N of e)N.listing_id&&g.add(N.round_number??1);return Array.from(g).sort((N,B)=>N-B)},[e]),fe=i.useMemo(()=>{const g={};for(const N of Pe)g[N.key]=[];for(const N of Oe)(g[N.stage]??=[]).push(N);return g},[Oe]),Ve=j?e.find(g=>g.id===j)??null:null,xe=w?e.find(g=>g.id===w)??null:null,Ie=g=>C(String(g.active.id)),Je=async g=>{C(null);const{active:N,over:B}=g;if(!B)return;const ve=String(N.id),F=String(B.id),me=E.has(ve)&&E.size>1?Array.from(E):[ve],J=e.filter(U=>me.includes(U.id)&&U.stage!==F);if(J.length===0)return;const ie=J.map(U=>U.id);t(U=>U.map(H=>ie.includes(H.id)?{...H,stage:F}:H));const{error:W}=await A.from("creator_kanban_cards").update({stage:F}).in("id",ie);if(W){L.error("Erro ao mover card(s)"),X();return}ie.length>1&&(L.success(`${ie.length} cards movidos para ${St(F)}`),O())};return n.jsxs("div",{className:"flex h-[calc(100vh-4rem)] flex-col",children:[n.jsxs("header",{className:"flex flex-wrap items-center justify-between gap-3 border-b bg-white px-6 py-4",children:[n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx("div",{className:"grid h-10 w-10 shrink-0 place-items-center rounded-xl bg-primary/10 text-primary",children:n.jsx(zr,{className:"h-5 w-5"})}),n.jsxs("div",{className:"min-w-0",children:[n.jsx("h1",{className:"font-display text-xl font-bold",children:"Kanban de Creators"}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"Pipeline de gestão do fluxo de trabalho com cada creator"})]})]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsxs(Bt,{value:c,onValueChange:d,children:[n.jsx(Ut,{className:"h-9 w-[220px]",children:n.jsx(Ht,{placeholder:"Filtrar por oportunidade"})}),n.jsxs(Vt,{children:[n.jsx("div",{className:"sticky top-0 z-10 bg-popover p-2",children:n.jsx(ge,{autoFocus:!0,value:p,onChange:g=>h(g.target.value),onKeyDown:g=>g.stopPropagation(),placeholder:"Buscar oportunidade...",className:"h-8"})}),n.jsx(ne,{value:"all",children:"Todas as oportunidades"}),n.jsx(ne,{value:"none",children:"Sem oportunidade"}),a.filter(g=>(g.company_name??"").toLowerCase().includes(p.trim().toLowerCase())).map(g=>n.jsx(ne,{value:g.id,children:g.company_name},g.id))]})]}),Le.length>1&&n.jsxs(Bt,{value:u,onValueChange:m,children:[n.jsx(Ut,{className:"h-9 w-[150px]",children:n.jsx(Ht,{placeholder:"Rodada"})}),n.jsxs(Vt,{children:[n.jsx(ne,{value:"all",children:"Todas as rodadas"}),Le.map(g=>n.jsxs(ne,{value:String(g),children:["Rodada ",g]},g))]})]}),n.jsxs(q,{onClick:()=>y(!0),children:[n.jsx(pn,{className:"mr-2 h-4 w-4"}),"Adicionar creator"]})]})]}),x?n.jsx("div",{className:"flex flex-1 items-center justify-center",children:n.jsx(Me,{className:"h-8 w-8 animate-spin text-primary"})}):n.jsxs(Zs,{sensors:D,onDragStart:Ie,onDragEnd:Je,children:[n.jsx("div",{className:"flex-1 overflow-x-auto overflow-y-hidden",children:n.jsx("div",{className:"flex h-full min-w-max gap-3 p-4",children:Pe.map(g=>n.jsx(wa,{stage:g.key,label:g.label,group:g.group,cards:fe[g.key]??[],clientMap:ae,selectedIds:E,onToggleSelect:I,onCardClick:k},g.key))})}),n.jsx(ba,{children:Ve?n.jsx(vr,{card:Ve,clientMap:ae,dragging:!0}):null})]}),n.jsx(Na,{open:_,onOpenChange:y,onCreated:()=>{y(!1),X()}}),n.jsx(Sa,{card:xe,open:!!xe,onOpenChange:g=>!g&&k(null),onChanged:()=>{X()}}),E.size>0&&n.jsx("div",{className:"pointer-events-none fixed inset-x-0 bottom-6 z-50 flex justify-center",children:n.jsxs("div",{className:"pointer-events-auto flex items-center gap-3 rounded-full border bg-white px-4 py-2 shadow-lg",children:[n.jsxs("span",{className:"text-sm font-medium",children:[E.size," card",E.size>1?"s":""," selecionado",E.size>1?"s":""]}),n.jsx("span",{className:"hidden text-xs text-muted-foreground sm:inline",children:"Arraste para mover em conjunto"}),n.jsx(q,{size:"sm",variant:"ghost",onClick:O,children:"Limpar"}),n.jsxs(q,{size:"sm",variant:"destructive",onClick:$,disabled:T,children:[T?n.jsx(Me,{className:"mr-2 h-4 w-4 animate-spin"}):n.jsx(ot,{className:"mr-2 h-4 w-4"}),"Excluir (",E.size,")"]})]})})]})}function wa({stage:e,label:t,group:r,cards:s,clientMap:a,selectedIds:l,onToggleSelect:c,onCardClick:d}){const{setNodeRef:u,isOver:m}=oa({id:e}),p=ya[r];return n.jsxs("div",{ref:u,className:`flex h-full w-72 shrink-0 flex-col rounded-2xl border ${p.column} ${m?`ring-2 ${p.ring}`:""}`,children:[n.jsxs("div",{className:`flex items-center justify-between rounded-t-2xl border-b px-3 py-2.5 ${p.header}`,children:[n.jsx("h3",{className:"text-sm font-semibold",children:t}),n.jsx(Qn,{variant:"secondary",className:"bg-white/70 text-xs",children:s.length})]}),n.jsxs("div",{className:"flex-1 space-y-2 overflow-y-auto p-2",children:[s.map(h=>n.jsx(ja,{card:h,clientMap:a,selected:l.has(h.id),onToggleSelect:()=>c(h.id),onClick:()=>d(h.id)},h.id)),s.length===0&&n.jsx("div",{className:"px-2 py-6 text-center text-xs text-muted-foreground
6/70",children:"Arraste um card aqui"})]})]})}function ja({card:e,clientMap:t,selected:r,onToggleSelect:s,onClick:a}){const{attributes:l,listeners:c,setNodeRef:d,isDragging:u}=na({id:e.id});return n.jsx("div",{ref:d,...l,...c,onClick:a,className:`cursor-grab active:cursor-grabbing ${u?"opacity-40":""}`,children:n.jsx(vr,{card:e,clientMap:t,selected:r,onToggleSelect:s})})}function vr({card:e,clientMap:t,dragging:r=!1,selected:s=!1,onToggleSelect:a}){const l=e.client_id?t?.get(e.client_id):null,c=l?.contract_type,d=c==="recorrente"?{label:"Recorrente",className:"border-violet-200 bg-violet-50 text-violet-700"}:c==="pontual"?{label:"Pontual",className:"border-amber-200 bg-amber-50 text-amber-700"}:null;return n.jsxs("div",{className:`group relative rounded-xl border bg-white p-3 shadow-sm transition hover:shadow ${r?"shadow-lg ring-2 ring-primary/30":""} ${s?"ring-2 ring-primary border-primary":""}`,children:[a&&n.jsx("button",{type:"button",onClick:u=>{u.stopPropagation(),a()},onPointerDown:u=>u.stopPropagation(),"aria-label":s?"Desmarcar card":"Selecionar card",className:`absolute right-2 top-2 grid h-5 w-5 place-items-center rounded-full border-2 transition ${s?"border-primary bg-primary text-primary-foreground opacity-100":"border-muted-foreground/40 bg-white opacity-0 group-hover:opacity-100"}`,children:s&&n.jsx(bn,{className:"h-3 w-3"})}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsxs(mn,{className:"h-9 w-9 shrink-0",children:[n.jsx(Jn,{src:e.avatar_url??void 0,alt:e.creator_name}),n.jsx(hn,{className:"text-xs",children:e.creator_name?.slice(0,2).toUpperCase()||"CR"})]}),n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsx("p",{className:"truncate text-sm font-semibold",children:e.creator_name}),l?.name&&n.jsx("p",{className:"truncate text-xs font-medium text-foreground/70",children:l.name}),e.campaign&&n.jsxs("p",{className:"truncate text-[11px] text-muted-foreground",children:[e.campaign,e.listing_id?` · Rodada ${e.round_number??1}`:""]})]})]}),(d||e.client_approval&&e.client_approval!=="pendente")&&n.jsxs("div",{className:"mt-2 flex flex-wrap gap-1",children:[d&&n.jsx("span",{className:`inline-flex items-center rounded-full border px-2 py-0.5 text-[10px] font-semibold ${d.className}`,children:d.label}),e.client_approval==="aprovado"&&n.jsx("span",{className:"inline-flex items-center rounded-full border border-emerald-200 bg-emerald-50 px-2 py-0.5 text-[10px] font-semibold text-emerald-800",children:"Cliente aprovou"}),e.client_approval==="recusado"&&n.jsx("span",{className:"inline-flex items-center rounded-full border border-rose-200 bg-rose-50 px-2 py-0.5 text-[10px] font-semibold text-rose-800",children:"Cliente recusou"})]})]})}function Na({open:e,onOpenChange:t,onCreated:r}){const[s,a]=i.useState(""),[l,c]=i.useState(""),[d,u]=i.useState(""),[m,p]=i.useState(!1);i.useEffect(()=>{e&&(a(""),c(""),u(""))},[e]);const h=async()=>{if(!s.trim()){L.error("Informe o nome do creator");return}p(!0);const{error:x}=await A.from("creator_kanban_cards").insert({creator_name:s.trim(),avatar_url:l.trim()||null,campaign:d.trim()||null,stage:"mapeamento"});if(p(!1),x){L.error("Erro ao criar card");return}L.success("Card criado"),r()};return n.jsx(Yn,{open:e,onOpenChange:t,children:n.jsxs(qn,{children:[n.jsx(Xn,{children:n.jsx(Wn,{children:"Adicionar creator"})}),n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{children:[n.jsx(se,{children:"Nome do creator *"}),n.jsx(ge,{value:s,onChange:x=>a(x.target.value),placeholder:"Ex: Ana Souza"})]}),n.jsxs("div",{children:[n.jsx(se,{children:"Foto (URL)"}),n.jsx(ge,{value:l,onChange:x=>c(x.target.value),placeholder:"https://..."})]}),n.jsxs("div",{children:[n.jsx(se,{children:"Produto / Campanha"}),n.jsx(ge,{value:d,onChange:x=>u(x.target.value),placeholder:"Ex: Lançamento verão"})]})]}),n.jsxs(Gn,{children:[n.jsx(q,{variant:"outline",onClick:()=>t(!1),children:"Cancelar"}),n.jsxs(q,{onClick:h,disabled:m,children:[m?n.jsx(Me,{className:"mr-2 h-4 w-4 animate-spin"}):null,"Criar"]})]})]})})}function Sa({card:e,open:t,onOpenChange:r,onChanged:s}){const{user:a,profile:l}=kr(),[c,d]=i.useState(""),[u,m]=i.useState(""),[p,h]=i.useState(""),[x,v]=i.useState(""),[_,y]=i.useState(""),[w,k]=i.useState(""),[j,C]=i.useState(null),[E,R]=i.useState(null),[T,S]=i.useState(null),[D,I]=i.useState(!1),[O,$]=i.useState([]),[ae,oe]=i.useState(null),[X,Oe]=i.useState({}),[Le,fe]=i.useState([]),[Ve,xe]=i.useState(null),[Ie,Je]=i.useState(!1);async function g(){const o=e?.creator_bank_id;if(!o){L.error("Este card não está vinculado a uma ficha do Banco de Creators");return}Je(!0);try{const{syncCreatorInstagram:f}=await ut(async()=>{const{syncCreatorInstagram:te}=await import("./apify-instagram.functions-D1vxgNEl.js");return{syncCreatorInstagram:te}},__vite__mapDeps([0,1,2,3]));await f({data:{creatorId:o}});const{getKanbanCardWithCreator:b}=await ut(async()=>{const{getKanbanCardWithCreator:te}=await import("./client-campaign.functions-Btgp8E1k.js");return{getKanbanCardWithCreator:te}},__vite__mapDeps([4,1,2,3])),M=await b({data:{card_id:e.id}});fe(Array.isArray(M?.igPosts)?M.igPosts:[]),xe(M?.igSyncedAt??null),L.success("Instagram sincronizado")}catch(f){L.error(f.message||"Não foi possível sincronizar agora")}finally{Je(!1)}}const[N,B]=i.useState(!1),[ve,F]=i.useState(!1),[me,J]=i.useState([]),[ie,W]=i.useState(""),[U,H]=i.useState(!1),[be,$e]=i.useState({info:!1,personal:!1,video:!1,script:!1,finals:!1}),Re=o=>$e(f=>({...f,[o]:!f[o]})),[ze,pt]=i.useState([]),[Ke,it]=i.useState(""),[ke,Qe]=i.useState(""),[ee,lt]=i.useState(""),[Ze,Ot]=i.useState(30),[Lt,Ye]=i.useState(!0),[Fe,qe]=i.useState("media"),[gt,Ce]=i.useState(!1),[Xe,xt]=i.useState([]),[It,ct]=i.useState(!1),[$t,vt]=i.useState(null),dt=i.useRef(null),zt=i.useRef({minH:8,totalH:12,dayStart:0}),nn=o=>{const f=b=>String(b).padStart(2,"0");return`${o.getFullYear()}-${f(o.getMonth()+1)}-${f(o.getDate())}T${f(o.getHours())}:${f(o.getMinutes())}`},rn=o=>
6{if(!dt.current||!ee)return;o.preventDefault(),o.stopPropagation();const b=dt.current.getBoundingClientRect(),M=new Date(ee);if(isNaN(M.getTime()))return;const{minH:te,totalH:de,dayStart:De}=zt.current,we=(M.getTime()-De)/36e5-te,Ne=o.clientX;o.target.setPointerCapture?.(o.pointerId);const rt=st=>{const at=(st.clientX-Ne)/b.width*de;let yt=we+at;const P=Math.max(5,Ze)/60;yt=Math.max(0,Math.min(de-P,yt));const Be=Math.round((te+yt)*60/5)*5,Ue=new Date(De);Ue.setHours(0,0,0,0),Ue.setMinutes(Be),lt(nn(Ue))},Ee=()=>{window.removeEventListener("pointermove",rt),window.removeEventListener("pointerup",Ee)};window.addEventListener("pointermove",rt),window.addEventListener("pointerup",Ee)};i.useEffect(()=>{if(!ee){xt([]),vt(null);return}const o=new Date(ee);if(isNaN(o.getTime()))return;const f=new Date(o.getFullYear(),o.getMonth(),o.getDate(),0,0,0),b=new Date(o.getFullYear(),o.getMonth(),o.getDate(),23,59,59);let M=!1;ct(!0),vt(null);const te=setTimeout(async()=>{try{const{listUpcomingEvents:de}=await ut(async()=>{const{listUpcomingEvents:we}=await import("./google-calendar.functions-DVu7I7a2.js");return{listUpcomingEvents:we}},__vite__mapDeps([5,1,2,3])),De=await de({data:{timeMin:f.toISOString(),timeMax:b.toISOString()}});M||xt(De?.events??[])}catch(de){M||(xt([]),vt(de.message||"Não foi possível carregar a agenda"))}finally{M||ct(!1)}},350);return()=>{M=!0,clearTimeout(te)}},[ee]),i.useEffect(()=>{let o=!1;return e&&(d(e.creator_name),m(e.avatar_url??""),h(e.campaign??""),v(e.notes??""),y(e.instagram_url??""),k(e.video_url??""),C(e.video_file_path??null),S(e.script_url??null),$(Array.isArray(e.final_videos)?e.final_videos:[]),Oe(e.personal_data??{}),R(null),(async()=>{try{const{getKanbanCardWithCreator:f}=await ut(async()=>{const{getKanbanCardWithCreator:M}=await import("./client-campaign.functions-Btgp8E1k.js");return{getKanbanCardWithCreator:M}},__vite__mapDeps([4,1,2,3])),b=await f({data:{card_id:e.id}});!o&&b?.personal&&Oe(b.personal),o||(fe(Array.isArray(b?.igPosts)?b.igPosts:[]),xe(b?.igSyncedAt??null))}catch{}})()),()=>{o=!0}},[e]),i.useEffect(()=>{let o=!1;if(!j){R(null);return}return A.storage.from("creator-kanban-videos").createSignedUrl(j,3600).then(({data:f})=>{o||R(f?.signedUrl??null)}),()=>{o=!0}},[j]);const Y=async o=>{const{data:f}=await A.from("creator_kanban_comments").select("id, body, author_name, author_id, created_at").eq("card_id",o).order("created_at",{ascending:!1});J(f??[])};i.useEffect(()=>{e?.id?Y(e.id):J([])},[e?.id]);const re=o=>`[card:${o}]`,Q=async o=>{const{data:f}=await A.from("tasks").select("id, title, description, status, priority, due_date, created_at").ilike("description",`%${re(o)}%`).order("created_at",{ascending:!1});pt(f??[])};i.useEffect(()=>{e?.id?Q(e.id):pt([])},[e?.id]);const Ae=async()=>{if(!e||!Ke.trim()||!a)return;Ce(!0);const o=re(e.id),f=ke.trim();let b=null;if(Lt&&ee)try{const{createCalendarEvent:we}=await ut(async()=>{const{createCalendarEvent:Ee}=await import("./google-calendar.functions-DVu7I7a2.js");return{createCalendarEvent:Ee}},__vite__mapDeps([5,1,2,3])),Ne=new Date(ee),rt=await we({data:{title:`${Ke.trim()} — ${e.creator_name}${e.campaign?" · "+e.campaign:""}`,description:`${f}
7
8${o}`,startISO:Ne.toISOString(),durationMinutes:Ze}});rt?.htmlLink&&(b=rt.htmlLink),L.success("Evento criado no Google Calendar")}catch(we){L.error(we?.message?.includes("não conectado")?"Conecte o Google Calendar em /calendar":"Não foi possível criar evento no Google Calendar")}const M=b?`
9📅 ${b}`:"",te=`${f}${f?`
10
11`:""}${o} ${e.creator_name}${e.campaign?" — "+e.campaign:""}${M}`,de=ee?ee.slice(0,10):null,{error:De}=await A.from("tasks").insert({title:Ke.trim(),description:te,due_date:de,priority:Fe,status:"a_fazer",client_id:e.client_id??null,created_by:a.id,assignee_id:a.id});if(Ce(!1),De)return L.error("Erro ao criar atividade");L.success("Atividade criada — visível em Tasks"),it(""),Qe(""),lt(""),Ot(30),qe("media"),await Q(e.id)},he=async o=>{const f=o.status==="concluido"?"a_fazer":"concluido";await A.from("tasks").update({status:f,completed_at:f==="concluido"?new Date().toISOString():null}
11).eq("id",o.id),e&&await Q(e.id)},le=async o=>{await A.from("tasks").delete().eq("id",o),e&&await Q(e.id)},je=async()=>{if(!e||!ie.trim()||!a)return;H(!0);const{error:o}=await A.from("creator_kanban_comments").insert({card_id:e.id,author_id:a.id,author_name:l?.full_name??a.email??"Usuário",body:ie.trim()});if(H(!1),o)return L.error("Erro ao comentar");W(""),await Y(e.id)},We=async o=>{e&&(await A.from("creator_kanban_comments").delete().eq("id",o),await Y(e.id))},V=i.useRef({}),ce=i.useRef(null);if(!e)return null;const ye=async()=>{if(!e)return;const o=V.current;if(V.current={},!!Object.keys(o).length)try{const{updateCreatorFromKanban:f}=await ut(async()=>{const{updateCreatorFromKanban:b}=await import("./client-campaign.functions-Btgp8E1k.js");return{updateCreatorFromKanban:b}},__vite__mapDeps([4,1,2,3]));await f({data:{card_id:e.id,patch:o}}),s()}catch(f){L.error(f?.message??"Erro ao salvar dados do creator")}},pe=(o,f)=>{Oe(b=>({...b,[o]:f})),V.current[o]=f,ce.current&&window.clearTimeout(ce.current),ce.current=window.setTimeout(()=>{ye()},700)},et=async()=>{B(!0),ce.current&&(window.clearTimeout(ce.current),ce.current=null),await ye();const{error:o}=await A.from("creator_kanban_cards").update({creator_name:c.trim(),avatar_url:u.trim()||null,campaign:p.trim()||null,notes:x.trim()||null,instagram_url:_.trim()||null,video_url:w.trim()||null,video_file_path:j,script_url:T,final_videos:O}).eq("id",e.id);if(B(!1),o)return L.error("Erro ao salvar");L.success("Salvo"),s()},tt=async o=>{F(!0);const f=`${e.id}/${Date.now()}-${o.name.replace(/[^\w.\-]/g,"_")}`,{error:b}=await A.storage.from("creator-kanban-videos").upload(f,o,{upsert:!1,contentType:o.type});if(b){F(!1),L.error("Erro ao enviar vídeo");return}j&&await A.storage.from("creator-kanban-videos").remove([j]),await A.from("creator_kanban_cards").update({video_file_path:f}).eq("id",e.id),C(f),F(!1),L.success("Vídeo enviado"),s()},Te=async()=>{j&&(await A.storage.from("creator-kanban-videos").remove([j]),await A.from("creator_kanban_cards").update({video_file_path:null}).eq("id",e.id),C(null),R(null),s())},nt=async o=>{I(!0);const f=o.name.replace(/[^\w.\-]/g,"_"),b=`kanban-scripts/${e.id}/${Date.now()}-${f}`,{error:M}=await A.storage.from("plan-media").upload(b,o,{upsert:!0,contentType:o.type||"application/pdf",cacheControl:"31536000"});if(M){I(!1),L.error("Erro ao enviar roteiro");return}const te=await Rn("plan-media",b);S(te),await A.from("creator_kanban_cards").update({script_url:te}).eq("id",e.id),I(!1),L.success("Roteiro enviado"),s()},bt=async()=>{S(null),await A.from("creator_kanban_cards").update({script_url:null}).eq("id",e.id),s()},br=async(o,f)=>{oe(o);const b=f.name.replace(/[^\w.\-]/g,"_"),M=`kanban-finals/${e.id}/hook-${o}-${Date.now()}-${b}`,{error:te}=await A.storage.from("plan-media").upload(M,f,{upsert:!0,contentType:f.type||"video/mp4",cacheControl:"31536000"});if(te){oe(null),L.error("Erro ao enviar vídeo");return}const de=await Rn("plan-media",M),De=[...O.filter(we=>we.hook!==o),{hook:o,url:de,path:M}].sort((we,Ne)=>we.hook-Ne.hook);$(De),await A.from("creator_kanban_cards").update({final_videos:De}).eq("id",e.id),oe(null),L.success(`Vídeo do Hook ${o} enviado`),s()},yr=async o=>{const f=O.filter(b=>b.hook!==o);$(f),await A.from("creator_kanban_cards").update({final_videos:f}).eq("id",e.id),s()},wr=()=>{const o=O.reduce((f,b)=>Math.max(f,b.hook),0);$([...O,{hook:o+1,url:""}])},jr=async()=>{if(!confirm("Excluir este card?"))return;j&&await A.storage.from("creator-kanban-videos").remove([j]);const{error:o}=await A.from("creator_kanban_cards").delete().eq("id",e.id);if(o)return L.error("Erro ao excluir");L.success("Card excluído"),r(!1),s()};[...e.stage_history??[]].reverse();const En=[{key:"full_name",label:"Nome completo",group:"Principais"},{key:"age",label:"Idade",type:"number",group:"Principais"},{key:"gender",label:"Sexo",group:"Principais"},{key:"whatsapp",label:"WhatsApp",group:"Principais"},{key:"email",label:"E-mail",type:"email",group:"Principais"},{key:"portfolio_link",label:"Portfólio (link)",group:"Principais"},{key:"niche",label:"Nichos",wide:!0,group:"Principais"},{key:"faixa_preco",label:"Faixa de preço",group:"Principais"},{key:"ethnicity",label:"Cor / etnia",group:"Principais"},{key:"instagram_handle",label:"Instagram (@)",group:"Presença digital"},{key:"tiktok_handle",label:"TikTok (@)",group:"Presença digital"},{key:"city",label:"Cidade",group:"Presença digital"},{key:"state",label:"Estado (UF)",group:"Presença digital"},{key:"followers",label:"Seguidores",type:"number",group:"Métricas"},{key:"engagement_rate",label:"Engajamento %",type:"number",group:"Métricas"},{key:"estimated_value",label:"Valor estimado (R$)",type:"number",group:"Métricas"},{key:"accepts_barter",label:"Aceito permuta",type:"toggle",group:"Modelo de trabalho"},{key:"cpf",label:"CPF",group:"Pagamento"},{key:"pix_type",label:"Tipo de chave Pix",group:"Pagamento"},{key:"pix_key",label:"Chave Pix",group:"Pagamento"},{key:"address_cep",label:"CEP",group:"Endereço"},{key:"address_street",label:"Endereço (logradouro)",group:"Endereço"},{key:"address_number",label:"Número",group:"Endereço"},{key:"address_complement",label:"Complemento",group:"Endereço"},{key:"address_neighborhood",label:"Bairro",group:"Endereço"},{key:"address_city",label:"Cidade",group:"Endereço"},{key:"address_state",label:"UF",group:"Endereço"}
11,{key:"address_aos_cuidados",label:"Aos cuidados de",group:"Endereço"}];return n.jsx(Yn,{open:t,onOpenChange:r,children:n.jsxs(qn,{className:"flex max-h-[92vh] w-[96vw] max-w-6xl flex-col overflow-hidden p-0 sm:w-[92vw]",children:[n.jsxs(Xn,{className:"shrink-0 border-b bg-muted/30 px-5 py-3",children:[n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsxs(mn,{className:"h-9 w-9",children:[n.jsx(Jn,{src:u||void 0}),n.jsx(hn,{className:"text-xs",children:c.slice(0,2).toUpperCase()||"CR"})]}),n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsx(Wn,{className:"truncate text-left text-base",children:e.creator_name}),n.jsxs("div",{className:"mt-0.5 flex items-center gap-1.5 text-[11px] text-muted-foreground",children:[n.jsx(Qn,{variant:"secondary",className:"text-[10px]",children:St(e.stage)}),e.campaign&&n.jsxs("span",{className:"truncate",children:["· ",e.campaign]})]})]})]}),n.jsx(ka,{currentStage:e.stage,onChange:async o=>{if(o===e.stage)return;const{error:f}=await A.from("creator_kanban_cards").update({stage:o}).eq("id",e.id);if(f){L.error("Erro ao atualizar etapa");return}L.success(`Etapa: ${St(o)}`),s()}})]}),n.jsxs("div",{className:"grid min-h-0 flex-1 grid-cols-1 overflow-hidden lg:grid-cols-[1fr_400px]",children:[n.jsx("div",{className:"overflow-y-auto px-6 py-5",children:n.jsxs("div",{className:"space-y-6",children:[n.jsxs("section",{className:"space-y-4 rounded-xl border p-4",children:[n.jsxs("button",{type:"button",onClick:()=>Re("info"),className:"flex w-full items-center justify-between text-left",children:[n.jsx("h4",{className:"text-sm font-semibold",children:"Informações gerais"}),n.jsx(jt,{className:`h-4 w-4 transition-transform ${be.info?"":"-rotate-90"}`})]}),be.info&&n.jsxs("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2",children:[n.jsxs("div",{children:[n.jsx(se,{className:"text-xs",children:"Nome"}),n.jsx(ge,{value:c,onChange:o=>d(o.target.value)})]}),n.jsxs("div",{children:[n.jsx(se,{className:"text-xs",children:"Produto / Campanha"}),n.jsx(ge,{value:p,onChange:o=>h(o.target.value)})]}),n.jsxs("div",{className:"sm:col-span-2",children:[n.jsxs(se,{className:"flex items-center gap-1 text-xs",children:[n.jsx(An,{className:"h-3.5 w-3.5"})," Link do Instagram"]}),n.jsxs("div",{className:"flex gap-2",children:[n.jsx(ge,{value:_,onChange:o=>y(o.target.value),placeholder:"https://www.instagram.com/usuario"}),_&&n.jsx(q,{type:"button",variant:"outline",size:"icon",onClick:()=>window.open(_,"_blank"),children:n.jsx(ln,{className:"h-4 w-4"})})]})]}),n.jsxs("div",{className:"sm:col-span-2",children:[n.jsxs("div",{className:"mb-1.5 flex flex-wrap items-center justify-between gap-2",children:[n.jsxs(se,{className:"text-xs",children:["Últimos posts do Instagram (",Le.length,")"]}),n.jsxs("div",{className:"flex items-center gap-2",children:[Ve&&n.jsxs("span",{className:"text-[10px] text-muted-foreground",children:["Sincronizado em ",new Date(Ve).toLocaleString("pt-BR")]}),n.jsxs(q,{type:"button",variant:"outline",size:"sm",className:"h-7 px-2 text-[11px]",disabled:Ie,onClick:()=>{g()},children:[Ie?n.jsx(Me,{className:"mr-1.5 h-3.5 w-3.5 animate-spin"}):n.jsx(_r,{className:"mr-1.5 h-3.5 w-3.5"}),Ie?"Sincronizando…":"Sincronizar Instagram"]})]})]}),Le.length===0?n.jsx("p",{className:"rounded border border-dashed py-5 text-center text-[11px] text-muted-foreground",children:"Nenhum post sincronizado para este creator."}):n.jsx("div",{className:"flex gap-2 overflow-x-auto pb-1",children:Le.map((o,f)=>n.jsxs("a",{href:o.url??void 0,target:"_blank",rel:"noopener noreferrer",className:"group relative w-28 shrink-0 overflow-hidden rounded-lg border bg-muted",children:[o.thumbnail_url?n.jsx("img",{src:o.thumbnail_url,alt:o.caption??"Post do Instagram",loading:"lazy",className:"aspect-square w-full object-cover transition group-hover:scale-105",onError:b=>{b.currentTarget.style.visibility="hidden"}}):n.jsx("div",{className:"flex aspect-square w-full items-center justify-center",children:n.jsx(An,{className:"h-4 w-4 text-muted-foreground"})}),n.jsxs("div",{className:"absolute inset-x-0 bottom-0 flex items-center gap-2 bg-black/55 px-1.5 py-1 text-[10px] text-white",children:[n.jsxs("span",{className:"flex items-center gap-0.5",children:[n.jsx(Rr,{className:"h-3 w-3"})," ",o.likes??0]}),n.jsxs("span",{className:"flex items-center gap-0.5",children:[n.jsx(Ar,{className:"h-3 w-3"})," ",o.comments??0]})]})]},o.id??f))})]}),n.jsxs("div",{className:"sm:col-span-2",children:[n.jsx(se,{className:"text-xs",children:"Bio"}),n.jsx(wt,{value:X.bio??"",onChange:o=>pe("bio",o.target.value),rows:3,placeholder:"Sobre o creator…"})]}),n.jsxs("div",{className:"sm:col-span-2",children:[n.jsx(se,{className:"text-xs",children:"Anotações"}),n.jsx(wt,{value:x,onChange:o=>v(o.target.value),rows:3})]})]})]}),n.jsxs("section",{className:"space-y-3 rounded-xl border p-4",children:[n.jsxs("button",{type:"button",onClick:()=>Re("personal"),className:"flex w-full items-start justify-between text-left",children:[n.jsxs("div",{children:[n.jsx("h4",{className:"text-sm font-semibold",children:"Dados completos do criador"}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"Dados do formulário de cadastro do creator."})]}),n.jsx(jt,{className:`mt-1 h-4 w-4 shrink-0 transition-transform ${be.personal?"":"-rotate-90"}`})]}),be.personal&&n.jsx("div",{className:"space-y-4",children:Array.from(new Set(En.map(o=>o.group??"Outros"))).map(o=>n.jsxs("div",{className:"space-y-2",children:[n.jsx("p",{className:"text-[11px] font-semibold uppercase tracking-wide text-muted-foreground",children:o}),n.jsx("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2",children:En.filter(f=>(f.group??"Outros")===o&&f.key!=="full_name").map(f=>n.jsxs("div",{className:f.wide?"sm:col-span-2":"",children:[n.jsx(se,{className:"text-xs",children:f.label}),f.key==="bio"?n.jsx(wt,{value:X[f.key]??"",onChange:b=>pe(f.key,b.target.value),rows:3}):f.type==="toggle"?n.jsx("div",{className:"flex h-10 items-center",children:n.jsx(Cr,{checked:X[f.key]==="true",onCheckedChange:b=>pe(f.key,b?"true":"")})}):n.jsx(ge,{type:f.type??"text",value:X[f.key]??"",onChange:b=>pe(f.key,b.target.value)})]},f.key))})]},o))})]}),n.jsxs("section",{className:"space-y-3 rounded-xl border p-4",children:[n.jsxs("button",{type:"button",onClick:()=>Re("video"),className:"flex w-full items-center justify-between text-left",children:[n.jsx("h4",{className:"text-sm font-semibold",children:"Vídeo do criador"}),n.jsx(jt,{className:`h-4 w-4 transition-transform ${be.video?"":"-rotate-90"}`})]}),be.video&&n.jsxs("div",{className:"space-y-3",children:[n.jsxs("div",{children:[n.jsxs(se,{className:"flex items-center gap-1 text-xs",children:[n.jsx(Tr,{className:"h-3.5 w-3.5"})," Link (YouTube, Vimeo, Drive…)"]}),n.jsx(ge,{value:w,onChange:o=>k(o.target.value),placeholder:"https://..."})]}),n.jsxs("div",{children:[n.jsxs(se,{className:"flex items-center gap-1 text-xs",children:[n.jsx(Tn,{className:"h-3.5 w-3.5"})," Upload de arquivo"]}),j?n.jsxs("div",{className:"space-y-2",children:[E&&n.jsx("video",{src:E,controls:!0,className:"w-full rounded-lg border bg-black"}),n.jsx("div",{className:"flex gap-2",children:n.jsxs(q,{type:"button",variant:"outline",size:"sm",onClick:Te,children:[n.jsx(ot,{className:"mr-2 h-3.5 w-3.5"})," Remover vídeo"]})})]}):n.jsx(ge,{type:"file",accept:"video/*",disabled:ve,onChange:o=>{const f=o.target.files?.[0];f&&tt(f)}}),ve&&n.jsxs("p",{className:"mt-1 flex items-center gap-1 text-xs text-muted-foreground",children:[n.jsx(Me,{className:"h-3 w-3 animate-spin"}
11)," Enviando…"]})]})]})]}),n.jsxs("section",{className:"space-y-3 rounded-xl border p-4",children:[n.jsxs("button",{type:"button",onClick:()=>Re("script"),className:"flex w-full items-center justify-between text-left",children:[n.jsx("h4",{className:"text-sm font-semibold",children:"Roteiro (PDF)"}),n.jsx(jt,{className:`h-4 w-4 transition-transform ${be.script?"":"-rotate-90"}`})]}),be.script&&n.jsx("div",{className:"space-y-3",children:T?n.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-lg border bg-muted/30 p-3",children:[n.jsxs("a",{href:T,target:"_blank",rel:"noreferrer",className:"flex items-center gap-2 text-sm text-primary hover:underline",children:[n.jsx(Mr,{className:"h-4 w-4"})," Ver roteiro",n.jsx(ln,{className:"h-3 w-3"})]}),n.jsxs(q,{type:"button",variant:"outline",size:"sm",onClick:bt,children:[n.jsx(ot,{className:"mr-2 h-3.5 w-3.5"})," Remover"]})]}):n.jsxs("div",{children:[n.jsxs(se,{className:"flex items-center gap-1 text-xs",children:[n.jsx(Tn,{className:"h-3.5 w-3.5"})," Enviar PDF do roteiro"]}),n.jsx(ge,{type:"file",accept:"application/pdf",disabled:D,onChange:o=>{const f=o.target.files?.[0];f&&nt(f)}}),D&&n.jsxs("p",{className:"mt-1 flex items-center gap-1 text-xs text-muted-foreground",children:[n.jsx(Me,{className:"h-3 w-3 animate-spin"})," Enviando…"]})]})})]}),n.jsxs("section",{className:"space-y-3 rounded-xl border p-4",children:[n.jsxs("button",{type:"button",onClick:()=>Re("finals"),className:"flex w-full items-center justify-between text-left",children:[n.jsx("h4",{className:"text-sm font-semibold",children:"Vídeos finais entregues"}),n.jsx(jt,{className:`h-4 w-4 transition-transform ${be.finals?"":"-rotate-90"}`})]}),be.finals&&n.jsxs("div",{className:"space-y-3",children:[O.length===0&&n.jsx("p",{className:"text-xs text-muted-foreground",children:"Nenhum vídeo enviado ainda. Adicione hooks e faça upload dos vídeos finais."}),O.slice().sort((o,f)=>o.hook-f.hook).map(o=>n.jsxs("div",{className:"space-y-2 rounded-lg border p-3",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("span",{className:"text-xs font-semibold",children:["Hook ",o.hook]}),n.jsx(q,{type:"button",variant:"ghost",size:"sm",onClick:()=>yr(o.hook),children:n.jsx(ot,{className:"h-3.5 w-3.5"})})]}),o.url?n.jsxs("div",{className:"space-y-2",children:[n.jsx("video",{src:o.url,controls:!0,className:"w-full rounded-md border bg-black"}),n.jsxs("a",{href:o.url,target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1 text-xs text-primary hover:underline",children:["Abrir ",n.jsx(ln,{className:"h-3 w-3"})]})]}):n.jsx(ge,{type:"file",accept:"video/*",disabled:ae===o.hook,onChange:f=>{const b=f.target.files?.[0];b&&br(o.hook,b)}}),ae===o.hook&&n.jsxs("p",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[n.jsx(Me,{className:"h-3 w-3 animate-spin"})," Enviando…"]})]},o.hook)),n.jsxs(q,{type:"button",variant:"outline",size:"sm",onClick:wr,children:[n.jsx(pn,{className:"mr-2 h-3.5 w-3.5"})," Adicionar hook"]})]})]})]})}),n.jsx("aside",{className:"flex min-h-0 flex-col border-t bg-muted/20 lg:border-l lg:border-t-0",children:n.jsxs(Dr,{defaultValue:"comments",className:"flex min-h-0 flex-1 flex-col",children:[n.jsxs(Er,{className:"mx-4 mt-4 grid w-auto grid-cols-3",children:[n.jsxs(an,{value:"comments",className:"gap-1.5 text-xs",children:[n.jsx(Pr,{className:"h-3.5 w-3.5"})," Comentários"]}),n.jsxs(an,{value:"activity",className:"gap-1.5 text-xs",children:[n.jsx(Or,{className:"h-3.5 w-3.5"})," Atividade"]}),n.jsxs(an,{value:"history",className:"gap-1.5 text-xs",children:[n.jsx(Br,{className:"h-3.5 w-3.5"})," Histórico"]})]}),n.jsxs(on,{value:"comments",className:"mt-0 flex min-h-0 flex-1 flex-col",children:[n.jsx("div",{className:"flex-1 space-y-3 overflow-y-auto px-5 py-4",children:me.length===0?n.jsx("p",{className:"text-xs text-muted-foreground",children:"Nenhum comentário ainda. Seja o primeiro a comentar."}):me.map(o=>n.jsxs("div",{className:"rounded-lg border bg-background p-3",children:[n.jsxs("div",{className:"mb-1 flex items-center justify-between gap-2",children:[n.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[n.jsx(mn,{className:"h-6 w-6",children:n.jsx(hn,{className:"text-[10px]",children:(o.author_name??"?").slice(0,2).toUpperCase()})}),n.jsx("span",{className:"font-semibold",children:o.author_name??"Usuário"}),n.jsx("span",{className:"text-muted-foreground",children:new Date(o.created_at).toLocaleStr
11ing("pt-BR")})]}),o.author_id===a?.id&&n.jsx(q,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>{We(o.id)},children:n.jsx(ot,{className:"h-3 w-3"})})]}),n.jsx("p",{className:"whitespace-pre-wrap text-sm",children:o.body})]},o.id))}),n.jsx("div",{className:"border-t bg-background p-3",children:n.jsxs("div",{className:"flex gap-2",children:[n.jsx(wt,{value:ie,onChange:o=>W(o.target.value),placeholder:"Escreva um comentário…",rows:2,className:"resize-none"}),n.jsx(q,{size:"icon",onClick:()=>{je()},disabled:U||!ie.trim(),children:U?n.jsx(Me,{className:"h-4 w-4 animate-spin"}):n.jsx(Lr,{className:"h-4 w-4"})})]})})]}),n.jsxs(on,{value:"activity",className:"mt-0 flex min-h-0 flex-1 flex-col overflow-y-auto",children:[n.jsxs("div",{className:"border-b bg-background p-4 space-y-3",children:[n.jsx(ge,{value:Ke,onChange:o=>it(o.target.value),placeholder:"Título da atividade",className:"h-9 text-sm font-medium"}),n.jsx(wt,{value:ke,onChange:o=>Qe(o.target.value),placeholder:"Descrição (opcional)",rows:2,className:"resize-none text-sm"}),n.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[n.jsxs("div",{className:"col-span-2",children:[n.jsx(se,{className:"mb-1 block text-[10px] uppercase text-muted-foreground",children:"Início"}),n.jsx(ge,{type:"datetime-local",value:ee,onChange:o=>lt(o.target.value),className:"h-9 text-sm w-full"})]}),n.jsxs("div",{children:[n.jsx(se,{className:"mb-1 block text-[10px] uppercase text-muted-foreground",children:"Duração"}),n.jsxs(Bt,{value:String(Ze),onValueChange:o=>Ot(Number(o)),children:[n.jsx(Ut,{className:"h-8 text-xs",children:n.jsx(Ht,{})}),n.jsxs(Vt,{children:[n.jsx(ne,{value:"15",children:"15 min"}),n.jsx(ne,{value:"30",children:"30 min"}),n.jsx(ne,{value:"45",children:"45 min"}),n.jsx(ne,{value:"60",children:"1 h"}),n.jsx(ne,{value:"90",children:"1 h 30 min"}),n.jsx(ne,{value:"120",children:"2 h"}),n.jsx(ne,{value:"180",children:"3 h"}),n.jsx(ne,{value:"240",children:"4 h"})]})]})]}),n.jsxs("div",{children:[n.jsx(se,{className:"mb-1 block text-[10px] uppercase text-muted-foreground",children:"Prioridade"}),n.jsxs(Bt,{value:Fe,onValueChange:o=>qe(o),children:[n.jsx(Ut,{className:"h-8 text-xs",children:n.jsx(Ht,{})}),n.jsxs(Vt,{children:[n.jsx(ne,{value:"baixa",children:"Baixa"}),n.jsx(ne,{value:"media",children:"Média"}),n.jsx(ne,{value:"alta",children:"Alta"}),n.jsx(ne,{value:"urgente",children:"Urgente"})]})]})]}),n.jsxs("label",{className:"flex items-end gap-2 pb-1 text-xs text-muted-foreground cursor-pointer select-none",children:[n.jsx("input",{type:"checkbox",checked:Lt,onChange:o=>Ye(o.target.checked),className:"h-3.5 w-3.5 accent-primary"}),"Sincronizar com Google Calendar"]})]}),ee&&(()=>{const o=new Date(ee);if(isNaN(o.getTime()))return null;const f=new Date(o.getTime()+Math.max(5,Ze)*6e4),b=Xe.filter(P=>{const Be=new Date(P.start).getTime(),Ue=new Date(P.end).getTime();return isNaN(Be)||isNaN(Ue)?!1:Be<f.getTime()&&Ue>o.getTime()}),M=P=>new Date(P).toLocaleTimeString("pt-BR",{hour:"2-digit",minute:"2-digit"}),te=o.toLocaleDateString("pt-BR",{weekday:"long",day:"2-digit",month:"long"}),de=new Date(o.getFullYear(),o.getMonth(),o.getDate()).getTime(),De=(o.getTime()-de)/36e5,we=(f.getTime()-de)/36e5,Ne=Math.max(0,Math.floor(De-4)),rt=Math.min(24,Math.ceil(we+4)),Ee=Math.max(1,rt-Ne);zt.current={minH:Ne,totalH:Ee,dayStart:de};const st=P=>Math.max(0,Math.min(100,((P-de)/36e5-Ne)/Ee*100)),sn=Array.from({length:Ee+1},(P,Be)=>Ne+Be),at=b.length>0,yt=Math.max(320,Ee*64);return n.jsxs("div",{className:"rounded-xl border border-border bg-card p-3 text-xs shadow-sm",children:[n.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("span",{className:"inline-flex h-6 w-6 items-center justify-center rounded-md bg-muted text-muted-foreground",children:"📅"}),n.jsx("span",{className:"font-medium capitalize text-foreground",children:te})]}),n.jsx("span",{className:`rounded-full px-2 py-0.5 text-[11px] font-medium ${at?"bg-red-100 text-red-700":It?"bg-muted text-muted-foreground":"bg-emerald-100 text-emerald-700"}`,children:It?"Carregando…":at?`Conflito (${b.length})`:"Horário livre"})]}),n.jsx("div",{className:"relative select-none overflow-x-auto",children:n.jsxs("div",{style:{width:`${yt}px`,minWidth:"100%"},children:[n.jsx("div",{className:"relative ml-0 h-4",children:sn.map(P=>n.jsx("span",{className:"absolute -translate-x-1/2 text-[10px] tabular-nums text-muted-foreground",style:{left:`${(P-Ne)/Ee*100}%`},children:P},P))}),n.jsxs("div",{ref:dt,className:"relative mt-1 h-9 rounded-md bg-muted/40",children:[sn.map(P=>n.jsx("div",{className:"absolute top-0 h-full w-px bg-border/70",style:{left:`${(P-Ne)/Ee*100}%`}},P)),Xe.map(P=>{const Be=new Date(P.start).getTime(),Ue=new Date(P.end).getTime();if(isNaN(Be)||isNaN(Ue))return null;const _n=st(Be),Nr=Math.max(1,st(Ue)-_n),Sr=b.includes(P);return n.jsx("div",{title:`${P.summary} · ${M(P.start)}–${M(P.end)}`,className:`absolute top-1 bottom-1 overflow-hidden rounded-[4px] px-1.5 text-[10px] font-medium leading-[1.9] ${Sr?"bg-red-200/80 text-red-900 ring-1 ring-red-400":"bg-slate-300/70 text-slate-800"}`,style:{left:`${_n}%`,width:`${Nr}%`},children:n.jsx("span",{className:"truncate block",children:P.summary||"Sem título"})},P.id)}),n.jsx("div",{onPointerDown:rn,role:"slider","aria-label":"Arraste para mover o horário",className:`absolute -top-0.5 -bottom-0.5 cursor-grab touch-none rounded-md ring-2 transition-shadow active:cursor-grabbing active:shadow-lg ${at?"bg-red-500/30 ring-red-500":"bg-primary/30 ring-primary"}`,style:{left:`${st(o.getTime())}%`,width:`${Math.max(1.2,st(f.getTime())-st(o.getTime()))}%`}
11,children:n.jsxs("div",{className:"flex h-full items-center justify-center gap-1 text-[10px] font-semibold text-foreground/80",children:[n.jsx("span",{className:"opacity-60",children:"⋮⋮"}),n.jsxs("span",{className:"hidden sm:inline",children:[M(o),"–",M(f)]})]})})]})]})}),n.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-x-3 gap-y-1 text-[11px] text-muted-foreground",children:[n.jsxs("span",{className:"inline-flex items-center gap-1",children:[n.jsx("span",{className:`inline-block h-2.5 w-2.5 rounded-sm ${at?"bg-red-500/60 ring-1 ring-red-500":"bg-primary/50 ring-1 ring-primary"}`}),"Nova atividade · ",M(o),"–",M(f)]}),Xe.length>0&&n.jsxs("span",{className:"inline-flex items-center gap-1",children:[n.jsx("span",{className:"inline-block h-2.5 w-2.5 rounded-sm bg-slate-300"}),Xe.length," evento",Xe.length>1?"s":""," no dia"]})]}),at&&n.jsx("ul",{className:"mt-1.5 space-y-0.5 text-[11px] text-red-700",children:b.map(P=>n.jsxs("li",{children:["⚠ ",M(P.start),"–",M(P.end)," · ",P.summary||"Sem título"]},P.id))}),$t&&n.jsx("p",{className:"mt-1.5 text-[11px] text-muted-foreground",children:"Conecte o Google Calendar para ver conflitos."})]})})(),n.jsx("div",{className:"flex justify-end",children:n.jsxs(q,{size:"sm",onClick:()=>{Ae()},disabled:gt||!Ke.trim(),children:[gt?n.jsx(Me,{className:"mr-1.5 h-3.5 w-3.5 animate-spin"}):n.jsx(pn,{className:"mr-1.5 h-3.5 w-3.5"}),"Salvar atividade"]})})]}),n.jsx("div",{className:"flex-1 space-y-2 overflow-y-auto px-4 py-3",children:ze.length===0?n.jsxs("p",{className:"px-1 text-xs text-muted-foreground",children:["Nenhuma atividade ainda. Crie a primeira acima — ela também aparecerá em ",n.jsx("span",{className:"font-medium",children:"Tasks"}),"."]}):ze.map(o=>{const f=o.status==="concluido",b=o.priority==="urgente"?"bg-red-500/15 text-red-600":o.priority==="alta"?"bg-orange-500/15 text-orange-600":o.priority==="baixa"?"bg-blue-500/15 text-blue-600":"bg-muted text-muted-foreground";return n.jsxs("div",{className:"group flex items-start gap-2 rounded-lg border bg-background p-3",children:[n.jsx("button",{onClick:()=>{he(o)},className:"mt-0.5 shrink-0 text-muted-foreground hover:text-primary","aria-label":f?"Reabrir":"Concluir",children:f?n.jsx(bn,{className:"h-4 w-4 text-emerald-500"}):n.jsx(Ir,{className:"h-4 w-4"})}),n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsx("p",{className:`text-sm ${f?"text-muted-foreground line-through":"font-medium"}`,children:o.title}),n.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-1.5 text-[10px]",children:[n.jsx("span",{className:`rounded-full px-1.5 py-0.5 font-medium ${b}`,children:o.priority}),o.due_date&&n.jsxs("span",{className:"text-muted-foreground",children:["📅 ",new Date(o.due_date+"T00:00:00").toLocaleDateString("pt-BR")]}),n.jsxs("span",{className:"text-muted-foreground",children:["• ",new Date(o.created_at).toLocaleDateString("pt-BR")]})]})]}),n.jsx(q,{variant:"ghost",size:"icon",className:"h-7 w-7 opacity-0 group-hover:opacity-100",onClick:()=>{le(o.id)},children:n.jsx(ot,{className:"h-3.5 w-3.5"})})]},o.id)})})]}),n.jsx(on,{value:"history",className:"mt-0 min-h-0 flex-1 overflow-y-auto px-5 py-4",children:(()=>{const o=[];return o.push({at:e.created_at,kind:"created",label:n.jsx(n.Fragment,{children:"Card criado"})}),(e.stage_history??[]).forEach(f=>{o.push({at:f.at,kind:"stage",label:n.jsxs(n.Fragment,{children:["Movido de ",n.jsx("span",{className:"text-muted-foreground",children:St(f.from)})," para"," ",n.jsx("span",{className:"font-semibold",children:St(f.to)})]})})}),me.forEach(f=>{o.push({at:f.created_at,kind:"comment",label:n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"font-semibold",children:f.author_name??"Usuário"})," comentou"]})})}),o.sort((f,b)=>+new Date(b.at)-+new Date(f.at)),o.length===0?n.jsx("p",{className:"text-xs text-muted-foreground",children:"Sem atividades."}):n.jsx("ol",{className:"relative space-y-4 border-l border-border pl-4",children:o.map((f,b)=>n.jsxs("li",{className:"relative",children:[n.jsx("span",{className:`absolute -left-[21px] top-1 h-3 w-3 rounded-full border-2 border-background ${f.kind==="comment"?"bg-blue-500":f.kind==="created"?"bg-emerald-500":"bg-primary"}`}),n.jsx("p",{className:"text-xs",children:f.label}),n.jsx("p",{className:"text-[11px] text-muted-foreground",children:new Date(f.at).toLocaleStr
11ing("pt-BR")})]},b))})})()})]})})]}),n.jsxs(Gn,{className:"flex-row shrink-0 items-center justify-between gap-2 border-t bg-background px-6 py-3 sm:justify-between",children:[n.jsxs(q,{variant:"destructive",size:"sm",onClick:jr,children:[n.jsx(ot,{className:"mr-2 h-4 w-4"})," Excluir"]}),n.jsxs("div",{className:"flex gap-2",children:[n.jsx(q,{variant:"outline",onClick:()=>r(!1),children:"Fechar"}),n.jsxs(q,{onClick:et,disabled:N,children:[N?n.jsx(Me,{className:"mr-2 h-4 w-4 animate-spin"}):null,"Salvar"]})]})]})]})})}function ka({currentStage:e,onChange:t}){const r=Pe.findIndex(c=>c.key===e),s={inicio:{done:"bg-sky-500 text-white border-sky-500",current:"bg-sky-600 text-white border-sky-600 ring-2 ring-sky-200",upcoming:"bg-white text-sky-700 border-sky-200",line:"bg-sky-200"},producao:{done:"bg-amber-500 text-white border-amber-500",current:"bg-amber-600 text-white border-amber-600 ring-2 ring-amber-200",upcoming:"bg-white text-amber-700 border-amber-200",line:"bg-amber-200"},financeiro:{done:"bg-emerald-500 text-white border-emerald-500",current:"bg-emerald-600 text-white border-emerald-600 ring-2 ring-emerald-200",upcoming:"bg-white text-emerald-700 border-emerald-200",line:"bg-emerald-200"}},a=()=>{r>0&&t(Pe[r-1].key)},l=()=>{r<Pe.length-1&&t(Pe[r+1].key)};return n.jsx("div",{className:"mt-2.5",children:n.jsxs("div",{className:"flex items-center gap-1.5",children:[n.jsx(q,{type:"button",variant:"outline",size:"sm",className:"h-7 shrink-0 px-2 text-[11px]",onClick:a,disabled:r<=0,children:"Voltar"}),n.jsx("div",{className:"flex-1 overflow-x-auto",children:n.jsx("div",{className:"flex min-w-max items-center px-0.5",children:Pe.map((c,d)=>{const u=d<r?"done":d===r?"current":"upcoming",m=s[c.group],p=d===Pe.length-1;return n.jsxs("div",{className:"flex items-center",children:[n.jsxs("button",{type:"button",onClick:()=>t(c.key),className:"group flex items-center gap-1.5",title:`Ir para: ${c.label}`,children:[n.jsx("span",{className:`flex h-5 w-5 items-center justify-center rounded-full border text-[9px] font-semibold transition ${m[u]}`,children:u==="done"?n.jsx(bn,{className:"h-3 w-3"}):d+1}),n.jsx("span",{className:`whitespace-nowrap text-[10px] font-medium ${u==="current"?"text-foreground":"text-muted-foreground"} group-hover:text-foreground`,children:c.label})]}),!p&&n.jsx("div",{className:`mx-1.5 h-px w-4 ${d<r?m.line:"bg-muted"}`})]},c.key)})})}),n.jsx(q,{type:"button",size:"sm",className:"h-7 shrink-0 px-2 text-[11px]",onClick:l,disabled:r>=Pe.length-1,children:"Avançar"})]})})}export{lo as component};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.