1import { nt as ref } from "./chunk-DlK_RcJg.js"; 2//#region step-by-step/pages/index/shared/lib/utils/utils.ts 3var modifyString = (str) => { 4 let modified = str; 5 if (modified.startsWith("\"") && modified.endsWith("\"")) modified = modified.slice(1, -1); 6 modified = modified.split("_").join(" ").replaceAll("0x27", `'`).replaceAll("0x2C", `,`).replaceAll("0x08", `(`).replaceAll("0x09", `)`).replaceAll("0x0e", `.`).replaceAll("0x20", `@`).replaceAll("0xA0", "\xA0"); 7 return modified; 8}; 9var normalizeOption = (option) => option.replace(/\r?\n/g, " ").replace(/\s+/g, " ").trim(); 10var findOptionByPrefix = (options = [], prefix) => options.find((opt) => normalizeOption(opt).startsWith(prefix)); 11var getOptionValue = (options = [], key) => { 12 const option = findOptionByPrefix(options, `${key}:`); 13 if (!option) return void 0; 14 return normalizeOption(option).slice(`${key}:`.length); 15}; 16var groupByStep = (data) => { 17 const grouped = {}; 18 const createItemObject = (item) => { 19 const itemObject = { 20 titles: {}, 21 subTitles: {}, 22 formField: null, 23 className: "", 24 isVisible: true 25 }; 26 const eyebrowTitle = item.options.find((opt) => opt.startsWith("eyebrow-field-title:")); 27 if (eyebrowTitle) itemObject.titles.eyebrowTitle = modifyString(eyebrowTitle.split(":")[1]); 28 const mainTitle = item.options.find((opt) => opt.startsWith("main-field-title:")); 29 if (mainTitle) itemObject.titles.mainTitle = modifyString(mainTitle.split(":")[1]); 30 const subTitle = item.options.find((opt) => opt.startsWith("sub-field-title:")); 31 if (subTitle) itemObject.titles.subTitle = modifyString(subTitle.split(":")[1]); 32 const lgTextTitle = item.options.find((opt) => opt.startsWith("lg-text-field-title:")); 33 if (lgTextTitle) itemObject.titles.lgTextTitle = modifyString(lgTextTitle.split(":")[1]); 34 const xsDisplayTitle = item.options.find((opt) => opt.startsWith("xs-display-field-title:")); 35 if (xsDisplayTitle) itemObject.titles.xsDisplayTitle = modifyString(xsDisplayTitle.split(":")[1]); 36 const dataText = item.options.find((opt) => opt.startsWith("data-text:")); 37 if (dataText) itemObject.titles.dataText = modifyString(dataText.split("data-text:")[1]); 38 else { 39 const dataTextIndex = item.options.indexOf("data-text"); 40 if (dataTextIndex !== -1) itemObject.titles.dataText = item.values?.[dataTextIndex] || item.labels?.[dataTextIndex]; 41 else if (item.basetype === "text" && !item.name && item.values?.[0]) itemObject.titles.dataText = item.values[0]; 42 } 43 const dataClass = item.options.find((opt) => opt.startsWith("data-class:")); 44 if (dataClass) itemObject.titles.dataClass = modifyString(dataClass.split("data-class:")[1]); 45 else { 46 const dataClassIndex = item.options.indexOf("data-class"); 47 if (dataClassIndex !== -1) itemObject.titles.dataClass = item.values?.[dataClassIndex] || item.labels?.[dataClassIndex]; 48 } 49 const text = item.options.find((opt) => opt.startsWith("text-field-title:")); 50 if (text) itemObject.titles.text = modifyString(text.split(":")[1]); 51 const mainFieldSubTitle = item.options.find((opt) => opt.startsWith("main-field-subtitle:")); 52 if (mainFieldSubTitle) itemObject.subTitles.mainTitle = modifyString(mainFieldSubTitle.split(":")[1]); 53 itemObject.isVisible = item.options.find((opt) =>
53 opt.startsWith("visible:"))?.split(":")[1] !== "false"; 54 const customClass = item.options.find((opt) => opt.startsWith("custom-class:")); 55 if (customClass) itemObject.titles.customClass = customClass.split(":")[1]; 56 const className = item.options.find((opt) => opt.startsWith("width:")); 57 let classNameStr = className ? `col-lg-${className.split(":")[1]}` : "col-lg-12"; 58 const orderOption = item.options.find((opt) => opt.startsWith("order:")); 59 if (orderOption) classNameStr += ` order-${orderOption.split(":")[1]}`; 60 const orderLgOption = item.options.find((opt) => opt.startsWith("order-lg:")); 61 if (orderLgOption) classNameStr += ` order-lg-${orderLgOption.split(":")[1]}`; 62 itemObject.className = classNameStr; 63 itemObject.formField = item; 64 const htmlContent = item.options.find((opt) => opt.startsWith("html-content:")); 65 if (htmlContent) { 66 itemObject.isVisible = true; 67 const fullValue = htmlContent.substring(13); 68 itemObject.htmlContent = (fullValue.startsWith("\"") && fullValue.endsWith("\"") ? fullValue.slice(1, -1) : fullValue).split("_").join(" "); 69 } 70 return itemObject; 71 }; 72 for (const item of data) { 73 const stepGroup = item.options.find((opt) => opt.startsWith("step-group:")); 74 const columnGroup = item.options.find((opt) => opt.startsWith("column:")); 75 const rowsGroup = item.options.find((opt) => opt.startsWith("rows-group:")); 76 const className = item.options.find((opt) => opt.startsWith("col:")); 77 const steps = Object.keys(grouped); 78 const lastStep = steps[steps.length - 1]; 79 const step = stepGroup ? modifyString(stepGroup.split(":")[1]) : lastStep; 80 if (step) { 81 if (!grouped[step]) grouped[step] = { 82 titles: {}, 83 columns: {} 84 }; 85 const eyebrowStepTitle = item.options.find((opt) => opt.startsWith("eyebrow-step-title:")); 86 if (eyebrowStepTitle) grouped[step].titles.eyebrowTitle = modifyString(eyebrowStepTitle.split(":")[1]); 87 const customStepClass = item.options.find((opt) => opt.startsWith("custom-step-class:")); 88 if (customStepClass) grouped[step].titles.customClass = customStepClass.split(":")[1]; 89 const mainStepTitle = item.options.find((opt) => opt.startsWith("main-step-title:")); 90 if (mainStepTitle) grouped[step].titles.mainTitle = modifyString(mainStepTitle.split(":")[1]); 91 const subStepTitle = item.options.find((opt) => opt.startsWith("sub-step-title:")); 92 if (subStepTitle) grouped[step].titles.subTitle = modifyString(subStepTitle.split(":")[1]); 93 const dataStepText = item.options.find((opt) => opt.startsWith("data-step-text:")); 94 if (dataStepText) grouped[step].titles.dataText = modifyString(dataStepText.split("data-step-text:")[1]); 95 const dataStepClass = item.options.find((opt) => opt.startsWith("data-step-class:")); 96 if (dataStepClass) grouped[step].titles.dataClass = modifyString(dataStepClass.split("data-step-class:")[1]); 97 if (columnGroup) { 98 const column = modifyString(columnGroup.split(":")[1]); 99 if (!grouped[step].columns[column]) grouped[step].columns[column] = { 100 titles: {}, 101 className: "", 102 items: {} 103 }; 104 const eyebrowColumnTitle = item.options.find((opt) => opt.startsWith("eyebrow-column-title:")); 105 if (eyebrowColumnTitle) grouped[step].columns[column].titles.eyebrowTitle = modifyString(eyebrowColumnTitle.split(":")[1]); 106 const customColumnClass = item.options.find((opt) => opt.startsWith("custom-column-class:")); 107 if (customColumnClass) grouped[step].columns[column].titles.customClass = customColumnClass.split(":")[1]; 108 const mainColumnTitle = item.options.find((opt) => opt.startsWith("main-column-title:")); 109 if (mainColumnTitle) grouped[step].columns[column].titles.mainTitle = modifyString(mainColumnTitle.split(":")[1]); 110 const subColumnTitle = item.options.find((opt) => opt.startsWith("sub-column-title:")); 111 if (subColumnTitle) grouped[step].columns[column].titles.subTitle = modifyString(subColumnTitle.split(":")[1]); 112 grouped[step].columns[column].className = className ? `col-lg-${className.split(":")[1]}` : "col-lg-12"; 113 if (rowsGroup) { 114 const rowsKey = modifyString(rowsGroup.split(":")[1]); 115 if (!grouped[step].columns[column].items[rowsKey]) grouped[step].columns[column].items[rowsKey] = []; 116 grouped[step].columns[column].items[rowsKey].push(createItemObject(item)); 117 } else { 118 const uniqueKey = `unique-${Math.random().toString(36).substr(2, 9)}`; 119 grouped[step].columns[column].items[uniqueKey] = []; 120 grouped[step].columns[column].items[uniqueKey].push(createItemObject(item)); 121 } 122 } else { 123 const columns = Object.keys(grouped[step].columns); 124 const lastColumn = columns[columns.length - 1]; 125 if (item.name === "event") { 126 if (!grouped[step].event) { 127 grouped[step].event = { 128 step: 0, 129 title: "", 130 fields: null 131 }; 132 const eventStep = item.options.find((opt) => opt.startsWith("step:")); 133 if (eventStep) grouped[step].event.step = Number(modifyString(eventStep.split(":")[1])); 134 const eventTitle = item.options.find((opt) => opt.startsWith("title:")); 135 if (eventTitle) grouped[step].event.title = eventTitle.split(":")[1]; 136 const eventFields = item.options.find((opt) => opt.startsWith("fields:")); 137 if (eventFields) grouped[step].event.fields = modifyString(eventFields.split(":")[1]).split("|"); 138 } 139 continue; 140 } 141 if (lastColumn) { 142 if (rowsGroup) { 143 const rowsKey = modifyString(rowsGroup.split(":")[1]); 144 if (!grouped[step].columns[lastColumn].items[rowsKey]) grouped[step].columns[lastColumn].items[rowsKey] = []; 145 grouped[step].columns[lastColumn].items[rowsKey].push(createItemObject(item)); 146 } else { 147 const uniqueKey = `unique-${Math.random().toString(36).substr(2, 9)}`; 148 grouped[step].columns[lastColumn].items[uniqueKey] = []; 149 grouped[step].columns[lastColumn].items[uniqueKey].push(createItemObject(item)); 150 } 151 } 152 } 153 } 154 } 155 return grouped; 156}; 157var findCurrentGroupedItems = (groupedItem) => { 158 const formFields = []; 159 for (const column of Object.values(groupedItem.columns)) for (const items of Object.values(column.items)) for (const item of items) if (item.isVisible) formFields.push(item); 160 return formFields; 161}; 162var findCurrentGroupedItemByName = (groupedItem, name) => { 163 for (const column of Object.values(groupedItem.columns)) for (const items of Object.values(column.items)) for (const item of items) if (item.formField?.name === name) return item; 164}; 165var getUuid = () => { 166 return Math.random().toString(16).slice(2, 10) + "-" + Math.random().toString(16).slice(2,
1666) + "-" + Math.random().toString(16).slice(2, 6) + "-" + Math.random().toString(16).slice(2, 6) + "-" + Math.random().toString(16).slice(2, 14); 167}; 168var getConditionFieldsNames = (formFields) => { 169 return formFields.map((field) => { 170 const conditionOption = getOptionValue(field.options, "condition"); 171 return conditionOption ? conditionOption.split("|").flatMap((cond) => cond.split("?")[0].split("&")) : null; 172 }).filter((titles) => titles !== null).flat(); 173}; 174var capitalizeWords = (str) => { 175 return str.split(" ").map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()).join(" "); 176}; 177//#endregion 178//#region step-by-step/pages/index/shared/lib/helpers/validation.ts 179var emailRegex = /^(([^<>()[\]\.,;:\s@\"]+(\.[^<>()[\]\.,;:\s@\"]+)*)|(\".+\"))@(([^<>()[\]\.,;:\s@\"]+\.)+[^<>()[\]\.,;:\s@\"]{2,})$/i; 180var validation = () => { 181 const errors = ref({}); 182 const errorCodes = ref({}); 183 const validate = (name, value, rules) => { 184 const fieldErrors = []; 185 const customMessages = rules.customMessages || {}; 186 const codes = rules.errorCodes || {}; 187 let firstErrorCode = null; 188 if (rules.required && (!value || Array.isArray(value) && value.length === 0 || typeof value === "string" && value.trim() === "")) { 189 fieldErrors.push(customMessages.required || `Please enter your ${capitalizeWords(name.replace("-", " "))}.`); 190 firstErrorCode = codes.required || `${name.toUpperCase().replace("-", "_")}_REQUIRED`; 191 } 192 if (value && rules.email && !emailRegex.test(value)) { 193 fieldErrors.push(customMessages.email || "Enter a valid email address (e.g., [email protected])."); 194 if (!firstErrorCode) firstErrorCode = codes.email || "EMAIL_INVALID_FORMAT"; 195 } 196 if (value && rules.minLength && value.length < rules.minLength) { 197 fieldErrors.push(customMessages.minLength || `Minimum ${rules.minLength} characters required.`); 198 if (!firstErrorCode) firstErrorCode = codes.minLength || "MIN_LENGTH"; 199 } 200 if (value && rules.maxLength && value.length > rules.maxLength) { 201 fieldErrors.push(customMessages.maxLength || `Maximum ${rules.maxLength} characters allowed.`); 202 if (!firstErrorCode) firstErrorCode = codes.maxLength || "MAX_LENGTH"; 203 } 204 if (value && rules.postalCode && !/^[A-Za-z0-9\s\-]+$/.test(value)) { 205 fieldErrors.push(customMessages.postalCode || "Enter a valid postal code."); 206 if (!firstErrorCode) firstErrorCode = codes.postalCode || "POSTAL_CODE_INVALID_FORMAT"; 207 } 208 if (value && rules.textOnly && !/^[a-zA-Z\s]+$/.test(value)) { 209 fieldErrors.push(customMessages.textOnly || `${capitalizeWords(name.replace("-", " "))} can include letters, spaces, and hyphens only.`); 210 if (!firstErrorCode) firstErrorCode = codes.textOnly || "TEXT_ONLY"; 211 } 212 if (value && rules.phone && !/^\+?[0-9\s-]+$/.test(value)) { 213 fieldErrors.push(customMessages.phone || "Enter a valid phone number (digits only; include area code)."); 214 if (!firstErrorCode) firstErrorCode = codes.phone || "PHONE_INVALID_FORMAT"; 215 } 216 if (value && rules.streetName && !/^[A-Za-z0-9\s\-\.\,\'\/]+$/.test(value)) { 217 fieldErrors.push(customMessages.streetName || `${capitalizeWords(name.replace("-", " "))} can include letters, spaces, and hyphens only.`); 218 if (!firstErrorCode) firstErrorCode = codes.streetName || "STREET_NAME_INVALID_FORMAT"; 219 } 220 if (value && rules.alphaNumeric && !/^[a-zA-Z0-9]+$/.test(value)) { 221 fieldErrors.push(customMessages.alphaNumeric || `Use letters and numbers only in ${capitalizeWords(name.replace("-", " "))}.`); 222 if (!firstErrorCode) firstErrorCode = codes.alphaNumeric || "ALPHA_NUMERIC_INVALID_FORMAT"; 223 } 224 if (value && rules.cityName && !/^[a-zA-Z\s\-]+$/.test(value)) { 225 fieldErrors.push(customMessages.cityName || `${capitalizeWords(name.replace("-", " "))} can include letters, spaces, and hyphens only.`); 226 if (!firstErrorCode) firstErrorCode = codes.cityName || "CITY_NAME_INVALID_FORMAT"; 227 } 228 if (value && rules.personName && !/^[a-zA-Z\s\-]+$/.test(value)) { 229 fieldErrors.push(customMessages.personName || `${capitalizeWords(name.replace("-", " "))} can include letters, spaces, and hyphens only.`); 230 if (!firstErrorCode) firstErrorCode = codes.personName || `${name.toUpperCase().replace("-", "_")}_INVALID_FORMAT`; 231 } 232 if (value && rules.website && !/^(https?:\/\/)?([\w\-]+\.)+[\w\-]+(\/[\w\-._~:/?#[\]@!$&'()*+,;=]*)?$/.test(value)) { 233 fieldErrors.push(customMessages.website || "Invalid website URL."); 234 if (!firstErrorCode) firstErrorCode = codes.website || "WEBSITE_INVALID_FORMAT"; 235 } 236 if (value && rules.matchEmail && value !== rules.matchEmail) { 237 fieldErrors.push(customMessages.matchEmail || "Email addresses must match."); 238 if (!firstErrorCode) firstErrorCode = codes.matchEmail || "MATCH_EMAIL"; 239 } 240 if (rules.fileTypes && Array.isArray(value) && value.length > 0) { 241 if (value.filter((file) => { 242 if (typeof file === "string") return false;
243 const fileExtension = file.name.split(".").pop()?.toLowerCase(); 244 return !fileExtension || !rules.fileTypes.includes(fileExtension); 245 }).length > 0) { 246 const allowedTypes = rules.fileTypes.map((ext) => ext.toUpperCase()).join(", "); 247 fieldErrors.push(customMessages.fileTypes || `Only ${allowedTypes} files are allowed.`); 248 if (!firstErrorCode) firstErrorCode = codes.fileTypes || "FILE_TYPE_INVALID"; 249 } 250 } 251 if (rules.maxFileSize && Array.isArray(value) && value.length > 0) { 252 if (value.filter((file) => { 253 if (typeof file === "string") return false; 254 return file.size > rules.maxFileSize * 1024 * 1024; 255 }).length > 0) { 256 fieldErrors.push(customMessages.maxFileSize || `File size must be less than ${rules.maxFileSize}MB.`); 257 if (!firstErrorCode) firstErrorCode = codes.maxFileSize || "FILE_SIZE_TOO_LARGE"; 258 } 259 } 260 if (rules.maxFiles && Array.isArray(value) && value.length > rules.maxFiles) { 261 fieldErrors.push(customMessages.maxFiles || `You can upload up to ${rules.maxFiles} files.`); 262 if (!firstErrorCode) firstErrorCode = codes.maxFiles || "TOO_MANY_FILES"; 263 } 264 errors.value[name] = fieldErrors.length ? fieldErrors : null; 265 errorCodes.value[name] = firstErrorCode; 266 }; 267 const isFormValid = () => { 268 return Object.values(errors.value).every((fieldErrors) => !fieldErrors); 269 }; 270 const resetValidation = () => { 271 errors.value = {}; 272 errorCodes.value = {}; 273 }; 274 const resetFieldValidation = (fieldName) => { 275 errors.value[fieldName] = null; 276 errorCodes.value[fieldName] = null; 277 }; 278 return { 279 errors, 280 errorCodes, 281 validate, 282 isFormValid, 283 resetValidation, 284 resetFieldValidation 285 }; 286}; 287//#endregion 288export { findOptionByPrefix as a, getUuid as c, findCurrentGroupedItems as i, groupByStep as l, capitalizeWords as n, getConditionFieldsNames as o, findCurrentGroupedItemByName as r, getOptionValue as s, validation as t, modifyString as u };
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.