import{getFilteredOptions}from"./../svelte/settings/workflow/utils/utils";class placeholders{getPlaceholders(e,t="",i){const l=[{id:"created_at_datetime",label:"Submission Date"},{id:"created_by",label:"Current User"},{id:"page_source_url",label:"Page Source URL"},{id:"ip_address",label:"IP Address"},{id:"admin_email",label:"Admin Email",field_type:"email"}],r=getFilteredOptions("id","generated_csv",l),d=i.trigger.actions.findIndex((e=>15==e.action_id));r.length<1&&-1!=d&&d<i.actionIndex&&l.push({id:"generated_csv",label:"Generated CSV"});let o=[{id:"trigger_source",group:"Form Fields",options:e.length?this.getOptionsWithPlaceholders(e):[]},{id:"trigger_smart_fields",group:"Form Smart Fields",options:this.getOptionsWithPlaceholders(l)}];if("email"==t){let e=[];o.forEach((t=>{t.options=getFilteredOptions("field_type","email",t.options),t.options.length&&e.push(t)})),o=e}return o}getOptionsWithPlaceholders(e){return e.length<1?e:e.map((e=>(e.placeholder=this.getPlaceholderFromFieldId(e.id),e)))}getPlaceholderFromFieldId(e){let t=e.replace(/[^a-zA-Z0-9]/g,"_");return t=t.toLowerCase(),t=`{{${t}}}`,t}}export default new placeholders;