"use strict";const e=require("../../../../common/vendor.js"),a=require("../common/util.js"),l=require("../composables/useTranslate.js"),u=require("./types.js");Math||c();const c=()=>"../wd-icon/wd-icon.js",s=e.defineComponent({name:"wd-search",options:{virtualHost:!0,addGlobalClass:!0,styleIsolation:"shared"},props:u.searchProps,emits:["update:modelValue","change","clear","search","focus","blur","cancel"],setup(u,{emit:c}){const s=u,t=c,{translate:o}=l.useTranslate("search"),n=e.ref(!1),r=e.ref(!1),d=e.ref(""),v=e.ref(!0),i=e.ref(!1);e.watch((()=>s.modelValue),(e=>{d.value=e,e&&(r.value=!0)}),{immediate:!0}),e.watch((()=>s.focus),(e=>{if(e){if(s.disabled)return;m()}})),e.onMounted((()=>{s.focus&&m()}));const h=e.computed((()=>`wd-search  ${s.light?"is-light":""}  ${s.hideCancel?"is-without-cancel":""} ${s.customClass}`)),p=e.computed((()=>{const e={display:""===d.value&&v.value?"flex":"none"};return a.objToStyle(e)}));async function f(e){r.value=e,await a.pause(),n.value=e}async function m(){s.disabled||(await a.pause(100),v.value=!1,f(!0))}function w(e){d.value=e.detail.value,t("update:modelValue",e.detail.value),t("change",{value:e.detail.value})}async function _(){d.value="",s.focusWhenClear&&(i.value=!0,n.value=!1),await a.pause(),s.focusWhenClear?(v.value=!1,f(!0)):(v.value=!0,f(!1)),t("change",{value:""}),t("update:modelValue",""),t("clear")}function C({detail:{value:e}}){t("search",{value:e})}function y(){v.value=!1,t("focus",{value:d.value})}async function b(){await a.pause(150),i.value?i.value=!1:(v.value=!d.value,r.value=!v.value,n.value=!1,t("blur",{value:d.value}))}function x(){t("cancel",{value:d.value})}return(a,l)=>e.e({a:!a.placeholderLeft},a.placeholderLeft?{}:{b:e.p({name:"search","custom-class":"wd-search__search-icon"}),c:e.t(a.placeholder||e.unref(o)("search")),d:e.n(`wd-search__placeholder-txt ${a.placeholderClass}`),e:e.s(p.value),f:e.o(m)},{g:r.value||d.value||a.placeholderLeft},r.value||d.value||a.placeholderLeft?{h:e.p({name:"search","custom-class":"wd-search__search-left-icon"})}:{},{i:r.value||d.value||a.placeholderLeft},r.value||d.value||a.placeholderLeft?{j:a.placeholder||e.unref(o)("search"),k:`wd-search__placeholder-txt ${a.placeholderClass}`,l:a.placeholderStyle,m:e.n(a.customInputClass),n:e.o(y),o:e.o([e=>d.value=e.detail.value,w]),p:e.o(b),q:e.o(C),r:a.disabled,s:a.maxlength,t:n.value,v:d.value}:{},{w:d.value},d.value?{x:e.o(_),y:e.p({"custom-class":"wd-search__clear wd-search__clear-icon",name:"error-fill"})}:{},{z:!a.hideCancel},a.hideCancel?{}:{A:e.t(a.cancelTxt||e.unref(o)("cancel")),B:e.o(x)},{C:e.n(h.value),D:e.s(a.customStyle)})}}),t=e._export_sfc(s,[["__scopeId","data-v-029340ab"]]);wx.createComponent(t);
