export const getNoticeContent=e=>{"gsheet"==e&&(e="google");let t={cf7:"Please activate the Contact Form 7 plugin for this trigger to work.",wpforms:"Please activate the WPForms plugin for this trigger to work.",elementor:"Please activate the Elementor Pro plugin for this trigger to work.",forminator:"Please activate the Forminator plugin for this trigger to work.",gravity:"Please activate the Gravity plugin for this trigger to work.",fluent:"Please activate the Fluent plugin for this trigger to work.",woocommerce:"Please activate the WooCommerce plugin for this trigger to work.",mailchimp:`${window.tablesomeTriggers.mailchimpCollection.message}<br><a class="tablesome-notice__link" href="${window.tablesomeTriggers.mailchimpCollection.redirect_url}"> Go to MailChimp Settings >></a>`,notion:`${window.tablesomeTriggers.notionCollection.message} <br><a class="tablesome-notice__link" href="${window.tablesomeTriggers.notionCollection.redirect_url}"> Go to Notion Settings >></a>`,three_actions_per_table:`You can use 1 trigger and 3 actions per table in the free version.<br><a class="tablesome-notice__link" href="${tablesome_fs.trial_url}"> Upgrade to Pro to use more >></a>`};return null==t[e]?tablesome_api_data.api_credentials[e].message_with_redirect_url:t[e]};export const getIntegrationActive=e=>{let t=!1,o=tablesomeTriggers.availableTriggers.findIndex((t=>t.integration===e));return"tablesome"==e&&(t=!0),-1!=o&&(t=tablesomeTriggers.availableTriggers[o].is_active),t};export const getActionIntegrationActive=e=>{"gsheet"==e&&(e="google_safe");let t=["mailchimp","notion","hubspot","slack","google_safe","openai"];if(["wordpress","tablesome","files"].includes(e))return!0;const o=t.includes(e)&&tablesome_api_data[e+"_api_status"]&&_getBool(tablesome_api_data[e+"_api_status"]);return!!(t.includes(e)&&tablesome_api_data.api_credentials[e]&&"success"==tablesome_api_data.api_credentials[e].status||o)};export const getFormattedActionOutputs=(e,t)=>{let o=[];for(let i=0;i<e.length;i++){const r=e[i];i<t&&o.push(r.content)}return o};export const getFilteredOptions=(e,t,o)=>o.filter((o=>o&&o[e]&&o[e]==t));export const getTriggerFields=e=>{let t=e.trigger.integration+"_"+e.trigger.form_id;return"5"==e.trigger.trigger_id?_getColumnsAsTriggerFields(e):"8"==e.trigger.trigger_id?e.workflow.options.email_fields:"9"==e.trigger.trigger_id?e.workflow.options.woo_thankyou_fields:getFilteredOptions("integration_and_post_id",t,e.workflow.options.fields)};export const getActionFields=e=>{let t=e.action.integration+"_"+e.action_source_id;return getFilteredOptions("integration_and_post_id",t,e.workflow.options.fields)};export const getActionOptions=(e,t)=>{const o="premium"===tablesome_fs.plan,i=[4,5,8];let r=getFilteredOptions("integration_type",e,t),a=[];return r.forEach((e=>{let t={...e};!o&&t&&t.id&&i.includes(t.id)&&(t.label=getProLabel(t.label),t.disabled=!0),a.push(t)})),a};export const getActionTaxonomies=e=>{let t=_getPostType(e.action);return getFilteredOptions("post_type",t,e.workflow.options.taxonomies)};export const getActionTermsByTaxonomy=(e,t)=>{if(null==t)return[];let o=getFilteredOptions("id",t,e.workflow.options.taxonomies);return o.length?o[0].terms:[]};export const clickOutside=e=>{const t=t=>{!e||e.contains(t.target)||t.defaultPrevented||e.dispatchEvent(new CustomEvent("click_outside",e))};return document.addEventListener("click",t,!0),{destroy(){document.removeEventListener("click",t,!0)}}};export const deepCopyObj=e=>JSON.parse(JSON.stringify(e));export const disableAlreadySelectedFields=(e,t)=>deepCopyObj(e).map((e=>(_doesFirstOperandExist(e.id,t)&&(e.disabled=!0),e)));const _doesFirstOperandExist=(e,t)=>{let o=!1,i=["taxonomies","post_meta"];return t.forEach((t=>{let r=t.operand_1&&t.operand_1.id?t.operand_1.id:"";e!=r||i.includes(e)||(o=!0)})),o},_getBool=e=>{var t=+e;return isNaN(t)?!!String(e).toLowerCase().replace(!1,""):!!t},getProLabel=e=>{let t=" - PRO";return e.includes(t)?e:e+=t},_getPostType=e=>{let t="";if(e.fields&&e.fields.length){let o=e.fields.findIndex((e=>e.field_type&&"cpt"==e.field_type&&e.value));t="-1"!=o?e.fields[o].value:""}return t},_getColumnsAsTriggerFields=e=>{let t=e.tableColumns,o=[];t&&t.length&&t.forEach((e=>{o.push({id:e.id,label:e.name,format:e.format,data_type:"date"==e.format||"number"==e.format?e.format:"string",object_type:"table_column"})}));return[{id:"trigger_source",group:"Table - Columns",options:o},{id:"trigger_smart_fields",group:"Table - Hidden Columns",options:[{id:"author_id",label:"Created By",data_type:"number",object_type:"table_column"},{id:"updated_by",label:"Updated By",data_type:"number",object_type:"table_column"},{id:"created_at",label:"Created At",data_type:"date",object_type:"table_column"},{id:"updated_at",label:"Updated At",data_type:"date",object_type:"table_column"}]}]};