{"version":3,"file":"Utility.js","sources":["../../Framework/Utility/http.ts","../../Framework/Utility/address.ts","../../Framework/Utility/arrayUtils.ts","../../Framework/Utility/linq.ts","../../Framework/Utility/guid.ts","../../Framework/Utility/stringUtils.ts","../../Framework/Utility/aspDateFormat.ts","../../Framework/Utility/rockDateTime.ts","../../Framework/Utility/util.ts","../../Framework/Utility/browserBus.ts","../../Framework/Utility/block.ts","../../Framework/Utility/booleanUtils.ts","../../Framework/Utility/cache.ts","../../Framework/Utility/cancellation.ts","../../Framework/Utility/suspense.ts","../../Framework/Utility/numberUtils.ts","../../Framework/Utility/component.ts","../../Framework/Utility/dateKey.ts","../../Framework/Utility/page.ts","../../Framework/Utility/dialogs.ts","../../Framework/Utility/email.ts","../../Framework/Utility/enumUtils.ts","../../Framework/Utility/fieldTypes.ts","../../Framework/Utility/file.ts","../../Framework/Utility/form.ts","../../Framework/Utility/fullscreen.ts","../../Framework/Utility/geo.ts","../../Framework/Utility/internetCalendar.ts","../../Framework/Utility/lava.ts","../../Framework/Utility/listItemBag.ts","../../Framework/Utility/mergeField.ts","../../Framework/Utility/objectUtils.ts","../../Framework/Utility/phone.ts","../../Framework/Utility/popover.ts","../../Framework/Utility/promiseUtils.ts","../../Framework/Utility/realTime.ts","../../Framework/Utility/rockCurrency.ts","../../Framework/Utility/slidingDateRange.ts","../../Framework/Utility/structuredContentEditor.ts","../../Framework/Utility/tooltip.ts","../../Framework/Utility/treeItemProviders.ts","../../Framework/Utility/url.ts","../../Framework/Utility/validationRules.ts"],"sourcesContent":["// \r\n// Copyright by the Spark Development Network\r\n//\r\n// Licensed under the Rock Community License (the \"License\");\r\n// you may not use this file except in compliance with the License.\r\n// You may obtain a copy of the License at\r\n//\r\n// http://www.rockrms.com/license\r\n//\r\n// Unless required by applicable law or agreed to in writing, software\r\n// distributed under the License is distributed on an \"AS IS\" BASIS,\r\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n// See the License for the specific language governing permissions and\r\n// limitations under the License.\r\n// \r\n//\r\n\r\nimport { Guid } from \"@Obsidian/Types\";\r\nimport axios, { AxiosResponse } from \"axios\";\r\nimport { ListItemBag } from \"@Obsidian/ViewModels/Utility/listItemBag\";\r\nimport { HttpBodyData, HttpMethod, HttpFunctions, HttpResult, HttpUrlParams } from \"@Obsidian/Types/Utility/http\";\r\nimport { inject, provide, getCurrentInstance } from \"vue\";\r\n\r\n\r\n// #region HTTP Requests\r\n\r\n/**\r\n * Make an API call. This is only place Axios (or AJAX library) should be referenced to allow tools like performance metrics to provide\r\n * better insights.\r\n * @param method\r\n * @param url\r\n * @param params\r\n * @param data\r\n */\r\nasync function doApiCallRaw(method: HttpMethod, url: string, params: HttpUrlParams, data: HttpBodyData): Promise> {\r\n return await axios({\r\n method,\r\n url,\r\n params,\r\n data\r\n });\r\n}\r\n\r\n/**\r\n * Make an API call. This is a special use function that should not\r\n * normally be used. Instead call useHttp() to get the HTTP functions that\r\n * can be used.\r\n *\r\n * @param {string} method The HTTP method, such as GET\r\n * @param {string} url The endpoint to access, such as /api/campuses/\r\n * @param {object} params Query parameter object. Will be converted to ?key1=value1&key2=value2 as part of the URL.\r\n * @param {any} data This will be the body of the request\r\n */\r\nexport async function doApiCall(method: HttpMethod, url: string, params: HttpUrlParams = undefined, data: HttpBodyData = undefined): Promise> {\r\n try {\r\n const result = await doApiCallRaw(method, url, params, data);\r\n\r\n return {\r\n data: result.data as T,\r\n isError: false,\r\n isSuccess: true,\r\n statusCode: result.status,\r\n errorMessage: null\r\n } as HttpResult;\r\n }\r\n catch (e) {\r\n if (axios.isAxiosError(e)) {\r\n if (e.response?.data?.Message || e?.response?.data?.message) {\r\n return {\r\n data: null,\r\n isError: true,\r\n isSuccess: false,\r\n statusCode: e.response.status,\r\n errorMessage: e?.response?.data?.Message ?? e.response.data.message\r\n } as HttpResult;\r\n }\r\n\r\n return {\r\n data: null,\r\n isError: true,\r\n isSuccess: false,\r\n statusCode: e.response?.status ?? 0,\r\n errorMessage: null\r\n } as HttpResult;\r\n }\r\n else {\r\n return {\r\n data: null,\r\n isError: true,\r\n isSuccess: false,\r\n statusCode: 0,\r\n errorMessage: null\r\n } as HttpResult;\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * Make a GET HTTP request. This is a special use function that should not\r\n * normally be used. Instead call useHttp() to get the HTTP functions that\r\n * can be used.\r\n *\r\n * @param {string} url The endpoint to access, such as /api/campuses/\r\n * @param {object} params Query parameter object. Will be converted to ?key1=value1&key2=value2 as part of the URL.\r\n */\r\nexport async function get(url: string, params: HttpUrlParams = undefined): Promise> {\r\n return await doApiCall(\"GET\", url, params, undefined);\r\n}\r\n\r\n/**\r\n * Make a POST HTTP request. This is a special use function that should not\r\n * normally be used. Instead call useHttp() to get the HTTP functions that\r\n * can be used.\r\n *\r\n * @param {string} url The endpoint to access, such as /api/campuses/\r\n * @param {object} params Query parameter object. Will be converted to ?key1=value1&key2=value2 as part of the URL.\r\n * @param {any} data This will be the body of the request\r\n */\r\nexport async function post(url: string, params: HttpUrlParams = undefined, data: HttpBodyData = undefined): Promise> {\r\n return await doApiCall(\"POST\", url, params, data);\r\n}\r\n\r\nconst httpFunctionsSymbol = Symbol(\"http-functions\");\r\n\r\n/**\r\n * Provides the HTTP functions that child components will use. This is an\r\n * internal API and should not be used by third party components.\r\n *\r\n * @param functions The functions that will be made available to child components.\r\n */\r\nexport function provideHttp(functions: HttpFunctions): void {\r\n provide(httpFunctionsSymbol, functions);\r\n}\r\n\r\n/**\r\n * Gets the HTTP functions that can be used by the component. This is the\r\n * standard way to make HTTP requests.\r\n *\r\n * @returns An object that contains the functions which can be called.\r\n */\r\nexport function useHttp(): HttpFunctions {\r\n let http: HttpFunctions | undefined;\r\n\r\n // Check if we are inside a setup instance. This prevents warnings\r\n // from being displayed if being called outside a setup() function.\r\n if (getCurrentInstance()) {\r\n http = inject(httpFunctionsSymbol);\r\n }\r\n\r\n return http || {\r\n doApiCall: doApiCall,\r\n get: get,\r\n post: post\r\n };\r\n}\r\n\r\n// #endregion\r\n\r\n// #region File Upload\r\n\r\ntype FileUploadResponse = {\r\n /* eslint-disable @typescript-eslint/naming-convention */\r\n Guid: Guid;\r\n FileName: string;\r\n /* eslint-enable */\r\n};\r\n\r\n/**\r\n * Progress reporting callback used when uploading a file into Rock.\r\n */\r\nexport type UploadProgressCallback = (progress: number, total: number, percent: number) => void;\r\n\r\n/**\r\n * Options used when uploading a file into Rock to change the default behavior.\r\n */\r\nexport type UploadOptions = {\r\n /**\r\n * The base URL to use when uploading the file, must accept the same parameters\r\n * and as the standard FileUploader.ashx handler.\r\n */\r\n baseUrl?: string;\r\n\r\n /** True if the file should be uploaded as temporary, only applies to binary files. */\r\n isTemporary?: boolean;\r\n\r\n /** A function to call to report the ongoing progress of the upload. */\r\n progress: UploadProgressCallback;\r\n};\r\n\r\n/**\r\n * Uploads a file in the form data into Rock. This is an internal function and\r\n * should not be exported.\r\n *\r\n * @param url The URL to use for the POST request.\r\n * @param data The form data to send in the request body.\r\n * @param progress The optional callback to use to report progress.\r\n *\r\n * @returns The response from the upload handler.\r\n */\r\nasync function uploadFile(url: string, data: FormData, progress: UploadProgressCallback | undefined): Promise {\r\n const result = await axios.post(url, data, {\r\n headers: {\r\n \"Content-Type\": \"multipart/form-data\"\r\n },\r\n onUploadProgress: (event: ProgressEvent) => {\r\n if (progress) {\r\n progress(event.loaded, event.total, Math.floor(event.loaded * 100 / event.total));\r\n }\r\n }\r\n });\r\n\r\n // Check for a \"everything went perfectly fine\" response.\r\n if (result.status === 200 && typeof result.data === \"object\") {\r\n return result.data;\r\n }\r\n\r\n if (result.status === 406) {\r\n throw \"File type is not allowed.\";\r\n }\r\n\r\n if (typeof result.data === \"string\") {\r\n throw result.data;\r\n }\r\n\r\n throw \"Upload failed.\";\r\n}\r\n\r\n/**\r\n * Uploads a file to the Rock file system, usually inside the ~/Content directory.\r\n *\r\n * @param file The file to be uploaded to the server.\r\n * @param encryptedRootFolder The encrypted root folder specified by the server,\r\n * this specifies the jail the upload operation is limited to.\r\n * @param folderPath The additional sub-folder path to use inside the root folder.\r\n * @param options The options to use when uploading the file.\r\n *\r\n * @returns A ListItemBag that contains the scrubbed filename that was uploaded.\r\n */\r\nexport async function uploadContentFile(file: File, encryptedRootFolder: string, folderPath: string, options?: UploadOptions): Promise {\r\n const url = `${options?.baseUrl ?? \"/FileUploader.ashx\"}?rootFolder=${encryptedRootFolder}`;\r\n const formData = new FormData();\r\n\r\n formData.append(\"file\", file);\r\n\r\n if (folderPath) {\r\n formData.append(\"folderPath\", folderPath);\r\n }\r\n\r\n const result = await uploadFile(url, formData, options?.progress);\r\n\r\n return {\r\n value: \"\",\r\n text: result.FileName\r\n };\r\n}\r\n\r\n/**\r\n * Uploads a BinaryFile into Rock. The specific storage location is defined by\r\n * the file type.\r\n *\r\n * @param file The file to be uploaded into Rock.\r\n * @param binaryFileTypeGuid The unique identifier of the BinaryFileType to handle the upload.\r\n * @param options The options ot use when uploading the file.\r\n *\r\n * @returns A ListItemBag whose value contains the new file Guid and text specifies the filename.\r\n */\r\nexport async function uploadBinaryFile(file: File, binaryFileTypeGuid: Guid, options?: UploadOptions): Promise {\r\n let url = `${options?.baseUrl ?? \"/FileUploader.ashx\"}?isBinaryFile=True&fileTypeGuid=${binaryFileTypeGuid}`;\r\n\r\n // Assume file is temporary unless specified otherwise so that files\r\n // that don't end up getting used will get cleaned up.\r\n if (options?.isTemporary === false) {\r\n url += \"&isTemporary=False\";\r\n }\r\n else {\r\n url += \"&isTemporary=True\";\r\n }\r\n\r\n const formData = new FormData();\r\n formData.append(\"file\", file);\r\n\r\n const result = await uploadFile(url, formData, options?.progress);\r\n\r\n return {\r\n value: result.Guid,\r\n text: result.FileName\r\n };\r\n}\r\n\r\n// #endregion\r\n\r\nexport default {\r\n doApiCall,\r\n post,\r\n get\r\n};\r\n","// \r\n// Copyright by the Spark Development Network\r\n//\r\n// Licensed under the Rock Community License (the \"License\");\r\n// you may not use this file except in compliance with the License.\r\n// You may obtain a copy of the License at\r\n//\r\n// http://www.rockrms.com/license\r\n//\r\n// Unless required by applicable law or agreed to in writing, software\r\n// distributed under the License is distributed on an \"AS IS\" BASIS,\r\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n// See the License for the specific language governing permissions and\r\n// limitations under the License.\r\n// \r\n//\r\n\r\nimport { HttpResult } from \"@Obsidian/Types/Utility/http\";\r\nimport { AddressControlBag } from \"@Obsidian/ViewModels/Controls/addressControlBag\";\r\nimport { AddressControlValidateAddressOptionsBag } from \"@Obsidian/ViewModels/Rest/Controls/AddressControlValidateAddressOptionsBag\";\r\nimport { AddressControlValidateAddressResultsBag } from \"@Obsidian/ViewModels/Rest/Controls/AddressControlValidateAddressResultsBag\";\r\nimport { post } from \"./http\";\r\n\r\nexport function getDefaultAddressControlModel(): AddressControlBag {\r\n return {\r\n state: \"AZ\",\r\n country: \"US\"\r\n };\r\n}\r\n\r\nexport function validateAddress(address: AddressControlValidateAddressOptionsBag): Promise> {\r\n return post(\"/api/v2/Controls/AddressControlValidateAddress\", undefined, address);\r\n}\r\n\r\nexport function getAddressString(address: AddressControlBag): Promise> {\r\n return post(\"/api/v2/Controls/AddressControlGetStreetAddressString\", undefined, address);\r\n}","// \r\n// Copyright by the Spark Development Network\r\n//\r\n// Licensed under the Rock Community License (the \"License\");\r\n// you may not use this file except in compliance with the License.\r\n// You may obtain a copy of the License at\r\n//\r\n// http://www.rockrms.com/license\r\n//\r\n// Unless required by applicable law or agreed to in writing, software\r\n// distributed under the License is distributed on an \"AS IS\" BASIS,\r\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n// See the License for the specific language governing permissions and\r\n// limitations under the License.\r\n// \r\n//\r\n\r\n/**\r\n * Flatten a nested array down by the given number of levels.\r\n * Meant to be a replacement for the official Array.prototype.flat, which isn't supported by all browsers we support.\r\n * Adapted from Polyfill: https://github.com/behnammodi/polyfill/blob/master/array.polyfill.js#L591\r\n *\r\n * @param arr (potentially) nested array to be flattened\r\n * @param depth The depth level specifying how deep a nested array structure should be flattened. Defaults to 1.\r\n *\r\n * @returns A new array with the sub-array elements concatenated into it.\r\n */\r\nexport const flatten = (arr: T[][], depth: number = 1): T[] => {\r\n const result: T[] = [];\r\n const forEach = result.forEach;\r\n\r\n const flatDeep = function (arr, depth): void {\r\n forEach.call(arr, function (val) {\r\n if (depth > 0 && Array.isArray(val)) {\r\n flatDeep(val, depth - 1);\r\n }\r\n else {\r\n result.push(val);\r\n }\r\n });\r\n };\r\n\r\n flatDeep(arr, depth);\r\n return result;\r\n};","/**\r\n * A function that will select a value from the object.\r\n */\r\ntype ValueSelector = (value: T) => string | number | boolean | null | undefined;\r\n\r\n/**\r\n * A function that will perform testing on a value to see if it meets\r\n * a certain condition and return true or false.\r\n */\r\ntype PredicateFn = (value: T, index: number) => boolean;\r\n\r\n/**\r\n * A function that will compare two values to see which one should\r\n * be ordered first.\r\n */\r\ntype ValueComparer = (a: T, b: T) => number;\r\n\r\nconst moreThanOneElement = \"More than one element was found in collection.\";\r\n\r\nconst noElementsFound = \"No element was found in collection.\";\r\n\r\n/**\r\n * Compares the values of two objects given the selector function.\r\n *\r\n * For the purposes of a compare, null and undefined are always a lower\r\n * value - unless both values are null or undefined in which case they\r\n * are considered equal.\r\n * \r\n * @param keySelector The function that will select the value.\r\n * @param descending True if this comparison should be in descending order.\r\n */\r\nfunction valueComparer(keySelector: ValueSelector, descending: boolean): ValueComparer {\r\n return (a: T, b: T): number => {\r\n const valueA = keySelector(a);\r\n const valueB = keySelector(b);\r\n\r\n // If valueA is null or undefined then it will either be considered\r\n // lower than or equal to valueB.\r\n if (valueA === undefined || valueA === null) {\r\n // If valueB is also null or undefined then they are considered equal.\r\n if (valueB === undefined || valueB === null) {\r\n return 0;\r\n }\r\n\r\n return !descending ? -1 : 1;\r\n }\r\n\r\n // If valueB is undefined or null (but valueA is not) then it is considered\r\n // a lower value than valueA.\r\n if (valueB === undefined || valueB === null) {\r\n return !descending ? 1 : -1;\r\n }\r\n\r\n // Perform a normal comparison.\r\n if (valueA > valueB) {\r\n return !descending ? 1 : -1;\r\n }\r\n else if (valueA < valueB) {\r\n return !descending ? -1 : 1;\r\n }\r\n else {\r\n return 0;\r\n }\r\n };\r\n}\r\n\r\n\r\n/**\r\n * Provides LINQ style access to an array of elements.\r\n */\r\nexport class List {\r\n /** The elements being tracked by this list. */\r\n protected elements: T[];\r\n\r\n // #region Constructors\r\n\r\n /**\r\n * Creates a new list with the given elements.\r\n * \r\n * @param elements The elements to be made available to LINQ queries.\r\n */\r\n constructor(elements?: T[]) {\r\n if (elements === undefined) {\r\n this.elements = [];\r\n }\r\n else {\r\n // Copy the array so if the caller makes changes it won't be reflected by us.\r\n this.elements = [...elements];\r\n }\r\n }\r\n\r\n /**\r\n * Creates a new List from the elements without copying to a new array.\r\n * \r\n * @param elements The elements to initialize the list with.\r\n * @returns A new list of elements.\r\n */\r\n public static fromArrayNoCopy(elements: T[]): List {\r\n const list = new List();\r\n\r\n list.elements = elements;\r\n\r\n return list;\r\n }\r\n\r\n // #endregion\r\n\r\n /**\r\n * Returns a boolean that determines if the collection contains any elements.\r\n *\r\n * @returns true if the collection contains any elements; otherwise false.\r\n */\r\n public any(): boolean;\r\n\r\n /**\r\n * Filters the list by the predicate and then returns a boolean that determines\r\n * if the filtered collection contains any elements.\r\n *\r\n * @param predicate The predicate to filter the elements by.\r\n *\r\n * @returns true if the collection contains any elements; otherwise false.\r\n */\r\n public any(predicate: PredicateFn): boolean;\r\n\r\n /**\r\n * Filters the list by the predicate and then returns a boolean that determines\r\n * if the filtered collection contains any elements.\r\n *\r\n * @param predicate The predicate to filter the elements by.\r\n *\r\n * @returns true if the collection contains any elements; otherwise false.\r\n */\r\n public any(predicate?: PredicateFn): boolean {\r\n let elements = this.elements;\r\n\r\n if (predicate !== undefined) {\r\n elements = elements.filter(predicate);\r\n }\r\n\r\n return elements.length > 0;\r\n }\r\n\r\n /**\r\n * Returns the first element from the collection if there are any elements.\r\n * Otherwise will throw an exception.\r\n *\r\n * @returns The first element in the collection.\r\n */\r\n public first(): T;\r\n\r\n /**\r\n * Filters the list by the predicate and then returns the first element\r\n * in the collection if any remain. Otherwise throws an exception.\r\n *\r\n * @param predicate The predicate to filter the elements by.\r\n *\r\n * @returns The first element in the collection.\r\n */\r\n public first(predicate: PredicateFn): T;\r\n\r\n /**\r\n * Filters the list by the predicate and then returns the first element\r\n * in the collection if any remain. Otherwise throws an exception.\r\n *\r\n * @param predicate The predicate to filter the elements by.\r\n *\r\n * @returns The first element in the collection.\r\n */\r\n public first(predicate?: PredicateFn): T {\r\n let elements = this.elements;\r\n\r\n if (predicate !== undefined) {\r\n elements = elements.filter(predicate);\r\n }\r\n\r\n if (elements.length >= 1) {\r\n return elements[0];\r\n }\r\n else {\r\n throw noElementsFound;\r\n }\r\n }\r\n\r\n /**\r\n * Returns the first element found in the collection or undefined if the\r\n * collection contains no elements.\r\n *\r\n * @returns The first element in the collection or undefined.\r\n */\r\n public firstOrUndefined(): T | undefined;\r\n\r\n /**\r\n * Filters the list by the predicate and then returns the first element\r\n * found in the collection. If no elements remain then undefined is\r\n * returned instead.\r\n *\r\n * @param predicate The predicate to filter the elements by.\r\n *\r\n * @returns The first element in the filtered collection or undefined.\r\n */\r\n public firstOrUndefined(predicate: PredicateFn): T | undefined;\r\n\r\n /**\r\n * Filters the list by the predicate and then returns the first element\r\n * found in the collection. If no elements remain then undefined is\r\n * returned instead.\r\n *\r\n * @param predicate The predicate to filter the elements by.\r\n *\r\n * @returns The first element in the filtered collection or undefined.\r\n */\r\n public firstOrUndefined(predicate?: PredicateFn): T | undefined {\r\n let elements = this.elements;\r\n\r\n if (predicate !== undefined) {\r\n elements = elements.filter(predicate);\r\n }\r\n\r\n if (elements.length === 1) {\r\n return elements[0];\r\n }\r\n else {\r\n return undefined;\r\n }\r\n }\r\n\r\n /**\r\n * Returns a single element from the collection if there is a single\r\n * element. Otherwise will throw an exception.\r\n *\r\n * @returns An element.\r\n */\r\n public single(): T;\r\n\r\n /**\r\n * Filters the list by the predicate and then returns the single remaining\r\n * element from the collection. If more than one element remains then an\r\n * exception will be thrown.\r\n *\r\n * @param predicate The predicate to filter the elements by.\r\n *\r\n * @returns An element.\r\n */\r\n public single(predicate: PredicateFn): T;\r\n\r\n /**\r\n * Filters the list by the predicate and then returns the single remaining\r\n * element from the collection. If more than one element remains then an\r\n * exception will be thrown.\r\n *\r\n * @param predicate The predicate to filter the elements by.\r\n *\r\n * @returns An element.\r\n */\r\n public single(predicate?: PredicateFn): T {\r\n let elements = this.elements;\r\n\r\n if (predicate !== undefined) {\r\n elements = elements.filter(predicate);\r\n }\r\n\r\n if (elements.length === 1) {\r\n return elements[0];\r\n }\r\n else {\r\n throw moreThanOneElement;\r\n }\r\n }\r\n\r\n /**\r\n * Returns a single element from the collection if there is a single\r\n * element. If no elements are found then undefined is returned. More\r\n * than a single element will throw an exception.\r\n *\r\n * @returns An element or undefined.\r\n */\r\n public singleOrUndefined(): T | undefined;\r\n\r\n /**\r\n * Filters the list by the predicate and then returns the single element\r\n * from the collection if there is only one remaining. If no elements\r\n * remain then undefined is returned. More than a single element will throw\r\n * an exception.\r\n *\r\n * @param predicate The predicate to filter the elements by.\r\n *\r\n * @returns An element or undefined.\r\n */\r\n public singleOrUndefined(predicate: PredicateFn): T | undefined;\r\n\r\n /**\r\n * Filters the list by the predicate and then returns the single element\r\n * from the collection if there is only one remaining. If no elements\r\n * remain then undefined is returned. More than a single element will throw\r\n * an exception.\r\n *\r\n * @param predicate The predicate to filter the elements by.\r\n *\r\n * @returns An element or undefined.\r\n */\r\n public singleOrUndefined(predicate?: PredicateFn): T | undefined {\r\n let elements = this.elements;\r\n\r\n if (predicate !== undefined) {\r\n elements = elements.filter(predicate);\r\n }\r\n\r\n if (elements.length === 0) {\r\n return undefined;\r\n }\r\n else if (elements.length === 1) {\r\n return elements[0];\r\n }\r\n else {\r\n throw moreThanOneElement;\r\n }\r\n }\r\n\r\n /**\r\n * Orders the elements of the array and returns a new list of items\r\n * in that order.\r\n * \r\n * @param keySelector The selector for the key to be ordered by.\r\n * @returns A new ordered list of elements.\r\n */\r\n public orderBy(keySelector: ValueSelector): OrderedList {\r\n const comparer = valueComparer(keySelector, false);\r\n\r\n return new OrderedList(this.elements, comparer);\r\n }\r\n\r\n /**\r\n * Orders the elements of the array in descending order and returns a\r\n * new list of items in that order.\r\n *\r\n * @param keySelector The selector for the key to be ordered by.\r\n * @returns A new ordered list of elements.\r\n */\r\n public orderByDescending(keySelector: ValueSelector): OrderedList {\r\n const comparer = valueComparer(keySelector, true);\r\n\r\n return new OrderedList(this.elements, comparer);\r\n }\r\n\r\n /**\r\n * Filters the results and returns a new list containing only the elements\r\n * that match the predicate.\r\n * \r\n * @param predicate The predicate to filter elements with.\r\n * \r\n * @returns A new collection of elements that match the predicate.\r\n */\r\n public where(predicate: PredicateFn): List {\r\n return new List(this.elements.filter(predicate));\r\n }\r\n\r\n /**\r\n * Get the elements of this list as a native array of items.\r\n *\r\n * @returns An array of items with all filters applied.\r\n */\r\n public toArray(): T[] {\r\n return [...this.elements];\r\n }\r\n}\r\n\r\n/**\r\n * A list of items that has ordering already applied.\r\n */\r\nclass OrderedList extends List {\r\n /** The base comparer to use when ordering. */\r\n private baseComparer!: ValueComparer;\r\n\r\n // #region Constructors\r\n\r\n constructor(elements: T[], baseComparer: ValueComparer) {\r\n super(elements);\r\n\r\n this.baseComparer = baseComparer;\r\n this.elements.sort(this.baseComparer);\r\n }\r\n\r\n // #endregion\r\n\r\n /**\r\n * Orders the elements of the array and returns a new list of items\r\n * in that order.\r\n * \r\n * @param keySelector The selector for the key to be ordered by.\r\n * @returns A new ordered list of elements.\r\n */\r\n public thenBy(keySelector: ValueSelector): OrderedList {\r\n const comparer = valueComparer(keySelector, false);\r\n\r\n return new OrderedList(this.elements, (a: T, b: T) => this.baseComparer(a, b) || comparer(a, b));\r\n }\r\n\r\n /**\r\n * Orders the elements of the array in descending order and returns a\r\n * new list of items in that order.\r\n *\r\n * @param keySelector The selector for the key to be ordered by.\r\n * @returns A new ordered list of elements.\r\n */\r\n public thenByDescending(keySelector: ValueSelector): OrderedList {\r\n const comparer = valueComparer(keySelector, true);\r\n\r\n return new OrderedList(this.elements, (a: T, b: T) => this.baseComparer(a, b) || comparer(a, b));\r\n }\r\n}\r\n","// \r\n// Copyright by the Spark Development Network\r\n//\r\n// Licensed under the Rock Community License (the \"License\");\r\n// you may not use this file except in compliance with the License.\r\n// You may obtain a copy of the License at\r\n//\r\n// http://www.rockrms.com/license\r\n//\r\n// Unless required by applicable law or agreed to in writing, software\r\n// distributed under the License is distributed on an \"AS IS\" BASIS,\r\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n// See the License for the specific language governing permissions and\r\n// limitations under the License.\r\n// \r\n//\r\n\r\nimport { Guid } from \"@Obsidian/Types\";\r\n\r\n/** An empty unique identifier. */\r\nexport const emptyGuid = \"00000000-0000-0000-0000-000000000000\";\r\n\r\n/**\r\n* Generates a new Guid\r\n*/\r\nexport function newGuid (): Guid {\r\n return \"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx\".replace(/[xy]/g, (c) => {\r\n const r = Math.random() * 16 | 0;\r\n const v = c === \"x\" ? r : r & 0x3 | 0x8;\r\n return v.toString(16);\r\n });\r\n}\r\n\r\n/**\r\n * Returns a normalized Guid that can be compared with string equality (===)\r\n * @param a\r\n */\r\nexport function normalize (a: Guid | null | undefined): Guid | null {\r\n if (!a) {\r\n return null;\r\n }\r\n\r\n return a.toLowerCase();\r\n}\r\n\r\n/**\r\n * Checks if the given string is a valid Guid. To be considered valid it must\r\n * be a bare guid with hyphens. Bare means not enclosed in '{' and '}'.\r\n * \r\n * @param guid The Guid to be checked.\r\n * @returns True if the guid is valid, otherwise false.\r\n */\r\nexport function isValidGuid(guid: Guid | string): boolean {\r\n return /^[0-9A-Fa-f]{8}-(?:[0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$/.test(guid);\r\n}\r\n\r\n/**\r\n * Converts the string value to a Guid.\r\n * \r\n * @param value The value to be converted.\r\n * @returns A Guid value or null is the string could not be parsed as a Guid.\r\n */\r\nexport function toGuidOrNull(value: string | null | undefined): Guid | null {\r\n if (value === null || value === undefined) {\r\n return null;\r\n }\r\n\r\n if (!isValidGuid(value)) {\r\n return null;\r\n }\r\n\r\n return value as Guid;\r\n}\r\n\r\n/**\r\n * Are the guids equal?\r\n * @param a\r\n * @param b\r\n */\r\nexport function areEqual (a: Guid | null | undefined, b: Guid | null | undefined): boolean {\r\n return normalize(a) === normalize(b);\r\n}\r\n\r\nexport default {\r\n newGuid,\r\n normalize,\r\n areEqual\r\n};\r\n\r\n","// \r\n// Copyright by the Spark Development Network\r\n//\r\n// Licensed under the Rock Community License (the \"License\");\r\n// you may not use this file except in compliance with the License.\r\n// You may obtain a copy of the License at\r\n//\r\n// http://www.rockrms.com/license\r\n//\r\n// Unless required by applicable law or agreed to in writing, software\r\n// distributed under the License is distributed on an \"AS IS\" BASIS,\r\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n// See the License for the specific language governing permissions and\r\n// limitations under the License.\r\n// \r\n//\r\n\r\nimport { areEqual, toGuidOrNull } from \"./guid\";\r\nimport { Pluralize } from \"@Obsidian/Libs/pluralize\";\r\n\r\n/**\r\n * Is the value an empty string?\r\n * @param val\r\n */\r\nexport function isEmpty(val: unknown): boolean {\r\n if (typeof val === \"string\") {\r\n return val.length === 0;\r\n }\r\n\r\n return false;\r\n}\r\n\r\n/**\r\n * Is the value an empty string?\r\n * @param val\r\n */\r\nexport function isWhiteSpace(val: unknown): boolean {\r\n if (typeof val === \"string\") {\r\n return val.trim().length === 0;\r\n }\r\n\r\n return false;\r\n}\r\n\r\n/**\r\n * Is the value null, undefined or whitespace?\r\n * @param val\r\n */\r\nexport function isNullOrWhiteSpace(val: unknown): boolean {\r\n return isWhiteSpace(val) || val === undefined || val === null;\r\n}\r\n\r\n/**\r\n * Turns camelCase or PascalCase strings into separate strings - \"MyCamelCaseString\" turns into \"My Camel Case String\"\r\n * @param val\r\n */\r\nexport function splitCase(val: string): string {\r\n // First, insert a space before sequences of capital letters followed by a lowercase letter (e.g., \"RESTKey\" -> \"REST Key\")\r\n val = val.replace(/([A-Z]+)([A-Z][a-z])/g, \"$1 $2\");\r\n // Then, insert a space before sequences of a lowercase letter or number followed by a capital letter (e.g., \"myKey\" -> \"my Key\")\r\n return val.replace(/([a-z0-9])([A-Z])/g, \"$1 $2\");\r\n}\r\n\r\n/**\r\n * Returns a string that has each item comma separated except for the last\r\n * which will use the word \"and\".\r\n *\r\n * @example\r\n * ['a', 'b', 'c'] => 'a, b and c'\r\n *\r\n * @param strs The strings to be joined.\r\n * @param andStr The custom string to use instead of the word \"and\".\r\n *\r\n * @returns A string that represents all the strings.\r\n */\r\nexport function asCommaAnd(strs: string[], andStr?: string): string {\r\n if (strs.length === 0) {\r\n return \"\";\r\n }\r\n\r\n if (strs.length === 1) {\r\n return strs[0];\r\n }\r\n\r\n if (!andStr) {\r\n andStr = \"and\";\r\n }\r\n\r\n if (strs.length === 2) {\r\n return `${strs[0]} ${andStr} ${strs[1]}`;\r\n }\r\n\r\n const last = strs.pop();\r\n return `${strs.join(\", \")} ${andStr} ${last}`;\r\n}\r\n\r\n/**\r\n * Convert the string to the title case.\r\n * hellO worlD => Hello World\r\n * @param str\r\n */\r\nexport function toTitleCase(str: string | null): string {\r\n if (!str) {\r\n return \"\";\r\n }\r\n\r\n return str.replace(/\\w\\S*/g, (word) => {\r\n return word.charAt(0).toUpperCase() + word.substring(1).toLowerCase();\r\n });\r\n}\r\n\r\n/**\r\n * Capitalize the first character\r\n */\r\nexport function upperCaseFirstCharacter(str: string | null): string {\r\n if (!str) {\r\n return \"\";\r\n }\r\n\r\n return str.charAt(0).toUpperCase() + str.substring(1);\r\n}\r\n\r\n/**\r\n * Pluralizes the given word. If count is specified and is equal to 1 then\r\n * the singular form of the word is returned. This will also de-pluralize a\r\n * word if required.\r\n *\r\n * @param word The word to be pluralized or singularized.\r\n * @param count An optional count to indicate when the word should be singularized.\r\n *\r\n * @returns The word in plural or singular form depending on the options.\r\n */\r\nexport function pluralize(word: string, count?: number): string {\r\n return Pluralize(word, count);\r\n}\r\n\r\n/**\r\n * Returns a singular or plural phrase depending on if the number is 1.\r\n * (0, Cat, Cats) => Cats\r\n * (1, Cat, Cats) => Cat\r\n * (2, Cat, Cats) => Cats\r\n * @param num\r\n * @param singular\r\n * @param plural\r\n */\r\nexport function pluralConditional(num: number, singular: string, plural: string): string {\r\n return num === 1 ? singular : plural;\r\n}\r\n\r\n/**\r\n * Pad the left side of a string so it is at least length characters long.\r\n *\r\n * @param str The string to be padded.\r\n * @param length The minimum length to make the string.\r\n * @param padCharacter The character to use to pad the string.\r\n */\r\nexport function padLeft(str: string | undefined | null, length: number, padCharacter: string = \" \"): string {\r\n if (padCharacter == \"\") {\r\n padCharacter = \" \";\r\n }\r\n else if (padCharacter.length > 1) {\r\n padCharacter = padCharacter.substring(0, 1);\r\n }\r\n\r\n if (!str) {\r\n return Array(length + 1).join(padCharacter);\r\n }\r\n\r\n if (str.length >= length) {\r\n return str;\r\n }\r\n\r\n return Array(length - str.length + 1).join(padCharacter) + str;\r\n}\r\n\r\n/**\r\n * Pad the right side of a string so it is at least length characters long.\r\n *\r\n * @param str The string to be padded.\r\n * @param length The minimum length to make the string.\r\n * @param padCharacter The character to use to pad the string.\r\n */\r\nexport function padRight(str: string | undefined | null, length: number, padCharacter: string = \" \"): string {\r\n if (padCharacter == \"\") {\r\n padCharacter = \" \";\r\n }\r\n else if (padCharacter.length > 1) {\r\n padCharacter = padCharacter.substring(0, 1);\r\n }\r\n\r\n if (!str) {\r\n return Array(length).join(padCharacter);\r\n }\r\n\r\n if (str.length >= length) {\r\n return str;\r\n }\r\n\r\n return str + Array(length - str.length + 1).join(padCharacter);\r\n}\r\n\r\nexport type TruncateOptions = {\r\n ellipsis?: boolean;\r\n};\r\n\r\n/**\r\n * Ensure a string does not go over the character limit. Truncation happens\r\n * on word boundaries.\r\n *\r\n * @param str The string to be truncated.\r\n * @param limit The maximum length of the resulting string.\r\n * @param options Additional options that control how truncation will happen.\r\n *\r\n * @returns The truncated string.\r\n */\r\nexport function truncate(str: string, limit: number, options?: TruncateOptions): string {\r\n // Early out if the string is already under the limit.\r\n if (str.length <= limit) {\r\n return str;\r\n }\r\n\r\n // All the whitespace characters that we can split on.\r\n const trimmable = \"\\u0009\\u000A\\u000B\\u000C\\u000D\\u0020\\u00A0\\u1680\\u180E\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200A\\u202F\\u205F\\u2028\\u2029\\u3000\\uFEFF\";\r\n const reg = new RegExp(`(?=[${trimmable}])`);\r\n const words = str.split(reg);\r\n let count = 0;\r\n\r\n // If we are appending ellipsis, then shorten the limit size.\r\n if (options && options.ellipsis === true) {\r\n limit -= 3;\r\n }\r\n\r\n // Get a list of words that will fit within our length requirements.\r\n const visibleWords = words.filter(function (word) {\r\n count += word.length;\r\n return count <= limit;\r\n });\r\n\r\n return `${visibleWords.join(\"\")}...`;\r\n}\r\n\r\n/** The regular expression that contains the characters to be escaped. */\r\nconst escapeHtmlRegExp = /[\"'&<>]/g;\r\n\r\n/** The character map of the characters to be replaced and the strings to replace them with. */\r\nconst escapeHtmlMap: Record = {\r\n '\"': \""\",\r\n \"&\": \"&\",\r\n \"'\": \"'\",\r\n \"<\": \"<\",\r\n \">\": \">\"\r\n};\r\n\r\n/**\r\n * Escapes a string so it can be used in HTML. This turns things like the <\r\n * character into the < sequence so it will still render as \"<\".\r\n *\r\n * @param str The string to be escaped.\r\n * @returns A string that has all HTML entities escaped.\r\n */\r\nexport function escapeHtml(str: string): string {\r\n return str.replace(escapeHtmlRegExp, (ch) => {\r\n return escapeHtmlMap[ch];\r\n });\r\n}\r\n\r\n/**\r\n * The default compare value function for UI controls. This checks if both values\r\n * are GUIDs and if so does a case-insensitive compare, otherwise it does a\r\n * case-sensitive compare of the two values.\r\n *\r\n * @param value The value selected in the UI.\r\n * @param itemValue The item value to be compared against.\r\n *\r\n * @returns true if the two values are considered equal; otherwise false.\r\n */\r\nexport function defaultControlCompareValue(value: string, itemValue: string): boolean {\r\n const guidValue = toGuidOrNull(value);\r\n const guidItemValue = toGuidOrNull(itemValue);\r\n\r\n if (guidValue !== null && guidItemValue !== null) {\r\n return areEqual(guidValue, guidItemValue);\r\n }\r\n\r\n return value === itemValue;\r\n}\r\n\r\n/**\r\n * Determins whether or not a given string contains any HTML tags in.\r\n *\r\n * @param value The string potentially containing HTML\r\n *\r\n * @returns true if it contains HTML, otherwise false\r\n */\r\nexport function containsHtmlTag(value: string): boolean {\r\n return /<[/0-9a-zA-Z]/.test(value);\r\n}\r\n\r\nexport default {\r\n asCommaAnd,\r\n containsHtmlTag,\r\n escapeHtml,\r\n splitCase,\r\n isNullOrWhiteSpace,\r\n isWhiteSpace,\r\n isEmpty,\r\n toTitleCase,\r\n pluralConditional,\r\n padLeft,\r\n padRight,\r\n truncate\r\n};\r\n","import { List } from \"./linq\";\r\nimport { padLeft, padRight } from \"./stringUtils\";\r\nimport { RockDateTime } from \"./rockDateTime\";\r\n\r\n/**\r\n * Returns a blank string if the string value is 0.\r\n *\r\n * @param value The value to check and return.\r\n * @returns The value passed in or an empty string if it equates to zero.\r\n */\r\nfunction blankIfZero(value: string): string {\r\n return parseInt(value) === 0 ? \"\" : value;\r\n}\r\n\r\n/**\r\n * Gets the 12 hour value of the given 24-hour number.\r\n *\r\n * @param hour The hour in a 24-hour format.\r\n * @returns The hour in a 12-hour format.\r\n */\r\nfunction get12HourValue(hour: number): number {\r\n if (hour == 0) {\r\n return 12;\r\n }\r\n else if (hour < 13) {\r\n return hour;\r\n }\r\n else {\r\n return hour - 12;\r\n }\r\n}\r\ntype DateFormatterCommand = (date: RockDateTime) => string;\r\n\r\nconst englishDayNames = [\"Sunday\", \"Monday\", \"Tuesday\", \"Wednesday\", \"Thursday\", \"Friday\", \"Saturday\"];\r\nconst englishMonthNames = [\"January\", \"February\", \"March\", \"April\", \"May\", \"June\", \"July\", \"August\", \"September\", \"October\", \"November\", \"December\"];\r\n\r\nconst dateFormatters: Record = {\r\n \"yyyyy\": date => padLeft(date.year.toString(), 5, \"0\"),\r\n \"yyyy\": date => padLeft(date.year.toString(), 4, \"0\"),\r\n \"yyy\": date => padLeft(date.year.toString(), 3, \"0\"),\r\n \"yy\": date => padLeft((date.year % 100).toString(), 2, \"0\"),\r\n \"y\": date => (date.year % 100).toString(),\r\n\r\n \"MMMM\": date => englishMonthNames[date.month - 1],\r\n \"MMM\": date => englishMonthNames[date.month - 1].substr(0, 3),\r\n \"MM\": date => padLeft(date.month.toString(), 2, \"0\"),\r\n \"M\": date => date.month.toString(),\r\n\r\n \"dddd\": date => englishDayNames[date.dayOfWeek],\r\n \"ddd\": date => englishDayNames[date.dayOfWeek].substr(0, 3),\r\n \"dd\": date => padLeft(date.day.toString(), 2, \"0\"),\r\n \"d\": date => date.day.toString(),\r\n\r\n \"fffffff\": date => padRight((date.millisecond * 10000).toString(), 7, \"0\"),\r\n \"ffffff\": date => padRight((date.millisecond * 1000).toString(), 6, \"0\"),\r\n \"fffff\": date => padRight((date.millisecond * 100).toString(), 5, \"0\"),\r\n \"ffff\": date => padRight((date.millisecond * 10).toString(), 4, \"0\"),\r\n \"fff\": date => padRight(date.millisecond.toString(), 3, \"0\"),\r\n \"ff\": date => padRight(Math.floor(date.millisecond / 10).toString(), 2, \"0\"),\r\n \"f\": date => padRight(Math.floor(date.millisecond / 100).toString(), 1, \"0\"),\r\n\r\n \"FFFFFFF\": date => blankIfZero(padRight((date.millisecond * 10000).toString(), 7, \"0\")),\r\n \"FFFFFF\": date => blankIfZero(padRight((date.millisecond * 1000).toString(), 6, \"0\")),\r\n \"FFFFF\": date => blankIfZero(padRight((date.millisecond * 100).toString(), 5, \"0\")),\r\n \"FFFF\": date => blankIfZero(padRight((date.millisecond * 10).toString(), 4, \"0\")),\r\n \"FFF\": date => blankIfZero(padRight(date.millisecond.toString(), 3, \"0\")),\r\n \"FF\": date => blankIfZero(padRight(Math.floor(date.millisecond / 10).toString(), 2, \"0\")),\r\n \"F\": date => blankIfZero(padRight(Math.floor(date.millisecond / 100).toString(), 1, \"0\")),\r\n\r\n \"g\": date => date.year < 0 ? \"B.C.\" : \"A.D.\",\r\n \"gg\": date => date.year < 0 ? \"B.C.\" : \"A.D.\",\r\n\r\n \"hh\": date => padLeft(get12HourValue(date.hour).toString(), 2, \"0\"),\r\n \"h\": date => get12HourValue(date.hour).toString(),\r\n\r\n \"HH\": date => padLeft(date.hour.toString(), 2, \"0\"),\r\n \"H\": date => date.hour.toString(),\r\n\r\n \"mm\": date => padLeft(date.minute.toString(), 2, \"0\"),\r\n \"m\": date => date.minute.toString(),\r\n\r\n \"ss\": date => padLeft(date.second.toString(), 2, \"0\"),\r\n \"s\": date => date.second.toString(),\r\n\r\n \"K\": date => {\r\n const offset = date.offset;\r\n const offsetHour = Math.abs(Math.floor(offset / 60));\r\n const offsetMinute = Math.abs(offset % 60);\r\n return `${offset >= 0 ? \"+\" : \"-\"}${padLeft(offsetHour.toString(), 2, \"0\")}:${padLeft(offsetMinute.toString(), 2, \"0\")}`;\r\n },\r\n\r\n \"tt\": date => date.hour >= 12 ? \"PM\" : \"AM\",\r\n \"t\": date => date.hour >= 12 ? \"P\" : \"A\",\r\n\r\n \"zzz\": date => {\r\n const offset = date.offset;\r\n const offsetHour = Math.abs(Math.floor(offset / 60));\r\n const offsetMinute = Math.abs(offset % 60);\r\n return `${offset >= 0 ? \"+\" : \"-\"}${padLeft(offsetHour.toString(), 2, \"0\")}:${padLeft(offsetMinute.toString(), 2, \"0\")}`;\r\n },\r\n \"zz\": date => {\r\n const offset = date.offset;\r\n const offsetHour = Math.abs(Math.floor(offset / 60));\r\n return `${offset >= 0 ? \"+\" : \"-\"}${padLeft(offsetHour.toString(), 2, \"0\")}`;\r\n },\r\n \"z\": date => {\r\n const offset = date.offset;\r\n const offsetHour = Math.abs(Math.floor(offset / 60));\r\n return `${offset >= 0 ? \"+\" : \"-\"}${offsetHour}`;\r\n },\r\n\r\n \":\": () => \":\",\r\n \"/\": () => \"/\"\r\n};\r\n\r\nconst dateFormatterKeys = new List(Object.keys(dateFormatters))\r\n .orderByDescending(k => k.length)\r\n .toArray();\r\n\r\nconst standardDateFormats: Record = {\r\n \"d\": date => formatAspDate(date, getLocalDateFormatString()),\r\n \"D\": date => formatAspDate(date, \"dddd, MMMM dd, yyyy\"),\r\n \"t\": date => formatAspDate(date, \"h:mm tt\"),\r\n \"T\": date => formatAspDate(date, \"h:mm:ss tt\"),\r\n \"M\": date => formatAspDate(date, \"MMMM dd\"),\r\n \"m\": date => formatAspDate(date, \"MMMM dd\"),\r\n \"Y\": date => formatAspDate(date, \"yyyy MMMM\"),\r\n \"y\": date => formatAspDate(date, \"yyyy MMMM\"),\r\n \"f\": date => `${formatAspDate(date, \"D\")} ${formatAspDate(date, \"t\")}`,\r\n \"F\": date => `${formatAspDate(date, \"D\")} ${formatAspDate(date, \"T\")}`,\r\n \"g\": date => `${formatAspDate(date, \"d\")} ${formatAspDate(date, \"t\")}`,\r\n \"G\": date => `${formatAspDate(date, \"d\")} ${formatAspDate(date, \"T\")}`,\r\n \"o\": date => formatAspDate(date, `yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffffffzzz`),\r\n \"O\": date => formatAspDate(date, `yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffffffzzz`),\r\n \"r\": date => formatAspDate(date, `ddd, dd MMM yyyy HH':'mm':'ss 'GMT'`),\r\n \"R\": date => formatAspDate(date, `ddd, dd MMM yyyy HH':'mm':'ss 'GMT'`),\r\n \"s\": date => formatAspDate(date, `yyyy'-'MM'-'dd'T'HH':'mm':'ss`),\r\n \"u\": date => formatAspDate(date, `yyyy'-'MM'-'dd HH':'mm':'ss'Z'`),\r\n \"U\": date => {\r\n return formatAspDate(date.universalDateTime, `F`);\r\n },\r\n};\r\n\r\n/**\r\n * Formats the Date object using custom format specifiers.\r\n *\r\n * @param date The date object to be formatted.\r\n * @param format The custom format string.\r\n * @returns A string that represents the date in the specified format.\r\n */\r\nfunction formatAspCustomDate(date: RockDateTime, format: string): string {\r\n let result = \"\";\r\n\r\n for (let i = 0; i < format.length;) {\r\n let matchFound = false;\r\n\r\n for (const k of dateFormatterKeys) {\r\n if (format.substr(i, k.length) === k) {\r\n result += dateFormatters[k](date);\r\n matchFound = true;\r\n i += k.length;\r\n break;\r\n }\r\n }\r\n\r\n if (matchFound) {\r\n continue;\r\n }\r\n\r\n if (format[i] === \"\\\\\") {\r\n i++;\r\n if (i < format.length) {\r\n result += format[i++];\r\n }\r\n }\r\n else if (format[i] === \"'\") {\r\n i++;\r\n for (; i < format.length && format[i] !== \"'\"; i++) {\r\n result += format[i];\r\n }\r\n i++;\r\n }\r\n else if (format[i] === '\"') {\r\n i++;\r\n for (; i < format.length && format[i] !== '\"'; i++) {\r\n result += format[i];\r\n }\r\n i++;\r\n }\r\n else {\r\n result += format[i++];\r\n }\r\n }\r\n\r\n return result;\r\n}\r\n\r\n/**\r\n * Formats the Date object using a standard format string.\r\n *\r\n * @param date The date object to be formatted.\r\n * @param format The standard format specifier.\r\n * @returns A string that represents the date in the specified format.\r\n */\r\nfunction formatAspStandardDate(date: RockDateTime, format: string): string {\r\n if (standardDateFormats[format] !== undefined) {\r\n return standardDateFormats[format](date);\r\n }\r\n\r\n return format;\r\n}\r\n\r\n/**\r\n * Formats the given Date object using nearly the same rules as the ASP C#\r\n * format methods.\r\n *\r\n * @param date The date object to be formatted.\r\n * @param format The format string to use.\r\n */\r\nexport function formatAspDate(date: RockDateTime, format: string): string {\r\n if (format.length === 1) {\r\n return formatAspStandardDate(date, format);\r\n }\r\n else if (format.length === 2 && format[0] === \"%\") {\r\n return formatAspCustomDate(date, format[1]);\r\n }\r\n else {\r\n return formatAspCustomDate(date, format);\r\n }\r\n}\r\n\r\n /**\r\n * Gets a format string that matches the current browser locale settings.\r\n *\r\n * @returns A string that represents the date format of the client browser.\r\n */\r\nfunction getLocalDateFormatString(): string {\r\n\r\n // Create an arbitrary date with recognizable numeric parts, format the date using the current locale settings\r\n // then replace the numeric parts with date format placeholders to get the local date format string.\r\n // Note that the month is specified as an index in the Date constructor, so \"9\" represents month \"10\".\r\n const refDate = new Date(2000,9,20);\r\n\r\n return refDate.toLocaleDateString(undefined, { year:\"numeric\", month:\"2-digit\", day:\"2-digit\" })\r\n .replace(\"20\",\"d\")\r\n .replace(\"10\",\"M\")\r\n .replace(\"2000\",\"yyyy\");\r\n}\r\n","import { DateTime, FixedOffsetZone, Zone } from \"luxon\";\r\nimport { formatAspDate } from \"./aspDateFormat\";\r\nimport { DayOfWeek } from \"@Obsidian/Enums/Controls/dayOfWeek\";\r\n\r\n/**\r\n * The days of the week that are used by RockDateTime.\r\n */\r\nexport { DayOfWeek } from \"@Obsidian/Enums/Controls/dayOfWeek\";\r\n\r\n/**\r\n * The various date and time formats supported by the formatting methods.\r\n */\r\nexport const DateTimeFormat: Record = {\r\n DateFull: {\r\n year: \"numeric\",\r\n month: \"long\",\r\n day: \"numeric\"\r\n },\r\n\r\n DateMedium: {\r\n year: \"numeric\",\r\n month: \"short\",\r\n day: \"numeric\"\r\n },\r\n\r\n DateShort: {\r\n year: \"numeric\",\r\n month: \"numeric\",\r\n day: \"numeric\"\r\n },\r\n\r\n TimeShort: {\r\n hour: \"numeric\",\r\n minute: \"numeric\",\r\n },\r\n\r\n TimeWithSeconds: {\r\n hour: \"numeric\",\r\n minute: \"numeric\",\r\n second: \"numeric\"\r\n },\r\n\r\n DateTimeShort: {\r\n year: \"numeric\",\r\n month: \"numeric\",\r\n day: \"numeric\",\r\n hour: \"numeric\",\r\n minute: \"numeric\"\r\n },\r\n\r\n DateTimeShortWithSeconds: {\r\n year: \"numeric\",\r\n month: \"numeric\",\r\n day: \"numeric\",\r\n hour: \"numeric\",\r\n minute: \"numeric\",\r\n second: \"numeric\"\r\n },\r\n\r\n DateTimeMedium: {\r\n year: \"numeric\",\r\n month: \"short\",\r\n day: \"numeric\",\r\n hour: \"numeric\",\r\n minute: \"numeric\"\r\n },\r\n\r\n DateTimeMediumWithSeconds: {\r\n year: \"numeric\",\r\n month: \"short\",\r\n day: \"numeric\",\r\n hour: \"numeric\",\r\n minute: \"numeric\",\r\n second: \"numeric\"\r\n },\r\n\r\n DateTimeFull: {\r\n year: \"numeric\",\r\n month: \"long\",\r\n day: \"numeric\",\r\n hour: \"numeric\",\r\n minute: \"numeric\"\r\n },\r\n\r\n DateTimeFullWithSeconds: {\r\n year: \"numeric\",\r\n month: \"long\",\r\n day: \"numeric\",\r\n hour: \"numeric\",\r\n minute: \"numeric\",\r\n second: \"numeric\"\r\n }\r\n};\r\n\r\n/**\r\n * A date and time object that handles time zones and formatting. This class is\r\n * immutable and cannot be modified. All modifications are performed by returning\r\n * a new RockDateTime instance.\r\n */\r\nexport class RockDateTime {\r\n /** The internal DateTime object that holds our date information. */\r\n private dateTime: DateTime;\r\n\r\n // #region Constructors\r\n\r\n /**\r\n * Creates a new instance of RockDateTime.\r\n *\r\n * @param dateTime The Luxon DateTime object that is used to track the internal state.\r\n */\r\n private constructor(dateTime: DateTime) {\r\n this.dateTime = dateTime;\r\n }\r\n\r\n /**\r\n * Creates a new instance of RockDateTime from the given date and time parts.\r\n *\r\n * @param year The year of the new date.\r\n * @param month The month of the new date (1-12).\r\n * @param day The day of month of the new date.\r\n * @param hour The hour of the day.\r\n * @param minute The minute of the hour.\r\n * @param second The second of the minute.\r\n * @param millisecond The millisecond of the second.\r\n * @param zone The time zone offset to construct the date in.\r\n *\r\n * @returns A RockDateTime instance or null if the requested date was not valid.\r\n */\r\n public static fromParts(year: number, month: number, day: number, hour?: number, minute?: number, second?: number, millisecond?: number, zone?: number | string): RockDateTime | null {\r\n let luxonZone: Zone | string | undefined;\r\n\r\n if (zone !== undefined) {\r\n if (typeof zone === \"number\") {\r\n luxonZone = FixedOffsetZone.instance(zone);\r\n }\r\n else {\r\n luxonZone = zone;\r\n }\r\n }\r\n\r\n const dateTime = DateTime.fromObject({\r\n year,\r\n month,\r\n day,\r\n hour,\r\n minute,\r\n second,\r\n millisecond\r\n }, {\r\n zone: luxonZone\r\n });\r\n\r\n if (!dateTime.isValid) {\r\n return null;\r\n }\r\n\r\n return new RockDateTime(dateTime);\r\n }\r\n\r\n /**\r\n * Creates a new instance of RockDateTime that represents the time specified\r\n * as the Javascript milliseconds value. The time zone is set to the browser\r\n * time zone.\r\n *\r\n * @param milliseconds The time in milliseconds since the epoch.\r\n *\r\n * @returns A new RockDateTime instance or null if the specified date was not valid.\r\n */\r\n public static fromMilliseconds(milliseconds: number): RockDateTime | null {\r\n const dateTime = DateTime.fromMillis(milliseconds);\r\n\r\n if (!dateTime.isValid) {\r\n return null;\r\n }\r\n\r\n return new RockDateTime(dateTime);\r\n }\r\n\r\n /**\r\n * Construct a new RockDateTime instance from a Javascript Date object.\r\n *\r\n * @param date The Javascript date object that contains the date information.\r\n *\r\n * @returns A RockDateTime instance or null if the date was not valid.\r\n */\r\n public static fromJSDate(date: Date): RockDateTime | null {\r\n const dateTime = DateTime.fromJSDate(date);\r\n\r\n if (!dateTime.isValid) {\r\n return null;\r\n }\r\n\r\n return new RockDateTime(dateTime);\r\n }\r\n\r\n /**\r\n * Constructs a new RockDateTime instance by parsing the given string from\r\n * ISO 8601 format.\r\n *\r\n * @param dateString The string that contains the ISO 8601 formatted text.\r\n *\r\n * @returns A new RockDateTime instance or null if the date was not valid.\r\n */\r\n public static parseISO(dateString: string): RockDateTime | null {\r\n const dateTime = DateTime.fromISO(dateString, { setZone: true });\r\n\r\n if (!dateTime.isValid) {\r\n return null;\r\n }\r\n\r\n return new RockDateTime(dateTime);\r\n }\r\n\r\n /**\r\n * Constructs a new RockDateTime instance by parsing the given string from\r\n * RFC 1123 format. This is common in HTTP headers.\r\n *\r\n * @param dateString The string that contains the RFC 1123 formatted text.\r\n *\r\n * @returns A new RockDateTime instance or null if the date was not valid.\r\n */\r\n public static parseHTTP(dateString: string): RockDateTime | null {\r\n const dateTime = DateTime.fromHTTP(dateString, { setZone: true });\r\n\r\n if (!dateTime.isValid) {\r\n return null;\r\n }\r\n\r\n return new RockDateTime(dateTime);\r\n }\r\n\r\n /**\r\n * Creates a new RockDateTime instance that represents the current date and time.\r\n *\r\n * @returns A RockDateTime instance.\r\n */\r\n public static now(): RockDateTime {\r\n return new RockDateTime(DateTime.now());\r\n }\r\n\r\n /**\r\n * Creates a new RockDateTime instance that represents the current time in UTC.\r\n *\r\n * @returns A new RockDateTime instance in the UTC time zone.\r\n */\r\n public static utcNow(): RockDateTime {\r\n return new RockDateTime(DateTime.now().toUTC());\r\n }\r\n\r\n // #endregion\r\n\r\n // #region Properties\r\n\r\n /**\r\n * The Date portion of this RockDateTime instance. All time properties of\r\n * the returned instance will be set to 0.\r\n */\r\n public get date(): RockDateTime {\r\n const date = RockDateTime.fromParts(this.year, this.month, this.day, 0, 0, 0, 0, this.offset);\r\n\r\n if (date === null) {\r\n throw \"Could not convert to date instance.\";\r\n }\r\n\r\n return date;\r\n }\r\n\r\n /**\r\n * The day of the month represented by this instance.\r\n */\r\n public get day(): number {\r\n return this.dateTime.day;\r\n }\r\n\r\n /**\r\n * The day of the week represented by this instance.\r\n */\r\n public get dayOfWeek(): DayOfWeek {\r\n switch (this.dateTime.weekday) {\r\n case 1:\r\n return DayOfWeek.Monday;\r\n\r\n case 2:\r\n return DayOfWeek.Tuesday;\r\n\r\n case 3:\r\n return DayOfWeek.Wednesday;\r\n\r\n case 4:\r\n return DayOfWeek.Thursday;\r\n\r\n case 5:\r\n return DayOfWeek.Friday;\r\n\r\n case 6:\r\n return DayOfWeek.Saturday;\r\n\r\n case 7:\r\n return DayOfWeek.Sunday;\r\n }\r\n\r\n throw \"Could not determine day of week.\";\r\n }\r\n\r\n /**\r\n * The day of the year represented by this instance.\r\n */\r\n public get dayOfYear(): number {\r\n return this.dateTime.ordinal;\r\n }\r\n\r\n /**\r\n * The hour of the day represented by this instance.\r\n */\r\n public get hour(): number {\r\n return this.dateTime.hour;\r\n }\r\n\r\n /**\r\n * The millisecond of the second represented by this instance.\r\n */\r\n public get millisecond(): number {\r\n return this.dateTime.millisecond;\r\n }\r\n\r\n /**\r\n * The minute of the hour represented by this instance.\r\n */\r\n public get minute(): number {\r\n return this.dateTime.minute;\r\n }\r\n\r\n /**\r\n * The month of the year represented by this instance (1-12).\r\n */\r\n public get month(): number {\r\n return this.dateTime.month;\r\n }\r\n\r\n /**\r\n * The offset from UTC represented by this instance. If the timezone of this\r\n * instance is UTC-7 then the value returned is -420.\r\n */\r\n public get offset(): number {\r\n return this.dateTime.offset;\r\n }\r\n\r\n /**\r\n * The second of the minute represented by this instance.\r\n */\r\n public get second(): number {\r\n return this.dateTime.second;\r\n }\r\n\r\n /**\r\n * The year represented by this instance.\r\n */\r\n public get year(): number {\r\n return this.dateTime.year;\r\n }\r\n\r\n /**\r\n * Creates a new RockDateTime instance that represents the same point in\r\n * time represented in the local browser time zone.\r\n */\r\n public get localDateTime(): RockDateTime {\r\n return new RockDateTime(this.dateTime.toLocal());\r\n }\r\n\r\n /**\r\n * Creates a new RockDateTime instance that represents the same point in\r\n * time represented in the organization time zone.\r\n */\r\n public get organizationDateTime(): RockDateTime {\r\n throw \"Not Implemented\";\r\n }\r\n\r\n /**\r\n * Creates a new RockDateTime instance that represents the same point in\r\n * time represented in UTC.\r\n */\r\n public get universalDateTime(): RockDateTime {\r\n return new RockDateTime(this.dateTime.toUTC());\r\n }\r\n\r\n // #endregion\r\n\r\n // #region Methods\r\n\r\n /**\r\n * Creates a new RockDateTime instance that represents the date and time\r\n * after adding the number of days to this instance.\r\n *\r\n * @param days The number of days to add.\r\n *\r\n * @returns A new instance of RockDateTime that represents the new date and time.\r\n */\r\n public addDays(days: number): RockDateTime {\r\n const dateTime = this.dateTime.plus({ days: days });\r\n\r\n if (!dateTime.isValid) {\r\n throw \"Operation produced an invalid date.\";\r\n }\r\n\r\n return new RockDateTime(dateTime);\r\n }\r\n\r\n /**\r\n * Creates a new RockDateTime instance that represents the last millisecond\r\n * of the end of the month for this instance.\r\n *\r\n * @example\r\n * RockDateTime.fromJSDate(new Date(2014, 3, 3)).endOfMonth().toISOString(); //=> '2014-03-31T23:59:59.999-05:00'\r\n */\r\n public endOfMonth(): RockDateTime {\r\n const dateTime = this.dateTime.endOf(\"month\");\r\n\r\n if (!dateTime.isValid) {\r\n throw \"Operation produced an invalid date.\";\r\n }\r\n\r\n return new RockDateTime(dateTime);\r\n }\r\n\r\n /**\r\n * Creates a new RockDateTime instance that represents the date and time\r\n * after adding the number of hours to this instance.\r\n *\r\n * @param days The number of hours to add.\r\n *\r\n * @returns A new instance of RockDateTime that represents the new date and time.\r\n */\r\n public addHours(hours: number): RockDateTime {\r\n const dateTime = this.dateTime.plus({ hours: hours });\r\n\r\n if (!dateTime.isValid) {\r\n throw \"Operation produced an invalid date.\";\r\n }\r\n\r\n return new RockDateTime(dateTime);\r\n }\r\n\r\n /**\r\n * Creates a new RockDateTime instance that represents the date and time\r\n * after adding the number of milliseconds to this instance.\r\n *\r\n * @param days The number of milliseconds to add.\r\n *\r\n * @returns A new instance of RockDateTime that represents the new date and time.\r\n */\r\n public addMilliseconds(milliseconds: number): RockDateTime {\r\n const dateTime = this.dateTime.plus({ milliseconds: milliseconds });\r\n\r\n if (!dateTime.isValid) {\r\n throw \"Operation produced an invalid date.\";\r\n }\r\n\r\n return new RockDateTime(dateTime);\r\n }\r\n\r\n /**\r\n * Creates a new RockDateTime instance that represents the date and time\r\n * after adding the number of minutes to this instance.\r\n *\r\n * @param days The number of minutes to add.\r\n *\r\n * @returns A new instance of RockDateTime that represents the new date and time.\r\n */\r\n public addMinutes(minutes: number): RockDateTime {\r\n const dateTime = this.dateTime.plus({ minutes: minutes });\r\n\r\n if (!dateTime.isValid) {\r\n throw \"Operation produced an invalid date.\";\r\n }\r\n\r\n return new RockDateTime(dateTime);\r\n }\r\n\r\n /**\r\n * Creates a new RockDateTime instance that represents the date and time\r\n * after adding the number of months to this instance.\r\n *\r\n * @param days The number of months to add.\r\n *\r\n * @returns A new instance of RockDateTime that represents the new date and time.\r\n */\r\n public addMonths(months: number): RockDateTime {\r\n const dateTime = this.dateTime.plus({ months: months });\r\n\r\n if (!dateTime.isValid) {\r\n throw \"Operation produced an invalid date.\";\r\n }\r\n\r\n return new RockDateTime(dateTime);\r\n }\r\n\r\n /**\r\n * Creates a new RockDateTime instance that represents the date and time\r\n * after adding the number of seconds to this instance.\r\n *\r\n * @param days The number of seconds to add.\r\n *\r\n * @returns A new instance of RockDateTime that represents the new date and time.\r\n */\r\n public addSeconds(seconds: number): RockDateTime {\r\n const dateTime = this.dateTime.plus({ seconds: seconds });\r\n\r\n if (!dateTime.isValid) {\r\n throw \"Operation produced an invalid date.\";\r\n }\r\n\r\n return new RockDateTime(dateTime);\r\n }\r\n\r\n /**\r\n * Creates a new RockDateTime instance that represents the date and time\r\n * after adding the number of years to this instance.\r\n *\r\n * @param days The number of years to add.\r\n *\r\n * @returns A new instance of RockDateTime that represents the new date and time.\r\n */\r\n public addYears(years: number): RockDateTime {\r\n const dateTime = this.dateTime.plus({ years: years });\r\n\r\n if (!dateTime.isValid) {\r\n throw \"Operation produced an invalid date.\";\r\n }\r\n\r\n return new RockDateTime(dateTime);\r\n }\r\n\r\n /**\r\n * Converts the date time representation into the number of milliseconds\r\n * that have elapsed since the epoch (1970-01-01T00:00:00Z).\r\n *\r\n * @returns The number of milliseconds since the epoch.\r\n */\r\n public toMilliseconds(): number {\r\n return this.dateTime.toMillis();\r\n }\r\n\r\n /**\r\n * Creates a new instance of RockDateTime that represents the same point\r\n * in time as represented by the specified time zone offset.\r\n *\r\n * @param zone The time zone offset as a number or string such as \"UTC+4\".\r\n *\r\n * @returns A new RockDateTime instance that represents the specified time zone.\r\n */\r\n public toOffset(zone: number | string): RockDateTime {\r\n let dateTime: DateTime;\r\n\r\n if (typeof zone === \"number\") {\r\n dateTime = this.dateTime.setZone(FixedOffsetZone.instance(zone));\r\n }\r\n else {\r\n dateTime = this.dateTime.setZone(zone);\r\n }\r\n\r\n if (!dateTime.isValid) {\r\n throw \"Invalid time zone specified.\";\r\n }\r\n\r\n return new RockDateTime(dateTime);\r\n }\r\n\r\n /**\r\n * Formats this instance according to C# formatting rules.\r\n *\r\n * @param format The string that specifies the format to use.\r\n *\r\n * @returns A string representing this instance in the given format.\r\n */\r\n public toASPString(format: string): string {\r\n return formatAspDate(this, format);\r\n }\r\n\r\n /**\r\n * Creates a string representation of this instance in ISO8601 format.\r\n *\r\n * @returns An ISO8601 formatted string.\r\n */\r\n public toISOString(): string {\r\n return this.dateTime.toISO();\r\n }\r\n\r\n /**\r\n * Formats this instance using standard locale formatting rules to display\r\n * a date and time in the browsers specified locale.\r\n *\r\n * @param format The format to use when generating the string.\r\n *\r\n * @returns A string that represents the date and time in then specified format.\r\n */\r\n public toLocaleString(format: Intl.DateTimeFormatOptions): string {\r\n return this.dateTime.toLocaleString(format);\r\n }\r\n\r\n /**\r\n * Transforms the date into a human friendly elapsed time string.\r\n *\r\n * @example\r\n * // Returns \"21yrs\"\r\n * RockDateTime.fromParts(2000, 3, 4).toElapsedString();\r\n *\r\n * @returns A string that represents the amount of time that has elapsed.\r\n */\r\n public toElapsedString(): string {\r\n const now = RockDateTime.now();\r\n const msPerHour = 1000 * 60 * 60;\r\n const hoursPerDay = 24;\r\n const daysPerMonth = 30.4167;\r\n const daysPerYear = 365.25;\r\n\r\n const totalMs = Math.abs(now.toMilliseconds() - this.toMilliseconds());\r\n const totalHours = totalMs / msPerHour;\r\n const totalDays = totalHours / hoursPerDay;\r\n\r\n if (totalDays < 2) {\r\n return \"1day\";\r\n }\r\n\r\n if (totalDays < 31) {\r\n return `${Math.floor(totalDays)}days`;\r\n }\r\n\r\n const totalMonths = totalDays / daysPerMonth;\r\n\r\n if (totalMonths <= 1) {\r\n return \"1mon\";\r\n }\r\n\r\n if (totalMonths <= 18) {\r\n return `${Math.round(totalMonths)}mon`;\r\n }\r\n\r\n const totalYears = totalDays / daysPerYear;\r\n\r\n if (totalYears <= 1) {\r\n return \"1yr\";\r\n }\r\n\r\n return `${Math.round(totalYears)}yrs`;\r\n }\r\n\r\n /**\r\n * Formats this instance as a string that can be used in HTTP headers and\r\n * cookies.\r\n *\r\n * @returns A new string that conforms to RFC 1123\r\n */\r\n public toHTTPString(): string {\r\n return this.dateTime.toHTTP();\r\n }\r\n\r\n /**\r\n * Get the value of the date and time in a format that can be used in\r\n * comparisons.\r\n *\r\n * @returns A number that represents the date and time.\r\n */\r\n public valueOf(): number {\r\n return this.dateTime.valueOf();\r\n }\r\n\r\n /**\r\n * Creates a standard string representation of the date and time.\r\n *\r\n * @returns A string representation of the date and time.\r\n */\r\n public toString(): string {\r\n return this.toLocaleString(DateTimeFormat.DateTimeFull);\r\n }\r\n\r\n /**\r\n * Checks if this instance is equal to another RockDateTime instance. This\r\n * will return true if the two instances represent the same point in time,\r\n * even if they have been associated with different time zones. In other\r\n * words \"2021-09-08 12:00:00 Z\" == \"2021-09-08 14:00:00 UTC+2\".\r\n *\r\n * @param otherDateTime The other RockDateTime to be compared against.\r\n *\r\n * @returns True if the two instances represent the same point in time.\r\n */\r\n public isEqualTo(otherDateTime: RockDateTime): boolean {\r\n return this.dateTime.toMillis() === otherDateTime.dateTime.toMillis();\r\n }\r\n\r\n /**\r\n * Checks if this instance is later than another RockDateTime instance.\r\n *\r\n * @param otherDateTime The other RockDateTime to be compared against.\r\n *\r\n * @returns True if this instance represents a point in time that occurred after another point in time, regardless of time zone.\r\n */\r\n public isLaterThan(otherDateTime: RockDateTime): boolean {\r\n return this.dateTime.toMillis() > otherDateTime.dateTime.toMillis();\r\n }\r\n\r\n /**\r\n * Checks if this instance is earlier than another RockDateTime instance.\r\n *\r\n * @param otherDateTime The other RockDateTime to be compared against.\r\n *\r\n * @returns True if this instance represents a point in time that occurred before another point in time, regardless of time zone.\r\n */\r\n public isEarlierThan(otherDateTime: RockDateTime): boolean {\r\n return this.dateTime.toMillis() < otherDateTime.dateTime.toMillis();\r\n }\r\n\r\n /**\r\n * Calculates the elapsed time between this date and the reference date and\r\n * returns that difference in a human friendly way.\r\n *\r\n * @param otherDateTime The reference date and time. If not specified then 'now' is used.\r\n *\r\n * @returns A string that represents the elapsed time.\r\n */\r\n public humanizeElapsed(otherDateTime?: RockDateTime): string {\r\n otherDateTime = otherDateTime ?? RockDateTime.now();\r\n\r\n const totalSeconds = Math.floor((otherDateTime.dateTime.toMillis() - this.dateTime.toMillis()) / 1000);\r\n\r\n if (totalSeconds <= 1) {\r\n return \"right now\";\r\n }\r\n else if (totalSeconds < 60) { // 1 minute\r\n return `${totalSeconds} seconds ago`;\r\n }\r\n else if (totalSeconds < 3600) { // 1 hour\r\n return `${Math.floor(totalSeconds / 60)} minutes ago`;\r\n }\r\n else if (totalSeconds < 86400) { // 1 day\r\n return `${Math.floor(totalSeconds / 3600)} hours ago`;\r\n }\r\n else if (totalSeconds < 31536000) { // 1 year\r\n return `${Math.floor(totalSeconds / 86400)} days ago`;\r\n }\r\n else {\r\n return `${Math.floor(totalSeconds / 31536000)} years ago`;\r\n }\r\n }\r\n\r\n // #endregion\r\n}\r\n","// \r\n// Copyright by the Spark Development Network\r\n//\r\n// Licensed under the Rock Community License (the \"License\");\r\n// you may not use this file except in compliance with the License.\r\n// You may obtain a copy of the License at\r\n//\r\n// http://www.rockrms.com/license\r\n//\r\n// Unless required by applicable law or agreed to in writing, software\r\n// distributed under the License is distributed on an \"AS IS\" BASIS,\r\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n// See the License for the specific language governing permissions and\r\n// limitations under the License.\r\n// \r\n//\r\n\r\n/**\r\n * Compares two values for equality by performing deep nested comparisons\r\n * if the values are objects or arrays.\r\n * \r\n * @param a The first value to compare.\r\n * @param b The second value to compare.\r\n * @param strict True if strict comparision is required (meaning 1 would not equal \"1\").\r\n *\r\n * @returns True if the two values are equal to each other.\r\n */\r\nexport function deepEqual(a: unknown, b: unknown, strict: boolean): boolean {\r\n // Catches everything but objects.\r\n if (strict && a === b) {\r\n return true;\r\n }\r\n else if (!strict && a == b) {\r\n return true;\r\n }\r\n\r\n // NaN never equals another NaN, but functionally they are the same.\r\n if (typeof a === \"number\" && typeof b === \"number\" && isNaN(a) && isNaN(b)) {\r\n return true;\r\n }\r\n\r\n // Remaining value types must both be of type object\r\n if (a && b && typeof a === \"object\" && typeof b === \"object\") {\r\n // Array status must match.\r\n if (Array.isArray(a) !== Array.isArray(b)) {\r\n return false;\r\n }\r\n\r\n if (Array.isArray(a) && Array.isArray(b)) {\r\n // Array lengths must match.\r\n if (a.length !== b.length) {\r\n return false;\r\n }\r\n\r\n // Each element in the array must match.\r\n for (let i = 0; i < a.length; i++) {\r\n if (!deepEqual(a[i], b[i], strict)) {\r\n return false;\r\n }\r\n }\r\n\r\n return true;\r\n }\r\n else {\r\n // NOTE: There are a few edge cases not accounted for here, but they\r\n // are rare and unusual:\r\n // Map, Set, ArrayBuffer, RegExp\r\n\r\n // The objects must be of the same \"object type\".\r\n if (a.constructor !== b.constructor) {\r\n return false;\r\n }\r\n\r\n // Get all the key/value pairs of each object and sort them so they\r\n // are in the same order as each other.\r\n const aEntries = Object.entries(a).sort((a, b) => a[0] < b[0] ? -1 : (a[0] > b[0] ? 1 : 0));\r\n const bEntries = Object.entries(b).sort((a, b) => a[0] < b[0] ? -1 : (a[0] > b[0] ? 1 : 0));\r\n\r\n // Key/value count must be identical.\r\n if (aEntries.length !== bEntries.length) {\r\n return false;\r\n }\r\n\r\n for (let i = 0; i < aEntries.length; i++) {\r\n const aEntry = aEntries[i];\r\n const bEntry = bEntries[i];\r\n\r\n // Ensure the keys are equal, must always be strict.\r\n if (!deepEqual(aEntry[0], bEntry[0], true)) {\r\n return false;\r\n }\r\n\r\n // Ensure the values are equal.\r\n if (!deepEqual(aEntry[1], bEntry[1], strict)) {\r\n return false;\r\n }\r\n }\r\n\r\n return true;\r\n }\r\n }\r\n\r\n return false;\r\n}\r\n\r\n\r\n/**\r\n * Debounces the function so it will only be called once during the specified\r\n * delay period. The returned function should be called to trigger the original\r\n * function that is to be debounced.\r\n * \r\n * @param fn The function to be called once per delay period.\r\n * @param delay The period in milliseconds. If the returned function is called\r\n * more than once during this period then fn will only be executed once for\r\n * the period. If not specified then it defaults to 250ms.\r\n * @param eager If true then the fn function will be called immediately and\r\n * then any subsequent calls will be debounced.\r\n *\r\n * @returns A function to be called when fn should be executed.\r\n */\r\nexport function debounce(fn: (() => void), delay: number = 250, eager: boolean = false): (() => void) {\r\n let timeout: NodeJS.Timeout | null = null;\r\n\r\n return (): void => {\r\n if (timeout) {\r\n clearTimeout(timeout);\r\n }\r\n else if (eager) {\r\n // If there was no previous timeout and we are configured for\r\n // eager calls, then execute now.\r\n fn();\r\n\r\n // An eager call should not result in a final debounce call.\r\n timeout = setTimeout(() => timeout = null, delay);\r\n\r\n return;\r\n }\r\n\r\n // If we had a previous timeout or we are not set for eager calls\r\n // then set a timeout to initiate the function after the delay.\r\n timeout = setTimeout(() => {\r\n timeout = null;\r\n fn();\r\n }, delay);\r\n };\r\n}\r\n","import { Guid } from \"@Obsidian/Types\";\r\nimport { BlockBeginEditData, BlockEndEditData, BrowserBusCallback, BrowserBusOptions, Message } from \"@Obsidian/Types/Utility/browserBus\";\r\nimport { areEqual } from \"./guid\";\r\n\r\n/*\r\n * READ THIS BEFORE MAKING ANY CHANGES TO THE BUS.\r\n *\r\n * OVERVIEW\r\n *\r\n * The browser bus is a basic pubsub interface within a single page. If you\r\n * publish a message to one instance of the bus it will be available to any\r\n * other instance on the same page. This uses document.addEventListener()\r\n * and document.dispatchEvent() with a single custom event name of `rockMessage`.\r\n *\r\n * The browser bus will not communicate with other browsers on the same page or\r\n * even other tabs within the same browser.\r\n *\r\n * For full documentation, see the gitbook developer documentation.\r\n *\r\n * FRAMEWORK MESSAGES\r\n *\r\n * All \"framework\" messages should have a type defined in\r\n * @Obsidian/Types/Utility/browserBus that specify the data type expected. If\r\n * no data type is expected than `void` can be used as the type. Message data\r\n * should always be an object rather than a primitive. This allows us to add\r\n * additional values without it being a breaking change to existing code.\r\n *\r\n * Additionally, all framework messages should have their name defined in either\r\n * the PageMessages object or BlockMessages object. This is for uniformity so it\r\n * is easier for core code and plugins to subscribe to these messages and know\r\n * they got the right message name.\r\n *\r\n * SUBSCRIBE OVERLOADS\r\n *\r\n * When adding new framework messages, be sure to add overloads to the\r\n * subscribe, subscribeToBlock and subscribeToBlockType functions for that\r\n * message name and data type. This compiles away to nothing but provides a\r\n * much better TypeScript experience.\r\n */\r\n\r\n\r\n/**\r\n * Framework messages that will be sent for pages.\r\n */\r\nexport const PageMessages = {\r\n\r\n} as const;\r\n\r\n/**\r\n * Framework messages that will be sent for blocks.\r\n */\r\nexport const BlockMessages = {\r\n /**\r\n * Sent just before a block switches into edit mode.\r\n */\r\n BeginEdit: \"block.core.beginEdit\",\r\n\r\n /**\r\n * Sent just after a block switches out of edit mode.\r\n */\r\n EndEdit: \"block.core.endEdit\",\r\n} as const;\r\n\r\n/**\r\n * Gets an object that will provide access to the browser bus. This bus will\r\n * allow different code on the page to send and receive messages betwen each\r\n * other as well as plain JavaScript. This bus does not cross page boundaries.\r\n *\r\n * Meaning, if you publish a message in one tab it will not show up in another\r\n * tab in the same (or a different) browser. Neither will messages magically\r\n * persist across page loads.\r\n *\r\n * If you call this method you are responsible for calling the {@link BrowserBus.dispose}\r\n * function when you are done with the bus. If you do not then your component\r\n * will probably never be garbage collected and your subscribed event handlers\r\n * will continue to be called.\r\n *\r\n * @param options Custom options to construct the {@link BrowserBus} object with. This should normally not be needed.\r\n *\r\n * @returns The object that provides access to the browser bus.\r\n */\r\nexport function useBrowserBus(options?: BrowserBusOptions): BrowserBus {\r\n return new BrowserBus(options ?? {});\r\n}\r\n\r\n// #region Internal Types\r\n\r\n/**\r\n * Internal message handler state that includes the filters used to decide\r\n * if the callback is valid for the message.\r\n */\r\ntype MessageHandler = {\r\n /** If not nullish messages must match this message name. */\r\n name?: string;\r\n\r\n /** If not nullish then messages must be from this block type. */\r\n blockType?: Guid;\r\n\r\n /** If not nullish them messages must be from this block instance. */\r\n block?: Guid;\r\n\r\n /** The callback that will be called. */\r\n callback: BrowserBusCallback;\r\n};\r\n\r\n// #endregion\r\n\r\n// #region Internal Implementation\r\n\r\n/** This is the JavaScript event name we use with dispatchEvent(). */\r\nconst customDomEventName = \"rockMessage\";\r\n\r\n/**\r\n * The main browser bus implementation. This uses a shared method to publish\r\n * and subscribe to messages such that if you create two BrowserBus instances on\r\n * the same page they will still be able to talk to each other.\r\n *\r\n * However, they will not be able to talk to instances on other pages such as\r\n * in other browser tabs.\r\n */\r\nexport class BrowserBus {\r\n /** The registered handlers that will potentially be invoked. */\r\n private handlers: MessageHandler[] = [];\r\n\r\n /** The options we were created with. */\r\n private options: BrowserBusOptions;\r\n\r\n /** The event listener. Used so we can remove the listener later. */\r\n private eventListener: (e: Event) => void;\r\n\r\n /**\r\n * Creates a new instance of the bus and prepares it to receive messages.\r\n *\r\n * This should be considered an internal constructor and not used by plugins.\r\n *\r\n * @param options The options that describe how this instance should operate.\r\n */\r\n constructor(options: BrowserBusOptions) {\r\n this.options = { ...options };\r\n\r\n this.eventListener = e => this.onEvent(e);\r\n document.addEventListener(customDomEventName, this.eventListener);\r\n }\r\n\r\n // #region Private Functions\r\n\r\n /**\r\n * Called when an event is received from the document listener.\r\n *\r\n * @param event The low level JavaScript even that was received.\r\n */\r\n private onEvent(event: Event): void {\r\n if (!(event instanceof CustomEvent)) {\r\n return;\r\n }\r\n\r\n let message = event.detail as Message;\r\n\r\n // Discard the message if it is not valid.\r\n if (!message.name) {\r\n return;\r\n }\r\n\r\n // If we got a message without a timestamp, it probably came from\r\n // plain JavaScript, so set it to 0.\r\n if (typeof message.timestamp === \"undefined\") {\r\n message = { ...message, timestamp: 0 };\r\n }\r\n\r\n this.onMessage(message);\r\n }\r\n\r\n /**\r\n * Called when a browser bus message is received from the bus.\r\n *\r\n * @param message The message that was received.\r\n */\r\n private onMessage(message: Message): void {\r\n // Make a copy of the handlers in case our list of handlers if modified\r\n // inside a handler.\r\n const handlers = [...this.handlers];\r\n\r\n for (const handler of handlers) {\r\n try {\r\n // Perform all the filtering. We could do this all in one\r\n // line but this is easier to read and understand.\r\n if (handler.name && handler.name !== message.name) {\r\n continue;\r\n }\r\n\r\n if (handler.blockType && !areEqual(handler.blockType, message.blockType)) {\r\n continue;\r\n }\r\n\r\n if (handler.block && !areEqual(handler.block, message.block)) {\r\n continue;\r\n }\r\n\r\n // All filters passed, execute the callback.\r\n handler.callback(message);\r\n }\r\n catch (e) {\r\n // Catch the error and display it so other handlers will still\r\n // be checked and called.\r\n console.error(e);\r\n }\r\n }\r\n }\r\n\r\n // #endregion\r\n\r\n // #region Public Functions\r\n\r\n /**\r\n * Frees up any resources used by this browser bus instance.\r\n */\r\n public dispose(): void {\r\n document.removeEventListener(customDomEventName, this.eventListener);\r\n this.handlers.splice(0, this.handlers.length);\r\n }\r\n\r\n /**\r\n * Publishes a named message without any data.\r\n *\r\n * @param messageName The name of the message to publish.\r\n */\r\n public publish(messageName: string): void;\r\n\r\n /**\r\n * Publishes a named message with some custom data.\r\n *\r\n * @param messageName The name of the message to publish.\r\n * @param data The custom data to include with the message.\r\n */\r\n public publish(messageName: string, data: unknown): void;\r\n\r\n /**\r\n * Publishes a named message with some custom data.\r\n *\r\n * @param messageName The name of the message to publish.\r\n * @param data The custom data to include with the message.\r\n */\r\n public publish(messageName: string, data?: unknown): void {\r\n this.publishMessage({\r\n name: messageName,\r\n timestamp: Date.now(),\r\n blockType: this.options.blockType,\r\n block: this.options.block,\r\n data\r\n });\r\n }\r\n\r\n /**\r\n * Publishes a message to the browser bus. No changes are made to the\r\n * message object.\r\n *\r\n * Do not use this message to publish a block message unless you have\r\n * manually filled in the {@link Message.blockType} and\r\n * {@link Message.block} properties.\r\n *\r\n * @param message The message to publish.\r\n */\r\n public publishMessage(message: Message): void {\r\n const event = new CustomEvent(customDomEventName, {\r\n detail: message\r\n });\r\n\r\n document.dispatchEvent(event);\r\n }\r\n\r\n // #endregion\r\n\r\n // #region subscribe()\r\n\r\n /**\r\n * Subscribes to the named message from any source.\r\n *\r\n * @param messageName The name of the message to subscribe to.\r\n * @param callback The callback to invoke when the message is received.\r\n */\r\n public subscribe(messageName: string, callback: BrowserBusCallback): void;\r\n\r\n /**\r\n * Subscribes to the named message from any source.\r\n *\r\n * @param messageName The name of the message to subscribe to.\r\n * @param callback The callback to invoke when the message is received.\r\n */\r\n public subscribe(messageName: \"core.block.beginEdit\", callback: BrowserBusCallback): void;\r\n\r\n /**\r\n * Subscribes to the named message from any source.\r\n *\r\n * @param messageName The name of the message to subscribe to.\r\n * @param callback The callback to invoke when the message is received.\r\n */\r\n public subscribe(messageName: \"core.block.endEdit\", callback: BrowserBusCallback): void;\r\n\r\n /**\r\n * Subscribes to any message that is sent.\r\n *\r\n * @param callback The callback to invoke when the message is received.\r\n */\r\n public subscribe(callback: BrowserBusCallback): void;\r\n\r\n /**\r\n * Subscribes to messages from any source.\r\n *\r\n * @param messageNameOrCallback The name of the message to subscribe to or the callback.\r\n * @param callback The callback to invoke when the message is received.\r\n */\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n public subscribe(messageNameOrCallback: string | BrowserBusCallback, callback?: BrowserBusCallback): void {\r\n let name: string | undefined;\r\n\r\n if (typeof messageNameOrCallback === \"string\") {\r\n name = messageNameOrCallback;\r\n }\r\n else {\r\n name = undefined;\r\n callback = messageNameOrCallback;\r\n }\r\n\r\n if (!callback) {\r\n return;\r\n }\r\n\r\n this.handlers.push({\r\n name,\r\n callback\r\n });\r\n }\r\n\r\n // #endregion\r\n\r\n // #region subscribeToBlockType()\r\n\r\n /**\r\n * Subscribes to the named message from any block instance with a matching\r\n * block type identifier.\r\n *\r\n * @param messageName The name of the message to subscribe to.\r\n * @param blockType The identifier of the block type.\r\n * @param callback The callback to invoke when the message is received.\r\n */\r\n public subscribeToBlockType(messageName: string, blockType: Guid, callback: BrowserBusCallback): void;\r\n\r\n /**\r\n * Subscribes to the named message from any block instance with a matching\r\n * block type identifier.\r\n *\r\n * @param messageName The name of the message to subscribe to.\r\n * @param blockType The identifier of the block type.\r\n * @param callback The callback to invoke when the message is received.\r\n */\r\n public subscribeToBlockType(messageName: \"core.block.beginEdit\", blockType: Guid, callback: BrowserBusCallback): void;\r\n\r\n /**\r\n * Subscribes to the named message from any block instance with a matching\r\n * block type identifier.\r\n *\r\n * @param messageName The name of the message to subscribe to.\r\n * @param blockType The identifier of the block type.\r\n * @param callback The callback to invoke when the message is received.\r\n */\r\n public subscribeToBlockType(messageName: \"core.block.endEdit\", blockType: Guid, callback: BrowserBusCallback): void;\r\n\r\n /**\r\n * Subscribes to any message that is sent from any block instance with a\r\n * matching block type identifier.\r\n *\r\n * @param blockType The identifier of the block type.\r\n * @param callback The callback to invoke when the message is received.\r\n */\r\n public subscribeToBlockType(blockType: Guid, callback: BrowserBusCallback): void;\r\n\r\n /**\r\n * Subscribes to messages from any block instance with a matching block\r\n * type identifier.\r\n *\r\n * @param messageNameOrBlockType The name of the message to subscribe to or the block type.\r\n * @param blockTypeOrCallback The block type or the callback function.\r\n * @param callback The callback to invoke when the message is received.\r\n */\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n public subscribeToBlockType(messageNameOrBlockType: string | Guid, blockTypeOrCallback: Guid | BrowserBusCallback, callback?: BrowserBusCallback): void {\r\n let name: string | undefined;\r\n let blockType: Guid;\r\n\r\n if (typeof blockTypeOrCallback === \"string\") {\r\n name = messageNameOrBlockType;\r\n blockType = blockTypeOrCallback;\r\n }\r\n else {\r\n blockType = messageNameOrBlockType;\r\n callback = blockTypeOrCallback;\r\n }\r\n\r\n if (!blockType || !callback) {\r\n return;\r\n }\r\n\r\n this.handlers.push({\r\n name,\r\n blockType,\r\n callback\r\n });\r\n }\r\n\r\n // #endregion\r\n\r\n // #region subscribeToBlock()\r\n\r\n /**\r\n * Subscribes to the named message from a single block instance.\r\n *\r\n * @param messageName The name of the message to subscribe to.\r\n * @param block The identifier of the block.\r\n * @param callback The callback to invoke when the message is received.\r\n */\r\n public subscribeToBlock(messageName: string, block: Guid, callback: BrowserBusCallback): void;\r\n\r\n /**\r\n * Subscribes to the named message from a single block instance.\r\n *\r\n * @param messageName The name of the message to subscribe to.\r\n * @param block The identifier of the block.\r\n * @param callback The callback to invoke when the message is received.\r\n */\r\n public subscribeToBlock(messageName: \"core.block.beginEdit\", block: Guid, callback: BrowserBusCallback): void;\r\n\r\n /**\r\n * Subscribes to the named message from a single block instance.\r\n *\r\n * @param messageName The name of the message to subscribe to.\r\n * @param block The identifier of the block.\r\n * @param callback The callback to invoke when the message is received.\r\n */\r\n public subscribeToBlock(messageName: \"core.block.endEdit\", block: Guid, callback: BrowserBusCallback): void;\r\n\r\n /**\r\n * Subscribes to any message that is sent from a single block instance.\r\n *\r\n * @param block The identifier of the block.\r\n * @param callback The callback to invoke when the message is received.\r\n */\r\n public subscribeToBlock(block: Guid, callback: BrowserBusCallback): void;\r\n\r\n /**\r\n * Subscribes to messages from a single block instance.\r\n *\r\n * @param messageNameOrBlock The name of the message to subscribe to or the block.\r\n * @param blockOrCallback The block or the callback function.\r\n * @param callback The callback to invoke when the message is received.\r\n */\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n public subscribeToBlock(messageNameOrBlock: string | Guid, blockOrCallback: Guid | BrowserBusCallback, callback?: BrowserBusCallback): void {\r\n let name: string | undefined;\r\n let block: Guid;\r\n\r\n if (typeof blockOrCallback === \"string\") {\r\n name = messageNameOrBlock;\r\n block = blockOrCallback;\r\n }\r\n else {\r\n block = messageNameOrBlock;\r\n callback = blockOrCallback;\r\n }\r\n\r\n if (!block || !callback) {\r\n return;\r\n }\r\n\r\n this.handlers.push({\r\n name,\r\n block,\r\n callback\r\n });\r\n }\r\n\r\n // #endregion\r\n}\r\n\r\n// #endregion\r\n","// \r\n// Copyright by the Spark Development Network\r\n//\r\n// Licensed under the Rock Community License (the \"License\");\r\n// you may not use this file except in compliance with the License.\r\n// You may obtain a copy of the License at\r\n//\r\n// http://www.rockrms.com/license\r\n//\r\n// Unless required by applicable law or agreed to in writing, software\r\n// distributed under the License is distributed on an \"AS IS\" BASIS,\r\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n// See the License for the specific language governing permissions and\r\n// limitations under the License.\r\n// \r\n//\r\n\r\nimport { BlockEvent, InvokeBlockActionFunc, SecurityGrant } from \"@Obsidian/Types/Utility/block\";\r\nimport { IBlockPersonPreferencesProvider, IPersonPreferenceCollection } from \"@Obsidian/Types/Core/personPreferences\";\r\nimport { ExtendedRef } from \"@Obsidian/Types/Utility/component\";\r\nimport { DetailBlockBox } from \"@Obsidian/ViewModels/Blocks/detailBlockBox\";\r\nimport { inject, provide, Ref, ref, watch } from \"vue\";\r\nimport { RockDateTime } from \"./rockDateTime\";\r\nimport { Guid } from \"@Obsidian/Types\";\r\nimport { HttpBodyData, HttpPostFunc, HttpResult } from \"@Obsidian/Types/Utility/http\";\r\nimport { BlockActionContextBag } from \"@Obsidian/ViewModels/Blocks/blockActionContextBag\";\r\nimport { ValidPropertiesBox } from \"@Obsidian/ViewModels/Utility/validPropertiesBox\";\r\nimport { IEntity } from \"@Obsidian/ViewModels/entity\";\r\nimport { debounce } from \"./util\";\r\nimport { BrowserBus, useBrowserBus } from \"./browserBus\";\r\n\r\nconst blockReloadSymbol = Symbol();\r\nconst configurationValuesChangedSymbol = Symbol();\r\nconst staticContentSymbol = Symbol(\"static-content\");\r\nconst blockBrowserBusSymbol = Symbol(\"block-browser-bus\");\r\n\r\n// TODO: Change these to use symbols\r\n\r\n/**\r\n * Maps the block configuration values to the expected type.\r\n *\r\n * @returns The configuration values for the block.\r\n */\r\nexport function useConfigurationValues(): T {\r\n const result = inject>(\"configurationValues\");\r\n\r\n if (result === undefined) {\r\n throw \"Attempted to access block configuration outside of a RockBlock.\";\r\n }\r\n\r\n return result.value;\r\n}\r\n\r\n/**\r\n * Gets the function that will be used to invoke block actions.\r\n *\r\n * @returns An instance of @see {@link InvokeBlockActionFunc}.\r\n */\r\nexport function useInvokeBlockAction(): InvokeBlockActionFunc {\r\n const result = inject(\"invokeBlockAction\");\r\n\r\n if (result === undefined) {\r\n throw \"Attempted to access block action invocation outside of a RockBlock.\";\r\n }\r\n\r\n return result;\r\n}\r\n\r\n/**\r\n * Creates a function that can be provided to the block that allows calling\r\n * block actions.\r\n *\r\n * @private This should not be used by plugins.\r\n *\r\n * @param post The function to handle the post operation.\r\n * @param pageGuid The unique identifier of the page.\r\n * @param blockGuid The unique identifier of the block.\r\n * @param pageParameters The parameters to include with the block action calls.\r\n *\r\n * @returns A function that can be used to provide the invoke block action.\r\n */\r\nexport function createInvokeBlockAction(post: HttpPostFunc, pageGuid: Guid, blockGuid: Guid, pageParameters: Record): InvokeBlockActionFunc {\r\n async function invokeBlockAction(actionName: string, data: HttpBodyData | undefined = undefined, actionContext: BlockActionContextBag | undefined = undefined): Promise> {\r\n let context: BlockActionContextBag = {};\r\n\r\n if (actionContext) {\r\n context = { ...actionContext };\r\n }\r\n\r\n context.pageParameters = pageParameters;\r\n\r\n return await post(`/api/v2/BlockActions/${pageGuid}/${blockGuid}/${actionName}`, undefined, {\r\n __context: context,\r\n ...data\r\n });\r\n }\r\n\r\n return invokeBlockAction;\r\n}\r\n\r\n/**\r\n * Provides the reload block callback function for a block. This is an internal\r\n * method and should not be used by plugins.\r\n *\r\n * @param callback The callback that will be called when a block wants to reload itself.\r\n */\r\nexport function provideReloadBlock(callback: () => void): void {\r\n provide(blockReloadSymbol, callback);\r\n}\r\n\r\n/**\r\n * Gets a function that can be called when a block wants to reload itself.\r\n *\r\n * @returns A function that will cause the block component to be reloaded.\r\n */\r\nexport function useReloadBlock(): () => void {\r\n return inject<() => void>(blockReloadSymbol, () => {\r\n // Intentionally blank, do nothing by default.\r\n });\r\n}\r\n\r\n/**\r\n * Provides the data for a block to be notified when its configuration values\r\n * have changed. This is an internal method and should not be used by plugins.\r\n *\r\n * @returns An object with an invoke and reset function.\r\n */\r\nexport function provideConfigurationValuesChanged(): { invoke: () => void, reset: () => void } {\r\n const callbacks: (() => void)[] = [];\r\n\r\n provide(configurationValuesChangedSymbol, callbacks);\r\n\r\n return {\r\n invoke: (): void => {\r\n for (const c of callbacks) {\r\n c();\r\n }\r\n },\r\n\r\n reset: (): void => {\r\n callbacks.splice(0, callbacks.length);\r\n }\r\n };\r\n}\r\n\r\n/**\r\n * Registered a function to be called when the block configuration values have\r\n * changed.\r\n *\r\n * @param callback The function to be called when the configuration values have changed.\r\n */\r\nexport function onConfigurationValuesChanged(callback: () => void): void {\r\n const callbacks = inject<(() => void)[]>(configurationValuesChangedSymbol);\r\n\r\n if (callbacks !== undefined) {\r\n callbacks.push(callback);\r\n }\r\n}\r\n\r\n/**\r\n * Provides the static content that the block provided on the server.\r\n *\r\n * @param content The static content from the server.\r\n */\r\nexport function provideStaticContent(content: Ref): void {\r\n provide(staticContentSymbol, content);\r\n}\r\n\r\n/**\r\n * Gets the static content that was provided by the block on the server.\r\n *\r\n * @returns A string of HTML content or undefined.\r\n */\r\nexport function useStaticContent(): Node[] {\r\n const content = inject>(staticContentSymbol);\r\n\r\n if (!content) {\r\n return [];\r\n }\r\n\r\n return content.value;\r\n}\r\n\r\n/**\r\n * Provides the browser bus configured to publish messages for the current\r\n * block.\r\n *\r\n * @param bus The browser bus.\r\n */\r\nexport function provideBlockBrowserBus(bus: BrowserBus): void {\r\n provide(blockBrowserBusSymbol, bus);\r\n}\r\n\r\n/**\r\n * Gets the browser bus configured for use by the current block. If available\r\n * this will be properly configured to publish messages with the correct block\r\n * and block type. If this is called outside the context of a block then a\r\n * generic use {@link BrowserBus} will be returned.\r\n *\r\n * @returns An instance of {@link BrowserBus}.\r\n */\r\nexport function useBlockBrowserBus(): BrowserBus {\r\n return inject(blockBrowserBusSymbol, () => useBrowserBus(), true);\r\n}\r\n\r\n\r\n/**\r\n * A type that returns the keys of a child property.\r\n */\r\ntype ChildKeys, PropertyName extends string> = keyof NonNullable & string;\r\n\r\n/**\r\n * A valid properties box that uses the specified name for the content bag.\r\n */\r\ntype ValidPropertiesSettingsBox = {\r\n validProperties?: string[] | null;\r\n} & {\r\n settings?: Record | null;\r\n};\r\n\r\n/**\r\n * Sets the a value for a custom settings box. This will set the value and then\r\n * add the property name to the list of valid properties.\r\n *\r\n * @param box The box whose custom setting value will be set.\r\n * @param propertyName The name of the custom setting property to set.\r\n * @param value The new value of the custom setting.\r\n */\r\nexport function setCustomSettingsBoxValue, K extends ChildKeys>(box: T, propertyName: K, value: S[K]): void {\r\n if (!box.settings) {\r\n box.settings = {} as Record;\r\n }\r\n\r\n box.settings[propertyName] = value;\r\n\r\n if (!box.validProperties) {\r\n box.validProperties = [];\r\n }\r\n\r\n if (!box.validProperties.includes(propertyName)) {\r\n box.validProperties.push(propertyName);\r\n }\r\n}\r\n\r\n/**\r\n * Sets the a value for a property box. This will set the value and then\r\n * add the property name to the list of valid properties.\r\n *\r\n * @param box The box whose property value will be set.\r\n * @param propertyName The name of the property on the bag to set.\r\n * @param value The new value of the property.\r\n */\r\nexport function setPropertiesBoxValue, K extends keyof T & string>(box: ValidPropertiesBox, propertyName: K, value: T[K]): void {\r\n if (!box.bag) {\r\n box.bag = {} as Record as T;\r\n }\r\n\r\n box.bag[propertyName] = value;\r\n\r\n if (!box.validProperties) {\r\n box.validProperties = [];\r\n }\r\n\r\n if (!box.validProperties.some(p => p.toLowerCase() === propertyName.toLowerCase())) {\r\n box.validProperties.push(propertyName);\r\n }\r\n}\r\n\r\n/**\r\n * Dispatches a block event to the document.\r\n *\r\n * @deprecated Do not use this function anymore, it will be removed in the future.\r\n * Use the BrowserBus instead.\r\n *\r\n * @param eventName The name of the event to be dispatched.\r\n * @param eventData The custom data to be attached to the event.\r\n *\r\n * @returns true if preventDefault() was called on the event, otherwise false.\r\n */\r\nexport function dispatchBlockEvent(eventName: string, blockGuid: Guid, eventData?: unknown): boolean {\r\n const ev = new CustomEvent(eventName, {\r\n cancelable: true,\r\n detail: {\r\n guid: blockGuid,\r\n data: eventData\r\n }\r\n });\r\n\r\n return document.dispatchEvent(ev);\r\n}\r\n\r\n/**\r\n * Tests if the given event is a custom block event. This does not ensure\r\n * that the event data is the correct type, only the event itself.\r\n *\r\n * @param event The event to be tested.\r\n *\r\n * @returns true if the event is a block event.\r\n */\r\nexport function isBlockEvent(event: Event): event is CustomEvent> {\r\n return \"guid\" in event && \"data\" in event;\r\n}\r\n\r\n// #region Entity Detail Blocks\r\n\r\nconst entityTypeNameSymbol = Symbol(\"EntityTypeName\");\r\nconst entityTypeGuidSymbol = Symbol(\"EntityTypeGuid\");\r\n\r\ntype UseEntityDetailBlockOptions = {\r\n /** The block configuration. */\r\n blockConfig: Record;\r\n\r\n /**\r\n * The entity that will be used by the block, this will cause the\r\n * onPropertyChanged logic to be generated.\r\n */\r\n entity?: Ref>;\r\n};\r\n\r\ntype UseEntityDetailBlockResult = {\r\n /** The onPropertyChanged handler for the edit panel. */\r\n onPropertyChanged?(propertyName: string): void;\r\n};\r\n\r\n/**\r\n * Performs any framework-level initialization of an entity detail block.\r\n *\r\n * @param options The options to use when initializing the detail block logic.\r\n *\r\n * @returns An object that contains information which can be used by the block.\r\n */\r\nexport function useEntityDetailBlock(options: UseEntityDetailBlockOptions): UseEntityDetailBlockResult {\r\n const securityGrant = getSecurityGrant(options.blockConfig.securityGrantToken as string);\r\n\r\n provideSecurityGrant(securityGrant);\r\n\r\n if (options.blockConfig.entityTypeName) {\r\n provideEntityTypeName(options.blockConfig.entityTypeName as string);\r\n }\r\n\r\n if (options.blockConfig.entityTypeGuid) {\r\n provideEntityTypeGuid(options.blockConfig.entityTypeGuid as Guid);\r\n }\r\n\r\n const entity = options.entity;\r\n\r\n const result: Record = {};\r\n\r\n if (entity) {\r\n const invokeBlockAction = useInvokeBlockAction();\r\n const refreshAttributesDebounce = debounce(() => refreshEntityDetailAttributes(entity, invokeBlockAction), undefined, true);\r\n\r\n result.onPropertyChanged = (propertyName: string): void => {\r\n // If we don't have any qualified attribute properties or this property\r\n // is not one of them then do nothing.\r\n if (!options.blockConfig.qualifiedAttributeProperties || !(options.blockConfig.qualifiedAttributeProperties as string[]).some(n => n.toLowerCase() === propertyName.toLowerCase())) {\r\n return;\r\n }\r\n\r\n refreshAttributesDebounce();\r\n };\r\n }\r\n\r\n return result;\r\n}\r\n\r\n/**\r\n * Provides the entity type name to child components.\r\n *\r\n * @param name The entity type name in PascalCase, such as `GroupMember`.\r\n */\r\nexport function provideEntityTypeName(name: string): void {\r\n provide(entityTypeNameSymbol, name);\r\n}\r\n\r\n/**\r\n * Gets the entity type name provided from a parent component.\r\n *\r\n * @returns The entity type name in PascalCase, such as `GroupMember` or undefined.\r\n */\r\nexport function useEntityTypeName(): string | undefined {\r\n return inject(entityTypeNameSymbol, undefined);\r\n}\r\n\r\n/**\r\n * Provides the entity type unique identifier to child components.\r\n *\r\n * @param guid The entity type unique identifier.\r\n */\r\nexport function provideEntityTypeGuid(guid: Guid): void {\r\n provide(entityTypeGuidSymbol, guid);\r\n}\r\n\r\n/**\r\n * Gets the entity type unique identifier provided from a parent component.\r\n *\r\n * @returns The entity type unique identifier or undefined.\r\n */\r\nexport function useEntityTypeGuid(): Guid | undefined {\r\n return inject(entityTypeGuidSymbol, undefined);\r\n}\r\n\r\n// #endregion\r\n\r\n// #region Security Grants\r\n\r\nconst securityGrantSymbol = Symbol();\r\n\r\n/**\r\n * Use a security grant token value provided by the server. This returns a reference\r\n * to the actual value and will automatically handle renewing the token and updating\r\n * the value. This function is meant to be used by blocks. Controls should use the\r\n * useSecurityGrant() function instead.\r\n *\r\n * @param token The token provided by the server.\r\n *\r\n * @returns A reference to the security grant that will be updated automatically when it has been renewed.\r\n */\r\nexport function getSecurityGrant(token: string | null | undefined): SecurityGrant {\r\n // Use || so that an empty string gets converted to null.\r\n const tokenRef = ref(token || null);\r\n const invokeBlockAction = useInvokeBlockAction();\r\n let renewalTimeout: NodeJS.Timeout | null = null;\r\n\r\n // Internal function to renew the token and re-schedule renewal.\r\n const renewToken = async (): Promise => {\r\n const result = await invokeBlockAction(\"RenewSecurityGrantToken\");\r\n\r\n if (result.isSuccess && result.data) {\r\n tokenRef.value = result.data;\r\n\r\n scheduleRenewal();\r\n }\r\n };\r\n\r\n // Internal function to schedule renewal based on the expiration date in\r\n // the existing token. Renewal happens 15 minutes before expiration.\r\n const scheduleRenewal = (): void => {\r\n // Cancel any existing renewal timer.\r\n if (renewalTimeout !== null) {\r\n clearTimeout(renewalTimeout);\r\n renewalTimeout = null;\r\n }\r\n\r\n // No token, nothing to do.\r\n if (tokenRef.value === null) {\r\n return;\r\n }\r\n\r\n const segments = tokenRef.value?.split(\";\");\r\n\r\n // Token not in expected format.\r\n if (segments.length !== 3 || segments[0] !== \"1\") {\r\n return;\r\n }\r\n\r\n const expiresDateTime = RockDateTime.parseISO(segments[1]);\r\n\r\n // Could not parse expiration date and time.\r\n if (expiresDateTime === null) {\r\n return;\r\n }\r\n\r\n const renewTimeout = expiresDateTime.addMinutes(-15).toMilliseconds() - RockDateTime.now().toMilliseconds();\r\n\r\n // Renewal request would be in the past, ignore.\r\n if (renewTimeout < 0) {\r\n return;\r\n }\r\n\r\n // Schedule the renewal task to happen 15 minutes before expiration.\r\n renewalTimeout = setTimeout(renewToken, renewTimeout);\r\n };\r\n\r\n scheduleRenewal();\r\n\r\n return {\r\n token: tokenRef,\r\n updateToken(newToken) {\r\n tokenRef.value = newToken || null;\r\n scheduleRenewal();\r\n }\r\n };\r\n}\r\n\r\n/**\r\n * Provides the security grant to child components to use in their API calls.\r\n *\r\n * @param grant The grant ot provide to child components.\r\n */\r\nexport function provideSecurityGrant(grant: SecurityGrant): void {\r\n provide(securityGrantSymbol, grant);\r\n}\r\n\r\n/**\r\n * Uses a previously provided security grant token by a parent component.\r\n * This function is meant to be used by controls that need to obtain a security\r\n * grant from a parent component.\r\n *\r\n * @returns A string reference that contains the security grant token.\r\n */\r\nexport function useSecurityGrantToken(): Ref {\r\n const grant = inject(securityGrantSymbol);\r\n\r\n return grant ? grant.token : ref(null);\r\n}\r\n\r\n// #endregion\r\n\r\n// #region Extended References\r\n\r\n/** An emit object that conforms to having a propertyChanged event. */\r\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\r\nexport type PropertyChangedEmitFn = E extends Array ? (event: EE, ...args: any[]) => void : (event: E, ...args: any[]) => void;\r\n\r\n/**\r\n * Watches for changes to the given Ref objects and emits a special event to\r\n * indicate that a given property has changed.\r\n *\r\n * @param propertyRefs The ExtendedRef objects to watch for changes.\r\n * @param emit The emit function for the component.\r\n */\r\nexport function watchPropertyChanges(propertyRefs: ExtendedRef[], emit: PropertyChangedEmitFn): void {\r\n for (const propRef of propertyRefs) {\r\n watch(propRef, () => {\r\n if (propRef.context.propertyName) {\r\n emit(\"propertyChanged\", propRef.context.propertyName);\r\n }\r\n });\r\n }\r\n}\r\n\r\n/**\r\n * Requests an updated attribute list from the server based on the\r\n * current UI selections made.\r\n *\r\n * @param box The valid properties box that will be used to determine current\r\n * property values and then updated with the new attributes and values.\r\n * @param invokeBlockAction The function to use when calling the block action.\r\n */\r\nasync function refreshEntityDetailAttributes(box: Ref>, invokeBlockAction: InvokeBlockActionFunc): Promise {\r\n const result = await invokeBlockAction>(\"RefreshAttributes\", {\r\n box: box.value\r\n });\r\n\r\n if (result.isSuccess) {\r\n if (result.statusCode === 200 && result.data && box.value) {\r\n const newBox: ValidPropertiesBox = {\r\n ...box.value,\r\n bag: {\r\n ...box.value.bag as TEntityBag,\r\n attributes: result.data.bag?.attributes,\r\n attributeValues: result.data.bag?.attributeValues\r\n }\r\n };\r\n\r\n box.value = newBox;\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * Requests an updated attribute list from the server based on the\r\n * current UI selections made.\r\n *\r\n * @param bag The entity bag that will be used to determine current property values\r\n * and then updated with the new attributes and values.\r\n * @param validProperties The properties that are considered valid on the bag when\r\n * the server will read the bag.\r\n * @param invokeBlockAction The function to use when calling the block action.\r\n */\r\nexport async function refreshDetailAttributes(bag: Ref, validProperties: string[], invokeBlockAction: InvokeBlockActionFunc): Promise {\r\n const data: DetailBlockBox = {\r\n entity: bag.value,\r\n isEditable: true,\r\n validProperties: validProperties\r\n };\r\n\r\n const result = await invokeBlockAction, unknown>>(\"RefreshAttributes\", {\r\n box: data\r\n });\r\n\r\n if (result.isSuccess) {\r\n if (result.statusCode === 200 && result.data && bag.value) {\r\n const newBag: TEntityBag = {\r\n ...bag.value,\r\n attributes: result.data.entity?.attributes,\r\n attributeValues: result.data.entity?.attributeValues\r\n };\r\n\r\n bag.value = newBag;\r\n }\r\n }\r\n}\r\n\r\n// #endregion Extended Refs\r\n\r\n// #region Block and BlockType Guid\r\n\r\nconst blockGuidSymbol = Symbol(\"block-guid\");\r\nconst blockTypeGuidSymbol = Symbol(\"block-type-guid\");\r\n\r\n/**\r\n * Provides the block unique identifier to all child components.\r\n * This is an internal method and should not be used by plugins.\r\n *\r\n * @param blockGuid The unique identifier of the block.\r\n */\r\nexport function provideBlockGuid(blockGuid: string): void {\r\n provide(blockGuidSymbol, blockGuid);\r\n}\r\n\r\n/**\r\n * Gets the unique identifier of the current block in this component chain.\r\n *\r\n * @returns The unique identifier of the block.\r\n */\r\nexport function useBlockGuid(): Guid | undefined {\r\n return inject(blockGuidSymbol);\r\n}\r\n\r\n/**\r\n * Provides the block type unique identifier to all child components.\r\n * This is an internal method and should not be used by plugins.\r\n *\r\n * @param blockTypeGuid The unique identifier of the block type.\r\n */\r\nexport function provideBlockTypeGuid(blockTypeGuid: string): void {\r\n provide(blockTypeGuidSymbol, blockTypeGuid);\r\n}\r\n\r\n/**\r\n * Gets the block type unique identifier of the current block in this component\r\n * chain.\r\n *\r\n * @returns The unique identifier of the block type.\r\n */\r\nexport function useBlockTypeGuid(): Guid | undefined {\r\n return inject(blockTypeGuidSymbol);\r\n}\r\n\r\n// #endregion\r\n\r\n// #region Person Preferences\r\n\r\nconst blockPreferenceProviderSymbol = Symbol();\r\n\r\n/** An no-op implementation of {@link IPersonPreferenceCollection}. */\r\nconst emptyPreferences: IPersonPreferenceCollection = {\r\n getValue(): string {\r\n return \"\";\r\n },\r\n setValue(): void {\r\n // Intentionally empty.\r\n },\r\n getKeys(): string[] {\r\n return [];\r\n },\r\n containsKey(): boolean {\r\n return false;\r\n },\r\n save(): Promise {\r\n return Promise.resolve();\r\n },\r\n withPrefix(): IPersonPreferenceCollection {\r\n return emptyPreferences;\r\n },\r\n on(): void {\r\n // Intentionally empty.\r\n },\r\n off(): void {\r\n // Intentionally empty.\r\n }\r\n};\r\n\r\nconst emptyPreferenceProvider: IBlockPersonPreferencesProvider = {\r\n blockPreferences: emptyPreferences,\r\n getGlobalPreferences() {\r\n return Promise.resolve(emptyPreferences);\r\n },\r\n getEntityPreferences() {\r\n return Promise.resolve(emptyPreferences);\r\n }\r\n};\r\n\r\n/**\r\n * Provides the person preferences provider that will be used by components\r\n * to access the person preferences associated with their block.\r\n *\r\n * @private This is an internal method and should not be used by plugins.\r\n *\r\n * @param blockGuid The unique identifier of the block.\r\n */\r\nexport function providePersonPreferences(provider: IBlockPersonPreferencesProvider): void {\r\n provide(blockPreferenceProviderSymbol, provider);\r\n}\r\n\r\n/**\r\n * Gets the person preference provider that can be used to access block\r\n * preferences as well as other preferences.\r\n *\r\n * @returns An object that implements {@link IBlockPersonPreferencesProvider}.\r\n */\r\nexport function usePersonPreferences(): IBlockPersonPreferencesProvider {\r\n return inject(blockPreferenceProviderSymbol)\r\n ?? emptyPreferenceProvider;\r\n}\r\n\r\n// #endregion\r\n","// \r\n// Copyright by the Spark Development Network\r\n//\r\n// Licensed under the Rock Community License (the \"License\");\r\n// you may not use this file except in compliance with the License.\r\n// You may obtain a copy of the License at\r\n//\r\n// http://www.rockrms.com/license\r\n//\r\n// Unless required by applicable law or agreed to in writing, software\r\n// distributed under the License is distributed on an \"AS IS\" BASIS,\r\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n// See the License for the specific language governing permissions and\r\n// limitations under the License.\r\n// \r\n//\r\n\r\n/**\r\n * Transform the value into true, false, or null\r\n * @param val\r\n */\r\nexport function asBooleanOrNull(val: unknown): boolean | null {\r\n if (val === undefined || val === null) {\r\n return null;\r\n }\r\n\r\n if (typeof val === \"boolean\") {\r\n return val;\r\n }\r\n\r\n if (typeof val === \"string\") {\r\n const asString = (val || \"\").trim().toLowerCase();\r\n\r\n if (!asString) {\r\n return null;\r\n }\r\n\r\n return [\"true\", \"yes\", \"t\", \"y\", \"1\"].indexOf(asString) !== -1;\r\n }\r\n\r\n if (typeof val === \"number\") {\r\n return !!val;\r\n }\r\n\r\n return null;\r\n}\r\n\r\n/**\r\n * Transform the value into true or false\r\n * @param val\r\n */\r\nexport function asBoolean(val: unknown): boolean {\r\n return !!asBooleanOrNull(val);\r\n}\r\n\r\n/** Transform the value into the strings \"Yes\", \"No\", or null */\r\nexport function asYesNoOrNull(val: unknown): \"Yes\" | \"No\" | null {\r\n const boolOrNull = asBooleanOrNull(val);\r\n\r\n if (boolOrNull === null) {\r\n return null;\r\n }\r\n\r\n return boolOrNull ? \"Yes\" : \"No\";\r\n}\r\n\r\n/** Transform the value into the strings \"True\", \"False\", or null */\r\nexport function asTrueFalseOrNull(val: unknown): \"True\" | \"False\" | null {\r\n const boolOrNull = asBooleanOrNull(val);\r\n\r\n if (boolOrNull === null) {\r\n return null;\r\n }\r\n\r\n return boolOrNull ? \"True\" : \"False\";\r\n}\r\n\r\n/** Transform the value into the strings \"True\" if truthy or \"False\" if falsey */\r\nexport function asTrueOrFalseString(val: unknown): \"True\" | \"False\" {\r\n const boolOrNull = asBooleanOrNull(val);\r\n\r\n return boolOrNull ? \"True\" : \"False\";\r\n}\r\n","// \r\n// Copyright by the Spark Development Network\r\n//\r\n// Licensed under the Rock Community License (the \"License\");\r\n// you may not use this file except in compliance with the License.\r\n// You may obtain a copy of the License at\r\n//\r\n// http://www.rockrms.com/license\r\n//\r\n// Unless required by applicable law or agreed to in writing, software\r\n// distributed under the License is distributed on an \"AS IS\" BASIS,\r\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n// See the License for the specific language governing permissions and\r\n// limitations under the License.\r\n// \r\n\r\nimport { RockDateTime } from \"./rockDateTime\";\r\n\r\n//\r\ntype CacheEntry = {\r\n value: T;\r\n expiration: number;\r\n};\r\n\r\n/**\r\n* Stores the value using the given key. The cache will expire at the expiration or in\r\n* 1 minute if none is provided\r\n* @param key\r\n* @param value\r\n* @param expiration\r\n*/\r\nfunction set(key: string, value: T, expirationDT: RockDateTime | null = null): void {\r\n let expiration: number;\r\n\r\n if (expirationDT) {\r\n expiration = expirationDT.toMilliseconds();\r\n }\r\n else {\r\n // Default to one minute\r\n expiration = RockDateTime.now().addMinutes(1).toMilliseconds();\r\n }\r\n\r\n const cache: CacheEntry = { expiration, value };\r\n const cacheJson = JSON.stringify(cache);\r\n sessionStorage.setItem(key, cacheJson);\r\n}\r\n\r\n/**\r\n * Gets a stored cache value if there is one that has not yet expired.\r\n * @param key\r\n */\r\nfunction get(key: string): T | null {\r\n const cacheJson = sessionStorage.getItem(key);\r\n\r\n if (!cacheJson) {\r\n return null;\r\n }\r\n\r\n const cache = JSON.parse(cacheJson) as CacheEntry;\r\n\r\n if (!cache || !cache.expiration) {\r\n return null;\r\n }\r\n\r\n if (cache.expiration < RockDateTime.now().toMilliseconds()) {\r\n return null;\r\n }\r\n\r\n return cache.value;\r\n}\r\n\r\nconst promiseCache: Record | undefined> = {};\r\n\r\n/**\r\n * Since Promises can't be cached, we need to store them in memory until we get the result back. This wraps\r\n * a function in another function that returns a promise and...\r\n * - If there's a cached result, return it\r\n * - Otherwise if there's a cached Promise, return it\r\n * - Otherwise call the given function and cache it's promise and return it. Once the the Promise resolves, cache its result\r\n *\r\n * @param key Key for identifying the cached values\r\n * @param fn Function that returns a Promise that we want to cache the value of\r\n *\r\n */\r\nfunction cachePromiseFactory(key: string, fn: () => Promise, expiration: RockDateTime | null = null): () => Promise {\r\n return async function (): Promise {\r\n // If it's cached, grab it\r\n const cachedResult = get(key);\r\n if (cachedResult) {\r\n return cachedResult;\r\n }\r\n\r\n // If it's not cached yet but we've already started fetching it\r\n // (it's not cached until we receive the results), return the existing Promise\r\n if (promiseCache[key]) {\r\n return promiseCache[key] as Promise;\r\n }\r\n\r\n // Not stored anywhere, so fetch it and save it on the stored Promise for the next call\r\n promiseCache[key] = fn();\r\n\r\n // Once it's resolved, cache the result\r\n promiseCache[key]?.then((result) => {\r\n set(key, result, expiration);\r\n delete promiseCache[key];\r\n return result;\r\n }).catch((e: Error) => {\r\n // Something's wrong, let's get rid of the stored promise, so we can try again.\r\n delete promiseCache[key];\r\n throw e;\r\n });\r\n\r\n return promiseCache[key] as Promise;\r\n };\r\n}\r\n\r\n\r\nexport default {\r\n set,\r\n get,\r\n cachePromiseFactory: cachePromiseFactory\r\n};\r\n","// \r\n// Copyright by the Spark Development Network\r\n//\r\n// Licensed under the Rock Community License (the \"License\");\r\n// you may not use this file except in compliance with the License.\r\n// You may obtain a copy of the License at\r\n//\r\n// http://www.rockrms.com/license\r\n//\r\n// Unless required by applicable law or agreed to in writing, software\r\n// distributed under the License is distributed on an \"AS IS\" BASIS,\r\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n// See the License for the specific language governing permissions and\r\n// limitations under the License.\r\n// \r\n\r\nimport mitt, { Emitter } from \"mitt\";\r\n\r\n// NOTE: Much of the logic for this was taken from VSCode's MIT licensed version:\r\n// https://github.com/microsoft/vscode/blob/342394d1e7d43d3324dc2ede1d634cffd52ba159/src/vs/base/common/cancellation.ts\r\n\r\n/**\r\n * A cancellation token can be used to instruct some operation to run but abort\r\n * if a certain condition is met.\r\n */\r\nexport interface ICancellationToken {\r\n /**\r\n * A flag signalling is cancellation has been requested.\r\n */\r\n readonly isCancellationRequested: boolean;\r\n\r\n /**\r\n * Registers a listener for when cancellation has been requested. This event\r\n * only ever fires `once` as cancellation can only happen once. Listeners\r\n * that are registered after cancellation will be called (next event loop run),\r\n * but also only once.\r\n *\r\n * @param listener The function to be called when the token has been cancelled.\r\n */\r\n onCancellationRequested(listener: () => void): void;\r\n}\r\n\r\nfunction shortcutCancelledEvent(listener: () => void): void {\r\n window.setTimeout(listener, 0);\r\n}\r\n\r\n/**\r\n * Determines if something is a cancellation token.\r\n *\r\n * @param thing The thing to be checked to see if it is a cancellation token.\r\n *\r\n * @returns true if the @{link thing} is a cancellation token, otherwise false.\r\n */\r\nexport function isCancellationToken(thing: unknown): thing is ICancellationToken {\r\n if (thing === CancellationTokenNone || thing === CancellationTokenCancelled) {\r\n return true;\r\n }\r\n if (thing instanceof MutableToken) {\r\n return true;\r\n }\r\n if (!thing || typeof thing !== \"object\") {\r\n return false;\r\n }\r\n return typeof (thing as ICancellationToken).isCancellationRequested === \"boolean\"\r\n && typeof (thing as ICancellationToken).onCancellationRequested === \"function\";\r\n}\r\n\r\n/**\r\n * A cancellation token that will never be in a cancelled state.\r\n */\r\nexport const CancellationTokenNone = Object.freeze({\r\n isCancellationRequested: false,\r\n onCancellationRequested() {\r\n // Intentionally blank.\r\n }\r\n});\r\n\r\n/**\r\n * A cancellation token that is already in a cancelled state.\r\n */\r\nexport const CancellationTokenCancelled = Object.freeze({\r\n isCancellationRequested: true,\r\n onCancellationRequested: shortcutCancelledEvent\r\n});\r\n\r\n/**\r\n * Internal implementation of a cancellation token that starts initially as\r\n * active but can later be switched to a cancelled state.\r\n */\r\nclass MutableToken implements ICancellationToken {\r\n private isCancelled: boolean = false;\r\n private emitter: Emitter> | null = null;\r\n\r\n /**\r\n * Cancels the token and fires any registered event listeners.\r\n */\r\n public cancel(): void {\r\n if (!this.isCancelled) {\r\n this.isCancelled = true;\r\n if (this.emitter) {\r\n this.emitter.emit(\"cancel\", undefined);\r\n this.emitter = null;\r\n }\r\n }\r\n }\r\n\r\n // #region ICancellationToken implementation\r\n\r\n get isCancellationRequested(): boolean {\r\n return this.isCancelled;\r\n }\r\n\r\n onCancellationRequested(listener: () => void): void {\r\n if (this.isCancelled) {\r\n return shortcutCancelledEvent(listener);\r\n }\r\n\r\n if (!this.emitter) {\r\n this.emitter = mitt();\r\n }\r\n\r\n this.emitter.on(\"cancel\", listener);\r\n }\r\n\r\n // #endregion\r\n}\r\n\r\n/**\r\n * Creates a source instance that can be used to trigger a cancellation\r\n * token into the cancelled state.\r\n */\r\nexport class CancellationTokenSource {\r\n /** The token that can be passed to functions. */\r\n private internalToken?: ICancellationToken = undefined;\r\n\r\n /**\r\n * Creates a new instance of {@link CancellationTokenSource}.\r\n *\r\n * @param parent The parent cancellation token that will also cancel this source.\r\n */\r\n constructor(parent?: ICancellationToken) {\r\n if (parent) {\r\n parent.onCancellationRequested(() => this.cancel());\r\n }\r\n }\r\n\r\n /**\r\n * The cancellation token that can be used to determine when the task\r\n * should be cancelled.\r\n */\r\n get token(): ICancellationToken {\r\n if (!this.internalToken) {\r\n // be lazy and create the token only when\r\n // actually needed\r\n this.internalToken = new MutableToken();\r\n }\r\n\r\n return this.internalToken;\r\n }\r\n\r\n /**\r\n * Moves the token into a cancelled state.\r\n */\r\n cancel(): void {\r\n if (!this.internalToken) {\r\n // Save an object creation by returning the default cancelled\r\n // token when cancellation happens before someone asks for the\r\n // token.\r\n this.internalToken = CancellationTokenCancelled;\r\n\r\n }\r\n else if (this.internalToken instanceof MutableToken) {\r\n // Actually cancel the existing token.\r\n this.internalToken.cancel();\r\n }\r\n }\r\n}\r\n","// \r\n// Copyright by the Spark Development Network\r\n//\r\n// Licensed under the Rock Community License (the \"License\");\r\n// you may not use this file except in compliance with the License.\r\n// You may obtain a copy of the License at\r\n//\r\n// http://www.rockrms.com/license\r\n//\r\n// Unless required by applicable law or agreed to in writing, software\r\n// distributed under the License is distributed on an \"AS IS\" BASIS,\r\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n// See the License for the specific language governing permissions and\r\n// limitations under the License.\r\n// \r\n//\r\n\r\nimport { Guid } from \"@Obsidian/Types\";\r\nimport { newGuid } from \"./guid\";\r\nimport { inject, nextTick, provide } from \"vue\";\r\n\r\nconst suspenseSymbol = Symbol(\"RockSuspense\");\r\n\r\n/**\r\n * Defines the interface for a provider of suspense monitoring. These are used\r\n * to track asynchronous operations that components may be performing so the\r\n * watching component can perform an operation once all pending operations\r\n * have completed.\r\n */\r\nexport interface ISuspenseProvider {\r\n /**\r\n * Adds a new operation identified by the promise. When the promise\r\n * either resolves or fails the operation is considered completed.\r\n *\r\n * @param operation The promise that represents the operation.\r\n */\r\n addOperation(operation: Promise): void;\r\n\r\n /**\r\n * Notes that an asynchronous operation has started on a child component.\r\n *\r\n * @param key The key that identifies the operation.\r\n */\r\n startAsyncOperation(key: Guid): void;\r\n\r\n /**\r\n * Notes that an asynchrounous operation has completed on a child component.\r\n *\r\n * @param key The key that was previously passed to startAsyncOperation.\r\n */\r\n completeAsyncOperation(key: Guid): void;\r\n}\r\n\r\n/**\r\n * A basic provider that handles the guts of a suspense provider. This can be\r\n * used by components that need to know when child components have completed\r\n * their work.\r\n */\r\nexport class BasicSuspenseProvider implements ISuspenseProvider {\r\n private readonly operationKey: Guid;\r\n\r\n private readonly parentProvider: ISuspenseProvider | undefined;\r\n\r\n private readonly pendingOperations: Guid[];\r\n\r\n private finishedHandlers: (() => void)[];\r\n\r\n /**\r\n * Creates a new suspense provider.\r\n *\r\n * @param parentProvider The parent suspense provider that will be notified of pending operations.\r\n */\r\n constructor(parentProvider: ISuspenseProvider | undefined) {\r\n this.operationKey = newGuid();\r\n this.parentProvider = parentProvider;\r\n this.pendingOperations = [];\r\n this.finishedHandlers = [];\r\n }\r\n\r\n /**\r\n * Called when all pending operations are complete. Notifies all handlers\r\n * that the pending operations have completed as well as the parent provider.\r\n */\r\n private allOperationsComplete(): void {\r\n // Wait until the next Vue tick in case a new async operation started.\r\n // This can happen, for example, with defineAsyncComponent(). It will\r\n // complete its async operation (loading the JS file) and then the\r\n // component defined in the file might start an async operation. This\r\n // prevents us from completing too soon.\r\n nextTick(() => {\r\n // Verify nothing started a new asynchronous operation while we\r\n // we waiting for the next tick.\r\n if (this.pendingOperations.length !== 0) {\r\n return;\r\n }\r\n\r\n // Notify all pending handlers that all operations completed.\r\n for (const handler of this.finishedHandlers) {\r\n handler();\r\n }\r\n this.finishedHandlers = [];\r\n\r\n // Notify the parent that our own pending operation has completed.\r\n if (this.parentProvider) {\r\n this.parentProvider.completeAsyncOperation(this.operationKey);\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * Adds a new operation identified by the promise. When the promise\r\n * either resolves or fails the operation is considered completed.\r\n *\r\n * @param operation The promise that represents the operation.\r\n */\r\n public addOperation(operation: Promise): void {\r\n const operationKey = newGuid();\r\n\r\n this.startAsyncOperation(operationKey);\r\n\r\n operation.then(() => this.completeAsyncOperation(operationKey))\r\n .catch(() => this.completeAsyncOperation(operationKey));\r\n }\r\n\r\n /**\r\n * Notes that an asynchronous operation has started on a child component.\r\n *\r\n * @param key The key that identifies the operation.\r\n */\r\n public startAsyncOperation(key: Guid): void {\r\n this.pendingOperations.push(key);\r\n\r\n // If this is the first operation we started, notify the parent provider.\r\n if (this.pendingOperations.length === 1 && this.parentProvider) {\r\n this.parentProvider.startAsyncOperation(this.operationKey);\r\n }\r\n }\r\n\r\n /**\r\n * Notes that an asynchrounous operation has completed on a child component.\r\n *\r\n * @param key The key that was previously passed to startAsyncOperation.\r\n */\r\n public completeAsyncOperation(key: Guid): void {\r\n const index = this.pendingOperations.indexOf(key);\r\n\r\n if (index !== -1) {\r\n this.pendingOperations.splice(index, 1);\r\n }\r\n\r\n // If this was the last operation then send notifications.\r\n if (this.pendingOperations.length === 0) {\r\n this.allOperationsComplete();\r\n }\r\n }\r\n\r\n /**\r\n * Checks if this provider has any asynchronous operations that are still\r\n * pending completion.\r\n *\r\n * @returns true if there are pending operations; otherwise false.\r\n */\r\n public hasPendingOperations(): boolean {\r\n return this.pendingOperations.length > 0;\r\n }\r\n\r\n /**\r\n * Adds a new handler that is called when all pending operations have been\r\n * completed. This is a fire-once, meaning the callback will only be called\r\n * when the current pending operations have completed. If new operations\r\n * begin after the callback is executed it will not be called again unless\r\n * it is added with this method again.\r\n *\r\n * @param callback The function to call when all pending operations have completed.\r\n */\r\n public addFinishedHandler(callback: () => void): void {\r\n this.finishedHandlers.push(callback);\r\n }\r\n}\r\n\r\n/**\r\n * Provides a new suspense provider to any child components.\r\n *\r\n * @param provider The provider to make available to child components.\r\n */\r\nexport function provideSuspense(provider: ISuspenseProvider): void {\r\n provide(suspenseSymbol, provider);\r\n}\r\n\r\n/**\r\n * Uses the current suspense provider that was defined by any parent component.\r\n *\r\n * @returns The suspense provider if one was defined; otherwise undefined.\r\n */\r\nexport function useSuspense(): ISuspenseProvider | undefined {\r\n return inject(suspenseSymbol);\r\n}\r\n\r\n","// \r\n// Copyright by the Spark Development Network\r\n//\r\n// Licensed under the Rock Community License (the \"License\");\r\n// you may not use this file except in compliance with the License.\r\n// You may obtain a copy of the License at\r\n//\r\n// http://www.rockrms.com/license\r\n//\r\n// Unless required by applicable law or agreed to in writing, software\r\n// distributed under the License is distributed on an \"AS IS\" BASIS,\r\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n// See the License for the specific language governing permissions and\r\n// limitations under the License.\r\n// \r\n\r\nimport { CurrencyInfoBag } from \"../ViewModels/Rest/Utilities/currencyInfoBag\";\r\n\r\n// From https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat\r\n// Number.toLocaleString takes the same options as Intl.NumberFormat\r\n// Most of the options probably won't get used, so just add the ones you need to use to this when needed\r\ntype NumberFormatOptions = {\r\n useGrouping?: boolean // MDN gives other possible values, but TS is complaining that it should only be boolean\r\n};\r\n\r\n/**\r\n * Get a formatted string.\r\n * Ex: 10001.2 => 10,001.2\r\n * @param num\r\n */\r\nexport function asFormattedString(num: number | null, digits?: number, options: NumberFormatOptions = {}): string {\r\n if (num === null) {\r\n return \"\";\r\n }\r\n\r\n return num.toLocaleString(\r\n \"en-US\",\r\n {\r\n minimumFractionDigits: digits,\r\n maximumFractionDigits: digits ?? 9,\r\n ...options\r\n }\r\n );\r\n}\r\n\r\n/**\r\n * Get a number value from a formatted string. If the number cannot be parsed, then zero is returned by default.\r\n * Ex: $1,000.20 => 1000.2\r\n * @param str\r\n */\r\nexport function toNumber(str?: string | number | null): number {\r\n return toNumberOrNull(str) || 0;\r\n}\r\n\r\n/**\r\n * Get a number value from a formatted string. If the number cannot be parsed, then null is returned by default.\r\n * Ex: $1,000.20 => 1000.2\r\n * @param str\r\n */\r\nexport function toNumberOrNull(str?: string | number | null): number | null {\r\n if (str === null || str === undefined || str === \"\") {\r\n return null;\r\n }\r\n\r\n if (typeof str === \"number\") {\r\n return str;\r\n }\r\n\r\n const replaced = str.replace(/[$,]/g, \"\");\r\n const num = Number(replaced);\r\n\r\n return !isNaN(num) ? num : null;\r\n}\r\n\r\n/**\r\n * Get a currency value from a string or number. If the number cannot be parsed, then null is returned by default.\r\n * Ex: 1000.20 => $1,000.20\r\n * @param value The value to be converted to a currency.\r\n */\r\nexport function toCurrencyOrNull(value?: string | number | null, currencyInfo: CurrencyInfoBag | null = null): string | null {\r\n if (typeof value === \"string\") {\r\n value = toNumberOrNull(value);\r\n }\r\n\r\n if (value === null || value === undefined) {\r\n return null;\r\n }\r\n const currencySymbol = currencyInfo?.symbol ?? \"$\";\r\n const currencyDecimalPlaces = currencyInfo?.decimalPlaces ?? 2;\r\n return `${currencySymbol}${asFormattedString(value, currencyDecimalPlaces)}`;\r\n}\r\n\r\n/**\r\n * Adds an ordinal suffix.\r\n * Ex: 1 => 1st\r\n * @param num\r\n */\r\nexport function toOrdinalSuffix(num?: number | null): string {\r\n if (!num) {\r\n return \"\";\r\n }\r\n\r\n const j = num % 10;\r\n const k = num % 100;\r\n\r\n if (j == 1 && k != 11) {\r\n return num + \"st\";\r\n }\r\n if (j == 2 && k != 12) {\r\n return num + \"nd\";\r\n }\r\n if (j == 3 && k != 13) {\r\n return num + \"rd\";\r\n }\r\n return num + \"th\";\r\n}\r\n\r\n/**\r\n * Convert a number to an ordinal.\r\n * Ex: 1 => first\r\n * @param num\r\n */\r\nexport function toOrdinal(num?: number | null): string {\r\n if (!num) {\r\n return \"\";\r\n }\r\n\r\n switch (num) {\r\n case 1: return \"first\";\r\n case 2: return \"second\";\r\n case 3: return \"third\";\r\n case 4: return \"fourth\";\r\n case 5: return \"fifth\";\r\n case 6: return \"sixth\";\r\n case 7: return \"seventh\";\r\n case 8: return \"eighth\";\r\n case 9: return \"ninth\";\r\n case 10: return \"tenth\";\r\n default: return toOrdinalSuffix(num);\r\n }\r\n}\r\n\r\n/**\r\n * Convert a number to a word.\r\n * Ex: 1 => one\r\n * @param num\r\n */\r\nexport function toWord(num?: number | null): string {\r\n if (num === null || num === undefined) {\r\n return \"\";\r\n }\r\n\r\n switch (num) {\r\n case 1: return \"one\";\r\n case 2: return \"two\";\r\n case 3: return \"three\";\r\n case 4: return \"four\";\r\n case 5: return \"five\";\r\n case 6: return \"six\";\r\n case 7: return \"seven\";\r\n case 8: return \"eight\";\r\n case 9: return \"nine\";\r\n case 10: return \"ten\";\r\n default: return `${num}`;\r\n }\r\n}\r\n\r\nexport function zeroPad(num: number, length: number): string {\r\n let str = num.toString();\r\n\r\n while (str.length < length) {\r\n str = \"0\" + str;\r\n }\r\n\r\n return str;\r\n}\r\n\r\nexport function toDecimalPlaces(num: number, decimalPlaces: number): number {\r\n decimalPlaces = Math.floor(decimalPlaces); // ensure it's an integer\r\n\r\n return Math.round(num * 10 ** decimalPlaces) / 10 ** decimalPlaces;\r\n}\r\n\r\nexport default {\r\n toOrdinal,\r\n toOrdinalSuffix,\r\n toNumberOrNull,\r\n asFormattedString\r\n};\r\n","// \r\n// Copyright by the Spark Development Network\r\n//\r\n// Licensed under the Rock Community License (the \"License\");\r\n// you may not use this file except in compliance with the License.\r\n// You may obtain a copy of the License at\r\n//\r\n// http://www.rockrms.com/license\r\n//\r\n// Unless required by applicable law or agreed to in writing, software\r\n// distributed under the License is distributed on an \"AS IS\" BASIS,\r\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n// See the License for the specific language governing permissions and\r\n// limitations under the License.\r\n// \r\n\r\nimport { AsyncComponentLoader, Component, ComponentPublicInstance, defineAsyncComponent as vueDefineAsyncComponent, ExtractPropTypes, PropType, reactive, ref, Ref, VNode, watch, WatchOptions, render, isVNode, createVNode } from \"vue\";\r\nimport { deepEqual } from \"./util\";\r\nimport { useSuspense } from \"./suspense\";\r\nimport { newGuid } from \"./guid\";\r\nimport { ControlLazyMode } from \"@Obsidian/Enums/Controls/controlLazyMode\";\r\nimport { PickerDisplayStyle } from \"@Obsidian/Enums/Controls/pickerDisplayStyle\";\r\nimport { ExtendedRef, ExtendedRefContext } from \"@Obsidian/Types/Utility/component\";\r\nimport type { RulesPropType, ValidationRule } from \"@Obsidian/Types/validationRules\";\r\nimport { toNumberOrNull } from \"./numberUtils\";\r\n\r\ntype Prop = { [key: string]: unknown };\r\ntype PropKey = Extract;\r\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\r\ntype EmitFn = E extends Array ? (event: EE, ...args: any[]) => void : (event: E, ...args: any[]) => void;\r\n\r\n/**\r\n * Utility function for when you are using a component that takes a v-model\r\n * and uses that model as a v-model in that component's template. It creates\r\n * a new ref that keeps itself up-to-date with the given model and fires an\r\n * 'update:MODELNAME' event when it gets changed.\r\n *\r\n * Ensure the related `props` and `emits` are specified to ensure there are\r\n * no type issues.\r\n */\r\nexport function useVModelPassthrough, E extends `update:${K}`>(props: T, modelName: K, emit: EmitFn, options?: WatchOptions): Ref {\r\n const internalValue = ref(props[modelName]) as Ref;\r\n\r\n watch(() => props[modelName], val => updateRefValue(internalValue, val), options);\r\n watch(internalValue, val => {\r\n if (val !== props[modelName]) {\r\n emit(`update:${modelName}`, val);\r\n }\r\n }, options);\r\n\r\n return internalValue;\r\n}\r\n\r\n/**\r\n * Utility function for when you are using a component that takes a v-model\r\n * and uses that model as a v-model in that component's template. It creates\r\n * a new ref that keeps itself up-to-date with the given model and fires an\r\n * 'update:MODELNAME' event when it gets changed. It also gives a means of watching\r\n * the model prop for any changes (verifies that the prop change is different than\r\n * the current value first)\r\n *\r\n * Ensure the related `props` and `emits` are specified to ensure there are\r\n * no type issues.\r\n */\r\nexport function useVModelPassthroughWithPropUpdateCheck, E extends `update:${K}`>(props: T, modelName: K, emit: EmitFn, options?: WatchOptions): [Ref, (fn: () => unknown) => void] {\r\n const internalValue = ref(props[modelName]) as Ref;\r\n const listeners: (() => void)[] = [];\r\n\r\n watch(() => props[modelName], val => {\r\n if (updateRefValue(internalValue, val)) {\r\n onPropUpdate();\r\n }\r\n }, options);\r\n watch(internalValue, val => emit(`update:${modelName}`, val), options);\r\n\r\n function onPropUpdate(): void {\r\n listeners.forEach(fn => fn());\r\n }\r\n\r\n function addPropUpdateListener(fn: () => unknown): void {\r\n listeners.push(fn);\r\n }\r\n\r\n return [internalValue, addPropUpdateListener];\r\n}\r\n\r\n/**\r\n * Updates the Ref value, but only if the new value is actually different than\r\n * the current value. A deep comparison is performed.\r\n *\r\n * @param target The target Ref object to be updated.\r\n * @param value The new value to be assigned to the target.\r\n *\r\n * @returns True if the target was updated, otherwise false.\r\n */\r\nexport function updateRefValue(target: Ref, value: TV): boolean {\r\n if (deepEqual(target.value, value, true)) {\r\n return false;\r\n }\r\n\r\n target.value = value;\r\n\r\n return true;\r\n}\r\n\r\n/**\r\n * Defines a component that will be loaded asynchronously. This contains logic\r\n * to properly work with the RockSuspense control.\r\n *\r\n * @param source The function to call to load the component.\r\n *\r\n * @returns The component that was loaded.\r\n */\r\nexport function defineAsyncComponent(source: AsyncComponentLoader): T {\r\n return vueDefineAsyncComponent(async () => {\r\n const suspense = useSuspense();\r\n const operationKey = newGuid();\r\n\r\n suspense?.startAsyncOperation(operationKey);\r\n const component = await source();\r\n suspense?.completeAsyncOperation(operationKey);\r\n\r\n return component;\r\n });\r\n}\r\n\r\n// #region Standard Form Field\r\n\r\ntype StandardRockFormFieldProps = {\r\n label: {\r\n type: PropType,\r\n default: \"\"\r\n },\r\n\r\n help: {\r\n type: PropType,\r\n default: \"\"\r\n },\r\n\r\n rules: RulesPropType,\r\n\r\n formGroupClasses: {\r\n type: PropType,\r\n default: \"\"\r\n },\r\n\r\n validationTitle: {\r\n type: PropType,\r\n default: \"\"\r\n },\r\n\r\n isRequiredIndicatorHidden: {\r\n type: PropType,\r\n default: false\r\n }\r\n};\r\n\r\n/** The standard component props that should be included when using RockFormField. */\r\nexport const standardRockFormFieldProps: StandardRockFormFieldProps = {\r\n label: {\r\n type: String as PropType,\r\n default: \"\"\r\n },\r\n\r\n help: {\r\n type: String as PropType,\r\n default: \"\"\r\n },\r\n\r\n rules: {\r\n type: [Array, Object, String] as PropType,\r\n default: \"\"\r\n },\r\n\r\n formGroupClasses: {\r\n type: String as PropType,\r\n default: \"\"\r\n },\r\n\r\n validationTitle: {\r\n type: String as PropType,\r\n default: \"\"\r\n },\r\n\r\n isRequiredIndicatorHidden: {\r\n type: Boolean as PropType,\r\n default: false\r\n }\r\n};\r\n\r\n/**\r\n * Copies the known properties for the standard rock form field props from\r\n * the source object to the destination object.\r\n *\r\n * @param source The source object to copy the values from.\r\n * @param destination The destination object to copy the values to.\r\n */\r\nfunction copyStandardRockFormFieldProps(source: ExtractPropTypes, destination: ExtractPropTypes): void {\r\n destination.formGroupClasses = source.formGroupClasses;\r\n destination.help = source.help;\r\n destination.label = source.label;\r\n destination.rules = source.rules;\r\n destination.validationTitle = source.validationTitle;\r\n}\r\n\r\n/**\r\n * Configures the basic properties that should be passed to the RockFormField\r\n * component. The value returned by this function should be used with v-bind on\r\n * the RockFormField in order to pass all the defined prop values to it.\r\n *\r\n * @param props The props of the component that will be using the RockFormField.\r\n *\r\n * @returns An object of prop values that can be used with v-bind.\r\n */\r\nexport function useStandardRockFormFieldProps(props: ExtractPropTypes): ExtractPropTypes {\r\n const propValues = reactive>({\r\n label: props.label,\r\n help: props.help,\r\n rules: props.rules,\r\n formGroupClasses: props.formGroupClasses,\r\n validationTitle: props.validationTitle,\r\n isRequiredIndicatorHidden: props.isRequiredIndicatorHidden\r\n });\r\n\r\n watch([() => props.formGroupClasses, () => props.help, () => props.label, () => props.rules, () => props.validationTitle], () => {\r\n copyStandardRockFormFieldProps(props, propValues);\r\n });\r\n\r\n return propValues;\r\n}\r\n\r\n// #endregion\r\n\r\n// #region Standard Async Pickers\r\n\r\ntype StandardAsyncPickerProps = StandardRockFormFieldProps & {\r\n /** Enhance the picker for dealing with long lists by providing a search mechanism. */\r\n enhanceForLongLists: {\r\n type: PropType,\r\n default: false\r\n },\r\n\r\n /** The method the picker should use to load data. */\r\n lazyMode: {\r\n type: PropType,\r\n default: \"onDemand\"\r\n },\r\n\r\n /** True if the picker should allow multiple items to be selected. */\r\n multiple: {\r\n type: PropType,\r\n default: false\r\n },\r\n\r\n /** True if the picker should allow empty selections. */\r\n showBlankItem: {\r\n type: PropType,\r\n default: false\r\n },\r\n\r\n /** The optional value to show when `showBlankItem` is `true`. */\r\n blankValue: {\r\n type: PropType,\r\n default: \"\"\r\n },\r\n\r\n /** The visual style to use when displaying the picker. */\r\n displayStyle: {\r\n type: PropType,\r\n default: \"auto\"\r\n },\r\n\r\n /** The number of columns to use when displaying the items in a list. */\r\n columnCount: {\r\n type: PropType,\r\n default: 0\r\n }\r\n};\r\n\r\n/** The standard component props that should be included when using BaseAsyncPicker. */\r\nexport const standardAsyncPickerProps: StandardAsyncPickerProps = {\r\n ...standardRockFormFieldProps,\r\n\r\n enhanceForLongLists: {\r\n type: Boolean as PropType,\r\n default: false\r\n },\r\n\r\n lazyMode: {\r\n type: String as PropType,\r\n default: ControlLazyMode.OnDemand\r\n },\r\n\r\n multiple: {\r\n type: Boolean as PropType,\r\n default: false\r\n },\r\n\r\n showBlankItem: {\r\n type: Boolean as PropType,\r\n default: false\r\n },\r\n\r\n blankValue: {\r\n type: String as PropType,\r\n default: \"\"\r\n },\r\n\r\n displayStyle: {\r\n type: String as PropType,\r\n default: PickerDisplayStyle.Auto\r\n },\r\n\r\n columnCount: {\r\n type: Number as PropType,\r\n default: 0\r\n }\r\n};\r\n\r\n/**\r\n * Copies the known properties for the standard async picker props from\r\n * the source object to the destination object.\r\n *\r\n * @param source The source object to copy the values from.\r\n * @param destination The destination object to copy the values to.\r\n */\r\nfunction copyStandardAsyncPickerProps(source: ExtractPropTypes, destination: ExtractPropTypes): void {\r\n copyStandardRockFormFieldProps(source, destination);\r\n\r\n destination.enhanceForLongLists = source.enhanceForLongLists;\r\n destination.lazyMode = source.lazyMode;\r\n destination.multiple = source.multiple;\r\n destination.showBlankItem = source.showBlankItem;\r\n destination.blankValue = source.blankValue;\r\n destination.displayStyle = source.displayStyle;\r\n destination.columnCount = source.columnCount;\r\n}\r\n\r\n/**\r\n * Configures the basic properties that should be passed to the BaseAsyncPicker\r\n * component. The value returned by this function should be used with v-bind on\r\n * the BaseAsyncPicker in order to pass all the defined prop values to it.\r\n *\r\n * @param props The props of the component that will be using the BaseAsyncPicker.\r\n *\r\n * @returns An object of prop values that can be used with v-bind.\r\n */\r\nexport function useStandardAsyncPickerProps(props: ExtractPropTypes): ExtractPropTypes {\r\n const standardFieldProps = useStandardRockFormFieldProps(props);\r\n\r\n const propValues = reactive>({\r\n ...standardFieldProps,\r\n enhanceForLongLists: props.enhanceForLongLists,\r\n lazyMode: props.lazyMode,\r\n multiple: props.multiple,\r\n showBlankItem: props.showBlankItem,\r\n blankValue: props.blankValue,\r\n displayStyle: props.displayStyle,\r\n columnCount: props.columnCount\r\n });\r\n\r\n // Watch for changes in any of the standard props. Use deep for this so we\r\n // don't need to know which prop keys it actually contains.\r\n watch(() => standardFieldProps, () => {\r\n copyStandardRockFormFieldProps(props, propValues);\r\n }, {\r\n deep: true\r\n });\r\n\r\n // Watch for changes in our known list of props that might change.\r\n watch([() => props.enhanceForLongLists, () => props.lazyMode, () => props.multiple, () => props.showBlankItem, () => props.displayStyle, () => props.columnCount], () => {\r\n copyStandardAsyncPickerProps(props, propValues);\r\n });\r\n\r\n return propValues;\r\n}\r\n\r\n// #endregion\r\n\r\n// #region Extended References\r\n\r\n/**\r\n * Creates a Ref that contains extended data to better identify this ref\r\n * when you have multiple refs to work with.\r\n *\r\n * @param value The initial value of the Ref.\r\n * @param extendedData The additional context data to put on the Ref.\r\n *\r\n * @returns An ExtendedRef object that can be used like a regular Ref object.\r\n */\r\nexport function extendedRef(value: T, context: ExtendedRefContext): ExtendedRef {\r\n const refValue = ref(value) as ExtendedRef;\r\n\r\n refValue.context = context;\r\n\r\n return refValue;\r\n}\r\n\r\n/**\r\n * Creates an extended Ref with the specified property name in the context.\r\n *\r\n * @param value The initial value of the Ref.\r\n * @param propertyName The property name to use for the context.\r\n *\r\n * @returns An ExtendedRef object that can be used like a regular Ref object.\r\n */\r\nexport function propertyRef(value: T, propertyName: string): ExtendedRef {\r\n return extendedRef(value, {\r\n propertyName\r\n });\r\n}\r\n\r\n// #endregion Extended Refs\r\n\r\n// #region VNode Helpers\r\n\r\n/**\r\n * Retrieves a single prop value from a VNode object. If the prop is explicitely\r\n * specified in the DOM then it will be returned. Otherwise the component's\r\n * prop default values are checked. If there is a default value it will be\r\n * returned.\r\n *\r\n * @param node The node whose property value is being requested.\r\n * @param propName The name of the property whose value is being requested.\r\n *\r\n * @returns The value of the property or `undefined` if it was not set.\r\n */\r\nexport function getVNodeProp(node: VNode, propName: string): T | undefined {\r\n // Check if the prop was specified in the DOM declaration.\r\n if (node.props && node.props[propName] !== undefined) {\r\n return node.props[propName] as T;\r\n }\r\n\r\n // Now look to see if the backing component has defined a prop with that\r\n // name and provided a default value.\r\n if (typeof node.type === \"object\" && typeof node.type[\"props\"] === \"object\") {\r\n const defaultProps = node.type[\"props\"] as Record;\r\n const defaultProp = defaultProps[propName];\r\n\r\n if (defaultProp && typeof defaultProp === \"object\" && defaultProp[\"default\"] !== undefined) {\r\n return defaultProp[\"default\"] as T;\r\n }\r\n }\r\n\r\n return undefined;\r\n}\r\n\r\n/**\r\n * Retrieves all prop values from a VNode object. First all default values\r\n * from the component are retrieved. Then any specified on the DOM will be used\r\n * to override those default values.\r\n *\r\n * @param node The node whose property values are being requested.\r\n *\r\n * @returns An object that contains all props and values for the node.\r\n */\r\nexport function getVNodeProps(node: VNode): Record {\r\n const props: Record = {};\r\n\r\n // Get all default values from the backing component's defined props.\r\n if (typeof node.type === \"object\" && typeof node.type[\"props\"] === \"object\") {\r\n const defaultProps = node.type[\"props\"] as Record;\r\n\r\n for (const p in defaultProps) {\r\n const defaultProp = defaultProps[p];\r\n\r\n if (defaultProp && typeof defaultProp === \"object\" && defaultProp[\"default\"] !== undefined) {\r\n props[p] = defaultProp[\"default\"];\r\n }\r\n }\r\n }\r\n\r\n // Override with any values specified on the DOM declaration.\r\n if (node.props) {\r\n for (const p in node.props) {\r\n if (typeof node.type === \"object\" && typeof node.type[\"props\"] === \"object\") {\r\n const propType = node.type[\"props\"][p]?.type;\r\n\r\n if (propType === Boolean) {\r\n props[p] = node.props[p] === true || node.props[p] === \"\";\r\n }\r\n else if (propType === Number) {\r\n props[p] = toNumberOrNull(node.props[p]) ?? undefined;\r\n }\r\n else {\r\n props[p] = node.props[p];\r\n }\r\n }\r\n else {\r\n props[p] = node.props[p];\r\n }\r\n }\r\n }\r\n\r\n return props;\r\n}\r\n\r\n/**\r\n * Renders the node into an off-screen div and then extracts the text content\r\n * by way of the innerText property of the div.\r\n *\r\n * @param node The node or component to be rendered.\r\n * @param props The properties to be passed to the component when it is mounted.\r\n *\r\n * @returns The text content of the node after it has rendered.\r\n */\r\nexport function extractText(node: VNode | Component, props?: Record): string {\r\n const el = document.createElement(\"div\");\r\n\r\n // Create a new virtual node with the specified properties.\r\n const vnode = createVNode(node, props);\r\n\r\n // Mount the node in our off-screen container.\r\n render(vnode, el);\r\n\r\n const text = el.innerText;\r\n\r\n // Unmount it.\r\n render(null, el);\r\n\r\n return text.trim();\r\n}\r\n\r\n/**\r\n * Renders the node into an off-screen div and then extracts the HTML content\r\n * by way of the innerHTML property of the div.\r\n *\r\n * @param node The node or component to be rendered.\r\n * @param props The properties to be passed to the component when it is mounted.\r\n *\r\n * @returns The HTML content of the node after it has rendered.\r\n */\r\nexport function extractHtml(node: VNode | Component, props?: Record): string {\r\n const el = document.createElement(\"div\");\r\n\r\n // Create a new virtual node with the specified properties.\r\n const vnode = createVNode(node, props);\r\n\r\n // Mount the node in our off-screen container.\r\n render(vnode, el);\r\n\r\n const html = el.innerHTML;\r\n\r\n // Unmount it.\r\n render(null, el);\r\n\r\n return html;\r\n}\r\n\r\n// #endregion\r\n","// \r\n// Copyright by the Spark Development Network\r\n//\r\n// Licensed under the Rock Community License (the \"License\");\r\n// you may not use this file except in compliance with the License.\r\n// You may obtain a copy of the License at\r\n//\r\n// http://www.rockrms.com/license\r\n//\r\n// Unless required by applicable law or agreed to in writing, software\r\n// distributed under the License is distributed on an \"AS IS\" BASIS,\r\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n// See the License for the specific language governing permissions and\r\n// limitations under the License.\r\n// \r\n//\r\n\r\nimport { toNumberOrNull, zeroPad } from \"./numberUtils\";\r\nconst dateKeyLength = \"YYYYMMDD\".length;\r\nconst dateKeyNoYearLength = \"MMDD\".length;\r\n\r\n/**\r\n * Gets the year value from the date key.\r\n * Ex: 20210228 => 2021\r\n * @param dateKey\r\n */\r\nexport function getYear(dateKey: string | null): number {\r\n const defaultValue = 0;\r\n\r\n if (!dateKey || dateKey.length !== dateKeyLength) {\r\n return defaultValue;\r\n }\r\n\r\n const asString = dateKey.substring(0, 4);\r\n const year = toNumberOrNull(asString) || defaultValue;\r\n return year;\r\n}\r\n\r\n/**\r\n * Gets the month value from the date key.\r\n * Ex: 20210228 => 2\r\n * @param dateKey\r\n */\r\nexport function getMonth(dateKey: string | null): number {\r\n const defaultValue = 0;\r\n\r\n if (!dateKey) {\r\n return defaultValue;\r\n }\r\n\r\n if (dateKey.length === dateKeyLength) {\r\n const asString = dateKey.substring(4, 6);\r\n return toNumberOrNull(asString) || defaultValue;\r\n }\r\n\r\n if (dateKey.length === dateKeyNoYearLength) {\r\n const asString = dateKey.substring(0, 2);\r\n return toNumberOrNull(asString) || defaultValue;\r\n }\r\n\r\n return defaultValue;\r\n}\r\n\r\n/**\r\n * Gets the day value from the date key.\r\n * Ex: 20210228 => 28\r\n * @param dateKey\r\n */\r\nexport function getDay(dateKey: string | null): number {\r\n const defaultValue = 0;\r\n\r\n if (!dateKey) {\r\n return defaultValue;\r\n }\r\n\r\n if (dateKey.length === dateKeyLength) {\r\n const asString = dateKey.substring(6, 8);\r\n return toNumberOrNull(asString) || defaultValue;\r\n }\r\n\r\n if (dateKey.length === dateKeyNoYearLength) {\r\n const asString = dateKey.substring(2, 4);\r\n return toNumberOrNull(asString) || defaultValue;\r\n }\r\n\r\n return defaultValue;\r\n}\r\n\r\n/**\r\n * Gets the datekey constructed from the parts.\r\n * Ex: (2021, 2, 28) => '20210228'\r\n * @param year\r\n * @param month\r\n * @param day\r\n */\r\nexport function toDateKey(year: number | null, month: number | null, day: number | null): string {\r\n if (!year || year > 9999 || year < 0) {\r\n year = 0;\r\n }\r\n\r\n if (!month || month > 12 || month < 0) {\r\n month = 0;\r\n }\r\n\r\n if (!day || day > 31 || day < 0) {\r\n day = 0;\r\n }\r\n\r\n const yearStr = zeroPad(year, 4);\r\n const monthStr = zeroPad(month, 2);\r\n const dayStr = zeroPad(day, 2);\r\n\r\n return `${yearStr}${monthStr}${dayStr}`;\r\n}\r\n\r\n/**\r\n * Gets the datekey constructed from the parts.\r\n * Ex: (2, 28) => '0228'\r\n * @param month\r\n * @param day\r\n */\r\nexport function toNoYearDateKey(month: number | null, day: number | null): string {\r\n if (!month || month > 12 || month < 0) {\r\n month = 0;\r\n }\r\n\r\n if (!day || day > 31 || day < 0) {\r\n day = 0;\r\n }\r\n\r\n const monthStr = zeroPad(month, 2);\r\n const dayStr = zeroPad(day, 2);\r\n\r\n return `${monthStr}${dayStr}`;\r\n}\r\n\r\nexport default {\r\n getYear,\r\n getMonth,\r\n getDay,\r\n toDateKey,\r\n toNoYearDateKey\r\n};\r\n","// \r\n// Copyright by the Spark Development Network\r\n//\r\n// Licensed under the Rock Community License (the \"License\");\r\n// you may not use this file except in compliance with the License.\r\n// You may obtain a copy of the License at\r\n//\r\n// http://www.rockrms.com/license\r\n//\r\n// Unless required by applicable law or agreed to in writing, software\r\n// distributed under the License is distributed on an \"AS IS\" BASIS,\r\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n// See the License for the specific language governing permissions and\r\n// limitations under the License.\r\n// \r\n//\r\n\r\nimport { Guid } from \"@Obsidian/Types\";\r\nimport { CurrentPersonBag } from \"@Obsidian/ViewModels/Crm/currentPersonBag\";\r\n\r\nexport type PageConfig = {\r\n executionStartTime: number;\r\n pageId: number;\r\n pageGuid: Guid;\r\n pageParameters: Record;\r\n currentPerson: CurrentPersonBag | null;\r\n isAnonymousVisitor: boolean;\r\n loginUrlWithReturnUrl: string;\r\n};\r\n\r\nexport function smoothScrollToTop(): void {\r\n window.scrollTo({ top: 0, behavior: \"smooth\" });\r\n}\r\n\r\nexport default {\r\n smoothScrollToTop\r\n};\r\n\r\n// eslint-disable-next-line @typescript-eslint/naming-convention, @typescript-eslint/no-explicit-any\r\ndeclare const Obsidian: any;\r\n\r\n\r\n/*\r\n * Code to handle working with modals.\r\n */\r\nlet currentModalCount = 0;\r\n\r\n/**\r\n * Track a modal being opened or closed. This is used to adjust the page in response\r\n * to any modals being visible.\r\n *\r\n * @param state true if the modal is now open, false if it is now closed.\r\n */\r\nexport function trackModalState(state: boolean): void {\r\n const body = document.body;\r\n const cssClasses = [\"modal-open\"];\r\n\r\n if (state) {\r\n currentModalCount++;\r\n }\r\n else {\r\n currentModalCount = currentModalCount > 0 ? currentModalCount - 1 : 0;\r\n }\r\n\r\n if (currentModalCount > 0) {\r\n for (const cssClass of cssClasses) {\r\n body.classList.add(cssClass);\r\n }\r\n }\r\n else {\r\n for (const cssClass of cssClasses) {\r\n body.classList.remove(cssClass);\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * Loads a JavaScript file asynchronously into the document and returns a\r\n * Promise that can be used to determine when the script has loaded. The\r\n * promise will return true if the script loaded successfully or false if it\r\n * failed to load.\r\n *\r\n * The function passed in isScriptLoaded will be called before the script is\r\n * inserted into the DOM as well as after to make sure it actually loaded.\r\n *\r\n * @param source The source URL of the script to be loaded.\r\n * @param isScriptLoaded An optional function to call to determine if the script is loaded.\r\n * @param attributes An optional set of attributes to apply to the script tag.\r\n * @param fingerprint If set to false, then a fingerprint will not be added to the source URL. Default is true.\r\n *\r\n * @returns A Promise that indicates if the script was loaded or not.\r\n */\r\nexport async function loadJavaScriptAsync(source: string, isScriptLoaded?: () => boolean, attributes?: Record, fingerprint?: boolean): Promise {\r\n let src = source;\r\n\r\n // Add the cache busting fingerprint if we have one.\r\n if (fingerprint !== false && typeof Obsidian !== \"undefined\" && Obsidian?.options?.fingerprint) {\r\n if (src.indexOf(\"?\") === -1) {\r\n src += `?${Obsidian.options.fingerprint}`;\r\n }\r\n else {\r\n src += `&${Obsidian.options.fingerprint}`;\r\n }\r\n }\r\n\r\n // Check if the script is already loaded. First see if we have a custom\r\n // function that will do the check. Otherwise fall back to looking for any\r\n // script tags that have the same source.\r\n if (isScriptLoaded) {\r\n if (isScriptLoaded()) {\r\n return true;\r\n }\r\n }\r\n\r\n // Make sure the script wasn't already added in some other way.\r\n const scripts = Array.from(document.getElementsByTagName(\"script\"));\r\n const thisScript = scripts.filter(s => s.src === src);\r\n\r\n if (thisScript.length > 0) {\r\n const promise = scriptLoadedPromise(thisScript[0]);\r\n return promise;\r\n }\r\n\r\n // Build the script tag that will be dynamically loaded.\r\n const script = document.createElement(\"script\");\r\n script.type = \"text/javascript\";\r\n script.src = src;\r\n if (attributes) {\r\n for (const key in attributes) {\r\n script.setAttribute(key, attributes[key]);\r\n }\r\n }\r\n\r\n // Load the script.\r\n const promise = scriptLoadedPromise(script);\r\n document.getElementsByTagName(\"head\")[0].appendChild(script);\r\n\r\n return promise;\r\n\r\n async function scriptLoadedPromise(scriptElement: HTMLScriptElement): Promise {\r\n try {\r\n await new Promise((resolve, reject) => {\r\n scriptElement.addEventListener(\"load\", () => resolve());\r\n scriptElement.addEventListener(\"error\", () => {\r\n reject();\r\n });\r\n });\r\n\r\n // If we have a custom function, call it to see if the script loaded correctly.\r\n if (isScriptLoaded) {\r\n return isScriptLoaded();\r\n }\r\n\r\n return true;\r\n }\r\n catch {\r\n return false;\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * Adds a new link to the quick return action menu. The URL in the address bar\r\n * will be used as the destination.\r\n *\r\n * @param title The title of the quick link that identifies the current page.\r\n * @param section The section title to place this link into.\r\n * @param sectionOrder The priority order to give the section if it doesn't already exist.\r\n */\r\nexport function addQuickReturn(title: string, section: string, sectionOrder?: number): void {\r\n interface IRock {\r\n personalLinks: {\r\n addQuickReturn: (type: string, typeOrder: number, itemName: string) => void\r\n }\r\n }\r\n \r\n const rock = window[\"Rock\"] as IRock;\r\n if (rock && rock.personalLinks) {\r\n rock.personalLinks.addQuickReturn(section, sectionOrder ?? 0, title);\r\n }\r\n}\r\n","// \r\n// Copyright by the Spark Development Network\r\n//\r\n// Licensed under the Rock Community License (the \"License\");\r\n// you may not use this file except in compliance with the License.\r\n// You may obtain a copy of the License at\r\n//\r\n// http://www.rockrms.com/license\r\n//\r\n// Unless required by applicable law or agreed to in writing, software\r\n// distributed under the License is distributed on an \"AS IS\" BASIS,\r\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n// See the License for the specific language governing permissions and\r\n// limitations under the License.\r\n// \r\n//\r\n\r\nimport { Guid } from \"@Obsidian/Types\";\r\nimport { trackModalState } from \"./page\";\r\n\r\n// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/naming-convention\r\ndeclare const Rock: any;\r\n\r\ntype DialogOptions = {\r\n message: string;\r\n buttons: ButtonOptions[];\r\n container?: string | Element;\r\n};\r\n\r\ntype ButtonOptions = {\r\n key: string;\r\n label: string;\r\n className: string;\r\n};\r\n\r\n/**\r\n * Creates a dialog to display a message.\r\n *\r\n * @param body The body content to put in the dialog.\r\n * @param footer The footer content to put in the dialog.\r\n *\r\n * @returns An element that should be added to the body.\r\n */\r\nfunction createDialog(body: HTMLElement | HTMLElement[], footer: HTMLElement | HTMLElement[] | undefined): HTMLElement {\r\n // Create the scrollable container that will act as a backdrop for the dialog.\r\n const scrollable = document.createElement(\"div\");\r\n scrollable.classList.add(\"modal-scrollable\");\r\n scrollable.style.zIndex = \"1060\";\r\n\r\n // Create the modal that will act as a container for the outer content.\r\n const modal = document.createElement(\"div\");\r\n scrollable.appendChild(modal);\r\n modal.classList.add(\"modal\", \"fade\");\r\n modal.tabIndex = -1;\r\n modal.setAttribute(\"role\", \"dialog\");\r\n modal.setAttribute(\"aria-hidden\", \"false\");\r\n modal.style.display = \"block\";\r\n\r\n // Create the inner dialog of the modal.\r\n const modalDialog = document.createElement(\"div\");\r\n modal.appendChild(modalDialog);\r\n modalDialog.classList.add(\"modal-dialog\");\r\n\r\n // Create the container for the inner content.\r\n const modalContent = document.createElement(\"div\");\r\n modalDialog.appendChild(modalContent);\r\n modalContent.classList.add(\"modal-content\");\r\n\r\n // Create the container for the body content.\r\n const modalBody = document.createElement(\"div\");\r\n modalContent.appendChild(modalBody);\r\n modalBody.classList.add(\"modal-body\");\r\n\r\n // Add all the body elements to the body.\r\n if (Array.isArray(body)) {\r\n for (const el of body) {\r\n modalBody.appendChild(el);\r\n }\r\n }\r\n else {\r\n modalBody.appendChild(body);\r\n }\r\n\r\n // If we have any footer content then create a footer.\r\n if (footer && (!Array.isArray(footer) || footer.length > 0)) {\r\n const modalFooter = document.createElement(\"div\");\r\n modalContent.appendChild(modalFooter);\r\n modalFooter.classList.add(\"modal-footer\");\r\n\r\n // Add all the footer elements to the footer.\r\n if (Array.isArray(footer)) {\r\n for (const el of footer) {\r\n modalFooter.appendChild(el);\r\n }\r\n }\r\n else {\r\n modalFooter.appendChild(footer);\r\n }\r\n }\r\n\r\n // Add a click handler to the background so the user gets feedback\r\n // that they can't just click away from the dialog.\r\n scrollable.addEventListener(\"click\", () => {\r\n modal.classList.remove(\"animated\", \"shake\");\r\n setTimeout(() => {\r\n modal.classList.add(\"animated\", \"shake\");\r\n }, 0);\r\n });\r\n\r\n return scrollable;\r\n}\r\n\r\n/**\r\n * Construct a standard close button to be placed in the dialog.\r\n *\r\n * @returns A button element.\r\n */\r\nfunction createCloseButton(): HTMLButtonElement {\r\n const closeButton = document.createElement(\"button\");\r\n closeButton.classList.add(\"close\");\r\n closeButton.type = \"button\";\r\n closeButton.style.marginTop = \"-10px\";\r\n closeButton.innerHTML = \"×\";\r\n\r\n return closeButton;\r\n}\r\n\r\n/**\r\n * Creates a standard backdrop element to be placed in the window.\r\n *\r\n * @returns An element to show that the background is not active.\r\n */\r\nfunction createBackdrop(): HTMLElement {\r\n const backdrop = document.createElement(\"div\");\r\n backdrop.classList.add(\"modal-backdrop\");\r\n backdrop.style.zIndex = \"1050\";\r\n\r\n return backdrop;\r\n}\r\n\r\n/**\r\n * Shows a dialog modal. This is meant to look and behave like the standard\r\n * Rock.dialog.* functions, but this handles fullscreen mode whereas the old\r\n * methods do not.\r\n *\r\n * @param options The options that describe the dialog to be shown.\r\n *\r\n * @returns The key of the button that was clicked, or \"cancel\" if the cancel button was clicked.\r\n */\r\nfunction showDialog(options: DialogOptions): Promise {\r\n return new Promise(resolve => {\r\n let timer: NodeJS.Timeout | null = null;\r\n const container = document.fullscreenElement || document.body;\r\n const body = document.createElement(\"div\");\r\n body.innerText = options.message;\r\n\r\n const buttons: HTMLElement[] = [];\r\n\r\n /**\r\n * Internal function to handle clearing the dialog and resolving the\r\n * promise.\r\n *\r\n * @param result The result to return in the promise.\r\n */\r\n function clearDialog(result: string): void {\r\n // This acts as a way to ensure only a single clear request happens.\r\n if (timer !== null) {\r\n return;\r\n }\r\n\r\n // The timout is used as a fallback in case we don't get the\r\n // transition end event.\r\n timer = setTimeout(() => {\r\n backdrop.remove();\r\n dialog.remove();\r\n trackModalState(false);\r\n\r\n resolve(result);\r\n }, 1000);\r\n\r\n modal.addEventListener(\"transitionend\", () => {\r\n if (timer) {\r\n clearTimeout(timer);\r\n }\r\n\r\n backdrop.remove();\r\n dialog.remove();\r\n trackModalState(false);\r\n\r\n resolve(result);\r\n });\r\n\r\n modal.classList.remove(\"in\");\r\n backdrop.classList.remove(\"in\");\r\n }\r\n\r\n // Add in all the buttons specified.\r\n for (const button of options.buttons) {\r\n const btn = document.createElement(\"button\");\r\n btn.classList.value = button.className;\r\n btn.type = \"button\";\r\n btn.innerText = button.label;\r\n btn.addEventListener(\"click\", () => {\r\n clearDialog(button.key);\r\n });\r\n buttons.push(btn);\r\n }\r\n\r\n // Construct the close (cancel) button.\r\n const closeButton = createCloseButton();\r\n closeButton.addEventListener(\"click\", () => {\r\n clearDialog(\"cancel\");\r\n });\r\n\r\n const dialog = createDialog([closeButton, body], buttons);\r\n const backdrop = createBackdrop();\r\n\r\n const modal = dialog.querySelector(\".modal\") as HTMLElement;\r\n\r\n // Do final adjustments to the elements and add to the body.\r\n trackModalState(true);\r\n container.appendChild(dialog);\r\n container.appendChild(backdrop);\r\n modal.style.marginTop = `-${modal.offsetHeight / 2.0}px`;\r\n\r\n // Show the backdrop and the modal.\r\n backdrop.classList.add(\"in\");\r\n modal.classList.add(\"in\");\r\n });\r\n}\r\n\r\n/**\r\n * Shows an alert message that requires the user to acknowledge.\r\n *\r\n * @param message The message text to be displayed.\r\n *\r\n * @returns A promise that indicates when the dialog has been dismissed.\r\n */\r\nexport async function alert(message: string): Promise {\r\n await showDialog({\r\n message,\r\n buttons: [\r\n {\r\n key: \"ok\",\r\n label: \"OK\",\r\n className: \"btn btn-primary\"\r\n }\r\n ]\r\n });\r\n}\r\n\r\n/**\r\n * Shows a confirmation dialog that consists of OK and Cancel buttons. The\r\n * user will be required to click one of these two buttons.\r\n *\r\n * @param message The message to be displayed inside the dialog.\r\n *\r\n * @returns A promise that indicates when the dialog has been dismissed. The\r\n * value will be true if the OK button was clicked or false otherwise.\r\n */\r\nexport async function confirm(message: string): Promise {\r\n const result = await showDialog({\r\n message,\r\n buttons: [\r\n {\r\n key: \"ok\",\r\n label: \"OK\",\r\n className: \"btn btn-primary\"\r\n },\r\n {\r\n key: \"cancel\",\r\n label: \"Cancel\",\r\n className: \"btn btn-default\"\r\n }\r\n ]\r\n });\r\n\r\n return result === \"ok\";\r\n}\r\n\r\n/**\r\n * Shows a delete confirmation dialog that consists of OK and Cancel buttons.\r\n * The user will be required to click one of these two buttons. The message\r\n * is standardized.\r\n *\r\n * @param nameText The name of type that will be deleted.\r\n *\r\n * @returns A promise that indicates when the dialog has been dismissed. The\r\n * value will be true if the OK button was clicked or false otherwise.\r\n */\r\nexport function confirmDelete(typeName: string, additionalMessage?: string): Promise {\r\n let message = `Are you sure you want to delete this ${typeName}?`;\r\n\r\n if (additionalMessage) {\r\n message += ` ${additionalMessage}`;\r\n }\r\n\r\n return confirm(message);\r\n}\r\n\r\n/**\r\n * Shows the security dialog for the given entity.\r\n *\r\n * @param entityTypeIdKey The identifier of the entity's type.\r\n * @param entityIdKey The identifier of the entity to secure.\r\n * @param entityTitle The title of the entity. This is used to construct the modal title.\r\n */\r\nexport function showSecurity(entityTypeIdKey: Guid | string | number, entityIdKey: Guid | string | number, entityTitle: string = \"Item\"): void {\r\n Rock.controls.modal.show(undefined, `/Secure/${entityTypeIdKey}/${entityIdKey}?t=Secure ${entityTitle}&pb=&sb=Done`);\r\n}","// \r\n// Copyright by the Spark Development Network\r\n//\r\n// Licensed under the Rock Community License (the \"License\");\r\n// you may not use this file except in compliance with the License.\r\n// You may obtain a copy of the License at\r\n//\r\n// http://www.rockrms.com/license\r\n//\r\n// Unless required by applicable law or agreed to in writing, software\r\n// distributed under the License is distributed on an \"AS IS\" BASIS,\r\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n// See the License for the specific language governing permissions and\r\n// limitations under the License.\r\n// \r\n//\r\n\r\n/**\r\n * Is the value a valid email address?\r\n * @param val\r\n */\r\nexport function isEmail(val: unknown): boolean {\r\n if (typeof val === \"string\") {\r\n const re = /^(([^<>()[\\]\\\\.,;:\\s@\"]+(\\.[^<>()[\\]\\\\.,;:\\s@\"]+)*)|(\".+\"))@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\])|(([a-zA-Z\\-0-9]+\\.)+[a-zA-Z]{2,}))$/;\r\n return re.test(val.toLowerCase());\r\n }\r\n\r\n return false;\r\n}\r\n","import { ListItemBag } from \"@Obsidian/ViewModels/Utility/listItemBag\";\r\n\r\n/**\r\n * A function to convert the enums to array of ListItemBag in the frontend.\r\n *\r\n * @param description The enum to be converted to an array of listItemBag as a dictionary of value to enum description\r\n *\r\n * @returns An array of ListItemBag.\r\n */\r\nexport function enumToListItemBag (description: Record): ListItemBag[] {\r\n const listItemBagList: ListItemBag[] = [];\r\n for(const property in description) {\r\n listItemBagList.push({\r\n text: description[property].toString(),\r\n value: property.toString()\r\n });\r\n }\r\n return listItemBagList;\r\n}","// \r\n// Copyright by the Spark Development Network\r\n//\r\n// Licensed under the Rock Community License (the \"License\");\r\n// you may not use this file except in compliance with the License.\r\n// You may obtain a copy of the License at\r\n//\r\n// http://www.rockrms.com/license\r\n//\r\n// Unless required by applicable law or agreed to in writing, software\r\n// distributed under the License is distributed on an \"AS IS\" BASIS,\r\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n// See the License for the specific language governing permissions and\r\n// limitations under the License.\r\n// \r\n//\r\n\r\nimport { Guid } from \"@Obsidian/Types\";\r\nimport { isValidGuid, normalize } from \"./guid\";\r\nimport { IFieldType } from \"@Obsidian/Types/fieldType\";\r\n\r\nconst fieldTypeTable: Record = {};\r\n\r\n/** Determines how the field type component is being used so it can adapt to different */\r\nexport type DataEntryMode = \"defaultValue\" | undefined;\r\n\r\n/**\r\n * Register a new field type in the system. This must be called for all field\r\n * types a plugin registers.\r\n *\r\n * @param fieldTypeGuid The unique identifier of the field type.\r\n * @param fieldType The class instance that will handle the field type.\r\n */\r\nexport function registerFieldType(fieldTypeGuid: Guid, fieldType: IFieldType): void {\r\n const normalizedGuid = normalize(fieldTypeGuid);\r\n\r\n if (!isValidGuid(fieldTypeGuid) || normalizedGuid === null) {\r\n throw \"Invalid guid specified when registering field type.\";\r\n }\r\n\r\n if (fieldTypeTable[normalizedGuid] !== undefined) {\r\n throw \"Invalid attempt to replace existing field type.\";\r\n }\r\n\r\n fieldTypeTable[normalizedGuid] = fieldType;\r\n}\r\n\r\n/**\r\n * Get the field type handler for a given unique identifier.\r\n *\r\n * @param fieldTypeGuid The unique identifier of the field type.\r\n *\r\n * @returns The field type instance or null if not found.\r\n */\r\nexport function getFieldType(fieldTypeGuid: Guid): IFieldType | null {\r\n const normalizedGuid = normalize(fieldTypeGuid);\r\n\r\n if (normalizedGuid !== null) {\r\n const field = fieldTypeTable[normalizedGuid];\r\n\r\n if (field) {\r\n return field;\r\n }\r\n }\r\n\r\n console.warn(`Field type \"${fieldTypeGuid}\" was not found`);\r\n return null;\r\n}\r\n\r\n","// \r\n// Copyright by the Spark Development Network\r\n//\r\n// Licensed under the Rock Community License (the \"License\");\r\n// you may not use this file except in compliance with the License.\r\n// You may obtain a copy of the License at\r\n//\r\n// http://www.rockrms.com/license\r\n//\r\n// Unless required by applicable law or agreed to in writing, software\r\n// distributed under the License is distributed on an \"AS IS\" BASIS,\r\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n// See the License for the specific language governing permissions and\r\n// limitations under the License.\r\n// \r\n//\r\n\r\nimport { Workbook } from \"exceljs\";\r\n\r\n\r\n/**\r\n * Triggers an automatic download of the workbook so it can be saved to\r\n * the filesystem.\r\n *\r\n * @param workbook The workbook to be downloaded by the browser.\r\n * @param title The title of the workbook, this is used as the base for the filename.\r\n * @param format The format to use when downloading the workbook.\r\n */\r\nexport async function downloadWorkbook(workbook: Workbook, title: string, format: \"csv\" | \"xlsx\"): Promise {\r\n // Get the export data.\r\n const buffer = format === \"xlsx\"\r\n ? await workbook.xlsx.writeBuffer()\r\n : await workbook.csv.writeBuffer();\r\n\r\n // Create the URL that contains the file data.\r\n const url = URL.createObjectURL(new Blob([buffer], {\r\n type: \"application/octet-stream\"\r\n }));\r\n\r\n // Create a fake hyperlink to simulate an attempt to download a file.\r\n const element = document.createElement(\"a\");\r\n element.innerText = \"Download\";\r\n element.style.position = \"absolute\";\r\n element.style.top = \"-100px\";\r\n element.style.left = \"0\";\r\n element.href = url;\r\n element.download = `${title.replace(/[^a-zA-Z0-9\\-_]/g, \"\")}.${format}`;\r\n document.body.appendChild(element);\r\n element.click();\r\n document.body.removeChild(element);\r\n\r\n setTimeout(() => URL.revokeObjectURL(url), 100);\r\n}","// \r\n// Copyright by the Spark Development Network\r\n//\r\n// Licensed under the Rock Community License (the \"License\");\r\n// you may not use this file except in compliance with the License.\r\n// You may obtain a copy of the License at\r\n//\r\n// http://www.rockrms.com/license\r\n//\r\n// Unless required by applicable law or agreed to in writing, software\r\n// distributed under the License is distributed on an \"AS IS\" BASIS,\r\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n// See the License for the specific language governing permissions and\r\n// limitations under the License.\r\n// \r\n//\r\n\r\nimport { inject, provide } from \"vue\";\r\n\r\n/** The unique symbol used when injecting the form state. */\r\nconst formStateSymbol = Symbol();\r\n\r\n/**\r\n * Holds the state of a single form on the page along with any callback methods\r\n * that can be used to interact with the form.\r\n */\r\nexport type FormState = {\r\n /** The number of submissions the form has had. */\r\n submitCount: number;\r\n\r\n /** Sets the current error for the given field name. A blank error means no error. */\r\n setError: (id: string, name: string, error: string) => void;\r\n};\r\n\r\n/**\r\n * Contains the internal form error passed between RockForm and RockValidation.\r\n *\r\n * This is an internal type and subject to change at any time.\r\n */\r\nexport type FormError = {\r\n /** The name of the field. */\r\n name: string;\r\n\r\n /** The current error text. */\r\n text: string;\r\n};\r\n\r\n/**\r\n * Provides the form state for any child components that need access to it.\r\n * \r\n * @param state The state that will be provided to child components.\r\n */\r\nexport function provideFormState(state: FormState): void {\r\n provide(formStateSymbol, state);\r\n}\r\n\r\n/**\r\n * Makes use of the FormState that was previously provided by a parent component.\r\n *\r\n * @returns The form state or undefined if it was not available.\r\n */\r\nexport function useFormState(): FormState | undefined {\r\n return inject(formStateSymbol, undefined);\r\n}\r\n","// \r\n// Copyright by the Spark Development Network\r\n//\r\n// Licensed under the Rock Community License (the \"License\");\r\n// you may not use this file except in compliance with the License.\r\n// You may obtain a copy of the License at\r\n//\r\n// http://www.rockrms.com/license\r\n//\r\n// Unless required by applicable law or agreed to in writing, software\r\n// distributed under the License is distributed on an \"AS IS\" BASIS,\r\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n// See the License for the specific language governing permissions and\r\n// limitations under the License.\r\n// \r\n//\r\n\r\n// Define the browser-specific versions of these functions that older browsers\r\n// implemented before using the standard API.\r\ndeclare global {\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n interface Document {\r\n mozCancelFullScreen?: () => Promise;\r\n webkitExitFullscreen?: () => Promise;\r\n mozFullScreenElement?: Element;\r\n webkitFullscreenElement?: Element;\r\n }\r\n\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n interface HTMLElement {\r\n mozRequestFullscreen?: () => Promise;\r\n webkitRequestFullscreen?: () => Promise;\r\n }\r\n}\r\n\r\n/**\r\n * Request that the window enter true fullscreen mode for the given element.\r\n * \r\n * @param element The element that will be the root of the fullscreen view.\r\n * @param exitCallback The function to call when leaving fullscreen mode.\r\n *\r\n * @returns A promise that indicates when the operation has completed.\r\n */\r\nexport async function enterFullscreen(element: HTMLElement, exitCallback?: (() => void)): Promise {\r\n try {\r\n if (element.requestFullscreen) {\r\n await element.requestFullscreen();\r\n }\r\n else if (element.mozRequestFullscreen) {\r\n await element.mozRequestFullscreen();\r\n }\r\n else if (element.webkitRequestFullscreen) {\r\n await element.webkitRequestFullscreen();\r\n }\r\n else {\r\n return false;\r\n }\r\n\r\n element.classList.add(\"is-fullscreen\");\r\n\r\n const onFullscreenChange = (): void => {\r\n element.classList.remove(\"is-fullscreen\");\r\n\r\n document.removeEventListener(\"fullscreenchange\", onFullscreenChange);\r\n document.removeEventListener(\"mozfullscreenchange\", onFullscreenChange);\r\n document.removeEventListener(\"webkitfullscreenchange\", onFullscreenChange);\r\n\r\n if (exitCallback) {\r\n exitCallback();\r\n }\r\n };\r\n\r\n document.addEventListener(\"fullscreenchange\", onFullscreenChange);\r\n document.addEventListener(\"mozfullscreenchange\", onFullscreenChange);\r\n document.addEventListener(\"webkitfullscreenchange\", onFullscreenChange);\r\n\r\n return true;\r\n }\r\n catch (ex) {\r\n console.error(ex);\r\n return false;\r\n }\r\n}\r\n\r\n/**\r\n * Checks if any element is currently in fullscreen mode.\r\n * \r\n * @returns True if an element is currently in fullscreen mode in the window; otherwise false.\r\n */\r\nexport function isFullscreen(): boolean {\r\n return !!document.fullscreenElement || !!document.mozFullScreenElement || !!document.webkitFullscreenElement;\r\n}\r\n\r\n/**\r\n * Manually exits fullscreen mode.\r\n * \r\n * @returns True if fullscreen mode was exited; otherwise false.\r\n */\r\nexport async function exitFullscreen(): Promise {\r\n try {\r\n if (document.exitFullscreen) {\r\n await document.exitFullscreen();\r\n }\r\n else if (document.mozCancelFullScreen) {\r\n await document.mozCancelFullScreen();\r\n }\r\n else if (document.webkitExitFullscreen) {\r\n document.webkitExitFullscreen();\r\n }\r\n else {\r\n return false;\r\n }\r\n\r\n return true;\r\n }\r\n catch (ex) {\r\n console.error(ex);\r\n return false;\r\n }\r\n}\r\n","// \r\n// Copyright by the Spark Development Network\r\n//\r\n// Licensed under the Rock Community License (the \"License\");\r\n// you may not use this file except in compliance with the License.\r\n// You may obtain a copy of the License at\r\n//\r\n// http://www.rockrms.com/license\r\n//\r\n// Unless required by applicable law or agreed to in writing, software\r\n// distributed under the License is distributed on an \"AS IS\" BASIS,\r\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n// See the License for the specific language governing permissions and\r\n// limitations under the License.\r\n// \r\n//\r\n\r\n/* global google */\r\n\r\nimport { DrawingMode, Coordinate, ILatLng, ILatLngLiteral } from \"@Obsidian/Types/Controls/geo\";\r\nimport { GeoPickerSettingsBag } from \"@Obsidian/ViewModels/Rest/Controls/geoPickerSettingsBag\";\r\nimport { GeoPickerGetSettingsOptionsBag } from \"@Obsidian/ViewModels/Rest/Controls/geoPickerGetSettingsOptionsBag\";\r\nimport { GeoPickerGoogleMapSettingsBag } from \"@Obsidian/ViewModels/Rest/Controls/geoPickerGoogleMapSettingsBag\";\r\nimport { emptyGuid } from \"./guid\";\r\nimport { post } from \"./http\";\r\nimport { loadJavaScriptAsync } from \"./page\";\r\n\r\n/**\r\n * Converts a LatLng object, \"lat,lng\" coordinate string, or WellKnown \"lng lat\" coordinate string to a Coordinate array\r\n * @param coord Either a string in \"lat,lng\" format or a LatLng object from Google Maps\r\n * @param isWellKnown True if is \"lng lat\" format, false if it is \"lat, lng\"\r\n *\r\n * @returns Coordinate: Tuple with a Latitude number and Longitude number as the elements\r\n */\r\nexport function toCoordinate(coord: string | ILatLng, isWellKnown: boolean = false): Coordinate {\r\n if (typeof coord == \"string\") {\r\n // WellKnown string format\r\n if (isWellKnown) {\r\n return coord.split(\" \").reverse().map(val => parseFloat(val)) as Coordinate;\r\n }\r\n // Google Maps URL string format\r\n else {\r\n return coord.split(\",\").map(val => parseFloat(val)) as Coordinate;\r\n }\r\n }\r\n else {\r\n return [coord.lat(), coord.lng()];\r\n }\r\n}\r\n\r\n/**\r\n * Takes a Well Known Text value and converts it into a Coordinate array\r\n */\r\nexport function wellKnownToCoordinates(wellKnownText: string, type: DrawingMode): Coordinate[] {\r\n if (wellKnownText == \"\") {\r\n return [];\r\n }\r\n if (type == \"Point\") {\r\n // From this format: POINT (-112.130946 33.600114)\r\n return [toCoordinate(wellKnownText.replace(/(POINT *\\( *)|( *\\) *)/ig, \"\"), true)];\r\n }\r\n else {\r\n // From this format: POLYGON ((-112.157058 33.598563, -112.092341 33.595132, -112.117061 33.608715, -112.124957 33.609286, -112.157058 33.598563))\r\n return wellKnownText.replace(/(POLYGON *\\(+ *)|( *\\)+ *)/ig, \"\").split(/ *, */).map((coord) => toCoordinate(coord, true));\r\n }\r\n}\r\n\r\n/**\r\n * Takes a Well Known Text value and converts it into a Coordinate array\r\n */\r\nexport function coordinatesToWellKnown(coordinates: Coordinate[], type: DrawingMode): string {\r\n if (coordinates.length == 0) {\r\n return \"\";\r\n }\r\n else if (type == \"Point\") {\r\n return `POINT(${coordinates[0].reverse().join(\" \")})`;\r\n }\r\n else {\r\n // DB doesn't work well with the points of a polygon specified in clockwise order for some reason\r\n if (isClockwisePolygon(coordinates)) {\r\n coordinates.reverse();\r\n }\r\n\r\n const coordinateString = coordinates.map(coords => coords.reverse().join(\" \")).join(\", \");\r\n return `POLYGON((${coordinateString}))`;\r\n }\r\n}\r\n\r\n/**\r\n * Takes a Coordinate and uses Geocoding to get nearest address\r\n */\r\nexport function nearAddressForCoordinate(coordinate: Coordinate): Promise {\r\n return new Promise(resolve => {\r\n // only try if google is loaded\r\n if (window.google) {\r\n const geocoder = new google.maps.Geocoder();\r\n geocoder.geocode({ location: new google.maps.LatLng(...coordinate) }, function (results, status) {\r\n if (status == google.maps.GeocoderStatus.OK && results?.[0]) {\r\n resolve(\"near \" + results[0].formatted_address);\r\n }\r\n else {\r\n console.log(\"Geocoder failed due to: \" + status);\r\n resolve(\"\");\r\n }\r\n });\r\n }\r\n else {\r\n resolve(\"\");\r\n }\r\n });\r\n}\r\n\r\n/**\r\n * Takes a Coordinate array and uses Geocoding to get nearest address for the first point\r\n */\r\nexport function nearAddressForCoordinates(coordinates: Coordinate[]): Promise {\r\n if (!coordinates || coordinates.length == 0) {\r\n return Promise.resolve(\"\");\r\n }\r\n return nearAddressForCoordinate(coordinates[0]);\r\n}\r\n\r\n/**\r\n * Determine whether the polygon's coordinates are drawn in clockwise order\r\n * Thank you dominoc!\r\n * http://dominoc925.blogspot.com/2012/03/c-code-to-determine-if-polygon-vertices.html\r\n */\r\nexport function isClockwisePolygon(polygon: number[][]): boolean {\r\n let sum = 0;\r\n\r\n for (let i = 0; i < polygon.length - 1; i++) {\r\n sum += (Math.abs(polygon[i + 1][0]) - Math.abs(polygon[i][0])) * (Math.abs(polygon[i + 1][1]) + Math.abs(polygon[i][1]));\r\n }\r\n\r\n return sum > 0;\r\n}\r\n\r\n/**\r\n * Download the necessary resources to run the maps and return the map settings from the API\r\n *\r\n * @param options Options for which data to get from the API\r\n *\r\n * @return Promise with the map settings retrieved from the API\r\n */\r\nexport async function loadMapResources(options: GeoPickerGetSettingsOptionsBag = { mapStyleValueGuid: emptyGuid }): Promise {\r\n const response = await post(\"/api/v2/Controls/GeoPickerGetGoogleMapSettings\", undefined, options);\r\n const googleMapSettings = response.data ?? {};\r\n\r\n let keyParam = \"\";\r\n\r\n if (googleMapSettings.googleApiKey) {\r\n keyParam = `key=${googleMapSettings.googleApiKey}&`;\r\n }\r\n\r\n await loadJavaScriptAsync(`https://maps.googleapis.com/maps/api/js?${keyParam}libraries=drawing,visualization,geometry`, () => typeof (google) != \"undefined\" && typeof (google.maps) != \"undefined\", {}, false);\r\n\r\n return googleMapSettings;\r\n}\r\n\r\n/**\r\n * Creates a ILatLng object\r\n */\r\nexport function createLatLng(latOrLatLngOrLatLngLiteral: number | ILatLngLiteral | ILatLng, lngOrNoClampNoWrap?: number | boolean | null, noClampNoWrap?: boolean): ILatLng {\r\n return new google.maps.LatLng(latOrLatLngOrLatLngLiteral as number, lngOrNoClampNoWrap, noClampNoWrap);\r\n}","// \r\n// Copyright by the Spark Development Network\r\n//\r\n// Licensed under the Rock Community License (the \"License\");\r\n// you may not use this file except in compliance with the License.\r\n// You may obtain a copy of the License at\r\n//\r\n// http://www.rockrms.com/license\r\n//\r\n// Unless required by applicable law or agreed to in writing, software\r\n// distributed under the License is distributed on an \"AS IS\" BASIS,\r\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n// See the License for the specific language governing permissions and\r\n// limitations under the License.\r\n// \r\n//\r\n\r\nimport { DayOfWeek, RockDateTime } from \"./rockDateTime\";\r\nimport { newGuid } from \"./guid\";\r\nimport { toNumberOrNull } from \"./numberUtils\";\r\nimport { pluralConditional } from \"./stringUtils\";\r\n\r\ntype Frequency = \"DAILY\" | \"WEEKLY\" | \"MONTHLY\";\r\n\r\n/**\r\n * The day of the week and an interval number for that particular day.\r\n */\r\nexport type WeekdayNumber = {\r\n /** The interval number for this day. */\r\n value: number;\r\n\r\n /** The day of the week. */\r\n day: DayOfWeek;\r\n};\r\n\r\n// Abbreviate nth lookup table.\r\nconst nthNamesAbbreviated: [number, string][] = [\r\n [1, \"1st\"],\r\n [2, \"2nd\"],\r\n [3, \"3rd\"],\r\n [4, \"4th\"],\r\n [-1, \"last\"]\r\n];\r\n\r\n// #region Internal Functions\r\n\r\n/**\r\n * Converts the number to a string and pads the left with zeros to make up\r\n * the minimum required length.\r\n *\r\n * @param value The value to be converted to a string.\r\n * @param length The minimum required length of the final string.\r\n *\r\n * @returns A string that represents the value.\r\n */\r\nfunction padZeroLeft(value: number, length: number): string {\r\n const str = value.toString();\r\n\r\n return \"0\".repeat(length - str.length) + str;\r\n}\r\n\r\n/**\r\n * Get a date-only string that can be used in the iCal format.\r\n *\r\n * @param date The date object to be converted to a string.\r\n *\r\n * @returns A string that represents only the date portion of the parameter.\r\n */\r\nfunction getDateString(date: RockDateTime): string {\r\n const year = date.year;\r\n const month = date.month;\r\n const day = date.day;\r\n\r\n return `${year}${padZeroLeft(month, 2)}${padZeroLeft(day, 2)}`;\r\n}\r\n\r\n/**\r\n * Gets a time-only string that can be used in the iCal format.\r\n *\r\n * @param date The date object to be converted to a string.\r\n *\r\n * @returns A string that represents only the time portion of the parameter.\r\n */\r\nfunction getTimeString(date: RockDateTime): string {\r\n const hour = date.hour;\r\n const minute = date.minute;\r\n const second = date.second;\r\n\r\n return `${padZeroLeft(hour, 2)}${padZeroLeft(minute, 2)}${padZeroLeft(second, 2)}`;\r\n}\r\n\r\n/**\r\n * Gets a date and time string that can be used in the iCal format.\r\n *\r\n * @param date The date object to be converted to a string.\r\n *\r\n * @returns A string that represents only the date and time of the parameter.\r\n */\r\nfunction getDateTimeString(date: RockDateTime): string {\r\n return `${getDateString(date)}T${getTimeString(date)}`;\r\n}\r\n\r\n/**\r\n * Gets all the date objects from a range or period string value. This converts\r\n * from an iCal format into a set of date objects.\r\n *\r\n * @param value The string value in iCal format.\r\n *\r\n * @returns An array of date objects that represents the range or period value.\r\n */\r\nfunction getDatesFromRangeOrPeriod(value: string): RockDateTime[] {\r\n const segments = value.split(\"/\");\r\n\r\n if (segments.length === 0) {\r\n return [];\r\n }\r\n\r\n const startDate = getDateFromString(segments[0]);\r\n if (!startDate) {\r\n return [];\r\n }\r\n\r\n if (segments.length !== 2) {\r\n return [startDate];\r\n }\r\n\r\n const dates: RockDateTime[] = [];\r\n\r\n if (segments[1].startsWith(\"P\")) {\r\n // Value is a period so we have a start date and then a period marker\r\n // to tell us how long that date extends.\r\n const days = getPeriodDurationInDays(segments[1]);\r\n\r\n for (let day = 0; day < days; day++) {\r\n const date = startDate.addDays(day);\r\n if (date) {\r\n dates.push(date);\r\n }\r\n }\r\n }\r\n else {\r\n // Value is a date range so we have a start date and then an end date\r\n // and we need to fill in the dates in between.\r\n const endDate = getDateFromString(segments[1]);\r\n\r\n if (endDate !== null) {\r\n let date = startDate;\r\n\r\n while (date <= endDate) {\r\n dates.push(date);\r\n date = date.addDays(1);\r\n }\r\n }\r\n }\r\n\r\n return dates;\r\n}\r\n\r\n/**\r\n * Get a date object that only has the date portion filled in from the iCal\r\n * date string. The time will be set to midnight.\r\n *\r\n * @param value An iCal date value.\r\n *\r\n * @returns A date object that represents the iCal date value.\r\n */\r\nfunction getDateFromString(value: string): RockDateTime | null {\r\n if (value.length < 8) {\r\n return null;\r\n }\r\n\r\n const year = parseInt(value.substring(0, 4));\r\n const month = parseInt(value.substring(4, 6));\r\n const day = parseInt(value.substring(6, 8));\r\n\r\n return RockDateTime.fromParts(year, month, day);\r\n}\r\n\r\n/**\r\n * Get a date object that has both the date and time filled in from the iCal\r\n * date string.\r\n *\r\n * @param value An iCal date value.\r\n *\r\n * @returns A date object that represents the iCal date value.\r\n */\r\nfunction getDateTimeFromString(value: string): RockDateTime | null {\r\n if (value.length < 15 || value[8] !== \"T\") {\r\n return null;\r\n }\r\n\r\n const year = parseInt(value.substring(0, 4));\r\n const month = parseInt(value.substring(4, 6));\r\n const day = parseInt(value.substring(6, 8));\r\n const hour = parseInt(value.substring(9, 11));\r\n const minute = parseInt(value.substring(11, 13));\r\n const second = parseInt(value.substring(13, 15));\r\n\r\n return RockDateTime.fromParts(year, month, day, hour, minute, second);\r\n}\r\n\r\n/**\r\n * Gets an iCal period duration in the number of days.\r\n *\r\n * @param period The iCal period definition.\r\n *\r\n * @returns The number of days found in the definition.\r\n */\r\nfunction getPeriodDurationInDays(period: string): number {\r\n // These are in a format like P1D, P2W, etc.\r\n if (!period.startsWith(\"P\")) {\r\n return 0;\r\n }\r\n\r\n if (period.endsWith(\"D\")) {\r\n return parseInt(period.substring(1, period.length - 1));\r\n }\r\n else if (period.endsWith(\"W\")) {\r\n return parseInt(period.substring(1, period.length - 1)) * 7;\r\n }\r\n\r\n return 0;\r\n}\r\n\r\n/**\r\n * Gets the specific recurrence dates from a RDATE iCal value string.\r\n *\r\n * @param attributes The attributes that were defined on the RDATE property.\r\n * @param value The value of the RDATE property.\r\n *\r\n * @returns An array of date objects found in the RDATE value.\r\n */\r\nfunction getRecurrenceDates(attributes: Record, value: string): RockDateTime[] {\r\n const recurrenceDates: RockDateTime[] = [];\r\n const valueParts = value.split(\",\");\r\n let valueType = attributes[\"VALUE\"];\r\n\r\n for (const valuePart of valueParts) {\r\n if(!valueType) {\r\n // The value type is unspecified and it could be a PERIOD, DATE-TIME or a DATE.\r\n // Determine it based on the length and the contents of the valuePart string.\r\n\r\n const length = valuePart.length;\r\n\r\n if (length === 8) { // Eg: 20240117\r\n valueType = \"DATE\";\r\n }\r\n else if ((length === 15 || length === 16) && valuePart[8] === \"T\") { // Eg: 19980119T020000, 19970714T173000Z\r\n valueType = \"DATE-TIME\";\r\n }\r\n else { // Eg: 20240201/20240202, 20240118/P1D\r\n valueType = \"PERIOD\";\r\n }\r\n }\r\n\r\n\r\n if (valueType === \"PERIOD\") {\r\n // Values are stored in period format, such as \"20221005/P1D\".\r\n recurrenceDates.push(...getDatesFromRangeOrPeriod(valuePart));\r\n }\r\n else if (valueType === \"DATE\") {\r\n // Values are date-only values.\r\n const date = getDateFromString(valuePart);\r\n if (date) {\r\n recurrenceDates.push(date);\r\n }\r\n }\r\n else if (valueType === \"DATE-TIME\") {\r\n // Values are date and time values.\r\n const date = getDateTimeFromString(valuePart);\r\n if (date) {\r\n recurrenceDates.push(date);\r\n }\r\n }\r\n }\r\n\r\n return recurrenceDates;\r\n}\r\n\r\n/**\r\n * Gets the name of the weekday from the iCal abbreviation.\r\n *\r\n * @param day The iCal day abbreviation.\r\n *\r\n * @returns A string that represents the day name.\r\n */\r\nfunction getWeekdayName(day: DayOfWeek): \"Sunday\" | \"Monday\" | \"Tuesday\" | \"Wednesday\" | \"Thursday\" | \"Friday\" | \"Saturday\" | \"Unknown\" {\r\n if (day === DayOfWeek.Sunday) {\r\n return \"Sunday\";\r\n }\r\n else if (day === DayOfWeek.Monday) {\r\n return \"Monday\";\r\n }\r\n else if (day === DayOfWeek.Tuesday) {\r\n return \"Tuesday\";\r\n }\r\n else if (day === DayOfWeek.Wednesday) {\r\n return \"Wednesday\";\r\n }\r\n else if (day === DayOfWeek.Thursday) {\r\n return \"Thursday\";\r\n }\r\n else if (day === DayOfWeek.Friday) {\r\n return \"Friday\";\r\n }\r\n else if (day === DayOfWeek.Saturday) {\r\n return \"Saturday\";\r\n }\r\n else {\r\n return \"Unknown\";\r\n }\r\n}\r\n\r\n/**\r\n * Checks if the date matches one of the weekday options.\r\n *\r\n * @param rockDate The date that must match one of the weekday options.\r\n * @param days The array of weekdays that the date must match.\r\n *\r\n * @returns True if the date matches; otherwise false.\r\n */\r\nfunction dateMatchesDays(rockDate: RockDateTime, days: DayOfWeek[]): boolean {\r\n for (const day of days) {\r\n if (rockDate.dayOfWeek === day) {\r\n return true;\r\n }\r\n }\r\n\r\n return false;\r\n}\r\n\r\n/**\r\n * Checks if the date matches the specifie day of week and also the offset into\r\n * the month for that day.\r\n *\r\n * @param rockDate The date object to be checked.\r\n * @param dayOfWeek The day of week the date must be on.\r\n * @param offsets The offset in week, such as 2 meaning the second 'dayOfWeek' or -1 meaning the last 'dayOfWeek'.\r\n *\r\n * @returns True if the date matches the options; otherwise false.\r\n */\r\nfunction dateMatchesOffsetDayOfWeeks(rockDate: RockDateTime, dayOfWeek: DayOfWeek, offsets: number[]): boolean {\r\n if (!dateMatchesDays(rockDate, [dayOfWeek])) {\r\n return false;\r\n }\r\n\r\n const dayOfMonth = rockDate.day;\r\n\r\n for (const offset of offsets) {\r\n if (offset === 1 && dayOfMonth >= 1 && dayOfMonth <= 7) {\r\n return true;\r\n }\r\n else if (offset === 2 && dayOfMonth >= 8 && dayOfMonth <= 14) {\r\n return true;\r\n }\r\n else if (offset === 3 && dayOfMonth >= 15 && dayOfMonth <= 21) {\r\n return true;\r\n }\r\n else if (offset === 4 && dayOfMonth >= 22 && dayOfMonth <= 28) {\r\n return true;\r\n }\r\n else if (offset === -1) {\r\n const lastDayOfMonth = rockDate.addDays(-(rockDate.day - 1)).addMonths(1).addDays(-1).day;\r\n\r\n if (dayOfMonth >= (lastDayOfMonth - 7) && dayOfMonth <= lastDayOfMonth) {\r\n return true;\r\n }\r\n }\r\n }\r\n\r\n return false;\r\n}\r\n\r\n/**\r\n * Gets the DayOfWeek value that corresponds to the iCal formatted weekday.\r\n *\r\n * @param day The day of the week to be parsed.\r\n *\r\n * @returns A DayOfWeek value that represents the day.\r\n */\r\nfunction getDayOfWeekFromIcalDay(day: \"SU\" | \"MO\" | \"TU\" | \"WE\" | \"TH\" | \"FR\" | \"SA\"): DayOfWeek {\r\n switch (day) {\r\n case \"SU\":\r\n return DayOfWeek.Sunday;\r\n\r\n case \"MO\":\r\n return DayOfWeek.Monday;\r\n case \"TU\":\r\n return DayOfWeek.Tuesday;\r\n\r\n case \"WE\":\r\n return DayOfWeek.Wednesday;\r\n\r\n case \"TH\":\r\n return DayOfWeek.Thursday;\r\n\r\n case \"FR\":\r\n return DayOfWeek.Friday;\r\n\r\n case \"SA\":\r\n return DayOfWeek.Saturday;\r\n }\r\n}\r\n\r\n/**\r\n * Gets the iCal abbreviation for the day of the week.\r\n *\r\n * @param day The day of the week to be converted to iCal format.\r\n *\r\n * @returns An iCal representation of the day of week.\r\n */\r\nfunction getiCalDay(day: DayOfWeek): \"SU\" | \"MO\" | \"TU\" | \"WE\" | \"TH\" | \"FR\" | \"SA\" {\r\n switch (day) {\r\n case DayOfWeek.Sunday:\r\n return \"SU\";\r\n\r\n case DayOfWeek.Monday:\r\n return \"MO\";\r\n\r\n case DayOfWeek.Tuesday:\r\n return \"TU\";\r\n\r\n case DayOfWeek.Wednesday:\r\n return \"WE\";\r\n\r\n case DayOfWeek.Thursday:\r\n return \"TH\";\r\n\r\n case DayOfWeek.Friday:\r\n return \"FR\";\r\n\r\n case DayOfWeek.Saturday:\r\n return \"SA\";\r\n }\r\n}\r\n\r\n/**\r\n * Normalizes line length so that none of the individual lines exceed the\r\n * maximum length of 75 charactes from the RFC.\r\n *\r\n * @param lines The array of lines to be normalized.\r\n *\r\n * @returns A new array with the lines normalized for length.\r\n */\r\nfunction normalizeLineLength(lines: string[]): string[] {\r\n const newLines: string[] = [...lines];\r\n\r\n for (let lineNumber = 0; lineNumber < newLines.length; lineNumber++) {\r\n // Spec does not allow lines longer than 75 characters.\r\n if (newLines[lineNumber].length > 75) {\r\n const currentLine = newLines[lineNumber].substring(0, 75);\r\n const newLine = \" \" + newLines[lineNumber].substring(75);\r\n\r\n newLines.splice(lineNumber, 1, currentLine, newLine);\r\n }\r\n }\r\n\r\n return newLines;\r\n}\r\n\r\n/**\r\n * Denormalizes line length so that any continuation lines are appending\r\n * to the previous line for proper parsing.\r\n *\r\n * @param lines The array of lines to be denormalized.\r\n *\r\n * @returns A new array with the lines denormalized.\r\n */\r\nfunction denormalizeLineLength(lines: string[]): string[] {\r\n const newLines: string[] = [...lines];\r\n\r\n for (let lineNumber = 1; lineNumber < newLines.length;) {\r\n if (newLines[lineNumber][0] === \" \") {\r\n newLines[lineNumber - 1] += newLines[lineNumber].substring(1);\r\n newLines.splice(lineNumber, 1);\r\n }\r\n else {\r\n lineNumber++;\r\n }\r\n }\r\n\r\n return newLines;\r\n}\r\n\r\n// #endregion\r\n\r\n/**\r\n * Helper utility to feed lines into ICS parsers.\r\n */\r\nclass LineFeeder {\r\n // #region Properties\r\n\r\n /**\r\n * The denormalzied lines that represent the ICS data.\r\n */\r\n private lines: string[];\r\n\r\n // #endregion\r\n\r\n // #region Constructors\r\n\r\n /**\r\n * Creates a new LineFeeder with the given content.\r\n *\r\n * @param content A string that represents raw ICS data.\r\n */\r\n constructor(content: string) {\r\n const lines = content.split(/\\r\\n|\\n|\\r/);\r\n\r\n this.lines = denormalizeLineLength(lines);\r\n }\r\n\r\n // #endregion\r\n\r\n // #region Functions\r\n\r\n /**\r\n * Peek at the next line to be read from the feeder.\r\n *\r\n * @returns The next line to be read or null if no more lines remain.\r\n */\r\n public peek(): string | null {\r\n if (this.lines.length === 0) {\r\n return null;\r\n }\r\n\r\n return this.lines[0];\r\n }\r\n\r\n /**\r\n * Pops the next line from the feeder, removing it.\r\n *\r\n * @returns The line that was removed from the feeder or null if no lines remain.\r\n */\r\n public pop(): string | null {\r\n if (this.lines.length === 0) {\r\n return null;\r\n }\r\n\r\n return this.lines.splice(0, 1)[0];\r\n }\r\n\r\n // #endregion\r\n}\r\n\r\n/**\r\n * Logic and structure for a rule that defines when an even recurs on\r\n * different dates.\r\n */\r\nexport class RecurrenceRule {\r\n // #region Properties\r\n\r\n /**\r\n * The frequency of this recurrence. Only Daily, Weekly and Monthly\r\n * are supported.\r\n */\r\n public frequency?: Frequency;\r\n\r\n /**\r\n * The date at which no more event dates will be generated. This is\r\n * an exclusive date, meaning if an event date lands on this date\r\n * then it will not be included in the list of dates.\r\n */\r\n public endDate?: RockDateTime;\r\n\r\n /**\r\n * The maximum number of dates, including the original date, that\r\n * should be generated.\r\n */\r\n public count?: number;\r\n\r\n /**\r\n * The interval between dates based on the frequency. If this value is\r\n * 2 and frequency is Weekly, then you are asking for \"every other week\".\r\n */\r\n public interval: number = 1;\r\n\r\n /**\r\n * The days of the month the event should recur on. Only a single value\r\n * is supported currently.\r\n */\r\n public byMonthDay: number[] = [];\r\n\r\n /**\r\n * The days of the week the event shoudl recur on.\r\n */\r\n public byDay: WeekdayNumber[] = [];\r\n\r\n // #endregion\r\n\r\n // #region Constructors\r\n\r\n /**\r\n * Creates a new recurrence rule that can be used to define or adjust the\r\n * recurrence pattern of an event.\r\n *\r\n * @param rule An existing RRULE string from an iCal file.\r\n *\r\n * @returns A new instance that can be used to adjust or define the rule.\r\n */\r\n public constructor(rule: string | undefined = undefined) {\r\n if (!rule) {\r\n return;\r\n }\r\n\r\n // Rule has a format like \"FREQ=DAILY;COUNT=5\" so we split by semicolon\r\n // first and then sub-split by equals character and then stuff everything\r\n // into this values object.\r\n const values: Record = {};\r\n\r\n for (const attr of rule.split(\";\")) {\r\n const attrParts = attr.split(\"=\");\r\n if (attrParts.length === 2) {\r\n values[attrParts[0]] = attrParts[1];\r\n }\r\n }\r\n\r\n // Make sure the values we have are valid.\r\n if (values[\"UNTIL\"] !== undefined && values[\"COUNT\"] !== undefined) {\r\n throw new Error(`Recurrence rule '${rule}' cannot specify both UNTIL and COUNT.`);\r\n }\r\n\r\n if (values[\"FREQ\"] !== \"DAILY\" && values[\"FREQ\"] !== \"WEEKLY\" && values[\"FREQ\"] !== \"MONTHLY\") {\r\n throw new Error(`Invalid frequence for recurrence rule '${rule}'.`);\r\n }\r\n\r\n this.frequency = values[\"FREQ\"];\r\n\r\n if (values[\"UNTIL\"]?.length === 8) {\r\n this.endDate = getDateFromString(values[\"UNTIL\"]) ?? undefined;\r\n }\r\n else if (values[\"UNTIL\"]?.length >= 15) {\r\n this.endDate = getDateTimeFromString(values[\"UNTIL\"]) ?? undefined;\r\n }\r\n\r\n if (values[\"COUNT\"] !== undefined) {\r\n this.count = toNumberOrNull(values[\"COUNT\"]) ?? undefined;\r\n }\r\n\r\n if (values[\"INTERVAL\"] !== undefined) {\r\n this.interval = toNumberOrNull(values[\"INTERVAL\"]) ?? 1;\r\n }\r\n\r\n if (values[\"BYMONTHDAY\"] !== undefined && values[\"BYMONTHDAY\"].length > 0) {\r\n this.byMonthDay = [];\r\n\r\n for (const v of values[\"BYMONTHDAY\"].split(\",\")) {\r\n const num = toNumberOrNull(v);\r\n if (num !== null) {\r\n this.byMonthDay.push(num);\r\n }\r\n }\r\n }\r\n\r\n if (values[\"BYDAY\"] !== undefined && values[\"BYDAY\"].length > 0) {\r\n this.byDay = [];\r\n\r\n for (const v of values[\"BYDAY\"].split(\",\")) {\r\n if (v.length < 2) {\r\n continue;\r\n }\r\n\r\n const num = v.length > 2 ? toNumberOrNull(v.substring(0, v.length - 2)) : 1;\r\n const day = v.substring(v.length - 2);\r\n\r\n if (num === null) {\r\n continue;\r\n }\r\n\r\n if (day === \"SU\" || day === \"MO\" || day === \"TU\" || day == \"WE\" || day == \"TH\" || day == \"FR\" || day == \"SA\") {\r\n this.byDay.push({\r\n value: num,\r\n day: getDayOfWeekFromIcalDay(day)\r\n });\r\n }\r\n }\r\n }\r\n }\r\n\r\n // #endregion\r\n\r\n // #region Functions\r\n\r\n /**\r\n * Builds and returns the RRULE value for an iCal file export.\r\n *\r\n * @returns A RRULE value that represents the recurrence rule.\r\n */\r\n public build(): string {\r\n const attributes: string[] = [];\r\n\r\n attributes.push(`FREQ=${this.frequency}`);\r\n\r\n if (this.count !== undefined) {\r\n attributes.push(`COUNT=${this.count}`);\r\n }\r\n else if (this.endDate) {\r\n attributes.push(`UNTIL=${getDateTimeString(this.endDate)}`);\r\n }\r\n\r\n if (this.interval > 1) {\r\n attributes.push(`INTERVAL=${this.interval}`);\r\n }\r\n\r\n if (this.byMonthDay.length > 0) {\r\n const monthDayValues = this.byMonthDay.map(md => md.toString()).join(\",\");\r\n attributes.push(`BYMONTHDAY=${monthDayValues}`);\r\n }\r\n\r\n if (this.frequency === \"MONTHLY\" && this.byDay.length > 0) {\r\n const dayValues = this.byDay.map(d => `${d.value}${getiCalDay(d.day)}`);\r\n attributes.push(`BYDAY=${dayValues}`);\r\n }\r\n else if (this.byDay.length > 0) {\r\n const dayValues = this.byDay.map(d => d.value !== 1 ? `${d.value}${getiCalDay(d.day)}` : getiCalDay(d.day));\r\n attributes.push(`BYDAY=${dayValues}`);\r\n }\r\n\r\n return attributes.join(\";\");\r\n }\r\n\r\n /**\r\n * Gets all the dates within the range that match the recurrence rule. A\r\n * maximum of 100,000 dates will be returned by this function.\r\n *\r\n * @param eventStartDateTime The start date and time of the primary event this rule is for.\r\n * @param startDateTime The inclusive starting date and time that events should be returned for.\r\n * @param endDateTime The exclusive ending date and time that events should be returned for.\r\n *\r\n * @returns An array of date objects that represent the additional dates and times for the event.\r\n */\r\n public getDates(eventStartDateTime: RockDateTime, startDateTime: RockDateTime, endDateTime: RockDateTime): RockDateTime[] {\r\n const dates: RockDateTime[] = [];\r\n let rockDate = eventStartDateTime;\r\n let dateCount = 0;\r\n\r\n if (!rockDate) {\r\n return [];\r\n }\r\n\r\n if (this.endDate && this.endDate < endDateTime) {\r\n endDateTime = this.endDate;\r\n }\r\n\r\n while (rockDate < endDateTime && dateCount < 100_000) {\r\n if (this.count && dateCount >= this.count) {\r\n break;\r\n }\r\n\r\n dateCount++;\r\n\r\n if (rockDate >= startDateTime) {\r\n dates.push(rockDate);\r\n }\r\n\r\n const nextDate = this.nextDateAfter(rockDate);\r\n\r\n if (nextDate === null) {\r\n break;\r\n }\r\n else {\r\n rockDate = nextDate;\r\n }\r\n }\r\n\r\n return dates;\r\n }\r\n\r\n /**\r\n * Gets the next valid date after the specified date based on our recurrence\r\n * rules.\r\n *\r\n * @param rockDate The reference date that should be used when calculation the next date.\r\n *\r\n * @returns The next date after the reference date or null if one cannot be determined.\r\n */\r\n private nextDateAfter(rockDate: RockDateTime): RockDateTime | null {\r\n if (this.frequency === \"DAILY\") {\r\n return rockDate.addDays(this.interval);\r\n }\r\n else if (this.frequency === \"WEEKLY\" && this.byDay.length > 0) {\r\n let nextDate = rockDate;\r\n\r\n if (nextDate.dayOfWeek === DayOfWeek.Saturday) {\r\n // On saturday process any skip intervals to move past the next n weeks.\r\n nextDate = nextDate.addDays(1 + ((this.interval - 1) * 7));\r\n }\r\n else {\r\n nextDate = nextDate.addDays(1);\r\n }\r\n\r\n while (!dateMatchesDays(nextDate, this.byDay.map(d => d.day))) {\r\n if (nextDate.dayOfWeek === DayOfWeek.Saturday) {\r\n // On saturday process any skip intervals to move past the next n weeks.\r\n nextDate = nextDate.addDays(1 + ((this.interval - 1) * 7));\r\n }\r\n else {\r\n nextDate = nextDate.addDays(1);\r\n }\r\n }\r\n\r\n return nextDate;\r\n }\r\n else if (this.frequency === \"MONTHLY\") {\r\n if (this.byMonthDay.length > 0) {\r\n let nextDate = rockDate.addDays(-(rockDate.day - 1));\r\n\r\n if (rockDate.day >= this.byMonthDay[0]) {\r\n nextDate = nextDate.addMonths(this.interval);\r\n }\r\n\r\n let lastDayOfMonth = nextDate.addMonths(1).addDays(-1).day;\r\n let loopCount = 0;\r\n\r\n // Skip any months that don't have this day number.\r\n while (lastDayOfMonth < this.byMonthDay[0]) {\r\n nextDate = nextDate.addMonths(this.interval);\r\n\r\n lastDayOfMonth = nextDate.addMonths(1).addDays(-1).day;\r\n\r\n // Fail-safe check so we don't get stuck looping forever\r\n // if the rule is one that can't be determined. Such as a\r\n // rule for the 30th day of the month every 12 months\r\n // starting in February.\r\n if (loopCount++ >= 100) {\r\n return null;\r\n }\r\n }\r\n\r\n nextDate = nextDate.addDays(this.byMonthDay[0] - 1);\r\n\r\n return nextDate;\r\n }\r\n else if (this.byDay.length > 0) {\r\n const dayOfWeek = this.byDay[0].day;\r\n const offsets = this.byDay.map(d => d.value);\r\n\r\n let nextDate = rockDate.addDays(1);\r\n\r\n while (!dateMatchesOffsetDayOfWeeks(nextDate, dayOfWeek, offsets)) {\r\n nextDate = nextDate.addDays(1);\r\n }\r\n\r\n return nextDate;\r\n }\r\n }\r\n\r\n return null;\r\n }\r\n\r\n // #endregion\r\n}\r\n\r\n/**\r\n * A single event inside a calendar.\r\n */\r\nexport class Event {\r\n // #region Properties\r\n\r\n /**\r\n * The unique identifier for this schedule used in the scheduled event.\r\n */\r\n public uid?: string;\r\n\r\n /**\r\n * The first date and time that the event occurs on. This must be provided\r\n * before the schedule can be built.\r\n */\r\n public startDateTime?: RockDateTime;\r\n\r\n /**\r\n * The end date and time for the event. This must be provided before\r\n * this schedule can be built.\r\n */\r\n public endDateTime?: RockDateTime;\r\n\r\n /**\r\n * An array of dates to be excluded from the recurrence rules.\r\n */\r\n public excludedDates: RockDateTime[] = [];\r\n\r\n /**\r\n * An array of specific dates that this schedule will recur on. This is\r\n * only valid if recurrenceRules contains no rules.\r\n */\r\n public recurrenceDates: RockDateTime[] = [];\r\n\r\n /**\r\n * The rules that define when this schedule recurs on for additional dates.\r\n * Only the first rule is currently supported.\r\n */\r\n public recurrenceRules: RecurrenceRule[] = [];\r\n\r\n // #endregion\r\n\r\n // #region Constructors\r\n\r\n /**\r\n * Creates a new internet calendar event.\r\n *\r\n * @param icsContent The content from the ICS file that represents this single event.\r\n *\r\n * @returns A new Event instance.\r\n */\r\n public constructor(icsContent: string | LineFeeder | undefined = undefined) {\r\n if (icsContent === undefined) {\r\n this.uid = newGuid();\r\n return;\r\n }\r\n\r\n let feeder: LineFeeder;\r\n\r\n if (typeof icsContent === \"string\") {\r\n feeder = new LineFeeder(icsContent);\r\n }\r\n else {\r\n feeder = icsContent;\r\n }\r\n\r\n this.parse(feeder);\r\n }\r\n\r\n // #endregion\r\n\r\n // #region Functions\r\n\r\n /**\r\n * Build the event as a list of individual lines that make up the event in\r\n * the ICS file format.\r\n *\r\n * @returns An array of lines to be inserted into an ICS file.\r\n */\r\n public buildLines(): string[] {\r\n if (!this.startDateTime || !this.endDateTime) {\r\n return [];\r\n }\r\n\r\n const lines: string[] = [];\r\n\r\n lines.push(\"BEGIN:VEVENT\");\r\n lines.push(`DTEND:${getDateTimeString(this.endDateTime)}`);\r\n lines.push(`DTSTAMP:${getDateTimeString(RockDateTime.now())}`);\r\n lines.push(`DTSTART:${getDateTimeString(this.startDateTime)}`);\r\n\r\n if (this.excludedDates.length > 0) {\r\n lines.push(`EXDATE:${this.excludedDates.map(d => getDateString(d) + \"/P1D\").join(\",\")}`);\r\n }\r\n\r\n if (this.recurrenceDates.length > 0) {\r\n const recurrenceDates: string[] = [];\r\n for (const date of this.recurrenceDates) {\r\n const rDate = RockDateTime.fromParts(date.year, date.month, date.day, this.startDateTime.hour, this.startDateTime.minute, this.startDateTime.second);\r\n if (rDate) {\r\n recurrenceDates.push(getDateTimeString(rDate));\r\n }\r\n }\r\n\r\n lines.push(`RDATE:${recurrenceDates.join(\",\")}`);\r\n }\r\n else if (this.recurrenceRules.length > 0) {\r\n for (const rrule of this.recurrenceRules) {\r\n lines.push(`RRULE:${rrule.build()}`);\r\n }\r\n }\r\n\r\n lines.push(\"SEQUENCE:0\");\r\n lines.push(`UID:${this.uid}`);\r\n lines.push(\"END:VEVENT\");\r\n\r\n return lines;\r\n }\r\n\r\n /**\r\n * Builds the event into a string that conforms to ICS format.\r\n *\r\n * @returns An ICS formatted string that represents the event data.\r\n */\r\n public build(): string | null {\r\n const lines = this.buildLines();\r\n\r\n if (lines.length === 0) {\r\n return null;\r\n }\r\n\r\n return normalizeLineLength(lines).join(\"\\r\\n\");\r\n }\r\n\r\n /**\r\n * Parse data from an existing event and store it on this instance.\r\n *\r\n * @param feeder The feeder that will provide the line data for parsing.\r\n */\r\n private parse(feeder: LineFeeder): void {\r\n let duration: string | null = null;\r\n let line: string | null;\r\n\r\n // Verify this is an event.\r\n if (feeder.peek() !== \"BEGIN:VEVENT\") {\r\n throw new Error(\"Invalid event.\");\r\n }\r\n\r\n feeder.pop();\r\n\r\n // Parse the line until we run out of lines or see an END line.\r\n while ((line = feeder.pop()) !== null) {\r\n if (line === \"END:VEVENT\") {\r\n break;\r\n }\r\n\r\n const splitAt = line.indexOf(\":\");\r\n if (splitAt < 0) {\r\n continue;\r\n }\r\n\r\n let key = line.substring(0, splitAt);\r\n const value = line.substring(splitAt + 1);\r\n\r\n const keyAttributes: Record = {};\r\n const keySegments = key.split(\";\");\r\n if (keySegments.length > 1) {\r\n key = keySegments[0];\r\n keySegments.splice(0, 1);\r\n\r\n for (const attr of keySegments) {\r\n const attrSegments = attr.split(\"=\");\r\n if (attr.length === 2) {\r\n keyAttributes[attrSegments[0]] = attrSegments[1];\r\n }\r\n }\r\n }\r\n\r\n if (key === \"DTSTART\") {\r\n this.startDateTime = getDateTimeFromString(value) ?? undefined;\r\n }\r\n else if (key === \"DTEND\") {\r\n this.endDateTime = getDateTimeFromString(value) ?? undefined;\r\n }\r\n else if (key === \"RRULE\") {\r\n this.recurrenceRules.push(new RecurrenceRule(value));\r\n }\r\n else if (key === \"RDATE\") {\r\n this.recurrenceDates = getRecurrenceDates(keyAttributes, value);\r\n }\r\n else if (key === \"UID\") {\r\n this.uid = value;\r\n }\r\n else if (key === \"DURATION\") {\r\n duration = value;\r\n }\r\n else if (key === \"EXDATE\") {\r\n const dateValues = value.split(\",\");\r\n for (const dateValue of dateValues) {\r\n const dates = getDatesFromRangeOrPeriod(dateValue);\r\n this.excludedDates.push(...dates);\r\n }\r\n }\r\n }\r\n\r\n if (duration !== null) {\r\n // TODO: Calculate number of seconds and add to startDate.\r\n }\r\n }\r\n\r\n /**\r\n * Determines if the date is listed in one of the excluded dates. This\r\n * currently only checks the excludedDates but in the future might also\r\n * check the excluded rules.\r\n *\r\n * @param rockDate The date to be checked to see if it is excluded.\r\n *\r\n * @returns True if the date is excluded; otherwise false.\r\n */\r\n private isDateExcluded(rockDate: RockDateTime): boolean {\r\n const rockDateOnly = rockDate.date;\r\n\r\n for (const excludedDate of this.excludedDates) {\r\n if (excludedDate.date.isEqualTo(rockDateOnly)) {\r\n return true;\r\n }\r\n }\r\n\r\n return false;\r\n }\r\n\r\n /**\r\n * Get all the dates for this event that fall within the specified date range.\r\n *\r\n * @param startDateTime The inclusive starting date to use when filtering event dates.\r\n * @param endDateTime The exclusive endign date to use when filtering event dates.\r\n *\r\n * @returns An array of dates that fall between startDateTime and endDateTime.\r\n */\r\n public getDates(startDateTime: RockDateTime, endDateTime: RockDateTime): RockDateTime[] {\r\n if (!this.startDateTime) {\r\n return [];\r\n }\r\n\r\n // If the schedule has a startDateTime that is later than the requested\r\n // startDateTime then use ours instead.\r\n if (this.startDateTime > startDateTime) {\r\n startDateTime = this.startDateTime;\r\n }\r\n\r\n if (this.recurrenceDates.length > 0) {\r\n const dates: RockDateTime[] = [];\r\n const recurrenceDates: RockDateTime[] = [this.startDateTime, ...this.recurrenceDates];\r\n\r\n for (const date of recurrenceDates) {\r\n if (date >= startDateTime && date < endDateTime) {\r\n dates.push(date);\r\n }\r\n }\r\n\r\n return dates;\r\n }\r\n else if (this.recurrenceRules.length > 0) {\r\n const rrule = this.recurrenceRules[0];\r\n\r\n return rrule.getDates(this.startDateTime, startDateTime, endDateTime)\r\n .filter(d => !this.isDateExcluded(d));\r\n }\r\n else {\r\n if (this.startDateTime >= startDateTime && this.startDateTime < endDateTime) {\r\n return [this.startDateTime];\r\n }\r\n\r\n return [];\r\n }\r\n }\r\n\r\n /**\r\n * Get the friendly text string that represents this event. This will be a\r\n * plain text string with no formatting applied.\r\n *\r\n * @returns A string that represents the event in a human friendly manner.\r\n */\r\n public toFriendlyText(): string {\r\n return this.toFriendlyString(false);\r\n }\r\n\r\n /**\r\n * Get the friendly HTML string that represents this event. This will be\r\n * formatted with HTML to make the information easier to read.\r\n *\r\n * @returns A string that represents the event in a human friendly manner.\r\n */\r\n public toFriendlyHtml(): string {\r\n return this.toFriendlyString(true);\r\n }\r\n\r\n /**\r\n * Get the friendly string that can be easily understood by a human.\r\n *\r\n * @param html If true then the string can contain HTML content to make things easier to read.\r\n *\r\n * @returns A string that represents the event in a human friendly manner.\r\n */\r\n private toFriendlyString(html: boolean): string {\r\n if (!this.startDateTime) {\r\n return \"\";\r\n }\r\n\r\n const startTimeText = this.startDateTime.toLocaleString({ hour: \"numeric\", minute: \"2-digit\", hour12: true });\r\n\r\n if (this.recurrenceRules.length > 0) {\r\n const rrule = this.recurrenceRules[0];\r\n\r\n if (rrule.frequency === \"DAILY\") {\r\n let result = \"Daily\";\r\n\r\n if (rrule.interval > 1) {\r\n result += ` every ${rrule.interval} ${pluralConditional(rrule.interval, \"day\", \"days\")}`;\r\n }\r\n\r\n result += ` at ${startTimeText}`;\r\n\r\n return result;\r\n }\r\n else if (rrule.frequency === \"WEEKLY\") {\r\n if (rrule.byDay.length === 0) {\r\n return \"No Scheduled Days\";\r\n }\r\n\r\n let result = rrule.byDay.map(d => getWeekdayName(d.day) + \"s\").join(\",\");\r\n\r\n if (rrule.interval > 1) {\r\n result = `Every ${rrule.interval} weeks: ${result}`;\r\n }\r\n else {\r\n result = `Weekly: ${result}`;\r\n }\r\n\r\n return `${result} at ${startTimeText}`;\r\n }\r\n else if (rrule.frequency === \"MONTHLY\") {\r\n if (rrule.byMonthDay.length > 0) {\r\n let result = `Day ${rrule.byMonthDay[0]} of every `;\r\n\r\n if (rrule.interval > 1) {\r\n result += `${rrule.interval} months`;\r\n }\r\n else {\r\n result += \"month\";\r\n }\r\n\r\n return `${result} at ${startTimeText}`;\r\n }\r\n else if (rrule.byDay.length > 0) {\r\n const byDay = rrule.byDay[0];\r\n const offsetNames = nthNamesAbbreviated.filter(n => rrule.byDay.some(d => d.value == n[0])).map(n => n[1]);\r\n let result = \"\";\r\n\r\n if (offsetNames.length > 0) {\r\n let nameText: string;\r\n\r\n if (offsetNames.length > 2) {\r\n nameText = `${offsetNames.slice(0, offsetNames.length - 1).join(\", \")} and ${offsetNames[offsetNames.length - 1]}`;\r\n }\r\n else {\r\n nameText = offsetNames.join(\" and \");\r\n }\r\n result = `The ${nameText} ${getWeekdayName(byDay.day)} of every month`;\r\n }\r\n else {\r\n return \"\";\r\n }\r\n\r\n return `${result} at ${startTimeText}`;\r\n }\r\n else {\r\n return \"\";\r\n }\r\n }\r\n else {\r\n return \"\";\r\n }\r\n }\r\n else {\r\n const dates: RockDateTime[] = [this.startDateTime, ...this.recurrenceDates];\r\n\r\n if (dates.length === 1) {\r\n return `Once at ${this.startDateTime.toASPString(\"g\")}`;\r\n }\r\n else if (!html || dates.length > 99) {\r\n const firstDate = dates[0];\r\n const lastDate = dates[dates.length - 1];\r\n\r\n if (firstDate && lastDate) {\r\n return `Multiple dates between ${firstDate.toASPString(\"g\")} and ${lastDate.toASPString(\"g\")}`;\r\n }\r\n else {\r\n return \"\";\r\n }\r\n }\r\n else if (dates.length > 1) {\r\n let listHtml = `
    `;\r\n\r\n for (const date of dates) {\r\n listHtml += `
  • ${date.toASPString(\"g\")}
  • `;\r\n }\r\n\r\n listHtml += \"\";\r\n\r\n return listHtml;\r\n }\r\n else {\r\n return \"No Schedule\";\r\n }\r\n }\r\n }\r\n\r\n // #endregion\r\n}\r\n\r\n/**\r\n * A recurring schedule allows schedules to be built and customized from the iCal\r\n * format used in ics files.\r\n */\r\nexport class Calendar {\r\n // #region Properties\r\n\r\n /**\r\n * The events that exist for this calendar.\r\n */\r\n public events: Event[] = [];\r\n\r\n // #endregion\r\n\r\n // #region Constructors\r\n\r\n /**\r\n * Creates a new Calendar instance.\r\n *\r\n * @param icsContent The content from an ICS file to initialize the calendar with.\r\n *\r\n * @returns A new Calendar instance.\r\n */\r\n public constructor(icsContent: string | undefined = undefined) {\r\n if (icsContent === undefined) {\r\n return;\r\n }\r\n\r\n const feeder = new LineFeeder(icsContent);\r\n\r\n this.parse(feeder);\r\n }\r\n\r\n // #endregion\r\n\r\n // #region Functions\r\n\r\n /**\r\n * Builds the calendar into a string that conforms to ICS format.\r\n *\r\n * @returns An ICS formatted string that represents the calendar data.\r\n */\r\n public build(): string | null {\r\n const lines: string[] = [];\r\n\r\n lines.push(\"BEGIN:VCALENDAR\");\r\n lines.push(\"PRODID:-//github.com/SparkDevNetwork/Rock//NONSGML Rock//EN\");\r\n lines.push(\"VERSION:2.0\");\r\n\r\n for (const event of this.events) {\r\n lines.push(...event.buildLines());\r\n }\r\n\r\n lines.push(\"END:VCALENDAR\");\r\n\r\n return denormalizeLineLength(lines).join(\"\\r\\n\");\r\n }\r\n\r\n /**\r\n * Parses the ICS data from a line feeder and constructs the calendar\r\n * from that data.\r\n *\r\n * @param feeder The feeder that provides the individual lines.\r\n */\r\n private parse(feeder: LineFeeder): void {\r\n let line: string | null;\r\n\r\n // Parse the line data.\r\n while ((line = feeder.peek()) !== null) {\r\n if (line === \"BEGIN:VEVENT\") {\r\n const event = new Event(feeder);\r\n\r\n this.events.push(event);\r\n }\r\n else {\r\n feeder.pop();\r\n }\r\n }\r\n }\r\n\r\n // #endregion\r\n}\r\n","// \r\n// Copyright by the Spark Development Network\r\n//\r\n// Licensed under the Rock Community License (the \"License\");\r\n// you may not use this file except in compliance with the License.\r\n// You may obtain a copy of the License at\r\n//\r\n// http://www.rockrms.com/license\r\n//\r\n// Unless required by applicable law or agreed to in writing, software\r\n// distributed under the License is distributed on an \"AS IS\" BASIS,\r\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n// See the License for the specific language governing permissions and\r\n// limitations under the License.\r\n// \r\n//\r\n\r\nimport { Liquid } from \"@Obsidian/Libs/liquidjs\";\r\n\r\nconst engine = new Liquid({\r\n cache: true\r\n});\r\n\r\nexport function resolveMergeFields(template: string, mergeFields: Record): string {\r\n const tpl = engine.parse(template);\r\n\r\n return engine.renderSync(tpl, mergeFields);\r\n}\r\n","// \r\n// Copyright by the Spark Development Network\r\n//\r\n// Licensed under the Rock Community License (the \"License\");\r\n// you may not use this file except in compliance with the License.\r\n// You may obtain a copy of the License at\r\n//\r\n// http://www.rockrms.com/license\r\n//\r\n// Unless required by applicable law or agreed to in writing, software\r\n// distributed under the License is distributed on an \"AS IS\" BASIS,\r\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n// See the License for the specific language governing permissions and\r\n// limitations under the License.\r\n// \r\n//\r\n\r\nimport { ListItemBag } from \"@Obsidian/ViewModels/Utility/listItemBag\";\r\n\r\nexport function asListItemBagOrNull(bagJson: string): ListItemBag | null {\r\n try {\r\n const val = JSON.parse(bagJson);\r\n\r\n if (\"value\" in val || \"text\" in val) {\r\n return val;\r\n }\r\n\r\n return null;\r\n }\r\n catch (e) {\r\n return null;\r\n }\r\n}","// \r\n// Copyright by the Spark Development Network\r\n//\r\n// Licensed under the Rock Community License (the \"License\");\r\n// you may not use this file except in compliance with the License.\r\n// You may obtain a copy of the License at\r\n//\r\n// http://www.rockrms.com/license\r\n//\r\n// Unless required by applicable law or agreed to in writing, software\r\n// distributed under the License is distributed on an \"AS IS\" BASIS,\r\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n// See the License for the specific language governing permissions and\r\n// limitations under the License.\r\n// \r\n//\r\n\r\nimport { MergeFieldPickerFormatSelectedValueOptionsBag } from \"@Obsidian/ViewModels/Rest/Controls/mergeFieldPickerFormatSelectedValueOptionsBag\";\r\nimport { useHttp } from \"./http\";\r\n\r\n/**\r\n * Take a given mergeFieldPicker value and format it for Lava\r\n *\r\n * @param value The merge field to be formatted\r\n *\r\n * @returns The formatted string in a Promise\r\n */\r\nexport async function formatValue(value: string): Promise {\r\n const http = useHttp();\r\n\r\n const options: MergeFieldPickerFormatSelectedValueOptionsBag = {\r\n selectedValue: value\r\n };\r\n\r\n const response = await http.post(\"/api/v2/Controls/MergeFieldPickerFormatSelectedValue\", {}, options);\r\n\r\n if (response.isSuccess && response.data) {\r\n return response.data;\r\n }\r\n else {\r\n console.error(\"Error\", response.errorMessage || `Error formatting '${value}'.`);\r\n return \"\";\r\n }\r\n}","// \r\n// Copyright by the Spark Development Network\r\n//\r\n// Licensed under the Rock Community License (the \"License\");\r\n// you may not use this file except in compliance with the License.\r\n// You may obtain a copy of the License at\r\n//\r\n// http://www.rockrms.com/license\r\n//\r\n// Unless required by applicable law or agreed to in writing, software\r\n// distributed under the License is distributed on an \"AS IS\" BASIS,\r\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n// See the License for the specific language governing permissions and\r\n// limitations under the License.\r\n// \r\n\r\nexport function fromEntries(entries: Iterable<[PropertyKey, string]>): Record {\r\n const res = {};\r\n for (const entry of entries) {\r\n res[entry[0]] = entry[1];\r\n }\r\n return res;\r\n}\r\n\r\n/**\r\n * Gets the value at the specified path within the object.\r\n *\r\n * @example\r\n * const object = {\r\n * person: {\r\n * name: \"Ted Decker\"\r\n * }\r\n * };\r\n *\r\n * const value = getValueFromPath(object, \"person.name\"); // returns \"Ted Decker\"\r\n *\r\n * @param object The object containing the desired value.\r\n * @param path The dot-separated path name to the desired value.\r\n * @returns The value at the specified path within the object, or `undefined`\r\n * if no such path exists.\r\n */\r\nexport function getValueFromPath(object: Record, path: string): unknown {\r\n if (!object || !path) {\r\n return;\r\n }\r\n\r\n const pathNames = path.split(\".\");\r\n\r\n for (let i = 0; i < pathNames.length; i++) {\r\n const pathName = pathNames[i].trim();\r\n\r\n // If the object doesn't have the specified path name as its own\r\n // property, return `undefined`.\r\n if (!pathName || !Object.prototype.hasOwnProperty.call(object, pathName)) {\r\n return;\r\n }\r\n\r\n const value = object[pathName];\r\n\r\n // If this is the last path name specified, return the current value.\r\n if (i === pathNames.length - 1) {\r\n return value;\r\n }\r\n\r\n // If the current value is not an object, but there are still\r\n // more path names to traverse, return `undefined`.\r\n if (typeof value !== \"object\") {\r\n return;\r\n }\r\n\r\n // Reassign `object` to the current value. This type assertion might\r\n // be incorrect, but will be caught on the next iteration if so,\r\n // in which case `undefined` will be returned.\r\n object = value as Record;\r\n }\r\n\r\n // If we somehow got here, return `undefined`.\r\n return;\r\n}\r\n","// \r\n// Copyright by the Spark Development Network\r\n//\r\n// Licensed under the Rock Community License (the \"License\");\r\n// you may not use this file except in compliance with the License.\r\n// You may obtain a copy of the License at\r\n//\r\n// http://www.rockrms.com/license\r\n//\r\n// Unless required by applicable law or agreed to in writing, software\r\n// distributed under the License is distributed on an \"AS IS\" BASIS,\r\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n// See the License for the specific language governing permissions and\r\n// limitations under the License.\r\n// \r\n\r\nimport Cache from \"./cache\";\r\nimport { useHttp } from \"./http\";\r\nimport { PhoneNumberBoxGetConfigurationResultsBag } from \"@Obsidian/ViewModels/Rest/Controls/phoneNumberBoxGetConfigurationResultsBag\";\r\nimport { PhoneNumberCountryCodeRulesConfigurationBag } from \"@Obsidian/ViewModels/Rest/Controls/phoneNumberCountryCodeRulesConfigurationBag\";\r\nimport { PhoneNumberBoxGetConfigurationOptionsBag } from \"@Obsidian/ViewModels/Rest/Controls/phoneNumberBoxGetConfigurationOptionsBag\";\r\n\r\nconst http = useHttp();\r\n\r\n/**\r\n * Fetch the configuration for phone numbers and their possible formats for different countries\r\n */\r\nasync function fetchPhoneNumberConfiguration(): Promise {\r\n const result = await http.post(\"/api/v2/Controls/PhoneNumberBoxGetConfiguration\", undefined, null);\r\n\r\n if (result.isSuccess && result.data) {\r\n return result.data;\r\n }\r\n\r\n throw new Error(result.errorMessage ?? \"Error fetching phone number configuration\");\r\n}\r\n\r\n/**\r\n * Fetch the configuration for phone numbers, SMS option, and possible phone number formats for different countries\r\n */\r\nasync function fetchPhoneNumberAndSmsConfiguration(): Promise {\r\n const options: PhoneNumberBoxGetConfigurationOptionsBag = {\r\n showSmsOptIn: true\r\n };\r\n const result = await http.post(\"/api/v2/Controls/PhoneNumberBoxGetConfiguration\", undefined, options);\r\n\r\n if (result.isSuccess && result.data) {\r\n return result.data;\r\n }\r\n\r\n throw new Error(result.errorMessage ?? \"Error fetching phone number configuration\");\r\n}\r\n\r\n/**\r\n * Fetch the configuration for phone numbers and their possible formats for different countries.\r\n * Cacheable version of fetchPhoneNumberConfiguration cacheable\r\n */\r\nexport const getPhoneNumberConfiguration = Cache.cachePromiseFactory(\"phoneNumberConfiguration\", fetchPhoneNumberConfiguration);\r\n\r\nexport const getPhoneNumberAndSmsConfiguration = Cache.cachePromiseFactory(\"phoneNumberAndSmsConfiguration\", fetchPhoneNumberAndSmsConfiguration);\r\n\r\nconst defaultRulesConfig = [\r\n {\r\n \"match\": \"^(\\\\d{3})(\\\\d{4})$\",\r\n \"format\": \"$1-$2\"\r\n },\r\n {\r\n \"match\": \"^(\\\\d{3})(\\\\d{3})(\\\\d{4})$\",\r\n \"format\": \"($1) $2-$3\"\r\n },\r\n {\r\n \"match\": \"^1(\\\\d{3})(\\\\d{3})(\\\\d{4})$\",\r\n \"format\": \"($1) $2-$3\"\r\n }\r\n];\r\n\r\n/**\r\n * Format a phone number according to a given configuration\r\n *\r\n * e.g. from the default configuration:\r\n * 3214567 => 321-4567\r\n * 3214567890 => (321) 456-7890\r\n */\r\nexport function formatPhoneNumber(value: string, rules: PhoneNumberCountryCodeRulesConfigurationBag[] = defaultRulesConfig): string {\r\n value = stripPhoneNumber(value);\r\n\r\n if (!value || rules.length == 0) {\r\n return value;\r\n }\r\n\r\n for (const rule of rules) {\r\n const regex = new RegExp(rule.match ?? \"\");\r\n\r\n if (regex.test(value)) {\r\n return value.replace(regex, rule.format ?? \"\") || value;\r\n }\r\n }\r\n\r\n return value;\r\n}\r\n\r\n/**\r\n * Strips special characters from the phone number.\r\n * (321) 456-7890 => 3214567890\r\n * @param str\r\n */\r\nexport function stripPhoneNumber(str: string): string {\r\n if (!str) {\r\n return \"\";\r\n }\r\n\r\n return str.replace(/\\D/g, \"\");\r\n}\r\n\r\nexport default {\r\n getPhoneNumberConfiguration,\r\n formatPhoneNumber,\r\n stripPhoneNumber\r\n};\r\n\r\n/* eslint-disable */\r\n// @ts-ignore\r\nwindow.formatPhoneNumber = formatPhoneNumber;","// \r\n// Copyright by the Spark Development Network\r\n//\r\n// Licensed under the Rock Community License (the \"License\");\r\n// you may not use this file except in compliance with the License.\r\n// You may obtain a copy of the License at\r\n//\r\n// http://www.rockrms.com/license\r\n//\r\n// Unless required by applicable law or agreed to in writing, software\r\n// distributed under the License is distributed on an \"AS IS\" BASIS,\r\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n// See the License for the specific language governing permissions and\r\n// limitations under the License.\r\n// \r\n//\r\n\r\n\r\n// NOTE: Do not make this public yet. This is essentially temporary and\r\n// will likely move to a different place and be merged with the tooltip\r\n// concept code as well.\r\ntype PopoverOptions = {\r\n /** Allow HTML content in the popover. */\r\n html?: boolean;\r\n\r\n /** Enables santization of HTML content. */\r\n sanitize?: boolean;\r\n};\r\n\r\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\r\ndeclare const $: any;\r\n\r\n/**\r\n * Configure a popover for the specified node or nodes to show on hover. This\r\n * currently uses Bootstrap popovers but may be changed to use a different\r\n * method later.\r\n * \r\n * @param node The node or nodes to have popovers configured on.\r\n * @param options The options that describe how the popovers should behave.\r\n */\r\nexport function popover(node: Element | Element[], options?: PopoverOptions): void {\r\n // If we got an array of elements then activate each one.\r\n if (Array.isArray(node)) {\r\n for (const n of node) {\r\n popover(n, options);\r\n }\r\n\r\n return;\r\n }\r\n\r\n $(node).popover({\r\n html: options?.html,\r\n sanitize: options?.sanitize ?? true\r\n });\r\n}\r\n","// \r\n// Copyright by the Spark Development Network\r\n//\r\n// Licensed under the Rock Community License (the \"License\");\r\n// you may not use this file except in compliance with the License.\r\n// You may obtain a copy of the License at\r\n//\r\n// http://www.rockrms.com/license\r\n//\r\n// Unless required by applicable law or agreed to in writing, software\r\n// distributed under the License is distributed on an \"AS IS\" BASIS,\r\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n// See the License for the specific language governing permissions and\r\n// limitations under the License.\r\n// \r\n//\r\n\r\n/**\r\n * Returns a promise that completes after the specified number of milliseconds\r\n * have ellapsed.\r\n * \r\n * @param ms The number of milliseconds to wait.\r\n * \r\n * @returns A promise that completes after the interval has ellapsed.\r\n */\r\nexport function sleep(ms: number): Promise {\r\n return new Promise(resolve => {\r\n setTimeout(resolve, ms);\r\n });\r\n}\r\n\r\n/**\r\n * Checks if the value is a promise to return a value. This is used to check\r\n * if a function that could have returned either a value or a promise for a\r\n * value returned a promise.\r\n * \r\n * @param obj The object to be tested if it is a promise.\r\n *\r\n * @returns True if the object is a promise.\r\n */\r\nexport function isPromise(obj: PromiseLike | T): obj is PromiseLike {\r\n return !!obj && (typeof obj === \"object\" || typeof obj === \"function\") && typeof (obj as Record).then === \"function\";\r\n}\r\n\r\n/**\r\n * A class that provides a way to defer execution via await until some\r\n * external trigger happens.\r\n */\r\nexport class PromiseCompletionSource {\r\n private internalPromise: Promise;\r\n\r\n private internalResolve: (T) => void = () => { /* Intentionally blank. */ };\r\n\r\n private internalReject: (reason?: unknown) => void = () => { /* Intentionally blank. */ };\r\n\r\n constructor() {\r\n this.internalPromise = new Promise((resolve, reject) => {\r\n this.internalResolve = resolve;\r\n this.internalReject = reject;\r\n });\r\n }\r\n\r\n /** The promise that can be awaited. */\r\n public get promise(): Promise {\r\n return this.internalPromise;\r\n }\r\n\r\n /**\r\n * Resolves the promise with the given value.\r\n * \r\n * @param value The value to be returned by the await call.\r\n */\r\n public resolve(value: T): void {\r\n this.internalResolve(value);\r\n }\r\n\r\n /**\r\n * Rejects the promise and throws the reason as an error.\r\n * \r\n * @param reason The reason to be thrown by the await call.\r\n */\r\n public reject(reason?: unknown): void {\r\n this.internalReject(reason);\r\n }\r\n}\r\n","// \r\n// Copyright by the Spark Development Network\r\n//\r\n// Licensed under the Rock Community License (the \"License\");\r\n// you may not use this file except in compliance with the License.\r\n// You may obtain a copy of the License at\r\n//\r\n// http://www.rockrms.com/license\r\n//\r\n// Unless required by applicable law or agreed to in writing, software\r\n// distributed under the License is distributed on an \"AS IS\" BASIS,\r\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n// See the License for the specific language governing permissions and\r\n// limitations under the License.\r\n// \r\n//\r\n\r\nimport { loadJavaScriptAsync } from \"./page\";\r\n\r\n// Disable certain checks as they are needed to interface with existing JS file.\r\n/* eslint-disable @typescript-eslint/ban-types */\r\n/* eslint-disable @typescript-eslint/no-explicit-any */\r\n\r\n/** A generic set a server functions with no type checking. */\r\nexport type GenericServerFunctions = {\r\n [name: string]: (...args: unknown[]) => unknown;\r\n};\r\n\r\n/** A set of specific server functions that conform to an interface. */\r\nexport type ServerFunctions = {\r\n [K in keyof T]: T[K] extends Function ? T[K] : never;\r\n};\r\n\r\n/**\r\n * An object that allows RealTime communication between the browser and the Rock\r\n * server over a specific topic.\r\n */\r\nexport interface ITopic = GenericServerFunctions> {\r\n /**\r\n * Allows messages to be sent to the server. Any property access is treated\r\n * like a message function whose property name is the message name.\r\n */\r\n server: TServer;\r\n\r\n /**\r\n * Gets the connection identifier for this topic. This will be the same for\r\n * all topics, but that should not be relied on staying that way in the future.\r\n */\r\n get connectionId(): string | null;\r\n\r\n /**\r\n * Gets a value that indicates if the topic is currently reconnecting.\r\n */\r\n get isReconnecting(): boolean;\r\n\r\n /**\r\n * Gets a value that indicates if the topic is disconnected and will no\r\n * longer try to connect to the server.\r\n */\r\n get isDisconnected(): boolean;\r\n\r\n /**\r\n * Registers a handler to be called when a message with the given name\r\n * is received.\r\n *\r\n * @param messageName The message name that will trigger the handler.\r\n * @param handler The handler to be called when a message is received.\r\n */\r\n on(messageName: string, handler: ((...args: any[]) => void)): void;\r\n\r\n /**\r\n * Registers a handler to be called when any message is received.\r\n *\r\n * @param handler The handler to be called when a message is received.\r\n */\r\n onMessage(handler: ((messageName: string, args: unknown[]) => void)): void;\r\n\r\n /**\r\n * Registers a callback to be called when the connection has been\r\n * temporarily lost. An automatic reconnection is in progress. The topic\r\n * is now in a state where it can not send any messages.\r\n *\r\n * @param callback The callback to be called.\r\n */\r\n onReconnecting(callback: (() => void)): void;\r\n\r\n /**\r\n * Registers a callback to be called when the connection has been\r\n * reconnected. The topic can now send messages again.\r\n *\r\n * @param callback The callback to be called.\r\n */\r\n onReconnected(callback: (() => void)): void;\r\n\r\n /**\r\n * Registers a callback to be called when the connection has been lost\r\n * and will no longer try to reconnect.\r\n *\r\n * @param callback The callback to be called.\r\n */\r\n onDisconnected(callback: (() => void)): void;\r\n}\r\n\r\ninterface IRockRealTimeStatic {\r\n getTopic>(identifier: string): Promise>;\r\n}\r\n\r\nlet libraryObject: IRockRealTimeStatic | null = null;\r\nlet libraryPromise: Promise | null = null;\r\n\r\n/**\r\n * Gets the real time object from window.Rock.RealTime. If it is not available\r\n * then an exception will be thrown.\r\n *\r\n * @returns An instance of IRockRealTimeStatic.\r\n */\r\nasync function getRealTimeObject(): Promise {\r\n if (libraryObject) {\r\n return libraryObject;\r\n }\r\n\r\n if (!libraryPromise) {\r\n libraryPromise = loadJavaScriptAsync(\"/Scripts/Rock/realtime.js\", () => !!window[\"Rock\"]?.[\"RealTime\"]);\r\n }\r\n\r\n if (!await libraryPromise) {\r\n throw new Error(\"Unable to load RealTime library.\");\r\n }\r\n\r\n libraryObject = window[\"Rock\"]?.[\"RealTime\"] as IRockRealTimeStatic;\r\n\r\n return libraryObject;\r\n}\r\n\r\n/**\r\n * Connects to a specific topic in the Rock RealTime system and returns an\r\n * instance to a proxy that handles sending to and receiving messages from\r\n * that specific topic.\r\n *\r\n * @param identifier The identifier of the topic to be connected to.\r\n *\r\n * @returns A proxy to handle communication with the topic.\r\n */\r\nexport async function getTopic>(identifier: string): Promise> {\r\n const realTime = await getRealTimeObject();\r\n\r\n return realTime.getTopic(identifier);\r\n}\r\n","// \r\n// Copyright by the Spark Development Network\r\n//\r\n// Licensed under the Rock Community License (the \"License\");\r\n// you may not use this file except in compliance with the License.\r\n// You may obtain a copy of the License at\r\n//\r\n// http://www.rockrms.com/license\r\n//\r\n// Unless required by applicable law or agreed to in writing, software\r\n// distributed under the License is distributed on an \"AS IS\" BASIS,\r\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n// See the License for the specific language governing permissions and\r\n// limitations under the License.\r\n// \r\n//\r\n\r\nimport Big from \"@Obsidian/Libs/big\";\r\nimport { CurrencyInfoBag } from \"@Obsidian/ViewModels/Rest/Utilities/currencyInfoBag\";\r\nimport { toCurrencyOrNull } from \"./numberUtils\";\r\n\r\ntype RockCurrencyValue = number | string | RockCurrency;\r\n\r\nexport class RockCurrency {\r\n private readonly big: Big;\r\n\r\n get isZero(): boolean {\r\n return this.big.eq(0);\r\n }\r\n\r\n get number(): number {\r\n return this.big.toNumber();\r\n }\r\n\r\n get isNegative(): boolean {\r\n return this.big.lt(0);\r\n }\r\n\r\n get units(): number {\r\n return this.big.times(new Big(10).pow(this.currencyInfo.decimalPlaces)).toNumber();\r\n }\r\n\r\n /**\r\n * Creates a new RockCurrency instance.\r\n *\r\n * Keep private so the constructor can hide reference to the underlying Big library usage.\r\n */\r\n private constructor(value: RockCurrencyValue | Big.Big, readonly currencyInfo: CurrencyInfoBag) {\r\n if (value instanceof RockCurrency) {\r\n // Always truncate the currency value decimal places (with Big.roundDown).\r\n this.big = new Big(value.big).round(this.currencyInfo.decimalPlaces, Big.roundDown);\r\n }\r\n else {\r\n // Always truncate the currency value decimal places (with Big.roundDown).\r\n this.big = new Big(value).round(this.currencyInfo.decimalPlaces, Big.roundDown);\r\n }\r\n }\r\n\r\n /**\r\n * Creates a new instance of the RockCurrency class.\r\n *\r\n * @param value The currency value.\r\n * @param currencyInfo The currency info.\r\n * @returns A new RockCurrency instance.\r\n */\r\n static create(value: RockCurrencyValue, currencyInfo: CurrencyInfoBag): RockCurrency {\r\n return new RockCurrency(value, currencyInfo);\r\n }\r\n\r\n asRockCurrency(value: RockCurrencyValue): RockCurrency {\r\n return value instanceof RockCurrency ? value : new RockCurrency(value, this.currencyInfo);\r\n }\r\n\r\n /**\r\n * Adds an amount to this RockCurrency.\r\n *\r\n * @param value The amount to add to this currency. Fractional amounts that exceed this currency's precision will be truncated; e.g., if this currency has a precision of two ($31.45), and the amount being added has a precision of three ($2.289), the \"9\" will be truncated to $2.28.\r\n * @returns A createCurrency instance containing the sum of the two currencies.\r\n * @example\r\n * createCurrency(2.61).add(3.999); // returns createCurrency(6.60)\r\n * createCurrency(2.61).add(createCurrency(3.999)); // returns createCurrency(6.60)\r\n */\r\n add(value: RockCurrencyValue): RockCurrency {\r\n const currency = this.asRockCurrency(value);\r\n\r\n return new RockCurrency(this.big.plus(currency.big), this.currencyInfo);\r\n }\r\n\r\n /**\r\n * Gets the negation of this RockCurrency.\r\n *\r\n * @returns A createCurrency instance containing the negation of this RockCurrency.\r\n * @example\r\n * createCurrency(2.61).negate(); // returns createCurrency(-2.61)\r\n */\r\n negate(): RockCurrency {\r\n return new RockCurrency(this.big.neg(), this.currencyInfo);\r\n }\r\n\r\n /**\r\n * Divides this currency by a number.\r\n *\r\n * @param divisor The number by which to divide this currency. Must be a number as a currency cannot be divided by another currency.\r\n * @returns The quotient and remainder of the division as separate RockCurrency instances.\r\n * @example\r\n * createCurrency(3.50).divide(3); // returns { quotient: createCurrency(1.16), remainder: createCurrency(0.02) }\r\n */\r\n divide(divisor: number): { quotient: RockCurrency, remainder: RockCurrency } {\r\n // Always truncate the currency value decimal places (with Big.roundDown).\r\n const quotient = this.big.div(divisor).round(this.currencyInfo.decimalPlaces, Big.roundDown);\r\n const remainder = this.big.minus(quotient.times(divisor));\r\n\r\n return {\r\n quotient: new RockCurrency(quotient, this.currencyInfo),\r\n remainder: new RockCurrency(remainder, this.currencyInfo),\r\n };\r\n }\r\n\r\n /**\r\n * Subtracts an amount from this currency.\r\n *\r\n * @param currency The amount to subtract from this currency. Fractional amounts that exceed this currency's precision will be truncated; e.g., if this currency has a precision of two ($31.45), and the amount being subtracted has a precision of three ($2.289), the \"9\" will be truncated to $2.28.\r\n * @returns A createCurrency instance containing the difference of the two currencies.\r\n * @example\r\n * createCurrency(2.61).subtract(3.999); // returns createCurrency(-1.38)\r\n * createCurrency(2.61).subtract(createCurrency(3.999)); // returns createCurrency(-1.38)\r\n */\r\n subtract(value: RockCurrencyValue): RockCurrency {\r\n const currency = this.asRockCurrency(value);\r\n\r\n return new RockCurrency(this.big.minus(currency.big), this.currencyInfo);\r\n }\r\n\r\n /**\r\n * Determines if this currency is equal another currency.\r\n *\r\n * @param value The currency to which to compare.\r\n * @returns `true` if the currencies are equal; otherwise, `false` is returned.\r\n */\r\n isEqualTo(value: RockCurrencyValue): boolean {\r\n const currency = this.asRockCurrency(value);\r\n return this.big.eq(currency.big);\r\n }\r\n\r\n /**\r\n * Determines if this currency is not equal to another currency.\r\n *\r\n * @param value The currency to which to compare.\r\n * @returns `true` if the currencies are not equal; otherwise, `false` is returned.\r\n */\r\n isNotEqualTo(value: RockCurrencyValue): boolean {\r\n const currency = this.asRockCurrency(value);\r\n return !this.big.eq(currency.big);\r\n }\r\n\r\n /**\r\n * Determines if this currency is less than to another currency.\r\n *\r\n * @param value The currency to which to compare.\r\n * @returns `true` if this currency is less than the provided currency; otherwise, `false` is returned.\r\n */\r\n isLessThan(value: RockCurrencyValue): boolean {\r\n const currency = this.asRockCurrency(value);\r\n return this.big.lt(currency.big);\r\n }\r\n\r\n /**\r\n * Returns this currency limited by the provided value.\r\n *\r\n * @param value The currency to which to compare.\r\n * @returns `this` currency if it is equal to or greater than the limit; otherwise, `value` is returned.\r\n */\r\n noLessThan(value: RockCurrencyValue): RockCurrency {\r\n const currency = this.asRockCurrency(value);\r\n if (this.big.lt(currency.big)) {\r\n return new RockCurrency(currency.big, this.currencyInfo);\r\n }\r\n else {\r\n return this;\r\n }\r\n }\r\n\r\n /**\r\n * Determines if this currency is greater than to another currency.\r\n *\r\n * @param value The currency to which to compare.\r\n * @returns `true` if this currency is greater than the provided currency; otherwise, `false` is returned.\r\n */\r\n isGreaterThan(value: RockCurrencyValue): boolean {\r\n const limit = this.asRockCurrency(value);\r\n return this.big.gt(limit.big);\r\n }\r\n\r\n /**\r\n * Returns this currency limited by the provided value.\r\n *\r\n * @param value The currency to which to compare.\r\n * @returns `this` currency if it is equal to or less than the limit; otherwise, `limit` is returned.\r\n */\r\n noGreaterThan(value: RockCurrencyValue): RockCurrency {\r\n const currency = this.asRockCurrency(value);\r\n if (this.big.gt(currency.big)) {\r\n return currency;\r\n }\r\n else {\r\n return this;\r\n }\r\n }\r\n\r\n /** Gets the absolute value of this currency. */\r\n abs(): RockCurrency {\r\n return new RockCurrency(this.big.abs(), this.currencyInfo);\r\n }\r\n\r\n /**\r\n * Returns the remainder after dividing this currency by a number.\r\n */\r\n mod(divisor: number): RockCurrency {\r\n const { remainder } = this.divide(divisor);\r\n return remainder;\r\n }\r\n\r\n /**\r\n * Gets the formatted string value of this currency.\r\n */\r\n toString(): string {\r\n // Always truncate the currency value decimal places (with Big.roundDown).\r\n const valueString = this.big.toFixed(this.currencyInfo.decimalPlaces, Big.roundDown);\r\n\r\n return toCurrencyOrNull(valueString, this.currencyInfo) ?? `${this.currencyInfo.symbol}${valueString}`;\r\n }\r\n}","// \r\n// Copyright by the Spark Development Network\r\n//\r\n// Licensed under the Rock Community License (the \"License\");\r\n// you may not use this file except in compliance with the License.\r\n// You may obtain a copy of the License at\r\n//\r\n// http://www.rockrms.com/license\r\n//\r\n// Unless required by applicable law or agreed to in writing, software\r\n// distributed under the License is distributed on an \"AS IS\" BASIS,\r\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n// See the License for the specific language governing permissions and\r\n// limitations under the License.\r\n// \r\n//\r\n\r\nimport { ListItemBag } from \"@Obsidian/ViewModels/Utility/listItemBag\";\r\nimport { toNumber, toNumberOrNull } from \"./numberUtils\";\r\nimport { SlidingDateRangeType as RangeType, SlidingDateRangeType } from \"@Obsidian/Enums/Controls/slidingDateRangeType\";\r\nimport { TimeUnitType as TimeUnit } from \"@Obsidian/Enums/Controls/timeUnitType\";\r\nimport { DayOfWeek, RockDateTime } from \"./rockDateTime\";\r\n\r\n// This file contains helper functions and tooling required to work with sliding\r\n// date ranges. A sliding date range is one that, generally, is anchored to whatever\r\n// the current date and time is when the check is made. For example, \"within the next\r\n// 5 days\" would be the english equivalent of a sliding date range.\r\n\r\n/**\r\n * The enums have been moved to separate files in order to share with the back end. We import them\r\n * above (with the names used by the definitions that used to exist in this file) so they can be\r\n * used below and we export them here so that any files previously importing them from here\r\n * do not break.\r\n */\r\nexport { SlidingDateRangeType as RangeType } from \"@Obsidian/Enums/Controls/slidingDateRangeType\";\r\nexport { TimeUnitType as TimeUnit } from \"@Obsidian/Enums/Controls/timeUnitType\";\r\n\r\n/**\r\n * Specifies the information required to track a sliding date range.\r\n */\r\nexport type SlidingDateRange = {\r\n /** The type of sliding date range represented by this instance. */\r\n rangeType: RangeType;\r\n\r\n /** The unit of time represented by the timeValue property. */\r\n timeUnit?: TimeUnit;\r\n\r\n /** The number of time units used when calculating the date range. */\r\n timeValue?: number;\r\n\r\n /** The lower value of a specific date range. */\r\n lowerDate?: string;\r\n\r\n /** The upper value of a specific date range. */\r\n upperDate?: string;\r\n};\r\n\r\n/**\r\n * The sliding date range types represented as an array of ListItemBag objects.\r\n * These are ordered correctly and can be used in pickers.\r\n */\r\nexport const rangeTypeOptions: ListItemBag[] = [\r\n {\r\n value: RangeType.Current.toString(),\r\n text: \"Current\"\r\n },\r\n {\r\n value: RangeType.Previous.toString(),\r\n text: \"Previous\"\r\n },\r\n {\r\n value: RangeType.Last.toString(),\r\n text: \"Last\"\r\n },\r\n {\r\n value: RangeType.Next.toString(),\r\n text: \"Next\"\r\n },\r\n {\r\n value: RangeType.Upcoming.toString(),\r\n text: \"Upcoming\"\r\n },\r\n {\r\n value: RangeType.DateRange.toString(),\r\n text: \"Date Range\"\r\n }\r\n];\r\n\r\n/**\r\n * The sliding date range time units represented as an array of ListItemBag objects.\r\n * These are ordered correctly and can be used in pickers.\r\n */\r\nexport const timeUnitOptions: ListItemBag[] = [\r\n {\r\n value: TimeUnit.Hour.toString(),\r\n text: \"Hour\"\r\n },\r\n {\r\n value: TimeUnit.Day.toString(),\r\n text: \"Day\"\r\n },\r\n {\r\n value: TimeUnit.Week.toString(),\r\n text: \"Week\"\r\n },\r\n {\r\n value: TimeUnit.Month.toString(),\r\n text: \"Month\"\r\n },\r\n {\r\n value: TimeUnit.Year.toString(),\r\n text: \"Year\"\r\n },\r\n];\r\n\r\n/**\r\n * Helper function to get the text from a ListItemBag that matches the value.\r\n *\r\n * @param value The value to be searched for.\r\n * @param options The ListItemBag options to be searched.\r\n *\r\n * @returns The text value of the ListItemBag or an empty string if not found.\r\n */\r\nfunction getTextForValue(value: string, options: ListItemBag[]): string {\r\n const matches = options.filter(v => v.value === value);\r\n\r\n return matches.length > 0 ? matches[0].text ?? \"\" : \"\";\r\n}\r\n\r\n/**\r\n * Gets the user friendly text that represents the RangeType value.\r\n *\r\n * @param rangeType The RangeType value to be represented.\r\n *\r\n * @returns A human readable string that represents the RangeType value.\r\n */\r\nexport function getRangeTypeText(rangeType: RangeType): string {\r\n const rangeTypes = rangeTypeOptions.filter(o => o.value === rangeType.toString());\r\n\r\n return rangeTypes.length > 0 ? rangeTypes[0].text ?? \"\" : \"\";\r\n}\r\n\r\n/**\r\n * Gets the user friendly text that represents the TimeUnit value.\r\n *\r\n * @param timeUnit The TimeUnit value to be represented.\r\n *\r\n * @returns A human readable string that represents the TimeUnit value.\r\n */\r\nexport function getTimeUnitText(timeUnit: TimeUnit): string {\r\n const timeUnits = timeUnitOptions.filter(o => o.value === timeUnit.toString());\r\n\r\n return timeUnits.length > 0 ? timeUnits[0].text ?? \"\" : \"\";\r\n}\r\n\r\n/**\r\n * Parses a pipe delimited string into a SlidingDateRange native object. The\r\n * delimited string is a format used by attribute values and other places.\r\n *\r\n * @param value The pipe delimited string that should be parsed.\r\n *\r\n * @returns A SlidingDaterange object or null if the string could not be parsed.\r\n */\r\nexport function parseSlidingDateRangeString(value: string): SlidingDateRange | null {\r\n const segments = value.split(\"|\");\r\n\r\n if (segments.length < 3) {\r\n return null;\r\n }\r\n\r\n // Find the matching range types and time units (should be 0 or 1) that\r\n // match the values in the string.\r\n const rangeTypes = rangeTypeOptions.filter(o => (o.text ?? \"\").replace(\" \", \"\").toLowerCase() === segments[0].toLowerCase() || o.value === segments[0]);\r\n const timeUnits = timeUnitOptions.filter(o => (o.text ?? \"\").toLowerCase() === segments[2].toLowerCase() || o.value === segments[2]);\r\n\r\n if (rangeTypes.length === 0) {\r\n return null;\r\n }\r\n\r\n const range: SlidingDateRange = {\r\n rangeType: toNumber(rangeTypes[0].value)\r\n };\r\n\r\n // If the range type is one that has time units then parse the time units.\r\n if (([RangeType.Current, RangeType.Last, RangeType.Next, RangeType.Previous, RangeType.Upcoming] as number[]).includes(range.rangeType)) {\r\n range.timeUnit = timeUnits.length > 0 ? toNumber(timeUnits[0].value) as TimeUnit : TimeUnit.Hour;\r\n\r\n // If the range type is one that has time values then parse the time value.\r\n if (([RangeType.Last, RangeType.Next, RangeType.Previous, RangeType.Upcoming] as number[]).includes(range.rangeType)) {\r\n range.timeValue = toNumberOrNull(segments[1]) ?? 1;\r\n }\r\n }\r\n\r\n // Parse the lower and upper dates if our range type is a DateRange.\r\n if (range.rangeType === RangeType.DateRange) {\r\n if (segments.length > 3) {\r\n range.lowerDate = segments[3];\r\n }\r\n\r\n if (segments.length > 4) {\r\n range.upperDate = segments[4];\r\n }\r\n }\r\n\r\n return range;\r\n}\r\n\r\n/**\r\n * Formats the pipe delimited string.\r\n *\r\n * @param value The pipe delimited string that should be formatted.\r\n *\r\n * @returns A string that formats the sliding date range.\r\n */\r\nexport function slidingDateRangeToString(value: SlidingDateRange): string {\r\n\r\n switch (value.rangeType) {\r\n case RangeType.Current:\r\n return `Current||${getTextForValue(value.timeUnit?.toString() ?? \"\", timeUnitOptions)}||`;\r\n\r\n case RangeType.DateRange:\r\n return `DateRange|||${value.lowerDate ?? \"\"}|${value.upperDate ?? \"\"}`;\r\n\r\n default:\r\n return `${getTextForValue(value.rangeType.toString(), rangeTypeOptions)}|${value.timeValue ?? \"\"}|${getTextForValue(value.timeUnit?.toString() ?? \"\", timeUnitOptions)}||`;\r\n }\r\n}\r\n\r\n/**\r\n * Calculates the start and end dates in a sliding date range.\r\n *\r\n * @param value The sliding date range to use when calculating dates.\r\n * @param currentDateTime The date and time to use in any \"now\" calculations.\r\n *\r\n * @returns An object that contains the start and end dates and times.\r\n */\r\nexport function calculateSlidingDateRange(value: SlidingDateRange, currentDateTime: RockDateTime | null | undefined = undefined): { start: RockDateTime | null, end: RockDateTime | null } {\r\n const result: { start: RockDateTime | null, end: RockDateTime | null } = {\r\n start: null,\r\n end: null\r\n };\r\n\r\n if (!currentDateTime) {\r\n currentDateTime = RockDateTime.now();\r\n }\r\n\r\n if (value.rangeType === RangeType.Current) {\r\n if (value.timeUnit === TimeUnit.Hour) {\r\n result.start = RockDateTime.fromParts(currentDateTime.year, currentDateTime.month, currentDateTime.day, currentDateTime.hour, 0, 0);\r\n result.end = result.start?.addHours(1) ?? null;\r\n }\r\n else if (value.timeUnit === TimeUnit.Day) {\r\n result.start = currentDateTime.date;\r\n result.end = result.start.addDays(1);\r\n }\r\n else if (value.timeUnit === TimeUnit.Week) {\r\n // TODO: This needs to be updated to get the FirstDayOfWeek from server.\r\n let diff = currentDateTime.dayOfWeek - DayOfWeek.Monday;\r\n\r\n if (diff < 0) {\r\n diff += 7;\r\n }\r\n\r\n result.start = currentDateTime.addDays(-1 * diff).date;\r\n result.end = result.start.addDays(7);\r\n }\r\n else if (value.timeUnit === TimeUnit.Month) {\r\n result.start = RockDateTime.fromParts(currentDateTime.year, currentDateTime.month, 1);\r\n result.end = result.start?.addMonths(1) ?? null;\r\n }\r\n else if (value.timeUnit === TimeUnit.Year) {\r\n result.start = RockDateTime.fromParts(currentDateTime.year, 1, 1);\r\n result.end = RockDateTime.fromParts(currentDateTime.year + 1, 1, 1);\r\n }\r\n }\r\n else if (value.rangeType === RangeType.Last || value.rangeType === RangeType.Previous) {\r\n // The number of time units to adjust by.\r\n const count = value.timeValue ?? 1;\r\n\r\n // If we are getting \"Last\" then round up to include the\r\n // current day/week/month/year.\r\n const roundUpCount = value.rangeType === RangeType.Last ? 1 : 0;\r\n\r\n if (value.timeUnit === TimeUnit.Hour) {\r\n result.end = RockDateTime.fromParts(currentDateTime.year, currentDateTime.month, currentDateTime.day, currentDateTime.hour, 0, 0)\r\n ?.addHours(roundUpCount) ?? null;\r\n result.start = result.end?.addHours(-count) ?? null;\r\n }\r\n else if (value.timeUnit === TimeUnit.Day) {\r\n result.end = currentDateTime.date.addDays(roundUpCount);\r\n result.start = result.end?.addDays(-count) ?? null;\r\n }\r\n else if (value.timeUnit === TimeUnit.Week) {\r\n // TODO: This needs to be updated to get the FirstDayOfWeek from server.\r\n let diff = currentDateTime.dayOfWeek - DayOfWeek.Monday;\r\n\r\n if (diff < 0) {\r\n diff += 7;\r\n }\r\n\r\n result.end = currentDateTime.addDays(-1 * diff).date.addDays(7 * roundUpCount);\r\n result.start = result.end.addDays(-count * 7);\r\n }\r\n else if (value.timeUnit === TimeUnit.Month) {\r\n result.end = RockDateTime.fromParts(currentDateTime.year, currentDateTime.month, 1)?.addMonths(roundUpCount) ?? null;\r\n result.start = result.end?.addMonths(-count) ?? null;\r\n }\r\n else if (value.timeUnit === TimeUnit.Year) {\r\n result.end = RockDateTime.fromParts(currentDateTime.year, 1, 1)?.addYears(roundUpCount) ?? null;\r\n result.start = result.end?.addYears(-count) ?? null;\r\n }\r\n\r\n // don't let Last,Previous have any future dates\r\n const cutoffDate = currentDateTime.date.addDays(1);\r\n if (result.end && result.end.date > cutoffDate) {\r\n result.end = cutoffDate;\r\n }\r\n }\r\n else if (value.rangeType === RangeType.Next || value.rangeType === RangeType.Upcoming) {\r\n // The number of time units to adjust by.\r\n const count = value.timeValue ?? 1;\r\n\r\n // If we are getting \"Upcoming\" then round up to include the\r\n // current day/week/month/year.\r\n const roundUpCount = value.rangeType === RangeType.Upcoming ? 1 : 0;\r\n\r\n if (value.timeUnit === TimeUnit.Hour) {\r\n result.start = RockDateTime.fromParts(currentDateTime.year, currentDateTime.month, currentDateTime.day, currentDateTime.hour, 0, 0)\r\n ?.addHours(roundUpCount) ?? null;\r\n result.end = result.start?.addHours(count) ?? null;\r\n }\r\n else if (value.timeUnit === TimeUnit.Day) {\r\n result.start = currentDateTime.date.addDays(roundUpCount);\r\n result.end = result.start.addDays(count);\r\n }\r\n else if (value.timeUnit === TimeUnit.Week) {\r\n // TODO: This needs to be updated to get the FirstDayOfWeek from server.\r\n let diff = currentDateTime.dayOfWeek - DayOfWeek.Monday;\r\n\r\n if (diff < 0) {\r\n diff += 7;\r\n }\r\n\r\n result.start = currentDateTime.addDays(-1 * diff)\r\n .date.addDays(7 * roundUpCount);\r\n result.end = result.start.addDays(count * 7);\r\n }\r\n else if (value.timeUnit === TimeUnit.Month) {\r\n result.start = RockDateTime.fromParts(currentDateTime.year, currentDateTime.month, 1)\r\n ?.addMonths(roundUpCount) ?? null;\r\n result.end = result.start?.addMonths(count) ?? null;\r\n }\r\n else if (value.timeUnit === TimeUnit.Year) {\r\n result.start = RockDateTime.fromParts(currentDateTime.year, 1, 1)\r\n ?.addYears(roundUpCount) ?? null;\r\n result.end = result.start?.addYears(count) ?? null;\r\n }\r\n\r\n // don't let Next,Upcoming have any past dates\r\n if (result.start && result.start.date < currentDateTime.date) {\r\n result.start = currentDateTime.date;\r\n }\r\n }\r\n else if (value.rangeType === RangeType.DateRange) {\r\n result.start = RockDateTime.parseISO(value.lowerDate ?? \"\");\r\n result.end = RockDateTime.parseISO(value.upperDate ?? \"\");\r\n\r\n // Sliding date range does not use ISO dates (though might be changed\r\n // in the future). So if we can't parse as an ISO date then try a\r\n // natural parse.\r\n if (!result.start && value.lowerDate) {\r\n result.start = RockDateTime.fromJSDate(new Date(value.lowerDate));\r\n }\r\n\r\n if (!result.end && value.upperDate) {\r\n result.end = RockDateTime.fromJSDate(new Date(value.upperDate));\r\n }\r\n\r\n if (result.end) {\r\n // Add a day to the end so that we get the entire day when comparing.\r\n result.end = result.end.addDays(1);\r\n }\r\n }\r\n\r\n // To avoid confusion about the day or hour of the end of the date range,\r\n // subtract a millisecond off our 'less than' end date. For example, if our\r\n // end date is 2019-11-7, we actually want all the data less than 2019-11-8,\r\n // but if a developer does EndDate.DayOfWeek, they would want 2019-11-7 and\r\n // not 2019-11-8 So, to make sure we include all the data for 2019-11-7, but\r\n // avoid the confusion about what DayOfWeek of the end, we'll compromise by\r\n // subtracting a millisecond from the end date\r\n if (result.end && value.timeUnit != TimeUnit.Hour) {\r\n result.end = result.end.addMilliseconds(-1);\r\n }\r\n\r\n return result;\r\n}\r\n","// \r\n// Copyright by the Spark Development Network\r\n//\r\n// Licensed under the Rock Community License (the \"License\");\r\n// you may not use this file except in compliance with the License.\r\n// You may obtain a copy of the License at\r\n//\r\n// http://www.rockrms.com/license\r\n//\r\n// Unless required by applicable law or agreed to in writing, software\r\n// distributed under the License is distributed on an \"AS IS\" BASIS,\r\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n// See the License for the specific language governing permissions and\r\n// limitations under the License.\r\n// \r\n\r\nimport { useHttp } from \"./http\";\r\nimport { StructuredContentEditorConfigurationBag } from \"@Obsidian/ViewModels/Rest/Controls/structuredContentEditorConfigurationBag\";\r\nimport { StructuredContentEditorGetConfigurationOptionsBag } from \"@Obsidian/ViewModels/Rest/Controls/structuredContentEditorGetConfigurationOptionsBag\";\r\n\r\nconst http = useHttp();\r\n\r\n/** Fetches the configuration for the structured content editor. */\r\nexport async function getStructuredContentEditorConfiguration(options: StructuredContentEditorGetConfigurationOptionsBag): Promise {\r\n const result = await http.post(\"/api/v2/Controls/StructuredContentEditorGetConfiguration\", undefined, options);\r\n\r\n if (result.isSuccess && result.data) {\r\n return result.data;\r\n }\r\n\r\n throw new Error(result.errorMessage || \"Error fetching structured content editor configuration\");\r\n}\r\n\r\nexport default {\r\n getStructuredContentEditorConfiguration\r\n};","// \r\n// Copyright by the Spark Development Network\r\n//\r\n// Licensed under the Rock Community License (the \"License\");\r\n// you may not use this file except in compliance with the License.\r\n// You may obtain a copy of the License at\r\n//\r\n// http://www.rockrms.com/license\r\n//\r\n// Unless required by applicable law or agreed to in writing, software\r\n// distributed under the License is distributed on an \"AS IS\" BASIS,\r\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n// See the License for the specific language governing permissions and\r\n// limitations under the License.\r\n// \r\n//\r\n\r\n\r\n// NOTE: Do not make this public yet. This is essentially temporary and\r\n// will likely move to a different place and be merged with the popover\r\n// concept code as well.\r\ntype TooltipOptions = {\r\n /** Allow HTML content in the tooltip. */\r\n html?: boolean;\r\n\r\n /** Enables santization of HTML content. */\r\n sanitize?: boolean;\r\n};\r\n\r\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\r\ndeclare const $: any;\r\n\r\n/**\r\n * Configure a tooltip for the specified node or nodes to show on hover. This\r\n * currently uses Bootstrap tooltips but may be changed to use a different\r\n * method later.\r\n * \r\n * @param node The node or nodes to have tooltips configured on.\r\n * @param options The options that describe how the tooltips should behave.\r\n */\r\nexport function tooltip(node: Element | Element[], options?: TooltipOptions): void {\r\n // If we got an array of elements then activate each one.\r\n if (Array.isArray(node)) {\r\n for (const n of node) {\r\n tooltip(n, options);\r\n }\r\n\r\n return;\r\n }\r\n\r\n $(node).tooltip({\r\n html: options?.html,\r\n sanitize: options?.sanitize ?? true\r\n });\r\n}\r\n\r\n/**\r\n * Manually show a previously-configured tooltip for the specified node.\r\n *\r\n * @param node The node for which to show a tooltip\r\n */\r\nexport function showTooltip(node: Element): void {\r\n $(node).tooltip(\"show\");\r\n}\r\n","// \r\n// Copyright by the Spark Development Network\r\n//\r\n// Licensed under the Rock Community License (the \"License\");\r\n// you may not use this file except in compliance with the License.\r\n// You may obtain a copy of the License at\r\n//\r\n// http://www.rockrms.com/license\r\n//\r\n// Unless required by applicable law or agreed to in writing, software\r\n// distributed under the License is distributed on an \"AS IS\" BASIS,\r\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n// See the License for the specific language governing permissions and\r\n// limitations under the License.\r\n// \r\n//\r\n\r\nimport { Guid } from \"@Obsidian/Types\";\r\nimport { emptyGuid, toGuidOrNull } from \"./guid\";\r\nimport { post } from \"./http\";\r\nimport { TreeItemBag } from \"@Obsidian/ViewModels/Utility/treeItemBag\";\r\nimport { CategoryPickerChildTreeItemsOptionsBag } from \"@Obsidian/ViewModels/Rest/Controls/categoryPickerChildTreeItemsOptionsBag\";\r\nimport { LocationItemPickerGetActiveChildrenOptionsBag } from \"@Obsidian/ViewModels/Rest/Controls/locationItemPickerGetActiveChildrenOptionsBag\";\r\nimport { DataViewPickerGetDataViewsOptionsBag } from \"@Obsidian/ViewModels/Rest/Controls/dataViewPickerGetDataViewsOptionsBag\";\r\nimport { WorkflowTypePickerGetWorkflowTypesOptionsBag } from \"@Obsidian/ViewModels/Rest/Controls/workflowTypePickerGetWorkflowTypesOptionsBag\";\r\nimport { PagePickerGetChildrenOptionsBag } from \"@Obsidian/ViewModels/Rest/Controls/pagePickerGetChildrenOptionsBag\";\r\nimport { PagePickerGetSelectedPageHierarchyOptionsBag } from \"@Obsidian/ViewModels/Rest/Controls/pagePickerGetSelectedPageHierarchyOptionsBag\";\r\nimport { ConnectionRequestPickerGetChildrenOptionsBag } from \"@Obsidian/ViewModels/Rest/Controls/connectionRequestPickerGetChildrenOptionsBag\";\r\nimport { GroupPickerGetChildrenOptionsBag } from \"@Obsidian/ViewModels/Rest/Controls/groupPickerGetChildrenOptionsBag\";\r\nimport { MergeTemplatePickerGetMergeTemplatesOptionsBag } from \"@Obsidian/ViewModels/Rest/Controls/mergeTemplatePickerGetMergeTemplatesOptionsBag\";\r\nimport { MergeTemplateOwnership } from \"@Obsidian/Enums/Controls/mergeTemplateOwnership\";\r\nimport { MetricCategoryPickerGetChildrenOptionsBag } from \"@Obsidian/ViewModels/Rest/Controls/metricCategoryPickerGetChildrenOptionsBag\";\r\nimport { MetricItemPickerGetChildrenOptionsBag } from \"@Obsidian/ViewModels/Rest/Controls/metricItemPickerGetChildrenOptionsBag\";\r\nimport { RegistrationTemplatePickerGetChildrenOptionsBag } from \"@Obsidian/ViewModels/Rest/Controls/registrationTemplatePickerGetChildrenOptionsBag\";\r\nimport { ReportPickerGetChildrenOptionsBag } from \"@Obsidian/ViewModels/Rest/Controls/reportPickerGetChildrenOptionsBag\";\r\nimport { SchedulePickerGetChildrenOptionsBag } from \"@Obsidian/ViewModels/Rest/Controls/schedulePickerGetChildrenOptionsBag\";\r\nimport { WorkflowActionTypePickerGetChildrenOptionsBag } from \"@Obsidian/ViewModels/Rest/Controls/workflowActionTypePickerGetChildrenOptionsBag\";\r\nimport { MergeFieldPickerGetChildrenOptionsBag } from \"@Obsidian/ViewModels/Rest/Controls/mergeFieldPickerGetChildrenOptionsBag\";\r\nimport { flatten } from \"./arrayUtils\";\r\nimport { toNumberOrNull } from \"./numberUtils\";\r\n\r\n/**\r\n * The methods that must be implemented by tree item providers. These methods\r\n * provide the TreeItem objects to be displayed when lazy loading is being used.\r\n */\r\nexport interface ITreeItemProvider {\r\n /**\r\n * Get the root items to be displayed in the tree list.\r\n *\r\n * @param expandToValues The values that should be auto-expanded to. This will contain\r\n * the nodes that should be visible when the data is returned, they should not be\r\n * expanded themselves, only any ancestor nodes.\r\n *\r\n * @returns A collection of TreeItem objects, optionally wrapped in a Promise\r\n * if the loading is being performed asynchronously.\r\n */\r\n getRootItems(expandToValues: string[]): Promise | TreeItemBag[];\r\n\r\n /**\r\n * Get the child items of the given tree item.\r\n *\r\n * @param item The parent item whose children should be loaded.\r\n *\r\n * @returns A collection of TreeItem objects, optionally wrapped in a Promise\r\n * if the loading is being performed asynchronously.\r\n */\r\n getChildItems(item: TreeItemBag): Promise | TreeItemBag[];\r\n\r\n /**\r\n * Checks if the item can be selected by the individual. This function\r\n * is optional.\r\n *\r\n * @param item The item that is about to be selected.\r\n * @param isSelectable True if the tree view considers the item selectable.\r\n *\r\n * @returns A boolean that determines the final selectable state of the item.\r\n */\r\n canSelectItem?(item: TreeItemBag, isSelectable: boolean): boolean;\r\n}\r\n\r\n/**\r\n * Tree Item Provider for retrieving categories from the server and displaying\r\n * them inside a tree list.\r\n */\r\nexport class CategoryTreeItemProvider implements ITreeItemProvider {\r\n /**\r\n * The root category to start pulling categories from. Set to undefined to\r\n * begin with any category that does not have a parent.\r\n */\r\n public rootCategoryGuid?: Guid;\r\n\r\n /**\r\n * The entity type unique identifier to restrict results to. Set to undefined\r\n * to include all categories, regardless of entity type.\r\n */\r\n public entityTypeGuid?: Guid;\r\n\r\n /**\r\n * The value that must match in the category EntityTypeQualifierColumn\r\n * property. Set to undefined or an empty string to ignore.\r\n */\r\n public entityTypeQualifierColumn?: string;\r\n\r\n /**\r\n * The value that must match in the category EntityTypeQualifierValue\r\n * property.\r\n */\r\n public entityTypeQualifierValue?: string;\r\n\r\n /**\r\n * The security grant token that will be used to request additional access\r\n * to the category list.\r\n */\r\n public securityGrantToken?: string | null;\r\n\r\n /**\r\n * Gets the child items from the server.\r\n *\r\n * @param parentGuid The parent item whose children are retrieved.\r\n *\r\n * @returns A collection of TreeItem objects as an asynchronous operation.\r\n */\r\n private async getItems(parentGuid?: Guid | null): Promise {\r\n const options: CategoryPickerChildTreeItemsOptionsBag = {\r\n parentGuid: parentGuid,\r\n entityTypeGuid: this.entityTypeGuid,\r\n entityTypeQualifierColumn: this.entityTypeQualifierColumn,\r\n entityTypeQualifierValue: this.entityTypeQualifierValue,\r\n lazyLoad: false,\r\n securityGrantToken: this.securityGrantToken,\r\n\r\n getCategorizedItems: false,\r\n includeCategoriesWithoutChildren: true,\r\n includeInactiveItems: false,\r\n includeUnnamedEntityItems: false,\r\n };\r\n\r\n const response = await post(\"/api/v2/Controls/CategoryPickerChildTreeItems\", {}, options);\r\n\r\n if (response.isSuccess && response.data) {\r\n return response.data;\r\n }\r\n else {\r\n console.log(\"Error\", response.errorMessage);\r\n return [];\r\n }\r\n }\r\n\r\n /**\r\n * @inheritdoc\r\n */\r\n async getRootItems(): Promise {\r\n return await this.getItems(this.rootCategoryGuid);\r\n }\r\n\r\n /**\r\n * @inheritdoc\r\n */\r\n async getChildItems(item: TreeItemBag): Promise {\r\n return this.getItems(item.value);\r\n }\r\n}\r\n\r\n/**\r\n * Tree Item Provider for retrieving locations from the server and displaying\r\n * them inside a tree list.\r\n */\r\nexport class LocationTreeItemProvider implements ITreeItemProvider {\r\n /**\r\n * The security grant token that will be used to request additional access\r\n * to the category list.\r\n */\r\n public securityGrantToken?: string | null;\r\n\r\n /**\r\n * Gets the child items from the server.\r\n *\r\n * @param parentGuid The parent item whose children are retrieved.\r\n *\r\n * @returns A collection of TreeItem objects as an asynchronous operation.\r\n */\r\n private async getItems(parentGuid?: Guid | null): Promise {\r\n const options: LocationItemPickerGetActiveChildrenOptionsBag = {\r\n guid: toGuidOrNull(parentGuid) ?? emptyGuid,\r\n rootLocationGuid: emptyGuid,\r\n securityGrantToken: this.securityGrantToken\r\n };\r\n const url = \"/api/v2/Controls/LocationItemPickerGetActiveChildren\";\r\n const response = await post(url, undefined, options);\r\n\r\n if (response.isSuccess && response.data) {\r\n return response.data;\r\n }\r\n else {\r\n console.log(\"Error\", response.errorMessage);\r\n return [];\r\n }\r\n }\r\n\r\n /**\r\n * @inheritdoc\r\n */\r\n async getRootItems(): Promise {\r\n return await this.getItems(null);\r\n }\r\n\r\n /**\r\n * @inheritdoc\r\n */\r\n async getChildItems(item: TreeItemBag): Promise {\r\n return this.getItems(item.value);\r\n }\r\n}\r\n\r\n/**\r\n * Tree Item Provider for retrieving data views from the server and displaying\r\n * them inside a tree list.\r\n */\r\nexport class DataViewTreeItemProvider implements ITreeItemProvider {\r\n /**\r\n * The entity type unique identifier to restrict results to. Set to undefined\r\n * to include all categories, regardless of entity type.\r\n */\r\n public entityTypeGuid?: Guid;\r\n\r\n /**\r\n * The security grant token that will be used to request additional access\r\n * to the category list.\r\n */\r\n public securityGrantToken?: string | null;\r\n\r\n /**\r\n * The flag sets whether only persisted data view should be shown by the picker\r\n */\r\n public displayPersistedOnly: boolean = false;\r\n\r\n /**\r\n * Gets the child items from the server.\r\n *\r\n * @param parentGuid The parent item whose children are retrieved.\r\n *\r\n * @returns A collection of TreeItem objects as an asynchronous operation.\r\n */\r\n private async getItems(parentGuid?: Guid | null): Promise {\r\n const options: DataViewPickerGetDataViewsOptionsBag = {\r\n parentGuid,\r\n getCategorizedItems: true,\r\n includeCategoriesWithoutChildren: false,\r\n entityTypeGuidFilter: this.entityTypeGuid,\r\n lazyLoad: false,\r\n securityGrantToken: this.securityGrantToken,\r\n displayPersistedOnly: this.displayPersistedOnly,\r\n includeUnnamedEntityItems: false,\r\n };\r\n\r\n const response = await post(\"/api/v2/Controls/DataViewPickerGetDataViews\", {}, options);\r\n\r\n if (response.isSuccess && response.data) {\r\n return response.data;\r\n }\r\n else {\r\n console.log(\"Error\", response.errorMessage);\r\n return [];\r\n }\r\n }\r\n\r\n /**\r\n * @inheritdoc\r\n */\r\n async getRootItems(): Promise {\r\n return await this.getItems();\r\n }\r\n\r\n /**\r\n * @inheritdoc\r\n */\r\n async getChildItems(item: TreeItemBag): Promise {\r\n return this.getItems(item.value);\r\n }\r\n}\r\n\r\n/**\r\n * Tree Item Provider for retrieving categories from the server and displaying\r\n * them inside a tree list.\r\n */\r\nexport class WorkflowTypeTreeItemProvider implements ITreeItemProvider {\r\n /**\r\n * The entity type unique identifier to restrict results to. Set to undefined\r\n * to include all categories, regardless of entity type.\r\n */\r\n public includeInactiveItems?: boolean;\r\n\r\n /**\r\n * The security grant token that will be used to request additional access\r\n * to the category list.\r\n */\r\n public securityGrantToken?: string | null;\r\n\r\n /**\r\n * Gets the child items from the server.\r\n *\r\n * @param parentGuid The parent item whose children are retrieved.\r\n *\r\n * @returns A collection of TreeItem objects as an asynchronous operation.\r\n */\r\n private async getItems(parentGuid?: Guid | null): Promise {\r\n const options: WorkflowTypePickerGetWorkflowTypesOptionsBag = {\r\n parentGuid,\r\n includeInactiveItems: this.includeInactiveItems ?? false,\r\n securityGrantToken: this.securityGrantToken,\r\n\r\n getCategorizedItems: false,\r\n includeCategoriesWithoutChildren: false,\r\n includeUnnamedEntityItems: false,\r\n lazyLoad: false,\r\n };\r\n\r\n const response = await post(\"/api/v2/Controls/WorkflowTypePickerGetWorkflowTypes\", {}, options);\r\n\r\n if (response.isSuccess && response.data) {\r\n return response.data;\r\n }\r\n else {\r\n console.log(\"Error\", response.errorMessage);\r\n return [];\r\n }\r\n }\r\n\r\n /**\r\n * @inheritdoc\r\n */\r\n async getRootItems(): Promise {\r\n return await this.getItems();\r\n }\r\n\r\n /**\r\n * @inheritdoc\r\n */\r\n async getChildItems(item: TreeItemBag): Promise {\r\n return this.getItems(item.value);\r\n }\r\n}\r\n\r\n\r\n/**\r\n * Tree Item Provider for retrieving pages from the server and displaying\r\n * them inside a tree list.\r\n */\r\nexport class PageTreeItemProvider implements ITreeItemProvider {\r\n /**\r\n * The security grant token that will be used to request additional access\r\n * to the category list.\r\n */\r\n public securityGrantToken?: string | null;\r\n\r\n /**\r\n * List of GUIDs or pages to exclude from the list.\r\n */\r\n public hidePageGuids?: Guid[] | null;\r\n\r\n /**\r\n * Currently selected page\r\n */\r\n public selectedPageGuids?: Guid[] | null;\r\n\r\n /**\r\n * Gets the child items of the given parent (or root if no parent given) from the server.\r\n *\r\n * @param parentGuid The parent item whose children are retrieved.\r\n *\r\n * @returns A collection of TreeItem objects as an asynchronous operation.\r\n */\r\n private async getItems(parentGuid?: Guid | null): Promise {\r\n let result: TreeItemBag[];\r\n\r\n const options: PagePickerGetChildrenOptionsBag = {\r\n guid: toGuidOrNull(parentGuid) ?? emptyGuid,\r\n rootPageGuid: null,\r\n hidePageGuids: this.hidePageGuids ?? [],\r\n securityGrantToken: this.securityGrantToken\r\n };\r\n const url = \"/api/v2/Controls/PagePickerGetChildren\";\r\n const response = await post(url, undefined, options);\r\n\r\n if (response.isSuccess && response.data) {\r\n result = response.data;\r\n }\r\n else {\r\n console.log(\"Error\", response.errorMessage);\r\n return [];\r\n }\r\n\r\n // If we're getting child nodes or if there is no selected page\r\n if (parentGuid || !this.selectedPageGuids) {\r\n return result;\r\n }\r\n\r\n // If we're getting the root elements and we have a selected page, we also want to grab\r\n // all the parent pages so we can pre-load the entire hierarchy to the selected page\r\n return this.getHierarchyToSelectedPage(result);\r\n }\r\n\r\n /**\r\n * Get the hierarchical list of parent pages of the selectedPageGuid\r\n *\r\n * @returns A list of GUIDs of the parent pages\r\n */\r\n private async getParentList(): Promise {\r\n const options: PagePickerGetSelectedPageHierarchyOptionsBag = {\r\n selectedPageGuids: this.selectedPageGuids,\r\n securityGrantToken: this.securityGrantToken\r\n };\r\n const url = \"/api/v2/Controls/PagePickerGetSelectedPageHierarchy\";\r\n const response = await post(url, undefined, options);\r\n\r\n if (response.isSuccess && response.data) {\r\n return response.data;\r\n }\r\n else {\r\n console.log(\"Error\", response.errorMessage);\r\n return [];\r\n }\r\n }\r\n\r\n /**\r\n * Fill in pages to the depth of the selected page\r\n *\r\n * @param rootLayer The bottom layer of pages that we'll build depth upon\r\n *\r\n * @return The augmented `rootLayer` with the child pages\r\n */\r\n private async getHierarchyToSelectedPage(rootLayer: TreeItemBag[]): Promise {\r\n const parents = await this.getParentList();\r\n\r\n if (!parents || parents.length == 0) {\r\n // Selected page has no parents, so we're done.\r\n return rootLayer;\r\n }\r\n\r\n const childLists = await Promise.all(parents.map(guid => this.getItems(guid)));\r\n const allPages = rootLayer.concat(flatten(childLists));\r\n\r\n parents.forEach((parentGuid, i) => {\r\n const parentPage: TreeItemBag | undefined = allPages.find(page => page.value == parentGuid);\r\n if (parentPage) {\r\n parentPage.children = childLists[i];\r\n }\r\n });\r\n\r\n return rootLayer;\r\n }\r\n\r\n\r\n /**\r\n * @inheritdoc\r\n */\r\n async getRootItems(): Promise {\r\n return await this.getItems(null);\r\n }\r\n\r\n /**\r\n * @inheritdoc\r\n */\r\n async getChildItems(item: TreeItemBag): Promise {\r\n return this.getItems(item.value);\r\n }\r\n}\r\n\r\n\r\n/**\r\n * Tree Item Provider for retrieving connection requests from the server and displaying\r\n * them inside a tree list.\r\n */\r\nexport class ConnectionRequestTreeItemProvider implements ITreeItemProvider {\r\n /**\r\n * The security grant token that will be used to request additional access\r\n * to the category list.\r\n */\r\n public securityGrantToken?: string | null;\r\n\r\n /**\r\n * Gets the child items from the server.\r\n *\r\n * @param parentGuid The parent item whose children are retrieved.\r\n *\r\n * @returns A collection of TreeItem objects as an asynchronous operation.\r\n */\r\n private async getItems(parentGuid?: Guid | null): Promise {\r\n const options: ConnectionRequestPickerGetChildrenOptionsBag = {\r\n parentGuid,\r\n securityGrantToken: this.securityGrantToken\r\n };\r\n const url = \"/api/v2/Controls/ConnectionRequestPickerGetChildren\";\r\n const response = await post(url, undefined, options);\r\n\r\n if (response.isSuccess && response.data) {\r\n return response.data;\r\n }\r\n else {\r\n console.log(\"Error\", response.errorMessage);\r\n return [];\r\n }\r\n }\r\n\r\n /**\r\n * @inheritdoc\r\n */\r\n async getRootItems(): Promise {\r\n return await this.getItems(null);\r\n }\r\n\r\n /**\r\n * @inheritdoc\r\n */\r\n async getChildItems(item: TreeItemBag): Promise {\r\n return this.getItems(item.value);\r\n }\r\n}\r\n\r\n\r\n/**\r\n * Tree Item Provider for retrieving groups from the server and displaying\r\n * them inside a tree list.\r\n */\r\nexport class GroupTreeItemProvider implements ITreeItemProvider {\r\n /** The security grant token that will be used to request additional access to the group list. */\r\n public securityGrantToken: string | null = null;\r\n\r\n /** GUID of the group you want to use as the root. */\r\n public rootGroupGuid: Guid | null = null;\r\n\r\n /** List of group types GUIDs to limit to groups of those types. */\r\n public includedGroupTypeGuids: Guid[] = [];\r\n\r\n /** Whether to include inactive groups or not. */\r\n public includeInactiveGroups: boolean = false;\r\n\r\n /** Whether to limit to only groups that have scheduling enabled. */\r\n public limitToSchedulingEnabled: boolean = false;\r\n\r\n /** Whether to limit to only groups that have RSVPs enabled. */\r\n public limitToRSVPEnabled: boolean = false;\r\n\r\n /**\r\n * Gets the child items from the server.\r\n *\r\n * @param parentGuid The parent item whose children are retrieved.\r\n *\r\n * @returns A collection of TreeItem objects as an asynchronous operation.\r\n */\r\n private async getItems(parentGuid: Guid | null = null): Promise {\r\n const options: GroupPickerGetChildrenOptionsBag = {\r\n guid: parentGuid,\r\n rootGroupGuid: this.rootGroupGuid,\r\n includedGroupTypeGuids: this.includedGroupTypeGuids,\r\n includeInactiveGroups: this.includeInactiveGroups,\r\n limitToSchedulingEnabled: this.limitToSchedulingEnabled,\r\n limitToRSVPEnabled: this.limitToRSVPEnabled,\r\n securityGrantToken: this.securityGrantToken\r\n };\r\n const url = \"/api/v2/Controls/GroupPickerGetChildren\";\r\n const response = await post(url, undefined, options);\r\n\r\n if (response.isSuccess && response.data) {\r\n return response.data;\r\n }\r\n else {\r\n console.log(\"Error\", response.errorMessage);\r\n return [];\r\n }\r\n }\r\n\r\n /**\r\n * @inheritdoc\r\n */\r\n async getRootItems(): Promise {\r\n return await this.getItems(null);\r\n }\r\n\r\n /**\r\n * @inheritdoc\r\n */\r\n async getChildItems(item: TreeItemBag): Promise {\r\n return this.getItems(item.value);\r\n }\r\n}\r\n\r\n\r\n/**\r\n * Tree Item Provider for retrieving merge templates from the server and displaying\r\n * them inside a tree list.\r\n */\r\nexport class MergeTemplateTreeItemProvider implements ITreeItemProvider {\r\n /** The security grant token that will be used to request additional access to the group list. */\r\n public securityGrantToken: string | null = null;\r\n\r\n /** Filter for which merge templates to include in results: Global, Public, or Both */\r\n public mergeTemplateOwnership: MergeTemplateOwnership = MergeTemplateOwnership.Global;\r\n\r\n /**\r\n * Gets the child items from the server.\r\n *\r\n * @param parentGuid The parent item whose children are retrieved.\r\n *\r\n * @returns A collection of TreeItem objects as an asynchronous operation.\r\n */\r\n private async getItems(parentGuid: Guid | null = null): Promise {\r\n const options: MergeTemplatePickerGetMergeTemplatesOptionsBag = {\r\n parentGuid,\r\n mergeTemplateOwnership: (toNumberOrNull(this.mergeTemplateOwnership) ?? 0) as MergeTemplateOwnership,\r\n securityGrantToken: this.securityGrantToken\r\n };\r\n const url = \"/api/v2/Controls/MergeTemplatePickerGetMergeTemplates\";\r\n const response = await post(url, undefined, options);\r\n\r\n if (response.isSuccess && response.data) {\r\n return response.data;\r\n }\r\n else {\r\n console.log(\"Error\", response.errorMessage);\r\n return [];\r\n }\r\n }\r\n\r\n /**\r\n * @inheritdoc\r\n */\r\n async getRootItems(): Promise {\r\n return await this.getItems(null);\r\n }\r\n\r\n /**\r\n * @inheritdoc\r\n */\r\n async getChildItems(item: TreeItemBag): Promise {\r\n return this.getItems(item.value);\r\n }\r\n}\r\n\r\n\r\n/**\r\n * Tree Item Provider for retrieving merge templates from the server and displaying\r\n * them inside a tree list.\r\n */\r\nexport class MetricCategoryTreeItemProvider implements ITreeItemProvider {\r\n /** The security grant token that will be used to request additional access to the group list. */\r\n public securityGrantToken: string | null = null;\r\n\r\n /**\r\n * Gets the child items from the server.\r\n *\r\n * @param parentGuid The parent item whose children are retrieved.\r\n *\r\n * @returns A collection of TreeItem objects as an asynchronous operation.\r\n */\r\n private async getItems(parentGuid: Guid | null = null): Promise {\r\n const options: MetricCategoryPickerGetChildrenOptionsBag = {\r\n parentGuid,\r\n securityGrantToken: this.securityGrantToken\r\n };\r\n const url = \"/api/v2/Controls/MetricCategoryPickerGetChildren\";\r\n const response = await post(url, undefined, options);\r\n\r\n if (response.isSuccess && response.data) {\r\n return response.data;\r\n }\r\n else {\r\n console.log(\"Error\", response.errorMessage);\r\n return [];\r\n }\r\n }\r\n\r\n /**\r\n * @inheritdoc\r\n */\r\n async getRootItems(): Promise {\r\n return await this.getItems(null);\r\n }\r\n\r\n /**\r\n * @inheritdoc\r\n */\r\n async getChildItems(item: TreeItemBag): Promise {\r\n return this.getItems(item.value);\r\n }\r\n}\r\n\r\n/**\r\n * Tree Item Provider for retrieving merge templates from the server and displaying\r\n * them inside a tree list.\r\n */\r\nexport class MetricItemTreeItemProvider implements ITreeItemProvider {\r\n /** The security grant token that will be used to request additional access to the group list. */\r\n public securityGrantToken: string | null = null;\r\n\r\n /** A list of category GUIDs to filter the results */\r\n public includeCategoryGuids: Guid[] | null = null;\r\n\r\n /**\r\n * Gets the child items from the server.\r\n *\r\n * @param parentGuid The parent item whose children are retrieved.\r\n *\r\n * @returns A collection of TreeItem objects as an asynchronous operation.\r\n */\r\n private async getItems(parentGuid: Guid | null = null): Promise {\r\n const options: MetricItemPickerGetChildrenOptionsBag = {\r\n parentGuid,\r\n includeCategoryGuids: this.includeCategoryGuids,\r\n securityGrantToken: this.securityGrantToken\r\n };\r\n const url = \"/api/v2/Controls/MetricItemPickerGetChildren\";\r\n const response = await post(url, undefined, options);\r\n\r\n if (response.isSuccess && response.data) {\r\n return response.data;\r\n }\r\n else {\r\n console.log(\"Error\", response.errorMessage);\r\n return [];\r\n }\r\n }\r\n\r\n /**\r\n * @inheritdoc\r\n */\r\n async getRootItems(): Promise {\r\n return await this.getItems(null);\r\n }\r\n\r\n /**\r\n * @inheritdoc\r\n */\r\n async getChildItems(item: TreeItemBag): Promise {\r\n return this.getItems(item.value);\r\n }\r\n}\r\n\r\n\r\n/**\r\n * Tree Item Provider for retrieving registration templates from the server and displaying\r\n * them inside a tree list.\r\n */\r\nexport class RegistrationTemplateTreeItemProvider implements ITreeItemProvider {\r\n /** The security grant token that will be used to request additional access to the group list. */\r\n public securityGrantToken: string | null = null;\r\n\r\n /**\r\n * Gets the child items from the server.\r\n *\r\n * @param parentGuid The parent item whose children are retrieved.\r\n *\r\n * @returns A collection of TreeItem objects as an asynchronous operation.\r\n */\r\n private async getItems(parentGuid: Guid | null = null): Promise {\r\n const options: RegistrationTemplatePickerGetChildrenOptionsBag = {\r\n parentGuid,\r\n securityGrantToken: this.securityGrantToken\r\n };\r\n const url = \"/api/v2/Controls/RegistrationTemplatePickerGetChildren\";\r\n const response = await post(url, undefined, options);\r\n\r\n if (response.isSuccess && response.data) {\r\n return response.data;\r\n }\r\n else {\r\n console.log(\"Error\", response.errorMessage);\r\n return [];\r\n }\r\n }\r\n\r\n /**\r\n * @inheritdoc\r\n */\r\n async getRootItems(): Promise {\r\n return await this.getItems(null);\r\n }\r\n\r\n /**\r\n * @inheritdoc\r\n */\r\n async getChildItems(item: TreeItemBag): Promise {\r\n return this.getItems(item.value);\r\n }\r\n}\r\n\r\n\r\n/**\r\n * Tree Item Provider for retrieving reports from the server and displaying\r\n * them inside a tree list.\r\n */\r\nexport class ReportTreeItemProvider implements ITreeItemProvider {\r\n /** The security grant token that will be used to request additional access to the group list. */\r\n public securityGrantToken: string | null = null;\r\n\r\n /** A list of category GUIDs to filter the results. */\r\n public includeCategoryGuids: Guid[] | null = null;\r\n\r\n /** Guid of an Entity Type to filter results by the reports that relate to this entity type. */\r\n public entityTypeGuid: Guid | null = null;\r\n\r\n /**\r\n * Gets the child items from the server.\r\n *\r\n * @param parentGuid The parent item whose children are retrieved.\r\n *\r\n * @returns A collection of TreeItem objects as an asynchronous operation.\r\n */\r\n private async getItems(parentGuid: Guid | null = null): Promise {\r\n const options: ReportPickerGetChildrenOptionsBag = {\r\n parentGuid,\r\n includeCategoryGuids: this.includeCategoryGuids,\r\n entityTypeGuid: this.entityTypeGuid,\r\n securityGrantToken: this.securityGrantToken\r\n };\r\n const url = \"/api/v2/Controls/ReportPickerGetChildren\";\r\n const response = await post(url, undefined, options);\r\n\r\n if (response.isSuccess && response.data) {\r\n return response.data;\r\n }\r\n else {\r\n console.log(\"Error\", response.errorMessage);\r\n return [];\r\n }\r\n }\r\n\r\n /**\r\n * @inheritdoc\r\n */\r\n async getRootItems(): Promise {\r\n return await this.getItems(null);\r\n }\r\n\r\n /**\r\n * @inheritdoc\r\n */\r\n async getChildItems(item: TreeItemBag): Promise {\r\n return this.getItems(item.value);\r\n }\r\n}\r\n\r\n\r\n/**\r\n * Tree Item Provider for retrieving reports from the server and displaying\r\n * them inside a tree list.\r\n */\r\nexport class ScheduleTreeItemProvider implements ITreeItemProvider {\r\n /** The security grant token that will be used to request additional access to the group list. */\r\n public securityGrantToken: string | null = null;\r\n\r\n /** Whether to include inactive schedules in the results. */\r\n public includeInactive: boolean = false;\r\n\r\n /**\r\n * Gets the child items from the server.\r\n *\r\n * @param parentGuid The parent item whose children are retrieved.\r\n *\r\n * @returns A collection of TreeItem objects as an asynchronous operation.\r\n */\r\n private async getItems(parentGuid: Guid | null = null): Promise {\r\n const options: SchedulePickerGetChildrenOptionsBag = {\r\n parentGuid,\r\n includeInactiveItems: this.includeInactive,\r\n securityGrantToken: this.securityGrantToken\r\n };\r\n const url = \"/api/v2/Controls/SchedulePickerGetChildren\";\r\n const response = await post(url, undefined, options);\r\n\r\n if (response.isSuccess && response.data) {\r\n return response.data;\r\n }\r\n else {\r\n console.log(\"Error\", response.errorMessage);\r\n return [];\r\n }\r\n }\r\n\r\n /**\r\n * @inheritdoc\r\n */\r\n async getRootItems(): Promise {\r\n return await this.getItems(null);\r\n }\r\n\r\n /**\r\n * @inheritdoc\r\n */\r\n async getChildItems(item: TreeItemBag): Promise {\r\n return this.getItems(item.value);\r\n }\r\n}\r\n\r\n\r\n/**\r\n * Tree Item Provider for retrieving reports from the server and displaying\r\n * them inside a tree list.\r\n */\r\nexport class WorkflowActionTypeTreeItemProvider implements ITreeItemProvider {\r\n /** The security grant token that will be used to request additional access to the group list. */\r\n public securityGrantToken: string | null = null;\r\n\r\n /** Whether to include inactive schedules in the results. */\r\n public includeInactive: boolean = false;\r\n\r\n /**\r\n * Gets the child items from the server.\r\n *\r\n * @param parentGuid The parent item whose children are retrieved.\r\n *\r\n * @returns A collection of TreeItem objects as an asynchronous operation.\r\n */\r\n private async getItems(parentId: string | null = null): Promise {\r\n const options: WorkflowActionTypePickerGetChildrenOptionsBag = {\r\n parentId: toNumberOrNull(parentId) ?? 0,\r\n securityGrantToken: this.securityGrantToken\r\n };\r\n const url = \"/api/v2/Controls/WorkflowActionTypePickerGetChildren\";\r\n const response = await post(url, undefined, options);\r\n\r\n if (response.isSuccess && response.data) {\r\n return response.data;\r\n }\r\n else {\r\n console.log(\"Error\", response.errorMessage);\r\n return [];\r\n }\r\n }\r\n\r\n /**\r\n * @inheritdoc\r\n */\r\n async getRootItems(): Promise {\r\n return await this.getItems(null);\r\n }\r\n\r\n /**\r\n * @inheritdoc\r\n */\r\n async getChildItems(item: TreeItemBag): Promise {\r\n return this.getItems(item.value);\r\n }\r\n}\r\n\r\n/**\r\n * Tree Item Provider for retrieving merge fields from the server and displaying\r\n * them inside a tree list.\r\n */\r\nexport class MergeFieldTreeItemProvider implements ITreeItemProvider {\r\n /**\r\n * The security grant token that will be used to request additional access\r\n * to the category list.\r\n */\r\n public securityGrantToken?: string | null;\r\n\r\n /**\r\n * Currently selected page\r\n */\r\n public selectedIds?: string[] | string | null;\r\n\r\n /**\r\n * Root Level Merge Fields\r\n */\r\n public additionalFields: string = \"\";\r\n\r\n /**\r\n * Gets the child items of the given parent (or root if no parent given) from the server.\r\n *\r\n * @param parentId The parent item whose children are retrieved.\r\n *\r\n * @returns A collection of TreeItem objects as an asynchronous operation.\r\n */\r\n private async getItems(parentId?: string | null): Promise {\r\n let result: TreeItemBag[];\r\n\r\n const options: MergeFieldPickerGetChildrenOptionsBag = {\r\n id: parentId || \"0\",\r\n additionalFields: this.additionalFields\r\n };\r\n const url = \"/api/v2/Controls/MergeFieldPickerGetChildren\";\r\n const response = await post(url, undefined, options);\r\n\r\n if (response.isSuccess && response.data) {\r\n result = response.data;\r\n }\r\n else {\r\n console.log(\"Error\", response.errorMessage);\r\n return [];\r\n }\r\n\r\n // If we're getting child nodes or if there is no selected page\r\n if (parentId || !this.selectedIds || this.selectedIds.length == 0) {\r\n return result;\r\n }\r\n\r\n // If we're getting the root elements and we have a selected page, we also want to grab\r\n // all the parent pages so we can pre-load the entire hierarchy to the selected page\r\n return this.getHierarchyToSelectedMergeField(result);\r\n }\r\n\r\n /**\r\n * Fill in pages to the depth of the selected page\r\n *\r\n * @param rootLayer The bottom layer of pages that we'll build depth upon\r\n *\r\n * @return The augmented `rootLayer` with the child pages\r\n */\r\n private async getHierarchyToSelectedMergeField(rootLayer: TreeItemBag[]): Promise {\r\n const parents = this.getParentList();\r\n\r\n if (!parents || parents.length == 0) {\r\n // Selected page has no parents, so we're done.\r\n return rootLayer;\r\n }\r\n\r\n const childLists = await Promise.all(parents.map(id => this.getItems(id)));\r\n const allMergeFields = rootLayer.concat(flatten(childLists));\r\n\r\n parents.forEach((parentGuid, i) => {\r\n const parentMergeField: TreeItemBag | undefined = allMergeFields.find(page => page.value == parentGuid);\r\n if (parentMergeField) {\r\n parentMergeField.children = childLists[i];\r\n }\r\n });\r\n\r\n return rootLayer;\r\n }\r\n\r\n /**\r\n * Get the hierarchical list of parent merge fields of the selected merge fields\r\n *\r\n * @returns A list of IDs of the parent merge fields\r\n */\r\n private getParentList(): string[] | null {\r\n if (!this.selectedIds || this.selectedIds.length == 0) {\r\n return null;\r\n }\r\n\r\n // If it's a single selection, grab the parents by splitting on \"|\",\r\n // e.g. \"Grand|Parent|Child\" will give [\"Grand\", \"Parent\"] as the parents\r\n if (typeof this.selectedIds == \"string\") {\r\n return this.splitSelectionIntoParents(this.selectedIds);\r\n }\r\n\r\n // Not null/empty nor a single selection, so must be an array of selections\r\n return flatten(this.selectedIds.map(sel => this.splitSelectionIntoParents(sel)));\r\n }\r\n\r\n /**\r\n * Split the given selected ID up and get a list of the parent IDs\r\n *\r\n * @param selection a string denoted one of the selected values\r\n */\r\n private splitSelectionIntoParents(selection: string): string[] {\r\n const parentIds: string[] = [];\r\n\r\n // grab the parents by splitting on \"|\",\r\n // e.g. \"Grand|Parent|Child\" will give [\"Grand\", \"Parent\"] as the parents\r\n const splitList = selection.split(\"|\");\r\n splitList.pop();\r\n\r\n // Now we need to make sure each item further in the list contains it's parents' names\r\n // e.g. [\"Grand\", \"Parent\"] => [\"Grand\", \"Grand|Parent\"]\r\n while (splitList.length >= 1) {\r\n parentIds.unshift(splitList.join(\"|\"));\r\n splitList.pop();\r\n }\r\n\r\n return parentIds;\r\n }\r\n\r\n\r\n /**\r\n * @inheritdoc\r\n */\r\n async getRootItems(): Promise {\r\n return await this.getItems();\r\n }\r\n\r\n /**\r\n * @inheritdoc\r\n */\r\n async getChildItems(item: TreeItemBag): Promise {\r\n return this.getItems(item.value);\r\n }\r\n}","// \r\n// Copyright by the Spark Development Network\r\n//\r\n// Licensed under the Rock Community License (the \"License\");\r\n// you may not use this file except in compliance with the License.\r\n// You may obtain a copy of the License at\r\n//\r\n// http://www.rockrms.com/license\r\n//\r\n// Unless required by applicable law or agreed to in writing, software\r\n// distributed under the License is distributed on an \"AS IS\" BASIS,\r\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n// See the License for the specific language governing permissions and\r\n// limitations under the License.\r\n// \r\n//\r\n\r\nimport { Ref, watch } from \"vue\";\r\n\r\n/**\r\n * Is the value a valid URL?\r\n * @param val\r\n */\r\nexport function isUrl(val: unknown): boolean {\r\n if (typeof val === \"string\") {\r\n // https://www.regextester.com/1965\r\n // Modified from link above to support urls like \"http://localhost:6229/Person/1/Edit\" (Url does not have a period)\r\n const re = /^(http[s]?:\\/\\/)?[^\\s([\"<,>]*\\.?[^\\s[\",><]*$/;\r\n return re.test(val);\r\n }\r\n\r\n return false;\r\n}\r\n\r\n/**\r\n * Make the URL safe to use for redirects. Basically, this strips off any\r\n * protocol and hostname from the URL and ensures it's not a javascript:\r\n * url or anything like that.\r\n *\r\n * @param url The URL to be made safe to use with a redirect.\r\n *\r\n * @returns A string that is safe to assign to window.location.href.\r\n */\r\nexport function makeUrlRedirectSafe(url: string): string {\r\n try {\r\n // If this can't be parsed as a url, such as \"/page/123\" it will throw\r\n // an error which will be handled by the next section.\r\n const u = new URL(url);\r\n\r\n // If the protocol isn't an HTTP or HTTPS, then it is most likely\r\n // a dangerous URL.\r\n if (u.protocol !== \"http:\" && u.protocol !== \"https:\") {\r\n return \"/\";\r\n }\r\n\r\n // Try again incase they did something like \"http:javascript:alert('hi')\".\r\n return makeUrlRedirectSafe(`${u.pathname}${u.search}`);\r\n }\r\n catch {\r\n // If the URL contains a : but could not be parsed as a URL then it\r\n // is not valid, so return \"/\" so they get redirected to home page.\r\n if (url.indexOf(\":\") !== -1) {\r\n return \"/\";\r\n }\r\n\r\n // Otherwise consider it safe to use.\r\n return url;\r\n }\r\n}\r\n\r\n/**\r\n * Keep a list of named Refs synchronized with URL query parameters in the address of the same names.\r\n * If there are already query parameters in the URL with those names, the Refs will be assigned those\r\n * values. This will also watch those Refs for changes and update the query parameters to reflect\r\n * those changes.\r\n *\r\n * @param refs An object where the keys represent the query parameters keys to keep synchronized with\r\n * and the values are the Refs those query parameters are synched with.\r\n */\r\nexport function syncRefsWithQueryParams(refs: Record): void {\r\n // Get current query parameters\r\n const params = new URLSearchParams(window.location.search);\r\n\r\n Object.entries(refs).forEach(([key, ref]: [string, Ref]) => {\r\n let param = null;\r\n\r\n // try to get the decoded parameter value\r\n try {\r\n param = JSON.parse(decodeURI(params.get(key) ?? \"\"));\r\n }\r\n catch (e) { /* just leave the param as null */ }\r\n\r\n // If we found a value, set the Ref to it\r\n if (param != null) {\r\n ref.value = param;\r\n }\r\n\r\n // keep URL params up-to-date with changes to this Ref\r\n watch(ref, updater(key));\r\n });\r\n\r\n //\r\n function updater(key) {\r\n return (value) => {\r\n params.set(key, encodeURI(JSON.stringify(value)));\r\n\r\n history.replaceState(null, \"\", \"?\" + params.toString());\r\n };\r\n }\r\n}\r\n\r\n/**\r\n * Removes query parameters from the current URL and replaces the state in history.\r\n *\r\n * @param queryParamKeys The string array of query parameter keys to remove from the current URL.\r\n */\r\nexport function removeCurrentUrlQueryParams(...queryParamKeys: string[]): (string | null)[] {\r\n return removeUrlQueryParams(window.location.href, ...queryParamKeys);\r\n}\r\n\r\n/**\r\n * Removes query parameters from the current URL and replaces the state in history.\r\n *\r\n * @param url The URL from which to remove the query parameters.\r\n * @param queryParamKeys The string array of query parameter keys to remove from the current URL.\r\n */\r\nexport function removeUrlQueryParams(url: string | URL, ...queryParamKeys: string[]): (string | null)[] {\r\n if (!queryParamKeys || !queryParamKeys.length) {\r\n return [];\r\n }\r\n\r\n if (typeof url === \"string\") {\r\n url = new URL(url);\r\n }\r\n\r\n const queryParams = url.searchParams;\r\n\r\n const removedQueryParams: (string | null)[] = [];\r\n\r\n for (let i = 0; i < queryParamKeys.length; i++) {\r\n const queryParamKey = queryParamKeys[i];\r\n removedQueryParams.push(queryParams.get(queryParamKey));\r\n queryParams.delete(queryParamKey);\r\n }\r\n\r\n window.history.replaceState(null, \"\", url);\r\n\r\n return removedQueryParams;\r\n}","// \r\n// Copyright by the Spark Development Network\r\n//\r\n// Licensed under the Rock Community License (the \"License\");\r\n// you may not use this file except in compliance with the License.\r\n// You may obtain a copy of the License at\r\n//\r\n// http://www.rockrms.com/license\r\n//\r\n// Unless required by applicable law or agreed to in writing, software\r\n// distributed under the License is distributed on an \"AS IS\" BASIS,\r\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n// See the License for the specific language governing permissions and\r\n// limitations under the License.\r\n// \r\n\r\nimport type { RulesPropType, ValidationResult, ValidationRule, ValidationRuleFunction, ValidationRuleReference } from \"@Obsidian/Types/validationRules\";\r\nimport type { PropType } from \"vue\";\r\n\r\n/** The currently defined rules by name. */\r\nconst definedRules: Record = {};\r\n\r\n/** Defines the property type for a component's rules. */\r\nexport const rulesPropType: RulesPropType = {\r\n type: [Array, Object, String] as PropType,\r\n default: \"\"\r\n};\r\n\r\n/**\r\n * Parse a string into a valid rule reference. Basically this does the heavy\r\n * lifting to take a string and spit out the rule name and parameters. This\r\n * assumes the rule has already been normalized and does not contain multiple\r\n * rules separated by a | character.\r\n *\r\n * @param rule The rule to be parsed.\r\n *\r\n * @returns The rule reference that contains the name and parameters.\r\n */\r\nexport function parseRule(rule: string): ValidationRuleReference {\r\n let name = \"\";\r\n let params: unknown[] = [];\r\n\r\n const colonIndex = rule.indexOf(\":\");\r\n if (colonIndex === -1) {\r\n name = rule;\r\n }\r\n else {\r\n name = rule.substring(0, colonIndex);\r\n params = rule.substring(colonIndex + 1).split(\",\");\r\n }\r\n\r\n return {\r\n name,\r\n params\r\n };\r\n}\r\n\r\n/**\r\n * Normalize a single rule or array of rules into a flat array of rules. This\r\n * handles strings that contain multiple rules and splits them out into individual\r\n * rule strings.\r\n *\r\n * @param rules The rules to be normalized.\r\n *\r\n * @returns A flattened array that contains all the individual rules.\r\n */\r\nexport function normalizeRules(rules: ValidationRule | ValidationRule[]): ValidationRule[] {\r\n if (typeof rules === \"string\") {\r\n if (rules.indexOf(\"|\") !== -1) {\r\n return rules.split(\"|\").filter(r => r.trim() !== \"\");\r\n }\r\n else if (rules.trim() !== \"\") {\r\n return [rules.trim()];\r\n }\r\n }\r\n else if (Array.isArray(rules)) {\r\n // Normalize the rule, since it may contain a string like \"required|notzero\"\r\n // which needs to be further normalized.\r\n const normalizedRules: ValidationRule[] = [];\r\n\r\n for (const r of rules) {\r\n normalizedRules.push(...normalizeRules(r));\r\n }\r\n\r\n return normalizedRules;\r\n }\r\n else if (typeof rules === \"function\") {\r\n return [rules];\r\n }\r\n else if (typeof rules === \"object\") {\r\n return [rules];\r\n }\r\n\r\n return [];\r\n}\r\n\r\n/**\r\n * Checks if any of the specified rules indicates a rule that requires the value\r\n * to be filled in.\r\n *\r\n * @param rules The rules to be checked.\r\n *\r\n * @returns True if any of the rules is considered a required rule; otherwise false.\r\n */\r\nexport function containsRequiredRule(rules: ValidationRule | ValidationRule[]): boolean {\r\n return normalizeRules(rules).some(r => r === \"required\");\r\n}\r\n\r\n/**\r\n * Normalizes rules to callable functions. This is used to translate string\r\n * and reference rules to their final function that will be called.\r\n *\r\n * @param rules The rules to be normalized to functions.\r\n *\r\n * @returns An array of rule functions that will perform validation checks.\r\n */\r\nfunction normalizeRulesToFunctions(rules: ValidationRule[]): ValidationRuleFunction[] {\r\n const ruleFunctions: ValidationRuleFunction[] = [];\r\n\r\n for (const rule of rules) {\r\n if (typeof rule === \"string\") {\r\n const ruleRef = parseRule(rule);\r\n const fn = definedRules[ruleRef.name];\r\n\r\n if (fn) {\r\n ruleFunctions.push((value) => fn(value, ruleRef.params));\r\n }\r\n else {\r\n console.warn(`Attempt to validate with unknown rule ${rule}.`);\r\n }\r\n }\r\n else if (typeof rule === \"function\") {\r\n ruleFunctions.push(rule);\r\n }\r\n else if (typeof rule === \"object\") {\r\n const fn = definedRules[rule.name];\r\n\r\n if (fn) {\r\n ruleFunctions.push((value) => fn(value, rule.params));\r\n }\r\n else {\r\n console.warn(`Attempt to validate with unknown rule ${rule.name}.`);\r\n }\r\n }\r\n }\r\n\r\n return ruleFunctions;\r\n}\r\n\r\n/**\r\n * Normalize a validation result into a useful text message that can be\r\n * displayed to the user.\r\n *\r\n * @param result The validation error message or a blank string if validation passed.\r\n */\r\nfunction normalizeRuleResult(result: ValidationResult): string {\r\n if (typeof result === \"string\") {\r\n return result;\r\n }\r\n else if (result === true) {\r\n return \"\";\r\n }\r\n else {\r\n return \"failed validation\";\r\n }\r\n}\r\n\r\n/**\r\n * Runs validation on the value for all the rules provided.\r\n *\r\n * @param value The value to be checked.\r\n * @param rule The array of rules that will be used during validation.\r\n *\r\n * @returns An array of error messages, or empty if value passed.\r\n */\r\nexport function validateValue(value: unknown, rule: ValidationRule | ValidationRule[]): string[] {\r\n const fns = normalizeRulesToFunctions(normalizeRules(rule));\r\n\r\n const results: string[] = [];\r\n\r\n for (const fn of fns) {\r\n const result = normalizeRuleResult(fn(value));\r\n\r\n if (result !== \"\") {\r\n results.push(result);\r\n }\r\n }\r\n\r\n return results;\r\n}\r\n\r\n/**\r\n * Define a new rule by name and provide the validation function.\r\n *\r\n * @param ruleName The name of the rule to be registered.\r\n * @param validator The validation function.\r\n */\r\nexport function defineRule(ruleName: string, validator: ValidationRuleFunction): void {\r\n if (definedRules[ruleName] !== undefined) {\r\n console.warn(`Attempt to redefine validation rule ${ruleName}.`);\r\n }\r\n else {\r\n definedRules[ruleName] = validator;\r\n }\r\n}\r\n"],"names":["doApiCallRaw","_x","_x2","_x3","_x4","_doApiCallRaw","apply","arguments","_asyncToGenerator","method","url","params","data","axios","doApiCall","_x5","_x6","_doApiCall","length","undefined","result","isError","isSuccess","statusCode","status","errorMessage","e","isAxiosError","_e$response","_e$response$data","_e$response2","_e$response2$data","_e$response$status","_e$response4","response","Message","message","_e$response$data$Mess","_e$response3","_e$response3$data","get","_x7","_get","post","_x8","_post","httpFunctionsSymbol","Symbol","provideHttp","functions","provide","useHttp","http","getCurrentInstance","inject","uploadFile","_x9","_x10","_x11","_uploadFile","progress","headers","onUploadProgress","event","loaded","total","Math","floor","uploadContentFile","_x12","_x13","_x14","_x15","_uploadContentFile","file","encryptedRootFolder","folderPath","options","_options$baseUrl","concat","baseUrl","formData","FormData","append","value","text","FileName","uploadBinaryFile","_x16","_x17","_x18","_uploadBinaryFile","binaryFileTypeGuid","_options$baseUrl2","isTemporary","Guid","getDefaultAddressControlModel","state","country","validateAddress","address","getAddressString","flatten","arr","depth","forEach","flatDeep","call","val","Array","isArray","push","moreThanOneElement","noElementsFound","valueComparer","keySelector","descending","a","b","valueA","valueB","List","constructor","elements","fromArrayNoCopy","list","any","predicate","filter","first","firstOrUndefined","single","singleOrUndefined","orderBy","comparer","OrderedList","orderByDescending","where","toArray","baseComparer","sort","thenBy","thenByDescending","emptyGuid","newGuid","replace","c","r","random","v","toString","normalize","toLowerCase","isValidGuid","guid","test","toGuidOrNull","areEqual","isEmpty","isWhiteSpace","trim","isNullOrWhiteSpace","splitCase","asCommaAnd","strs","andStr","last","pop","join","toTitleCase","str","word","charAt","toUpperCase","substring","upperCaseFirstCharacter","pluralize","count","Pluralize","pluralConditional","num","singular","plural","padLeft","padCharacter","padRight","truncate","limit","trimmable","reg","RegExp","words","split","ellipsis","visibleWords","escapeHtmlRegExp","escapeHtmlMap","escapeHtml","ch","defaultControlCompareValue","itemValue","guidValue","guidItemValue","containsHtmlTag","blankIfZero","parseInt","get12HourValue","hour","englishDayNames","englishMonthNames","dateFormatters","date","year","month","substr","dayOfWeek","day","millisecond","minute","second","offset","offsetHour","abs","offsetMinute",":","/","dateFormatterKeys","Object","keys","k","standardDateFormats","formatAspDate","getLocalDateFormatString","universalDateTime","formatAspCustomDate","format","i","matchFound","_iterator","_createForOfIteratorHelper","_step","s","n","done","err","f","formatAspStandardDate","refDate","Date","toLocaleDateString","DateTimeFormat","DateFull","DateMedium","DateShort","TimeShort","TimeWithSeconds","DateTimeShort","DateTimeShortWithSeconds","DateTimeMedium","DateTimeMediumWithSeconds","DateTimeFull","DateTimeFullWithSeconds","RockDateTime","dateTime","fromParts","zone","luxonZone","FixedOffsetZone","instance","DateTime","fromObject","isValid","fromMilliseconds","milliseconds","fromMillis","fromJSDate","parseISO","dateString","fromISO","setZone","parseHTTP","fromHTTP","now","utcNow","toUTC","weekday","DayOfWeek","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday","dayOfYear","ordinal","localDateTime","toLocal","organizationDateTime","addDays","days","plus","endOfMonth","endOf","addHours","hours","addMilliseconds","addMinutes","minutes","addMonths","months","addSeconds","seconds","addYears","years","toMilliseconds","toMillis","toOffset","toASPString","toISOString","toISO","toLocaleString","toElapsedString","msPerHour","hoursPerDay","daysPerMonth","daysPerYear","totalMs","totalHours","totalDays","totalMonths","round","totalYears","toHTTPString","toHTTP","valueOf","isEqualTo","otherDateTime","isLaterThan","isEarlierThan","humanizeElapsed","_otherDateTime","totalSeconds","deepEqual","strict","isNaN","aEntries","entries","bEntries","aEntry","bEntry","debounce","fn","delay","eager","timeout","clearTimeout","setTimeout","PageMessages","BlockMessages","BeginEdit","EndEdit","useBrowserBus","BrowserBus","customDomEventName","_defineProperty","_objectSpread","eventListener","onEvent","document","addEventListener","CustomEvent","detail","name","timestamp","onMessage","handlers","_i","_handlers","handler","blockType","block","callback","console","error","dispose","removeEventListener","splice","publish","messageName","publishMessage","dispatchEvent","subscribe","messageNameOrCallback","subscribeToBlockType","messageNameOrBlockType","blockTypeOrCallback","subscribeToBlock","messageNameOrBlock","blockOrCallback","blockReloadSymbol","configurationValuesChangedSymbol","staticContentSymbol","blockBrowserBusSymbol","useConfigurationValues","useInvokeBlockAction","createInvokeBlockAction","pageGuid","blockGuid","pageParameters","invokeBlockAction","_invokeBlockAction","actionName","actionContext","context","__context","provideReloadBlock","useReloadBlock","provideConfigurationValuesChanged","callbacks","invoke","_callbacks","reset","onConfigurationValuesChanged","provideStaticContent","content","useStaticContent","provideBlockBrowserBus","bus","useBlockBrowserBus","setCustomSettingsBoxValue","box","propertyName","settings","validProperties","includes","setPropertiesBoxValue","bag","some","p","dispatchBlockEvent","eventName","eventData","ev","cancelable","isBlockEvent","entityTypeNameSymbol","entityTypeGuidSymbol","useEntityDetailBlock","securityGrant","getSecurityGrant","blockConfig","securityGrantToken","provideSecurityGrant","entityTypeName","provideEntityTypeName","entityTypeGuid","provideEntityTypeGuid","entity","refreshAttributesDebounce","refreshEntityDetailAttributes","onPropertyChanged","qualifiedAttributeProperties","useEntityTypeName","useEntityTypeGuid","securityGrantSymbol","token","tokenRef","ref","renewalTimeout","renewToken","_ref","scheduleRenewal","_tokenRef$value","segments","expiresDateTime","renewTimeout","updateToken","newToken","grant","useSecurityGrantToken","watchPropertyChanges","propertyRefs","emit","_loop","propRef","watch","_refreshEntityDetailAttributes","_result$data$bag","_result$data$bag2","newBox","attributes","attributeValues","refreshDetailAttributes","_refreshDetailAttributes","isEditable","_result$data$entity","_result$data$entity2","newBag","blockGuidSymbol","blockTypeGuidSymbol","provideBlockGuid","useBlockGuid","provideBlockTypeGuid","blockTypeGuid","useBlockTypeGuid","blockPreferenceProviderSymbol","emptyPreferences","getValue","setValue","getKeys","containsKey","save","Promise","resolve","withPrefix","on","off","emptyPreferenceProvider","blockPreferences","getGlobalPreferences","getEntityPreferences","providePersonPreferences","provider","usePersonPreferences","_inject","asBooleanOrNull","asString","indexOf","asBoolean","asYesNoOrNull","boolOrNull","asTrueFalseOrNull","asTrueOrFalseString","set","key","expirationDT","expiration","cache","cacheJson","JSON","stringify","sessionStorage","setItem","getItem","parse","promiseCache","cachePromiseFactory","_promiseCache$key","cachedResult","then","catch","shortcutCancelledEvent","listener","window","isCancellationToken","thing","CancellationTokenNone","CancellationTokenCancelled","MutableToken","isCancellationRequested","onCancellationRequested","freeze","cancel","isCancelled","emitter","mitt","CancellationTokenSource","parent","internalToken","suspenseSymbol","BasicSuspenseProvider","parentProvider","operationKey","pendingOperations","finishedHandlers","allOperationsComplete","nextTick","completeAsyncOperation","addOperation","operation","startAsyncOperation","index","hasPendingOperations","addFinishedHandler","provideSuspense","useSuspense","asFormattedString","digits","minimumFractionDigits","maximumFractionDigits","toNumber","toNumberOrNull","replaced","Number","toCurrencyOrNull","_currencyInfo$symbol","_currencyInfo$decimal","currencyInfo","currencySymbol","symbol","currencyDecimalPlaces","decimalPlaces","toOrdinalSuffix","j","toOrdinal","toWord","zeroPad","toDecimalPlaces","pow","useVModelPassthrough","props","modelName","internalValue","updateRefValue","useVModelPassthroughWithPropUpdateCheck","listeners","onPropUpdate","addPropUpdateListener","target","defineAsyncComponent","source","vueDefineAsyncComponent","suspense","component","standardRockFormFieldProps","label","type","String","default","help","rules","formGroupClasses","validationTitle","isRequiredIndicatorHidden","Boolean","copyStandardRockFormFieldProps","destination","useStandardRockFormFieldProps","propValues","reactive","standardAsyncPickerProps","enhanceForLongLists","lazyMode","ControlLazyMode","OnDemand","multiple","showBlankItem","blankValue","displayStyle","PickerDisplayStyle","Auto","columnCount","copyStandardAsyncPickerProps","useStandardAsyncPickerProps","standardFieldProps","deep","extendedRef","refValue","propertyRef","getVNodeProp","node","propName","defaultProps","defaultProp","getVNodeProps","_node$type$props$_p","propType","_toNumberOrNull","extractText","el","createElement","vnode","createVNode","render","innerText","extractHtml","html","innerHTML","dateKeyLength","dateKeyNoYearLength","getYear","dateKey","defaultValue","getMonth","getDay","toDateKey","yearStr","monthStr","dayStr","toNoYearDateKey","smoothScrollToTop","scrollTo","top","behavior","currentModalCount","trackModalState","body","cssClasses","cssClass","classList","add","_iterator2","_step2","remove","loadJavaScriptAsync","_loadJavaScriptAsync","isScriptLoaded","fingerprint","_Obsidian","_Obsidian$options","src","Obsidian","scripts","from","getElementsByTagName","thisScript","promise","scriptLoadedPromise","script","setAttribute","appendChild","_scriptLoadedPromise","scriptElement","reject","_unused","addQuickReturn","title","section","sectionOrder","rock","personalLinks","createDialog","footer","scrollable","style","zIndex","modal","tabIndex","display","modalDialog","modalContent","modalBody","modalFooter","createCloseButton","closeButton","marginTop","createBackdrop","backdrop","showDialog","timer","container","fullscreenElement","buttons","clearDialog","dialog","_iterator3","_step3","button","btn","className","querySelector","offsetHeight","alert","_alert","confirm","_confirm","confirmDelete","typeName","additionalMessage","showSecurity","entityTypeIdKey","entityIdKey","entityTitle","Rock","controls","show","isEmail","re","enumToListItemBag","description","listItemBagList","property","fieldTypeTable","registerFieldType","fieldTypeGuid","fieldType","normalizedGuid","getFieldType","field","warn","downloadWorkbook","_downloadWorkbook","workbook","buffer","xlsx","writeBuffer","csv","URL","createObjectURL","Blob","element","position","left","href","download","click","removeChild","revokeObjectURL","formStateSymbol","provideFormState","useFormState","enterFullscreen","_enterFullscreen","exitCallback","requestFullscreen","mozRequestFullscreen","webkitRequestFullscreen","onFullscreenChange","ex","isFullscreen","mozFullScreenElement","webkitFullscreenElement","exitFullscreen","_exitFullscreen","mozCancelFullScreen","webkitExitFullscreen","toCoordinate","coord","isWellKnown","reverse","map","parseFloat","lat","lng","wellKnownToCoordinates","wellKnownText","coordinatesToWellKnown","coordinates","isClockwisePolygon","coordinateString","coords","nearAddressForCoordinate","coordinate","google","geocoder","maps","Geocoder","geocode","location","LatLng","results","GeocoderStatus","OK","formatted_address","log","nearAddressForCoordinates","polygon","sum","loadMapResources","_loadMapResources","_response$data","mapStyleValueGuid","googleMapSettings","keyParam","googleApiKey","createLatLng","latOrLatLngOrLatLngLiteral","lngOrNoClampNoWrap","noClampNoWrap","nthNamesAbbreviated","padZeroLeft","repeat","getDateString","getTimeString","getDateTimeString","getDatesFromRangeOrPeriod","startDate","getDateFromString","dates","startsWith","getPeriodDurationInDays","endDate","getDateTimeFromString","period","endsWith","getRecurrenceDates","recurrenceDates","valueParts","valueType","valuePart","getWeekdayName","dateMatchesDays","rockDate","dateMatchesOffsetDayOfWeeks","offsets","dayOfMonth","lastDayOfMonth","getDayOfWeekFromIcalDay","getiCalDay","normalizeLineLength","lines","newLines","lineNumber","currentLine","newLine","denormalizeLineLength","LineFeeder","peek","RecurrenceRule","_values$UNTIL","_values$UNTIL2","rule","values","_iterator4","_step4","attr","attrParts","Error","frequency","_getDateFromString","_getDateTimeFromStrin","_toNumberOrNull2","interval","byMonthDay","_iterator5","_step5","byDay","_iterator6","_step6","build","monthDayValues","md","dayValues","d","getDates","eventStartDateTime","startDateTime","endDateTime","dateCount","nextDate","nextDateAfter","loopCount","Event","icsContent","uid","feeder","buildLines","excludedDates","_iterator7","_step7","rDate","recurrenceRules","_iterator8","_step8","rrule","line","splitAt","keyAttributes","keySegments","_iterator9","_step9","attrSegments","_getDateTimeFromStrin2","_getDateTimeFromStrin3","dateValues","_iterator10","_step10","dateValue","isDateExcluded","rockDateOnly","_iterator11","_step11","excludedDate","_recurrenceDates","toFriendlyText","toFriendlyString","toFriendlyHtml","startTimeText","hour12","offsetNames","nameText","slice","firstDate","lastDate","listHtml","_iterator12","_step12","Calendar","_iterator13","events","_step13","engine","Liquid","resolveMergeFields","template","mergeFields","tpl","renderSync","asListItemBagOrNull","bagJson","formatValue","_formatValue","selectedValue","fromEntries","res","entry","getValueFromPath","object","path","pathNames","pathName","prototype","hasOwnProperty","fetchPhoneNumberConfiguration","_fetchPhoneNumberConfiguration","_result$errorMessage","fetchPhoneNumberAndSmsConfiguration","_fetchPhoneNumberAndSmsConfiguration","_result$errorMessage2","showSmsOptIn","getPhoneNumberConfiguration","Cache","getPhoneNumberAndSmsConfiguration","defaultRulesConfig","formatPhoneNumber","stripPhoneNumber","_rule$match","regex","match","_rule$format","popover","_options$sanitize","$","sanitize","sleep","ms","isPromise","obj","PromiseCompletionSource","internalPromise","internalResolve","internalReject","reason","libraryObject","libraryPromise","getRealTimeObject","_getRealTimeObject","_window$Rock2","_window$Rock","getTopic","_getTopic","identifier","realTime","RockCurrency","isZero","big","eq","number","isNegative","lt","units","times","Big","roundDown","create","asRockCurrency","currency","negate","neg","divide","divisor","quotient","div","remainder","minus","subtract","isNotEqualTo","isLessThan","noLessThan","isGreaterThan","gt","noGreaterThan","mod","_this$divide","_toCurrencyOrNull","valueString","toFixed","rangeTypeOptions","RangeType","Current","Previous","Last","Next","Upcoming","DateRange","timeUnitOptions","TimeUnit","Hour","Day","Week","Month","Year","getTextForValue","_matches$0$text","matches","getRangeTypeText","rangeType","_rangeTypes$0$text","rangeTypes","o","getTimeUnitText","timeUnit","_timeUnits$0$text","timeUnits","parseSlidingDateRangeString","_o$text","_o$text2","range","timeValue","lowerDate","upperDate","slidingDateRangeToString","_value$timeUnit$toStr","_value$timeUnit","_value$lowerDate","_value$upperDate","_value$timeValue","_value$timeUnit$toStr2","_value$timeUnit2","calculateSlidingDateRange","currentDateTime","start","end","_result$start$addHour","_result$start","diff","_result$start$addMont","_result$start2","_value$timeValue2","roundUpCount","_RockDateTime$fromPar","_RockDateTime$fromPar2","_result$end$addHours","_result$end","_result$end$addDays","_result$end2","_RockDateTime$fromPar3","_RockDateTime$fromPar4","_result$end$addMonths","_result$end3","_RockDateTime$fromPar5","_RockDateTime$fromPar6","_result$end$addYears","_result$end4","cutoffDate","_value$timeValue3","_RockDateTime$fromPar7","_RockDateTime$fromPar8","_result$start$addHour2","_result$start3","_RockDateTime$fromPar9","_RockDateTime$fromPar10","_result$start$addMont2","_result$start4","_RockDateTime$fromPar11","_RockDateTime$fromPar12","_result$start$addYear","_result$start5","_value$lowerDate2","_value$upperDate2","getStructuredContentEditorConfiguration","_getStructuredContentEditorConfiguration","tooltip","showTooltip","CategoryTreeItemProvider","getItems","parentGuid","_this","entityTypeQualifierColumn","entityTypeQualifierValue","lazyLoad","getCategorizedItems","includeCategoriesWithoutChildren","includeInactiveItems","includeUnnamedEntityItems","getRootItems","_this2","rootCategoryGuid","getChildItems","item","_this3","LocationTreeItemProvider","_this4","_toGuidOrNull","rootLocationGuid","_this5","_this6","DataViewTreeItemProvider","_this7","entityTypeGuidFilter","displayPersistedOnly","_this8","_this9","WorkflowTypeTreeItemProvider","_this10","_this10$includeInacti","_this11","_this12","PageTreeItemProvider","_this13","_toGuidOrNull2","_this13$hidePageGuids","rootPageGuid","hidePageGuids","selectedPageGuids","getHierarchyToSelectedPage","getParentList","_this14","rootLayer","_this15","parents","childLists","all","allPages","parentPage","find","page","children","_this16","_this17","ConnectionRequestTreeItemProvider","_this18","_this19","_this20","GroupTreeItemProvider","_arguments","_this21","rootGroupGuid","includedGroupTypeGuids","includeInactiveGroups","limitToSchedulingEnabled","limitToRSVPEnabled","_this22","_this23","MergeTemplateTreeItemProvider","MergeTemplateOwnership","Global","_arguments2","_this24","mergeTemplateOwnership","_this25","_this26","MetricCategoryTreeItemProvider","_arguments3","_this27","_this28","_this29","MetricItemTreeItemProvider","_arguments4","_this30","includeCategoryGuids","_this31","_this32","RegistrationTemplateTreeItemProvider","_arguments5","_this33","_this34","_this35","ReportTreeItemProvider","_arguments6","_this36","_this37","_this38","ScheduleTreeItemProvider","_arguments7","_this39","includeInactive","_this40","_this41","WorkflowActionTypeTreeItemProvider","_arguments8","_this42","parentId","_this43","_this44","MergeFieldTreeItemProvider","_this45","id","additionalFields","selectedIds","getHierarchyToSelectedMergeField","_this46","allMergeFields","parentMergeField","splitSelectionIntoParents","sel","selection","parentIds","splitList","unshift","_this47","_this48","isUrl","makeUrlRedirectSafe","u","protocol","pathname","search","syncRefsWithQueryParams","refs","URLSearchParams","_ref2","_slicedToArray","param","_params$get","decodeURI","updater","encodeURI","history","replaceState","removeCurrentUrlQueryParams","_len","queryParamKeys","_key","removeUrlQueryParams","_len2","_key2","queryParams","searchParams","removedQueryParams","queryParamKey","delete","definedRules","rulesPropType","parseRule","colonIndex","normalizeRules","normalizedRules","containsRequiredRule","normalizeRulesToFunctions","ruleFunctions","ruleRef","normalizeRuleResult","validateValue","fns","defineRule","ruleName","validator"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAqB0D,SAa3CA,YAAYA,CAAAC,EAAA,EAAAC,GAAA,EAAAC,GAAA,EAAAC,GAAA,EAAA;MAAA,EAAA,OAAAC,aAAA,CAAAC,KAAA,CAAA,IAAA,EAAAC,SAAA,CAAA,CAAA;MAAA,CAAA;MAAA,SAAAF,aAAA,GAAA;QAAAA,aAAA,GAAAG,iBAAA,CAA3B,WAA4BC,MAAkB,EAAEC,GAAW,EAAEC,MAAqB,EAAEC,IAAkB,EAAmC;MACrI,IAAA,OAAA,MAAaC,KAAK,CAAC;YACfJ,MAAM;YACNC,GAAG;YACHC,MAAM;MACNC,MAAAA,IAAAA;MACJ,KAAC,CAAC,CAAA;SACL,CAAA,CAAA;MAAA,EAAA,OAAAP,aAAA,CAAAC,KAAA,CAAA,IAAA,EAAAC,SAAA,CAAA,CAAA;MAAA,CAAA;MAYD,SAAsBO,SAASA,CAAAC,GAAA,EAAAC,GAAA,EAAA;MAAA,EAAA,OAAAC,UAAA,CAAAX,KAAA,CAAA,IAAA,EAAAC,SAAA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