import{q as S,aI as b,B as c,t as d,aJ as P,aK as R,aL as V,v as w}from"./index.d8ce26ef.js";import{u as C}from"./use-response-handle.e6cae34f.js";const q={api:{type:Function,required:!0},value:{type:String},requestProp:{type:String},responseLabelProp:{type:String},responseValProp:{type:String},placeholder:{type:String},isRoot:{type:Boolean},width:{type:String}};function j(e){return typeof e=="function"||Object.prototype.toString.call(e)==="[object Object]"&&!V(e)}const O=S({name:"RemoteSelect",props:q,emits:["listChange","itemChange","itenDetail"],setup(e,{emit:s}){const u=b(e,"value"),m=C(),o=c([]),n=c(!1);async function v(a){if(!a)return;const{responseLabelProp:t,responseValProp:l,requestProp:i,api:f}=e;n.value=!0;const{code:g,data:p,message:h}=await f({[i||t]:a});m({code:g,message:h,handler:()=>{const y=e.isRoot?p:p.list;o.value=y.map(r=>({...r,label:r[t],value:r[l]})),s("listChange",w(o))}}),n.value=!1}return()=>{let a;return d(R,{modelValue:u.value,"onUpdate:modelValue":t=>u.value=t,placeholder:e.placeholder,remoteMethod:v,loading:n.value,reserveKeyword:!0,filterable:!0,clearable:!0,remote:!0,style:{wdith:e.width?e.width+"px":""},onChange:t=>{s("itemChange",o.value.find(l=>l.value===t))}},j(a=o.value.map((t,l)=>d(P,{label:t.label,key:l,value:t.value},null)))?a:{default:()=>[a]})}}});export{O as R};
