import{c as x,_ as b,p as C,y as f,h as l,a as d,b as s,l as c,u as t,m,t as o,i as n,q as _,f as A,g as h,F as z,x as M,r as v,z as T,o as r,C as B,D as N}from"./index-yErsUbD6.js";import{T as P}from"./target-DmESUw9c.js";import{B as V}from"./book-open-Cmnj20ue.js";import{P as $}from"./plus-Y1qXSgej.js";/** * @license lucide-vue-next v1.0.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const j=x("trash-2",[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]]),G={class:"row",style:{"align-items":"center","margin-bottom":"16px"}},L={style:{margin:"0"}},D={class:"row",style:{"margin-left":"auto",gap:"10px"}},F={class:"soft"},I={class:"primary"},S={class:"muted"},q={key:0,class:"card",style:{"min-height":"80px"}},E={key:1,class:"card empty-state"},H={key:0},O={key:1},J={class:"grid"},K={class:"row",style:{"justify-content":"space-between"}},Q={class:"row",style:{gap:"6px","align-items":"center"}},R=["onClick"],U={class:"muted",style:{margin:"6px 0 12px"}},W={class:"row",style:{gap:"8px"}},X={class:"muted"},Y={class:"primary",style:{width:"100%","margin-top":"12px"}},Z={__name:"Training",setup(tt){const u=v([]),y=v(!0);function k(e){return e.sales_kit&&e.sales_kit.productName||e.input&&e.input.product||""}function g(e){return e.personas||e.persona_count||0}async function w(e){if(confirm(`ลบกลุ่ม "${e.title}" และบุคคลต้นแบบทั้งหมด? (ติดลบถาวร)`))try{await f.deleteGroup(e.id),u.value=u.value.filter(i=>i.id!==e.id)}catch(i){alert(i.message)}}return C(async()=>{try{const e=(await f.listGroups()).groups||[];u.value=l.isAdmin?e:e.filter(i=>i.status==="ready")}finally{y.value=!1}}),(e,i)=>{const p=T("router-link");return r(),d("div",null,[s("div",G,[s("h2",L,[c(t(P),{size:22,"stroke-width":1.8,style:{"vertical-align":"-4px"}}),m(" "+o(t(n).t("training")),1)]),s("div",D,[c(p,{to:"/guide"},{default:_(()=>[s("button",F,[c(t(V),{size:18,"stroke-width":1.8}),i[0]||(i[0]=m(" คู่มือ",-1))])]),_:1}),t(l).isAdmin?(r(),A(p,{key:0,to:"/admin/new-group"},{default:_(()=>[s("button",I,[c(t($),{size:18,"stroke-width":2}),m(" "+o(t(n).t("addProduct")),1)])]),_:1})):h("",!0)])]),s("p",S,o(t(n).t("trainingSubtitle")),1),y.value?(r(),d("div",q,[...i[1]||(i[1]=[s("div",{class:"skeleton",style:{height:"50px"}},null,-1)])])):u.value.length===0?(r(),d("div",E,[s("strong",null,o(t(n).t("noTraining")),1),t(l).isAdmin?(r(),d("span",H,'Click "'+o(t(n).t("addProduct"))+'" to create a persona group.',1)):(r(),d("span",O,"Ask an admin to create a persona group first."))])):h("",!0),s("div",J,[(r(!0),d(z,null,M(u.value,a=>(r(),d("div",{key:a.id,class:"card lift train-card"},[s("div",K,[c(p,{to:t(l).isAdmin?`/admin/groups/${a.id}/edit`:`/groups/${a.id}/personas`,style:{"text-decoration":"none",color:"inherit","min-width":"0"}},{default:_(()=>[s("strong",null,o(a.title),1)]),_:2},1032,["to"]),s("div",Q,[s("span",{class:B(["badge",a.status==="ready"?"ready":"draft"])},o(a.status),3),t(l).isAdmin?(r(),d("button",{key:0,class:"del-btn",title:"ลบกลุ่มนี้ (ติดลบถาวร)",onClick:N(st=>w(a),["prevent","stop"])},[c(t(j),{size:16,"stroke-width":1.8})],8,R)):h("",!0)])]),c(p,{to:t(l).isAdmin?`/admin/groups/${a.id}/edit`:`/groups/${a.id}/personas`,style:{"text-decoration":"none",color:"inherit"}},{default:_(()=>[s("div",U,o(k(a)),1),s("div",W,[s("span",X,o(g(a))+" "+o(t(n).t("personas").toLowerCase()),1)]),s("button",Y,o(t(l).isAdmin?a.status==="ready"?t(n).t("managePersonas"):t(n).t("analyze"):t(n).t("selectPersona")),1)]),_:2},1032,["to"])]))),128))])])}}},nt=b(Z,[["__scopeId","data-v-10820ca0"]]);export{nt as default};