import{d as _,k as f,m as x,r as u,o as l,a as i,f as o,t as s,j as d,i as p}from"./app-bWy6VYs1.js";import{g as y}from"./AppLayout.vue_vue_type_script_setup_true_lang-BwuDxc8O.js";const b={key:0,class:"rounded-md border border-violet-200 bg-violet-50/50 p-3"},k={class:"mb-2 flex items-center justify-between"},h=["disabled"],T={key:0,class:"text-xs text-violet-900"},C={key:1,class:"mt-1 text-xs text-violet-800"},S={class:"font-semibold"},w={key:2,class:"mt-1 text-xs text-violet-800"},j={class:"font-semibold"},P=_({__name:"AiDocumentSuggestionPanel",props:{documentType:{},title:{},description:{},notes:{}},setup(c){const a=c,m=f(),v=x(()=>!!m.props.ai?.allowed),n=u(!1),e=u(null),g=async()=>{n.value=!0;const r=await fetch("/ai/suggest-document",{method:"POST",credentials:"same-origin",headers:{"Content-Type":"application/json",Accept:"application/json","X-CSRF-TOKEN":y()},body:JSON.stringify({document_type:a.documentType,title:a.title||"",description:a.description||"",notes:a.notes||""})});if(n.value=!1,!r.ok)return;const t=await r.json();e.value=t.suggestion||null};return(r,t)=>v.value?(l(),i("div",b,[o("div",k,[t[0]||(t[0]=o("p",{class:"text-xs font-semibold text-violet-900"},"AI Template Suggestions",-1)),o("button",{type:"button",class:"rounded bg-violet-600 px-2 py-1 text-xs font-medium text-white hover:bg-violet-700 disabled:opacity-60",disabled:n.value,onClick:g},s(n.value?"Checking…":"Suggest"),9,h)]),e.value?.rationale?(l(),i("p",T,s(e.value.rationale),1)):d("",!0),e.value?.pdf_template?(l(),i("div",C,[t[1]||(t[1]=p(" PDF: ",-1)),o("span",S,s(e.value.pdf_template.name),1),p(" — "+s(e.value.pdf_template.reason),1)])):d("",!0),e.value?.email_template?(l(),i("div",w,[t[2]||(t[2]=p(" Email: ",-1)),o("span",j,s(e.value.email_template.name),1),p(" — "+s(e.value.email_template.reason),1)])):d("",!0)])):d("",!0)}});export{P as _};
