import{r as e}from"./rolldown-runtime-BM3Ffeng.js";import{dt as t,ot as n}from"./element-plus-vendor-BF9PNysW.js";import{A as r,E as i,I as a,N as o,O as s,P as c,Pt as l,Tt as u,U as d,et as f,ht as p,j as m,k as h,pt as g,ut as _}from"./vue-vendor-DMUmTARL.js";import{Ta as v}from"./icons-vendor-Db5MGAkr.js";import{v as y}from"./index-kSn5YXd0.js";import{t as b}from"./_plugin-vue_export-helper-CWyGVBf-.js";import{D as x,E as S}from"./admin-storage-BUsF0XeM.js";import{t as C}from"./StoragePathPickerDialog-DofhHaC6.js";var w=[`doge`],T=e=>!!e&&w.includes(e),E=e=>{let t=y(),n=u(`idle`),r=u(null),a=i(()=>n.value===`testing`),o=()=>{n.value=`idle`,r.value=null};return g(()=>JSON.stringify(e.value.storageSourceAllParam||{}),()=>{n.value!==`idle`&&o()}),g(()=>e.value.type,()=>{n.value!==`idle`&&o()}),{testConnection:async()=>{let i=e.value.type;if(!i){t.warning(`请先选择存储源类型`);return}if(T(i)){t.warning(`该存储类型暂不支持连接测试, 请完成配置并保存后验证`);return}n.value=`testing`;try{let t=e.value.id,a={type:i,storageSourceAllParam:e.value.storageSourceAllParam||{}},o=(t?await S(t,a):await x(a))?.data,s=!!o?.success;r.value={success:s,message:o?.message||(s?`连接成功`:`未知错误`),costMs:o?.costMs??0},n.value=s?`success`:`failed`}catch(e){r.value={success:!1,message:e?.message||`测试请求失败`,costMs:0},n.value=`failed`}},testLoading:a,testState:n,testResult:r,resetTest:o}},D={class:`storage-path-field`},O=a({__name:`StoragePathField`,props:d({fieldKey:{},fieldName:{default:``},placeholder:{default:`请输入或点击「浏览」选择路径`}},{storageItem:{required:!0},storageItemModifiers:{}}),emits:[`update:storageItem`],setup(e){let a=e,d=_(e,`storageItem`),g=i({get:()=>d.value.storageSourceAllParam?.[a.fieldKey]??``,set:e=>{let t=d.value.storageSourceAllParam||{};t[a.fieldKey]=e,d.value.storageSourceAllParam=t}}),y=i(()=>!!d.value.type&&!T(d.value.type)),b=u(!1),x=()=>{b.value=!0},S=e=>{g.value=e};return(i,a)=>{let u=n,_=t;return f(),r(`div`,D,[c(_,{modelValue:g.value,"onUpdate:modelValue":a[0]||=e=>g.value=e,placeholder:e.placeholder},m({_:2},[y.value?{name:`append`,fn:p(()=>[c(u,{icon:l(v),onClick:x},{default:p(()=>[...a[2]||=[o(`浏览`,-1)]]),_:1},8,[`icon`])]),key:`0`}:void 0]),1032,[`modelValue`,`placeholder`]),y.value?(f(),s(C,{key:0,modelValue:b.value,"onUpdate:modelValue":a[1]||=e=>b.value=e,title:`选择${e.fieldName||`路径`}`,"storage-item":d.value,"init-path":g.value||`/`,onConfirm:S},null,8,[`modelValue`,`title`,`storage-item`,`init-path`])):h(``,!0)])}}}),k=e({default:()=>A}),A=b(O,[[`__scopeId`,`data-v-697e4ee3`]]);export{E as i,k as n,T as r,A as t};