import{d as b,aa as h,w as C,i as w,j as o,aC as B,t as a,C as x,c as i,g as y,J as N,B as S,Q as M,e as $,aI as V}from"./index-DOFLUERq.js";import{L}from"./LinkField-CPzmuCgV.js";import{_ as T}from"./_plugin-vue_export-helper-DlAUqK2U.js";import"./iconify-p99pbjf9.js";const q={class:"dialog-content"},D=b({__name:"CustomBlockDialog",props:{show:{type:Boolean},values:{}},emits:["update:show","submit"],setup(r,{emit:d}){const p=$(),s=r,m=d,_=h(),n=i({get:()=>s.show,set:e=>m("update:show",e)}),c=i(()=>!!s.values?.name),t=M({custom_block_name:"",name:""});function k(){return{query:"jingrow.desk.pagetype.custom_html_block.custom_html_block.get_custom_blocks_for_user"}}C(()=>s.show,e=>{e&&(s.values?(t.custom_block_name=s.values.custom_block_name||"",t.name=s.values.name||""):(t.custom_block_name="",t.name=""))},{immediate:!0});function g(){if(!t.custom_block_name)return _.error(a("Please select a custom block")),!1;const e={...t};return!c.value&&!e.name&&(e.name=`custom_block-${t.custom_block_name}-${Math.random().toString(36).substring(2,12)}`),m("submit",e),n.value=!1,!0}function f(){n.value=!1}function v(){n.value=!1;const e=V("Custom HTML Block"),l=Math.random().toString(36).substring(2,12),u=`new-${e}-${l}`;p.push(`/app/${e}/${u}`)}return(e,l)=>(y(),w(o(B),{show:n.value,"onUpdate:show":l[1]||(l[1]=u=>n.value=u),preset:"dialog",title:c.value?o(a)("Edit Custom Block"):o(a)("Add Custom Block"),"positive-text":c.value?o(a)("Save"):o(a)("Add"),"negative-text":o(a)("Cancel"),onPositiveClick:g,onNegativeClick:f,style:{width:"500px"}},{default:x(()=>[N("div",q,[S(L,{modelValue:t.custom_block_name,"onUpdate:modelValue":l[0]||(l[0]=u=>t.custom_block_name=u),options:"Custom HTML Block",label:o(a)("Custom Block Name"),required:!0,placeholder:"","enable-create":!0,onCreate:v,"get-query":k},null,8,["modelValue","label"])])]),_:1},8,["show","title","positive-text","negative-text"]))}}),P=T(D,[["__scopeId","data-v-efbc2751"]]);export{P as default};
