import{api as b}from"./common-DEIQtiPI.js";import{d as h,A as s,J as o,_ as k,P as j,O as m,B as _,j as B,am as A,H as C,c as r,r as v,g as i}from"./index-DOFLUERq.js";import{_ as V}from"./_plugin-vue_export-helper-DlAUqK2U.js";const N={class:"field-label"},P={key:0,class:"required"},E={class:"password-input-wrap"},M={key:0,xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},S={key:1,xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},z=h({__name:"Password",props:{df:{},record:{},canEdit:{type:Boolean},ctx:{}},setup(t){const e=t,p=r(()=>e.df.label_layout||"vertical"),w=r(()=>{const n=window.jingrow?.boot;return n?.user?.name==="Administrator"||n?.user?.roles?.includes?.("Administrator")}),l=v(!1),c=v(!1),y=r(()=>l.value?"text":"password");function g(n){return n?[...new Set(n)].join("")==="*":!1}const u=r(()=>e.ctx?.entity&&(e.ctx.entity.value??e.ctx.entity)||e.record?.pagetype||""),f=r(()=>e.ctx?.id&&(e.ctx.id.value??e.ctx.id)||e.record?.name||"");async function x(){if(l.value){l.value=!1;return}const n=e.record[e.df.fieldname];if(g(n)&&u.value&&f.value){c.value=!0;try{const a=await b.call("jingrow.client.get_password",{pagetype:u.value,name:f.value,fieldname:e.df.fieldname}),d=a?.message??a;d&&(e.record[e.df.fieldname]=d)}catch{}finally{c.value=!1}}l.value=!0}return(n,a)=>(i(),s("div",{class:C(["field-wrapper",`layout-${p.value}`])},[o("label",N,[k(j(t.ctx.t(t.df.label||t.df.fieldname))+" ",1),t.df.reqd?(i(),s("span",P,"*")):m("",!0)]),o("div",E,[_(B(A),{value:t.record[t.df.fieldname],"onUpdate:value":a[0]||(a[0]=d=>t.record[t.df.fieldname]=d),type:y.value,placeholder:"",disabled:!t.canEdit,loading:c.value},null,8,["value","type","disabled","loading"]),t.canEdit&&w.value?(i(),s("button",{key:0,type:"button",class:"password-toggle-btn",onClick:x},[l.value?(i(),s("svg",M,[...a[1]||(a[1]=[o("path",{d:"M17.94 17.94A10.07 10.07 0 0 1 12 20c-7 0-11-8-11-8a18.45 18.45 0 0 1 5.06-5.94"},null,-1),o("path",{d:"M9.9 4.24A9.12 9.12 0 0 1 12 4c7 0 11 8 11 8a18.5 18.5 0 0 1-2.16 3.19"},null,-1),o("line",{x1:"1",y1:"1",x2:"23",y2:"23"},null,-1)])])):(i(),s("svg",S,[...a[2]||(a[2]=[o("path",{d:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"},null,-1),o("circle",{cx:"12",cy:"12",r:"3"},null,-1)])]))])):m("",!0)])],2))}}),O=V(z,[["__scopeId","data-v-485f5fef"]]),I=Object.freeze(Object.defineProperty({__proto__:null,default:O},Symbol.toStringTag,{value:"Module"}));export{I as _};
