import{Y as V,aH as B,r as H,F as q,W as z,M as G}from"./index.17037962789732.js";import"./index.170379627897337.js";import"./index.170379627897315.js";import"./index.170379627897318.js";import"./index.170379627897319.js";import"./index.1703796278973311.js";import{u as Q}from"./product.17037962789738.js";import{a as f}from"./comm.1703796278973.js";import{d as U,s as W,k as P,v as Y,r as K,o as X,c as Z,a as p,z as h,b as r,t as C,u as _,G as $,H as A}from"./vue.1703796278973.js";import{x as ee,m as te}from"./product.17037962789737.js";import{s as ae}from"./plugin.17037962789733.js";import{_ as oe}from"./_plugin-vue_export-helper.1703796278973.js";import"./index.17037962789733.js";import"./dayjs.min.1703796278973.js";import"./isArray.1703796278973.js";import"./editor.api.1703796278973.js";import"./preload-helper.1703796278973.js";import"./monaco.contribution.1703796278973.js";import"./encodeQuery.1703796278973.js";import"./system.1703796278973.js";import"./index.170379627897332.js";import"./index.170379627897333.js";import"./index.170379627897334.js";import"./default.1703796278973.js";import"./permission.1703796278973.js";import"./consts.1703796278973.js";import"./404.1703796278973.js";const se=i=>($("data-v-7d77dfb3"),i=i(),A(),i),ce={class:"tip"},ne=se(()=>h("span",{style:{"font-weight":"bold",padding:"0 4px"}},"物模型",-1)),re=["src"],ie=U({name:"MetadataModal"}),pe=U({...ie,props:{metadata:{type:Object,default:()=>({})},access:{type:Object,default:()=>({})},data:{type:Object,default:()=>({})}},emits:["submit","cancel"],setup(i,{emit:w}){const t=i,v=Q(),{current:g}=W(v),x=P(),l=Y({type:void 0}),d=P(!1),E=[{value:"intersection",label:"取交集",subLabel:"仅保留标识一致的属性",iconUrl:f("/device/intersection.png")},{value:"union",label:"取并集",subLabel:"保留平台、插件中的所有属性",iconUrl:f("/device/union.png")},{value:"ignore",label:"忽略",subLabel:"仅保留平台中的属性",iconUrl:f("/device/ignore.png")},{value:"cover",label:"覆盖",subLabel:"仅保留插件中的属性",iconUrl:f("/device/cover.png")}],O=(a,s)=>{Object.keys(a).forEach(e=>{typeof a[e]=="string"?s[e]=a[e]:O(a[e],s)})},R=async(a,s,e)=>{var M,T,D,I,j,k,L,N;const o={};O(s,o);const{storePolicy:n,...b}=o,y={...g.value,metadata:JSON.stringify(e),transportProtocol:(M=t.access)==null?void 0:M.transport,protocolName:(D=(T=t.access)==null?void 0:T.protocolDetail)==null?void 0:D.name,accessId:(I=t.access)==null?void 0:I.id,accessName:(j=t.access)==null?void 0:j.name,accessProvider:(k=t.access)==null?void 0:k.provider,messageProtocol:(L=t.access)==null?void 0:L.protocol};if(d.value=!0,!(await ee(y)).success){d.value=!1;return}((N=t.access)==null?void 0:N.provider)==="plugin_gateway"&&t.data.productTypeId&&await ae("product",t.access.id,t.data.id,t.data.productTypeId).catch(()=>({}));const c=await te(a||"",{id:a,configuration:{...b},storePolicy:n});d.value=!1,c.status===200&&(G.success("操作成功！"),v.current.storePolicy=n,window.onTabSaveSuccess?c.result&&(window.onTabSaveSuccess(c),setTimeout(()=>window.close(),300)):(await v.getDetail(g.value.id),w("submit")))},F=()=>{x.value.validate().then(a=>{var s;if(a){let e=JSON.parse(((s=g.value)==null?void 0:s.metadata)||"{}");switch(l.type[0]){case"intersection":e.properties=u(e.properties,t.metadata.properties),e.events=u(e.events,t.metadata.events),e.functions=u(e.functions,t.metadata.functions),e.tags=u(e.tags,t.metadata.tags);break;case"union":e.properties=m(e.properties,t.metadata.properties),e.functions=m(e.functions,t.metadata.functions),e.events=m(e.events,t.metadata.events),e.tags=m(e.tags,t.metadata.tags);break;case"cover":e=t.metadata;break}R(t.data.id,t.data.values,e)}}).catch(()=>{})},J=()=>{w("cancel")},u=(a=[],s=[])=>{const e=[];return a.length?(s.forEach(o=>{console.log(o,o.id),a.some(n=>n.id===o.id)&&e.push(o)}),e):[]},m=(a=[],s=[])=>{const e=new Map;return s.forEach(o=>{e.set(o.id,o)}),a.forEach(o=>{e.has(o.id)||e.set(o.id,o)}),console.log(a,s,[...e.values()]),[...e.values()]};return(a,s)=>{const e=K("a-icon"),o=V,n=B,b=H,y=q,S=z;return X(),Z(S,{title:"选择处理方式",visible:"",width:"900px",okText:"确定",cancelText:"取消",confirmLoading:_(d),onOk:F,onCancel:J},{default:p(()=>[h("div",ce,[r(e,{type:"ExclamationCircleOutlined"}),C(" 平台 "),ne,C(" 中已有数据，请选择处理方式。 "),r(o,{title:"默认采用覆盖的方式处理功能、事件、标签下的数据"},{default:p(()=>[r(e,{type:"QuestionCircleOutlined"})]),_:1})]),r(y,{layout:"vertical",ref_key:"formRef",ref:x,model:_(l)},{default:p(()=>[r(b,{label:"处理方式",rules:[{required:!0,message:"请选择处理方式"}]},{default:p(()=>[r(n,{value:_(l).type,"onUpdate:value":s[0]||(s[0]=c=>_(l).type=c),column:4,options:E},{image:p(({image:c})=>[h("img",{src:c},null,8,re)]),_:1},8,["value"])]),_:1})]),_:1},8,["model"])]),_:1},8,["confirmLoading"])}}});const Re=oe(pe,[["__scopeId","data-v-7d77dfb3"]]);export{Re as default};
