import{b as p,i as E}from"./useflows-BpG3C9m1.js";import{e as t}from"./main-few-lands-burn.js";import{s as r,h as i}from"./machine.-BRuqPpdF.js";import{h as T,c as S}from"./commons.-bP-saOXM.js";import{f as s,a as d,s as l,h as m}from"./machineh-5vGV0ecU.js";import"./mutative-C6xjlr6O.js";import"./lodash-YpNkAOPN.js";const A=p(({helpers:o})=>({states:{components:[S(o),{componentName:o.componentName.select,fieldType:"config",id:"spreadsheet-id",label:t("Spreadsheet"),onChange:"SELECT_SPREADSHEET",onRefetch:"REFETCH_SPREADSHEETS",optionFilterProp:"label",options:[],placeholder:t("Select a spreadsheet"),render:"IF_CONNECTION_SELECTED",showSearch:!0,value:void 0},{componentName:o.componentName.select,fieldType:"config",id:"sheet-title",isMappable:!0,label:t("Sheet"),onChange:"SELECT_SHEET",onRefetch:"REFETCH_SHEETS",optionFilterProp:"label",options:[],placeholder:t("Select a sheet"),render:"IF_SPREADSHEET_SELECTED",showSearch:!0,value:void 0},{addItemButtonLabel:"Add Column",componentName:o.componentName.repeaterField,fieldsMetaData:[{componentName:o.componentName.select,label:t("Column"),name:"column",options:[],required:!0,style:{width:100},value:""},{componentName:o.componentName.mixInput,label:t("Value"),name:"value",required:!0,value:[],wrapperClassName:"w-100"}],id:"row-data",label:t("Field Mapping"),labelActionIconName:"refresh-cw",labelActionOnClick:"REFETCH_COLUMNS",labelActionText:t("Refetch Columns"),onChange:"ON_CHANGE_ROW_DATA",path:"rowData",render:"IF_SHEET_SELECTED",value:[],wrapperClassName:"mt-3"},{componentName:o.componentName.switch,id:"show-advanced-settings",label:t("Show Advanced Settings"),onChange:"HANDLE_SHOW_ADVANCED_SETTINGS",render:"IF_SHEET_SELECTED",size:"small"},{componentName:o.componentName.select,fieldType:"config",helperText:t("Choose how new data is added relative to existing sheet content. 'Overwrite' updates empty columns without affecting existing data; 'Insert Rows' always adds new rows."),id:"insert-data-option",isMappable:!0,label:t("Insert Data Option"),onChange:"SELECT_INSERT_DATA_OPTION",options:[{label:t("Insert Rows"),value:"INSERT_ROWS"},{label:t("Overwrite"),value:"OVERWRITE"}],render:"IF_ADVANCED_SETTINGS_ENABLED",value:"INSERT_ROWS"},{componentName:o.componentName.select,fieldType:"config",helperText:t("Specifies how input data is interpreted: store as-is (RAW) or parse like user input in Sheets (USER_ENTERED)."),id:"value-input-option",isMappable:!0,label:t("Value Input Option"),onChange:"SELECT_VALUE_INPUT_OPTION",options:[{label:t("User Entered"),value:"USER_ENTERED"},{label:t("Raw"),value:"RAW"}],render:"IF_ADVANCED_SETTINGS_ENABLED",value:"USER_ENTERED"}]},actions:{CONNECTION_ADD_CHANGE:T,IF_CONNECTION_SELECTED:({$:e})=>E(e.getComponent("connection-id")?.value),IF_SHEET_SELECTED:({$:e})=>E(e.getComponent("sheet-title")?.value),IF_SPREADSHEET_SELECTED:({$:e})=>E(e.getComponent("spreadsheet-id")?.value),ON_CHANGE_ROW_DATA:i("rowData"),REFETCH_COLUMNS:({$:e})=>l(e),REFETCH_SHEETS:({$:e})=>Promise.all([d(e),l(e)]),REFETCH_SPREADSHEETS:({$:e})=>s(e),SELECT_INSERT_DATA_OPTION:i("insertDataOption"),SELECT_VALUE_INPUT_OPTION:i("valueInputOption"),IF_ADVANCED_SETTINGS_ENABLED:({$:e})=>E(e.getComponent("sheet-title")?.value)&&e.getComponent("show-advanced-settings")?.value===!0,HANDLE_SHOW_ADVANCED_SETTINGS:async({$:e,e:a})=>{e.setThisComponent(n=>{n.value=a})},SELECT_SHEET:({$:e,e:a})=>{i("sheetTitle")({$:e,e:a}),l(e)},SELECT_SPREADSHEET:({$:e,e:a})=>{e.setThisComponent(n=>{n.value=a}),e.setComponent("sheet-title",n=>{n.value=void 0}),e.setDb(n=>{n.spreadsheetId=a,n.sheetTitle=void 0}),d(e)},SET_CONNECTION:({$:e,e:a})=>{e.setThisComponent(n=>{n.value=a}),e.setDb(n=>{n.connectionId=a}),s(e),m(e,o)},ON_MACHINE_LOAD:({$:e})=>{r(e,[{db:"connectionId",id:"connection-id"},{db:"spreadsheetId",id:"spreadsheet-id"},{db:"sheetTitle",id:"sheet-title"},{db:"rowData",id:"row-data"},{db:"insertDataOption",id:"insert-data-option"},{db:"valueInputOption",id:"value-input-option"}]),Promise.all([s(e),d(e),l(e)])}}}));export{A as default};
