import{h as C,r as m,e as w,o as N,a,w as o,q as b,u,d as x,f as P,t as y,F as B}from"./vue.esm-bundler.js?ver=1.5.2";import{_ as $}from"./DynamicIcon.js?ver=1.5.2";import{t as l}from"./Translator.js?ver=1.5.2";import{n as f}from"./Notify.js?ver=1.5.2";import{R as q}from"./Rest.js?ver=1.5.2";import{I as S}from"./IconButton.js?ver=1.5.2";import"./Arr.js?ver=1.5.2";import"./Str.js?ver=1.5.2";import"./index.js?ver=1.5.2";import"./_plugin-vue_export-helper.js?ver=1.5.2";const I={class:"dialog-footer"},A={__name:"CreatePageButton",props:{title:{default:"Create Page"},content:{required:!0,type:String}},emits:["onPageCreated"],setup(c,{emit:V}){const g=c,k=V,n=C(!1),r=C(g.title),_=()=>{q.post("onboarding/create-page",{page_name:r.value,content:g.content,save_settings:!0}).then(e=>{k("onPageCreated",{value:e.page_id,label:`${r.value}( ${e.page_id})`,page_link:e.link}),r.value="",n.value=!1,f.success(l("The page created successfully."))}).catch(e=>{if(e&&e.hasOwnProperty("page_name")){const t=Object.entries(e.page_name).length;let i="",p=0;for(const d in e.page_name)i+=e.page_name[d],p!==t&&(i+=`
`),p++;f.error(i)}else f.error(l("Sorry, Unable To Create Page!!"))})};return(e,t)=>{const i=m("el-input"),p=m("el-form-item"),d=m("el-form"),v=m("el-button"),h=m("el-dialog");return N(),w(B,null,[a(S,{onClick:t[0]||(t[0]=b(s=>n.value=!0,["prevent"])),tag:"button",bg:"info",outline:""},{default:o(()=>[a($,{name:"Plus"})]),_:1}),a(h,{modelValue:n.value,"onUpdate:modelValue":t[3]||(t[3]=s=>n.value=s),title:u(l)("Create %s Page",c.title),width:"35%",center:"","append-to-body":!0},{footer:o(()=>[x("div",I,[a(v,{onClick:t[2]||(t[2]=s=>n.value=!1),type:"info",soft:""},{default:o(()=>[P(y(u(l)("Cancel")),1)]),_:1}),a(v,{type:"primary",onClick:_},{default:o(()=>[P(y(u(l)("Create Page")),1)]),_:1})])]),default:o(()=>[a(d,{"require-asterisk-position":"right","label-position":"top",onSubmit:b(_,["prevent"])},{default:o(()=>[a(p,{label:u(l)("Page Name"),required:""},{default:o(()=>[a(i,{modelValue:r.value,"onUpdate:modelValue":t[1]||(t[1]=s=>r.value=s),placeholder:u(l)("Page Name")},null,8,["modelValue","placeholder"])]),_:1},8,["label"])]),_:1})]),_:1},8,["modelValue","title"])],64)}}};export{A as default};
