1import{aK as P,aT as K}from"./CqJabS_z.js";import{y as q,X as a,F as o,ag as Q,a3 as n,A as t,a8 as d,a5 as f,a7 as T,Q as E,Y as G,f as k,c as R,a2 as N,_ as F,$ as j,D as U,w as Y,R as D}from"./Bk15PzoC.js";import{u as O}from"./CmQ9415S.js";import{u as X,R as H}from"./CdscPQ8e.js";try{let u=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},x=new u.Error().stack;x&&(u._sentryDebugIds=u._sentryDebugIds||{},u._sentryDebugIds[x]="597338c5-b183-4535-9a5d-90b01e939ab2",u._sentryDebugIdIdentifier="sentry-dbid-597338c5-b183-4535-9a5d-90b01e939ab2")}catch{}const J=(u,x)=>u.flatMap(($,_)=>x.map(A=>({ideaIndex:_,topic:$.topic,market:A,state:"pending"}))),W=async(u,x,$,_={})=>{const A=Math.max(1,_.concurrency??3),S=J(u,x),i=()=>_.onChange?.(S),v=(r,c)=>S.find(l=>l.ideaIndex===r&&l.market===c),B=async(r,c,l,C)=>{const g=v(r,l);g&&(g.state="running",i());try{const w=await $({topic:c.topic,keywords:c.keywords,market:l,articleGroupId:C});return g&&(g.state="done",g.articleId=w.id),i(),w}catch{return g&&(g.state="error"),i(),null}};for(const[r,c]of u.entries()){const[l,...C]=x;if(!l)continue;const g=await B(r,c,l);if(!g){for(const I of C){const m=v(r,I);m&&(m.state="error")}i();continue}const w=[...C],L=Array.from({length:Math.min(A,w.length)},async()=>{for(;;){const I=w.shift();if(!I)return;await B(r,c,I,g.articleGroupId)}});await Promise.all(L)}return S},Z={class:"h-full w-full max-w-md overflow-y-auto bg-white p-6 shadow-xl"},ee={class:"mb-4 flex items-center justify-between"},te=["disabled"],se=["disabled"],ne={key:0,class:"mb-3 text-sm text-red-600"},ae={key:1,class:"sticky top-0 z-10 mb-3 rounded-lg border bg-gray-50 p-3"},oe={class:"flex items-center justify-between"},re={class:"flex items-center gap-2 text-sm text-gray-700"},le=["checked","disabled"],ie={class:"text-xs text-gray-500"},ce=["disabled"],de={key:0,class:"mt-2 text-xs text-gray-500"},ue={key:2,class:"mb-4 space-y-2"},be={class:"mb-2 truncate text-sm font-medium text-gray-900"},ge={class:"flex flex-wrap gap-1"},pe={key:0,class:"text-xs text-gray-500"},me={class:"space-y-3"},ye={class:"flex cursor-pointer items-start gap-2"},fe=["checked","disabled","onChange"],xe={class:"min-w-0"},he={class:"block font-medium text-gray-900"},ke={class:"mt-1 block text-sm text-gray-600"},_e={key:0,class:"mt-2 block text-xs text-gray-500"},ve={key:1,class:"mt-1 block text-xs italic text-gray-400"},we=["disabled","onClick"],Ie=q({__name:"ContentIdeasPanel",props:{open:{type:Boolean},markets:{}},emits:["close","use","done"],setup(u,{emit:x}){const $=u,_=x,{generateIdeas:A,generate:S}=O(),i=k([]),v=k(!1),B=k(!1),r=k(new Set),c=k([]),l=k(!1),C=R(()=>i.value.length>0&&r.value.size===i.value.length),g=R(()=>c.value.filter(s=>s.state==="done"||s.state==="error").length),w=R(()=>c.value.length>0&&!l.value),L=R(()=>Math.max(1,Math.round(c.value.length*35/60))),I=R(()=>{const s=new Map;for(const e of c.value){const h=s.get(e.ideaIndex)??{ideaIndex:e.ideaIndex,topic:e.topic,tasks:[]};h.tasks.push(e),!h.firstArticleId&&e.articleId&&(h.firstArticleId=e.articleId),s.set(e.ideaIndex,h)}return[...s.values()]}),m=s=>{const e=new Set(r.value);e.has(s)?e.delete(s):e.add(s),r.value=e},p=()=>{r.value=C.value?new Set:new Set(i.value.map((s,e)=>e))},M=async()=>{v.value=!0,B.value=!1;try{const s=await A();i.value=s.ideas,r.value=new Set,c.value=[]}catch{B.value=!0}finally{v.value=!1}},z=async()=>{const s=[...r.value].sort((e,h)=>e-h).map(e=>({topic:i.value[e].title,keywords:i.value[e].keywords}));if(s.length){l.value=!0;try{await W(s,$.markets,async e=>{const h=await S({...e,articleType:"blog",length:"long"});return{id:h.id,articleGroupId:h.articleGroupId}},{onChange:e=>{c.value=[...e]}}),_("done")}finally{l.value=!1}}};return(s,e)=>{const h=P;return u.open?(a(),o("div",{key:0,class:"fixed inset-0 z-50 flex justify-end bg-black/30",onClick:e[1]||(e[1]=Q(b=>t(l)?null:s.$emit("close"),["self"]))},[n("div",Z,[n("div",ee,[e[2]||(e[2]=n("h2",{class:"text-base font-semibold"},"Idées d'articles (IA)",-1)),n("button",{type:"button",class:"text-gray-400 hover:text-gray-600 disabled:opacity-30",disabled:t(l),onClick:e[0]||(e[0]=b=>s.$emit("close"))}," â ",8,te)]),n("button",{type:"button",class:"mb-4 rounded bg-bo-accent-600 px-3 py-1.5 text-sm font-medium text-white hover:bg-bo-accent-700 disabled:opacity-50",disabled:t(v)||t(l),onClick:M},d(t(v)?"Générationâ¦":t(i).length?"Regénérer":"Générer des idées"),9,se),t(B)?(a(),o("p",ne,"Ãchec de la génération. Réessayer.")):f("",!0),t(i).length?(a(),o("div",ae,[n("div",oe,[n("label",re,[n("input",{type:"checkbox",checked:t(C),disabled:t(l),onChange:p},null,40,le),T(" "+d(t(r).size)+" sélectionnée"+d(t(r).size>1?"s":""),1)]),n("span",ie,d(u.markets.length)+" langues",1)]),n("button",{type:"button",class:"mt-3 w-full rounded bg-bo-accent-600 px-3 py-2 text-sm font-medium text-white hover:bg-bo-accent-700 disabled:opacity-50",disabled:!t(r).size||t(l),onClick:z},d(t(l)?`Rédaction⦠${t(g)}/${t(c).length}`:`Rédiger ${t(r).size||""} article${t(r).size>1?"s":""} à ${u.markets.length} langues`),9,ce),t(l)?(a(),o("p",de," Environ "+d(t(L))+" min. Ne ferme pas cet onglet â la rédaction est pilotée depuis le navigateur. ",1)):f("",!0)])):f("",!0),t(c).length?(a(),o("div",ue,[(a(!0),o(E,null,G(t(I),b=>(a(),o("div",{key:b.ideaIndex,class:"rounded-lg border p-3"}
1,[n("p",be,d(b.topic),1),n("div",ge,[(a(!0),o(E,null,G(b.tasks,y=>(a(),o("span",{key:y.market,class:N(["rounded px-1.5 py-0.5 text-xs",{"bg-gray-100 text-gray-500":y.state==="pending","bg-bo-accent-100 text-bo-accent-700":y.state==="running","bg-green-100 text-green-700":y.state==="done","bg-red-100 text-red-700":y.state==="error"}])},[T(d(y.market),1),y.state==="done"?(a(),o(E,{key:0},[T(" â")],64)):f("",!0),y.state==="error"?(a(),o(E,{key:1},[T(" â")],64)):f("",!0)],2))),128))]),b.firstArticleId?(a(),F(h,{key:0,to:`/_bo/content/${b.firstArticleId}`,class:"mt-2 inline-block text-xs text-bo-accent-600 hover:underline"},{default:j(()=>[...e[3]||(e[3]=[T(" Ouvrir l'article â ",-1)])]),_:1},8,["to"])):f("",!0)]))),128)),t(w)?(a(),o("p",pe," Terminé. Ajoute l'image sur un article : elle se propage à toutes ses langues, puis publie-les en une fois. ")):f("",!0)])):f("",!0),n("div",me,[(a(!0),o(E,null,G(t(i),(b,y)=>(a(),o("div",{key:y,class:N(["rounded-lg border p-3",t(r).has(y)?"border-bo-accent-400 bg-bo-accent-50/40":""])},[n("label",ye,[n("input",{type:"checkbox",class:"mt-1",checked:t(r).has(y),disabled:t(l),onChange:V=>m(y)},null,40,fe),n("span",xe,[n("span",he,d(b.title),1),n("span",ke,d(b.angle),1),b.keywords.length?(a(),o("span",_e,d(b.keywords.join(", ")),1)):f("",!0),b.rationale?(a(),o("span",ve,d(b.rationale),1)):f("",!0)])]),n("button",{type:"button",class:"mt-3 rounded border border-bo-accent-300 px-2 py-1 text-xs font-medium text-bo-accent-700 hover:bg-bo-accent-50 disabled:opacity-50",disabled:t(l),onClick:V=>s.$emit("use",{topic:b.title,keywords:b.keywords})}," Rédiger seule (1 langue) ",8,we)],2))),128))])])])):f("",!0)}}}),$e={class:"mb-4 flex items-center justify-between"},Ae={class:"flex items-center"},Ce={key:1,class:"space-y-2"},Be={key:2,class:"space-y-2"},Ee={class:"min-w-0 flex-1"},Se={class:"truncate font-medium text-gray-900"},Te={class:"truncate text-xs text-gray-500"},Re={class:"flex shrink-0 flex-wrap items-center justify-end gap-1"},Ge=["title"],Le={class:"shrink-0 rounded bg-gray-100 px-2 py-0.5 text-xs font-medium text-gray-600"},Me={class:"hidden shrink-0 text-xs text-gray-400 sm:block"},Ne={key:3,class:"py-12 text-center text-sm text-gray-400"},qe=q({__name:"index",setup(u){const{listArticles:x}=O(),$=k([]),_=k(!0),A=k(!1),S=m=>{K({path:"/_bo/content/new",query:{topic:m.topic,keywords:m.keywords.join(",")}})},i=k(""),v=k(!1);function B(m,p=!1){i.value=m,v.value=p}const r={rg:"Roger&Gallet",ph:"Phyto",lc:"Lierac"},c={draft:"Brouillon",validated:"Validé",published:"Publié"},l={blog:"Conseil / Blog",guide:"Guide / Routine",category:"Intro catégorie",faq:"FAQ thématique"},C={fr:"Français",nl:"Néerlandais",de:"Allemand",it:"Italien",es:"Espagnol",pt:"Portugais",gr:"Grec",pl:"Polonais",en:"Anglais","ca-fr":"Canada (FR)","ca-en":"Canada (EN)"};function g(m){return m==="published"?"bg-green-100 text-green-700":m==="validated"?"bg-bo-accent-100 text-bo-accent-700":"bg-gray-100 text-gray-600"}const{ctx:w}=X(),L=R(()=>H[w.value.region]);async function I(){_.value=!0;try{$.value=await x()}catch{B("Impossible de charger les articles.",!0)}finally{_.value=!1}}return U(I),Y(()=>w.value,()=>I(),{deep:!0}),(m,p)=>{const M=P,z=Ie;return a(),o("div",null,[n("div",$e,[p[3]||(p[3]=n("div",null,[n("h1",{class:"text-lg font-semibold"},"Articles"),n("p",{class:"text-sm text-gray-500"},"Génération d'articles SEO/GEO par marque")],-1)),n("div",Ae,[n("button",{type:"button",class:"mr-2 rounded border border-bo-accent-300 px-3 py-1.5 text-sm font-medium text-bo-accent-700 hover:bg-bo-accent-50",onClick:p[0]||(p[0]=s=>A.value=!0)}," Idées d'articles (IA) "),D(M,{to:"/_bo/content/new",class:"rounded bg-bo-accent-600 px-3 py-1.5 text-sm font-medium text-white hover:bg-bo-accent-700"},{default:j(()=>[...p[2]||(p[2]=[T(" Nouvel article ",-1)])]),_:1})])]),t(i)?(a(),o("p",{key:0,class:N(["mb-3 text-sm",t(v)?"text-red-600":"text-gray-600"])},d(t(i)),3)):f("",!0),t(_)?(a(),o("div",Ce,[(a(),o(E,null,G(4,s=>n("div",{key:s,class:"h-14 animate-pulse rounded-lg border bg-white"})),64))])):t($).length?(a(),o("div",Be,[(a(!0),o(E,null,G(t($),s=>(a(),F(M,{key:s.articleGroupId,to:`/_bo/content/${s.versions[0].id}
1`,class:"flex items-center gap-4 rounded-lg border bg-white px-4 py-3 hover:border-bo-accent-300 hover:shadow-sm"},{default:j(()=>[n("div",Ee,[n("p",Se,d(s.title||s.topic),1),n("p",Te,d(s.topic),1)]),n("div",Re,[(a(!0),o(E,null,G(s.versions,e=>(a(),o("span",{key:e.market,class:N(["rounded px-1.5 py-0.5 text-[11px] font-medium uppercase",g(e.status)]),title:`${C[e.market]??e.market} â ${c[e.status]??e.status}`},d(e.market),11,Ge))),128))]),n("span",Le,d(r[s.brand]??s.brand),1),n("span",Me,d(l[s.articleType]??s.articleType),1),p[4]||(p[4]=n("span",{class:"shrink-0 text-gray-300"},"âº",-1))]),_:2},1032,["to"]))),128))])):(a(),o("p",Ne,"Aucun article généré pour le moment.")),D(z,{open:t(A),markets:t(L),onClose:p[1]||(p[1]=s=>A.value=!1),onUse:S,onDone:I},null,8,["open","markets"])])}}});export{qe 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.