1import{r as o,j as e,L as xt,e as Hn,u as Wn}from"./react-vendor-Cvme-g6x.js";import{c as pt,Z as ot,B as m,r as De,a3 as Ss,X as Se,d as Ce,a as it,m as oe,F as na,G as la,H as ca,J as da,K as ma,P as gs,T as Jn,k as wt,S as vr,a9 as jr,a6 as Kn,j as N,L as Ps,C as Ci,a4 as Yn,U as Xn,aq as Zn,t as q,u as el,W as lr,E as Si,ad as Pi,D as Mi,q as tl,ar as al,as as sl,x as cr,y as dr}from"./index-Dij6-G9-.js";import{r as rl}from"./supportTicketAttachment-CQADcQR5.js";import{u as il}from"./usePageVisible-CtjPv3_L.js";import{m as ol,r as Ms,j as Qa,T as Wa,g as Nr,D as Dt,a as Ft,b as $t,e as nl,d as ks,f as Nt,H as jt,k as no,l as be,V as mr,i as ll}from"./vitrineCartHandoff-D3z1VO-3.js";import{A as Ai,a as Ii,b as Oi,c as Ti,d as Ri,e as Ei,f as Li}from"./alert-dialog-BMfGVxdn.js";import{r as lo,i as Di,g as cl,b as Fi,L as dl}from"./LinkMirrorSection-CU8G5TwV.js";import{S as ua}from"./shopping-bag-DJ0PtXCh.js";import{I as As}from"./image-plus-C66wTkDI.js";import{E as Ja}from"./external-link-gXljzYZa.js";import{C as Fe}from"./calendar-clock-CqqcwrCT.js";import{Q as co}from"./QueueRadarCard-CQpkC5_m.js";import{S as qt}from"./shopping-cart-CC2MDXSp.js";import{f as wr,C as ml,P as ul,n as ur,M as hl}from"./communityMinerCategories-BMyegEYz.js";import{n as ha,h as xl,D as pl}from"./DestinationCategoryAssign-Cr6aEiMz.js";import{C as Ne}from"./circle-check-mjfUpuUy.js";import{I as mo}from"./info-CUwVWIYW.js";import{m as uo}from"./magaluDisplayImage-JOr_OBsF.js";import{T as ho}from"./triangle-alert-CasIb3go.js";import{T as Le}from"./trash-2-DZbsnt_v.js";import{D as Is}from"./database-BmpTlk5T.js";import{L as yr}from"./layout-grid-N5QXD5Uy.js";import{P as Os,c as bl,S as gl,b as fl}from"./miningHubConfig-DY-xsUl2.js";import{W as vl}from"./WhatsAppConnectToolbar-Dlh7JFdA.js";import{u as jl}from"./useTransientSuccess-URc51EAR.js";import{c as $i,S as zi,w as qi,L as Bi,i as Nl,b as wl}from"./libraryScheduleHandoff-OVoUjfQR.js";import{c as Vi,n as _i}from"./vitrineInstantConvert-TmZd2Oo8.js";import{w as yl}from"./videoPromptHandoff-Biol2Q4x.js";import{i as hr,j as kl,k as Ui,l as Cl}from"./minerOffers-D3myd5HH.js";import{g as xo}from"./shopeeExtensionWebstore-DXtu9EN3.js";import{C as Sr}from"./chevron-up-jhO79PLr.js";import{s as Sl}from"./selectionButtonStyles-D5mS1pRJ.js";import{c as Pl}from"./affiliateUrlCompact-CPGnhjyE.js";import{b as Gi}from"./schedulePostCopy-T_RAiZwK.js";import{C as xr}from"./copy-BkDvKeOr.js";import{I as Ml}from"./image-CS--XUcm.js";import{S as Al}from"./save-QCo7QYyZ.js";import"./trpc-vendor-CcQiuHv2.js";import"./recharts-vendor-D3gx481F.js";import"./framer-vendor-vyqLUUua.js";import"./parseFlexibleMoney-B6RdYWM1.js";import"./index-32mIk2zp.js";import"./index-BN74VVMI.js";import"./index-BlR1dMZ8.js";import"./chevron-right-cB9ixyqo.js";import"./switch-DALd8d07.js";import"./index-DbRBuB-4.js";import"./refresh-cw-BE3b88El.js";import"./WhatsAppSingleBotWarning-Cp0527Cu.js";import"./constructNow-BiiAh-X8.js";import"./mercadoLivreProductUrl-CLl3NzO_.js";import"./marketplaceClosingPhrases-BSVOaX_g.js";/** 2 * @license lucide-react v0.453.0 - ISC 3 * 4 * This source code is licensed under the ISC license. 5 * See the LICENSE file in the root directory of this source tree. 6 */const kr=pt("Archive",[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8",key:"1s80jp"}],["path",{d:"M10 12h4",key:"a56b0p"}]]);/** 7 * @license lucide-react v0.453.0 - ISC 8 * 9 * This source code is licensed under the ISC license. 10 * See the LICENSE file in the root directory of this source tree. 11 */const Il=pt("BadgePercent",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"M9 9h.01",key:"1q5me6"}],["path",{d:"M15 15h.01",key:"lqbp3k"}]]);/** 12 * @license lucide-react v0.453.0 - ISC 13 * 14 * This source code is licensed under the ISC license. 15 * See the LICENSE file in the root directory of this source tree. 16 */const Qi=pt("CirclePlus",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"M12 8v8",key:"napkw2"}]]);/** 17 * @license lucide-react v0.453.0 - ISC 18 * 19 * This source code is licensed under the ISC license. 20 * See the LICENSE file in the root directory of this source tree. 21 */const Rs=pt("Coins",[["circle",{cx:"8",cy:"8",r:"6",key:"3yglwk"}],["path",{d:"M18.09 10.37A6 6 0 1 1 10.34 18",key:"t5s6rm"}],["path",{d:"M7 6h1v4",key:"1obek4"}],["path",{d:"m16.71 13.88.7.71-2.82 2.82",key:"1rbuyh"}]]);/** 22 * @license lucide-react v0.453.0 - ISC 23 * 24 * This source code is licensed under the ISC license. 25 * See the LICENSE file in the root directory of this source tree. 26 */const Ua=pt("Ellipsis",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]]);/** 27 * @license lucide-react v0.453.0 - ISC 28 * 29 * This source code is licensed under the ISC license. 30 * See the LICENSE file in the root directory of this source tree. 31 */const Ol=pt("GripVertical",[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]]);/** 32 * @license lucide-react v0.453.0 - ISC 33 * 34 * This source code is licensed under the ISC license. 35 * See the LICENSE file in the root directory of this source tree. 36 */const Tl=pt("ImageOff",[["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}],["path",{d:"M10.41 10.41a2 2 0 1 1-2.83-2.83",key:"1bzlo9"}],["line",{x1:"13.5",x2:"6",y1:"13.5",y2:"21",key:"1q0aeu"}],["line",{x1:"18",x2:"21",y1:"12",y2:"15",key:"5mozeu"}],["path",{d:"M3.59 3.59A1.99 1.99 0 0 0 3 5v14a2 2 0 0 0 2 2h14c.55 0 1.052-.22 1.41-.59",key:"mmje98"}],["path",{d:"M21 15V5a2 2 0 0 0-2-2H9",key:"43el77"}]]);/** 37 * @license lucide-react v0.453.0 - ISC 38 * 39 * This source code is licensed under the ISC license. 40 * See the LICENSE file in the root directory of this source tree. 41 */const Rl=pt("PackageCheck",[["path",{d:"m16 16 2 2 4-4",key:"gfu2re"}],["path",{d:"M21 10V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l2-1.14",key:"e7tb2h"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["line",{x1:"12",x2:"12",y1:"22",y2:"12",key:"a4e8g8"}]]);/** 42 * @license lucide-react v0.453.0 - ISC 43 * 44 * This source code is licensed under the ISC license. 45 * See the LICENSE file in the root directory of this source tree. 46 */const Ts=pt("PackageOpen",[["path",{d:"M12 22v-9",key:"x3hkom"}],["path",{d:"M15.17 2.21a1.67 1.67 0 0 1 1.63 0L21 4.57a1.93 1.93 0 0 1 0 3.36L8.82 14.79a1.655 1.655 0 0 1-1.64 0L3 12.43a1.93 1.93 0 0 1 0-3.36z",key:"2ntwy6"}],["path",{d:"M20 13v3.87a2.06 2.06 0 0 1-1.11 1.83l-6 3.08a1.93 1.93 0 0 1-1.78 0l-6-3.08A2.06 2.06 0 0 1 4 16.87V13",key:"1pmm1c"}],["path",{d:"M21 12.43a1.93 1.93 0 0 0 0-3.36L8.83 2.2a1.64 1.64 0 0 0-1.63 0L3 4.57a1.93 1.93 0 0 0 0 3.36l12.18 6.86a1.636 1.636 0 0 0 1.63 0z",key:"12ttoo"}
46]]),Va={mercadolivre:"Mercado Livre Captura",magalu:"Magalu Captura",amazon:"Amazon Captura",tiktokshop:"TikTok Shop Captura",shein:"Shein Captura"},po=["Shopee Captura","Shopee Brand Offer","Shopee Product Offer",Va.mercadolivre,Va.magalu,Va.amazon,Va.tiktokshop,Va.shein],zt=po[0];function Cs(s){return ha(s)===ha(zt)}function bo(s){const r=ha(s);return r?po.some(n=>ha(n)===r):!1}function El(s){const r=wr(s);if(r)return r;const n=ha(s);if(n.length<3)return null;for(const u of ml){const d=ha(u);if(!(d.length<4)&&(n.includes(d)||d.includes(n)))return u}return null}function Ll(s){if(String(s.platform||"").toLowerCase()!=="shopee")return!1;if(ol(s))return!0;const r=String(s.category??"").trim();return Cs(r)||bo(r)}function Dl(s,r="Sem categoria"){if(Ll(s))return zt;const n=String(s.category??"").trim();if(bo(n)){const u=El(String(s.productTitle??""));if(u)return u;const d=String(s.platform??"").trim();return d?d.charAt(0).toUpperCase()+d.slice(1):r}return n||r}function Fl(s,r="Sem categoria"){const n=new Map;for(const d of s){const h=Dl(d,r),x=n.get(h);x?x.push(d):n.set(h,[d])}const u=Array.from(n.entries());return u.sort(([d],[h])=>d===zt&&h!==zt?-1:h===zt&&d!==zt||d===r&&h!==r?1:h===r&&d!==r?-1:d.localeCompare(h,"pt-BR")),u}const $l=new Set(["extension-capture","vitrine-shopee-extension"]);function zl(s){const r=String(s||"").replace(/^#/,"").trim(),[n,...u]=r.split("&");let d=null;for(const h of u)h.startsWith("cap=")&&(d=h.slice(4)||null);return{name:(n||"").toLowerCase(),cap:d}}function ql(s){const r=s.replace(/-/g,"+").replace(/_/g,"/"),n=r+"=".repeat((4-r.length%4)%4),u=atob(n),d=new Uint8Array(u.length);for(let h=0;h<u.length;h+=1)d[h]=u.charCodeAt(h);return d}async function Bl(s){try{if(typeof DecompressionStream!="function")return null;const r=ql(decodeURIComponent(s)),n=new Blob([r]).stream().pipeThrough(new DecompressionStream("gzip")),u=await new Response(n).text(),d=JSON.parse(u);if(!d||typeof d!="object")return null;const h=d;return!Array.isArray(h.items)||h.items.length<1?null:h}catch{return null}}const Ha="smartoferta:extension-imported-keys";function Vl(s){try{const r=window.sessionStorage.getItem(Ha),n=r?JSON.parse(r):[];return Array.isArray(n)&&n.includes(s)}catch{return!1}}function _l(s){try{const r=window.sessionStorage.getItem(Ha),n=r?JSON.parse(r):[],u=[...Array.isArray(n)?n:[],s].slice(-30);window.sessionStorage.setItem(Ha,JSON.stringify(u))}catch{}}function Ul(s){try{const r=window.sessionStorage.getItem(Ha),n=r?JSON.parse(r):[];if(!Array.isArray(n))return;window.sessionStorage.setItem(Ha,JSON.stringify(n.filter(u=>u!==s)))}catch{}}const Hi={display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",overflow:"hidden"};function Pr({offer:s,selected:r,onToggle:n,formatCurrency:u,formatPercent:d,cn:h,extension:x,density:g="default",onRemove:M,isRemoving:f=!1,onUploadProductImage:y,isUploadingImage:D=!1}){const[E,F]=o.useState(!1),ae=o.useRef(null),z=s.productTitle||s.title||s.productName||"Produto sem tÃtulo",se=s.description&&s.description.trim()!=="Oferta pronta para seleção, copy e agendamento."?s.description.trim():"",_=o.useMemo(()=>{const I=Wl(s);return lo(I)||""},[s]);o.useEffect(()=>{F(!1)},[_]);const W=Gl(s.platform||s.marketplace||""),H=Ms(s),O=!!H,ue=()=>{O&&window.open(H,"_blank","noopener,noreferrer")},$=Ga(s.currentPrice),re=Ga(s.originalPrice),A=Ga(s.discountPercent),L=Ql(s.commissionPercent),he=Ga(s.commissionAmount),J=/shein/i.test(String(W||"")),w=J&&(L<=0||/estimativa|capture\s*\(est\.\)|referência|referencia/i.test(String(s.commissionSourceLabel||"estimativa"))),le=J&&w?0:L,T=J&&w?0:he,ce=A>0?A:Hl($,re),k=Qa(s),ee=!!_&&!E&&!k,$e=re>0&&re>$,xe=ce>0,K=le>0,nt=$>0,te=s.category?.trim()||"Sem categoria";function Pe(){r||n(s.id),window.setTimeout(()=>{const I=document.getElementById("schedule-panel")||document.querySelector("[data-schedule-panel='true']");if(I instanceof HTMLElement){I.scrollIntoView({behavior:"smooth",block:"start"});return}window.scrollTo({top:document.body.scrollHeight,behavior:"smooth"})},r?0:120)}return e.jsxs("article",{className:h("group overflow-hidden rounded-[24px] border bg-white shadow-sm transition-all duration-200","hover:-translate-y-1 hover:shadow-[0_20px_40px_rgba(124,58,237,0.12)]",O&&"curs
46or-pointer",r?"border-violet-500 ring-[3px] ring-violet-300/90 shadow-[0_12px_32px_rgba(124,58,237,0.18)]":"border-violet-100"),role:O?"button":void 0,tabIndex:O?0:void 0,onClick:ue,onKeyDown:I=>{O&&(I.key==="Enter"||I.key===" ")&&(I.preventDefault(),ue())},children:[e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"aspect-square overflow-hidden bg-slate-50 p-2.5 sm:p-3 flex items-center justify-center",children:ee?e.jsx("img",{src:_,alt:z,className:"max-h-full max-w-full object-contain transition-transform duration-300 group-hover:scale-[1.05] drop-shadow-sm",loading:"lazy",decoding:"async",referrerPolicy:"no-referrer",onLoad:I=>{const ze=I.currentTarget;ze.naturalWidth>0&&ze.naturalHeight>0&&(ze.naturalWidth<48||ze.naturalHeight<48)&&F(!0)},onError:()=>F(!0)}):k?e.jsxs("div",{className:"relative flex h-full w-full flex-col justify-between overflow-hidden bg-gradient-to-br from-[#ff5b2e] via-[#ff6f3d] to-[#ff8f68] p-4 text-white",children:[e.jsx("div",{className:"absolute right-[-22px] top-[-18px] h-28 w-28 rounded-full border border-white/15 bg-white/10 blur-[1px]"}),e.jsx("div",{className:"absolute left-[-18px] bottom-[-24px] h-24 w-24 rounded-full border border-white/15 bg-white/10"}),e.jsxs("div",{className:"relative z-10 inline-flex w-fit items-center gap-2 rounded-full border border-white/20 bg-white/15 px-3 py-1 text-[10px] font-black uppercase tracking-[0.18em] backdrop-blur",children:[e.jsx(ot,{className:"h-3.5 w-3.5"}),"Campanha Shopee"]}),e.jsxs("div",{className:"relative z-10 space-y-2",children:[e.jsx("p",{className:"max-w-[85%] text-2xl font-black leading-none tracking-tight",children:"Shopee"}),e.jsx("p",{className:"max-w-[90%] text-sm font-semibold leading-5 text-white/90",children:"Comissão ativa e link afiliado prontos para uso interno."})]}),e.jsxs("div",{className:"relative z-10 flex items-center gap-2 text-[11px] font-semibold text-white/90",children:[e.jsx(ua,{className:"h-4 w-4"}),"Abra a campanha para ver produtos e preços"]})]}):e.jsxs("div",{className:"flex h-full w-full flex-col items-center justify-center gap-2 text-violet-300",children:[e.jsx("div",{className:"flex h-12 w-12 items-center justify-center rounded-full bg-white shadow-sm",children:e.jsx(Tl,{className:"h-5 w-5"})}),e.jsx("p",{className:"text-xs font-semibold text-slate-400",children:"Imagem não disponÃvel"}),y?e.jsxs(e.Fragment,{children:[e.jsxs(m,{type:"button",variant:"outline",size:"sm",disabled:D,className:"min-h-[40px] touch-manipulation rounded-xl border-violet-200 bg-white text-xs font-bold text-violet-800 hover:bg-violet-50",onClick:I=>{I.stopPropagation(),ae.current?.click()},children:[D?e.jsx(De,{className:"mr-1.5 h-3.5 w-3.5 animate-spin"}):e.jsx(As,{className:"mr-1.5 h-3.5 w-3.5"}),"Enviar foto"]}),e.jsx("input",{ref:ae,type:"file",accept:"image/png,image/jpeg,image/webp,image/*",className:"sr-only",onClick:I=>I.stopPropagation(),onChange:I=>{const ze=I.target.files?.[0];I.target.value="",ze&&y(s.id,ze)}})]}):null]})}),e.jsxs("div",{className:"absolute left-3 top-3 flex max-w-[calc(100%-48px)] flex-wrap items-center gap-1.5 overflow-hidden",children:[W?e.jsxs("span",{className:h("inline-flex items-center gap-1 rounded-full border px-2 py-0.5 text-[10px] font-extrabold uppercase tracking-wider text-white shadow-sm shrink-0",W==="shopee"?"bg-[#ee4d2d] border-[#ee4d2d]":W==="mercadolivre"?"bg-[#ffe600] border-[#ecd400] text-slate-900":W==="amazon"?"bg-[#232f3e] border-[#37475a]":W==="magalu"?"bg-[#0086ff] border-[#0074de]":W==="shein"?"bg-[#7928ca] border-[#6b21a8]":W==="tiktokshop"?"bg-[#000000] border-slate-700":"bg-slate-950/80 border-white/20"),children:[e.jsx(ua,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{className:"truncate max-w-[76px]",children:W})]}):null,xe?e.jsxs("span",{className:"inline-flex items-center gap-0.5 rounded-full border border-fuchsia-200 bg-white/95 px-2 py-0.5 text-[10px] font-extrabold text-fuchsia-700 shadow-sm shrink-0",children:[e.jsx(Il,{className:"h-3 w-3 shrink-0"}),d(ce)]}):null,K?e.jsxs("span",{className:"inline-flex items-center gap-0.5 rounded-full border border-emerald-200 bg-emerald-50/95 px-2 py-0.5 text-[10px] font-extrabold text-emerald-700 shadow-sm shrink-0",children:[e.jsx(Rs,{className:"h-3 w-3 shrink-0"}),le.toFixed(1),"%"]}):J?e.jsx("span",{className:"inline-flex items-center gap-1 rounded-full border border-amber-200 bg-amber-50/95 px-2 py-0.5 text-[10px] font-bold text-amber-800 shadow-sm shrink-0",children:"Validar %"}):null]}),e.jsx("button",{type:"button",onClick:I=>{I.stopPropagation(),n(s.id)},className:h("group absolute right-3 top-3 flex h-9 w-9 items-center justify-center rounded-full border border-white/80 bg-white/95 shadow-sm transition-all outline-none focus-visible:ring-2 focus-visible:ring-violet-400 focus-visible:ring-offset-2 hover:bg-white",r&&"border-violet-300 ring-2 ring-violet-200 ring-offset-2 ring-offset-white"),"aria-label":r?"Remover seleção":"Selecionar oferta","aria-pressed":r,children:e.jsx(Ss,{className:h("h-4 w-4 transition-colors",r?"text-violet-600":"text-slate-500 group-active:text-violet-600")})}),M?e.jsx("button",{type:"button",disabled:f,onClick:I=>{I.stopPropagation(),M(s.id)},className:h("absolute bottom-3 right-3 flex h-9 w-9 touch-manipulation items-center justify-center rounded-full border border-white/80 bg-white/95 shadow-sm outline-none transition-all focus-visible:ring-2 focus-visible:ring-rose-400 focus-visible:ring-offset-2 hover:bg-rose-50 disabled:opacity-60"),"aria-label":"Remover da galeria",title:"Remover da galeria",children:f?e.jsx(De,{className:"h-4 w-4 animate-spin text-rose-600","aria-hidden":!0}):e.jsx(Se,{className:"h-4 w-4 text-rose-600","aria-hidden":!0})}):null]}),e.jsxs("div",{className:h("space-y-4",g==="compact"?"p-3":"p-4"),children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("h3",{className:h("font-black leading-5 tracking-tight text-slate-900",g==="compact"?"min-h-[2.25rem] text-[14px]":"min-h-[2.5rem] text-[15px]"),style:Hi,title:z,children:z}),se?e.jsx("p",{className:h("leading-5 text-slate-500",g==="compact"?"text-[13px]":"text-sm"),style:Hi,children:se}):null,e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex max-w-[78%] flex-wrap gap-2",children:[e.jsx("span",{className:"inline-flex max-w-full items-center rounded-full border border-violet-200 bg-vi
46olet-50 px-2.5 py-1 text-[11px] font-semibold text-violet-700",children:e.jsx("span",{className:"truncate",children:te})}),K?e.jsxs("span",{className:"inline-flex items-center rounded-full border border-emerald-200 bg-emerald-50 px-2.5 py-1 text-[11px] font-semibold text-emerald-700",children:["Comissão ",le.toFixed(1),"%"]}):J?e.jsx("span",{className:"inline-flex items-center rounded-full border border-amber-200 bg-amber-50 px-2.5 py-1 text-[11px] font-semibold text-amber-800",children:"Validar % na Shein"}):null]}),H?e.jsxs("a",{href:H,target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1 text-xs font-bold text-violet-600 transition-colors hover:text-violet-800",onClick:I=>I.stopPropagation(),children:[k?"Abrir campanha":"Abrir",e.jsx(Ja,{className:"h-3.5 w-3.5"})]}):null]})]}),e.jsxs("div",{className:h("rounded-[18px] border border-violet-100 bg-gradient-to-b from-violet-50/70 to-white",g==="compact"?"p-2.5":"p-3"),children:[nt?e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-black uppercase tracking-[0.16em] text-violet-500",children:"Preço atual"}),e.jsx("p",{className:h("mt-1 font-black tracking-tight text-slate-900",g==="compact"?"text-xl":"text-2xl"),children:u($)})]}),$e?e.jsxs("div",{className:"text-right",children:[e.jsx("p",{className:"text-[10px] font-black uppercase tracking-[0.16em] text-slate-400",children:"De"}),e.jsx("p",{className:"mt-1 text-sm font-semibold text-slate-400 line-through",children:u(re)})]}):null]}):k?e.jsxs("div",{className:"rounded-[14px] border border-dashed border-violet-200 bg-white/70 px-3 py-3",children:[e.jsx("p",{className:"text-[10px] font-black uppercase tracking-[0.16em] text-violet-500",children:"Campanha com comissão"}),e.jsx("p",{className:"mt-1 text-sm font-semibold text-slate-700",children:"Preço ao abrir oferta"}),e.jsx("p",{className:"mt-1 text-[11px] leading-5 text-slate-500",children:"O preço real depende da expansão para produto e pode não estar disponÃvel no feed bruto."})]}):e.jsx("div",{className:"rounded-[14px] border border-dashed border-slate-200 bg-white/70 px-3 py-3",children:e.jsx("p",{className:"text-sm font-semibold text-slate-700",children:"Preço indisponÃvel"})}),xe||K?e.jsxs("div",{className:"mt-3 flex flex-wrap items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex flex-wrap gap-2",children:[xe?e.jsxs("span",{className:"inline-flex items-center rounded-full border border-emerald-200 bg-emerald-50 px-2.5 py-1 text-[11px] font-semibold text-emerald-700",children:["Economia ",d(ce)]}):null,T>0?e.jsxs("span",{className:"inline-flex items-center rounded-full border border-sky-200 bg-sky-50 px-2.5 py-1 text-[11px] font-semibold text-sky-700",children:["Comissão ",u(T)]}):null]}),e.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full bg-gradient-to-r from-violet-600 to-fuchsia-600 px-2.5 py-1 text-[11px] font-bold text-white",children:[e.jsx(ot,{className:"h-3.5 w-3.5"}),"Oferta"]})]}):null,s.commissionSourceLabel&&!w?e.jsx("p",{className:"mt-3 text-[11px] font-semibold text-slate-500",children:s.commissionSourceLabel}):J?e.jsx("p",{className:"mt-3 text-[11px] font-semibold text-amber-800",children:"Validar % no Centro de Afiliados Shein"}):s.commissionSourceLabel?e.jsx("p",{className:"mt-3 text-[11px] font-semibold text-slate-500",children:s.commissionSourceLabel}):null]}),e.jsxs("div",{className:h("grid grid-cols-2",g==="compact"?"gap-2":"gap-2.5"),children:[e.jsxs(m,{type:"button",variant:"outline",onClick:I=>{I.stopPropagation(),Pe()},"aria-label":"Agendar envio",title:"Agendar",className:h("touch-manipulation justify-center rounded-xl border-violet-200 bg-white px-2 text-sm font-bold text-violet-700 hover:bg-violet-50 md:justify-start md:px-4",g==="compact"?"h-9 md:h-9":"h-9 md:h-10"),children:[e.jsx(Fe,{className:"h-4 w-4 shrink-0 md:mr-2","aria-hidden":!0}),e.jsx("span",{className:"hidden md:inline",children:"Agendar"})]}),e.jsxs(m,{type:"button",onClick:I=>{I.stopPropagation(),n(s.id)},"aria-label":r?"Remover seleção":"Selecionar oferta",title:r?"Selecionada":"Selecionar",className:h("touch-manipulation justify-center rounded-xl text-sm font-bold shadow-sm transition-all md:justify-start md:px-4",g==="compact"?"h-9 md:h-9":"h-9 md:h-10",r?"bg-violet-700 text-white ring-2 ring-violet-300 ring-offset-2 hover:bg-violet-800":"bg-gradient-to-r from-violet-600 to-fuchsia-600 text-white hover:opacity-95"),children:[e.jsx(ot,{className:"h-4 w-4 shrink-0 md:mr-2","aria-hidden":!0}),e.jsx("span",{className:"hidden md:inline",children:r?"Selecionada":"Selecionar"})]})]}),x?e.jsx("div",{className:"border-t border-violet-100 pt-4",onClick:I=>I.stopPropagation(),children:x}):null]})]})}function Gl(s){const r=String(s||"").toLowerCase().trim();return r?r==="mercadolivre"?"Mercado Livre":r==="magalu"?"Magalu":r==="amazon"?"Amazon":r==="shopee"?"Shopee":s:""}function Ga(s){if(typeof s=="number")return Number.isFinite(s)?s:0;
46if(typeof s!="string")return 0;const r=s.replace(/[^\d,.-]/g,"").replace(/\.(?=\d{3}(?:\D|$))/g,"").replace(",","."),n=Number(r);return Number.isFinite(n)?n:0}function Ql(s){if(s==null||s==="")return 0;if(typeof s=="string"&&s.includes("%"))return Ga(s);const r=Number(s);return!Number.isFinite(r)||r<=0?0:r>=1?r:r*100}function Hl(s,r){return!s||!r||r<=s?0:Math.round((r-s)/r*100)}function Wl(s){const r=[s.productImage,s.imageUrl,s.image,s.thumbnail,s.image_url,s.thumb];for(const u of r){const d=Je(u);if(d)return d}const n=[s.images,s.media,s.gallery];for(const u of n){const d=Jl(u);if(d)return d}return""}function Jl(s){if(!s)return"";if(Array.isArray(s)){for(const r of s){const n=Je(r);if(n)return n}return""}if(typeof s=="string"){const r=s.trim();if(!r)return"";if(r.startsWith("[")&&r.endsWith("]")||r.startsWith("{")&&r.endsWith("}"))try{const n=JSON.parse(r);if(Array.isArray(n))for(const u of n){const d=Je(u);if(d)return d}else return Je(n)}catch{return Je(r)}return Je(r)}return Je(s)}function Je(s){if(!s)return"";if(typeof s=="string"){const r=s.trim();return!r||r==="null"||r==="undefined"?"":r.startsWith("//")?`https:${r}`:r.startsWith("http://")||r.startsWith("https://")?r:""}return typeof s=="object"?Je(s.url)||Je(s.src)||Je(s.image)||Je(s.thumbnail):""}function Kl(...s){return s.filter(Boolean).join(" ")}function pr({label:s,value:r,helper:n}){return e.jsxs("div",{className:"rounded-[18px] border border-violet-100 bg-violet-50/55 px-4 py-4",children:[e.jsx("p",{className:"text-[10px] font-black uppercase tracking-[0.18em] text-violet-500",children:s}),e.jsx("p",{className:"mt-1 text-lg font-black text-slate-900",children:r}),e.jsx("p",{className:"mt-1 text-xs text-slate-500",children:n})]})}function Yl(s){const{showQueueRadar:r,onToggleQueueRadar:n,queueItems:u,queueRadarItems:d,nextQueueItem:h,formatQueueRadarDate:x,onViewHistory:g}=s;return e.jsx("div",{className:"hidden md:block",children:e.jsxs("section",{className:"overflow-hidden rounded-[24px] border border-violet-100 bg-white shadow-sm",children:[e.jsxs("button",{type:"button",onClick:n,className:"flex w-full items-center justify-between gap-4 px-5 py-4 text-left transition hover:bg-violet-50/60 md:px-6",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-black uppercase tracking-[0.22em] text-violet-500",children:"Monitoramento da operação"}),e.jsx("h3",{className:"mt-1 text-xl font-black tracking-tight text-slate-900",children:"Radar da sua operação"}),e.jsx("p",{className:"mt-1 text-sm leading-6 text-slate-500",children:"Recolha o radar para deixar a tela mais limpa e expanda só quando quiser consultar a fila."})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-2 rounded-full border border-violet-200 bg-white px-3 py-2 text-xs font-bold text-violet-700 shadow-sm",children:[r?"Ocultar radar":"Mostrar radar",e.jsx(Ce,{className:Kl("h-4 w-4 transition-transform",r&&"rotate-180")})]})]}),r?e.jsx("div",{className:"border-t border-violet-100 p-4 md:p-5",children:e.jsx(co,{title:"Radar da sua operação",subtitle:"Fila real das campanhas vinculadas à sua biblioteca.",totalScheduled:u.length,totalGroups:d.length,nextSendLabel:h?x(new Date(h.executeAt)):"Sem próximo envio definido",items:d,emptyMessage:"Nenhum agendamento pendente no radar neste momento.",actionLabel:"Ver histórico",onViewQueue:g})}):e.jsxs("div",{className:"grid gap-3 border-t border-violet-100 p-4 md:grid-cols-3 md:p-5",children:[e.jsx(pr,{label:"Campanhas na fila",value:String(u.length),helper:"Volume ativo no scheduler"}),e.jsx(pr,{label:"Destinos monitorados",value:String(d.length),helper:"Canais e grupos acompanhados"}),e.jsx(pr,{label:"Próximo envio",value:h?x(new Date(h.executeAt)):"â",helper:"Janela operacional atual"})]})]})})}function Re(...s){return s.filter(Boolean).join(" ")}function go(s){if(typeof s=="number"&&Number.isFinite(s))return s;if(typeof s!="string")return 0;const r=s.replace(/[^\d,.-]/g,"").replace(/\.(?=\d{3}(?:\D|$))/g,"").replace(",","."),n=Number(r);return Number.isFinite(n)?n:0}function Xl(s){if(s==null||s==="")return 0;if(typeof s=="string"&&s.includes("%"))return go(s.replace("%",""));const r=Number(s);return!Number.isFinite(r)||r<=0?0:r>=1?r:r*100}function oa({offer:s,selected:r,formatCurrency:n,formatPlatformName:u,formatCommission:d,onToggle:h,onPrimary:x,primaryMode:g,primaryDisabled:M,secondaryLabel:f,primaryLabel:y,footer:D,campaignShopeeApi:E=!1,campaignOpenUrl:F,onScrollToExtension:ae,onRemove:z,isRemoving:se=!1,layout:_="strip",onUploadProductImage:W,isU
46ploadingImage:H=!1}){const O=_==="fluid",ue=String(s.productTitle||"Sem tÃtulo").trim(),re=Xl(s.commissionPercent)>0,A=go(s.commissionAmount)>0,L=/shein/i.test(String(s.platform||"")),he=lo(s.productImage),J=o.useRef(null);return e.jsxs("article",{className:Re("flex flex-col overflow-hidden rounded-[14px] border bg-white shadow-sm transition-all",O?"w-full shrink":"w-[148px] shrink-0 snap-start",r?"border-violet-500 ring-2 ring-violet-300/80 shadow-md":E?"border-orange-200 ring-1 ring-orange-100":"border-slate-100"),children:[e.jsxs("div",{className:Re("relative w-full overflow-hidden bg-slate-50 flex items-center justify-center p-2",O?"aspect-square max-h-56":"aspect-square"),children:[he?e.jsx("img",{src:he,alt:"",className:"max-h-full max-w-full object-contain",loading:"lazy",decoding:"async",referrerPolicy:"no-referrer"}):e.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-2 px-2 text-center",children:[e.jsx("p",{className:"text-[10px] font-semibold text-slate-400",children:"Sem imagem"}),W?e.jsxs(e.Fragment,{children:[e.jsxs("button",{type:"button",disabled:H,onClick:w=>{w.stopPropagation(),J.current?.click()},className:"inline-flex min-h-[36px] touch-manipulation items-center justify-center gap-1 rounded-lg border border-violet-200 bg-white px-2.5 py-1.5 text-[10px] font-bold text-violet-800 shadow-sm hover:bg-violet-50 disabled:opacity-60",children:[H?e.jsx(De,{className:"h-3.5 w-3.5 animate-spin","aria-hidden":!0}):e.jsx(As,{className:"h-3.5 w-3.5","aria-hidden":!0}),"Enviar foto"]}),e.jsx("input",{ref:J,type:"file",accept:"image/png,image/jpeg,image/webp,image/*",className:"sr-only",onChange:w=>{const le=w.target.files?.[0];w.target.value="",le&&W(le)}})]}):null]}),e.jsx("div",{className:"pointer-events-none absolute left-1 top-1 max-w-[calc(100%-2.5rem)]",children:e.jsx("span",{className:"inline-block truncate rounded bg-slate-950/75 px-1.5 py-0.5 text-[9px] font-bold uppercase tracking-wide text-white backdrop-blur-sm",children:u(String(s.platform||""))})}),z?e.jsx("button",{type:"button",disabled:se,onClick:w=>{w.stopPropagation(),z()},className:"absolute right-1 top-1 z-10 flex h-8 w-8 touch-manipulation items-center justify-center rounded-full border border-white/80 bg-white/95 shadow-sm outline-none focus-visible:ring-2 focus-visible:ring-rose-400 hover:bg-rose-50 disabled:opacity-60","aria-label":"Remover da galeria",title:"Remover",children:se?e.jsx(De,{className:"h-3.5 w-3.5 animate-spin text-rose-600","aria-hidden":!0}):e.jsx(Se,{className:"h-3.5 w-3.5 text-rose-600","aria-hidden":!0})}):null]}),e.jsxs("div",{className:Re("flex min-h-0 flex-1 flex-col gap-1.5 p-2",O&&"gap-2 p-3"),children:[e.jsx("p",{className:Re("line-clamp-2 font-black leading-tight text-slate-900",O?"min-h-0 text-sm line-clamp-3":"min-h-[2.25rem] text-[11px]"),children:ue}),e.jsxs("div",{className:Re("space-y-0.5 rounded-lg border border-violet-100 bg-violet-50/60 px-2 py-1.5",O&&"sm:flex sm:items-center sm:justify-between sm:gap-3 sm:space-y-0"),children:[e.jsx("p",{className:"text-[9px] font-black uppercase tracking-wide text-violet-600",children:"Preço"}),E?e.jsx("p",{className:"text-[10px] font-bold leading-snug text-violet-700",children:"Na Shopee após abrir o link â capture com a extensão"}):e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-sm font-black leading-none text-slate-900",children:n(s.currentPrice)}),s.originalPrice?e.jsx("p",{className:"text-[10px] font-semibold text-slate-400 line-through",children:n(s.originalPrice)}):null]})]}),E?e.jsxs("div",{className:"flex flex-col gap-1",children:[F?e.jsxs("a",{href:F,target:"_blank",rel:"noreferrer",className:"inline-flex h-8 touch-manipulation items-center justify-center gap-1 rounded-lg border border-orange-300 bg-white px-2 text-[10px] font-bold text-orange-900 hover:bg-orange-50",children:[e.jsx(Ja,{className:"h-3.5 w-3.5 shrink-0","aria-hidden":!0}),"Abrir"]}):null,ae?e.jsx(m,{type:"button",variant:"outline",size:"sm",className:"h-8 touch-manipulation rounded-lg border-orange-200 bg-orange-50/80 px-2 text-[10px] font-bold text-orange-900 hover:bg-orange-100",onClick:w=>{w.stopPropagation(),ae()},children:"Extensão"}):null]}):null,e.jsxs("div",{className:Re("rounded-lg border px-2 py-1.5",re?"border-emerald-100 bg-emerald-50/70":L?"border-amber-100 bg-amber-50/80":"border-emerald-100 bg-emerald-50/70",O&&"sm:flex sm:items-center sm:justify-between sm:gap-3"),children:[e.jsx("p",{className:Re("text-[9px] font-black uppercase tracking-wide",L&&!re?"text-amber-800":"text-emerald-700"),children:"Comissão"}),e.jsxs("p",{className:Re("text-[11px] font-bold leading-tight",L&&!re?"text-amber-900":"text-emerald-900"),children:[re?d(s.commissionPercent):L?"Validar na Shein":"â",A?e.jsx("span",{className:"mt-0.5 block text-[10px] font-semibold text-emerald-800",children:n(s.commissionAmount)}):null]})]}),e.jsxs("div",{className:Re("mt-auto flex gap-1",O&&"gap-2"),children:[e.jsx(m,{type:"button",variant:"outline",size:"sm","aria-label":f,title:f,onClick:w=>{w.stopPropagation(),h()},className:Re("group h-9 min-h-9 flex-1 touch-manipulation rounded-lg border-slate-200 bg-white px-0 shadow-none hover:bg-white disabled:opacity-50",O&&"min-h-[44px] flex-[1.2] sm:hidden"),children:e.jsx(Wa,{className:Re("h-4 w-4 shrink-0 text-slate-500 transition-colors group-active:text-violet-600",r&&"text-violet-600"),"aria-hidden":!0})}),O?e.jsx(m,{type:"button",variant:"outline",size:"sm",onClick:w=>{w.stopPropagation(),h()},className:"hidden min-h-[44px] flex-[1.2] touch-manipulation rounded-lg border-slate-200 bg-white text-xs font-bold text-slate-800 shadow-none hover:bg-slate-50 sm:inline-flex",children:f}):null,e.jsx(m,{type:"button",variant:"outline",size:"sm","aria-label":y,title:y,disabled:M,onClick:w=>{w.stopPropagation(),x()},className:Re("group h-9 min-h-9 flex-1 touch-manipulation rounded-lg border-slate-200 bg-white px-0 shadow-none hover:bg-white disabled:opacity-50",O&&"min-h-[44px] flex-[1.2] sm:hidden"),children:g==="schedule"?e.jsx(Fe,{className:"h-4 w-4 shrink-0 text-slate-500 transition-colors group-active:text-violet-600","aria-hidden":!0}):e.jsx(qt,{className:"h-4 w-4 shrink-0 text-slate-500 transition-colors group-active:text-violet-600","aria-hidden":!0})}),O?e.jsx(m,{type:"button",size:"sm",disabled:M,onClick:w=>{w.stopPropagation(),x()},className:"hidden min-h-[44px] flex-[1.4] touch-manipulation rounded-lg bg-violet-600 text-xs font-bold text-white hover:bg-violet-700 sm:inline-flex",children:y}):null]}),D?e.jsx("div",{className:"border-t border-slate-100 pt-1.5",onClick:w=>w.stopPropagation(),children:D}):null]})]})}const Cr="galeria-shopee-captura-shelf";
46function fe(...s){return s.filter(Boolean).join(" ")}function X({children:s}){return e.jsx("span",{className:"inline-flex items-center rounded-full border border-violet-200 bg-white px-3 py-1 text-xs font-semibold text-violet-700",children:s})}function Zl(s){const r=Number(s||0);return`${Math.round(r)}%`}function Wi({children:s,icon:r}){return e.jsxs("p",{className:"inline-flex items-center gap-2 text-xs font-black uppercase tracking-[0.22em] text-slate-500",children:[r,s]})}function ec(s){const{sectionRef:r,categoryPanelRef:n,stores:u,visible:d,state:h,actions:x,helpers:g,personalMiningResultsRef:M}=s,f=x.clearPersonalSelection,{personalSelectedPlatforms:y,personalSelectedCategories:D,personalSearch:E,personalCategoriesOpen:F,personalCategorySummary:ae,personalCategorySearch:z,personalCatCustomDraft:se="",selectedPersonalCustomCategories:_=[],canAddPersonalSearchAsCategory:W=!1,maxCategoryNameLen:H=80,filteredCategories:O,personalLimit:ue,personalAvoidLowQuality:$,startPersonalMiningPending:re,appliedPersonalScope:A,filteredPersonalMiningOffers:L,personalResultsSelectedCount:he,selectedCartIds:J,resultAvailablePlatforms:w,resultSelectedPlatforms:le,resultAvailableCategories:T,resultSelectedCategories:ce,resultSortMode:k="menorPreco",resultMinCommissionPercent:ee=0,resultMinPrice:$e="",resultMaxPrice:xe="",resultMinDiscountPercent:K=0,showResultFilters:nt,personalMiningLoading:te,personalMiningTotalCount:Pe=0,personalSelectedOfferIds:I,personalSelectedOfferIdSet:ze,resultSearch:xa,communityPremiumUnlocked:ge=!0,canRunLiveMining:Bt=!1}=h,yt=g?.formatCommissionPercent||g?.safeFormatCommissionPercent||g?.formatPercent||Zl,lt=g.formatPlatformName,[Ka,kt]=o.useState(!1),[Ct,pa]=o.useState(!1),[de,ct]=o.useState("all"),Ke=L.reduce((l,S)=>l+Number(S.commissionAmount||0),0),St=L.reduce((l,S)=>Math.max(l,Number(S.commissionPercent||0)),0),ba=y.length>0||D.length>0||!!E.trim(),we=!!A,ga=!te&&(ba||we||Pe>0),qe=ze??new Set(I.map(l=>Number(l))),Ye=o.useMemo(()=>L.filter(l=>Qa(l)),[L]),pe=o.useMemo(()=>L.filter(l=>!Qa(l)),[L]),dt=o.useMemo(()=>de==="shopee"?[]:pe,[de,pe]),Be=o.useMemo(()=>de==="catalog"?[]:Ye,[de,Ye]),Pt=o.useMemo(()=>Fl(dt),[dt]),me=o.useMemo(()=>Nr(Be),[Be]);o.useEffect(()=>{if(de==="shopee"&&Ye.length===0){ct(pe.length>0?"catalog":"all");return}de==="catalog"&&pe.length===0&&ct(Ye.length>0?"shopee":"all")},[de,Ye.length,pe.length]),o.useEffect(()=>{ce.some(S=>Cs(S))&&de==="shopee"&&ct(pe.length>0?"catalog":"all")},[ce,de,pe.length]);const Me=()=>{x.goToBiblioteca?.(),window.setTimeout(()=>{document.getElementById("extension-capture")?.scrollIntoView({behavior:"smooth",block:"start"})},150)},fa=Number(h.gallerySavedCount??0);function Vt(l,S){return e.jsx(Pr,{offer:{...l,currentPrice:g.parseFlexibleMoneyValue(l.currentPrice)??0,originalPrice:g.parseFlexibleMoneyValue(l.originalPrice)??0,discountPercent:Number(l.discountPercent||0),commissionPercent:l.commissionPercent,commissionAmount:g.parseFlexibleMoneyValue(l.commissionAmount)??0,commissionSourceLabel:l.commissionSourceLabel||null},selected:qe.has(Number(l.id)),onToggle:x.togglePersonalOffer,formatCurrency:g.formatCurrency,formatPercent:g.formatPercent,cn:fe,extension:Mt(l)},l.id)}function va(l,S,U,At){return S.length?e.jsxs("div",{id:At,className:"col-span-full space-y-4",children:[e.jsxs("div",{className:"flex items-end justify-between gap-2 border-b border-violet-100 pb-2",children:[e.jsx("h4",{className:"text-base font-black tracking-tight text-slate-900",children:l}),e.jsxs("span",{className:"shrink-0 text-xs font-semibold text-violet-600",children:[S.length," oferta(s)"]})]}),e.jsx("div",{className:"grid gap-3.5 sm:gap-4 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5 2xl:grid-cols-6",children:S.map(Na=>Vt(Na))})]},`${U}-${l}`):null}function Mt(l){const S=Ms(l);return e.jsxs("div",{className:"space-y-3",children:[Qa(l)?e.jsxs("div",{className:"rounded-xl border border-orange-200 bg-orange-50/90 p-3 text-left",children:[e.jsx("p",{className:"text-[10px] font-black uppercase tracking-[0.16em] text-orange-600",children:"Campanha Shopee (API)"}),e.jsx("p",{className:"mt-1 text-xs font-semibold text-orange-950",children:"Abra na Shopee, capture com a extensão e importe. Os itens com preço passam para a grade geral; estes cartões deixam de ser «só campanha»."}),e.jsxs("div",{className:"mt-2 flex flex-wrap gap-2",children:[S?e.jsx(m,{asChild:!0,variant:"outline",className:"h-9 min-h-9 flex-1 touch-manipulation rounded-xl border-orange-300 bg-white text-orange-900 hover:bg-orange-50",children:e.jsxs("a",{href:S,target:"_blank",rel:"noreferrer",className:"inline-flex items-center justify-center gap-1",children:[e.jsx(Ja,{className:"h-4 w-4 shrink-0","aria-hidden":!0}),"Abrir campanha"]})}):null,e.jsx(m,{type:"button",variant:"outline",className:"h-9 min-h-9 flex-1 touch-manipulation rounded-xl border-orange-300 bg-white text-orange-900 hover:bg-orange-50",onClick:Me,children:"Extensão / importar"})]})]}):null,e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"rounded-[14px] border border-emerald-100 bg-emerald-50/70 px-3 py-2.5",children:[e.jsx("p",{className:"text-[10px] font-black uppercase tracking-[0.18em] text-emerald-700",children:"Comissão"}),e.jsx("p",{className:"mt-1 text-sm font-black text-slate-900",children:yt(l.commissionPercent)}),l.commissionSourceLabel?e.jsx("p",{className:"mt-1 text-[10px] leading-snug text-slate-600",children:l.commissionSourceLabel}):null]}),e.jsxs("div",{className:"rounded-[14px] border border-violet-100 bg-violet-50/60 px-3 py-2.5",children:[e.jsx("p",{className:"text-[10px] font-black uppercase tracking-[0.18em] text-violet-700",children:"Estimativa por venda"}),e.jsx("p",{className:"mt-1 text-sm font-black text-slate-900",children:g.formatCurrency(l.commissionAmount)}),e.jsx("p",{className:"mt-1 text-[10px] text-slate-500",children:"Ajuda a priorizar o que compensa postar."})]})]}),e.jsxs(m,{variant:"outline",onClick:()=>x.addOfferToCart(l.id),disabled:!ge,className:"group h-10 w-full rounded-xl border-slate-200 bg-white text-slate-700 shadow-none hover:bg-white disabled:opacity-50",children:[e.jsx(qt,{className:"mr-2 h-4 w-4 text-slate-500 transition-colors group-active:text-violet-600"}),"Adicionar ao carrinho"]})]})}const ja=o.useMemo(()=>
46{if(y.length===0)return"Plataformas â toque para escolher";if(y.length===1)return lt(y[0]);const l=y.slice(0,2).map(U=>lt(U)),S=y.length>2?` +${y.length-2}`:"";return`${l.join(" · ")}${S}`},[y,lt]);return e.jsxs("div",{ref:r,className:fe("space-y-4 md:space-y-6",!d&&"hidden"),children:[e.jsxs("section",{className:"overflow-hidden rounded-2xl border border-violet-100 bg-white shadow-sm",children:[e.jsxs("div",{className:"sticky top-0 z-[22] border-b border-violet-100/90 bg-white/95 px-2 py-2 backdrop-blur-md md:px-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("div",{className:"hidden shrink-0 md:block",children:e.jsx("p",{className:"text-[10px] font-black uppercase tracking-[0.2em] text-violet-500",children:"Explorar vitrine"})}),e.jsx("div",{className:"md:hidden",children:e.jsxs(Dt,{modal:!1,children:[e.jsx(Ft,{asChild:!0,children:e.jsxs("button",{type:"button",className:"flex h-10 min-h-10 max-w-[11rem] shrink-0 touch-manipulation items-center justify-between gap-2 rounded-xl border border-violet-200 bg-white px-2.5 py-2 text-left text-xs font-bold text-slate-800 shadow-sm outline-none ring-violet-400 focus-visible:ring-2",children:[e.jsx("span",{className:"min-w-0 truncate",children:ja}),e.jsx(Ce,{className:"h-4 w-4 shrink-0 text-violet-600","aria-hidden":!0})]})}),e.jsx($t,{align:"start",className:"z-[80] max-h-[min(70vh,360px)] w-[min(calc(100vw-2rem),22rem)] overflow-y-auto p-1",children:u.map(l=>e.jsx(nl,{className:"touch-manipulation",checked:y.includes(l),onCheckedChange:()=>x.togglePersonalPlatform(l),onSelect:S=>S.preventDefault(),children:g.formatPlatformName(l)},l))})]})}),e.jsx("div",{className:"hidden flex-wrap gap-1.5 md:flex",children:u.map(l=>{const S=y.includes(l);return e.jsx("button",{type:"button",onClick:()=>x.togglePersonalPlatform(l),className:fe("touch-manipulation rounded-lg border px-2.5 py-1.5 text-[11px] font-bold transition-all md:px-3 md:py-2 md:text-xs",S?"border-violet-500 bg-violet-600 text-white shadow-sm":"border-slate-200 bg-slate-50 text-slate-600 hover:border-violet-200 hover:bg-violet-50"),children:g.formatPlatformName(l)},l)})}),e.jsxs("div",{className:"relative min-w-0 flex-1 basis-[11rem]",children:[e.jsx(it,{className:"pointer-events-none absolute left-2.5 top-1/2 z-0 h-4 w-4 -translate-y-1/2 text-violet-300","aria-hidden":!0}),e.jsx(oe,{id:"personal-search-keyword-toolbar",type:"search",inputMode:"search",enterKeyHint:"search",autoComplete:"off",autoCapitalize:"none",autoCorrect:"off",spellCheck:!1,placeholder:"Palavra-chaveâ¦",className:"relative z-[1] h-10 w-full min-w-0 rounded-xl border-violet-100 bg-violet-50/60 pl-9 text-sm touch-manipulation",value:E,onChange:l=>x.setPersonalSearch(l.target.value)})]}),e.jsxs(m,{type:"button",variant:"outline",size:"sm",onClick:()=>pa(!0),className:"h-10 shrink-0 touch-manipulation gap-1 rounded-xl px-3 text-xs font-bold md:text-sm","aria-expanded":Ct,"aria-controls":"galeria-pers
46onal-scope-sheet",children:["Categorias · rodada",e.jsx(Ce,{className:"h-4 w-4 opacity-80","aria-hidden":!0})]}),e.jsxs("span",{className:"hidden tabular-nums text-[11px] font-bold text-slate-500 sm:inline",children:[D.length," cat. · ",ue,"/rodada"]})]}),ge?Bt?null:e.jsx("p",{className:"mt-1.5 text-[11px] leading-snug text-slate-600 md:text-xs",children:"Mineração ao vivo: só administrador. Aqui você filtra o pool já salvo."}):e.jsxs("p",{className:"mt-1.5 text-[11px] font-semibold leading-snug text-amber-800 md:text-xs",children:["Catálogo visÃvel para todos. Carrinho e importação exigem"," ",e.jsx("span",{className:"font-black",children:"Elite"}),"."]})]}),e.jsx(na,{open:Ct,onOpenChange:pa,children:e.jsxs(la,{id:"galeria-personal-scope-sheet",side:"bottom",className:"z-[90] flex max-h-[min(92dvh,880px)] flex-col gap-0 overflow-hidden rounded-t-2xl border-violet-100 p-0 pt-2 shadow-2xl md:inset-y-4 md:left-auto md:right-4 md:top-4 md:max-h-[calc(100vh-2rem)] md:max-w-lg md:rounded-2xl md:border",children:[e.jsxs(ca,{className:"space-y-1 border-b border-violet-100 px-4 pb-3 pt-1 text-left",children:[e.jsx(da,{className:"text-lg font-black text-slate-900",children:"Categorias e mineração"}),e.jsx(ma,{className:"text-sm leading-snug text-slate-600",children:"Palavra-chave permanece na barra acima. Ajuste categorias, limite e rode mineração (admin)."})]}),e.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto overscroll-y-contain px-4 py-3 pb-[max(1rem,env(safe-area-inset-bottom))]",children:e.jsxs("div",{className:"space-y-4 px-4 pb-[calc(1rem+env(safe-area-inset-bottom,0px))] pt-4 md:p-0 md:pt-0",children:[e.jsx("p",{className:"rounded-lg border border-dashed border-violet-200 bg-violet-50/50 px-3 py-2 text-[11px] leading-snug text-slate-600 md:hidden",children:"Para trocar de loja, feche e use o seletor de plataformas no topo (fora deste painel)."}),e.jsxs("div",{className:"hidden space-y-3 md:block",children:[e.jsx(Wi,{icon:e.jsx(Wa,{className:"h-4 w-4"}),children:"Plataformas"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:u.map(l=>{const S=y.includes(l);return e.jsx("button",{type:"button",onClick:()=>x.togglePersonalPlatform(l),className:fe("rounded-xl border px-3 py-2 text-xs font-bold transition-all",S?"border-violet-500 bg-violet-600 text-white shadow-sm":"border-slate-200 bg-slate-50 text-slate-600 hover:border-violet-200 hover:bg-violet-50"),children:g.formatPlatformName(l)},l)})})]}),e.jsxs("div",{className:"space-y-2 md:hidden",children:[e.jsx("label",{className:"block text-[10px] font-black uppercase tracking-[0.18em] text-violet-500",children:"Categorias"}),e.jsx("p",{className:"text-[11px] text-slate-500",children:D.length>0?`${D.length} marcada(s)`:"Toque na grelha abaixo para marcar"}),e.jsxs("div",{className:"relative isolate",children:[e.jsx(it,{className:"pointer-events-none absolute left-3 top-1/2 z-0 h-4 w-4 -translate-y-1/2 text-violet-300","aria-hidden":!0}),e.jsx(oe,{id:"personal-category-filter-mobile",type:"text",autoComplete:"off",autoCapitalize:"none",autoCorrect:"off",spellCheck:!1,value:z,onChange:l=>x.setPersonalCategorySearch(l.target.value),placeholder:"Filtrar categorias...",className:"relative z-[1] h-10 touch-manipulation rounded-xl border-violet-100 bg-violet-50/60 pl-10 text-sm"})]}),e.jsx("div",{className:"max-h-[min(42vh,280px)] overflow-y-auto overflow-x-hidden rounded-xl border border-violet-100 bg-white p-2",children:e.jsx("div",{className:"grid grid-cols-2 gap-2",children:O.length>0?O.map(l=>{const S=D.includes(l);return e.jsx("button",{type:"button",onClick:()=>x.togglePersonalCategory(l),className:fe("min-h-[42px] touch-manipulation rounded-xl border px-2 py-2 text-left text-[11px] font-semibold leading-snug transition-all",S?"border-violet-500 bg-violet-50 text-violet-700 ring-1 ring-violet-200":"border-slate-200 bg-white text-slate-700 hover:border-violet-200 hover:bg-violet-50"),children:l},l)}):e.jsx("div",{className:"col-span-full w-full space-y-2 rounded-lg border border-dashed border-violet-200 bg-violet-50/60 p-3 text-xs font-semibold text-slate-600",children:W?e.jsxs(e.Fragment,{children:[e.jsx("p",{children:"Nenhuma sugestão com esse termo."}),e.jsxs(m,{type:"button",size:"sm",variant:"secondary",onClick:x.addPersonalSearchTermAsCategory,className:"h-8 rounded-lg font-bold",children:[e.jsx(gs,{className:"mr-1 h-3.5 w-3.5"}),"Incluir «",String(z).trim(),"»"]})]}):e.jsx("p",{children:'Nenhuma categoria encontrada. Ajuste o filtro ou use "Outra" abaixo.'})})})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(oe,{value:se,onChange:l=>x.setPersonalCatCustomDraft(l.target.value),onKeyDown:l=>{l.key==="Enter"&&(l.preventDefault(),x.addPersonalCustomCategory())},maxLength:H,placeholder:"Outra categoriaâ¦",className:"h-9 flex-1 rounded-xl border-violet-100 bg-white text-sm"}),e.jsx(m,{type:"button",variant:"secondary",onClick:x.addPersonalCustomCategory,className:"h-9 shrink-0 rounded-xl px-3 font-bold","aria-label":"Incluir categoria personalizada",children:e.jsx(gs,{className:"h-4 w-4"})})]}),_.length>0?e.jsx("div",{className:"flex flex-wrap gap-1.5",children:_.map(l=>e.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full border border-violet-300 bg-vi
46olet-50 px-2 py-0.5 text-[11px] font-semibold text-violet-800",children:[l,e.jsx("button",{type:"button",onClick:()=>x.removePersonalCustomCategory(l),className:"rounded p-0.5 text-slate-400 hover:text-rose-600",title:"Remover",children:e.jsx(Se,{className:"h-3 w-3"})})]},l))}):null,e.jsx(m,{variant:"outline",onClick:x.clearCategories,className:"h-9 w-full rounded-xl border-violet-200 bg-white text-xs font-bold text-violet-700 hover:bg-violet-50",children:"Limpar categorias"})]}),e.jsxs("div",{ref:n,className:"hidden space-y-3 md:block",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx(Wi,{icon:e.jsx(Ce,{className:"h-4 w-4"}),children:"Categorias"}),e.jsxs("button",{type:"button",onClick:x.toggleCategoriesOpen,className:"inline-flex items-center gap-2 rounded-full border border-violet-200 bg-violet-50 px-3 py-1.5 text-[11px] font-bold text-violet-700 transition hover:bg-violet-100",children:[D.length>0?`${D.length} selecionada(s)`:"Escolher",e.jsx(Ce,{className:fe("h-4 w-4 transition-transform",F&&"rotate-180")})]})]}),e.jsxs("button",{type:"button",onClick:x.toggleCategoriesOpen,className:fe("flex w-full items-center justify-between rounded-[18px] border px-4 py-3 text-left transition-all",F?"border-violet-300 bg-violet-50 shadow-sm":"border-violet-100 bg-slate-50 hover:border-violet-200 hover:bg-violet-50"),children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-black uppercase tracking-[0.18em] text-violet-500",children:"Seletor inteligente"}),e.jsx("p",{className:"mt-1 text-sm font-semibold text-slate-700",children:ae})]}),e.jsx("div",{className:"rounded-full bg-white p-2 text-violet-500 shadow-sm",children:e.jsx(it,{className:"h-4 w-4"})})]}),F?e.jsx("div",{className:"rounded-[24px] border border-violet-200 bg-white p-4 shadow-[0_24px_80px_rgba(91,33,182,0.12)]",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"relative isolate",children:[e.jsx(it,{className:"pointer-events-none absolute left-3 top-1/2 z-0 h-4 w-4 -translate-y-1/2 text-violet-300","aria-hidden":!0}),e.jsx(oe,{value:z,onChange:l=>x.setPersonalCategorySearch(l.target.value),placeholder:"Buscar categoria...",className:"relative z-[1] h-10 touch-manipulation rounded-xl border-violet-100 bg-violet-50/60 pl-10"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-[10px] font-black uppercase tracking-[0.12em] text-slate-500",children:"Sua categoria (não está na lista)"}),e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row",children:[e.jsx(oe,{value:se,onChange:l=>x.setPersonalCatCustomDraft(l.target.value),onKeyDown:l=>{l.key==="Enter"&&(l.preventDefault(),x.addPersonalCustomCategory())},maxLength:H,placeholder:"Ex.: Colecionáveis, nicho regionalâ¦",className:"h-10 flex-1 rounded-xl border-violet-100 bg-white"}),e.jsxs(m,{type:"button",variant:"secondary",onClick:x.addPersonalCustomCategory,className:"h-10 shrink-0 rounded-xl font-bold",children:[e.jsx(gs,{className:"mr-1.5 h-4 w-4"}),"Incluir"]})]}),e.jsxs("p",{className:"text-xs leading-relaxed text-slate-500",children:["Máx. ",H," caracteres. Se o nome bater com uma categoria padrão, o chip é unificado."]}),_.length>0?e.jsxs("div",{className:"flex flex-wrap items-center gap-2 rounded-xl border border-dashed border-violet-200 bg-violet-50/50 p-2",children:[e.jsx("span",{className:"text-[10px] font-bold uppercase text-violet-600",children:"Personalizadas"}),_.map(l=>e.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full border border-violet-300 bg-white px-2.5 py-0.5 text-[11px] font-semibold text-violet-800",children:[l,e.jsx("button",{type:"button",onClick:()=>x.removePersonalCustomCategory(l),className:"rounded p-0.5 text-slate-400 hover:text-rose-600",title:"Remover",children:e.jsx(Se,{className:"h-3.5 w-3.5"})})]},l))]}):null]}),e.jsx("div",{className:"max-h-[min(52vh,400px)] overflow-y-auto overflow-x-hidden pr-1 md:max-h-[240px]",children:e.jsx("div",{className:"grid grid-cols-2 gap-2 sm:grid-cols-3",children:O.length>0?O.map(l=>{const S=D.includes(l);return e.jsx("button",{type:"button",onClick:()=>x.togglePersonalCategory(l),className:fe("min-h-[42px] touch-manipulation rounded-xl border px-2.5 py-2 text-left text-[11px] font-semibold leading-snug transition-all",S?"border-violet-500 bg-violet-50 text-violet-700 ring-1 ring-violet-200":"border-slate-200 bg-white text-slate-700 hover:border-violet-200 hover:bg-violet-50"),children:l},l)}):e.jsx("div",{className:"col-span-full w-full space-y-2 rounded-[16px] border border-dashed border-violet-200 bg-vi
46olet-50/60 p-4 text-sm font-semibold text-slate-600",children:W?e.jsxs(e.Fragment,{children:[e.jsx("p",{children:"Nenhuma sugestão com esse termo. Você pode incluir a busca como categoria personalizada."}),e.jsxs(m,{type:"button",size:"sm",variant:"secondary",onClick:x.addPersonalSearchTermAsCategory,className:"h-8 rounded-lg font-bold",children:[e.jsx(gs,{className:"mr-1 h-3.5 w-3.5"}),"Incluir «",String(z).trim(),"»"]})]}):e.jsx("p",{children:'Nenhuma categoria encontrada. Digite um termo, use o campo "Sua categoria" ou escolha na lista padrão.'})})})}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(m,{variant:"outline",onClick:x.clearCategories,className:"h-10 rounded-xl border-violet-200 bg-white text-violet-700 hover:bg-violet-50",children:"Limpar"}),e.jsx(m,{onClick:x.closeCategories,className:"h-10 rounded-xl bg-violet-600 text-white hover:bg-violet-700",children:"Aplicar"})]})]})}):null]}),e.jsxs("div",{className:"grid grid-cols-1 gap-3 md:grid-cols-2",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"mb-2 block text-[10px] font-black uppercase tracking-[0.18em] text-violet-500",children:[e.jsx("span",{className:"md:hidden",children:"Qtd. por rodada"}),e.jsx("span",{className:"hidden md:inline",children:"Quantidade por pesquisa"})]}),e.jsx(oe,{type:"number",min:1,max:100,value:ue,onChange:l=>x.setPersonalLimit(Number(l.target.value||12)),className:"h-10 rounded-xl border-violet-100 bg-violet-50/60 md:h-11"})]}),e.jsx("div",{className:"rounded-xl border border-violet-100 bg-violet-50/50 px-3 py-2.5 md:px-4 md:py-3",children:e.jsxs("label",{className:"flex cursor-pointer items-start gap-3",children:[e.jsx("input",{type:"checkbox",checked:$,onChange:l=>x.setPersonalAvoidLowQuality(l.target.checked),className:"mt-1 h-4 w-4 rounded border-violet-300"}),e.jsx("span",{className:"text-xs font-semibold leading-snug text-slate-700 md:text-sm",children:"Evitar baixa qualidade"})]})})]}),e.jsxs(m,{onClick:x.handleRunPersonalMining,disabled:re||!Bt,className:"h-11 w-full rounded-xl bg-violet-600 text-white hover:bg-violet-700 disabled:opacity-60",children:[e.jsx(Jn,{className:fe("mr-2 h-4 w-4",re&&"animate-spin")}),re?"Minerando...":Bt?"Minerar ao vivo (admin)":"Mineração ao vivo: somente administrador"]})]})})]})})]}),ga?e.jsxs(e.Fragment,{children:[L.length>0?e.jsx("section",{className:"sticky top-[88px] z-20 mb-4 hidden rounded-[18px] border border-violet-200/70 bg-white/95 p-2 shadow-sm backdrop-blur-xl sm:p-3 md:block",children:e.jsxs("div",{className:"flex flex-col gap-2 xl:flex-row xl:items-center xl:justify-between",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs(X,{children:[L.length," no resultado"]}),e.jsxs(X,{children:[I.length," na seleção"]}),e.jsx("div",{className:"hidden flex-wrap items-center gap-2 xl:flex",children:e.jsxs(X,{children:[J.length," no carrinho"]})})]}),e.jsxs("div",{className:"hidden flex-wrap gap-2 xl:flex",children:[e.jsxs(m,{variant:"outline",onClick:x.selectAllPersonalResults,className:"h-9 rounded-xl border-violet-200 bg-white px-3 text-violet-700 hover:bg-violet-50",children:[e.jsx(Ne,{className:"h-4 w-4 shrink-0 xl:mr-2","aria-hidden":!0}),e.jsx("span",{className:"hidden xl:inline",children:"Marcar resultados"})]}),e.jsxs(m,{variant:"outline",onClick:()=>f?.(),disabled:I.length===0,className:"h-9 rounded-xl border-violet-200 bg-white px-3 text-violet-700 hover:bg-violet-50 disabled:opacity-50",children:[e.jsx(Se,{className:"h-4 w-4 shrink-0 xl:mr-2","aria-hidden":!0}),e.jsx("span",{className:"hidden xl:inline",children:"Limpar seleção"})]})]})]})}):null,e.jsxs("section",{ref:M,id:"personal-mining-results",className:"rounded-[24px] border border-violet-100 bg-white p-4 shadow-sm md:p-5",children:[e.jsxs("div",{className:"mb-4 rounded-2xl border border-violet-200 bg-violet-50/90 px-4 py-3 text-sm leading-relaxed text-violet-950",children:[e.jsxs("p",{children:[e.jsx("span",{className:"font-bold",children:"Pesquisar"})," mostra o catálogo da vitrine (importações Shopee entram aqui). Para"," ",e.jsx("span",{className:"font-bold",children:"excluir com (Ã)"})," ou"," ",e.jsx("span",{className:"font-bold",children:"limpar toda a galeria"}),", abra a aba"," ",typeof x.goToBiblioteca=="function"?e.jsx("button",{type:"button",className:"font-bold text-violet-800 underline underline-offset-2 touch-manipulation",onClick:x.goToBiblioteca,children:"Galeria de Ofertas"}):e.jsx("strong",{children:"Galeria de Ofertas"}),fa>0?` â você tem ${fa} oferta(s) salva(s) lá.`:" â ofertas que você salvou na biblioteca."]}),Pt.length>1?e.jsx("p",{className:"mt-1.5 text-xs font-medium text-violet-800/90",children:"Capturas Shopee aparecem em blocos por categoria (mobile: deslize; desktop: seções abaixo)."}):null]}),e.jsxs("div",{className:"space-y-3 md:hidden",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-[10px] font-black uppercase tracking-[0.22em] text-violet-500",children:we?"Resultado da pesquisa":"Ofertas do catálogo"}),e.jsxs("p",{className:"mt-0.5 text-sm font-black text-slate-900",children:[L.length," oferta(s) · ",he," ","marcada(s)"]})]}),e.jsxs(Dt,{modal:!1,children:[e.jsx(Ft,{asChild:!0,children:e.jsxs(m,{type:"button",variant:"outline",size:"sm",className:"h-10 shrink-0 touch-manipulation gap-1.5 rounded-xl border-violet-200 bg-white px-3",children:[e.jsx(mo,{className:"h-4 w-4","aria-hidden":!0}),"Informações",e.jsx(Ce,{className:"h-3.5 w-3.5 opacity-80","aria-hidden":!0})]})}),e.jsxs($t,{align:"end",sideOffset:6,className:"z-[80] max-h-[min(72vh,480px)] w-[min(calc(100vw-1.5rem),20rem)] overflow-y-auto p-3",children:[e.jsx("p",{className:"text-[10px] font-black uppercase tracking-[0.18em] text-violet-500",children:we?"Resultado da pesquisa":"Ofertas do catálogo"}),e.jsx("p",{className:"mt-1 text-sm font-black leading-snug text-slate-900",children:we?"Somente o que você pesquisou":"Lista carregada para explorar"}),e.jsx("p",{className:"mt-2 text-xs leading-relaxed text-slate-600",children:we?"Revise, priorize por comissão e leve para o carrinho só o que vale a operação.":"Ofertas do pool da vitrine (até 500) com os filtros atuais de plataforma, categoria e busca â dados já armazenados no servidor."}),e.jsx(ks,{className:"my-3"}),e.jsx("p",{className:"text-[10px] font-black uppercase tracking-[0.18em] text-slate-500",children:"Resumo"}),e.jsxs("div",{className:"mt-2 flex flex-wrap gap-1.5",children:[e.jsxs(X,{children:[L.length," resultado(s)"]}),e.jsxs(X,{children:[he," marcada(s)"]}),e.jsxs(X,{children:[J.length," no carrinho"]}),e.jsxs(X,{children:["Potencial ",g.formatCurrency(Ke)]}),e.jsxs(X,{children:["Melhor comissão ",yt(St)]}),we&&A?e.jsxs(e.Fragment,{children:[A.search?.trim()?e.jsxs(X,{children:["Busca: ",A.search.trim()]}):null,A.platforms?.length?e.jsxs(X,{children:[A.platforms.length," plataforma(s)"]}):null,A.categories?.length?e.jsxs(X,{children:[A.categories.length," categoria(s)"]}):null]}):e.jsx(X,{children:"Recorte completo: minerar acima"})]})]})]})]}),e.jsxs("div",{className:"flex gap-2 overflow-x-auto pb-0.5 [-webkit-overflow-scrolling:touch]",children:[e.jsxs(m,{variant:"outline",onClick:x.selectAllPersonalResults,className:"h-10 shrink-0 touch-manipulation rounded-xl border-violet-200 bg-white px-3 text-violet-700 hover:bg-violet-50",children:[e.jsx(Ne,{className:"mr-1.5 h-4 w-4","aria-hidden":!0}),"Marcar"]}),e.jsxs(m,{onClick:x.addSelectedResultsToCart,disabled:I.length===0||!ge,className:"h-10 shrink-0 touch-manipulation rounded-xl bg-violet-600 px-3 text-white hover:bg-violet-700 disabled:opacity-50",children:[e.jsx(Qi,{className:"mr-1.5 h-4 w-4","aria-hidden":!0}),"Carrinho"]}),e.jsx(m,{variant:"outline",onClick:x.goToCart,className:"h-10 shrink-0 touch-manipulation rounded-xl border-violet-200 bg-white px-3 text-violet-700 hover:bg-violet-50",children:"Ver carrinho"})]})]}),e.jsxs("div",{className:"hidden flex-col gap-4 xl:flex-row xl:items-center xl:justify-between md:flex",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs font-black uppercase tracking-[0.22em] text-violet-500",children:we?"Resultado da pesquisa":"Ofertas do catálogo"}),e.jsx("h3",{className:"text-xl font-black tracking-tight text-slate-900",children:we?"Somente o que você pesquisou":"Lista carregada para explorar"}),e.jsx("p",{className:"text-sm leading-6 text-slate-500",children:we?"Revise, priorize por comissão e leve para o carrinho só o que vale a operação.":"Ofertas do pool da vitrine (até 500) com os filtros atuais de plataforma, categoria e busca â dados já armazenados no servidor."})]}),e.jsxs("div",{className:"flex w-full flex-col gap-2 sm:flex-row xl:w-auto",children:[e.jsxs(m,{variant:"outline",onClick:x.selectAllPersonalResults,className:"h-10 rounded-xl border-violet-200 bg-white text-violet-700 hover:bg-violet-50",children:[e.jsx(Ne,{className:"mr-2 h-4 w-4"}),"Marcar resultados"]}),e.jsxs(m,{onClick:x.addSelectedResultsToCart,disabled:I.length===0||!ge,className:"h-10 rounded-xl bg-violet-600 text-white hover:bg-violet-700",children:[e.jsx(Qi,{className:"mr-2 h-4 w-4"}),"Adicionar ao carrinho"]}),e.jsx(m,{variant:"outline",onClick:x.goToCart,className:"h-10 rounded-xl border-violet-200 bg-white text-violet-700 hover:bg-violet-50",children:"Ver carrinho"})]})]}),e.jsxs("div",{className:"mt-4 hidden flex-wrap gap-2 md:flex",children:[e.jsxs(X,{children:[L.length," resultado(s)"]}),e.jsxs(X,{children:[he," marcada(s)"]}),e.jsxs(X,{children:[J.length," no carrinho"]}),e.jsxs(X,{children:["Potencial ",g.formatCurrency(Ke)]}),e.jsxs(X,{children:["Melhor comissão ",yt(St)]}),we&&A?e.jsxs(e.Fragment,{children:[A.search?.trim()?e.jsxs(X,{children:["Busca: ",A.search.trim()]}):null,A.platforms?.length?e.jsxs(X,{children:[A.platforms.length," plataforma(s)"]}):null,A.categories?.length?e.jsxs(X,{children:[A.categories.length," categoria(s)"]}):null]}):e.jsx(X,{children:"Recorte completo: minerar acima"})]}),e.jsxs("div",{className:"mt-4 rounded-[20px] border border-violet-100 bg-violet-50/40 p-4",children:[e.jsxs("div",{className:"flex flex-col gap-3 md:flex-row md:items-center md:justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-black uppercase tracking-[0.18em] text-violet-500",children:"Filtros da mineração"}),e.jsx("p",{className:"mt-1 hidden text-sm text-slate-600 md:block",children:"Agora você pode priorizar por c
46ategoria, preço, desconto e comissão estimada/real."})]}),e.jsxs("button",{type:"button",onClick:()=>kt(!0),className:"inline-flex min-h-11 touch-manipulation items-center justify-center gap-2 rounded-full border border-violet-200 bg-white px-3 py-2 text-xs font-bold text-violet-700 transition hover:bg-violet-50 md:hidden",children:["Filtros",e.jsx(Ce,{className:"h-4 w-4"})]}),e.jsxs("button",{type:"button",onClick:x.onToggleResultFilters,className:"hidden items-center gap-2 rounded-full border border-violet-200 bg-white px-3 py-2 text-xs font-bold text-violet-700 transition hover:bg-violet-50 md:inline-flex",children:[nt?"Recolher filtros":"Expandir filtros",e.jsx(Ce,{className:fe("h-4 w-4 transition-transform",nt&&"rotate-180")})]})]}),nt?e.jsxs("div",{className:"mt-4 hidden space-y-4 md:block",children:[e.jsxs("div",{className:"relative isolate",children:[e.jsx(it,{className:"pointer-events-none absolute left-3 top-1/2 z-0 h-4 w-4 -translate-y-1/2 text-violet-300","aria-hidden":!0}),e.jsx(oe,{id:"personal-results-filter",type:"search",autoComplete:"off",autoCapitalize:"none",autoCorrect:"off",spellCheck:!1,placeholder:"Filtrar o resultado por nome, categoria ou plataforma...",className:"relative z-[1] h-10 touch-manipulation rounded-xl border-violet-100 bg-white pl-10",value:xa,onChange:l=>x.setResultSearch(l.target.value)})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsxs("div",{children:[e.jsx("label",{className:"mb-2 block text-[10px] font-black uppercase tracking-[0.18em] text-violet-500",children:"Ordenar resultado"}),e.jsxs("select",{value:k,onChange:l=>x.setResultSortMode(l.target.value),className:"h-10 w-full rounded-xl border border-violet-100 bg-white px-3 text-sm font-semibold text-slate-700 outline-none",children:[e.jsx("option",{value:"maiorComissaoValor",children:"Maior comissão em R$"}),e.jsx("option",{value:"maiorComissaoPercentual",children:"Maior comissão %"}),e.jsx("option",{value:"maiorDesconto",children:"Maior desconto"}),e.jsx("option",{value:"menorDesconto",children:"Menor desconto"}),e.jsx("option",{value:"menorPreco",children:"Menor preço"}),e.jsx("option",{value:"maiorPreco",children:"Maior preço"}),e.jsx("option",{value:"recentes",children:"Mais recentes"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-2 block text-[10px] font-black uppercase tracking-[0.18em] text-violet-500",children:"Comissão mÃnima"}),e.jsx("select",{value:ee,onChange:l=>x.setResultMinCommissionPercent(Number(l.target.value)),className:"h-10 w-full rounded-xl border border-violet-100 bg-white px-3 text-sm font-semibold text-slate-700 outline-none",children:[0,4,6,8,10,12,15,20].map(l=>e.jsx("option",{value:l,children:l===0?"Todas as comissões":`${l}% ou mais`},l))})]})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"mb-2 block text-[10px] font-black uppercase tracking-[0.18em] text-violet-500",children:"Preço mÃn. (R$)"}),e.jsx(oe,{inputMode:"decimal",autoComplete:"off",placeholder:"Ex.: 29,90",className:"h-10 rounded-xl border border-violet-100 bg-white text-sm touch-manipulation",value:$e,onChange:l=>x.setResultMinPrice(l.target.value)})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-2 block text-[10px] font-black uppercase tracking-[0.18em] text-violet-500",children:"Preço máx. (R$)"}),e.jsx(oe,{inputMode:"decimal",autoComplete:"off",placeholder:"Ex.: 500",className:"h-10 rounded-xl border border-violet-100 bg-white text-sm touch-manipulation",value:xe,onChange:l=>x.setResultMaxPrice(l.target.value)})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-2 block text-[10px] font-black uppercase tracking-[0.18em] text-violet-500",children:"Desconto mÃn. (%)"}),e.jsx("select",{value:K,onChange:l=>x.setResultMinDiscountPercent(Number(l.target.value)),className:"h-10 w-full rounded-xl border border-violet-100 bg-white px-3 text-sm font-semibold text-slate-700 outline-none",children:[0,5,10,15,20,30,40,50].map(l=>e.jsx("option",{value:l,children:l===0?"Qualquer desconto":`${l}% ou mais`},l))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-[10px] font-black uppercase tracking-[0.18em] text-violet-500",children:"Plataformas"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:w.length>0?w.map(l=>{const S=le.includes(l);return e.jsx("button",{type:"button",onClick:()=>x.toggleResultPlatform(l),className:fe("rounded-xl border px-3 py-2 text-xs font-bold transition-all",S?"border-violet-500 bg-violet-600 text-white shadow-sm":"border-slate-200 bg-white text-slate-600 hover:border-violet-200 hover:bg-violet-50"),children:g.formatPlatformName(l)},l)}):e.jsx(X,{children:"Nenhuma plataforma"})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-[10px] font-black uppercase tracking-[0.18em] text-violet-500",children:"Categorias"}),e.jsx("div",{className:"flex max-h-[120px] flex-wrap gap-2 overflow-y-auto pr-1",children:T.length>0?T.map(l=>{const S=ce.includes(l);return e.jsx("button",{type:"button",onClick:()=>x.toggleResultCategory(l),className:fe("rounded-full border px-3 py-1.5 text-[11px] font-semibold transition-all",S?"border-violet-500 bg-violet-50 text-violet-700":"border-slate-200 bg-white text-slate-600 hover:border-violet-200 hover:bg-violet-50"),children:l},l)}):e.jsx(X,{children:"Nenhuma categoria"})})]})]}):null,e.jsx(na,{open:Ka,onOpenChange:kt,children:e.jsxs(la,{side:"bottom",className:"max-h-[85vh] overflow-y-auto rounded-t-2xl border-violet-100 bg-white p-0",children:[e.jsx(ca,{className:"sticky top-0 z-10 border-b border-violet-100 bg-white/95 backdrop-blur",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx(da,{className:"text-base font-black text-slate-900",children:"Filtros da mineração"}),e.jsx(ma,{className:"text-xs text-slate-500",children:"Refine por texto, comissão, preço, desconto, plataforma e categoria."})]}),e.jsx(m,{type:"button",variant:"outline",size:"sm",onClick:()=>kt(!1),className:"h-10 min-h-10 touch-manipulation rounded-xl border-violet-200 bg-white text-violet-700 hover:bg-violet-50",children:"Fechar"})]})}),e.jsxs("div",{className:"space-y-4 p-4",children:[e.jsxs("div",{className:"relative isolate",children:[e.jsx(it,{className:"pointer-events-none absolute left-3 top-1/2 z-0 h-4 w-4 -translate-y-1/2 text-violet-300","aria-hidden":!0}),e.jsx(oe,{id:"personal-results-filter-mobile",type:"search",autoComplete:"off",autoCapitalize:"none",autoCorrect:"off",spellCheck:!1,placeholder:"Filtrar o resultado por nome, categoria ou plataforma...",className:"relative z-[1] h-11 min-h-11 touch-manipulation rounded-xl border-violet-100 bg-white pl-10",value:xa,onChange:l=>x.setResultSearch(l.target.value)})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsxs("div",{children:[e.jsx("label",{className:"mb-2 block text-[10px] font-black uppercase tracking-[0.18em] text-violet-500",children:"Ordenar resultado"}),e.jsxs("select",{value:k,onChange:l=>x.setResultSortMode(l.target.value),className:"h-11 w-full rounded-xl border border-violet-100 bg-white px-3 text-sm font-semibold text-slate-700 outline-none",children:[e.jsx("option",{value:"maiorComissaoValor",children:"Maior comissão em R$"}),e.jsx("option",{value:"maiorComissaoPercentual",children:"Maior comissão %"}),e.jsx("option",{value:"maiorDesconto",children:"Maior desconto"}),e.jsx("option",{value:"menorDesconto",children:"Menor desconto"}),e.jsx("option",{value:"menorPreco",children:"Menor preço"}),e.jsx("option",{value:"maiorPreco",children:"Maior preço"}),e.jsx("option",{value:"recentes",children:"Mais recentes"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-2 block text-[10px] font-black uppercase tracking-[0.18em] text-violet-500",children:"Comissão mÃnima"}),e.jsx("select",{value:ee,onChange:l=>x.setResultMinCommissionPercent(Number(l.target.value)),className:"h-11 w-full rounded-xl border border-violet-100 bg-white px-3 text-sm font-semibold text-slate-700 outline-none",children:[0,4,6,8,10,12,15,20].map(l
46=>e.jsx("option",{value:l,children:l===0?"Todas as comissões":`${l}% ou mais`},l))})]})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsxs("div",{children:[e.jsx("label",{className:"mb-2 block text-[10px] font-black uppercase tracking-[0.18em] text-violet-500",children:"Preço mÃn. (R$)"}),e.jsx(oe,{inputMode:"decimal",autoComplete:"off",placeholder:"Ex.: 29,90",className:"h-11 min-h-11 rounded-xl border border-violet-100 bg-white text-sm touch-manipulation",value:$e,onChange:l=>x.setResultMinPrice(l.target.value)})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-2 block text-[10px] font-black uppercase tracking-[0.18em] text-violet-500",children:"Preço máx. (R$)"}),e.jsx(oe,{inputMode:"decimal",autoComplete:"off",placeholder:"Ex.: 500",className:"h-11 min-h-11 rounded-xl border border-violet-100 bg-white text-sm touch-manipulation",value:xe,onChange:l=>x.setResultMaxPrice(l.target.value)})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-2 block text-[10px] font-black uppercase tracking-[0.18em] text-violet-500",children:"Desconto mÃn. (%)"}),e.jsx("select",{value:K,onChange:l=>x.setResultMinDiscountPercent(Number(l.target.value)),className:"h-11 w-full rounded-xl border border-violet-100 bg-white px-3 text-sm font-semibold text-slate-700 outline-none",children:[0,5,10,15,20,30,40,50].map(l=>e.jsx("option",{value:l,children:l===0?"Qualquer desconto":`${l}% ou mais`},l))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-[10px] font-black uppercase tracking-[0.18em] text-violet-500",children:"Plataformas"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:w.length>0?w.map(l=>{const S=le.includes(l);return e.jsx("button",{type:"button",onClick:()=>x.toggleResultPlatform(l),className:fe("rounded-full border px-3 py-1.5 text-xs font-bold transition touch-manipulation",S?"border-violet-300 bg-violet-600 text-white":"border-violet-200 bg-white text-violet-700 hover:bg-violet-50"),children:g.formatPlatformName(l)},l)}):e.jsx("p",{className:"text-xs text-slate-500",children:"Sem plataformas para filtrar."})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-[10px] font-black uppercase tracking-[0.18em] text-violet-500",children:"Categorias"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:T.length>0?T.map(l=>{const S=ce.includes(l);return e.jsx("button",{type:"button",onClick:()=>x.toggleResultCategory(l),className:fe("rounded-full border px-3 py-1.5 text-xs font-bold transition touch-manipulation",S?"border-violet-300 bg-violet-600 text-white":"border-violet-200 bg-white text-violet-700 hover:bg-violet-50"),children:l},l)}):e.jsx("p",{className:"text-xs text-slate-500",children:"Sem categorias para filtrar."})})]}),e.jsx("div",{className:"pt-1",children:e.jsx("div",{className:"h-[max(0px,env(safe-area-inset-bottom,0px))]"})})]})]})})]}),!te&&L.length>0?e.jsx("div",{role:"tablist","aria-label":"Tipo de oferta na vitrine",className:"mt-4 flex gap-2 overflow-x-auto pb-1 [-webkit-overflow-scrolling:touch] md:mt-5",children:[{id:"all",short:"Todas",hint:"Catálogo + campanhas API"},{id:"catalog",short:"Catálogo",hint:"Com preço no servidor"},{id:"shopee",short:"Campanhas Shopee",hint:"API â link de campanha"}].map(l=>{const S=l.id==="all"?L.length:l.id==="catalog"?pe.length:Ye.length,U=de===l.id;return e.jsxs("button",{type:"button",role:"tab","aria-selected":U,disabled:S===0,title:l.hint,onClick:()=>ct(l.id),className:fe("h-10 min-h-10 shrink-0 touch-manipulation rounded-full border px-3.5 text-left text-[11px] font-bold transition-all sm:text-xs",U?"border-violet-500 bg-violet-600 text-white shadow-sm":"border-violet-200 bg-white text-slate-700 hover:border-violet-300 hover:bg-violet-50",S===0&&"cursor-not-allowed opacity-45 hover:bg-white"),children:[e.jsx("span",{className:"block leading-tight",children:l.short}),e.jsx("span",{className:"block text-[10px] font-semibold tabular-nums opacity-90",children:S})]},l.id)})}):null,e.jsx("div",{className:"mt-5 space-y-6 md:hidden",children:te?e.jsx(Nt,{title:"Carregando resultadosâ¦",hint:"Catálogo da vitrine",children:Array.from({length:8}).map((l,S)=>e.jsxs("div",{className:"w-[148px] shrink-0 snap-start overflow-hidden rounded-[14px] border border-violet-100 bg-white shadow-sm",children:[e.jsx("div",{className:"aspect-[3/4] animate-pulse bg-violet-100"}),e.jsxs("div",{className:"space-y-2 p-2",children:[e.jsx("div",{className:"h-3 animate-pulse rounded bg-vi
46olet-100"}),e.jsx("div",{className:"h-6 animate-pulse rounded bg-violet-100"}),e.jsx("div",{className:"h-8 animate-pulse rounded-lg bg-violet-100"})]})]},S))}):L.length===0?e.jsxs("div",{className:"rounded-[18px] border border-dashed border-violet-200 bg-white px-4 py-8 text-center shadow-sm",children:[e.jsx("p",{className:"text-sm font-semibold text-slate-700",children:"Nenhuma oferta no filtro atual"}),e.jsx("p",{className:"mt-1 text-xs text-slate-500",children:"Ajuste categorias, lojas ou minere de novo."})]}):de==="catalog"&&dt.length===0?e.jsxs("div",{className:"rounded-[18px] border border-dashed border-violet-200 bg-white px-4 py-8 text-center shadow-sm",children:[e.jsx("p",{className:"text-sm font-semibold text-slate-700",children:"Nenhuma oferta de catálogo neste recorte"}),e.jsx("p",{className:"mt-1 text-xs text-slate-500",children:Ye.length>0?"Troque para «Campanhas Shopee» ou «Todas» para ver links de campanha.":"Afrouxe os filtros do resultado ou minere de novo."})]}):de==="shopee"&&Be.length===0?e.jsxs("div",{className:"rounded-[18px] border border-dashed border-orange-200 bg-orange-50/50 px-4 py-8 text-center shadow-sm",children:[e.jsx("p",{className:"text-sm font-semibold text-orange-950",children:"Sem campanhas Shopee (API) neste resultado"}),e.jsx("p",{className:"mt-1 text-xs text-orange-900/80",children:pe.length>0?"Volte para «Catálogo» ou «Todas» para ver ofertas com preço.":"Nenhum item deste tipo no pool filtrado."})]}):e.jsxs(e.Fragment,{children:[Be.length>0?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"rounded-xl border border-orange-200 bg-orange-50/80 px-4 py-3 shadow-sm",children:[e.jsx("p",{className:"text-[10px] font-black uppercase tracking-[0.18em] text-orange-600",children:"Campanhas Shopee (API â sem preço no servidor)"}),e.jsx("p",{className:"mt-1 text-sm font-semibold text-orange-950",children:"Abra cada campanha na Shopee, use a extensão e importe aqui. Os produtos com preço passam para a grade abaixo; estes cartões deixam de ser campanha pura."}),e.jsx(m,{type:"button",variant:"outline",size:"sm",className:"mt-2 h-10 touch-manipulation rounded-xl border-orange-300 bg-white text-orange-900 hover:bg-orange-50",onClick:Me,children:"Ir para captura / extensão"})]}),me.map(([l,S])=>e.jsx(Nt,{title:l==="Sem categoria"?"Campanhas Shopee":l,hint:`${S.length} · deslize`,children:S.map(U=>{const At=Ms(U);return e.jsx(oa,{offer:U,selected:qe.has(Number(U.id)),formatCurrency:g.formatCurrency,formatPlatformName:g.formatPlatformName,formatCommission:yt,onToggle:()=>x.togglePersonalOffer(U.id),onPrimary:()=>x.addOfferToCart(U.id),primaryMode:"cart",primaryDisabled:!ge,secondaryLabel:qe.has(Number(U.id))?"Desmarcar":"Marcar",primaryLabel:ge?"Adicionar ao carrinho":"Premium para carrinho",campaignShopeeApi:!0,campaignOpenUrl:At||void 0,onScrollToExtension:Me},U.id)})},`shopee-api-${l}`))]}):null,Pt.map(([l,S])=>e.jsx(Nt,{id:Cs(l)?Cr:void 0,title:l,hint:`${S.length} oferta(s) â deslize para o lado`,children:S.map(U=>e.jsx(oa,{offer:U,selected:qe.has(Number(U.id)),formatCurrency:g.formatCurrency,formatPlatformName:g.formatPlatformName,formatCommission:yt,onToggle:()=>x.togglePersonalOffer(U.id),onPrimary:()=>x.addOfferToCart(U.id),primaryMode:"cart",primaryDisabled:!ge,secondaryLabel:qe.has(Number(U.id))?"Desmarcar":"Marcar",primaryLabel:ge?"Adicionar ao carrinho":"Premium para carrinho"},U.id))},l))]})}),e.jsx("div",{className:"mt-5 hidden gap-3.5 sm:gap-4 md:grid md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5 2xl:grid-cols-6",children:te?Array.from({length:6}).map((l,S)=>e.jsxs("div",{className:"rounded-[24px] border border-violet-100 bg-white p-4 shadow-sm",children:[e.jsx("div",{className:"skeleton h-44 rounded-[18px]"}),e.jsxs("div",{className:"mt-4 space-y-3",children:[e.jsx("div",{className:"skeleton h-4 w-24"}),e.jsx("div",{className:"skeleton h-5 w-full"}),e.jsx("div",{className:"skeleton h-5 w-3/4"})]})]},S)):L.length>0&&de!=="all"&&Be.length===0&&dt.length===0?e.jsxs("div",{className:"col-span-full rounded-[24px] border border-dashed border-violet-200 bg-white p-10 text-center shadow-sm",children:[e.jsx("h4",{className:"text-lg font-black text-slate-800",children:de==="catalog"?"Nenhuma oferta de catálogo neste recorte":"Sem campanhas Shopee (API) aqui"}),e.jsx("p",{className:"mx-auto mt-2 max-w-xl text-sm text-slate-500",children:de==="catalog"&&Ye.length>0?"Há itens só como campanha API â use a aba «Campanhas Shopee» ou «Todas».":de==="shopee"&&pe.length>0?"Há ofertas com preço no catálogo â use «Catálogo» ou «Todas».":"Afrouxe os filtros do resultado ou minere de novo."})]}):Be.length>0||dt.length>0?e.jsxs(e.Fragment,{children:[Be.length>0?e.jsxs("div",{className:"col-span-full rounded-xl border border-orange-200 bg-orange-50/80 p-4 shadow-sm",children:[e.jsx("p",{className:"text-[10px] font-black uppercase tracking-[0.18em] text-orange-600",children:"Campanhas Shopee (API â sem preço no servidor)"}),e.jsxs("p",{className:"mt-1 text-sm font-semibold text-orange-950",children:[Be.length," oferta(s) só com link de campanha. Use «Abrir campanha» e a extensão; após importar, os produtos aparecem com preço na grade abaixo."]}),e.jsx(m,{type:"button",variant:"outline",className:"mt-3 h-10 touch-manipulation rounded-xl border-orange-300 bg-white text-orange-900 hover:bg-orange-50",onClick:Me,children:"Ir para captura / extensão"})]}):null,me.map(([l,S])=>va(l==="Sem categoria"?"Campanhas Shopee":l,S,"shopee-api")),Pt.map(([l,S])=>va(l,S,"catalog",Cs(l)?Cr:void 0))]}):e.jsxs("div",{className:"col-span-full rounded-[24px] border border-dashed border-violet-200 bg-white p-12 text-center shadow-sm",children:[e.jsx("div",{className:"mx-auto h-14 w-14 roun
46ded-full bg-violet-50"}),e.jsx("h4",{className:"mt-4 text-xl font-black text-slate-800",children:"Nenhuma oferta encontrada"}),e.jsx("p",{className:"mx-auto mt-2 max-w-2xl text-sm leading-6 text-slate-500",children:"Tente outras categorias, plataformas, faixa de comissão ou termo opcional."})]})})]})]}):null]})}function fo(...s){return s.filter(Boolean).join(" ")}function fs({icon:s,label:r,value:n,tone:u}){const d=u==="emerald"?"border-emerald-200 bg-emerald-50 text-emerald-700":u==="amber"?"border-amber-200 bg-amber-50 text-amber-700":u==="rose"?"border-rose-200 bg-rose-50 text-rose-700":"border-violet-200 bg-violet-50 text-violet-700";return e.jsx("div",{className:fo("rounded-[18px] border p-4 shadow-sm",d),children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-black uppercase tracking-[0.18em]",children:r}),e.jsx("p",{className:"mt-2 text-2xl font-black tracking-tight",children:n})]}),e.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-2xl bg-white/70",children:s})]})})}function tc({state:s,actions:r,helpers:n}){const u=Number(s?.cartReadyNowOffers?.length||0),d=Number(s?.cartActionIds?.length||0),h=Number(s?.cartBlockedActionOffers?.length||0),x=Number(s?.cartActionOffers?.length||0),g=Number(s?.cartMarkedCommissionTotal||0),M=Number(s?.cartReadyCommissionTotal||0),f=n?.formatCurrency||(E=>new Intl.NumberFormat("pt-BR",{style:"currency",currency:"BRL"}).format(Number(E||0))),y=n?.formatCommissionPercent||n?.safeFormatCommissionPercent||n?.formatPercent||(E=>`${Number(E||0).toFixed(2)}%`),D=Number(s?.bestCartCommissionPercent||0);return e.jsxs("section",{className:"rounded-[24px] border border-violet-100 bg-gradient-to-br from-violet-50/80 via-white to-fuchsia-50/60 p-4 shadow-sm md:p-5",children:[e.jsxs("div",{className:"flex flex-col gap-4 xl:flex-row xl:items-center xl:justify-between",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs font-black uppercase tracking-[0.22em] text-violet-500",children:"Leitura operacional"}),e.jsx("h3",{className:"text-xl font-black tracking-tight text-slate-900 md:text-2xl",children:"O que realmente está pronto para virar campanha"}),e.jsx("p",{className:"text-sm leading-6 text-slate-500",children:"Antes de mandar para operação, valide o lote, o potencial financeiro e o que ainda está bloqueando."})]}),e.jsxs("div",{className:"flex w-full flex-col gap-2 sm:flex-row xl:w-auto",children:[e.jsxs(m,{onClick:()=>r?.handleCartImportToLibrary?.(!0),disabled:u===0,className:"h-11 rounded-xl bg-violet-600 text-white hover:bg-violet-700",children:[e.jsx(wt,{className:"mr-2 h-4 w-4"}),"Enviar prontas para operação"]}),e.jsxs(m,{variant:"outline",onClick:()=>r?.clearCartAction?.(),disabled:d===0,className:"h-11 rounded-xl border-violet-200 bg-white text-violet-700 hover:bg-violet-50",children:[e.jsx(Se,{className:"mr-2 h-4 w-4"}),"Limpar marcação"]})]})]}),e.jsxs("div",{className:"mt-5 grid gap-3 md:grid-cols-2 xl:grid-cols-4",children:[e.jsx(fs,{icon:e.jsx(Wa,{className:"h-5 w-5"}),label:"Marcadas",value:String(d),tone:"violet"}),e.jsx(fs,{icon:e.jsx(Ne,{className:"h-5 w-5"}),label:"Prontas agora",value:String(u),tone:"emerald"}),e.jsx(fs,{icon:e.jsx(ho,{className:"h-5 w-5"}),label:"Bloqueadas",value:String(h),tone:"amber"}),e.jsx(fs,{icon:e.jsx(Rs,{className:"h-5 w-5"}),label:"Potencial",value:f(g),tone:"rose"})]}),e.jsxs("div",{className:"mt-5 grid gap-4 xl:grid-cols-[1.1fr_0.9fr]",children:[e.jsxs("div",{className:"rounded-[22px] border border-violet-100 bg-white p-4 shadow-sm",children:[e.jsx("p",{className:"text-[10px] font-black uppercase tracking-[0.18em] text-violet-500",children:"Checklist"}),e.jsxs("div",{className:"mt-4 space-y-3",children:[e.jsx(vs,{ok:d>0,label:"Você marcou um lote para a próxima ação",helper:d>0?`${d} oferta(s) no lote atual.`:"Marque ofertas do carrinho para formar o lote."}),e.jsx(vs,{ok:u>0,label:"Existem ofertas prontas para subir para operação",helper:u>0?`${u} oferta(s) prontas agora.`:"Ainda não há ofertas prontas para essa etapa."}),e.jsx(vs,{ok:h===0,label:"O lote está sem bloqueios crÃticos",helper:h===0?"Nenhum bloqueio crÃtico detectado.":`${h} oferta(s) ainda precisam de revisão.`}),e.jsx(vs,{ok:D>0,label:"Você já tem leitura de comissão no lote",helper:D>0?`Melhor comissão: ${y(D)}.`:"Comissão ainda não disponÃvel para comparação."})]})]}),e.jsxs("div",{className:"rounded-[22px] border border-violet-100 bg-white p-4 shadow-sm",children:[e.jsx("p",{className:"text-[10px] font-black uppercase tracking-[0.18em] text-violet-500",children:"Decisão rápida"}),e.jsxs("div",{className:"mt-4 grid gap-3",children:[e.jsx(Ji,{title:"Lote atual em ação",value:`${x}`,helper:"Ofertas consideradas no contexto operacional",icon:e.jsx(Rl,{className:"h-5 w-5"})}),e.jsx(Ji,{title:"Potencial pronto",value:f(M),helper:"Comissão estimada só das prontas",icon:e.jsx(vr,{className:"h-5 w-5"})})]})]})]})]})}function vs({ok:s,label:r,helper:n}){return e.jsxs("div",{className:"flex items-start gap-3 rounded-[18px] border border-violet-100 bg-violet-50/30 px-4 py-3",children:[e.jsx("div",{className:fo("mt-0.5 flex h-8 w-8 items-center justify-center rounded-full",s?"bg-emerald-100 text-emerald-700":"bg-amber-100 text-amber-700"),children:s?e.jsx(Ne,{className:"h-4 w-4"}):e.jsx(ho,{className:"h-4 w-4"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-black tracking-tight text-slate-900",children:r}),e.jsx("p",{className:"mt-1 text-sm text-slate-500",children:n})]})]})}function Ji({title:s,value:r,helper:n,icon:u}){return e.jsx("div",{className:"rounded-[18px] border border-violet-100 bg-violet-50/30 p-4",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-black uppercase tracking-[0.18em] text-violet-500",children:s}),e.jsx("p",{className:"mt-2 text-xl font-black tracking-tight text-slate-900",children:r}),e.jsx("p",{className:"mt-1 text-sm text-slate-500",children:n})]}),e.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-2xl bg-white text-violet-700 shadow-sm",children:u})]})})}
46function rt(...s){return s.filter(Boolean).join(" ")}function ac(s){return`${Number(s||0).toFixed(2)}%`}function ra({title:s,description:r,children:n}){return e.jsxs("div",{className:"flex min-h-0 flex-col rounded-[18px] border border-violet-100 bg-white p-3 shadow-sm sm:p-4",children:[e.jsx("p",{className:"text-sm font-black leading-snug text-slate-900",children:s}),e.jsx("p",{className:"mt-1 text-xs leading-relaxed text-slate-600",children:r}),e.jsx("div",{className:"mt-3 flex w-full flex-col gap-2",children:n})]})}function ia({icon:s,label:r,value:n,tone:u}){const d={emerald:"border-emerald-200 bg-white text-emerald-700",violet:"border-violet-200 bg-white text-violet-700",blue:"border-blue-200 bg-white text-blue-700",amber:"border-amber-200 bg-white text-amber-700",rose:"border-rose-200 bg-white text-rose-700",slate:"border-slate-200 bg-white text-slate-700"};return e.jsxs("div",{className:rt("rounded-[18px] border p-3 shadow-sm",d[u]||d.violet),children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("span",{className:"inline-flex h-9 w-9 items-center justify-center rounded-2xl bg-current/10",children:s}),e.jsx("span",{className:"text-2xl font-black",children:n})]}),e.jsx("p",{className:"mt-3 text-xs font-black uppercase tracking-[0.18em]",children:r})]})}function sc(s){const{offer:r,selected:n,onToggle:u,onPrimaryAction:d,isRecentlyImported:h,formatPlatformName:x,formatCurrency:g,formatCommissionPercent:M}=s,f=String(r?.convertedUrl||r?.originalUrl||r?.productUrl||"").trim();return e.jsxs("article",{className:rt("flex w-[9.5rem] shrink-0 snap-start flex-col overflow-hidden rounded-[14px] border bg-white shadow-sm transition-all touch-manipulation sm:w-[10.25rem]",n?"border-violet-500 ring-2 ring-violet-300/90 shadow-md":"border-violet-100"),children:[e.jsxs("div",{className:"relative flex h-[6.75rem] shrink-0 items-center justify-center overflow-hidden bg-slate-50 p-1.5",children:[r.productImage?e.jsx("img",{src:uo(r.productImage),alt:"",className:"max-h-full max-w-full object-contain",loading:"lazy",decoding:"async",referrerPolicy:"no-referrer"}):e.jsx("div",{className:"flex h-full items-center justify-center text-[10px] text-slate-400",children:"Sem foto"}),h?e.jsx("span",{className:"absolute left-1 top-1 rounded-md bg-emerald-500 px-1 py-0.5 text-[8px] font-black uppercase text-white shadow-sm",children:"Nova"}):null,r.discountPercent&&Number(r.discountPercent)>0?e.jsxs("span",{className:"absolute right-1 top-1 rounded-md bg-rose-500 px-1 py-0.5 text-[8px] font-black text-white shadow-sm",children:["-",Math.round(Number(r.discountPercent)),"%"]}):null]}),e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-1.5 p-2",children:[e.jsx("p",{className:"line-clamp-2 min-h-[2.25rem] text-[11px] font-bold leading-tight text-slate-900",title:r.productTitle,children:r.productTitle}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-black leading-none text-slate-900",children:g(r.currentPrice)}),r.originalPrice?e.jsx("p",{className:"text-[10px] text-slate-400 line-through",children:g(r.originalPrice)}):null]}),e.jsx("p",{className:"truncate text-[9px] font-semibold uppercase tracking-wide text-violet-700",children:x(r.platform)}),r.commissionPercent?e.jsx("p",{className:"truncate text-[9px] font-medium text-slate-500",children:M(r.commissionPercent)}):null,e.jsxs("div",{className:"mt-auto flex gap-1 pt-0.5",children:[e.jsx(m,{type:"button",variant:"outline",size:"icon",onClick:y=>{y.stopPropagation(),u()},"aria-pressed":n,"aria-label":n?"Desmarcar":"Marcar",className:rt("h-9 w-9 shrink-0 rounded-lg border-slate-200",n&&"border-violet-400 bg-violet-50 text-violet-700"),children:e.jsx(Wa,{className:"h-4 w-4","aria-hidden":!0})}),e.jsx(m,{type:"button",variant:"outline",size:"icon",onClick:y=>{y.stopPropagation(),d()},"aria-label":"Remover",className:"h-9 w-9 shrink-0 rounded-lg border-slate-200 text-slate-600 hover:text-rose-600",children:e.jsx(Le,{className:"h-4 w-4","aria-hidden":!0})}),f?e.jsx(m,{type:"button",variant:"outline",size:"icon",asChild:!0,className:"h-9 w-9 shrink-0 rounded-lg border-violet-200 text-violet-700",children:e.jsx("a",{href:f,target:"_blank",rel:"noreferrer","aria-label":"Abrir oferta",onClick:y=>y.stopPropagation(),children:e.jsx(wt,{className:"h-4 w-4","aria-hidden":!0})})}):null]})]})]})}function rc(s){const{sectionRef:r,visible:n,state:u,actions:d,helpers:h,onGoToOperation:x,canUsePoolActions:g=!0,hasAutopilotAccess:M=!1}=s,{filteredCartOffers:f,cartOffersTotalCount:y=0,cartHydrationPending:D,selectedCartIds:E,cartActionIds:F,cartReadyNowOffers:ae,cartAvailablePlatforms:z,cartSelectedPlatforms:se,cartAvailableCategories:_,cartSelectedCategories:W,showCartFilters:H,cartSearch:O,cartReadyCommissionTotal:ue,bestCartCommissionPercent:$,importPending:re,recentImportedSourceOfferIds:A}=u,[L,he]=o.useState(!1),J=new Set((A||[]).map(k=>
46Number(k)).filter(Boolean)),w=E.length>0&&y>0&&!D,le=re||ae.length===0||!g,T=h?.formatCommissionPercent||h?.safeFormatCommissionPercent||h?.formatPercent||ac,ce=h?.formatCurrency||(k=>new Intl.NumberFormat("pt-BR",{style:"currency",currency:"BRL"}).format(Number(k||0)));return e.jsxs("div",{ref:r,className:rt("space-y-4 md:space-y-6 max-md:scroll-mt-4",!n&&"hidden"),children:[e.jsxs("section",{className:"rounded-[24px] border border-violet-100 bg-white p-3 shadow-sm sm:p-4 md:p-5",children:[e.jsxs("div",{className:"flex flex-col gap-4 border-b border-violet-50 pb-4 xl:flex-row xl:items-start xl:justify-between",children:[e.jsxs("div",{className:"min-w-0 space-y-2",children:[e.jsx("p",{className:"text-xs font-black uppercase tracking-[0.22em] text-violet-500",children:"Selecionadas"}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("h3",{className:"text-lg font-black tracking-tight text-slate-900 sm:text-xl md:text-2xl",children:"Visão do seu carrinho"}),e.jsx("span",{className:"rounded-full border border-violet-200 bg-violet-50 px-2.5 py-0.5 text-xs font-bold tabular-nums text-violet-800",children:y})]}),e.jsxs("p",{className:"text-[13px] leading-snug text-slate-500 sm:text-sm sm:leading-6",children:["A grade abaixo é o foco: marque nos cartões e, em seguida, use"," ",e.jsx("span",{className:"font-semibold text-slate-700",children:"Decidir o lote"})," para biblioteca, agenda, disparo ou piloto."]}),e.jsx(m,{asChild:!0,variant:"outline",className:"h-11 min-h-11 w-full touch-manipulation rounded-xl border-violet-200 bg-white text-violet-800 hover:bg-violet-50 sm:w-auto",children:e.jsx(xt,{to:"/miner-offers",className:"touch-manipulation",children:"Ir à Vitrine acrescentar ofertas"})})]}),e.jsxs("div",{className:"grid w-full grid-cols-1 gap-2 min-[400px]:grid-cols-3 xl:flex xl:w-auto xl:max-w-none xl:flex-wrap xl:justify-end xl:gap-2",children:[e.jsxs(m,{variant:"outline",onClick:d.selectAllCartVisible,className:"h-11 min-h-11 w-full touch-manipulation justify-center rounded-xl border-violet-200 bg-white px-3 text-violet-700 hover:bg-violet-50 xl:w-auto",children:[e.jsx(Ne,{className:"h-4 w-4 shrink-0 sm:mr-2","aria-hidden":!0}),e.jsx("span",{className:"hidden sm:inline",children:"Marcar visÃveis"}),e.jsx("span",{className:"sm:hidden",children:"Marcar"})]}),e.jsxs(m,{variant:"outline",onClick:d.clearCartAction,disabled:F.length===0,className:"h-11 min-h-11 w-full touch-manipulation justify-center rounded-xl border-violet-200 bg-white px-3 text-violet-700 hover:bg-violet-50 disabled:opacity-50 xl:w-auto",children:[e.jsx(Se,{className:"h-4 w-4 shrink-0 sm:mr-2","aria-hidden":!0}),e.jsx("span",{className:"hidden min-[400px]:inline",children:"Limpar marcação"}),e.jsx("span",{className:"min-[400px]:hidden",children:"Limpar"})]}),e.jsxs(m,{variant:"outline",onClick:d.clearSelectedCart,disabled:E.length===0,className:"h-11 min-h-11 w-full touch-manipulation justify-center rounded-xl border-violet-200 bg-white px-3 text-violet-700 hover:bg-violet-50 disabled:opacity-50 xl:w-auto",children:[e.jsx(Le,{className:"h-4 w-4 shrink-0 sm:mr-2","aria-hidden":!0}),e.jsx("span",{className:"hidden sm:inline",children:"Limpar carrinho"}),e.jsx("span",{className:"sm:hidden",children:"Limpar tudo"})]})]})]}),e.jsxs("div",{className:"mt-4 flex flex-col gap-3 sm:flex-row sm:items-end sm:justify-between",children:[e.jsx("p",{className:"min-w-0 text-sm leading-snug text-slate-600",children:D?e.jsx(e.Fragment,{children:"Sincronizando com o catálogo da vitrineâ¦"}):E.length===0?e.jsx(e.Fragment,{children:"Adicione ofertas na Vitrine para montar o carrinho aqui."}):e.jsxs(e.Fragment,{children:[y," oferta(s) carregada(s) · ",F.length," ","marcada(s) · ",ae.length," pronta(s) para importar"]})}),f.length>1?e.jsxs(m,{type:"button",variant:"outline",onClick:d.selectAllCartVisible,className:"h-11 min-h-11 w-full shrink-0 touch-manipulation rounded-xl border-violet-200 bg-white text-violet-800 hover:bg-violet-50 sm:w-auto",children:[e.jsx(Ne,{className:"mr-2 h-4 w-4 shrink-0","aria-hidden":!0}),"Marcar visÃveis no lote"]}):null]}),D?e.jsxs("div",{className:"mt-8 flex flex-col items-center gap-3 rounded-[22px] border border-dashed border-violet-200 bg-vi
46olet-50/40 py-16 text-center",children:[e.jsx(De,{className:"h-10 w-10 shrink-0 animate-spin text-violet-500","aria-hidden":!0}),e.jsx("p",{className:"text-sm font-semibold text-slate-700",children:"Sincronizando com o catálogo da vitrineâ¦"})]}):E.length===0?e.jsxs("div",{className:"mt-8 rounded-[22px] border border-dashed border-violet-200 bg-violet-50/30 px-4 py-12 text-center",children:[e.jsx(Is,{className:"mx-auto h-12 w-12 text-violet-300","aria-hidden":!0}),e.jsx("h4",{className:"mt-4 text-lg font-black tracking-tight text-slate-900",children:"Carrinho vazio"}),e.jsx("p",{className:"mx-auto mt-2 max-w-md text-sm leading-6 text-slate-500",children:'Na Vitrine, toque no alvo nas ofertas e depois em "Ver seleção na Galeria de Ofertas" para trazer o lote para cá.'}),e.jsx(m,{asChild:!0,className:"mt-6 h-11 min-h-11 w-full max-w-xs rounded-xl bg-violet-600 text-white hover:bg-violet-700",children:e.jsx(xt,{to:"/miner-offers",className:"touch-manipulation",children:"Ir para a Vitrine"})})]}):y===0?e.jsxs("div",{className:"mt-8 rounded-[22px] border border-dashed border-amber-200 bg-amber-50/50 px-4 py-10 text-center",children:[e.jsx("h4",{className:"text-lg font-black text-slate-900",children:"Não foi possÃvel carregar os dados destas ofertas"}),e.jsx("p",{className:"mx-auto mt-2 max-w-lg text-sm leading-6 text-slate-600",children:"Limpe o carrinho e selecione novamente na Vitrine, ou verifique sua conexão."}),e.jsx(m,{type:"button",variant:"outline",className:"mt-6 h-11 min-h-11 w-full max-w-xs touch-manipulation rounded-xl border-slate-200",onClick:d.clearSelectedCart,children:"Limpar carrinho"})]}):f.length===0?e.jsxs("div",{className:"mt-8 rounded-[22px] border border-dashed border-violet-200 bg-violet-50/30 px-4 py-10 text-center",children:[e.jsxs("h4",{className:"text-lg font-black text-slate-900",children:["Filtros escondem todas as ",y," oferta(s)"]}),e.jsx("p",{className:"mx-auto mt-2 max-w-lg text-sm text-slate-600",children:"Limpe busca, plataforma e categoria para ver o lote completo (filtros em Métricas e filtros)."}),e.jsx(m,{type:"button",variant:"outline",className:"mt-6 h-11 touch-manipulation rounded-xl border-violet-200 bg-white text-violet-800 hover:bg-violet-50",onClick:()=>d.clearCartDisplayFilters?.(),children:"Limpar filtros do carrinho"})]}):e.jsxs("div",{id:"offers-cart-grid",className:"mt-4 scroll-mt-28",children:[e.jsxs("div",{className:"mb-2 flex flex-wrap items-center justify-between gap-2",children:[e.jsxs("p",{className:"flex min-w-0 items-center gap-1.5 text-[11px] font-semibold text-violet-800",children:[e.jsx(yr,{className:"h-3.5 w-3.5 shrink-0","aria-hidden":!0}),e.jsxs("span",{className:"truncate",children:["Deslize horizontalmente para revisar â ",f.length," ","oferta(s)"]})]}),f.length>1?e.jsx("button",{type:"button",onClick:d.selectAllCartVisible,className:"shrink-0 text-[11px] font-bold text-violet-700 underline-offset-2 hover:underline touch-manipulation",children:"Marcar todas"}):null]}),e.jsx("div",{className:"rounded-2xl border border-violet-100 bg-gradient-to-b from-violet-50/50 to-white p-1.5 shadow-inner",children:e.jsx("div",{className:"flex max-h-[min(48vh,400px)] min-h-[12.5rem] gap-2 overflow-x-auto overflow-y-hidden overscroll-x-contain px-0.5 pb-1 pt-0.5 [-webkit-overflow-scrolling:touch] scroll-smooth snap-x snap-mandatory [scrollbar-width:thin]",role:"list","aria-label":"Ofertas no carrinho",children:f.slice(0,120).map(k=>e.jsx(sc,{offer:k,isRecentlyImported:J.has(Number(k.id)),selected:F.includes(k.id),onToggle:()=>d.toggleCartAction(k.id),onPrimaryAction:()=>d.removeOfferFromCart(k.id),formatPlatformName:h.formatPlatformName,formatCurrency:ce,formatCommissionPercent:T},k.id))})}),f.length>120?e.jsxs("p",{className:"mt-2 text-center text-xs text-slate-500",children:["Mostrando 120 de ",f.length,". Use filtros em Métricas e filtros."]}):null]})]}),w?e.jsxs("section",{className:"rounded-[24px] border border-emerald-200 bg-gradient-to-br from-emerald-50/60 via-white to-white p-3 shadow-sm sm:p-4 md:p-5",children:[e.jsx("p",{className:"text-xs font-black uppercase tracking-[0.22em] text-emerald-700",children:"Decidir o lote"}),e.jsx("h3",{className:"mt-1 text-base font-black leading-snug text-slate-900 sm:text-lg md:text-xl",children:"Para onde você leva as ofertas marcadas?"}),e.jsxs("p",{className:"mt-1 max-w-3xl text-[13px] leading-relaxed text-slate-600 sm:text-sm",children:["Importar usa só as marcadas que estão prontas para operação. Sem Premium da vitrine, a importação do carrinho permanece bloqueada.",g?null:e.jsxs("span",{className:"font-semibold text-amber-800",children:[" ","Seu plano atual não inclui importar ofertas da vitrine para a biblioteca."]})]}),e.jsxs("div",{className:"mt-4 grid grid-cols-1 gap-3 sm:grid-cols-2 xl:grid-cols-3",children:[e.jsx(ra,{title:"Minha biblioteca",description:"Importa as prontas para a sua biblioteca e abre a aba Biblioteca para organizar.",children:e.jsxs(m,{type:"button",variant:"outline",className:"h-11 min-h-11 w-full touch-manipulation justify-start rounded-xl border-emerald-200 bg-white text-emerald-900 hover:bg-emerald-50 disabled:opacity-50 sm:min-w-0",disabled:le,title:le?"Marque ofertas prontas ou verifique Premium":void 0,onClick:()=>d.handleCartImportToLibrary(!1),children:[e.jsx(Is,{className:"mr-2 h-4 w-4 shrink-0","aria-hidden":!0}),"Importar para biblioteca"]})}),e.jsx(ra,{title:"Operação + agenda",description:"Importa e vai para a Operação com o painel de agendamento aberto.",children:e.jsxs(m,{type:"button",className:"h-11 min-h-11 w-full touch-manipulation justify-start rounded-xl bg-emerald-600 text-white hover:bg-emerald-700 disabled:opacity-50 sm:min-w-0",disabled:le,title:le?"Marque ofertas prontas ou verifique Premium":void 0,onClick:()=>d.handleCartImportToLibrary(!0),children:[e.jsx(Fe,{className:"mr-2 h-4 w-4 shrink-0","aria-hidden":!0}),"Importar e abrir agenda"]})}),e.jsx(ra,{title:"Ãrea Operação",description:"Montar copy, banner e canais na mesma página da Galeria de Ofertas (útil se já importou antes).",children:e.jsxs(m,{type:"button",variant:"outline",className:"h-11 min-h-11 w-full touch-manipulation justify-start rounded-xl border-violet-200 bg-white text-violet-900 hover:bg-violet-50 sm:min-w-0",disabled:!x,onClick:()=>x?.(),children:[e.jsx(yr,{className:"mr-2 h-4 w-4 shrink-0","aria-hidden":!0}),"Ir para Operação"]})}
46),e.jsx(ra,{title:"Agenda de disparos",description:"Filas, pausa e próximos envios na página dedicada de agendamento.",children:e.jsx(m,{asChild:!0,variant:"outline",className:"h-11 min-h-11 w-full touch-manipulation justify-start rounded-xl border-violet-200 bg-white p-0 sm:min-w-0",children:e.jsxs(xt,{to:"/agendamento",className:"inline-flex h-11 min-h-11 w-full touch-manipulation items-center justify-start gap-0 rounded-xl px-4 py-2 text-left font-semibold",children:[e.jsx(Fe,{className:"mr-2 h-4 w-4 shrink-0","aria-hidden":!0}),"Abrir agenda"]})})}),e.jsx(ra,{title:"Disparo nos canais",description:"Converter links e enviar para WhatsApp e Telegram com revisão antes do envio.",children:e.jsx(m,{asChild:!0,variant:"outline",className:"h-11 min-h-11 w-full touch-manipulation justify-start rounded-xl border-violet-200 bg-white p-0 sm:min-w-0",children:e.jsxs(xt,{to:"/convert-link",className:"inline-flex h-11 min-h-11 w-full touch-manipulation items-center justify-start gap-0 rounded-xl px-4 py-2 text-left font-semibold",children:[e.jsx(jr,{className:"mr-2 h-4 w-4 shrink-0","aria-hidden":!0}),"Ir para disparo"]})})}),e.jsx(ra,{title:"Piloto automático",description:"Automação contÃnua quando incluÃda no seu plano.",children:M?e.jsx(m,{asChild:!0,variant:"outline",className:"h-11 min-h-11 w-full touch-manipulation justify-start rounded-xl border-violet-200 bg-white p-0 sm:min-w-0",children:e.jsxs(xt,{to:"/piloto-automatico",className:"inline-flex h-11 min-h-11 w-full touch-manipulation items-center justify-start gap-0 rounded-xl px-4 py-2 text-left font-semibold",children:[e.jsx(ot,{className:"mr-2 h-4 w-4 shrink-0 text-amber-600","aria-hidden":!0}),"Abrir Piloto automático"]})}):e.jsxs(m,{type:"button",variant:"outline",disabled:!0,className:"h-11 min-h-11 w-full cursor-not-allowed justify-start rounded-xl border-slate-200 bg-slate-50 text-slate-500 sm:min-w-0",title:"Recurso disponÃvel em planos com Piloto automático",children:[e.jsx(Kn,{className:"mr-2 h-4 w-4 shrink-0","aria-hidden":!0}),"Piloto não disponÃvel no plano"]})})]}),e.jsxs("div",{className:"mt-4 flex flex-col gap-2 rounded-[14px] border border-violet-100 bg-white/60 px-3 py-3 text-xs text-slate-600 sm:flex-row sm:flex-wrap sm:items-center sm:gap-x-3 sm:gap-y-1 sm:border-0 sm:bg-transparent sm:px-0 sm:py-0",children:[e.jsx("span",{className:"font-semibold text-slate-700",children:"Atalhos:"}),e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:flex-wrap sm:items-center sm:gap-x-3",children:[e.jsx(xt,{to:"/copy",className:"inline-flex min-h-11 touch-manipulation items-center font-bold text-violet-700 underline-offset-4 hover:underline sm:min-h-0",children:"Copy"}),e.jsx("span",{"aria-hidden":!0,className:"hidden text-slate-300 sm:inline",children:"·"}),e.jsx(xt,{to:"/generate-posts",className:"inline-flex min-h-11 touch-manipulation items-center font-bold text-violet-700 underline-offset-4 hover:underline sm:min-h-0",children:"Gerar Banner"})]})]})]}):null,e.jsxs("details",{className:"rounded-[24px] border border-violet-100 bg-violet-50/40 shadow-sm",children:[e.jsx("summary",{className:"flex min-h-11 cursor-pointer list-none items-center px-4 py-3 text-sm font-bold text-violet-800 touch-manipulation md:px-5 [&::-webkit-details-marker]:hidden",children:"Métricas e filtros do carrinho (opcional)"}),e.jsxs("div",{className:"border-t border-violet-100 px-4 pb-5 pt-2 md:px-5",children:[e.jsxs("div",{className:"mt-4 grid grid-cols-2 gap-2 sm:gap-3 md:grid-cols-3 xl:grid-cols-6",children:[e.jsx(ia,{icon:e.jsx(Ts,{className:"h-4 w-4"}),label:"VisÃveis agora",value:String(f.length),tone:"violet"}),e.jsx(ia,{icon:e.jsx(Wa,{className:"h-4 w-4"}),label:"No carrinho",value:String(E.length),tone:"blue"}),e.jsx(ia,{icon:e.jsx(jr,{className:"h-4 w-4"}),label:"Marcadas",value:String(F.length),tone:"emerald"}),e.jsx(ia,{icon:e.jsx(Ne,{className:"h-4 w-4"}),label:"Prontas",value:String(ae.length),tone:"emerald"}),e.jsx(ia,{icon:e.jsx(Rs,{className:"h-4 w-4"}),label:"Potencial",value:ce(ue),tone:"amber"}),e.jsx(ia,{icon:e.jsx(kr,{className:"h-4 w-4"}),label:"Melhor comissão",value:T($),tone:"rose"})]}),J.size>0?e.jsx("div",{className:"mt-3",children:e.jsxs("span",{className:"inline-flex items-center rounded-full border border-emerald-200 bg-emerald-50 px-3 py-1 text-xs font-bold text-emerald-700",children:["Novas importadas agora: ",J.size]})}):null,e.jsxs("div",{className:"mt-5 rounded-[16px] border border-violet-100 bg-white/80 p-3 md:p-4",children:[e.jsxs("div",{className:"flex flex-col gap-3 md:flex-row md:items-center md:justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-black uppercase tracking-[0.18em] text-violet-500",children:"Filtros do carrinho"}),e.jsx("p",{className:"mt-1 text-sm text-slate-600",children:"Refine por texto, plataforma ou categoria."})]}),e.jsxs("button",{type:"button",onClick:()=>he(!0),className:"inline-flex min-h-11 touch-manipulation items-center justify-center gap-2 rounded-full border border-violet-200 bg-white px-3 py-2 text-xs font-bold text-violet-700 transition hover:bg-violet-50 md:hidden",children:["Filtros",e.jsx(Se,{className:"h-4 w-4"})]}),e.jsxs("button",{type:"button",onClick:d.onToggleCartFilters,className:"hidden items-center gap-2 rounded-full border border-violet-200 bg-white px-3 py-2 text-xs font-bold text-violet-700 transition hover:bg-violet-50 touch-manipulation md:inline-flex",children:[H?"Recolher filtros":"Expandir filtros",e.jsx(Se,{className:rt("h-4 w-4 transition-transform",H&&"rotate-45")})]})]}),H?e.jsxs("div",{className:"mt-4 hidden space-y-4 md:block",children:[e.jsxs("div",{className:"relative",children:[e.jsx(it,{className:"pointer-events-none absolute left-3 top-3 h-4 w-4 text-violet-300"}),e.jsx(oe,{placeholder:"Buscar dentro das selecionadas...",className:"h-11 min-h-11 rounded-xl border-violet-100 bg-white pl-10 touch-manipulation",value:O,onChange:k=>d.setCartSearch(k.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-[10px] font-black uppercase tracking-[0.18em] text-violet-500",children:"Plataformas"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:z.map(k=>{const ee=se.includes(k);return e.jsx("button",{type:"button",onClick:()=>d.toggleCartPlatform(k),className:rt("rounded-full border px-3 py-1.5 text-xs font-bold transition touch-manipulation",ee?"border-violet-300 bg-vi
46olet-600 text-white":"border-violet-200 bg-white text-violet-700 hover:bg-violet-50"),children:h.formatPlatformName(k)},k)})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-[10px] font-black uppercase tracking-[0.18em] text-violet-500",children:"Categorias"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:_.map(k=>{const ee=W.includes(k);return e.jsx("button",{type:"button",onClick:()=>d.toggleCartCategory(k),className:rt("rounded-full border px-3 py-1.5 text-xs font-bold transition touch-manipulation",ee?"border-violet-300 bg-violet-600 text-white":"border-violet-200 bg-white text-violet-700 hover:bg-violet-50"),children:k},k)})})]})]}):null,e.jsx(na,{open:L,onOpenChange:he,children:e.jsxs(la,{side:"bottom",className:"max-h-[85vh] overflow-y-auto rounded-t-2xl border-violet-100 bg-white p-0",children:[e.jsx(ca,{className:"sticky top-0 z-10 border-b border-violet-100 bg-white/95 backdrop-blur",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx(da,{className:"text-base font-black text-slate-900",children:"Filtros do carrinho"}),e.jsx(ma,{className:"text-xs text-slate-500",children:"Filtre por texto, plataforma e categoria."})]}),e.jsx(m,{type:"button",variant:"outline",size:"sm",onClick:()=>he(!1),className:"h-10 min-h-10 touch-manipulation rounded-xl border-violet-200 bg-white text-violet-700 hover:bg-violet-50",children:"Fechar"})]})}),e.jsxs("div",{className:"space-y-4 p-4",children:[e.jsxs("div",{className:"relative",children:[e.jsx(it,{className:"pointer-events-none absolute left-3 top-3 h-4 w-4 text-violet-300"}),e.jsx(oe,{placeholder:"Buscar dentro das selecionadas...",className:"h-11 min-h-11 rounded-xl border-violet-100 bg-white pl-10 touch-manipulation",value:O,onChange:k=>d.setCartSearch(k.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-[10px] font-black uppercase tracking-[0.18em] text-violet-500",children:"Plataformas"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:z.map(k=>{const ee=se.includes(k);return e.jsx("button",{type:"button",onClick:()=>d.toggleCartPlatform(k),className:rt("rounded-full border px-3 py-1.5 text-xs font-bold transition touch-manipulation",ee?"border-violet-300 bg-violet-600 text-white":"border-violet-200 bg-white text-violet-700 hover:bg-violet-50"),children:h.formatPlatformName(k)},k)})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-[10px] font-black uppercase tracking-[0.18em] text-violet-500",children:"Categorias"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:_.map(k=>{const ee=W.includes(k);return e.jsx("button",{type:"button",onClick:()=>d.toggleCartCategory(k),className:rt("rounded-full border px-3 py-1.5 text-xs font-bold transition touch-manipulation",ee?"border-violet-300 bg-violet-600 text-white":"border-violet-200 bg-white text-violet-700 hover:bg-violet-50"),children:k},k)})})]}),typeof d.clearCartDisplayFilters=="function"?e.jsx(m,{type:"button",variant:"outline",onClick:()=>d.clearCartDisplayFilters?.(),className:"h-11 w-full touch-manipulation rounded-xl border-violet-200 bg-white text-violet-700 hover:bg-violet-50",children:"Limpar filtros"}):null,e.jsx("div",{className:"h-[max(0px,env(safe-area-inset-bottom,0px))]"})]})]})})]})]})]}),e.jsxs("details",{className:"rounded-[24px] border border-violet-100 bg-white shadow-sm",children:[e.jsx("summary",{className:"flex min-h-11 cursor-pointer list-none items-center px-4 py-3 text-sm font-bold text-violet-800 touch-manipulation md:px-5 [&::-webkit-details-marker]:hidden",children:"Checklist antes de publicar (opcional)"}),e.jsx("div",{className:"border-t border-violet-100 px-4 pb-5 pt-2 md:px-5",children:e.jsx(tc,{state:u,actions:d,helpers:h})})]}),e.jsxs("details",{className:"rounded-[24px] border border-violet-100 bg-white shadow-sm",children:[e.jsx("summary",{className:"flex min-h-11 cursor-pointer list-none items-center px-4 py-3 text-sm font-bold text-violet-800 touch-manipulation md:px-5 [&::-webkit-details-marker]:hidden",children:"Cartões grandes para revisão profunda (opcional)"}),e.jsxs("div",{className:"border-t border-violet-100 px-4 pb-5 pt-2 md:px-5",children:[e.jsx("p",{className:"mb-4 text-sm leading-6 text-slate-500",children:"Mesmas ofertas da faixa acima, com mais contexto em cada cartão."}),e.jsx("div",{className:"grid gap-4 xl:grid-cols-2",children:f.slice(0,6).map(k=>e.jsx(Pr,{offer:{...k,currentPrice:h.parseFlexibleMoneyValue?.(k.currentPrice)??Number(k.currentPrice||0),originalPrice
46:h.parseFlexibleMoneyValue?.(k.originalPrice)??Number(k.originalPrice||0),discountPercent:Number(k.discountPercent||0)},selected:F.includes(k.id),onToggle:ee=>d.toggleCartAction(ee),formatCurrency:ce,formatPercent:h.formatPercent||T,cn:rt},k.id))})]})]})]})}const ic="flex h-14 min-h-[56px] w-14 min-w-[56px] touch-manipulation flex-col items-center justify-center gap-0 rounded-full border-2 border-violet-200 bg-violet-600 pb-0.5 text-white shadow-xl transition hover:bg-violet-700 hover:shadow-2xl focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-violet-400 focus-visible:ring-offset-2 active:scale-[0.98] disabled:opacity-50",oc=o.forwardRef(function({count:r,expanded:n,controlsId:u,className:d,type:h="button",...x},g){return e.jsxs("button",{ref:g,type:h,className:N(ic,d),"aria-expanded":n,"aria-controls":u,"aria-haspopup":"menu","aria-label":`Abrir ações do carrinho, ${r} item${r===1?"":"s"}`,...x,children:[e.jsx("span",{className:"text-base font-black tabular-nums leading-none",children:r}),e.jsx(Ce,{className:"h-3 w-3 shrink-0 opacity-90","aria-hidden":!0})]})});function st({label:s,value:r,onPress:n,disabled:u,ariaLabel:d,variant:h="dark"}){const x=h==="light",g=Number.parseInt(String(r).replace(/\D/g,""),10),M=Number.isFinite(g)&&g>0,f=!!n&&!u&&M;return n?e.jsxs("button",{type:"button",onClick:()=>{f&&n()},disabled:!f,"aria-label":d||`${s}: ${r}`,title:f?`Ver ${r} â ${s.toLowerCase()}`:M?void 0:"Nada para mostrar aqui",className:N("w-full rounded-[18px] border px-3 py-3 text-left transition-colors touch-manipulation",x?f?"border-violet-200 bg-violet-50 hover:bg-violet-100 active:bg-violet-200":"cursor-not-allowed border-slate-100 bg-slate-50 opacity-60":f?"border-white/25 bg-white/15 hover:bg-white/20 active:bg-violet-400/90 active:shadow-[0_0_18px_rgba(167,139,250,0.45)]":"cursor-not-allowed border-white/10 bg-white/10 opacity-60"),children:[e.jsx("p",{className:N("text-[10px] font-black uppercase tracking-[0.18em]",x?"text-violet-600":"text-violet-200"),children:s}),e.jsx("p",{className:N("mt-1 text-lg font-black",x?"text-slate-900":"text-white"),children:r}),f?e.jsx("p",{className:N("mt-1 text-[10px] font-semibold",x?"text-violet-600/90":"text-violet-200/90"),children:"Toque para ver na página"}):null]}):e.jsxs("div",{className:N("rounded-[18px] border px-3 py-3",x?"border-slate-100 bg-slate-50":"border-white/10 bg-white/10"),children:[e.jsx("p",{className:N("text-[10px] font-black uppercase tracking-[0.18em]",x?"text-violet-600":"text-violet-200"),children:s}),e.jsx("p",{className:N("mt-1 text-lg font-black",x?"text-slate-900":"text-white"),children:r})]})}const He="inline-flex h-11 min-h-[44px] items-center justify-center gap-2 rounded-2xl px-3 text-sm font-bold transition touch-manipulation focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-violet-300 focus-visible:ring-offset-2 focus-visible:ring-offset-violet-950";function js(s){return s?"border-violet-200 bg-violet-400 text-white shadow-[0_0_22px_rgba(167,139,250,0.65)] ring-2 ring-violet-200/80":"border-white/15 bg-white/10 text-white hover:bg-white/15"}function nc({expanded:s,onToggle:r,selectedResultsCount:n,markedCount:u,cartCount:d,readyCount:h,blockedCount:x,libraryCount:g,commissionPotential:M,bestCommissionPercent:f,onContinue:y,onOpenCart:D,onSchedule:E,onGoToOperation:F,onShowSearchSelection:ae,onShowCartWorkspace:z,onShowLibrarySelection:se,activeAction:_=null,libraryMode:W=!1,onConvertLibrary:H,onGenerateBannerLibrary:O,onGoToVideoPromptsLibrary:ue,onAutopilotLibrary:$,canAutopilotLibrary:re=!0,onFavoriteLibrary:A,onDeleteSelectedLibrary:L}){const[he,J]=o.useState(!1),w=Pe=>_===Pe,le=()=>J(!1),T=Pe=>{Pe(),le()},ce=typeof M=="number"?M.toLocaleString("pt-BR",{style:"currency",currency:"BRL"}):"R$ 0,00",k=Number(f||0)>0?`${String(Math.round(Number(f||0)*10)/10).replace(".",",")}%`:"â",ee=d+n+g,$e=Math.max(d,n,g,ee,1),xe=W&&g>0&&typeof H=="function",K=Pe=>N("h-12 min-h-[48px] w-full touch-manipulation justify-start gap-3 rounded-xl px-4 text-left text-base font-semibold",Pe&&"border-violet-300 bg-violet-400 text-white shadow-[0_0_18px_rgba(167,139,250,0.45)] ring-2 ring-violet-200/80 hover:bg-violet-400"),nt=e.jsxs(e.Fragment,{children:[e.jsxs(m,{type:"button",variant:"outline",className:N(K(!1),"border-violet-200 text-violet-900 hover:bg-violet-50"),onClick:()=>T(H),children:[e.jsx(Ps,{className:"h-5 w-5 shrink-0 text-violet-600","aria-hidden":!0}),"Converter oferta selecionada"]}
46),O?e.jsxs(m,{type:"button",variant:"default",className:N(K(!1),"bg-violet-600 text-white hover:bg-violet-700"),onClick:()=>T(O),children:[e.jsx(As,{className:"h-5 w-5 shrink-0","aria-hidden":!0}),"Gerar Banner da oferta selecionada"]}):null,ue?e.jsxs(m,{type:"button",variant:"outline",className:N(K(!1),"border-sky-200 bg-sky-50/50 text-sky-950 hover:bg-sky-50"),onClick:()=>T(ue),children:[e.jsx(Ci,{className:"h-5 w-5 shrink-0 text-sky-700","aria-hidden":!0}),"VÃdeo ou carrossel no Studio"]}):null,e.jsxs(m,{type:"button",variant:"outline",className:N(K(w("schedule")),!w("schedule")&&"border-emerald-200 bg-emerald-50/40 text-emerald-950 hover:bg-emerald-50"),onClick:()=>T(E),children:[e.jsx(Fe,{className:"h-5 w-5 shrink-0 text-emerald-700","aria-hidden":!0}),"Agendar envio da seleção"]}),$?e.jsxs(m,{type:"button",variant:"outline",disabled:!re,className:N(K(!1),"border-fuchsia-200 bg-fuchsia-50/40 text-fuchsia-950 hover:bg-fuchsia-50 disabled:opacity-50"),onClick:()=>T($),children:[e.jsx(ot,{className:"h-5 w-5 shrink-0 text-fuchsia-700","aria-hidden":!0}),"Enviar ao piloto automático"]}):null,A?e.jsxs(m,{type:"button",variant:"default",className:N(K(!1),"bg-violet-600 text-white hover:bg-violet-700"),onClick:()=>T(A),children:[e.jsx(jt,{className:"h-5 w-5 shrink-0","aria-hidden":!0}),"Favoritar seleção"]}):null,L?e.jsxs(m,{type:"button",variant:"outline",className:N(K(!1),"border-rose-200 bg-rose-50/60 text-rose-700 hover:bg-rose-100 hover:text-rose-800"),onClick:()=>T(L),children:[e.jsx(Le,{className:"h-5 w-5 shrink-0 text-rose-600","aria-hidden":!0}),"Excluir seleção da galeria"]}):null]}),te=e.jsxs(e.Fragment,{children:[e.jsxs(m,{type:"button",variant:"default",className:K(w("continue")),onClick:()=>T(y),children:[e.jsx(wt,{className:"h-5 w-5 shrink-0","aria-hidden":!0}),"Continuar fluxo"]}),e.jsxs(m,{type:"button",variant:"outline",className:N(K(w("cart")),!w("cart")&&"border-violet-200 text-violet-900 hover:bg-violet-50"),onClick:()=>T(D),children:[e.jsx(qt,{className:"h-5 w-5 shrink-0","aria-hidden":!0}),"Carrinho"]}),e.jsxs(m,{type:"button",variant:"outline",className:N(K(w("schedule")),!w("schedule")&&"border-emerald-200 bg-emerald-50/40 text-emerald-950 hover:bg-emerald-50"),onClick:()=>T(E),children:[e.jsx(Fe,{className:"h-5 w-5 shrink-0 text-emerald-700","aria-hidden":!0}),"Agendar"]}),e.jsxs(m,{type:"button",variant:"outline",className:N(K(w("operation")),!w("operation")&&"border-fuchsia-200 bg-fuchsia-50/40 text-fuchsia-950 hover:bg-fuchsia-50"),onClick:()=>T(F),children:[e.jsx(ot,{className:"h-5 w-5 shrink-0 text-fuchsia-700","aria-hidden":!0}),"Operação"]})]});return e.jsxs(no,{storageKey:"smartoferta:fab-pos:offers-cart-dock",defaultAlign:"right",defaultBottom:112,className:"pointer-events-none max-md:!right-auto max-md:!left-auto max-md:!translate-x-0",desktopClassName:"bottom-6 left-1/2 -translate-x-1/2 md:left-auto md:right-6 md:w-[440px] md:translate-x-0",children:[e.jsx("div",{className:"pointer-events-auto md:hidden",children:e.jsxs(na,{open:he,onOpenChange:J,children:[e.jsx(Yn,{asChild:!0,children:e.jsx(oc,{count:$e,expanded:he,controlsId:"offers-cart-dock-sheet"})}),e.jsxs(la,{id:"offers-cart-dock-sheet",side:"bottom",className:"z-[200] max-h-[min(88vh,32rem)] gap-0 overflow-y-auto rounded-t-2xl border-violet-100 p-0 pt-2 shadow-2xl",children:[e.jsxs(ca,{className:"space-y-1 border-b border-violet-100 px-4 pb-3 pt-1 text-left",children:[e.jsx(da,{className:"text-lg font-black text-slate-900",children:xe?"Para onde levar":"Carrinho rápido"}),e.jsx(ma,{className:"text-sm leading-snug text-slate-600",children:xe?`${g} oferta${g===1?"":"s"} marcada${g===1?"":"s"}. Escolha Converter Link, Gerar Banner, Prompt, piloto automático ou Agendamento.`:`${d} no carrinho · ${n} na pesquisa · ${ce} em potencial.`})]}),e.jsxs("div",{className:"flex flex-col gap-2.5 px-4 py-4 pb-[max(1.25rem,env(safe-area-inset-bottom))]",children:[xe?nt:te,e.jsx("div",{className:"my-1 h-px bg-violet-100","aria-hidden":!0}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsx(st,{variant:"light",label:"Pesquisa",value:String(n),onPress:ae?()=>T(ae):void 0}),e.jsx(st,{variant:"light",label:"Carrinho",value:String(d),onPress:z?()=>T(z):void 0}),e.jsx(st,{variant:"light",label:"Biblioteca",value:String(g),onPress:se?()=>T(se):void 0}),e.jsx(st,{variant:"light",label:"Prontas",value:String(h),onPress:z?()=>T(z):void 0})]})]})]})]})}),e.jsxs("div",{className:"pointer-events-auto hidden w-[440px] overflow-hidden rounded-[24px] border border-violet-400/20 bg-violet-950 text-white shadow-[0_24px_80px_rgba(59,7,100,0.42)] md:block",children:[e.jsxs("button",{type:"button",onClick:r,className:"flex w-full items-center justify-between gap-3 px-4 py-4 text-left touch-manipulation",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex h-11 w-11 items-center justify-center rounded-2xl bg-white/10 text-violet-100",children:e.jsx(qt,{className:"h-5 w-5","aria-hidden":!0})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-black uppercase tracking-[0.18em] text-violet-200",children:xe?"Para onde levar":"Carrinho rápido"}),e.jsx("p",{className:"text-sm font-bold text-white",children:xe?`${g} oferta${g===1?"":"s"} na galeria`:`${d} no carrinho ⢠${h} prontas ⢠${ce} em potencial`})]})]}),ee>0?e.jsx("span",{className:"rounded-full bg-violet-400/30 px-2 py-0.5 text-[10px] font-black tabular-nums text-violet-100",children:ee}):null,e.jsx(Ce,{className:N("h-5 w-5 shrink-0 text-violet-200 transition-transform",s&&"rotate-180"),"aria-hidden":!0})]}),s?e.jsxs("div",{className:"space-y-4 border-t border-white/10 px-4 py-4",children:[e.jsxs("div",{className:"rounded-[18px] border border-white/10 bg-white/10 px-4 py-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-violet-100",children:[e.jsx(Rs,{className:"h-4 w-4","aria-hidden":!0}),e.jsx("span",{className:"text-xs font-black uppercase tracking-[0.18em]",children:"Leitura comercial rápida"})]}),e.jsx("p",{className:"mt-2 text-lg font-black text-white",children:ce}),e.jsxs("p",{className:"mt-1 text-xs text-violet-200/90",children:["Potencial somado das ofertas prontas para seguir. Melhor comissão atual:"," ",k,"."]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3 sm:grid-cols-3",children:[e.jsx(st,{label:"Marcadas na pesquisa",value:String(n),onPress:ae,ariaLabel:`Ver ofertas marcadas na pesquisa: ${n}`}),e.jsx(st,{label:"Marcadas para ação",value:String(u),onPress:z,ariaLabel:`Ver ofertas marcadas para ação no carrinho: ${u}`}),e.jsx(st,{label:"No carrinho",value:String(d),onPress:z,ariaLabel:`Ver ofertas no carrinho: ${d}`}),e.jsx(st,{label:"Prontas",value:String(h),onPress:z,ariaLabel:`Ver ofertas prontas no carrinho: ${h}`}),e.jsx(st,{label:"Bloqueadas",value:String(x),onPress:z,ariaLabel:`Ver ofertas bloqueadas no carrinho: ${x}`}),e.jsx(st,{label:"Na biblioteca",value:String(g),onPress:se,ariaLabel:`Ver ofertas em foco na biblioteca: ${g}`})]}),e.jsx("div",{className:N("grid gap-2",xe?"sm:grid-cols-2":"sm:grid-cols-4"),children:xe?e.jsxs(e.Fragment,{children:[e.jsxs("button",{type:"button",onClick:H,"aria-label":"Converter oferta selecionada",title:"Converter link",className:N(He,"border border-white/15 bg-white/10 text-white hover:bg-white/15"),children:[e.jsx(Ps,{className:"h-5 w-5 shrink-0","aria-hidden":!0}),e.jsx("span",{children:"Converter"})]}),O?e.jsxs("button",{type:"button",onClick:O,"aria-label":"Gerar banner da oferta selecionada",title:"Gerar banner",className:N(He,"bg-white text-violet-900 hover:bg-violet-50"),children:[e.jsx(As,{className:"h-5 w-5 shrink-0","aria-hidden":!0}),e.jsx("span",{children:"Banner"})]}):null,ue?e.jsxs("button",{type:"button",onClick:ue,"aria-label":"VÃdeo ou carrossel no Studio",title:"Prompt / Estúdio UGC",className:N(He,"border border-sky-300/40 bg-sky-500/20 text-sky-50 hover:bg-sky-500/30"),children:[e.jsx(Ci,{className:"h-5 w-5 shrink-0","aria-hidden":!0}),e.jsx("span",{children:"Prompt"})]}):null,e.jsxs("button",{type:"button",onClick:E,"aria-label":"Agendar envio da seleção",title:"Agendar","aria-pressed":w("schedule"),className:N(He,js(w("schedule"))),children:[e.jsx(Fe,{className:"h-5 w-5 shrink-0","aria-hidden":!0}),e.jsx("span",{children:"Agendar"})]}),$?e.jsxs("button",{type:"button",onClick:$,disabled:!re,"aria-label":"Enviar ao piloto automático",title:"Piloto automático",className:N(He,"border border-fuchsia-300/40 bg-fuchsia-500/20 text-fuchsia-50 hover:bg-fuchsia-500/30 disabled:opacity-50"),children:[e.jsx(ot,{className:"h-5 w-5 shrink-0","aria-hidden":!0}),e.jsx("span",{children:"Piloto"})]}):null,A?e.jsxs("button",{type:"button",onClick:A,"aria-label":"Favoritar sele
46ção",title:"Favoritar",className:N(He,"bg-white text-violet-900 hover:bg-violet-50"),children:[e.jsx(jt,{className:"h-5 w-5 shrink-0","aria-hidden":!0}),e.jsx("span",{children:"Favoritar"})]}):null,L?e.jsxs("button",{type:"button",onClick:L,"aria-label":"Excluir selecionadas da galeria",title:"Excluir seleção",className:N(He,"border border-rose-400/30 bg-rose-500/20 text-rose-100 hover:bg-rose-500/30"),children:[e.jsx(Le,{className:"h-5 w-5 shrink-0 text-rose-300","aria-hidden":!0}),e.jsx("span",{children:"Excluir"})]}):null]}):e.jsxs(e.Fragment,{children:[e.jsxs("button",{type:"button",onClick:y,"aria-label":"Continuar fluxo",title:"Continuar fluxo","aria-pressed":w("continue"),className:N(He,w("continue")?"bg-violet-400 text-white shadow-[0_0_22px_rgba(167,139,250,0.65)] ring-2 ring-violet-200/80":"bg-white text-violet-900 hover:bg-violet-50"),children:[e.jsx(wt,{className:"h-5 w-5 shrink-0","aria-hidden":!0}),e.jsx("span",{children:"Continuar"})]}),e.jsxs("button",{type:"button",onClick:D,"aria-label":"Ver carrinho",title:"Ver carrinho â aba Selecionadas","aria-pressed":w("cart"),className:N(He,js(w("cart"))),children:[e.jsx(qt,{className:"h-5 w-5 shrink-0","aria-hidden":!0}),e.jsx("span",{children:"Carrinho"})]}),e.jsxs("button",{type:"button",onClick:E,"aria-label":"Agendar",title:"Agendar","aria-pressed":w("schedule"),className:N(He,js(w("schedule"))),children:[e.jsx(Fe,{className:"h-5 w-5 shrink-0","aria-hidden":!0}),e.jsx("span",{children:"Agendar"})]}),e.jsxs("button",{type:"button",onClick:F,"aria-label":"Ir para operação",title:"Ir para operação","aria-pressed":w("operation"),className:N(He,js(w("operation"))),children:[e.jsx(ot,{className:"h-5 w-5 shrink-0","aria-hidden":!0}),e.jsx("span",{children:"Operação"})]})]})})]}):null]})]})}const lc="smartoferta:miningFabPosition";function cc({count:s,busy:r,canUsePoolActions:n=!0,onAgenda:u,onContacts:d,onOperation:h,onAddToCart:x,onImportLibrary:g,onClearSelection:M,onGoToShopeeCaptura:f}){return e.jsxs(no,{storageKey:lc,defaultAlign:"center",defaultBottom:112,className:"pointer-events-auto flex max-w-[min(100vw-1rem,380px)] items-center gap-1 rounded-full border border-violet-400/40 bg-violet-950/95 px-1.5 py-1 shadow-[0_12px_40px_rgba(59,7,100,0.45)] backdrop-blur-md md:hidden",children:[e.jsx("span",{className:"flex h-10 min-h-10 w-7 shrink-0 cursor-grab touch-none items-center justify-center rounded-l-full border-r border-white/10 text-violet-300 active:cursor-grabbing","aria-hidden":!0,children:e.jsx(Ol,{className:"h-5 w-5 shrink-0 opacity-80"})}),e.jsx("span",{className:"min-w-[2rem] px-1 text-center text-[11px] font-black tabular-nums text-violet-200",children:s}),e.jsxs(Dt,{children:[e.jsx(Ft,{asChild:!0,children:e.jsx(m,{type:"button",size:"icon",variant:"ghost",disabled:r||s===0,className:"h-10 min-h-10 w-10 min-w-10 shrink-0 rounded-full text-white hover:bg-white/10","aria-label":"Mais opções",children:r?e.jsx(De,{className:"h-4 w-4 animate-spin","aria-hidden":!0}):e.jsx(Ua,{className:"h-5 w-5","aria-hidden":!0})})}),e.jsxs($t,{align:"start",className:"z-[200] w-56",children:[f?e.jsx(be,{onClick:f,disabled:r,children:"Ir para Shopee Captura"}):null,e.jsx(be,{onClick:x,disabled:!n||r||s===0,children:"Enviar seleção ao carrinho"}),e.jsx(be,{onClick:()=>void g(),disabled:!n||r||s===0,children:"Importar direto para a biblioteca"}),e.jsx(be,{onClick:M,disabled:r||s===0,className:"text-rose-600 focus:text-rose-700",children:"Limpar seleção da pesquisa"})]})]}),e.jsx("div",{className:"mx-0.5 h-7 w-px bg-white/15","aria-hidden":!0}),f?e.jsx(m,{type:"button",size:"icon",variant:"ghost",disabled:r,className:"h-10 min-h-10 w-10 min-w-10 shrink-0 touch-manipulation rounded-full text-white hover:bg-violet-600/80","aria-label":"Ir para Shopee Captura",title:"Shopee Captura",onClick:f,children:e.jsx(Ts,{className:"h-5 w-5"})}):null,e.jsx(m,{type:"button",size:"icon",variant:"ghost",disabled:r||s===0||!n,className:"h-10 min-h-10 w-10 min-w-10 shrink-0 rounded-full text-white hover:bg-violet-600/80","aria-label":"Escolher ofertas e agendar",title:"Agendar",onClick:()=>void u(),children:e.jsx(Fe,{className:"h-5 w-5"})}),e.jsx(m,{type:"button",size:"icon",variant:"ghost",disabled:r||s===0||!n,className:"h-10 min-h-10 w-10 min-w-10 shrink-0 rounded-full text-white hover:bg-violet-600/80","aria-label":"Destinos e contatos",title:"Contatos / destinos",onClick:()=>void d(),children:e.jsx(Xn,{className:"h-5 w-5"})}),e.jsx(m,{type:"button",size:"icon",variant:"ghost",disabled:r||s===0||!n,className:"h-10 min-h-10 w-10 min-w-10 shrink-0 rounded-full text-white hover:bg-fuchsia-600/90","aria-label":"Operação e envio",title:"Operação",onClick:()=>void h(),children:e.jsx(qt,{className:"h-5 w-5"})})]})}function dc({open:s,onOpenChange:r,candidates:n,includedIds:u,onToggle:d,onConfirmSchedule:h,busy:x}){const g=new Set(u);return e.jsx(na,{open:s,onOpenChange:r,children:e.jsxs(la,{side:"bottom",className:"flex max-h-[88dvh] touch-manipulation flex-col gap-0 rounded-t-[24px] border-violet-200 p-0",children:[e.jsxs(ca,{className:"border-b border-violet-100 px-4 pb-3 pt-4 text-left",children:[e.jsx(da,{className:"text-lg",children:"Quem entra
46no agendamento?"}),e.jsx(ma,{children:"Toque para incluir ou tirar. Miniaturas compactas para ver várias ofertas no celular."})]}),e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-3 overflow-hidden px-4 py-3",children:[e.jsx("div",{className:"flex gap-2 overflow-x-auto pb-1 [-webkit-overflow-scrolling:touch]",children:n.map(M=>{const f=g.has(M.id);return e.jsxs("button",{type:"button",onClick:()=>d(M.id),className:`relative w-[76px] shrink-0 overflow-hidden rounded-xl border text-left transition-all touch-manipulation active:opacity-90 ${f?"border-violet-500 ring-2 ring-violet-300":"border-violet-100 opacity-75"}`,children:[e.jsx("div",{className:"aspect-square bg-violet-50",children:M.productImage?e.jsx("img",{src:uo(M.productImage),alt:"",className:"h-full w-full object-cover",loading:"lazy",decoding:"async",referrerPolicy:"no-referrer"}):e.jsx("div",{className:"flex h-full items-center justify-center text-[9px] text-slate-400",children:"Sem img"})}),e.jsx("p",{className:"line-clamp-2 min-h-[2rem] px-1 py-1 text-[9px] font-semibold leading-tight text-slate-800",children:M.productTitle||"Sem tÃtulo"}),f?e.jsx("span",{className:"absolute right-1 top-1 flex h-5 w-5 items-center justify-center rounded-full bg-violet-600 text-white shadow",children:e.jsx(Ss,{className:"h-3 w-3","aria-hidden":!0})}):e.jsx("span",{className:"absolute right-1 top-1 flex h-5 w-5 items-center justify-center rounded-full bg-black/40 text-[10px] font-bold text-white",children:"â"})]},M.id)})}),e.jsxs("p",{className:"text-xs text-slate-500",children:[u.length," de ",n.length," marcada(s) para levar à operação e ao painel de agendamento."]})]}),e.jsxs(Zn,{className:"flex-row gap-2 border-t border-violet-100 px-4 pt-3 pb-[max(12px,env(safe-area-inset-bottom,0px))]",children:[e.jsx(m,{type:"button",variant:"outline",className:"h-11 min-h-11 flex-1 rounded-xl touch-manipulation",onClick:()=>r(!1),children:"Voltar"}),e.jsx(m,{type:"button",className:"h-11 min-h-11 flex-1 rounded-xl touch-manipulation bg-violet-600 hover:bg-violet-700",disabled:x||u.length===0,onClick:h,children:"Continuar para agendar"})]})]})})}const mc="https://shop.tiktok.com/br",uc="https://shop.tiktok.com/br/c/phones-electronics/601739",Ki="smartoferta:tiktok-extension-capture-collapsed";function hc({onImportFromExtension:s,importing:r=!1}){const n=xo(),[u,d]=o.useState(()=>{if(typeof window>"u")return!0;const h=window.localStorage.getItem(Ki);return h==null?!0:h==="1"});return o.useEffect(()=>{typeof window>"u"||window.localStorage.setItem(Ki,u?"1":"0")},[u]),e.jsx("div",{className:N("overflow-hidden rounded-2xl border border-slate-800/20 bg-gradient-to-br from-slate-950 via-slate-900 to-fuchsia-950/40 text-white",u?"px-3 py-2":"p-3 md:p-4"),children:u?e.jsxs("div",{className:"flex min-h-11 items-center gap-2",children:[e.jsx(ua,{className:"h-4 w-4 shrink-0 text-fuchsia-200","aria-hidden":!0}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-[13px] font-bold leading-none",children:"TikTok Shop"}),e.jsx(m,{type:"button",size:"sm",disabled:r||!s,onClick:()=>void s?.(),className:"h-9 max-w-[46%] shrink touch-manipulation truncate rounded-lg bg-fuchsia-500 px-2.5 text-xs font-bold text-white hover:bg-fuchsia-400",children:r?"â¦":"Importar"}),e.jsx(m,{type:"button",variant:"outline",size:"icon",className:"h-9 w-9 shrink-0 touch-manipulation rounded-lg border-white/25 bg-white/5 text-white hover:bg-white/10",onClick:()=>d(!1),"aria-label":"Expandir TikTok Shop",title:"Expandir",children:e.jsx(Ce,{className:"h-4 w-4","aria-hidden":!0})})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-start gap-2.5",children:[e.jsx("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-xl bg-white/10",children:e.jsx(ua,{className:"h-4 w-4","aria-hidden":!0})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsx("p",{className:"text-sm font-bold tracking-tight",children:"Ofertas do TikTok Shop"}),e.jsx(m,{type:"button",variant:"outline",size:"icon",className:"h-8 w-8 shrink-0 touch-manipulation rounded-lg border-white/25 bg-white/5 text-white hover:bg-white/10",onClick:()=>d(!0),"aria-label":"Minimizar TikTok Shop",title:"Minimizar",children:e.jsx(Sr,{className:"h-4 w-4","aria-hidden":!0})})]}),e.jsxs("p",{className:"mt-0.5 text-[11px] leading-snug text-slate-200/90 md:text-[12px]",children:["Capture com a extensão e importe aqui â vai para a"," ",e.jsx("span",{className:"font-semibold text-white",children:"Galeria"})," e a"," ",e.jsx("span",{className:"font-semibold text-white",children:"Vitrine"}),". No iPhone, use o atalho (bookmarklet) da Galeria na página do produto."]})]})]}),e.jsxs("ol",{className:"mt-2.5 space-y-1 text-[11px] leading-snug text-slate-300",children:[e.jsx("li",{children:"1. Abra a loja, entre na conta e navegue categorias/busca."}),e.jsxs("li",{children:["2. Extensão â ",e.jsx("strong",{className:"text-white",children:"Capturar"}),"."]}),e.jsxs("li",{children:["3. Volte e toque em"," ",e.jsx("strong",{className:"text-white",children:"Importar"}),"."]})]}),e.jsxs("div",{className:"mt-3 grid grid-cols-1 gap-2 min-[380px]:grid-cols-2",children:[e.jsx(m,{asChild:!0,className:"h-10 min-h-10 w-full min-w-0 touch-manipulation truncate rounded-xl bg-white px-2 text-xs font-semibold text-slate-900 hover:bg-slate-100 sm:text-sm",children:e.jsxs("a",{href:mc,target:"_blank",rel:"noreferrer",children:[e.jsx(Ja,{className:"mr-1.5 h-3.5 w-3.5 shrink-0","aria-hidden":!0}),e.jsx("span",{className:"truncate",children:"Abrir TikTok"})]})}),e.jsx(m,{asChild:!0,variant:"outline",className:"h-10 min-h-10 w-full min-w-0 touch-manipulation truncate rounded-xl border-white/25 bg-white/5 px-2 text-xs font-semibold text-white hover:bg-white/10 sm:text-sm",children:e.jsx("a",{href:uc,target:"_blank",rel:"noreferrer",children:e.jsx("span",{className:"truncate",children:"Exemplo categoria"})})}),e.jsxs(m,{type:"button",disabled:r||!s,onClick:()=>void s?.(),className:"h-10 min-h-10 w-full min-w-0 touch-manipulation truncate rounded-xl bg-fuchsia-500 px-2 text-xs font-bold text-white hover:bg-fuchsia-400 min-[380px]:col-span-2 sm:text-sm",children:[e.jsx(Os,{className:"mr-1.5 h-3.5 w-3.5 shrink-0","aria-hidden":!0}),e.jsx("span",{className:"truncate",children:r?"Importandoâ¦":"Importar da extensão"})]})]}),e.jsxs("p",{className:"mt-2 text-[11px] leading-snug text-slate-400",children:["Sem a extensão?"," ",e.jsx("a",{href:n,target:"_blank",rel:"noreferrer",className:"font-semibold text-fuchsia-200 underline-offset-2 hover:underline",children:"Instalar SmartOferta Capture"})]})]})})}const xc="https://br.shein.com/",pc="https://br.shein.com/pdsearch/vestido/",Yi="smartoferta:shein-extension-capture-collapsed";function bc({onImportFromExtension:s,importing:r=!1}
46){const n=xo(),[u,d]=o.useState(()=>{if(typeof window>"u")return!0;const h=window.localStorage.getItem(Yi);return h==null?!0:h==="1"});return o.useEffect(()=>{typeof window>"u"||window.localStorage.setItem(Yi,u?"1":"0")},[u]),e.jsx("div",{className:N("overflow-hidden rounded-2xl border border-slate-800/20 bg-gradient-to-br from-slate-950 via-neutral-900 to-rose-950/35 text-white",u?"px-3 py-2":"p-3 md:p-4"),children:u?e.jsxs("div",{className:"flex min-h-11 items-center gap-2",children:[e.jsx(ua,{className:"h-4 w-4 shrink-0 text-rose-200","aria-hidden":!0}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-[13px] font-bold leading-none",children:"Shein"}),e.jsx(m,{type:"button",size:"sm",disabled:r||!s,onClick:()=>void s?.(),className:"h-9 max-w-[46%] shrink touch-manipulation truncate rounded-lg bg-rose-500 px-2.5 text-xs font-bold text-white hover:bg-rose-400",children:r?"â¦":"Importar"}),e.jsx(m,{type:"button",variant:"outline",size:"icon",className:"h-9 w-9 shrink-0 touch-manipulation rounded-lg border-white/25 bg-white/5 text-white hover:bg-white/10",onClick:()=>d(!1),"aria-label":"Expandir Shein",title:"Expandir",children:e.jsx(Ce,{className:"h-4 w-4","aria-hidden":!0})})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-start gap-2.5",children:[e.jsx("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-xl bg-white/10",children:e.jsx(ua,{className:"h-4 w-4","aria-hidden":!0})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsx("p",{className:"text-sm font-bold tracking-tight",children:"Ofertas da Shein"}),e.jsx(m,{type:"button",variant:"outline",size:"icon",className:"h-8 w-8 shrink-0 touch-manipulation rounded-lg border-white/25 bg-white/5 text-white hover:bg-white/10",onClick:()=>d(!0),"aria-label":"Minimizar Shein",title:"Minimizar",children:e.jsx(Sr,{className:"h-4 w-4","aria-hidden":!0})})]}),e.jsxs("p",{className:"mt-0.5 text-[11px] leading-snug text-slate-200/90 md:text-[12px]",children:["Capture com a extensão e importe aqui â vai para a"," ",e.jsx("span",{className:"font-semibold text-white",children:"Galeria"})," e a"," ",e.jsx("span",{className:"font-semibold text-white",children:"Vitrine"}),". A % de comissão não é inventada: valide no Centro de Afiliados Shein. No iPhone, use o atalho (bookmarklet) da Galeria na página do produto."]})]})]}),e.jsxs("ol",{className:"mt-2.5 space-y-1 text-[11px] leading-snug text-slate-300",children:[e.jsxs("li",{children:["1. Cadastre o ID KOC na"," ",e.jsx("strong",{className:"text-white",children:"Central do Afiliado"}),"."]}),e.jsxs("li",{children:["2. Abra a Shein, navegue e use a extensão â"," ",e.jsx("strong",{className:"text-white",children:"Capturar"}),"."]}),e.jsxs("li",{children:["3. Volte e toque em"," ",e.jsx("strong",{className:"text-white",children:"Importar"}),"."]})]}),e.jsxs("div",{className:"mt-3 grid grid-cols-1 gap-2 min-[380px]:grid-cols-2",children:[e.jsx(m,{asChild:!0,className:"h-10 min-h-10 w-full min-w-0 touch-manipulation truncate rounded-xl bg-white px-2 text-xs font-semibold text-slate-900 hover:bg-slate-100 sm:text-sm",children:e.jsxs("a",{href:xc,target:"_blank",rel:"noreferrer",children:[e.jsx(Ja,{className:"mr-1.5 h-3.5 w-3.5 shrink-0","aria-hidden":!0}),e.jsx("span",{className:"truncate",children:"Abrir Shein"})]})}),e.jsx(m,{asChild:!0,variant:"outline",className:"h-10 min-h-10 w-full min-w-0 touch-manipulation truncate rounded-xl border-white/25 bg-white/5 px-2 text-xs font-semibold text-white hover:bg-white/10 sm:text-sm",children:e.jsx("a",{href:pc,target:"_blank",rel:"noreferrer",children:e.jsx("span",{className:"truncate",children:"Busca (exemplo)"})})}),e.jsxs(m,{type:"button",disabled:r||!s,onClick:()=>void s?.(),className:"h-10 min-h-10 w-full min-w-0 touch-manipulation truncate rounded-xl bg-rose-500 px-2 text-xs font-bold text-white hover:bg-rose-400 min-[380px]:col-span-2 sm:text-sm",children:[e.jsx(Os,{className:"mr-1.5 h-3.5 w-3.5 shrink-0","aria-hidden":!0}),e.jsx("span",{className:"truncate",children:r?"Importandoâ¦":"Importar da extensão"})]})]}),e.jsxs("p",{className:"mt-2 text-[11px] leading-snug text-slate-400",children:["Sem a extensão?"," ",e.jsx("a",{href:n,target:"_blank",rel:"noreferrer",className:"font-semibold text-rose-200 underline-offset-2 hover:underline",children:"Instalar SmartOferta Capture"})]})]})})}const vo=["shopee","amazon","magalu","mercadolivre"],gc=[...vo,"tiktokshop","shein"],fc=["story-clean-01","
46story-instagram-01","story-instagram-02","story-copa_01","story-copa_02","story-copa_03","story-03","story-04","story-mercadolivre-01","story-magalu-02","story-amazon-01","story-shopee-01","story-shopee-02","story-shopee-03","story-shopee-04","feed-clean-01","feed-premium-01"],Xi="smartoferta:offers-ui",Zi="smartoferta:offers-shopee-extension-collapsed";function vc(s){if(!s||typeof s!="object")return[];const r=s.vitrineCartIds;return Array.isArray(r)?r.map(n=>Number(n)).filter(n=>Number.isFinite(n)&&n>0):[]}function eo(s){const r=[],n=new Set;for(const u of s){const d=typeof u=="number"&&Number.isFinite(u)?u:Number(u);if(!Number.isFinite(d)||d<=0)continue;const h=Math.trunc(d);n.has(h)||(n.add(h),r.push(h))}return r}function jc(s,r){if(!s.length||!r.length)return s;const n=new Map;r.forEach((d,h)=>{n.has(d)||n.set(d,h)});const u=d=>{const h=Number(d?.id||0),x=Number(d?.sourceOfferId||0),g=h>0?n.get(h):void 0,M=x>0?n.get(x):void 0,f=[g,M].filter(y=>typeof y=="number");return f.length?Math.min(...f):999999};return[...s].sort((d,h)=>u(d)-u(h)||Number(h?.id||0)-Number(d?.id||0))}function to(s,r){const n=new Map;for(const u of s){const d=Number(u?.id||0),h=Number(u?.sourceOfferId||0);if(d){if(r.has(d)){n.set(d,u);continue}h>0&&r.has(h)&&n.set(d,u)}}return Array.from(n.values())}function Sd(){const s=Hn(),r=Wn(),n=q.useUtils(),u=il(),[d,h]=o.useState(""),x=o.useDeferredValue(d),[g,M]=o.useState([]),[f,y]=o.useState([]),[D,E]=o.useState(!1),[F,ae]=o.useState(!1),[z,se]=o.useState(!1),[_,W]=o.useState(null),H=o.useRef(""),[O,ue]=o.useState(!1),[$,re]=o.useState(["telegram"]),[A,L]=o.useState([]),[he,J]=o.useState({}),[w,le]=o.useState(""),[T,ce]=o.useState(""),[k,ee]=o.useState(""),[$e,xe]=o.useState(""),[K,nt]=o.useState("telegram"),[te,Pe]=o.useState("maiorComissao"),[I,ze]=o.useState(!1),[xa,ge]=o.useState(""),[Bt,yt]=o.useState(""),lt=o.useRef(!1),Ka=o.useRef(null),[kt,Ct]=o.useState(""),[pa,de]=o.useState(""),[ct,Ke]=o.useState(()=>{if(typeof window>"u")return!0;try{if(window.location.hash.includes("extension-capture"))return!1;const t=window.localStorage.getItem(Zi);return t!=="0"}catch{return!0}}),[St,ba]=o.useState([]),[we,ga]=o.useState(30),[qe,Ye]=o.useState(new Date().toISOString().slice(0,10)),[pe,dt]=o.useState("09:00"),[Be,Pt]=o.useState("22:30"),[me,Me]=o.useState("biblioteca"),[fa,Vt]=o.useState(!1),[va,Mt]=o.useState(!1),[ja,l]=o.useState(!1),[S,U]=o.useState(!0),[At,Na]=o.useState(!1),[Es,Ve]=o.useState(!1),[Mr,_e]=o.useState("library"),[No,wa]=o.useState(!1),[wo,ya]=o.useState(!1),[Ar,Ir]=o.useState(!1),[_t,Or]=o.useState(""),[It,Tr]=o.useState(""),[Ls,Ds]=o.useState(""),[yo,Fs]=o.useState(!1),[bt,Rr]=o.useState(["shopee","mercadolivre"]),[ie,Ut]=o.useState([]),[Ya,Er]=o.useState(12),[Xa,Lr]=o.useState(!0),[B,Gt]=o.useState([]),[ko,$s]=o.useState(!1),[Dr,Co]=o.useState([]),[Za,Fr]=o.useState([]),[So,Qt]=o.useState(!1),[es,$r]=o.useState(null),[ka,zs]=o.useState(""),[Ca,zr]=o.useState("menorPreco"),[Ht,qr]=o.useState(0),[Sa,Br]=o.useState(""),[Pa,Vr]=o.useState(""),[Wt,_r]=o.useState(0),[Ma,qs]=o.useState([]),[Aa,ts]=o.useState([]),[Y,Xe]=o.useState([]),[mt,ye]=o.useState([]),[Ia,Oa]=o.useState(""),[Ta,Ra]=o.useState([]),[Ea,La]=o.useState([]),Bs=o.useRef(null),Ur=o.useRef(null),Vs=o.useRef(null),_s=o.useRef(null),Da=o.useRef(null),Po=o.useRef(null),Us=o.useRef(null),Gs=o.useRef(!1),Gr=o.useRef(null),Qr=o.useRef((t,a)=>{Gr.current?.(t,a)}).current,Hr=o.useRef(()=>{}),Wr=o.useRef(t=>{Hr.current(t)}).current,Ze=q.offers.listMine.useQuery({limit:500},{staleTime:6e4,refetchOnWindowFocus:!1}),Qs=q.offers.listCopyTemplates.useQuery(void 0,{staleTime:5*6e4,refetchOnWindowFocus:!1}),Jt=q.access.me.useQuery(void 0,{staleTime:6e4,refetchOnWindowFocus:!1}),Mo=o.useMemo(()=>!!Jt.data?.features?.includes("community.premium"),[Jt.data?.features]),{user:Fa}=el(),Ae=Mo||Fa?.role==="admin",Hs=o.useMemo(()=>!!Jt.data?.features?.includes("operations.autopilot"),[Jt.data?.features]),Ao=o.useMemo(()=>Fa?.role==="admin"||!!Jt.data?.features?.includes("operations.link_mirror"),[Jt.data?.features,Fa?.role]),Jr=Ae,Kt=jl(),Kr=q.whatsappApi.getStatus.useQuery(void 0,{enabled:z,refetchInterval:u&&z?8e3:!1,refetchOnWindowFocus:z}),Yr=String(Kr.data?.status||"").toUpperCase()==="CONNECTED",Io=q.miner.sendLibraryOffersToAutopilot.useMutation(),Xr=q.whatsappApi.getGroups.useQuery(void 0,{enabled:z&&Yr,staleTime:3e4}),as=q.miner.getMinedOffers.useQuery({platforms:bt.length>0?bt:void 0,categories:ie.length>0?ie:void 0,search:_t.trim()||void 0,limit:500,sort:te==="maisVendidos"?"mostSold":"recent"},{enabled:es!=null||bt.length>0||ie.length>0||_t.trim().length>=2,refetchOnWindowFocus:!1,staleTime:6e4}),Zr=q.miner.getQueue.useQuery(void 0,{staleTime:3e4,refetchOnWindowFocus:!1,refetchInterval:u?15e3:!1}),Ot=q.miner.getSchedulePreferences.useQuery(void 0,{staleTime:6e4,refetchOnWindowFocus:!0}),ei=o.useRef(!1),Te=q.offers.getAvailableDestinations.useQuery({channels:$.filter(t=>t==="whatsapp"||t==="telegram")},{enabled:va||me==="operacao"||f.length>0,staleTime:6e4,refetchOnWindowFocus:!1}),ti=q.whatsappApi.getGroups.useQuery(void 0,{enabled:$.includes("whatsapp"),staleTime:300*1e3}),ai=q.whatsappApi.getStatus.useQuery(void 0,{enabled:$.includes("whatsapp"),refetchInterval:u&&$.includes("whatsapp")?8e3:!1,staleTime:1e4,refetchOnWindowFocus:!1}),ss=q.whatsappApi.startSession.useMutation({onSuccess:async()=>{await Promise.all([n.whatsappApi.getStatus.invalidate(),n.whatsappApi.getGroups.invalidate(),n.offers.getAvailableDestinations.invalidate()])},onError:t=>{b(`â ï¸ Não foi possÃvel conectar o WhatsApp automaticamente: ${t.message}`,5e3),lt.current=!1}}),rs=q.whatsappApi.startPairingSession.useMutation({onSuccess:async()=>{await Promise.all([n.whatsappApi.getStatus.invalidate(),n.whatsappApi.getGroups.invalidate(),n.offers.getAvailableDestinations.invalidate()])},onError:t=>{b(`â Falha no pareamento por número: ${t.message}`,5e3)}});o.useEffect(()=>{!Ot.data||ei.current||(ei.current=!0,ga(Ot.data.intervalMinutes),dt(Ot.data.startHour),Pt(Ot.data.endHour))},[Ot.data]),o.useEffect(()=>{const t=Ot.data?.destinationCategories;if(!t)return;const a=Te.data??[];J(i=>{const p={...i};for(const c of A){if((p[c]?.length??0)>0)continue;const j=a.find(P=>P.chatId===c);if(!j)continue;const v=j.provider==="whatsapp"?"whatsapp":j.provider==="telegram"?"telegram":null;if(!v)continue;const C=xl(t,v,[c])[c];C?.length&&(p[c]=C)}return p})},[Ot.data?.destinationCategories,A,Te.data]),o.useEffect(()=>{if(!(typeof window>"u"))try{window.localStorage.setItem(Zi,ct?"1":"0")}catch{}},[ct]),o.useEffect(()=>{if(!$.includes("whatsapp")){lt.current=!1;return}lt.current||ss.isPending||(lt.current=!0,ss.mutate())},[$,ss]),o.useEffect(()=>{function t(a){Bs.current&&!Bs.current.contains(a.target)&&Fs(!1)}return document.addEventListener("mousedown",t),()=>{document.removeEventListener("mousedown",t)}},[]),o.useEffect(()=>{const t=new URLSearchParams(s.search);if(t.get("tab")==="cart"){Me("selecionadas");return}t.get("tab")==="biblioteca"&&(Me("biblioteca"),_e("library"))},[s.search]),o.useEffect(()=>{const t=new URLSearchParams(s.search),a=t.get("mirror")==="1",i=Number(t.get("offerId")||0),p=String(t.get("offerIds")||"").split(",").map(v=>Number(v.trim())).filter(v=>Number.isFinite(v)&&v>0),c=p.length>0?p:i>0?[i]:[];if(!a&&c.length===0){H.current="";return}const j=`${s.search}::${c.join(",")}`;
46H.current!==j&&(H.current=j,Me("biblioteca"),_e("library"),Ve(!0),a&&ae(!0),c.length>0&&(y(c),E(!0),W(c[0]??null)))},[s.search]),o.useEffect(()=>{const t=s.hash.replace("#","").trim().toLowerCase();(t==="espelho"||t==="espelho-whatsapp"||t==="link-mirror")&&se(!0)},[s.hash]),o.useEffect(()=>{const{name:t,cap:a}=zl(s.hash);if(!$l.has(t))return;Me("biblioteca"),_e("library"),Ke(!1),window.setTimeout(()=>{document.getElementById("extension-capture")?.scrollIntoView({behavior:"smooth",block:"start"})},180);const i=new URLSearchParams(s.search),p=[t,i.get("extPlatform")||"",i.get("extAt")||"",i.get("extItems")||""].join("|");if(Ka.current===p)return;Ka.current=p;const c=!!i.get("extAt");if(c&&Vl(p))return;c&&_l(p);const j=window.setTimeout(()=>{(async()=>{let v=!1;if(a){const C=await Bl(a);C&&(v=Qo(C))}v||(v=await Yt()),!v&&(c&&Ul(p),Ke(!1),b("Não achámos a captura da extensão neste browser. No Orion: capture e importe no mesmo app â ou toque Copiar JSON na extensão e cole abaixo.",8e3),window.setTimeout(()=>{const C=document.getElementById("extension-json-paste");C?.scrollIntoView({behavior:"smooth",block:"center"}),C?.querySelector("textarea")?.focus()},200))})()},450);return()=>window.clearTimeout(j)},[s.hash,s.search]),o.useEffect(()=>{if(typeof window>"u")return;let t=[];try{const p=window.sessionStorage.getItem(mr);if(p){const c=JSON.parse(p);Array.isArray(c)&&(t=c.map(j=>Number(j)).filter(j=>Number.isFinite(j)&&j>0))}}catch{t=[]}const a=vc(s.state),i=Array.from(new Set([...t,...a]));try{const p=window.localStorage.getItem(Xi);if(!p){window.matchMedia("(max-width: 767px)").matches&&(U(!1),Na(!1),l(!1),Ve(!0)),i.length>0&&(Xe(Array.from(new Set(i))),ye(Array.from(new Set(i))),Oa(""),Ra([]),La([]),ge(`Seleção da Vitrine: ${i.length} oferta(s) no carrinho. Confira abaixo e siga para operação.`),window.setTimeout(()=>ge(""),5200)),Gs.current=!0;return}const c=JSON.parse(p);typeof c.search=="string"&&h(c.search),Array.isArray(c.selectedPlatforms)&&M(c.selectedPlatforms),(c.sortMode==="recentes"||c.sortMode==="maiorDesconto"||c.sortMode==="menorPreco"||c.sortMode==="maiorPreco"||c.sortMode==="maiorComissao"||c.sortMode==="menorDesconto"||c.sortMode==="maisVendidos")&&Pe(c.sortMode==="recentes"?"maiorComissao":c.sortMode),typeof c.libraryCompactMode=="boolean"&&ue(c.libraryCompactMode),typeof c.personalSearch=="string"&&Or(c.personalSearch),Array.isArray(c.personalSelectedPlatforms)&&Rr(c.personalSelectedPlatforms),Array.isArray(c.personalSelectedCategories)&&Ut(c.personalSelectedCategories),typeof c.personalLimit=="number"&&Er(c.personalLimit),typeof c.personalAvoidLowQuality=="boolean"&&Lr(c.personalAvoidLowQuality),c.appliedPersonalScope&&$r(c.appliedPersonalScope),typeof c.resultSearch=="string"&&zs(c.resultSearch);const j=["maiorComissaoValor","maiorComissaoPercentual","maiorDesconto","menorDesconto","menorPreco","maiorPreco","recentes"];if(typeof c.resultSortMode=="string"&&j.includes(c.resultSortMode)&&zr(c.resultSortMode),typeof c.resultMinCommissionPercent=="number"&&Number.isFinite(c.resultMinCommissionPercent)&&qr(Math.min(100,Math.max(0,Math.round(c.resultMinCommissionPercent)))),typeof c.resultMinPrice=="string"&&Br(c.resultMinPrice),typeof c.resultMaxPrice=="string"&&Vr(c.resultMaxPrice),typeof c.resultMinDiscountPercent=="number"&&Number.isFinite(c.resultMinDiscountPercent)&&_r(Math.min(100,Math.max(0,Math.round(c.resultMinDiscountPercent)))),Array.isArray(c.resultSelectedPlatforms)&&qs(c.resultSelectedPlatforms),Array.isArray(c.resultSelectedCategories)&&ts(c.resultSelectedCategories),Array.isArray(c.selectedCartIds)){const v=c.selectedCartIds.map(P=>Number(P)).filter(Boolean),C=Array.from(new Set([...v,...i]));Xe(C)}else i.length>0&&Xe(Array.from(new Set(i)));if(Array.isArray(c.cartActionIds)){const v=c.cartActionIds.map(P=>Number(P)).filter(Boolean),C=Array.from(new Set([...v,...i]));ye(C)}else i.length>0&&ye(Array.from(new Set(i)));typeof c.cartSearch=="string"&&Oa(c.cartSearch),Array.isArray(c.cartSelectedPlatforms)&&Ra(c.cartSelectedPlatforms),Array.isArray(c.cartSelectedCategories)&&La(c.cartSelectedCategories),typeof c.showQueueRadar=="boolean"&&l(c.showQueueRadar),typeof c.showResultFilters=="boolean"&&U(c.showResultFilters),typeof c.showCartFilters=="boolean"&&Na(c.showCartFilters),typeof c.showSelectionDock=="boolean"&&Ve(c.showSelectionDock),i.length>0&&(Oa(""),Ra([]),La([]),ge(`Seleção da Vitrine: ${i.length} oferta(s) no carrinho. Confira abaixo e siga para operação.`),window.setTimeout(()=>ge(""),5200)),a.length>0&&r(`${s.pathname}${s.search}`,{replace:!0,state:{}})}catch{}finally{Gs.current=!0}},[]),o.useEffect(()=>{if(typeof window>"u"||!Gs.current)return;const t={search:d,selectedPlatforms:g,sortMode:te,libraryCompactMode:O,personalSearch:_t,personalSelectedPlatforms:bt,personalSelectedCategories:ie,personalLimit:Ya,personalAvoidLowQuality:Xa,appliedPersonalScope:es,resultSearch:ka,resultSelectedPlatforms:Ma,resultSelectedCategories:Aa,selectedCartIds:Y,cartActionIds:mt,cartSearch:Ia,cartSelectedPlatforms:Ta,cartSelectedCategories:Ea,showQueueRadar:ja,showResultFilters:S,showCartFilters:At,showSelectionDock:Es,resultSortMode:Ca,resultMinCommissionPercent:Ht,resultMinPrice:Sa,resultMaxPrice:Pa,resultMinDiscountPercent:Wt};try{window.localStorage.setItem(Xi,JSON.stringify(t));try{Y.length>0&&window.sessionStorage.getItem(mr)&&window.sessionStorage.removeItem(mr)}catch{}}catch{}},[d,g,te,O,_t,bt,ie,Ya,Xa,es,ka,Ma,Aa,Y,mt,Ia,Ta,Ea,ja,S,At,Es,Ca,Ht,Sa,Pa,Wt]),o.useEffect(()=>{const t=new Set((Te.data||[]).map(a=>a.chatId));L(a=>a.filter(i=>t.has(i)))},[Te.data]),o.useEffect(()=>{const t=Te.data||[];t.length===1&&A.length===0&&L([t[0].chatId])},[Te.data,A.length]),o.useEffect(()=>{ye(t=>t.filter(a=>Y.includes(a)))},[Y]);function b(t,a=6500){ge(t),window.setTimeout(()=>ge(""),a)}function Oo(t,a){const i=Number(t||0);if(!i)return;if(!Ae){b("ð O carrinho a partir do catálogo da Vitrine requer o Elite. O catálogo é visÃvel para todos;
46 faça upgrade para importar e operar.",5500);return}const p=Y.includes(i);Xe(c=>Array.from(new Set([...c,i]))),a?.markForAction!==!1&&ye(c=>Array.from(new Set([...c,i]))),Ve(!0),a?.openCart&&V("selecionadas"),a?.showToast!==!1&&b(p?"ð Essa oferta já estava no carrinho operacional.":"ð Oferta adicionada ao carrinho operacional.",2600)}Gr.current=Oo;function $a(t,a){const i=t.map(p=>Number(p)).filter(Boolean);if(i.length){if(!Ae){b("ð O carrinho a partir do catálogo da Vitrine requer o Elite.",5500);return}Xe(p=>Array.from(new Set([...p,...i]))),a?.markForAction!==!1&&ye(p=>Array.from(new Set([...p,...i]))),Ve(!0),a?.openCart&&V("selecionadas"),b(a?.toastLabel||`ð ${i.length} oferta(s) adicionada(s) ao carrinho operacional.`,3200)}}async function To(){if(B.length>0){$a(B,{openCart:!0,toastLabel:`ð ${B.length} oferta(s) enviada(s) para o carrinho.`});return}if(Y.length>0){V("selecionadas");return}if(f.length>0){et();return}b("â ï¸ Selecione pelo menos uma oferta para continuar.",3e3)}async function Ro(){if(Lt.length>0){_e("operation"),await xs(!0);return}if(f.length>0){et();return}if(Y.length>0){V("selecionadas"),b("â ï¸ Marque no carrinho as ofertas prontas para a próxima ação.",3200);return}if(B.length>0){$a(B,{openCart:!0});return}b("â ï¸ Nada pronto para seguir para operação.",3e3)}function Eo(t){return t==="selecionadas"?"cart":t==="operacao"?"operation":t==="biblioteca"?"library":t==="pesquisar"?"search":null}function V(t){Me(t),_e(Eo(t));const a={pesquisar:Ur,selecionadas:Vs,biblioteca:_s,operacao:Da};window.setTimeout(()=>{a[t].current?.scrollIntoView({behavior:"smooth",block:"start"})},100)}function Ws(){ae(!1),E(!1),W(null),H.current="",r("/offers?tab=biblioteca",{replace:!0})}function Js(){se(!0)}function si(){se(!1),ae(!0),Me("biblioteca"),_e("library"),r(Fi(),{replace:!0}),window.setTimeout(()=>{_s.current?.scrollIntoView({behavior:"smooth",block:"start"})},120)}function Lo(t){const a=t.map(i=>Number(i.id||0)).filter(i=>Number.isFinite(i)&&i>0);a.length&&(y(i=>Array.from(new Set([...i,...a]))),Ve(!0),b(`â ${a.length} oferta(s) do grupo selecionada(s).`,2600))}function Do(){const t=at.map(a=>Number(a.id||0)).filter(a=>Number.isFinite(a)&&a>0);if(!t.length){b("Nenhuma oferta do espelho WhatsApp neste filtro.",2800);return}y(t),Ve(!0),b(`â ${t.length} oferta(s) do espelho selecionada(s).`,2800)}function ri(){_e("cart"),Ve(!0),Me("selecionadas"),window.setTimeout(()=>{Vs.current?.scrollIntoView({behavior:"smooth",block:"start"})},80)}function ii(){if(_e("cart"),B.length>0){$a(B,{openCart:!0,toastLabel:`ð ${B.length} oferta(s) enviada(s) para o carrinho.`});return}ri()}function Fo(){if(ne.length>0){et();return}if(B.length>0){Ni();return}if(Y.length>0){b("â ï¸ Marque ofertas prontas no carrinho e importe para a biblioteca antes de agendar, ou selecione itens na Galeria.",4500),ri();return}b("â ï¸ Selecione ofertas na pesquisa ou na biblioteca para agendar.",3500)}function $o(){eo(f).length!==0&&(E(!0),Ve(!0),_e("library"),V("biblioteca"),window.setTimeout(()=>{document.getElementById("offers-library-offers")?.scrollIntoView({behavior:"smooth",block:"start"})},220))}function zo(){U(!0),_e("search"),V("pesquisar"),window.setTimeout(()=>{Us.current?.scrollIntoView({behavior:"smooth",block:"start"})},240)}function qo(t){t?.openSchedule&&Mt(!0),Vt(!0),V("operacao"),window.setTimeout(()=>{Da.current?.scrollIntoView({behavior:"smooth",block:"start"})},100)}function et(t){const a=typeof t=="number"?f.some(i=>Number(i)===Number(t))?f:[...f,t]:f;typeof t=="number"&&y(a),a.length>0&&qi(a),r(`/agendamento?${Bi}=1`)}function Ks(){const t=new Set(ne.map(Number));return Q.find(a=>t.has(Number(a.id)))??null}function Bo(){const t=Ks(),a=String(t?.convertedUrl||t?.originalUrl||"").trim();if(!t||!a){b("â ï¸ Selecione uma oferta da galeria com link válido para abrir o Converter.",4e3);return}const i=Vi({id:Number(t.sourceOfferId||t.id),platform:String(t.platform||"unknown"),productTitle:String(t.productTitle||"Oferta"),productUrl:a,affiliateUrl:t.convertedUrl,productImage:t.productImage,currentPrice:t.currentPrice!=null?String(t.currentPrice):null,originalPrice
46:t.originalPrice!=null?String(t.originalPrice):null,discountPercent:t.discountPercent!=null?String(t.discountPercent):null,productDescription:t.productDescription??null,commissionPercent:t.commissionPercent,commissionAmount:t.commissionAmount,commissionSourceLabel:t.commissionSourceLabel});_i(r,"convert-link",{id:Number(t.sourceOfferId||t.id)||void 0,productUrl:a,snapshot:i??void 0})}function Vo(){const t=Ks(),a=String(t?.convertedUrl||t?.originalUrl||"").trim();if(!t||!a){b("â ï¸ Selecione uma oferta da galeria com link válido para gerar o banner.",4e3);return}const i=Vi({id:Number(t.sourceOfferId||t.id),platform:String(t.platform||"unknown"),productTitle:String(t.productTitle||"Oferta"),productUrl:a,affiliateUrl:t.convertedUrl,productImage:t.productImage,currentPrice:t.currentPrice!=null?String(t.currentPrice):null,originalPrice:t.originalPrice!=null?String(t.originalPrice):null,discountPercent:t.discountPercent!=null?String(t.discountPercent):null,productDescription:t.productDescription??null,commissionPercent:t.commissionPercent,commissionAmount:t.commissionAmount,commissionSourceLabel:t.commissionSourceLabel});_i(r,"generate-posts",{id:Number(t.sourceOfferId||t.id)||void 0,productUrl:a,snapshot:i??void 0})}function _o(){const t=Ks();if(!t){b("â ï¸ Selecione uma oferta da galeria com foto para abrir o Estúdio UGC.",4e3);return}const a=String(t.productImage||Oe(t)||"").trim();if(!a){b("â ï¸ Esta oferta não tem foto. Escolha outra ou envie a imagem antes de gerar o prompt.",5e3);return}yl({productTitle:String(t.productTitle||"Oferta").trim(),currentPrice:t.currentPrice!=null?String(t.currentPrice):void 0,originalPrice:t.originalPrice!=null?String(t.originalPrice):void 0,platform:String(t.platform||"").trim()||void 0,category:String(t.category||"").trim()||void 0,description:t.productDescription!=null?String(t.productDescription):void 0,imageUrl:a,source:"galeria"}),r("/estudio-ugc")}function Uo(){if(!Hs&&Fa?.role!=="admin"){b("ð Piloto automático disponÃvel no Elite.",5e3);return}if(ne.length===0){b("â ï¸ Selecione ao menos uma oferta da galeria para o piloto automático.",4e3);return}Io.mutate({offerIds:ne.map(Number).slice(0,200)},{onSuccess:t=>{if(!t.pilotEnabled){b(`â ${t.marked} oferta(s) marcada(s), mas o Piloto está desligado. Ligue o Piloto para enviar.`,7e3);return}const a=t.unmatched>0?` â ï¸ ${t.unmatched} não combina(m) com a categoria de nenhum grupo â não serão enviadas (use «Aleatório» num grupo ou agende).`:"";b(`â ${t.marked-t.unmatched} oferta(s) vão na frente no Piloto, no ritmo normal, nos grupos da categoria.${a}`,t.unmatched>0?9e3:5e3),y([])},onError:t=>b(`â ${t.message}`,5e3)})}function Ys(t){if(!t||typeof t!="object"||!Array.isArray(t.items))throw new Error("Payload inválido.");const a=hr(t);if(de(String(t.sourceUrl||"")),Ct(JSON.stringify(t,null,2)),a==="shopee"){oi.mutate(t);return}ni.mutate(Cl(a,t))}function Go(){const t=kt.trim();if(!t){b("â Cole o JSON da captura primeiro.",3500);return}if(t.startsWith("javascript:")||t.startsWith("(async")||t.startsWith("(() =>")||t.startsWith("/**")||t.includes("Executar JavaScript")||t.includes("completion(")||t.includes("/* ignore */")||t.includes("SMART_CAPTURE")||t.includes("bookmarklet")||t.includes("document.querySelector")&&!t.trimStart().startsWith("{")||!t.startsWith("{")){b("â Isso não é o JSON da captura. No Safari (página do produto): Compartilhar â Captura SmartOfertaAI â Permitir â na tela do resultado toque longo â Copiar â cole aqui.",8e3);return}try{Ys(JSON.parse(t))}catch(i){const p=i instanceof Error?i.message:"JSON inválido para a captura.";b(`â ${p}`,4500)}}function Qo(t){try{const a=new URLSearchParams(window.location.search),i=hr({...t,platform:a.get("extPlatform")||t.platform}),p=Ui({platform:i,payload:t});return b(`Importando ${p.platformLabel} · ${p.itemCount} item(ns)â¦`,3500),Ys(p.payload),!0}catch(a){return b(`â ${a instanceof Error?a.message:"Captura inválida no link."}`,6e3),!1}}async function Yt(){try{const t=new URLSearchParams(window.location.search),a=t.get("extPlatform"),i=t.get("extItems"),p=a?hr({platform:a}):null,c=i?Number(i):null,j=await kl({expectedPlatform:p,expectedItemCount:Number.isFinite(c)&&c>0?c:null}),v=Ui(j);if(!v.payload||typeof v.payload!="object")throw new Error("A extensão retornou uma captura inválida.");return b(`Importando ${v.platformLabel} · ${v.itemCount} item(ns)â¦`,3500),Ys(v.payload),!0}catch(t){const a=t instanceof Error?t.message:"Não foi possÃvel ler a última captura da extensão.";return b(`â ${a}`,6e3),!1}}function Ho(t){L(a=>a.includes(t)?a.filter(i=>i!==t):[...a,t])}const Xt=q.offers.importFromMining.useMutation({onSuccess:async t=>{b(`ð¥ ${t.createdCount} oferta(s) importada(s) para a Galeria de Ofertas.`),Gt([]),await n.offers.listMine.invalidate(),V("biblioteca")},onError:t=>{b(`â Erro ao importar: ${t.message}`,5e3)}});q.offers.addFromCommunityToCart.useMutation();const oi=q.miner.importShopeeBrowserCapture.useMutation({onSuccess:async t=>{const a=(t.importedOfferIds||[]).map(v=>Number(v)).filter(v=>Number.isFinite(v)&&v>0);ba(a);const i=Number(t.galleryCreatedCount??0);b(`ð§² ${t.importedCount} importada(s) ⢠${i} na galeria ⢠também na vitrine para todos.`,5e3),Ct(""),await n.miner.getMinedOffers.invalidate(),await n.offers.listMine.invalidate();const p=await n.offers.listMine.fetch({limit:500}),c=(t.galleryUserOfferIds||[]).map(v=>Number(v)).filter(v=>Number.isFinite(v)&&v>0),j=c.length>0?c:(p||[]).filter(v=>a.includes(Number(v.sourceOfferId||0))).map(v=>Number(v.id||0)).filter(v=>Number.isFinite(v)&&v>0);y(j),Xe([]),ye([]),j.length>0?(E(!0),V("biblioteca"),r("/offers",{replace:!0})):a.length>0&&(V("biblioteca"),r("/offers",{replace:!0}))},onError:t=>{b(`â Erro ao importar captura Shopee: ${t.message}`,5e3)}}),ni=q.miner.importMarketplaceBrowserCapture.useMutation({onSuccess:async t=>{const a=(t.importedOfferIds||[]).map(P=>Number(P)).filter(P=>Number.isFinite(P)&&P>0);ba(a);const i=Number(t.galleryCreatedCount??0),p=Number(t.skippedInvalidUrlCount??0),c=p>0?` ⢠${p} link(s) inválido(s) ignorado(s)`:"";b(`ð§² ${t.importedCount} importada(s)${t.platform?` (${t.platform})`:""} ⢠${i} na galeria ⢠também na vitrine para todos.${c}`,5500),Ct(""),await n.miner.getMinedOffers.invalidate(),await n.offers.listMine.invalidate();const j=await n.offers.listMine.fetch({limit:500}),v=(t.galleryUserOfferIds||[]).map(P=>Number(P)).filter(P=>Number.isFinite(P)&&P>0),C=v.length>0?v:(j||[]).filter(P=>a.includes(Number(P.sourceOfferId||0))).map(P=>Number(P.id||0)).filter(P=>Number.isFinite(P)&&P>0);y(C),Xe([]),ye([]),C.length>0?(E(!0),V("biblioteca"),r("/offers",{replace:!0})):a.length>0&&(V("biblioteca"),r("/offers",{replace:!0}))},onError:t=>{b(`â Erro ao importar captura: ${t.message}`,5e3)}}),ut=oi.isPending||ni.isPending;o.useEffect(()=>{if(St.length===0)return;const t=window.setTimeout(()=>{ba([])},600*1e3);return()=>window.clearTimeout(t)},[St]);const li=q.miner.startGlobalMining.useMutation({onSuccess:async t=>{const a=Number(t.galleryCreatedCount??0);b(`ð Mineração concluÃda: ${t.totalSaved||0} no pool ⢠${a} nova(s) na galeria.`,5e3),await Promise.all([n.miner.getMinedOffers.invalidate(),n.miner.getMiningDailyQuota.invalidate(),n.offers.listMine.invalidate()]),V("biblioteca")},onError:t=>{b(`â Erro ao minerar: ${t.message}`,5e3),n.miner.getMiningDailyQuota.invalidate()}}),is=q.offers.updateOffer.useMutation({onSuccess:async()=>{await n.offers.listMine.invalidate()}}),os=q.offers.toggleFavorite.useMutation({onSuccess:async()=>{await n.offers.listMine.invalidate()}}),ci=q.offers.archiveOffer.useMutation({onSuccess:async()=>{await n.offers.listMine.invalidate()}}),Ue=q.offers.deleteOffer.useMutation({onSuccess:async(t,a)=>{const i=Number(a.offerId);y(p=>p.filter(c=>Number(c)!==i)),await n.offers.listMine.invalidate(),b("Oferta removida da galeria.",3e3)},onError:t=>{b(`Erro ao remover da galeria: ${t.message}`,4500)}}),Zt=q.offers.setProductImage.useMutation({onSuccess:async()=>{await n.offers.listMine.invalidate(),await n.linkMirror.listImports.invalidate(),b("Foto enviada com sucesso.",28
4600)},onError:t=>{b(`Erro ao enviar foto: ${t.message}`,4500)}}),ns=o.useCallback(async(t,a)=>{try{const i=await rl(a);await Zt.mutateAsync({offerId:t,imageDataUrl:i})}catch(i){const p=i instanceof Error?i.message:"Falha ao ler a imagem.";b(`Erro ao enviar foto: ${p}`,4500)}},[Zt]),ls=o.useCallback(t=>Zt.isPending&&Number(Zt.variables?.offerId)===Number(t),[Zt.isPending,Zt.variables?.offerId]),cs=o.useCallback(t=>{Ue.mutate({offerId:t})},[Ue]),Wo=o.useCallback(async()=>{if(f.length!==0){Ir(!0);try{const t=[...f];await Promise.all(t.map(a=>Ue.mutateAsync({offerId:a}))),y([]),await n.offers.listMine.invalidate(),b(`ðï¸ ${t.length} oferta(s) removida(s) da galeria com sucesso.`,4e3),ya(!1)}catch(t){b(`Erro ao excluir ofertas selecionadas: ${t.message}`,5e3)}finally{Ir(!1)}}},[f,Ue,n.offers.listMine]),ds=o.useCallback(t=>Ue.isPending&&Number(Ue.variables?.offerId)===Number(t),[Ue.isPending,Ue.variables?.offerId]),Tt=q.offers.clearMineLibrary.useMutation({onSuccess:async t=>{y([]);try{$i()}catch{}await n.offers.listMine.invalidate(),b(t.deletedCount>0?`Galeria limpa: ${t.deletedCount} oferta(s) removida(s). Importe ou mine novas ofertas para atualizar sua galeria.`:"Sua galeria já estava vazia.",5e3),wa(!1)},onError:t=>{b(`Erro ao limpar galeria: ${t.message}`,5e3)}});q.offers.scheduleOffers.useMutation({onSuccess:async t=>{b(`ð¦ ${t.createdCount} agendamento(s) criado(s) com sucesso.`,5e3),await n.offers.listMine.invalidate(),await n.miner.getQueue.invalidate();try{$i()}catch{}Mt(!1),V("operacao")},onError:t=>{b(`â Erro ao agendar: ${t.message}`,5e3)}}),q.miner.updateScheduleWindow.useMutation({onSuccess:t=>{const a=t.scheduleWindow;a&&(ga(a.intervalMinutes),dt(a.start),Pt(a.end)),b(a?`â° Janela salva: ${a.start}â${a.end}, intervalo ${a.intervalMinutes} min.`:"â° Janela de postagem sincronizada.",2800),n.miner.getSchedulePreferences.invalidate(),n.miner.getScheduleOverview.invalidate()},onError:t=>{b(`â Erro ao salvar janela: ${t.message}`,5e3)}});const Q=o.useMemo(()=>(Ze.data||[]).map(t=>({...t,productImage:t.productImage||t.imageUrl||t.image||t.thumbnail||t.image_url||Oe(t.images)||Oe(t.media)||Oe(t.gallery)||""})),[Ze.data]),ke=o.useMemo(()=>(as.data||[]).filter(t=>!ll(t)).map(t=>({...t,productImage:t.productImage||t.imageUrl||t.image||t.thumbnail||t.image_url||Oe(t.images)||Oe(t.media)||Oe(t.gallery)||""})),[as.data]),Jo=o.useMemo(()=>{const t=ve(It);return bl.filter(a=>ve(a).includes(t))},[It]),Ko=o.useMemo(()=>ie.filter(t=>!ul.has(t)),[ie]),Yo=o.useMemo(()=>!!ur(It),[It]),Xo=o.useMemo(()=>Array.from(new Set(ke.map(t=>String(t.platform||"").trim()).filter(Boolean))),[ke]),Zo=o.useMemo(()=>Array.from(new Set(ke.map(t=>String(t.category||"").trim()).filter(Boolean))).sort((t,a)=>t.localeCompare(a,"pt-BR")),[ke]),ea=o.useMemo(()=>{const t=ve(ka),a=new Set(Ma.map(Ee)),i=new Set(Aa.map(Ee));let c=ke.filter(C=>{const P=ve(C.productTitle||C.title||C.productName||""),G=ve(C.productDescription||C.description||""),Qe=ve(C.category||""),nr=ve(C.platform||""),Un=!t||P.includes(t)||G.includes(t)||Qe.includes(t)||nr.includes(t),Gn=a.size===0||a.has(Ee(C.platform||"")),Qn=i.size===0||i.has(Ee(C.category||""));return Un&&Gn&&Qn});Ht>0&&(c=c.filter(C=>Ie(C.commissionPercent)>=Ht));const j=Z(Sa.trim());j!=null&&j>0&&(c=c.filter(C=>(Z(C.currentPrice)??0)>=j));const v=Z(Pa.trim());return v!=null&&v>0&&(c=c.filter(C=>{const P=Z(C.currentPrice)??0;return P>0&&P<=v})),Wt>0&&(c=c.filter(C=>Number(C.discountPercent||0)>=Wt)),[...c].sort((C,P)=>{switch(Ca){case"maiorComissaoValor":return(Z(P.commissionAmount)??0)-(Z(C.commissionAmount)??0);case"maiorComissaoPercentual":return Ie(P.commissionPercent)-Ie(C.commissionPercent);case"maiorDesconto":return Number(P.discountPercent||0)-Number(C.discountPercent||0);case"menorDesconto":return Number(C.discountPercent||0)-Number(P.discountPercent||0);case"menorPreco":return(Z(C.currentPrice)??0)-(Z(P.currentPrice)??0);case"maiorPreco":return(Z(P.currentPrice)??0)-(Z(C.currentPrice)??0);case"recentes":default:{const G=ao(P),Qe=ao(C);return G-Qe||Number(P.id||0)-Number(C.id||0)}}})},[ke,ka,Ma,Aa,Ca,Ht,Sa,Pa,Wt]),Xs=o.useMemo(()=>ea.filter(t=>Qa(t)),[ea]),di=o.useMemo(()=>Nr(Xs),[Xs]),mi=o.useCallback(()=>{V("biblioteca"),Ke(!1),window.setTimeout(()=>{document.getElementById("extension-capture")?.scrollIntoView({behavior:"smooth",block:"start"})},150)},[]),en=o.useCallback(()=>{V("pesquisar"),U(!0),ts(t=>t.some(a=>a.trim().toLowerCase()==="shopee captura")?t:[...t,zt]),window.setTimeout(()=>{const t=document.getElementById(Cr);if(t){t.scrollIntoView({behavior:"smooth",block:"start"});return}Us.current?.scrollIntoView({behavior:"smooth",block:"start"})},280)},[]),tt=o.useMemo(()=>{const t=ve(x).split(/\s+/).map(j=>
46j.trim()).filter(Boolean),a=new Set(g.map(Ee)),p=Q.filter(j=>{const v=Sc(j),C=t.length===0||t.every(Qe=>v.includes(Qe)),P=a.size===0||a.has(Ee(j.platform||"")),G=!I||Number(j.isFavorite||0)===1;return C&&P&&G}).sort((j,v)=>{if(te==="maiorDesconto")return Number(v.discountPercent||0)-Number(j.discountPercent||0);if(te==="menorDesconto")return Number(j.discountPercent||0)-Number(v.discountPercent||0);if(te==="menorPreco")return(Z(j.currentPrice)??0)-(Z(v.currentPrice)??0);if(te==="maiorPreco")return(Z(v.currentPrice)??0)-(Z(j.currentPrice)??0);if(te==="maiorComissao")return Ie(v.commissionPercent)-Ie(j.commissionPercent);if(te==="maisVendidos"){const C=Number(v.unitsSoldApprox??0),P=Number(j.unitsSoldApprox??0);if(C!==P)return C-P;const G=so(v),Qe=so(j);return G-Qe||Number(v.id||0)-Number(j.id||0)}return Number(v.id||0)-Number(j.id||0)}),c=new Map;for(const j of p){const v=Ee(String(j.convertedUrl||j.originalUrl||j.productUrl||"")),C=Ee(`${j.productTitle||""}|${Z(j.currentPrice)||0}|${j.platform||""}`),P=v||C;if(!P)continue;const G=c.get(P);if(!G){c.set(P,j);continue}const Qe=!!String(j.productImage||"").trim(),nr=!!String(G.productImage||"").trim();if(Qe&&!nr){c.set(P,j);continue}Number(j.id||0)>Number(G.id||0)&&c.set(P,j)}return Array.from(c.values())},[Q,x,g,te,I]),ne=o.useMemo(()=>eo(f),[f]),ht=o.useMemo(()=>new Set(ne),[ne]),Rt=o.useCallback(t=>{const a=Number(t?.id||0),i=Number(t?.sourceOfferId||0);return a>0&&ht.has(a)||i>0&&ht.has(i)},[ht]),at=o.useMemo(()=>{const t=F?tt.filter(i=>Di(i)):tt;if(!D||ne.length===0)return t;let a=to(t,ht);return a.length===0&&(a=to(Q,ht)),jc(a,ne)},[F,D,ne,ht,tt,Q]);o.useEffect(()=>{if(!_||Ze.isLoading)return;const t=_,a=window.setTimeout(()=>{document.querySelector(`[data-library-offer-id="${t}"]`)?.scrollIntoView({behavior:"smooth",block:"center"})},320);return()=>window.clearTimeout(a)},[_,Ze.isLoading,at.length]);const za=o.useMemo(()=>Q.filter(t=>Di(t)),[Q]),ms=o.useMemo(()=>cl(at),[at]),tn=o.useMemo(()=>F?ms.map(t=>[`${t.groupName} · ${t.dayLabel}`,t.items]):Nr(at),[F,ms,at]),Ge=o.useMemo(()=>Zr.data||[],[Zr.data]),Zs=o.useMemo(()=>Ge.length?[...Ge].sort((t,a)=>new Date(t.executeAt).getTime()-new Date(a.executeAt).getTime())[0]:null,[Ge]),er=o.useMemo(()=>{const t=new Map;for(const a of Ge){const i=a.channel||"telegram",p=a.targetChatId||"destino",c=`${i}:${p}`,j=a.executeAt?new Date(a.executeAt):null;t.has(c)||t.set(c,{id:c,platform:i,groupName:a.targetChatName||p,groupId:p,scheduledCount:0,nextDate:j});const v=t.get(c);v&&(v.scheduledCount+=1,j&&(!v.nextDate||j.getTime()<v.nextDate.getTime())&&(v.nextDate=j))}return Array.from(t.values()).sort((a,i)=>!a.nextDate&&!i.nextDate?0:a.nextDate?i.nextDate?a.nextDate.getTime()-i.nextDate.getTime():-1:1).map(a=>({id:a.id,platform:a.platform,groupName:a.groupName,groupId:a.groupId,scheduledCount:a.scheduledCount,nextSendAt:a.nextDate?fr(a.nextDate):"Sem horário definido",status:"queued"}))},[Ge]),ui=o.useMemo(()=>Q.filter(t=>Number(t.isFavorite||0)===1).length,[Q]),an=o.useMemo(()=>ie.length===0?"Escolha as categorias que deseja pesquisar":ie.length===1?ie[0]:ie.length===2?`${ie[0]} ⢠${ie[1]}`:`${ie[0]} ⢠${ie[1]} +${ie.length-2}`,[ie]),qa=o.useMemo(()=>Q.filter(t=>{const a=Number(t.id||0),i=Number(t.sourceOfferId||0);return a>0&&ht.has(a)||i>0&&ht.has(i)}),[Q,ht]),sn=o.useMemo(()=>{const t=new Set(ea.map(a=>Number(a.id)));return B.filter(a=>t.has(a)).length},[ea,B]),tr=o.useMemo(()=>new Set(B.map(t=>Number(t))),[B]);o.useEffect(()=>{f.length===0&&E(!1)},[f.length]);const hi=o.useMemo(()=>{const t=new Map;for(const a of Q){const i=Number(a.sourceOfferId||0);i&&t.set(i,a)}return t},[Q]),ar=o.useMemo(()=>{const t=Array.from(new Set(Y.map(p=>Number(p)).filter(Boolean))),a=new Set(ke.map(p=>Number(p.id))),i=new Set(Q.map(p=>Number(p.sourceOfferId||0)).filter(p=>Number.isFinite(p)&&p>0));return t.filter(p=>!a.has(p)&&!i.has(p))},[Y,ke,Q]),sr=q.miner.getMinedOffersByIds.useQuery({ids:ar},{enabled:ar.length>0,staleTime:12e4}),ta=o.useMemo(()=>{const t=Array.from(new Set(Y.map(c=>Number(c)).filter(Boolean)));if(!t.length)return[];const a=new Map(ke.map(c=>[Number(c.id),c]).filter(([c])=>Number.isFinite(c)&&c>0)),i=new Map((sr.data||[]).map(c=>[Number(c.id),c])),p=new Map(Q.map(c=>[Number(c.sourceOfferId||0),c]).filter(([c])=>Number.isFinite(c)&&c>0));return t.map(c=>{const j=a.get(c);if(j)return j;const v=i.get(c);if(v)return v;const C=p.get(c);return C?{...C,id:c}:null}
46).filter(Boolean)},[Y,ke,Q,sr.data]),aa=o.useMemo(()=>ta.map(t=>{const a=Number(t.id),i=hi.get(a)??null,p=String(i?.derivedStatus||i?.status||"").trim().toLowerCase(),c=i?p==="published"?"enviado":p==="scheduled"?"agendado":p==="archived"?"arquivado":p==="ready"?"pronto":"biblioteca":"novo",j=i&&Number(i.id||0)||null;return{...t,linkedLibraryOffer:i,linkedLibraryId:j,cartStage:c,canProceedToOperation:c==="novo"||c==="biblioteca"||c==="pronto"}}),[ta,hi]),Et=o.useMemo(()=>{const t=new Set(mt);return aa.filter(a=>t.has(Number(a.id)))},[aa,mt]),Lt=o.useMemo(()=>Et.filter(t=>t.canProceedToOperation),[Et]),xi=o.useMemo(()=>Et.filter(t=>!t.canProceedToOperation),[Et]),rn=o.useMemo(()=>Lt.reduce((t,a)=>t+(Z(a.commissionAmount)??0),0),[Lt]),on=o.useMemo(()=>Lt.reduce((t,a)=>Math.max(t,Ie(a.commissionPercent)),0),[Lt]),nn=o.useMemo(()=>Et.reduce((t,a)=>(t.total+=1,a.cartStage==="novo"&&(t.newCount+=1),a.cartStage==="biblioteca"&&(t.libraryCount+=1),a.cartStage==="pronto"&&(t.readyCount+=1),a.cartStage==="agendado"&&(t.scheduledCount+=1),a.cartStage==="enviado"&&(t.sentCount+=1),a.cartStage==="arquivado"&&(t.archivedCount+=1),t),{total:0,newCount:0,libraryCount:0,readyCount:0,scheduledCount:0,sentCount:0,archivedCount:0}),[Et]),ln=o.useMemo(()=>Array.from(new Set(ta.map(t=>String(t.platform||"").trim()).filter(Boolean))),[ta]),cn=o.useMemo(()=>Array.from(new Set(ta.map(t=>String(t.category||"").trim()).filter(Boolean))).sort((t,a)=>t.localeCompare(a,"pt-BR")),[ta]),pi=o.useMemo(()=>{const t=ve(Ia),a=new Set(Ta.map(Ee)),i=new Set(Ea.map(Ee));return aa.filter(p=>{const c=ve(p.productTitle||p.title||p.productName||""),j=ve(p.productDescription||p.description||""),v=ve(p.category||""),C=ve(p.platform||""),P=!t||c.includes(t)||j.includes(t)||v.includes(t)||C.includes(t),G=a.size===0||a.has(Ee(p.platform||"")),Qe=i.size===0||i.has(Ee(p.category||""));return P&&G&&Qe})},[aa,Ia,Ta,Ea]),gt=o.useMemo(()=>(Te.data||[]).filter(a=>A.includes(a.chatId)),[Te.data,A]),dn=o.useMemo(()=>gt.filter(t=>t.provider===K).map(t=>t.chatName||t.chatId).slice(0,3),[gt,K]),us=o.useMemo(()=>w?(Qs.data||[]).find(t=>Number(t.id)===Number(w))??null:null,[Qs.data,w]),bi=o.useMemo(()=>w?us?.name||"Copy personalizada":"Sem copy selecionada",[us,w]),R=o.useMemo(()=>{if(_){const t=qa.find(a=>Number(a.id)===_)||Q.find(a=>Number(a.id)===_);if(t)return t}return qa[0]||tt[0]||null},[_,qa,Q,tt]),gi=o.useMemo(()=>String(R?.convertedUrl||R?.originalUrl||R?.productUrl||"").trim()?jo(R):"",[R]),Ba=o.useMemo(()=>R?Pc({offer:R,aiText:k,notes:$e}):{hook:null,body:"",publicText:""},[R,k,$e]),sa=Ba.publicText,hs=o.useMemo(()=>{if(!R)return"";const t=[];return w&&t.push(`âï¸ Copy: ${bi}`),T&&t.push(`ð¼ï¸ Layout: ${T}`),gt.length&&t.push(`ð Destinos: ${gt.map(a=>a.chatName||a.chatId).join(" ⢠")}`),qe&&pe&&t.push(`ðï¸ ${qe} à s ${pe}`),t.length?`âââ 47${t.join(` 48`)}`:""},[R,w,bi,T,gt,qe,pe]),fi=o.useMemo(()=>{const t=Ba.body;return hs?t?`${t} 49 50${hs}`:hs:t},[Ba.body,hs]),mn=o.useMemo(()=>{if(!R)return[];const t=R.discountPercent?`${_a(R.discountPercent)}`:null;return["â Aproveite essa oferta especial antes que acabe.","ð Achado de oportunidade para hoje.",t?`ð¥ Promoção com ${t} de desconto por tempo limitado.`:"ð¥ Oferta por tempo limitado.","ð Toque no link e confira os detalhes atualizados da oferta."]},[R]),vi=o.useMemo(()=>String(R?.generatedBannerUrl||"").trim()||String(R?.productImage||"").trim()||"",[R]),un=o.useMemo(()=>{const t=new Set(Dr.map(Number));return Q.filter(a=>t.has(Number(a.id))).map(a=>({id:Number(a.id),productTitle:a.productTitle,productImage:a.productImage}))},[Q,Dr]),ft=o.useMemo(()=>({channelsReady:$.length>0,destinationsReady:A.length>0,assetsReady:!!(w||T||String(R?.generatedBannerUrl||"").trim()),copyReady:!!sa.trim()}),[$.length,A.length,w,T,R,sa]);function hn(t){qs(a=>a.includes(t)?a.filter(i=>i!==t):[...a,t])}function xn(t){ts(a=>a.includes(t)?a.filter(i=>i!==t):[...a,t])}function pn(t){Ra(a=>a.includes(t)?a.filter(i=>i!==t):[...a,t])}function bn(t){La(a=>a.includes(t)?a.filter(i=>i!==t):[...a,t])}function gn(t){ye(a=>a.includes(t)?a.filter(i=>i!==t):[...a,t])}function fn(t){Xe(a=>a.filter(i=>i!==t)),ye(a=>a.filter(i=>i!==t))}function vn(){if(!Ae){b("ð Adicionar ao carrinho a partir da Vitrine requer o Elite.",5500);return}if(!B.length){b("â ï¸ Selecione pelo menos uma oferta da pesquisa.",3500);return}$a(B,{openCart:!0,toastLabel:`ð ${B.length} oferta(s) adicionada(s) ao carrinho operacional.`})}function jn(){Xe([]),ye([]),b("ð§¹ Selecionadas limpas.",2500)}function Nn(){ye([]),b("ð¯ Marcação da ação limpa.",2500)}function wn(){const t=pi.map(a=>
50Number(a.id)).filter(Boolean);if(!t.length){b("â ï¸ Não há ofertas visÃveis nas selecionadas.",3e3);return}ye(a=>Array.from(new Set([...a,...t]))),b(`â
${t.length} oferta(s) visÃvel(is) marcada(s) para a próxima ação.`,3e3)}async function xs(t=!1){if(!Ae){b("ð Importar ofertas do carrinho da Vitrine para a sua biblioteca requer o Elite.",5500);return}if(!mt.length){b("â ï¸ Marque pelo menos uma oferta no carrinho.",3500);return}const i=aa.filter(G=>mt.includes(Number(G.id))).filter(G=>G.canProceedToOperation);if(!i.length){b("â ï¸ Nenhuma oferta marcada está pronta para seguir para operação.",4e3);return}const p=i.filter(G=>!G.linkedLibraryId).map(G=>Number(G.id)).filter(Boolean),c=i.map(G=>Number(G.linkedLibraryId||0)).filter(Boolean);p.length&&await Xt.mutateAsync({offerIds:p});const C=((await Ze.refetch()).data||[]).filter(G=>p.includes(Number(G.sourceOfferId))).map(G=>Number(G.id)).filter(Boolean),P=Array.from(new Set([...c,...C]));P.length&&y(P),t?(Mt(!0),V("operacao"),window.setTimeout(()=>{Da.current?.scrollIntoView({behavior:"smooth",block:"start"})},120)):V("biblioteca"),b(`ð ${i.length} oferta(s) validada(s) para a próxima etapa.`,3500)}function yn(t){M(a=>a.includes(t)?a.filter(i=>i!==t):[...a,t])}function ps(t){y(a=>a.includes(t)?a.filter(i=>i!==t):[...a,t])}function kn(t){t!=="instagram"&&re(a=>a.includes(t)?a.filter(i=>i!==t):[...a,t])}const Cn=ai.data?.status||(ss.isPending||rs.isPending?"INITIALIZING":"DISCONNECTED"),bs=String(ai.data?.pairingCode||"").trim();function Sn(t){Rr(a=>a.includes(t)?a.filter(i=>i!==t):[...a,t])}function Pn(){const t=Bt.replace(/\D/g,"");if(t.length<10){b("â ï¸ Informe um número válido com DDD (somente números).",4e3);return}lt.current=!0,rs.mutate({phoneNumber:t},{onSuccess:()=>{b("ð² Código de pareamento solicitado. Confira abaixo.",4500)}})}function Mn(t){const a=t.replace(/\D/g,"").slice(0,13),i=a.slice(0,2),p=a.length>10?a.slice(2,7):a.slice(2,6),c=a.length>10?a.slice(7,11):a.slice(6,10),v=`${a.length>11?`+${a.slice(0,a.length-11)} `:""}${i?`(${i}) `:""}${p}${c?`-${c}`:""}`;yt(v.trim())}async function An(){if(!bs)return!1;try{return await navigator.clipboard.writeText(bs),Kt.trigger(),b("â
Código copiado.",2500),!0}catch{return b("â ï¸ Não foi possÃvel copiar automaticamente.",3500),!1}}function In(t){Ut(a=>a.includes(t)?a.filter(i=>i!==t):[...a,t])}function On(){const t=ur(Ls);if(!t){b("â ï¸ Digite um nome com pelo menos 2 caracteres.",4e3);return}const a=wr(Ls)??t;Ut(i=>i.some(p=>p.toLowerCase()===a.toLowerCase())?i:[...i,a]),Ds("")}function Tn(){const t=ur(It);if(!t){b("â ï¸ Termo muito curto para virar categoria.",4e3);return}const a=wr(It)??t;Ut(i=>i.some(p=>p.toLowerCase()===a.toLowerCase())?i:[...i,a])}function Rn(t){Ut(a=>a.filter(i=>i!==t))}function En(){const t=ea.map(a=>Number(a.id)).filter(Boolean);if(!t.length){b("â ï¸ Não há resultados visÃveis para selecionar.",3e3);return}Gt(a=>Array.from(new Set([...a,...t]))),b(`â
${t.length} oferta(s) da pesquisa selecionada(s).`,3e3)}function ji(){const t=tt.map(a=>Number(a.id)).filter(Boolean);if(!t.length){b("â ï¸ Não há ofertas visÃveis na biblioteca.",3e3);return}y(a=>Array.from(new Set([...a,...t]))),b(`â
${t.length} oferta(s) visÃvel(is) selecionada(s).`,3e3)}function Ln(){h(""),M([]),Pe("maiorComissao"),F&&Ws()}async function Dn(){if(!Jr){b("â¹ï¸ A mineração ao vivo é só para administradores. Ajuste plataformas e categorias acima para filtrar o pool já armazenado.",6e3);return}if(!Ae){b("ð Minerar o pool da Vitrine requer o Elite. Você pode ver e filtrar o catálogo em qualquer plano.",5500);return}if(!bt.length){b("â ï¸ Escolha pelo menos uma plataforma.",3500);return}if(!ie.length){b("â ï¸ Escolha pelo menos uma categoria.",3500);return}const t={platforms:[...bt],categories:[...ie],search:_t.trim(),limit:Ya,avoidLowQuality:Xa};$r(t),Gt([]),zs(""),qs([]),ts([]),await li.mutateAsync({categories:t.categories,platforms:t.platforms,limit:t.limit,avoidLowQuality:t.avoidLowQuality,countAsProductMine:t.categories.length===1&&t.search.trim().length>=2&&t.categories[0]?.trim().toLowerCase()===t.search.trim().toLowerCase()})}async function Fn(){if(!Ae){b("ð Importar ofertas da Vitrine para a biblioteca requer o Elite.",5500);return}if(!B.length){b("â ï¸ Selecione pelo menos uma oferta da sua pesquisa.",3500);return}await Xt.mutateAsync({offerIds:B})}
50async function rr(){if(!B.length)return b("â ï¸ Nenhuma oferta selecionada na pesquisa.",3e3),null;if(!Ae)return b("ð Importar da Vitrine para operar requer o Elite.",5500),null;await Xt.mutateAsync({offerIds:B});const a=(await Ze.refetch()).data||[],i=B.map(p=>{const c=a.find(j=>Number(j.sourceOfferId||0)===Number(p));return c?Number(c.id):null}).filter(p=>p!=null&&p>0);return i.length?i:(b("â ï¸ Importação concluÃda, mas não localizamos as ofertas na biblioteca. Abra a aba Biblioteca e tente novamente.",5200),null)}function $n(t){Fr(a=>a.includes(t)?a.filter(i=>i!==t):[...a,t])}function zn(){if(!Za.length){b("â ï¸ Marque pelo menos uma oferta para agendar.",3e3);return}y(Za),$s(!1),qi(Za),r(`/agendamento?${Bi}=1`)}async function Ni(){Qt(!0);try{const t=await rr();if(!t?.length)return;Co(t),Fr(t),$s(!0)}finally{Qt(!1)}}async function qn(){Qt(!0);try{const t=await rr();if(!t?.length)return;y(t),Mt(!1),V("operacao"),window.setTimeout(()=>{document.getElementById("operation-step-destinations")?.scrollIntoView({behavior:"smooth",block:"start"})},200)}finally{Qt(!1)}}async function Bn(){Qt(!0);try{const t=await rr();if(!t?.length)return;y(t),Mt(!0),Vt(!0),V("operacao"),window.setTimeout(()=>{document.getElementById("operation-schedule-submit")?.scrollIntoView({behavior:"smooth",block:"center"})},280)}finally{Qt(!1)}}async function ir(){if(!f.length){b("â ï¸ Selecione pelo menos uma oferta da sua biblioteca.",3500);return}await Promise.all(f.map(t=>os.mutateAsync({offerId:t,isFavorite:!0}))),b("ð Seleção marcada como favorita.")}async function Vn(){f.length&&await Promise.all(f.map(t=>is.mutateAsync({offerId:t,selectedCopyTemplateId:w===""?null:w,selectedBannerTemplateKey:T||null,generatedCopy:sa.trim()||null,notes:$e.trim()||null,status:"ready"})))}async function _n(){if(!f.length){b("â ï¸ Selecione pelo menos uma oferta da sua biblioteca.",3500);return}if(!w&&!T&&!sa.trim()&&!String(R?.generatedBannerUrl||"").trim()){b("â ï¸ Escolha um template de copy ou de layout de imagem, ou ajuste o copy/IA.",3500);return}await Vn(),Vt(!1),b("ð¨ Configuração da operação aplicada à s ofertas selecionadas.")}async function wi(){const t=sa.trim();if(!t){b("â ï¸ Sem texto para copiar.",3e3);return}try{await navigator.clipboard.writeText(t),b("â
Texto copiado.",2500)}catch{b("â ï¸ Não foi possÃvel copiar.",3500)}}async function yi(){const t=gi.trim();if(!t){b("â ï¸ Sem link nesta prévia.",3e3);return}try{await navigator.clipboard.writeText(t),b("â
Link copiado.",2500)}catch{b("â ï¸ Não foi possÃvel copiar o link.",3500)}}async function ki(){const t=sa.trim(),a=gi.trim();if(typeof navigator.share=="function")try{await navigator.share({title:String(R?.productTitle||"Smart Oferta"),text:t,url:a||void 0});return}catch{}if(t)try{await navigator.clipboard.writeText(t)}catch{}await or(),b(t?"Legenda copiada e download da imagem iniciado. No WhatsApp, envie a foto e cole o texto debaixo.":"Download da imagem iniciado.",4500)}async function or(){const t=vi.trim();if(!t){b("â ï¸ Sem imagem na prévia.",3e3);return}try{const i=await(await fetch(t)).blob(),p=URL.createObjectURL(i),c=document.createElement("a");c.href=p,c.download=`smart-oferta-${R?.id??"banner"}.jpg`,c.click(),URL.revokeObjectURL(p),b("â
Download iniciado.",2500)}catch{window.open(t,"_blank","noopener,noreferrer"),b("Abra a imagem na nova aba para salvar manualmente.",4500)}}return Hr.current=t=>{Gt(a=>a.includes(t)?a.filter(i=>i!==t):[...a,t])},e.jsxs("div",{className:"min-w-0 w-full space-y-4 md:space-y-6 pb-28 md:pb-16 overflow-x-hidden",children:[e.jsxs("section",{className:"min-w-0 max-w-full overflow-hidden rounded-2xl md:rounded-[24px] border border-violet-100 bg-white p-3.5 sm:p-5 shadow-sm space-y-4",children:[e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex h-11 w-11 shrink-0 items-center justify-center rounded-2xl bg-gradient-to-br from-violet-600 via-fuchsia-600 to-purple-700 text-white shadow-md shadow-violet-500/20",children:e.jsx(Is,{className:"h-5 w-5"})}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h1",{className:"text-xl sm:text-2xl font-black tracking-tight text-slate-900",children:"Galeria de Ofertas"}),e.jsxs("span",{className:"hidden sm:inline-flex items-center gap-1 rounded-full border border-emerald-300 bg-emerald-50 px-2 py-0.5 text-[10px] font-extrabold uppercase text-emerald-700",children:[e.jsx(Ne,{className:"h-3 w-3"}),"Ativo"]})]}),e.jsx("p",{className:"text-xs text-slate-500 font-medium",children:"Gerencie sua biblioteca, pesquise no catálogo e prepare campanhas para disparo."})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs(xt,{to:"/miner-offers",className:"inline-flex h-9 items-center gap-1.5 rounded-xl border border-violet-200 bg-vi
50olet-50/60 px-3 text-xs font-bold text-violet-800 transition hover:bg-violet-100",children:[e.jsx("span",{children:"Abrir Vitrine"}),e.jsx(wt,{className:"h-3.5 w-3.5"})]}),e.jsx(xt,{to:"/generate-posts",className:"inline-flex h-9 items-center gap-1.5 rounded-xl border border-slate-200 bg-white px-3 text-xs font-semibold text-slate-700 transition hover:bg-slate-50",children:e.jsx("span",{children:"Gerar Conteúdo"})}),e.jsxs("button",{type:"button",onClick:Js,className:"inline-flex h-9 items-center gap-1.5 rounded-xl border border-[#1ebe57]/30 bg-[#25D366]/10 px-3 text-xs font-bold text-[#1a8b42] transition hover:bg-[#25D366]/20",children:[e.jsx(yc,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{children:"Espelho"}),za.length>0?e.jsx("span",{className:"rounded-full bg-[#25D366] px-1.5 py-0.2 text-[10px] font-black text-white",children:za.length}):null]})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 pt-1 border-t border-slate-100",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 p-1 rounded-2xl bg-slate-100/80 border border-slate-200/80",children:[e.jsxs("button",{type:"button",onClick:()=>V("biblioteca"),className:N("inline-flex items-center gap-2 rounded-xl px-3 sm:px-4 py-2 text-xs sm:text-sm font-bold transition-all",me==="biblioteca"?"bg-white text-violet-950 shadow-sm shadow-slate-200 font-extrabold":"text-slate-600 hover:text-violet-900 hover:bg-white/60"),children:[e.jsx(Is,{className:"h-4 w-4 text-violet-600"}),e.jsx("span",{children:"Minha Galeria"}),e.jsx("span",{className:N("px-2 py-0.5 rounded-full text-[11px] font-extrabold",me==="biblioteca"?"bg-violet-100 text-violet-800":"bg-slate-200/80 text-slate-700"),children:Q.length})]}),e.jsxs("button",{type:"button",onClick:()=>V("pesquisar"),className:N("inline-flex items-center gap-2 rounded-xl px-3 sm:px-4 py-2 text-xs sm:text-sm font-bold transition-all",me==="pesquisar"?"bg-white text-violet-950 shadow-sm shadow-slate-200 font-extrabold":"text-slate-600 hover:text-violet-900 hover:bg-white/60"),children:[e.jsx(it,{className:"h-4 w-4 text-fuchsia-600"}),e.jsx("span",{children:"Pesquisar Catálogo"}),ke.length>0?e.jsx("span",{className:N("px-2 py-0.5 rounded-full text-[11px] font-extrabold",me==="pesquisar"?"bg-fuchsia-100 text-fuchsia-800":"bg-slate-200/80 text-slate-700"),children:ke.length}):null]}),e.jsxs("button",{type:"button",onClick:()=>V("selecionadas"),className:N("inline-flex items-center gap-2 rounded-xl px-3 sm:px-4 py-2 text-xs sm:text-sm font-bold transition-all",me==="selecionadas"?"bg-white text-violet-950 shadow-sm shadow-slate-200 font-extrabold":"text-slate-600 hover:text-violet-900 hover:bg-white/60"),children:[e.jsx(qt,{className:"h-4 w-4 text-emerald-600"}),e.jsx("span",{children:"Carrinho"}),Y.length>0?e.jsx("span",{className:"px-2 py-0.5 rounded-full text-[11px] font-extrabold bg-emerald-100 text-emerald-800",children:Y.length}):null]}),e.jsxs("button",{type:"button",onClick:()=>V("operacao"),className:N("inline-flex items-center gap-2 rounded-xl px-3 sm:px-4 py-2 text-xs sm:text-sm font-bold transition-all",me==="operacao"?"bg-white text-violet-950 shadow-sm shadow-slate-200 font-extrabold":"text-slate-600 hover:text-violet-900 hover:bg-white/60"),children:[e.jsx(ot,{className:"h-4 w-4 text-amber-500"}),e.jsx("span",{children:"Operação & Disparo"}),Ge.length>0?e.jsxs("span",{className:"px-2 py-0.5 rounded-full text-[11px] font-extrabold bg-amber-100 text-amber-800",children:[Ge.length," na fila"]}):null]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>{ze(t=>!t),me!=="biblioteca"&&V("biblioteca")},className:N("inline-flex items-center gap-1.5 px-3 py-1.5 rounded-xl text-xs font-bold border transition-all",I?"bg-rose-50 border-rose-300 text-rose-700 shadow-sm":"bg-white border-slate-200 text-slate-600 hover:bg-slate-50"),title:"Filtrar favoritas na galeria",children:[e.jsx(jt,{className:N("h-3.5 w-3.5",I?"fill-rose-500 text-rose-500":"text-slate-400")}),e.jsx("span",{children:"Favoritas"}),ui>0?e.jsxs("span",{className:"text-[10px] font-extrabold",children:["(",ui,")"]}):null]}),e.jsxs("button",{type:"button",onClick:()=>Ke(t=>!t),className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-xl text-xs font-bold border border-violet-200 bg-white text-violet-700 hover:bg-violet-50 transition-all shadow-sm",title:"Importar ofertas da extensão ou colar JSON",children:[e.jsx(Os,{className:"h-3.5 w-3.5 text-violet-600"}),e.jsx("span",{children:"Importar"})]})]})]})]}),e.jsx("div",{ref:Po,children:e.jsx(Yl,{showQueueRadar:ja,onToggleQueueRad
50ar:()=>l(t=>!t),queueItems:Ge,queueRadarItems:er,nextQueueItem:Zs,formatQueueRadarDate:fr,onViewHistory:()=>r("/post-history")})}),e.jsx(ec,{sectionRef:Ur,categoryPanelRef:Bs,stores:vo,visible:me==="pesquisar",personalMiningResultsRef:Us,state:{personalSelectedPlatforms:bt,personalSelectedCategories:ie,personalSearch:_t,personalCategoriesOpen:yo,personalCategorySummary:an,personalCategorySearch:It,personalCatCustomDraft:Ls,selectedPersonalCustomCategories:Ko,canAddPersonalSearchAsCategory:Yo,maxCategoryNameLen:hl,filteredCategories:Jo,personalLimit:Ya,personalAvoidLowQuality:Xa,startPersonalMiningPending:li.isPending,appliedPersonalScope:es,filteredPersonalMiningOffers:ea,personalResultsSelectedCount:sn,selectedCartIds:Y,resultAvailablePlatforms:Xo,resultSelectedPlatforms:Ma,resultAvailableCategories:Zo,resultSelectedCategories:Aa,showResultFilters:S,personalMiningLoading:as.isLoading,personalMiningTotalCount:ke.length,personalSelectedOfferIds:B,personalSelectedOfferIdSet:tr,resultSearch:ka,resultSortMode:Ca,resultMinCommissionPercent:Ht,resultMinPrice:Sa,resultMaxPrice:Pa,resultMinDiscountPercent:Wt,communityPremiumUnlocked:Ae,canRunLiveMining:Jr,gallerySavedCount:Q.length},actions:{togglePersonalPlatform:Sn,setPersonalSearch:Or,setPersonalCatCustomDraft:Ds,toggleCategoriesOpen:()=>Fs(t=>!t),togglePersonalCategory:In,setPersonalCategorySearch:Tr,addPersonalCustomCategory:On,addPersonalSearchTermAsCategory:Tn,removePersonalCustomCategory:Rn,clearCategories:()=>{Ut([]),Tr(""),Ds("")},closeCategories:()=>Fs(!1),setPersonalLimit:Er,setPersonalAvoidLowQuality:Lr,handleRunPersonalMining:Dn,selectAllPersonalResults:En,addSelectedResultsToCart:vn,goToCart:()=>V("selecionadas"),goToBiblioteca:()=>V("biblioteca"),openClearGalleryDialog:()=>wa(!0),onToggleResultFilters:()=>U(t=>!t),setResultSearch:zs,setResultSortMode:zr,setResultMinCommissionPercent:qr,setResultMinPrice:Br,setRe
50sultMaxPrice:Vr,setResultMinDiscountPercent:_r,toggleResultPlatform:hn,toggleResultCategory:xn,togglePersonalOffer:Wr,addOfferToCart:Qr,clearPersonalSelection:()=>Gt([])},helpers:{formatPlatformName:vt,formatCurrency:We,formatPercent:_a,parseFlexibleMoneyValue:Z}}),e.jsx(rc,{sectionRef:Vs,visible:me==="selecionadas",canUsePoolActions:Ae,hasAutopilotAccess:Hs,onGoToOperation:()=>{V("operacao"),window.setTimeout(()=>{Da.current?.scrollIntoView({behavior:"smooth",block:"start"})},120)},state:{filteredCartOffers:pi,cartOffersTotalCount:aa.length,cartHydrationPending:ar.length>0&&sr.isLoading,selectedCartIds:Y,cartActionIds:mt,cartReadyNowOffers:Lt,cartAvailablePlatforms:ln,cartSelectedPlatforms:Ta,cartAvailableCategories:cn,cartSelectedCategories:Ea,showCartFilters:At,cartSearch:Ia,cartActionSummary:nn,cartBlockedActionOffers:xi,cartActionOffers:Et,recentImportedSourceOfferIds:St,importPending:Xt.isPending},actions:{selectAllCartVisible:wn,clearCartAction:Nn,clearSelectedCart:jn,handleCartImportToLibrary:xs,onToggleCartFilters:()=>Na(t=>!t),clearCartDisplayFilters:()=>{Oa(""),Ra([]),La([])},setCartSearch:Oa,toggleCartPlatform:pn,toggleCartCategory:bn,toggleCartAction:gn,removeOfferFromCart:fn},helpers:{formatPlatformName:vt,formatCurrency:We,formatPercent:_a,parseFlexibleMoneyValue:Z}}),e.jsxs("div",{ref:_s,className:N("space-y-4 md:space-y-6",me!=="biblioteca"&&"hidden"),children:[e.jsx("section",{id:"extension-capture",className:N("rounded-[24px] border border-violet-100 bg-white shadow-sm",ct?"px-3 py-2 md:px-4 md:py-2.5":"p-4 md:p-5"),children:ct?e.jsxs("div",{className:"flex h-10 max-h-10 flex-nowrap items-center gap-2 overflow-hidden md:h-11 md:max-h-11",children:[e.jsx(Os,{className:"h-4 w-4 shrink-0 text-violet-600","aria-hidden":!0}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-left text-[13px] font-bold leading-none text-slate-900",children:"Captura / colar JSON"}),e.jsx(m,{type:"button",size:"sm",variant:"outline",className:"h-9 shrink-0 touch-manipulation rounded-lg border-emerald-300 bg-emerald-50 px-2.5 text-xs font-bold text-emerald-800 hover:bg-emerald-100",onClick:()=>{Ke(!1),window.requestAnimationFrame(()=>{document.getElementById("extension-json-paste")?.scrollIntoView({behavior:"smooth",block:"center"})})},children:"Colar JSON"}),e.jsx(m,{type:"button",size:"sm",className:"h-9 min-h-9 shrink-0 touch-manipulation rounded-lg bg-gradient-to-r from-violet-600 via-fuchsia-600 to-purple-700 px-2.5 text-xs font-bold text-white hover:opacity-95 disabled:opacity-50",onClick:()=>void Yt(),disabled:ut,children:ut?e.jsx(De,{className:"h-4 w-4 animate-spin","aria-hidden":!0}):"Extensão"}),e.jsx(m,{type:"button",variant:"outline",size:"icon",className:"h-9 w-9 shrink-0 touch-manipulation rounded-lg border-violet-200",onClick:()=>Ke(!1),"aria-label":"Expandir bloco de captura",title:"Expandir",children:e.jsx(Ce,{className:"h-4 w-4","aria-hidden":!0})})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-col gap-4 md:flex-row md:items-start md:justify-between",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-xs font-black uppercase tracking-[0.22em] text-violet-500",children:"Captura de Ofertas via extensão"}),e.jsx("h3",{className:"mt-1 text-xl font-black tracking-tight text-slate-900",children:"Importar ofertas para a Galeria"}),e.jsxs("p",{className:"mt-2 text-sm text-slate-500",children:["Capture no"," ",e.jsx("strong",{className:"text-slate-600",children:"Shopee, Mercado Livre, Magalu, Amazon, TikTok Shop ou Shein"})," ","com a extensão no"," ",e.jsx("strong",{className:"text-slate-600",children:"mesmo navegador"})," ","(Chrome/Edge no PC ou ",e.jsx("strong",{className:"text-slate-600",children:"Orion no iPhone"}),"). As ofertas vão para a sua"," ",e.jsx("strong",{className:"text-slate-600",children:"Galeria"})," e também alimentam a"," ",e.jsx("strong",{className:"text-slate-600",children:"Vitrine global"}),". Se a ponte falhar, use"," ",e.jsx("strong",{className:"text-slate-600",children:"Copiar JSON"})," na extensão e ",e.jsx("strong",{className:"text-slate-600",children:"Colar JSON"})," ","abaixo â não abra a Galeria no Safari/PWA depois de capturar no Orion."]})]}),e.jsx(m,{type:"button",variant:"outline",size:"icon",className:"h-9 w-9 shrink-0 rounded-xl border-violet-200 bg-white text-violet-800 hover:bg-violet-50",onClick:()=>Ke(!0),"aria-label":"Minimizar bloco de captura via extensão",title:"Minimizar",children:e.jsx(Sr,{className:"h-4 w-4","aria-hidden":!0})})]}),e.jsx(gl,{className:"mt-3"})]}),e.jsxs("div",{className:"flex w-full flex-col gap-2 sm:w-auto md:min-w-[220px]",children:[e.jsx(m,{onClick:()=>void Yt(),disabled:ut,className:"h-11 min-h-[44px] touch-manipulation rounded-xl bg-gradient-to-r from-violet-600 via-fuchsia-600 to-purple-700 text-white hover:opacity-95",children:ut?"Importando captura...":"Importar captura da extensão"}),pa?e.jsxs("a",{href:pa,target:"_blank",rel:"noreferrer",className:"inline-flex items-center justify-center gap-1 text-sm font-bold text-violet-600 transition hover:text-violet-800",children:["Abrir página capturada",e.jsx(wt,{className:"h-4 w-4"})]}):null]})]}),e.jsx("div",{id:"extension-json-paste",children:e.jsx(fl,{className:"mt-4",value:kt,onChange:Ct,onImport:Go,disabled:!kt.trim(),importing:ut})})]})}),e.jsxs("section",{className:"overflow-hidden rounded-[24px] border border-violet-100 bg-white p-4 shadow-sm md:p-5",children:[e.jsxs("div",{className:"flex min-w-0 flex-col gap-4 lg:flex-row lg:items-start lg:justify-between",children:[e.jsxs("div",{className:"min-w-0 space-y-2",children:[e.jsx("p",{className:"text-xs font-black uppercase tracking-[0.22em] text-violet-500",children:"Sua biblioteca salva"}),e.jsx("h3",{className:"text-xl font-black tracking-tight text-slate-900 md:text-2xl",children:"Galeria de Ofertas"}),e.jsx("p",{className:"text-sm font-semibold text-violet-700",children:"Aqui você remove com (Ã), limpa tudo e opera o que já salvou â diferente da aba Pesquisar (catálogo da vitrine)."}),e.jsx("p",{className:"hidden text-sm leading-6 text-slate-500 md:block",children:"Organize, filtre e prepare sua biblioteca com menos poluição visual."}),e.jsxs("details",{className:"group md:hidden",children:[e.jsxs("summary",{className:"inline-flex min-h-11 touch-manipulation list-none items-center gap-2 rounded-full border border-violet-200 bg-vi
50olet-50 px-3 py-2 text-xs font-bold text-violet-700 [&_::-webkit-details-marker]:hidden",children:[e.jsx(mo,{className:"h-4 w-4 shrink-0","aria-hidden":!0}),"Como usar",e.jsx(Ce,{className:"h-4 w-4 shrink-0 transition-transform group-open:rotate-180","aria-hidden":!0})]}),e.jsxs("div",{className:"mt-2 rounded-2xl border border-violet-100 bg-white p-3 text-[13px] leading-relaxed text-slate-600 shadow-sm",children:["Use a ordenação e marque ofertas visÃveis para operações em lote. Toque em"," ",e.jsx("strong",{className:"font-semibold text-slate-800",children:"Limpar galeria"})," para remover tudo e importar ofertas novas."]})]})]}),e.jsxs("div",{className:"flex w-full min-w-0 flex-wrap items-stretch gap-2 sm:items-center",children:[e.jsx(m,{type:"button",onClick:()=>void Yt(),disabled:ut,className:"h-11 min-h-11 w-full min-w-0 touch-manipulation rounded-xl bg-gradient-to-r from-violet-600 via-fuchsia-600 to-purple-700 px-3 text-sm font-bold text-white hover:opacity-95 sm:w-auto sm:max-w-full",children:ut?e.jsxs("span",{className:"inline-flex items-center gap-2",children:[e.jsx(De,{className:"h-4 w-4 animate-spin","aria-hidden":!0}),"Importandoâ¦"]}):e.jsx("span",{className:"truncate",children:"Importar da extensão"})}),e.jsx("div",{className:"w-full min-w-0 sm:w-[200px] sm:max-w-full",children:e.jsxs("select",{value:te,onChange:t=>Pe(t.target.value),className:"h-10 w-full rounded-xl border border-violet-100 bg-white px-3 text-sm font-semibold text-slate-700 outline-none",children:[e.jsx("option",{value:"maiorPreco",children:"Maior Preço"}),e.jsx("option",{value:"menorPreco",children:"Menor preço"}),e.jsx("option",{value:"maiorComissao",children:"Maior Comissão"}),e.jsx("option",{value:"maiorDesconto",children:"Maior desconto"}),e.jsx("option",{value:"menorDesconto",children:"Menor desconto"}),e.jsx("option",{value:"maisVendidos",children:"Mais Vendidos"})]})}),e.jsxs(m,{type:"button",variant:"outline",onClick:()=>ue(t=>!t),className:"hidden h-10 min-h-10 shrink-0 touch-manipulation rounded-xl border-violet-200 bg-white px-3 text-violet-700 hover:bg-violet-50 md:inline-flex","aria-pressed":O,title:O?"Desativar modo compacto":"Ativar modo compacto",children:[e.jsx(yr,{className:"mr-2 h-4 w-4 shrink-0","aria-hidden":!0}),O?"Compacto: ON":"Compacto: OFF"]}
50),e.jsxs(m,{variant:"outline",onClick:ji,className:"hidden h-10 min-h-10 shrink-0 touch-manipulation rounded-xl border-violet-200 bg-white px-3 text-violet-700 hover:bg-violet-50 md:inline-flex",children:[e.jsx(Ne,{className:"mr-2 h-4 w-4 shrink-0"}),"Marcar visÃveis"]}),e.jsxs(m,{type:"button",variant:"outline",disabled:Q.length===0||Ze.isLoading||Tt.isPending,className:"group h-10 min-h-10 w-full min-w-0 shrink-0 touch-manipulation rounded-xl border-rose-200 bg-white px-3 text-rose-800 shadow-none hover:bg-rose-50 disabled:opacity-50 sm:w-auto",onClick:()=>wa(!0),children:[Tt.isPending?e.jsx(De,{className:"mr-2 h-4 w-4 animate-spin","aria-hidden":!0}):e.jsx(Le,{className:"mr-2 h-4 w-4 shrink-0 text-rose-600","aria-hidden":!0}),"Limpar galeria"]}),e.jsxs(Dt,{children:[e.jsx(Ft,{asChild:!0,children:e.jsx(m,{type:"button",variant:"outline",size:"icon",className:"h-10 w-10 shrink-0 touch-manipulation rounded-xl border-violet-200 bg-white text-violet-700 hover:bg-violet-50 md:hidden","aria-label":"Ações da biblioteca",title:"Ações",children:e.jsx(Ua,{className:"h-5 w-5","aria-hidden":!0})})}),e.jsx($t,{align:"end",sideOffset:8,className:"w-56",children:e.jsxs(be,{onSelect:t=>{t.preventDefault(),ji()},children:[e.jsx(Ne,{className:"mr-2 h-4 w-4","aria-hidden":!0}),"Marcar visÃveis"]})})]})]})]}),e.jsx(Ai,{open:No,onOpenChange:wa,children:e.jsxs(Ii,{className:"max-w-[min(100vw-1.5rem,28rem)] rounded-2xl border-violet-100",children:[e.jsxs(Oi,{children:[e.jsx(Ti,{children:"Limpar a galeria?"}),e.jsx(Ri,{className:"text-left text-sm leading-relaxed text-slate-600",children:"Todas as ofertas da sua Galeria serão removidas da conta. Use isso para recomeçar e importar ou minerar ofertas atualizadas na Vitrine ou em Pesquisar. O catálogo compartilhado da Vitrine não é alterado. Envios já agendados na fila continuam como estão."})]}),e.jsxs(Ei,{className:"flex-col-reverse gap-2 sm:flex-row",children:[e.jsx(Li,{className:"mt-0 h-11 touch-manipulation rounded-xl",children:"Cancelar"}),e.jsx(m,{type:"button",className:"h-11 touch-manipulation rounded-xl bg-rose-600 text-white hover:bg-rose-700 focus-visible:ring-rose-400",disabled:Tt.isPending,onClick:()=>Tt.mutate(),children:Tt.isPending?e.jsxs(e.Fragment,{children:[e.jsx(De,{className:"mr-2 h-4 w-4 animate-spin","aria-hidden":!0}),"Removendoâ¦"]}):"Limpar galeria"})]})]})}),e.jsx(Ai,{open:wo,onOpenChange:ya,children:e.jsxs(Ii,{className:"max-w-[min(100vw-1.5rem,28rem)] rounded-2xl border-rose-100",children:[e.jsxs(Oi,{children:[e.jsxs(Ti,{className:"flex items-center gap-2 text-slate-900",children:[e.jsx(Le,{className:"h-5 w-5 text-rose-600"}),"Excluir ofertas selecionadas?"]}),e.jsxs(Ri,{className:"text-left text-sm leading-relaxed text-slate-600",children:["Você está prestes a excluir"," ",e.jsxs("strong",{className:"text-slate-900",children:[f.length," oferta(s)"]})," ","selecionada(s) da sua galeria. Esta ação não poderá ser desfeita."]})]}),e.jsxs(Ei,{className:"flex-col-reverse gap-2 sm:flex-row",children:[e.jsx(Li,{className:"mt-0 h-11 touch-manipulation rounded-xl",children:"Cancelar"}),e.jsx(m,{type:"button",className:"h-11 touch-manipulation rounded-xl bg-rose-600 text-white hover:bg-rose-700 focus-visible:ring-rose-400",disabled:Ar,onClick:()=>void Wo(),children:Ar?e.jsxs(e.Fragment,{children:[e.jsx(De,{className:"mr-2 h-4 w-4 animate-spin","aria-hidden":!0}),"Excluindoâ¦"]}):`Excluir ${f.length} selecionada(s)`})]})]})}),e.jsxs("div",{className:"mt-4 space-y-3",children:[e.jsx(hc,{importing:ut,onImportFromExtension:()=>void Yt()}),e.jsx(bc,{importing:ut,onImportFromExtension:()=>void Yt()})]}),e.jsxs("div",{className:"mt-4 space-y-4",children:[e.jsxs("div",{className:"relative",children:[e.jsx(it,{className:"absolute left-3 top-3 h-4 w-4 text-violet-300"}),e.jsx(oe,{placeholder:"Ex.: ferro de passar, celular, tênisâ¦",className:"h-10 rounded-xl border-violet-100 bg-violet-50/60 pl-10",value:d,onChange:t=>h(t.target.value),autoComplete:"off"})]}),e.jsx("p",{className:"text-[11px] leading-snug text-violet-600/85",children:"Busca instantânea na sua biblioteca: filtra a cada letra. Várias palavras afinam o resultado (todas precisam aparecer no texto)."}),e.jsx("div",{className:"flex flex-wrap gap-2",children:gc.map(t=>{const a=g.includes(t);return e.jsx("button",{type:"button",onClick:()=>
50yn(t),className:N("rounded-xl border px-3 py-2 text-xs font-bold transition-all",a?"border-violet-500 bg-violet-600 text-white shadow-sm":"border-slate-200 bg-slate-50 text-slate-600 hover:border-violet-200 hover:bg-violet-50"),children:vt(t)},t)})}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(je,{children:[tt.length," oferta(s)"]}),e.jsxs(je,{children:[f.length," selecionada(s)"]}),e.jsxs(je,{children:[g.length," filtro(s) ativo(s)"]}),tt.length>0?e.jsxs("button",{type:"button",onClick:()=>{const t=tt.map(a=>Number(a.id)).filter(a=>a>0);y(a=>Array.from(new Set([...a,...t])))},className:"inline-flex min-h-9 touch-manipulation items-center rounded-full border border-violet-200 bg-white px-3 py-1 text-xs font-semibold text-violet-700 transition hover:bg-violet-50",title:"Marcar todas as ofertas visÃveis nesta listagem",children:[e.jsx(Ss,{className:"mr-1 h-3.5 w-3.5"}),"Selecionar visÃveis (",tt.length,")"]}):null,f.length>0?e.jsxs(e.Fragment,{children:[e.jsxs("button",{type:"button",onClick:()=>y([]),className:"inline-flex min-h-9 touch-manipulation items-center rounded-full border border-slate-200 bg-white px-3 py-1 text-xs font-semibold text-slate-700 transition hover:bg-slate-100",title:"Desmarcar todas as ofertas selecionadas",children:[e.jsx(Se,{className:"mr-1 h-3.5 w-3.5"}),"Desmarcar"]}),e.jsxs("button",{type:"button",onClick:()=>ya(!0),className:"inline-flex min-h-9 touch-manipulation items-center rounded-full border border-rose-300 bg-rose-50 px-3 py-1 text-xs font-bold text-rose-700 transition hover:bg-rose-100 shadow-sm",title:"Excluir apenas as ofertas selecionadas da galeria",children:[e.jsx(Le,{className:"mr-1 h-3.5 w-3.5 text-rose-600"}),"Excluir selecionadas (",f.length,")"]})]}):null,e.jsxs("button",{type:"button",onClick:()=>{if(F){Ws();return}if(za.length===0){Js();return}ae(!0),Me("biblioteca"),_e("library"),r(Fi(),{replace:!0})},onContextMenu:t=>{t.preventDefault(),Js()},className:N("inline-flex min-h-9 touch-manipulation items-center rounded-full border px-3 py-1 text-xs font-semibold transition",F?"border-amber-400 bg-amber-100 text-amber-950":"border-slate-200 bg-white text-slate-700 hover:bg-amber-50"),children:["Espelho WhatsApp",za.length>0?` (${za.length})`:" · configurar"]}),d||g.length>0||te!=="maiorComissao"||F?e.jsxs("button",{type:"button",onClick:Ln,className:"inline-flex min-h-9 touch-manipulation items-center rounded-full border border-violet-200 bg-white px-3 py-1 text-xs font-semibold text-violet-700 transition hover:bg-violet-50",children:[e.jsx(Se,{className:"mr-1 h-3.5 w-3.5"}),"Limpar filtros"]}):null,Q.length>0&&!Ze.isLoading?e.jsxs("button",{type:"button",disabled:Tt.isPending,onClick:()=>wa(!0),className:"inline-flex min-h-9 touch-manipulation items-center rounded-full border border-rose-200 bg-rose-50 px-3 py-1 text-xs font-semibold text-rose-800 transition hover:bg-rose-100 disabled:opacity-50",children:[Tt.isPending?e.jsx(De,{className:"mr-1 h-3.5 w-3.5 animate-spin","aria-hidden":!0}):e.jsx(Le,{className:"mr-1 h-3.5 w-3.5","aria-hidden":!0}),"Limpar galeria"]}):null]})]})]}),as.isLoading?e.jsx("section",{className:"rounded-[24px] border border-orange-100 bg-white p-4 shadow-sm md:p-5",children:e.jsx(Nt,{title:"Campanhas Shopee",hint:"Carregandoâ¦",children:Array.from({length:6}).map((t,a)=>e.jsxs("div",{className:"w-[148px] shrink-0 snap-start overflow-hidden rounded-[14px] border border-orange-100 bg-white shadow-sm",children:[e.jsx("div",{className:"aspect-[3/4] animate-pulse bg-orange-50"}),e.jsxs("div",{className:"space-y-2 p-2",children:[e.jsx("div",{className:"h-3 animate-pulse rounded bg-orange-100"}),e.jsx("div",{className:"h-6 animate-pulse rounded bg-orange-100"}),e.jsx("div",{className:"h-8 animate-pulse rounded-lg bg-orange-100"})]})]},a))})}):di.length>0?e.jsxs("section",{className:"space-y-4 rounded-[24px] border-2 border-orange-200/80 bg-gradient-to-b from-orange-50/95 to-white p-4 shadow-md md:p-5",children:[e.jsxs("div",{className:"rounded-xl border border-orange-200 bg-orange-50/80 px-4 py-3 shadow-sm",children:[e.jsx("p",{className:"text-[10px] font-black uppercase tracking-[0.18em] text-orange-600",children:"Campanhas Shopee (API â sem preço no servidor)"}),e.jsx("p",{className:"mt-1 text-sm font-semibold text-orange-950",children:"Abra cada campanha na Shopee, use a extensão e importe aqui. Os produtos com preço passam para a grade da pesquisa e para a biblioteca; estes cartões deixam de ser campanha pura."}),e.jsx(m,{type:"button",variant:"outline",size:"sm",className:"mt-2 h-10 touch-manipulation rounded-xl border-orange-300 bg-white text-orange-900 hover:bg-orange-50",onClick:mi,children:"Ir para captura / extensão"})]}),di.map(([t,a])=>e.jsx(Nt,{title:t==="Sem categoria"?"Campanhas Shopee":t,hint:`${a.length} · deslize`,children:a.map(i=>{const p=Ms(i);return e.jsx(oa,{offer:i,selected:tr.has(Number(i.id)),formatCurrency:We,formatPlatformName:vt,formatCommission:_a,onToggle:()=>Wr(Number(i.id)),onPrimary:()=>Qr(Number(i.id)),primaryMode:"cart",primaryDisabled:!Ae,secondaryLabel:tr.has(Number(i.id))?"Desmarcar":"Marcar",primaryLabel:Ae?"Adicionar ao carrinho":"Premium para carrinho",campaignShopeeApi:!0,campaignOpenUrl:p||void 0,onScrollToExtension:mi},i.id)})},`galeria-shopee-api-${t}`))]}):ke.length>0&&Xs.length===0?e.jsx("p",{className:"rounded-xl border border-dashed border-orange-200/80 bg-orange-50/40 px-4 py-3 text-center text-xs leading-relaxed text-orange-900/85",children:"Sem campanhas Shopee (API) neste recorte. Afrouxe os filtros na aba Pesquisar ou minere de novo â quando houver, aparecem aqui por categoria, como na vitrine."}):null,f.length>0?e.jsxs("section",{className:"rounded-[24px] border border-violet-200 bg-white p-4 shadow-sm md:p-5",children:[e.jsxs("div",{className:"flex flex-col gap-3 md:flex-row md:items-center md:justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-black uppercase tracking-[0.22em] text-violet-500",children:"Seleção ativa"}),e.jsxs("h3",{className:"mt-1 text-lg font-black text-slate-900",children:[f.length," oferta(s) selecionada(s)"]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 md:flex md:flex-wrap",children:[e.jsxs(m,{variant:"outline",onClick:ir,className:"h-10 rounded-xl border-violet-200 bg-white text-violet-700 hover:bg-violet-50",children:[e.jsx(jt,{className:"mr-2 h-4 w-4"}),"Favoritar"]}),e.jsxs(m,{variant:"outline",onClick:()=>qo({}),className:"h-10 rounded-xl border-violet-200 bg-white text-violet-700 hover:bg-violet-50",children:[e.jsx(lr,{className:"mr-2 h-4 w-4"}),"Templates"]}),e.jsxs(m,{onClick:()=>et(),className:"h-10 rounded-xl bg-violet-600 text-white hover:bg-violet-700",children:[e.jsx(Fe,{className:"mr-2 h-4 w-4"}),"Agendar"]}),e.jsxs(m,{variant:"outline",onClick:()=>ya(!0),className:"h-10 rounded-xl border-rose-200 bg-rose-50/70 text-rose-700 hover:bg-rose-100 hover:border-rose-300",title:"Excluir ofertas selecionadas da galeria",children:[e.jsx(Le,{className:"mr-2 h-4 w-4 text-rose-600"}),"Excluir selecionadas"]}),e.jsxs(m,{variant:"ghost",onClick:()=>y([]),className:"h-10 rounded-xl text-slate-500 hover:bg-slate-100",title:"Desmarcar todas",children:[e.jsx(Se,{className:"mr-1.5 h-4 w-4"}),"Desmarcar"]})]})]}),e.jsxs("div",{className:"mt-4 grid gap-3 sm:grid-cols-2 xl:grid-cols-3",children:[e.jsx(gr,{label:"Favoritas na seleção",value:String(qa.filter(t=>Number(t.isFavorite||0)===1).length),helper:"Prioridade comercial"}),e.jsx(gr,{label:"Prontas",value:String(qa.filter(t=>String(t.status||"")==="ready").length),helper:"Status operacional"}),e.jsx(gr,{label:"Fila atual",value:String(Ge.length),helper:"Agendamentos pendentes"})]})]}):null,F?e.jsxs("div",{className:"flex flex-col gap-3 rounded-2xl border border-amber-200 bg-gradient-to-r from-amber-50 to-orange-50/80 p-3 shadow-sm sm:p-4 md:flex-row md:items-center md:justify-between",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-xs font-black uppercase tracking-[0.18em] text-amber-700",children:"Espelho WhatsApp"}),e.jsxs("p",{className:"mt-1 text-sm font-semibold leading-snug text-amber-950",children:[at.length," oferta(s) importada(s) de"," ",ms.length," lote(s) · agrupadas por grupo e horário"]})]}),e.jsxs("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2 md:flex md:flex-wrap md:justify-end",children:[e.jsx(m,{type:"button",variant:"outline",className:"h-11 min-h-[44px] w-full touch-manipulation rounded-xl border-amber-300 bg-white text-xs font-bold text-amber-950 sm:w-auto",onClick:Do,children:"Selecionar todas"}),e.jsx(m,{type:"button",className:"h-11 min-h-[44px] w-full touch-manipulation rounded-xl bg-amber-600 text-xs font-bold text-white hover:bg-amber-700 sm:w-auto",onClick:()=>et(),disabled:f.length===0,children:"Agendar seleção"}),e.jsx("p",{className:"text-[11px] leading-snug text-amber-900/85 sm:basis-full",children:"Sem foto? Use «Enviar foto» no card ou volte ao Espelho e use «Buscar fotos e preços»."}),e.jsx(m,{type:"button",variant:"ghost",className:"h-11 min-h-[44px] w-full touch-manipulation rounded-xl text-xs font-bold text-amber-900 sm:w-auto",onClick:Ws,children:"Ver galeria completa"})]})]}):null,D&&ne.length>0?e.jsxs("div",{className:"flex flex-col gap-3 rounded-2xl border border-amber-200 bg-amber-50/95 p-4 shadow-sm sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("p",{className:"text-sm font-semibold leading-snug text-amber-950",children:["Mostrando só as ",ne.length," oferta(s) em foco na biblioteca (selecionadas). As demais continuam salvas."]}),e.jsx(m,{type:"button",variant:"outline",className:"h-11 min-h-11 shrink-0 touch-manipulation rounded-xl border-amber-300 bg-white text-amber-950 hover:bg-amber-100",onClick:()=>E(!1),children:"Ver biblioteca completa"})]}):null,e.jsxs("div",{id:"offers-library-offers",className:"scroll-mt-28 space-y-6 md:space-y-8",children:[e.jsx("div",{className:N("space-y-6",F?"lg:hidden":"md:hidden"),children:Ze.isLoading?e.jsx(Nt,{title:"Carregando bibliotecaâ¦",hint:"Arraste para o lado para ver placeholders",children:Array.from({length:8}).map((t,a)=>e.jsxs("div",{className:"w-[148px] shrink-0 snap-start overflow-hidden rounded-[14px] border border-violet-100 bg-white shadow-sm",children:[e.jsx("div",{className:"aspect-[3/4] animate-pulse bg-violet-100"}),e.jsxs("div",{className:"space-y-2 p-2",children:[e.jsx("div",{className:"h-3 animate-pulse rounded bg-vi
50olet-100"}),e.jsx("div",{className:"h-6 animate-pulse rounded bg-violet-100"}),e.jsx("div",{className:"h-8 animate-pulse rounded-lg bg-violet-100"})]})]},a))}):at.length===0?D&&ne.length>0?e.jsxs("div",{className:"rounded-[18px] border border-dashed border-amber-200 bg-amber-50/60 px-4 py-8 text-center",children:[e.jsx("p",{className:"text-sm font-semibold text-amber-950",children:"Não encontramos essas ofertas na lista carregada"}),e.jsx("p",{className:"mt-1 text-xs leading-relaxed text-amber-900/85",children:"A seleção não bateu com os itens da biblioteca neste momento (IDs ou sincronização). Tente atualizar a página ou volte à vista completa."}),e.jsx(m,{type:"button",variant:"outline",className:"mt-4 h-11 min-h-11 touch-manipulation rounded-xl border-amber-300 bg-white text-amber-950 hover:bg-amber-100",onClick:()=>E(!1),children:"Ver biblioteca completa"})]}):e.jsxs("div",{className:"rounded-[18px] border border-dashed border-violet-200 bg-violet-50/40 px-4 py-8 text-center",children:[e.jsx("p",{className:"text-sm font-semibold text-slate-700",children:"Nenhuma oferta neste filtro"}),e.jsx("p",{className:"mt-1 text-xs text-slate-500",children:"Ajuste a busca ou os filtros de loja."})]}):F?ms.map(t=>e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex flex-col gap-2 px-1 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("p",{className:"text-xs font-bold leading-snug text-amber-900 sm:text-[11px]",children:[t.dayLabel,t.timeRangeLabel?` · ${t.timeRangeLabel}`:""]}),e.jsx(m,{type:"button",variant:"outline",size:"sm",className:"h-10 min-h-[44px] w-full touch-manipulation rounded-lg border-amber-300 bg-white px-3 text-[11px] font-bold text-amber-950 sm:h-8 sm:min-h-8 sm:w-auto sm:px-2 sm:text-[10px]",onClick:()=>Lo(t.items),children:"Selecionar lote"})]}),e.jsxs("div",{className:"space-y-3 md:hidden",children:[e.jsxs("div",{className:"px-1",children:[e.jsx("p",{className:"text-sm font-black text-slate-900",children:t.groupName}),e.jsxs("p",{className:"text-[11px] font-medium text-slate-500",children:[t.items.length," oferta(s)"]})]}),t.items.map(a=>e.jsx("div",{"data-library-offer-id":a.id,className:N(_===Number(a.id)&&"rounded-[14px] ring-2 ring-amber-400 ring-offset-2"),children:e.jsx(oa,{layout:"fluid",offer:a,selected:Rt(a),formatCurrency:We,formatPlatformName:vt,formatCommission:i=>Ie(i)>0?`${Ie(i).toFixed(1)}%`:"â",onToggle:()=>ps(a.id),onRemove:()=>cs(a.id),isRemoving:ds(a.id),onUploadProductImage:i=>void ns(a.id,i),isUploadingImage:ls(a.id),onPrimary:()=>et(a.id),primaryMode:"schedule",secondaryLabel:Rt(a)?"Remover seleção":"Selecionar oferta",primaryLabel:"Agendar envio",footer:e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("span",{className:"text-[10px] font-bold leading-snug text-slate-500",children:[a.mirrorImportedAt?new Date(a.mirrorImportedAt).toLocaleString("pt-BR",{day:"2-digit",month:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}):null,a.status==="ready"?e.jsx("span",{className:"text-emerald-600",children:" · Pronta"}):" · Salva"]}),a.convertedUrl||a.originalUrl?e.jsx("a",{href:String(a.convertedUrl||a.originalUrl),target:"_blank",rel:"noopener noreferrer",className:"inline-flex min-h-[44px] touch-manipulation items-center justify-center rounded-lg border border-slate-200 bg-white px-3 text-[11px] font-bold text-slate-800 hover:bg-slate-50",children:"Abrir oferta"}):null]})})},a.id))]}),e.jsx("div",{className:"hidden md:block lg:hidden",children:e.jsx(Nt,{title:t.groupName,hint:`${t.items.length} oferta(s) â arraste`,children:t.items.map(a=>e.jsx("div",{"data-library-offer-id":a.id,className:N("w-[min(72vw,260px)] shrink-0 snap-start",_===Number(a.id)&&"rounded-[14px] ring-2 ring-amber-400 ring-offset-2"),children:e.jsx(oa,{offer:a,selected:Rt(a),formatCurrency:We,formatPlatformName:vt,formatCommission:i=>Ie(i)>0?`${Ie(i).toFixed(1)}%`:"â",onToggle:()=>ps(a.id),onRemove:()=>cs(a.id),isRemoving:ds(a.id),onUploadProductImage:i=>void ns(a.id,i),isUploadingImage:ls(a.id),onPrimary:()=>et(a.id),primaryMode:"schedule",secondaryLabel:Rt(a)?"Remover seleção":"Selecionar oferta",primaryLabel:"Agendar envio",footer
50:e.jsx("div",{className:"flex items-center justify-between gap-2",children:e.jsxs("span",{className:"text-[9px] font-bold text-slate-500",children:[a.mirrorImportedAt?new Date(a.mirrorImportedAt).toLocaleString("pt-BR",{day:"2-digit",month:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}):null,a.status==="ready"?e.jsx("span",{className:"text-emerald-600",children:" · Pronta"}):" · Salva"]})})})},a.id))})})]},t.key)):tn.map(([t,a])=>e.jsx(Nt,{title:t,hint:`${a.length} oferta(s) â arraste para o lado`,children:a.map(i=>e.jsx("div",{"data-library-offer-id":i.id,className:N("w-[148px] shrink-0 snap-start",_===Number(i.id)&&"rounded-[14px] ring-2 ring-amber-400 ring-offset-2"),children:e.jsx(oa,{offer:i,selected:Rt(i),formatCurrency:We,formatPlatformName:vt,formatCommission:p=>Ie(p)>0?`${Ie(p).toFixed(1)}%`:"â",onToggle:()=>ps(i.id),onRemove:()=>cs(i.id),isRemoving:ds(i.id),onUploadProductImage:p=>void ns(i.id,p),isUploadingImage:ls(i.id),onPrimary:()=>et(i.id),primaryMode:"schedule",secondaryLabel:Rt(i)?"Remover seleção":"Selecionar oferta",primaryLabel:"Agendar envio",footer:e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("span",{className:"text-[9px] font-bold text-slate-500",children:[i.status==="ready"?e.jsx("span",{className:"text-emerald-600",children:"Pronta"}):"Salva",Number(i.isFavorite||0)===1?e.jsx("span",{className:"text-violet-600",children:" · Fav."}):null]}),e.jsxs(Dt,{children:[e.jsx(Ft,{asChild:!0,children:e.jsx(m,{variant:"ghost",type:"button",className:"h-8 w-8 touch-manipulation rounded-full p-0 text-slate-600 hover:bg-slate-100","aria-label":"Mais ações",title:"Mais ações",children:e.jsx(Ua,{className:"h-4 w-4","aria-hidden":!0})})}),e.jsxs($t,{align:"end",sideOffset:8,className:"w-44",children:[e.jsxs(be,{onSelect:p=>{p.preventDefault(),os.mutate({offerId:i.id,isFavorite:Number(i.isFavorite||0)!==1})},children:[e.jsx(jt,{className:"mr-2 h-4 w-4 text-violet-600","aria-hidden":!0}),Number(i.isFavorite||0)===1?"Desfavoritar":"Favoritar"]}),e.jsxs(be,{onSelect:p=>{p.preventDefault(),is.mutate({offerId:i.id,status:"ready"})},children:[e.jsx(Ne,{className:"mr-2 h-4 w-4 text-emerald-600","aria-hidden":!0}),"Marcar pronta"]}),e.jsx(ks,{}),e.jsxs(be,{className:"text-rose-700 focus:text-rose-700",onSelect:p=>{p.preventDefault(),Ue.mutate({offerId:i.id})},children:[e.jsx(Le,{className:"mr-2 h-4 w-4","aria-hidden":!0}),"Excluir"]})]})]})]})})},i.id))},t))}),e.jsx("section",{className:N(F?"hidden lg:grid":"hidden md:grid",F?"gap-3.5 sm:gap-4 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4":O?"gap-3 sm:gap-3.5 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5 2xl:grid-cols-6":"gap-3.5 sm:gap-4 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5 2xl:grid-cols-6"),children:Ze.isLoading?Array.from({length:6}).map((t,a)=>e.jsxs("div",{className:"rounded-[24px] border border-violet-100 bg-white p-4 shadow-sm",children:[e.jsx("div",{className:"skeleton h-44 rounded-[18px]"}),e.jsxs("div",{className:"mt-4 space-y-3",children:[e.jsx("div",{className:"skeleton h-4 w-24"}),e.jsx("div",{className:"skeleton h-5 w-full"}),e.jsx("div",{className:"skeleton h-5 w-3/4"}),e.jsx("div",{className:"skeleton h-10 w-full rounded-xl"})]})]},a)):at.length>0?at.map(t=>e.jsx("div",{"data-library-offer-id":t.id,className:N(_===Number(t.id)&&"rounded-[24px] ring-2 ring-amber-400 ring-offset-2"),children:e.jsx(Pr,{offer:{...t,currentPrice:Z(t.currentPrice)??0,originalPrice:Z(t.originalPrice)??0,discountPercent:Number(t.discountPercent||0),commissionPercent:Ie(t.commissionPercent),commissionAmount:Z(t.commissionAmount)??0,commissionSourceLabel:t.commissionSourceLabel||null},selected:Rt(t),onToggle:a=>ps(a),onRemove:cs,isRemoving:ds(t.id),onUploadProductImage:(a,i)=>void ns(a,i),isUploadingImage:ls(t.id),formatCurrency:We,formatPercent:_a,cn:N,density:O?"compact":"default",extension:O?e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(je,{children:["Status: ",t.status]}),Number(t.isFavorite||0)===1?e.jsx(je,{children:"Favorita"}):null]}),e.jsxs(Dt,{children:[e.jsx(Ft,{asChild:!0,children:e.jsx(m,{variant:"outline",type:"button",className:"h-9 w-10 touch-manipulation rounded-xl border-slate-200 bg-white p-0 text-slate-700 shadow-none hover:bg-white","aria-label":"Mais ações",title:"Mais ações",children:e.jsx(Ua,{className:"h-4 w-4","aria-hidden":!0})})}),e.jsxs($t,{align:"end",sideOffset:8,className:"w-48",children:[e.jsxs(be,{onSelect:a=>{a.preventDefault(),os.mutate({offerId:t.id,isFavorite:Number(t.isFavorite||0)!==1})},children:[e.jsx(jt,{className:"mr-2 h-4 w-4 text-violet-600","aria-hidden":!0}),Number(t.isFavorite||0)===1?"Desfavoritar":"Favoritar"]}),e.jsxs(be,{onSelect:a=>{a.preventDefault(),is.mutate({offerId:t.id,status:"ready"})},children:[e.jsx(Ne,{className:"mr-2 h-4 w-4 text-emerald-600","aria-hidden":!0}),"Marcar pronta"]}),e.jsx(ks,{}),e.jsxs(be,{onSelect:a=>{a.preventDefault(),ci.mutate({offerId:t.id})},children:[e.jsx(kr,{className:"mr-2 h-4 w-4","aria-hidden":!0}),"Arquivar"]}),e.jsxs(be,{className:"text-rose-700 focus:text-rose-700",onSelect:a=>{a.preventDefault(),Ue.mutate({offerId:t.id})},children:[e.jsx(Le,{className:"mr-2 h-4 w-4","aria-hidden":!0}),"Excluir"]})]})]})]}):e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(je,{children:["Status: ",t.status]}),St.includes(Number(t.sourceOfferId||0))?e.jsx(je,{children:"Importada agora"}):null,Number(t.isFavorite||0)===1?e.jsx(je,{children:"Favorita"}):null]}),e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[t.convertedUrl||t.originalUrl||t.productUrl?e.jsxs("a",{href:t.convertedUrl||t.originalUrl||t.productUrl,target:"_blank",rel:"noreferrer",className:"inline-flex flex-1 items-center justify-center gap-2 rounded-xl border border-violet-200 bg-white px-3 py-2 text-sm font-semibold text-violet-700 transition hover:bg-violet-50",children:[String(t.platform||"").toLowerCase()==="shopee"?"Abrir campanha":"Abrir oferta",e.jsx(wt,{className:"h-4 w-4"})]}):e.jsx("div",{className:"flex-1"}),e.jsxs(Dt,{children:[e.jsx(Ft,{asChild:!0,children:e.jsx(m,{variant:"outline",type:"button",className:"h-10 w-10 touch-manipulation rounded-xl border-slate-200 bg-white p-0 text-slate-700 shadow-none hover:bg-white","aria-label":"Mais ações",title:"Mais ações",children:e.jsx(Ua,{className:"h-4 w-4","aria-hidden":!0})})}),e.jsxs($t,{align:"end",sideOffset:8,className:"w-48",children:[e.jsxs(be,{onSelect:a=>{a.preventDefault(),os.mutate({offerId:t.id,isFavorite:Number(t.isFavorite||0)!==1})},children:[e.jsx(jt,{className:"mr-2 h-4 w-4 text-violet-600","aria-hidden":!0}),Number(t.isFavorite||0)===1?"Desfavoritar":"Favoritar"]}),e.jsxs(be,{onSelect:a=>{a.preventDefault(),is.mutate({offerId:t.id,status:"ready"})},children:[e.jsx(Ne,{className:"mr-2 h-4 w-4 text-emerald-600","aria-hidden":!0}),"Marcar pronta"]}),e.jsx(ks,{}),e.jsxs(be,{onSelect:a=>{a.preventDefault(),ci.mutate({offerId:t.id})},children:[e.jsx(kr,{className:"mr-2 h-4 w-4","aria-hidden":!0}),"Arquivar"]}),e.jsxs(be,{className:"text-rose-700 focus:text-rose-700",onSelect:a=>{a.preventDefault(),Ue.mutate({offerId:t.id})},children:[e.jsx(Le,{className:"mr-2 h-4 w-4","aria-hidden":!0}),"Excluir"]})]})]})]})]})})},t.id)):D&&ne.length>0?e.jsxs("div",{className:"col-span-full rounded-[24px] border border-dashed border-amber-200 bg-amber-50/50 p-12 text-center shadow-sm",children:[e.jsx(Ts,{className:"mx-auto h-14 w-14 text-amber-300"}),e.jsx("h4",{className:"mt-4 text-xl font-black text-amber-950",children:"Seleção não encontrada n
50a lista"}),e.jsx("p",{className:"mx-auto mt-2 max-w-2xl text-sm leading-6 text-amber-900/90",children:"Não localizamos as ofertas marcadas na biblioteca carregada. Atualize a página ou volte à vista completa para rever tudo o que está salvo."}),e.jsx(m,{type:"button",variant:"outline",className:"mt-6 h-11 min-h-11 touch-manipulation rounded-xl border-amber-300 bg-white text-amber-950 hover:bg-amber-100",onClick:()=>E(!1),children:"Ver biblioteca completa"})]}):e.jsxs("div",{className:"col-span-full rounded-[24px] border border-dashed border-violet-200 bg-white p-12 text-center shadow-sm",children:[e.jsx(Ts,{className:"mx-auto h-14 w-14 text-violet-200"}),e.jsx("h4",{className:"mt-4 text-xl font-black text-slate-800",children:"Sua biblioteca ainda está vazia"}),e.jsx("p",{className:"mx-auto mt-2 max-w-2xl text-sm leading-6 text-slate-500",children:"Faça sua pesquisa pessoal acima, importe o que interessa e comece a organizar a sua operação."})]})})]})]}),e.jsxs("div",{id:"schedule-panel","data-schedule-panel":"true",ref:Da,className:N("space-y-4 md:space-y-6",me!=="operacao"&&"hidden"),children:[e.jsx("div",{className:"md:hidden",children:e.jsx(co,{title:"Radar da sua operação",subtitle:"Fila viva das campanhas da sua biblioteca.",totalScheduled:Ge.length,totalGroups:er.length,nextSendLabel:Zs?fr(new Date(Zs.executeAt)):"Sem próximo envio definido",items:er,emptyMessage:"Nenhum agendamento pendente neste momento.",actionLabel:"Ver histórico",onViewQueue:()=>r("/post-history")})}),e.jsxs("section",{className:"rounded-[24px] border border-violet-100 bg-white p-4 shadow-sm md:p-5",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs font-black uppercase tracking-[0.22em] text-violet-500",children:"Operação"}),e.jsx("h3",{className:"text-xl font-black tracking-tight text-slate-900",children:"Canais, ativos, IA/manual e prévia da campanha"}),e.jsx("p",{className:"text-sm leading-6 text-slate-500",children:"Organize tudo em sequência: escolha os canais, confirme os destinos, monte copy e imagem, ajuste o gancho e valide a prévia antes de agendar."})]}),e.jsxs("div",{className:"mt-4 grid gap-3 md:grid-cols-4",children:[e.jsx(Ns,{label:"Selecionadas",value:String(f.length)}),e.jsx(Ns,{label:"Canais",value:String($.length)}),e.jsx(Ns,{label:"Destinos",value:String(A.length)}),e.jsx(Ns,{label:"Fila",value:String(Ge.length)})]}),(va||f.length>0)&&R?e.jsxs("div",{className:"mt-5 grid gap-5 xl:grid-cols-[360px_minmax(0,1fr)]",children:[e.jsxs("div",{className:"space-y-4 max-xl:order-2",children:[e.jsxs("div",{className:"overflow-hidden rounded-[22px] border border-violet-100 bg-white shadow-sm",children:[e.jsx("div",{className:"aspect-square overflow-hidden bg-violet-50",children:R.productImage?e.jsx("img",{src:R.productImage,alt:R.productTitle,className:"h-full w-full object-cover",loading:"lazy",decoding:"async",referrerPolicy:"no-referrer"}):e.jsx("div",{className:"flex h-full items-center justify-center text-sm text-slate-400",children:"Sem imagem"})}),e.jsxs("div",{className:"space-y-3 p-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"line-clamp-2 text-sm font-black leading-5 text-slate-900",children:R.productTitle}),e.jsx("p",{className:"mt-2 text-2xl font-black text-slate-900",children:We(R.currentPrice)}),R.originalPrice?e.jsx("p",{className:"text-xs text-slate-400 line-through",children:We(R.originalPrice)}):null]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(je,{children:vt(R.platform)}),R.category?e.jsx(je,{children:R.category}):null,T?e.jsxs(je,{children:["Layout: ",T]}):null]})]})]}),e.jsxs("div",{className:"rounded-[18px] border border-violet-100 bg-violet-50/50 p-4",children:[e.jsxs("div",{className:"mb-3 flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-violet-700",children:[e.jsx(Si,{className:"h-4 w-4"}),e.jsx("span",{className:"text-sm font-semibold",children:"Prévia visual por canal"})]}),e.jsxs("span",{className:"text-xs font-semibold text-slate-500",children:[$.length," canal(is)"]})]}),e.jsx("div",{className:"mb-3 flex flex-wrap gap-2",children:$.map(t=>e.jsx("button",{type:"button",onClick:()=>
50nt(t),className:N("rounded-full border px-3 py-1.5 text-[11px] font-semibold transition-all",K===t?"border-violet-500 bg-violet-600 text-white":"border-violet-200 bg-white text-violet-700 hover:bg-violet-50"),children:Cc(t)},t))}),e.jsx(wc,{channel:K,title:String(R.productTitle||"Oferta"),highlightLine:Ba.hook,content:fi,previewImageUrl:vi,priceLabel:We(R.currentPrice),oldPriceLabel:R.originalPrice?We(R.originalPrice):"",destinations:dn})]}),e.jsxs("div",{className:"rounded-[18px] border border-violet-100 bg-violet-50/50 p-4",children:[e.jsxs("div",{className:"mb-2 flex items-center gap-2 text-violet-700",children:[e.jsx(Si,{className:"h-4 w-4"}),e.jsx("span",{className:"text-sm font-semibold",children:"Prévia do texto final"})]}),e.jsx(Nc,{className:"max-h-[360px] overflow-y-auto",hook:Ba.hook,bodyText:fi}),e.jsxs("div",{className:"mt-3 flex touch-manipulation flex-wrap gap-2",children:[e.jsxs(m,{type:"button",variant:"outline",size:"sm",className:"h-10 min-h-10 rounded-lg px-2.5 text-[11px]",onClick:()=>void wi(),children:[e.jsx(xr,{className:"mr-1 h-3.5 w-3.5"}),"Copiar texto"]}),e.jsxs(m,{type:"button",variant:"outline",size:"sm",className:"h-10 min-h-10 rounded-lg px-2.5 text-[11px]",onClick:()=>void yi(),children:[e.jsx(Ps,{className:"mr-1 h-3.5 w-3.5"}),"Copiar link"]}),e.jsxs(m,{type:"button",variant:"outline",size:"sm",className:"h-10 min-h-10 rounded-lg px-2.5 text-[11px]",onClick:()=>void ki(),children:[e.jsx(Pi,{className:"mr-1 h-3.5 w-3.5"}),"Compartilhar"]}),e.jsxs(m,{type:"button",variant:"outline",size:"sm",className:"h-10 min-h-10 rounded-lg px-2.5 text-[11px]",onClick:()=>void or(),children:[e.jsx(Mi,{className:"mr-1 h-3.5 w-3.5"}),"Baixar imagem"]})]})]})]}),e.jsxs("div",{className:"space-y-4 max-xl:order-1",children:[e.jsxs("div",{id:"operation-step-channels",className:"rounded-[18px] border border-violet-100 bg-violet-50/50 p-4",children:[e.jsx("p",{className:"text-xs font-black uppercase tracking-[0.18em] text-violet-500",children:"Passo 1 ⢠Canais de comunicação"}),e.jsx("div",{className:"mt-3 grid gap-3 sm:grid-cols-2",children:[{key:"telegram",label:"Telegram",icon:e.jsx(jr,{className:"h-4 w-4"})},{key:"whatsapp",label:"WhatsApp",icon:e.jsx(tl,{className:"h-4 w-4"})}].map(t=>{const a=$.includes(t.key);return e.jsxs("button",{type:"button","aria-pressed":a,onClick:()=>kn(t.key),className:N(Sl(a,"rounded-2xl px-4 py-4 text-left"),a&&"shadow-sm"),children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-bold",children:[t.icon,t.label]}),e.jsx("p",{className:N("mt-2 text-[11px]",a?"text-violet-100":"text-slate-400"),children:a?"Canal incluÃdo na operação":"Toque para incluir este canal"})]},t.key)})}),$.includes("whatsapp")?e.jsxs("div",{className:"mt-3 space-y-2",children:[e.jsx(vl,{compact:!0}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(oe,{value:Bt,onChange:t=>Mn(t.target.value),placeholder:"Telefone com DDD (ex: 11999998888)",className:"h-10 w-full border-violet-200 bg-white sm:max-w-xs"}),e.jsx(m,{type:"button",variant:"outline",onClick:Pn,disabled:rs.isPending,className:"h-10 rounded-xl border-amber-200 bg-amber-50 text-amber-700 hover:bg-amber-100",children:rs.isPending?"Solicitando código...":"Conectar por número"})]}),Cn==="PAIRING_CODE_READY"&&bs?e.jsxs("div",{className:"rounded-xl border border-amber-200 bg-amber-50 px-3 py-2 text-sm font-semibold text-amber-800",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("span",{children:["Código de pareamento:"," ",e.jsx("span",{className:"font-black tracking-widest",children:bs})]}),e.jsxs(m,{type:"button",variant:"outline",onClick:()=>void An(),className:N("h-8 rounded-lg border-amber-300 bg-white px-2 text-xs text-amber-800 hover:bg-amber-100",Kt.active&&"border-emerald-400 bg-emerald-50 text-emerald-900"),"aria-label":Kt.active?"Código copiado":"Copiar código de pareamento",title:Kt.active?"Copiado":"Copiar código",children:[Kt.active?e.jsx(Ss,{className:"mr-1 h-3.5 w-3.5 shrink-0","aria-hidden":!0}):e.jsx(xr,{className:"mr-1 h-3.5 w-3.5 shrink-0","aria-hidden":!0}),e.jsx("span",{className:"hidden sm:inline",children:Kt.active?"Copiado":"Copiar código"})]})]}),e.jsxs("div",{className:"mt-2 space-y-1 rounded-lg border border-amber-200/80 bg-white/60 px-2 py-2 text-xs font-medium text-amber-800",children:[e.jsxs("p",{children:[e.jsx("span",{className:"mr-1 inline-flex h-4 w-4 items-center justify-center rounded-full bg-amber-200 text-[10px] font-black text-amber-900",children:"1"}),"Abra o WhatsApp no celular."]}),e.jsxs("p",{children:[e.jsx("span",{className:"mr-1 inline-flex h-4 w-4 items-center justify-center rounded-full bg-amber-200 text-[10px] font-black text-amber-900",children:"2"}),"Acesse Dispositivos conectados e toque em Conectar com número."]}),e.jsxs("p",{children:[e.jsx("span",{className:"mr-1 inline-flex h-4 w-4 items-center justify-center rounded-full bg-amber-200 text-[10px] font-black text-amber-900",children:"3"}),"Digite o código acima para concluir."]})]})]}):null]}):null]}),e.jsxs("div",{id:"operation-step-destinations",className:"rounded-[18px] border border-violet-100 bg-violet-50/50 p-4",children:[e.jsxs("div",{className:"mb-3 flex items-center justify-between gap-3",children:[e.jsx("p",{className:"text-xs font-black uppercase tracking-[0.18em] text-violet-500",children:"Passo 2 ⢠Destinos por canal"}),e.jsxs("span",{className:"text-xs font-semibold text-slate-500",children:[gt.length," selecionado(s)"]})]}),Te.isLoading?e.jsx("div",{className:"space-y-3",children:Array.from({length:3}).map((t,a)=>e.jsx("div",{className:"skeleton h-16 rounded-[16px]"},a))}):(Te.data||[]).length>0?e.jsx("div",{className:"max-h-[220px] space-y-3 overflow-y-auto pr-1",children:(Te.data||[]).map(t=>{const a=A.includes(t.chatId),i=t.provider==="whatsapp"?io(t.chatId,ti.data,t.chatName):t.chatName||t.chatId;return e.jsxs("button",{type:"button",onClick:()=>Ho(t.chatId),className:N("flex w-full items-center justify-between rounded-[16px] border p-3 text-left transition-all",a?"border-violet-300 bg-vi
50olet-50":"border-slate-200 bg-white hover:bg-slate-50"),children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate text-sm font-bold text-slate-800",children:i}),e.jsx("p",{className:"truncate text-[11px] text-slate-400",children:t.provider==="whatsapp"?"whatsapp ⢠grupo conectado":`${t.provider} ⢠${t.chatId}`})]}),e.jsx("div",{className:N("flex h-5 w-5 items-center justify-center rounded-full border",a?"border-violet-600 bg-violet-600 text-white":"border-slate-300 bg-white"),children:a?e.jsx(Ne,{size:12}):null})]},t.id)})}):e.jsx("div",{className:"rounded-[16px] border border-amber-100 bg-amber-50 p-4 text-sm font-semibold text-amber-700",children:"Nenhum destino disponÃvel para os canais selecionados."}),$.includes("whatsapp")&>.some(t=>t.provider==="whatsapp")?e.jsx(pl,{channel:"whatsapp",destinations:(Te.data||[]).filter(t=>t.provider==="whatsapp").map(t=>({chatId:t.chatId,chatName:io(t.chatId,ti.data,t.chatName)})),selectedChatIds:A.filter(t=>gt.some(a=>a.chatId===t&&a.provider==="whatsapp")),categoriesByChatId:he,onCategoriesChange:(t,a)=>J(i=>({...i,[t]:a})),className:"mt-3"}):null,e.jsx(zi,{visible:$.length>0&&A.length===0,className:"mt-3"})]}),e.jsxs("div",{className:"grid gap-4 xl:grid-cols-[1fr_1fr]",children:[e.jsxs("div",{className:"rounded-[18px] border border-violet-100 bg-violet-50/50 p-4",children:[e.jsxs("div",{className:"mb-3 flex items-center justify-between gap-3",children:[e.jsx("p",{className:"text-xs font-black uppercase tracking-[0.18em] text-violet-500",children:"Passo 3 ⢠Copy e imagem"}),e.jsx("button",{type:"button",onClick:()=>Vt(t=>!t),className:"text-xs font-semibold text-violet-700 underline-offset-4 hover:underline",children:fa?"Recolher":"Expandir"})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("select",{value:w,onChange:t=>le(t.target.value?Number(t.target.value):""),className:"h-11 w-full rounded-xl border border-violet-100 bg-white px-3 text-sm font-semibold text-slate-700 outline-none",children:[e.jsx("option",{value:"",children:"Selecionar template de copy"}),(Qs.data||[]).map(t=>e.jsx("option",{value:t.id,children:t.name},t.id))]}),e.jsxs("select",{value:T,onChange:t=>ce(t.target.value),className:"h-11 w-full rounded-xl border border-violet-100 bg-white px-3 text-sm font-semibold text-slate-700 outline-none",children:[e.jsx("option",{value:"",children:"Selecionar layout visual (imagem do post)"}),fc.map(t=>e.jsx("option",{value:t,children:t},t))]}),fa?e.jsxs("div",{className:"rounded-[16px] border border-violet-100 bg-white p-3 text-xs leading-6 text-slate-500",children:[e.jsx("p",{className:"font-bold text-slate-700",children:"Template atual"}),e.jsx("p",{className:"mt-1",children:us?.name||"Nenhuma copy selecionada."}),e.jsx("p",{className:"mt-2 text-[11px] text-slate-400",children:us?.content||"Selecione uma copy para ver a base de comunicação que será usada no preview."})]}):null]})]}),e.jsxs("div",{className:"rounded-[18px] border border-violet-100 bg-violet-50/50 p-4",children:[e.jsx("p",{className:"text-xs font-black uppercase tracking-[0.18em] text-violet-500",children:"Passo 4 ⢠Gancho IA/manual"}),e.jsxs("div",{className:"mt-3 space-y-3",children:[e.jsx("textarea",{value:k,onChange:t=>ee(t.target.value),placeholder:"Cole aqui o gancho gerado por IA ou escreva a linha de abertura que quer usar no post...",className:"min-h-[110px] w-full rounded-xl border border-violet-100 bg-white p-3 text-sm leading-6 text-slate-700 outline-none focus:ring-2 focus:ring-violet-500"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:mn.map(t=>e.jsx("button",{type:"button",onClick:()=>ee(t),className:"min-h-[44px] touch-manipulation rounded-full border border-violet-200 bg-white px-3 py-2 text-left text-[11px] font-semibold leading-snug text-violet-700 transition hover:bg-violet-50 max-sm:w-full sm:py-1.5 sm:text-center",children:t},t))}),e.jsx("textarea",{value:$e,onChange:t=>xe(t.target.value),placeholder:"Observações internas da operação: prioridade, ângulo da campanha, CTA desejado...",className:"min-h-[90px] w-full rounded-xl border border-violet-100 bg-white p-3 text-sm leading-6 text-slate-700 outline-none focus:ring-2 focus:ring-violet-500"})]})]})]}),e.jsxs("div",{className:"grid gap-3 md:grid-cols-2 xl:grid-cols-4",children:[e.jsx(ys,{label:"Canal",ready:ft.channelsReady,helper:ft.channelsReady?`${$.length} canal(is)`:"Escolha os canais"}),e.jsx(ys,{label:"Destino",ready:ft.destinationsReady,helper:ft.destinationsReady?`${A.length} destino(s)`:"Selecione os grupos/canais"}
50),e.jsx(ys,{label:"Ativos",ready:ft.assetsReady,helper:ft.assetsReady?"Copy e imagem definidos":"Escolha copy e layout"}),e.jsx(ys,{label:"Texto",ready:ft.copyReady,helper:ft.copyReady?"Prévia pronta":"Ajuste o texto"})]}),e.jsxs("div",{className:"rounded-[18px] border border-violet-100 bg-violet-50/50 p-4",children:[e.jsx("p",{className:"text-xs font-black uppercase tracking-[0.18em] text-violet-500",children:"Passo 5 ⢠Janela e ação final"}),e.jsxs("div",{className:"mt-3 grid gap-3 sm:grid-cols-2 xl:grid-cols-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-[10px] font-black uppercase tracking-[0.18em] text-violet-500",children:"Data inicial"}),e.jsx(oe,{type:"date",value:qe,onChange:t=>Ye(t.target.value),className:"h-11 rounded-xl border-violet-100 bg-white"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-[10px] font-black uppercase tracking-[0.18em] text-violet-500",children:"Primeiro post"}),e.jsx(oe,{type:"time",value:pe,onChange:t=>dt(t.target.value),className:"h-11 rounded-xl border-violet-100 bg-white"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-[10px] font-black uppercase tracking-[0.18em] text-violet-500",children:"Ãltimo post até"}),e.jsx(oe,{type:"time",value:Be,onChange:t=>Pt(t.target.value),className:"h-11 rounded-xl border-violet-100 bg-white"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-[10px] font-black uppercase tracking-[0.18em] text-violet-500",children:"Intervalo (min)"}),e.jsx(oe,{type:"number",min:1,value:we,onChange:t=>ga(Number(t.target.value||30)),className:"h-11 rounded-xl border-violet-100 bg-white"})]})]}),e.jsxs("div",{className:"mt-3 rounded-[16px] border border-violet-100 bg-white/70 px-4 py-3 text-xs leading-6 text-slate-600",children:["O scheduler vai iniciar em ",e.jsx("span",{className:"font-black text-slate-900",children:qe||"â"}),", publicar a partir de ",e.jsxs("span",{className:"font-black text-slate-900",children:[" ",pe||"â"]}),", respeitar a janela até ",e.jsxs("span",{className:"font-black text-slate-900",children:[" ",Be||"â"]})," ","e distribuir os posts de"," ",e.jsxs("span",{className:"font-black text-slate-900",children:[we," em ",we," minuto(s)"]}),". Quando a janela terminar, o restante continua automaticamente no próximo dia."]}),e.jsxs("div",{className:"mt-4 grid gap-3 md:grid-cols-3",children:[e.jsx(br,{icon:e.jsx(lr,{className:"h-4 w-4"}),title:"Salvar setup",description:"Persistir copy, layout de imagem e gancho nas ofertas selecionadas.",onClick:_n}),e.jsx(br,{icon:e.jsx(al,{className:"h-4 w-4"}),title:"Priorizar",description:"Marcar as selecionadas como favoritas para uso recorrente.",onClick:ir}),e.jsx(br,{icon:e.jsx(Fe,{className:"h-4 w-4"}),title:"Agendar seleção",description:"Prévia, horários e confirmação na página Agendamento.",onClick:()=>et()})]}),e.jsxs("div",{id:"operation-schedule-submit",className:"mt-4 space-y-3",children:[e.jsx(zi,{visible:$.length>0&&A.length===0}),e.jsxs("div",{className:"flex touch-manipulation flex-wrap gap-2",children:[e.jsxs(m,{type:"button",variant:"outline",size:"sm",className:"h-10 min-h-10 rounded-lg px-2.5 text-[11px]",onClick:()=>void wi(),children:[e.jsx(xr,{className:"mr-1 h-3.5 w-3.5"}),"Copiar texto do post"]}),e.jsxs(m,{type:"button",variant:"outline",size:"sm",className:"h-10 min-h-10 rounded-lg px-2.5 text-[11px]",onClick:()=>void yi(),children:[e.jsx(Ps,{className:"mr-1 h-3.5 w-3.5"}),"Copiar link"]}),e.jsxs(m,{type:"button",variant:"outline",size:"sm",className:"h-10 min-h-10 rounded-lg px-2.5 text-[11px]",onClick:()=>void ki(),children:[e.jsx(Pi,{className:"mr-1 h-3.5 w-3.5"}),"Compartilhar"]}),e.jsxs(m,{type:"button",variant:"outline",size:"sm",className:"h-10 min-h-10 rounded-lg px-2.5 text-[11px]",onClick:()=>void or(),children:[e.jsx(Mi,{className:"mr-1 h-3.5 w-3.5"}),"Baixar banner"]})]}),e.jsxs(m,{onClick:()=>et(),disabled:!f.length,className:"h-12 w-full rounded-xl bg-gradient-to-r from-violet-500 via-fuchsia-500 to-purple-700 text-white hover:opacity-95",children:[e.jsx(Fe,{className:"mr-2 h-4 w-4"}),"Agendar na página Agendamento"]})]})]})]})]}):e.jsx("div",{className:"mt-4 rounded-[18px] border border-dashed border-violet-200 bg-vi
50olet-50/30 p-4 text-sm text-slate-500",children:"Selecione ofertas na biblioteca e clique em levar para operação para abrir esta área completa."}),e.jsxs("div",{className:"mt-5 grid gap-3 md:grid-cols-4",children:[e.jsx(ws,{icon:e.jsx(lr,{className:"h-4 w-4"}),title:"Copy",description:"Escolha template e gere um texto final consistente para a campanha."}),e.jsx(ws,{icon:e.jsx(Ml,{className:"h-4 w-4"}),title:"Imagem do post",description:"Defina o layout visual que acompanha a copy na operação."}),e.jsx(ws,{icon:e.jsx(vr,{className:"h-4 w-4"}),title:"IA/manual",description:"Cole ou ajuste o gancho que vai abrir a copy antes do agendamento."}),e.jsx(ws,{icon:e.jsx(jt,{className:"h-4 w-4"}),title:"Prévia",description:"Valide imagem, texto e destinos antes de mandar para a fila."})]})]})]}),B.length>0&&(me==="pesquisar"||me==="biblioteca")&&Y.length===0&&ne.length===0?e.jsxs(e.Fragment,{children:[e.jsx(cc,{count:B.length,busy:So||Xt.isPending,canUsePoolActions:Ae,onAgenda:()=>void Ni(),onContacts:()=>void qn(),onOperation:()=>void Bn(),onAddToCart:()=>$a(B,{openCart:!1}),onImportLibrary:()=>void Fn(),onClearSelection:()=>Gt([]),onGoToShopeeCaptura:en}),e.jsx(dc,{open:ko,onOpenChange:$s,candidates:un,includedIds:Za,onToggle:$n,onConfirmSchedule:zn,busy:Xt.isPending})]}):null,e.jsx(na,{open:z,onOpenChange:se,children:e.jsxs(la,{side:"bottom",className:"max-h-[min(92vh,920px)] gap-0 overflow-y-auto rounded-t-2xl border-amber-200/80 p-0 pb-[max(1rem,env(safe-area-inset-bottom))] md:mx-auto md:max-w-3xl",children:[e.jsxs(ca,{className:"sticky top-0 z-10 shrink-0 border-b border-amber-100 bg-amber-50 px-4 py-3 pr-14 text-left",children:[e.jsx(da,{className:"text-base font-black text-slate-900",children:"Espelho WhatsApp · achadinhos"}),e.jsx(ma,{className:"text-xs text-slate-600",children:"Escolha grupos onde você já é membro, importe links na Galeria e revise antes de publicar."}),e.jsx(sl,{"aria-label":"Fechar espelho",className:"absolute right-2 top-2 inline-flex h-11 w-11 touch-manipulation items-center justify-center rounded-full text-slate-600 hover:bg-amber-100 hover:text-slate-900",children:e.jsx(Se,{className:"h-5 w-5"})})]}),e.jsx("div",{className:"shrink-0 px-3 py-3 sm:px-4",children:e.jsx(dl,{embedded:!0,connected:Yr,groups:Xr.data??[],loadingGroups:Xr.isLoading,canUse:Ao,onViewImports:si,whatsappProvider:Kr.data?.provider??null,selectedOfferIds:ne,onToggleOfferSelect:t=>y(a=>a.some(i=>Number(i)===t)?a.filter(i=>Number(i)!==t):[...a,t])})}),ne.length>0?e.jsx("div",{className:"sticky bottom-0 z-10 shrink-0 border-t border-violet-200 bg-white px-3 py-3 sm:px-4",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("p",{className:"min-w-0 flex-1 text-xs font-bold text-slate-800",children:[ne.length," selecionada(s)",e.jsx("span",{className:"block text-[11px] font-medium text-slate-500",children:"Agendar, Piloto, converter, banner ou vÃdeo"})]}),e.jsx(m,{type:"button",variant:"ghost",className:"min-h-11 shrink-0 text-xs",onClick:()=>y([]),children:"Limpar"}),e.jsxs(m,{type:"button",className:"min-h-11 shrink-0 bg-violet-600 text-xs font-bold text-white hover:bg-violet-700",onClick:()=>{si(),Ve(!0)},children:["Continuar",e.jsx(wt,{className:"ml-1 h-4 w-4"})]})]})}):null]})}),Y.length>0&&me==="selecionadas"?e.jsx("div",{className:"fixed inset-x-3 z-[52] rounded-[20px] border border-violet-300 bg-violet-950 p-3 pb-[max(0.75rem,env(safe-area-inset-bottom))] text-white shadow-2xl md:hidden bottom-[max(7rem,calc(5.5rem+env(safe-area-inset-bottom)))]",children:e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"text-[11px] font-black uppercase tracking-[0.22em] text-violet-300",children:"Carrinho"}),e.jsxs("p",{className:"text-sm font-semibold",children:[mt.length||Y.length," em ação"]}),e.jsx("p",{className:"mt-0.5 text-[11px] font-medium leading-snug text-violet-200/90 sm:hidden",children:"Salvar â biblioteca · Raio â operação com agenda."}),e.jsx("p",{className:"mt-0.5 hidden text-[11px] font-medium leading-snug text-violet-200/90 sm:block",children:"Salvar importa o lote marcado para a biblioteca;
50 raio importa e abre a operação."})]}),e.jsxs("div",{className:"flex shrink-0 justify-end gap-2",children:[e.jsx(m,{type:"button",variant:"ghost",onClick:()=>{Xe([]),ye([])},"aria-label":"Fechar barra do carrinho",title:"Fechar",className:"h-11 min-h-11 min-w-11 shrink-0 touch-manipulation rounded-xl text-violet-200 hover:bg-white/10 hover:text-white",children:e.jsx(Se,{className:"h-5 w-5 shrink-0","aria-hidden":!0})}),e.jsx(m,{onClick:()=>xs(!1),"aria-label":"Salvar no carrinho",title:"Salvar",className:"h-11 min-h-11 min-w-11 shrink-0 touch-manipulation rounded-xl bg-white px-3 text-violet-900 hover:bg-violet-50",children:e.jsx(Al,{className:"h-5 w-5 shrink-0","aria-hidden":!0})}),e.jsx(m,{variant:"outline",onClick:()=>xs(!0),"aria-label":"Enviar para operação",title:"Operação",className:"h-11 min-h-11 min-w-11 shrink-0 touch-manipulation rounded-xl border-white/20 bg-white/10 px-3 text-white hover:bg-white/15",children:e.jsx(ot,{className:"h-5 w-5 shrink-0","aria-hidden":!0})})]})]})}):null,B.length>0||Y.length>0||f.length>0?e.jsx(nc,{expanded:Es,onToggle:()=>Ve(t=>!t),selectedResultsCount:B.length,markedCount:mt.length,cartCount:Y.length,readyCount:Lt.length,blockedCount:xi.length,libraryCount:ne.length,commissionPotential:rn,bestCommissionPercent:on,onContinue:To,onOpenCart:ii,onSchedule:Fo,onGoToOperation:Ro,onShowSearchSelection:zo,onShowCartWorkspace:ii,onShowLibrarySelection:$o,activeAction:Mr,libraryMode:ne.length>0&&(Mr==="library"||Y.length===0&&B.length===0),onConvertLibrary:Bo,onGenerateBannerLibrary:Vo,onGoToVideoPromptsLibrary:_o,onAutopilotLibrary:Uo,canAutopilotLibrary:Hs||Fa?.role==="admin",onFavoriteLibrary:ir,onDeleteSelectedLibrary:()=>ya(!0)}):null,xa?e.jsx("div",{className:"fixed left-1/2 z-[54] w-[calc(100%-2rem)] max-w-xl -translate-x-1/2 rounded-[20px] border border-violet-400/20 bg-violet-950 px-5 py-4 text-sm font-bold text-white shadow-2xl bottom-[max(13.5rem,calc(12rem+env(safe-area-inset-bottom)))] md:bottom-[7.5rem]",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(vr,{className:"h-4 w-4 text-violet-300"}),e.jsx("span",{children:xa})]})}):null]})}function Nc({hook:s,bodyText:r,className:n}){return e.jsxs("div",{className:N("text-xs leading-5 text-slate-700",n),children:[s?e.jsx("p",{className:"whitespace-pre-wrap break-words px-0.5 text-center font-semibold text-slate-800 [overflow-wrap:anywhere]",children:s}):null,s&&r?e.jsx("div",{className:"h-3 shrink-0","aria-hidden":!0}):null,r?e.jsx("pre",{className:"whitespace-pre-wrap break-words text-left [overflow-wrap:anywhere]",children:r}):s?null:e.jsx("p",{className:"text-slate-500",children:"Configure copy, IA e destinos para ver a prévia da campanha."})]})}function wc({channel:s,title:r,content:n,highlightLine:u,previewImageUrl:d,priceLabel:h,oldPriceLabel:x,destinations:g}){const M=kc(s);return e.jsxs("div",{className:N("overflow-hidden rounded-[22px] border",M.shellClassName),children:[e.jsx("div",{className:N("px-4 py-3",M.headerClassName),children:e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsxs("p",{className:"text-[10px] font-black uppercase tracking-[0.18em] opacity-80",children:["Prévia ",M.label]}),e.jsx("p",{className:"mt-1 text-sm font-semibold",children:r})]}),e.jsx("div",{className:"rounded-full border border-current/15 bg-white/10 px-3 py-1 text-[10px] font-bold uppercase tracking-[0.18em]",children:M.badge})]})}),e.jsxs("div",{className:"space-y-3 bg-white p-4 text-slate-800",children:[e.jsx("div",{className:"overflow-hidden rounded-[14px] border border-violet-100 bg-violet-50",children:d?e.jsx("img",{src:d,alt:r,className:"h-28 w-full object-cover",loading:"lazy",decoding:"async",referrerPolicy:"no-referrer"}):e.jsx("div",{className:"flex h-28 w-full items-center justify-center text-xs text-slate-400",children:"Sem imagem"})}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[h?e.jsx(je,{children:h}):null,x?e.jsxs(je,{children:["Antes ",x]}):null,g.length?e.jsx(je,{children:g.join(" ⢠")}):e.jsx(je,{children:"Sem destino selecionado"})]}
50),e.jsxs("div",{className:N("rounded-[18px] border p-4",M.bodyClassName),children:[u?e.jsx("p",{className:"mb-2 line-clamp-2 whitespace-pre-wrap break-words text-center text-xs font-semibold leading-5 text-slate-800 [overflow-wrap:anywhere]",children:u}):null,e.jsx("pre",{className:N("line-clamp-6 whitespace-pre-wrap break-words text-xs leading-5 text-slate-700 [overflow-wrap:anywhere]",u?"text-left":""),children:n||"Configure copy, IA e destinos para ver a prévia da campanha."})]})]})]})}function yc({className:s}){return e.jsx("svg",{viewBox:"0 0 24 24",className:s,"aria-hidden":!0,fill:"currentColor",children:e.jsx("path",{d:"M17.472 14.382c-.297-.149-1.758-.867-2.03-.967-.273-.099-.471-.148-.67.15-.197.297-.767.966-.94 1.164-.173.199-.347.223-.644.075-.297-.15-1.255-.463-2.39-1.475-.883-.788-1.48-1.761-1.653-2.059-.173-.297-.018-.458.13-.606.134-.133.298-.347.446-.52.149-.174.198-.298.298-.497.099-.198.05-.371-.025-.52-.075-.149-.669-1.612-.916-2.207-.242-.579-.487-.5-.669-.51-.173-.008-.371-.01-.57-.01-.198 0-.52.074-.792.372-.272.297-1.04 1.016-1.04 2.479 0 1.462 1.065 2.875 1.213 3.074.149.198 2.096 3.2 5.077 4.487.709.306 1.262.489 1.694.625.712.227 1.36.195 1.871.118.571-.085 1.758-.719 2.006-1.413.248-.694.248-1.289.173-1.413-.074-.124-.272-.198-.57-.347m-5.421 7.403h-.004a9.87 9.87 0 01-5.031-1.378l-.361-.214-3.741.982.998-3.648-.235-.374a9.86 9.86 0 01-1.51-5.26c.001-5.45 4.436-9.884 9.888-9.884 2.64 0 5.122 1.03 6.988 2.898a9.825 9.825 0 012.893 6.994c-.003 5.45-4.435 9.884-9.885 9.884m8.413-18.297A11.815 11.815 0 0012.05 0C5.495 0 .16 5.335.157 11.892c0 2.096.547 4.142 1.588 5.945L.057 24l6.305-1.654a11.882 11.882 0 005.683 1.448h.005c6.554 0 11.89-5.335 11.893-11.893a11.821 11.821 0 00-3.48-8.413z"})})}function kc(s){return s==="whatsapp"?{label:"WhatsApp",badge:"Conversa",shellClassName:"border-emerald-100 bg-emerald-50/40",headerClassName:"bg-gradient-to-r from-emerald-500 to-emerald-600 text-white",bodyClassName:"border-emerald-100 bg-emerald-50/40"}:s==="instagram"?{label:"Instagram",badge:"Story/Post",shellClassName:"border-fuchsia-100 bg-fuchsia-50/40",headerClassName:"bg-gradient-to-r from-fuchsia-500 via-pink-500 to-orange-400 text-white",bodyClassName:"border-fuchsia-100 bg-fuchsia-50/40"}:{label:"Telegram",badge:"Canal",shellClassName:"border-sky-100 bg-sky-50/40",headerClassName:"bg-gradient-to-r from-sky-500 to-cyan-500 text-white",bodyClassName:"border-sky-100 bg-sky-50/40"}}function Cc(s){return s==="whatsapp"?"WhatsApp":s==="instagram"?"Instagram":"Telegram"}function Ns({label:s,value:r}){return e.jsxs("div",{className:"rounded-[16px] border border-violet-200 bg-violet-50 px-4 py-3",children:[e.jsx("p",{className:"text-[10px] font-black uppercase tracking-[0.18em] text-violet-500",children:s}),e.jsx("p",{className:"mt-1 text-lg font-black text-slate-900",children:r})]})}function je({children:s}){return e.jsx("span",{className:"inline-flex items-center rounded-full border border-violet-200 bg-white px-3 py-1 text-xs font-semibold text-violet-700",children:s})}function ws({icon:s,title:r,description:n}){return e.jsxs("div",{className:"rounded-2xl border border-violet-100 bg-violet-50/40 p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-violet-700",children:[s,e.jsx("span",{className:"font-semibold",children:r})]}),e.jsx("p",{className:"mt-2 text-sm text-slate-500",children:n})]})}function br({icon:s,title:r,description:n,onClick:u}){return e.jsxs("button",{type:"button",onClick:u,className:"rounded-2xl border border-violet-100 bg-white p-4 text-left transition hover:border-violet-200 hover:bg-violet-50",children:[e.jsxs("div",{className:"flex items-center gap-2 text-violet-700",children:[s,e.jsx("span",{className:"font-semibold",children:r})]}),e.jsx("p",{className:"mt-2 text-sm text-slate-500",children:n})]})}function gr({label:s,value:r,helper:n}){return e.jsxs("div",{className:"rounded-[18px] border border-violet-100 bg-violet-50/55 px-4 py-4",children:[e.jsx("p",{className:"text-[10px] font-black uppercase tracking-[0.18em] text-violet-500",children:s}),e.jsx("p",{className:"mt-1 text-lg font-black text-slate-900",children:r}),e.jsx("p",{className:"mt-1 text-xs text-slate-500",children:n})]})}function ys({label:s,ready:r,helper:n}
50){return e.jsxs("div",{className:N("rounded-[18px] border px-4 py-4",r?"border-emerald-200 bg-emerald-50/70":"border-violet-100 bg-white"),children:[e.jsx("p",{className:"text-[10px] font-black uppercase tracking-[0.18em] text-violet-500",children:s}),e.jsx("p",{className:N("mt-2 text-sm font-bold",r?"text-emerald-700":"text-slate-800"),children:r?"Pronto":"Pendente"}),e.jsx("p",{className:"mt-1 text-xs text-slate-500",children:n})]})}function ve(s){return s.normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase().trim()}function Ee(s){return ve(s).replace(/[^a-z0-9]/g,"")}function Sc(s){return ve(`${s.productTitle||""} ${s.title||""} ${s.productName||""} ${s.category||""} ${s.platform||""} ${s.productDescription||""} ${s.description||""} ${s.commissionPercent??""} ${s.commissionAmount??""} ${s.commissionSourceLabel||""} ${s.unitsSoldLabel||""}`)}function ao(s){const r=s?.lastSeenAt??s?.updatedAt??s?.createdAt;if(r==null)return 0;const n=new Date(r).getTime();return Number.isFinite(n)?n:0}function so(s){const r=s.updatedAt??s.createdAt;if(r==null)return 0;const n=new Date(r).getTime();return Number.isFinite(n)?n:0}function ro(s){return String(s||"").trim().replace(/\s+/g,"").toLowerCase()}function io(s,r,n){const u=ro(s),d=(r||[]).find(h=>[h?.id,h?._serialized,h?.wid?._serialized,h?.wid?.user,h?.jid].filter(Boolean).map(g=>ro(String(g))).includes(u));return d?d?.name||d?.subject||d?.formattedTitle||d?.pushname||n||s:n||s}function Z(s){if(s==null||s==="")return null;if(typeof s=="number")return Number.isFinite(s)?s:null;const r=String(s).trim();if(!r)return null;const u=r.replace(/\u00A0/g," ").replace(/R\$/gi,"").trim().replace(/[^\d.,-]/g,"");if(!u)return null;const d=u.lastIndexOf(","),h=u.lastIndexOf(".");let x=u;if(d>-1&&h>-1)d>h?x=u.replace(/\./g,"").replace(",","."):x=u.replace(/,/g,"");else if(d>-1)u.length-d-1===2?x=u.replace(/\./g,"").replace(",","."):x=u.replace(/,/g,"");else if(h>-1){const M=u.length-h-1;M===2?x=u:M===3&&(x=u.replace(/\./g,""))}const g=Number(x);return Number.isFinite(g)?g:null}function We(s){const r=Z(s);return r==null?"â":r.toLocaleString("pt-BR",{style:"currency",currency:"BRL"})}function Ie(s){if(s==null||s==="")return 0;if(typeof s=="string"&&s.includes("%"))return Z(s)??0;const r=Number(s);return!Number.isFinite(r)||r<=0?0:r>=1?r:r*100}function _a(s){const r=Number(s||0);return`${Math.round(r)}%`}function vt(s){return s==="mercadolivre"?"Mercado Livre":s==="magalu"?"Magalu":s==="amazon"?"Amazon":s==="shopee"?"Shopee":s==="tiktokshop"||s==="tiktok"?"TikTok Shop":s==="shein"||s==="sheen"?"Shein":s}function fr(s){return Nl(s)?`Hoje ⢠${cr(s,"HH:mm",{locale:dr})}`:wl(s)?`Amanhã ⢠${cr(s,"HH:mm",{locale:dr})}`:cr(s,"dd/MM ⢠HH:mm",{locale:dr})}function jo(s){const r=String(s?.convertedUrl||s?.originalUrl||s?.productUrl||"").trim();if(!r)return"";try{return Pl(r,s?.platform)}catch{return r}}function oo(s,r){const n=r.trim();return n?`${s} 51 52ð Observação interna: ${n}`:s}function Pc({offer:s,aiText:r,notes:n}){const u=r.trim(),d=n.trim(),h=String(s?.productTitle||"").trim(),x=jo(s),g=s?.currentPrice!=null&&String(s.currentPrice).trim()!==""?String(s.currentPrice).trim():null,M=s?.originalPrice!=null&&String(s.originalPrice).trim()!==""?String(s.originalPrice).trim():null,f=s?.discountPercent!=null&&String(s.discountPercent).trim()!==""?String(s.discountPercent).trim():null,y=Gi({productTitle:h,currentPrice:g,originalPrice:M,discountPercent:f,convertedUrl:x,linkMode:"placeholder"}),D=oo(y,d),E=oo(u?Gi({aiHook:u,productTitle:h,currentPrice:g,originalPrice:M,discountPercent:f,convertedUrl:x,linkMode:"placeholder"}):y,d);return{hook:u||null,body:D,publicText:E}}function Oe(s){if(!s)return"";if(Array.isArray(s)){for(const r of s){const n=Oe(r);if(n)return n}return""}if(typeof s=="object"){const r=s;return Oe(r.url)||Oe(r.src)||Oe(r.image)||Oe(r.thumbnail)}if(typeof s=="string"){const r=s.trim();if(!r||r==="null"||r==="undefined")return"";if(r.startsWith("//"))return`https:${r}`;if(r.startsWith("http://")||r.startsWith("https://"))return r;if(r.startsWith("[")&&r.endsWith("]")||r.startsWith("{")&&r.endsWith("}"))try{return Oe(JSON.parse(r))}catch{return""}}return""}export{Sd as default};
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.