import{d as V,a3 as B,r as D,c as u,e as f,f as l,h as g,j as s,B as c,w as Q,s as b,g as p,t,n as v,p as $,V as E}from"./index-a0da86f0.js";import{i as x}from"./nodes-23b691ed.js";import{_ as K}from"./_plugin-vue_export-helper-c27b6911.js";const L={class:"toolbar"},j={class:"filters"},z={class:"view-toggle"},A=["title"],H=["title"],O=["disabled"],R=["disabled","title"],T=["disabled"],U=["disabled"],q=V({__name:"local_ai_node_list_toolbar",props:{entity:{},searchQuery:{},viewMode:{},selectedKeys:{},loading:{type:Boolean}},emits:["update:searchQuery","update:viewMode","reload","create","delete-selected"],setup(h,{emit:y}){const _=h,n=y,i=B(),d=D(!1),m=u({get:()=>_.searchQuery,set:e=>n("update:searchQuery",e)}),r=u({get:()=>_.viewMode,set:e=>n("update:viewMode",e)});function w(){n("reload")}function k(){n("create")}function C(){n("delete-selected")}const I=u(()=>[{label:t("Import local nodes"),key:"import-local-nodes"}]);function M(e){e==="import-local-nodes"&&N()}async function N(){if(!d.value){d.value=!0;try{const e=await x();if(n("reload"),!(e!=null&&e.success)){i.error({title:t("Error"),content:t("Import failed")});return}const o=e.matched||0,a=e.imported||0,S=e.skipped_existing||0;o===0?i.info({title:t("Info"),content:t("No local node definitions found")}):a===0&&S>0?i.info({title:t("Info"),content:t("All local nodes already exist")}):a>0?i.success({title:t("Success"),content:`${t("Imported")} ${a} ${t("nodes")}`}):i.info({title:t("Info"),content:t("No new local nodes found")})}catch(e){console.error("Import local nodes error:",e),i.error({title:t("Error"),content:t("Import failed")})}finally{d.value=!1}}}return(e,o)=>(v(),f("div",L,[l("div",j,[g(s($),{value:m.value,"onUpdate:value":o[0]||(o[0]=a=>m.value=a),placeholder:s(t)("Search"),clearable:"",style:{width:"200px"}},null,8,["value","placeholder"])]),l("div",z,[l("button",{class:c(["toggle-btn",{active:r.value==="list"}]),onClick:o[1]||(o[1]=a=>r.value="list"),title:s(t)("List View")},[...o[3]||(o[3]=[l("i",{class:"fa fa-list"},null,-1)])],10,A),l("button",{class:c(["toggle-btn",{active:r.value==="card"}]),onClick:o[2]||(o[2]=a=>r.value="card"),title:s(t)("Card View")},[...o[4]||(o[4]=[l("i",{class:"fa fa-th-large"},null,-1)])],10,H)]),l("button",{class:"refresh-btn",onClick:w,disabled:e.loading},[l("i",{class:c(e.loading?"fa fa-spinner fa-spin":"fa fa-refresh")},null,2)],8,O),g(s(E),{trigger:"click",options:I.value,onSelect:M},{default:Q(()=>[l("button",{class:"refresh-btn",disabled:e.loading||d.value,title:s(t)("More")},[l("i",{class:c(d.value?"fa fa-ellipsis-h fa-spin":"fa fa-ellipsis-h")},null,2)],8,R)]),_:1},8,["options"]),e.selectedKeys.length===0?(v(),f("button",{key:0,class:"create-btn",onClick:k,disabled:e.loading},[o[5]||(o[5]=l("i",{class:"fa fa-plus"},null,-1)),b(" "+p(s(t)("Create")),1)],8,T)):(v(),f("button",{key:1,class:"delete-btn",onClick:C,disabled:e.loading},[o[6]||(o[6]=l("i",{class:"fa fa-trash"},null,-1)),b(" "+p(s(t)("Delete Selected"))+" ("+p(e.selectedKeys.length)+") ",1)],8,U))]))}});const P=K(q,[["__scopeId","data-v-653d49dd"]]);export{P as default};
