import{u}from"./Note.NSUdvR3c.js";import{_ as e,b as c}from"./main.2.9.0.js";const f=[{label:e("Create Topic","bit-integrations"),name:"create_topic",is_pro:!0},{label:e("Create Forum","bit-integrations"),name:"create_forum",is_pro:!0},{label:e("Post Reply In Topic","bit-integrations"),name:"post_reply_in_topic",is_pro:!0},{label:e("Subscribe User In Forum","bit-integrations"),name:"subscribe_user_in_forum",is_pro:!0}],_={create_topic:[{key:"forum_id",label:e("Forum ID","bit-integrations"),required:!0},{key:"topic_name",label:e("Topic Name","bit-integrations"),required:!0},{key:"topic_content",label:e("Topic Content","bit-integrations"),required:!0},{key:"author_id",label:e("Author ID","bit-integrations"),required:!1}],create_forum:[{key:"parent_id",label:e("Parent ID","bit-integrations"),required:!1},{key:"forum_name",label:e("Forum Name","bit-integrations"),required:!0},{key:"forum_description",label:e("Forum Description","bit-integrations"),required:!1},{key:"forum_icon",label:e("Forum Icon","bit-integrations"),required:!1}],post_reply_in_topic:[{key:"topic_id",label:e("Topic ID","bit-integrations"),required:!0},{key:"reply_content",label:e("Reply Content","bit-integrations"),required:!0},{key:"author_id",label:e("Author ID","bit-integrations"),required:!1}],subscribe_user_in_forum:[{key:"user_id",label:e("User ID","bit-integrations"),required:!0},{key:"forum_id",label:e("Forum ID","bit-integrations"),required:!0}]},y=(t,n,i)=>{const a=u(n,o=>{o[t.target.name]=t.target.value});i(a)},l=t=>_[t]||[],h=t=>{if(!(t!=null&&t.length))return[];const n=t.filter(i=>i.required===!0);return n.length>0?n.map(i=>({formField:"",asgarosForumField:i.key})):[{formField:"",asgarosForumField:""}]},q=t=>{const{mainAction:n,field_map:i=[]}=t||{};if(!n)return!1;const a=l(n).filter(o=>o.required);return a.length?a.every(o=>i.some(r=>(r==null?void 0:r.asgarosForumField)===o.key&&(r==null?void 0:r.formField)&&(r.formField!=="custom"||(r==null?void 0:r.customValue)))):!0},k=(t,n,i,a,o)=>{if(!(t!=null&&t.name)){i({name:e("Integration name can't be empty","bit-integrations")});return}i({}),o(!0),c({name:t.name},"asgaros_forum_authorize").then(r=>{r!=null&&r.success?(a(!0),n(s=>u(s,b=>{b.name=t.name}))):i({name:(r==null?void 0:r.data)||e("Authorization failed","bit-integrations")})}).catch(()=>{i({name:e("Authorization failed","bit-integrations")})}).finally(()=>{o(!1)})};export{l as a,k as b,q as c,h as g,y as h,f as m};
