import{V as B,aJ as S,r as A}from"./index.17037962789732.js";import"./index.170379627897318.js";import"./index.170379627897319.js";import{_ as F}from"./index.17037962789739.js";import"./index.1703796278973312.js";import{d as g,s as I,k as _,T as O,w as v,p as z,r as E,o as l,x as i,b as h,a as f,u as c,M as L,F as b,h as M,c as P,E as R,z as k}from"./vue.1703796278973.js";import{u as V}from"./scene.1703796278973.js";import{C as j,a as J,h as N}from"./util.17037962789735.js";import{g as q}from"./scene.17037962789732.js";import K from"./Branches.17037962789732.js";import U from"./index.1703796278973260.js";const $={class:"actions-terms"},G=k("div",{class:"actions-terms-title",style:{padding:"0","margin-bottom":"24px"}}," 否则 ",-1),H={class:"actions-terms-options no-when"},Q={key:1,class:"actions-branches-item"},W=g({name:"Terms"}),ie=g({...W,setup(X){const y=V(),{data:e}=I(y),r=_(!1),p=_([]);O(j,p);const w=n=>{n?(e.value.branches.push(null),e.value.branches[0].when=[{terms:[{column:void 0,value:{source:"fixed",value:void 0},termType:void 0,key:"params_1",type:"and"}],type:"and",key:"terms_1"}]):(e.value.branches.length=1,e.value.branches[0].when=[])},C=n=>{var t;const s=B(n);s.branches=(t=s.branches)==null?void 0:t.filter(a=>!!a),q(s).then(a=>{p.value=N(a.result)})},x=()=>{var t;const n={when:[],key:`branches_${new Date().getTime()}`,shakeLimit:{enabled:!1,time:1,threshold:1,alarmFirst:!1},then:[]},s=e.value.branches.length-1||0;(t=e.value.branches)==null||t.splice(s,1,n),e.value.options.when=[]},D=n=>{var s,t,a,m,u;((s=e.value.branches)==null?void 0:s.length)===2?(t=e.value.branches)==null||t.splice(n,1,null):(a=e.value.branches)==null||a.splice(n,1),(u=(m=e.value.options)==null?void 0:m.when)==null||u.splice(n,1)},T=()=>{};return v(()=>{var n;(n=e.value.trigger)!=null&&n.device&&C({trigger:e.value.trigger})}),v(()=>{var n;(n=e.value.branches)!=null&&n.filter(s=>s).length?r.value=!!e.value.branches[0].when.length:r.value=!0}),z(()=>{console.log("terms-onMounted")}),(n,s)=>{const t=S,a=F,m=E("AIcon"),u=A;return l(),i("div",$,[h(a,{data:"触发条件",style:{"font-size":"14px"}},{extra:f(()=>[h(t,{checked:c(r),"onUpdate:checked":s[0]||(s[0]=o=>L(r)?r.value=o:null),onChange:w,checkedChildren:"开",unCheckedChildren:"关",style:{"margin-left":"4px"}},null,8,["checked"])]),_:1}),c(r)?(l(!0),i(b,{key:0},M(c(e).branches,(o,d)=>(l(),i(b,null,[o?(l(),P(K,{data:o,isFirst:d===0,name:d,key:o.key,onDelete:D,onDeleteAll:T},null,8,["data","isFirst","name"])):(l(),i("div",{key:1,class:"actions-terms-warp",style:R({marginTop:c(e).branches.length===2?0:24})},[G,k("div",H,[h(m,{type:"PlusOutlined",class:"when-add-button",onClick:x})])],4))],64))),256)):(l(),i("div",Q,[h(u,{name:["branches",0,"then"],rules:c(J)},{default:f(()=>{var o;return[h(U,{name:0,openShakeLimit:!0,thenOptions:(o=c(e).branches[0])==null?void 0:o.then},null,8,["thenOptions"])]}),_:1},8,["rules"])]))])}}});export{ie as _};
