"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const n=require("vue"),r=require("lodash"),f=require("nanoid"),k=require("../../commons/core/datasource/index.js"),i=require("../../commons/utils/json2css.js"),M=["type","placeholder"],_=n.defineComponent({name:"zv-interaction-input"}),q=n.defineComponent({..._,props:{basicOption:{},sources:{},useEvents:{},uuid:{}},emits:["on-blur","on-focus","on-input","on-change"],setup(h,{expose:w,emit:y}){const o=h,l=y,m=()=>{const e=n.ref(""),u=n.ref(),p=s=>{if(i.autoInstallFont(s.fontFamily),i.autoInstallFont(s.focus.fontFamily),u.value)return{...i.jsonToCssStyle(s),...i.jsonToCssStyle(s.focus,"focus"),...i.jsonToCssStyle(s.placeholder,"placeholder")}},v=n.ref(),d=()=>{k.SHJDatasourceV2.parse({tId:o.uuid,sources:o.sources,callback:({data:s})=>{try{window.SHJParseEvent(o.useEvents,"dataListener",s),v.value=f.nanoid(),e.value=s[0].data[0].value}catch{window.SHJParseEvent(o.useEvents,"dataListener",null),v.value=f.nanoid()}}})};return n.onMounted(()=>d()),{key:v,init:d,rendererDomStyle:p,inputRef:u,inputValue:e}},{key:E,init:a,rendererDomStyle:S,inputRef:t,inputValue:c}=m(),b=e=>{t.value&&(l("on-blur",e,t.value.value),window.SHJParseEvent(o.useEvents,"on-blur",{data:t.value.value,event:e}))},I=e=>{t.value&&(l("on-focus",e,t.value.value),window.SHJParseEvent(o.useEvents,"on-focus",{data:t.value.value,event:e}))},D=e=>{t.value&&(l("on-input",e,t.value.value),window.SHJParseEvent(o.useEvents,"on-input",{data:t.value.value,event:e}))},g=e=>{t.value&&(l("on-change",e,t.value.value),window.SHJParseEvent(o.useEvents,"on-change",{data:t.value.value,event:e}))};return n.watch(()=>r.cloneDeep(o.basicOption),(e,u)=>{r.isEqual(e,u)||a()},{deep:!0}),n.watch(()=>r.cloneDeep(o.sources),(e,u)=>{r.isEqual(e,u)||a()},{deep:!0}),w({refresh:()=>a(),refreshView:()=>a(),refreshData:()=>a()}),(e,u)=>n.withDirectives((n.openBlock(),n.createElementBlock("input",{"onUpdate:modelValue":u[0]||(u[0]=p=>n.isRef(c)?c.value=p:null),key:n.unref(E),ref_key:"inputRef",ref:t,type:e.basicOption.css.type||"text",class:"zerov-widget-input",placeholder:e.basicOption.placeholderValue,style:n.normalizeStyle(n.unref(S)(e.basicOption.css)),onBlur:n.withModifiers(b,["stop"]),onFocus:n.withModifiers(I,["stop"]),onInput:n.withModifiers(D,["stop"]),onChange:n.withModifiers(g,["stop"])},null,44,M)),[[n.vModelDynamic,n.unref(c)]])}});exports.default=q;
