1System.register(['axios', 'vue', '@Obsidian/Libs/sse', '@Obsidian/Libs/pluralize', 'luxon', '@Obsidian/Enums/Controls/dayOfWeek', 'mitt', '@Obsidian/Enums/Cms/blockRole', '@Obsidian/Libs/chart', '@Obsidian/Enums/Controls/controlLazyMode', '@Obsidian/Enums/Controls/pickerDisplayStyle', '@Obsidian/Libs/liquidjs', '@Obsidian/Libs/big', '@Obsidian/Enums/Controls/slidingDateRangeType', '@Obsidian/Enums/Controls/timeUnitType', '@Obsidian/Enums/Controls/mergeTemplateOwnership'], (function (exports, module) { 2 'use strict'; 3 var axios, provide, getCurrentInstance, inject, ref, watch, computed, nextTick, defineAsyncComponent$1, reactive, markRaw, createVNode, render, onMounted, onUnmounted, EventSourceStream, Pluralize, FixedOffsetZone, DateTime, DayOfWeek, mitt, BlockRoleDescription, BarElement, ControlLazyMode, PickerDisplayStyle, Liquid, Big, SlidingDateRangeType, TimeUnitType, MergeTemplateOwnership; 4 return { 5 setters: [function (module) { 6 axios = module.default; 7 }, function (module) { 8 provide = module.provide; 9 getCurrentInstance = module.getCurrentInstance; 10 inject = module.inject; 11 ref = module.ref; 12 watch = module.watch; 13 computed = module.computed; 14 nextTick = module.nextTick; 15 defineAsyncComponent$1 = module.defineAsyncComponent; 16 reactive = module.reactive; 17 markRaw = module.markRaw; 18 createVNode = module.createVNode; 19 render = module.render; 20 onMounted = module.onMounted; 21 onUnmounted = module.onUnmounted; 22 }, function (module) { 23 EventSourceStream = module.EventSourceStream; 24 }, function (module) { 25 Pluralize = module.Pluralize; 26 }, function (module) { 27 FixedOffsetZone = module.FixedOffsetZone; 28 DateTime = module.DateTime; 29 }, function (module) { 30 DayOfWeek = module.DayOfWeek; 31 }, function (module) { 32 mitt = module.default; 33 }, function (module) { 34 BlockRoleDescription = module.BlockRoleDescription; 35 }, function (module) { 36 BarElement = module.BarElement; 37 }, function (module) { 38 ControlLazyMode = module.ControlLazyMode; 39 }, function (module) { 40 PickerDisplayStyle = module.PickerDisplayStyle; 41 }, function (module) { 42 Liquid = module.Liquid; 43 }, function (module) { 44 Big = module.default; 45 }, function (module) { 46 SlidingDateRangeType = module.SlidingDateRangeType; 47 }, function (module) { 48 TimeUnitType = module.TimeUnitType; 49 }, function (module) { 50 MergeTemplateOwnership = module.MergeTemplateOwnership; 51 }], 52 execute: (function () { 53 54 function _defineProperty(e, r, t) { 55 return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { 56 value: t, 57 enumerable: !0, 58 configurable: !0, 59 writable: !0 60 }) : e[r] = t, e; 61 } 62 function ownKeys(e, r) { 63 var t = Object.keys(e); 64 if (Object.getOwnPropertySymbols) { 65 var o = Object.getOwnPropertySymbols(e); 66 r && (o = o.filter(function (r) { 67 return Object.getOwnPropertyDescriptor(e, r).enumerable; 68 })), t.push.apply(t, o); 69 } 70 return t; 71 } 72 function _objectSpread2(e) { 73 for (var r = 1; r < arguments.length; r++) { 74 var t = null != arguments[r] ? arguments[r] : {}; 75 r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { 76 _defineProperty(e, r, t[r]); 77 }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { 78 Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); 79 }); 80 } 81 return e; 82 } 83 function _toPrimitive(t, r) { 84 if ("object" != typeof t || !t) return t; 85 var e = t[Symbol.toPrimitive]; 86 if (void 0 !== e) { 87 var i = e.call(t, r || "default"); 88 if ("object" != typeof i) return i; 89 throw new TypeError("@@toPrimitive must return a primitive value."); 90 } 91 return ("string" === r ? String : Number)(t); 92 } 93 function _toPropertyKey(t) { 94 var i = _toPrimitive(t, "string"); 95 return "symbol" == typeof i ? i : i + ""; 96 } 97 98 async function doApiCallRaw(method, url, params, data, options, cancellationToken) { 99 return await axios({ 100 method, 101 url, 102 params, 103 data, 104 headers: options === null || options === void 0 ? void 0 : options.headers, 105 signal: getSignal(cancellationToken) 106 }); 107 } 108 async function doStreamingApiCallRaw(method, url, params, data, options, cancellationToken) { 109 return await axios({ 110 method, 111 url, 112 params, 113 data, 114 signal: getSignal(cancellationToken),
115 headers: _objectSpread2(_objectSpread2({}, options === null || options === void 0 ? void 0 : options.headers), {}, { 116 Accept: "text/event-stream" 117 }), 118 responseType: "stream", 119 adapter: "fetch" 120 }); 121 } 122 function getSignal(cancellationToken) { 123 if (cancellationToken) { 124 const controller = new AbortController(); 125 cancellationToken.onCancellationRequested(() => { 126 if (controller && controller.signal && !controller.signal.aborted) { 127 controller.abort(); 128 } 129 }); 130 return controller.signal; 131 } 132 } 133 async function doApiCall(method, url) { 134 let params = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : undefined; 135 let data = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : undefined; 136 let optionsOrCancellationToken = arguments.length > 4 ? arguments[4] : undefined; 137 let cancellationToken = arguments.length > 5 ? arguments[5] : undefined; 138 try { 139 let result; 140 if (optionsOrCancellationToken && "onCancellationRequested" in optionsOrCancellationToken) { 141 result = await doApiCallRaw(method, url, params, data, undefined, optionsOrCancellationToken); 142 } else { 143 result = await doApiCallRaw(method, url, params, data, optionsOrCancellationToken, cancellationToken); 144 } 145 return { 146 data: result.data, 147 isError: false, 148 isSuccess: true, 149 statusCode: result.status, 150 errorMessage: null 151 }; 152 } catch (e) { 153 if (axios.isAxiosError(e)) { 154 var _e$response, _e$response2, _e$response$status, _e$response4; 155 if ((_e$response = e.response) !== null && _e$response !== void 0 && (_e$response = _e$response.data) !== null && _e$response !== void 0 && _e$response.Message || e !== null && e !== void 0 && (_e$response2 = e.response) !== null && _e$response2 !== void 0 && (_e$response2 = _e$response2.data) !== null && _e$response2 !== void 0 && _e$response2.message) { 156 var _e$response$data$Mess, _e$response3; 157 return { 158 data: null, 159 isError: true, 160 isSuccess: false, 161 statusCode: e.response.status, 162 errorMessage: (_e$response$data$Mess = e === null || e === void 0 || (_e$response3 = e.response) === null || _e$response3 === void 0 || (_e$response3 = _e$response3.data) === null || _e$response3 === void 0 ? void 0 : _e$response3.Message) !== null && _e$response$data$Mess !== void 0 ? _e$response$data$Mess : e.response.data.message 163 }; 164 } 165 return { 166 data: null, 167 isError: true, 168 isSuccess: false, 169 statusCode: (_e$response$status = (_e$response4 = e.response) === null || _e$response4 === void 0 ? void 0 : _e$response4.status) !== null && _e$response$status !== void 0 ? _e$response$status : 0, 170 errorMessage: null 171 }; 172 } else { 173 return { 174 data: null, 175 isError: true, 176 isSuccess: false, 177 statusCode: 0, 178 errorMessage: null 179 }; 180 } 181 } 182 } 183 async function doStreamingApiCall(method, url) { 184 let params = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : undefined; 185 let data = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : undefined; 186 let optionsOrCancellationToken = arguments.length > 4 ? arguments[4] : undefined; 187 let cancellationToken = arguments.length > 5 ? arguments[5] : undefined; 188 try { 189 let result; 190 if (optionsOrCancellationToken && "onCancellationRequested" in optionsOrCancellationToken) { 191 result = await doStreamingApiCallRaw(method, url, params, data, undefined, optionsOrCancellationToken); 192 } else { 193 result = await doStreamingApiCallRaw(method, url, params, data, optionsOrCancellationToken, cancellationToken); 194 } 195 const decoder = new EventSourceStream(); 196 const x = new JsonDecodeStream(); 197 return { 198 data: result.data.pipeThrough(decoder).pipeThrough(x), 199 isError: false, 200 isSuccess: true, 201 statusCode: result.status, 202 errorMessage: null 203 }; 204 } catch (e) { 205 if (axios.isAxiosError(e)) { 206 var _e$response5, _e$response6, _e$response$status2, _e$response8; 207 if ((_e$response5 = e.response) !== null && _e$response5 !== void 0 && (_e$response5 = _e$response5.data) !== null && _e$response5 !== void 0 && _e$response5.Message || e !== null && e !== void 0 && (_e$response6 = e.response) !== null && _e$response6 !== void 0 && (_e$response6 = _e$response6.data) !== null && _e$response6 !== void 0 && _e$response6.message) { 208 var _e$response$data$Mess2, _e$response7; 209 return { 210 data: null, 211 isError: true, 212 isSuccess: false, 213 statusCode: e.response.status, 214 errorMessage: (_e$response$data$Mess2 = e === null || e === void 0 || (_e$response7 = e.response) === null || _e$response7 === void 0 || (_e$response7 = _e$response7.data) === null || _e$response7 === void 0 ? void 0 : _e$response7.Message) !== null && _e$response$data$Mess2 !== void 0 ? _e$response$data$Mess2 : e.response.data.message 215 }; 216 } 217 return { 218 data: null, 219 isError: true, 220 isSuccess: false, 221 statusCode: (_e$response$status2 = (_e$response8 = e.response) === null || _e$response8 === void 0 ? void 0 : _e$response8.status) !== null && _e$response$status2 !== void 0 ? _e$response$status2 : 0, 222 errorMessage: null 223 }; 224 } else { 225 return { 226 data: null, 227 isError: true, 228 isSuccess: false, 229 statusCode: 0, 230 errorMessage: null 231 }; 232 } 233 } 234 } 235 async function get$1(url) { 236 let params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : undefined; 237 return await doApiCall("GET", url, params, undefined); 238 } 239 async function post(url) { 240 let params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : undefined; 241 let data = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : undefined; 242 let cancellationToken = arguments.length > 3 ? arguments[3] : undefined; 243 return await doApiCall("POST", url, params, data, cancellationToken); 244 } 245 const httpFunctionsSymbol = Symbol("http-functions"); 246 function provideHttp(functions) { 247 provide(httpFunctionsSymbol, functions); 248 } 249 function useHttp() { 250 let http; 251 if (getCurrentInstance()) { 252 http = inject(httpFunctionsSymbol); 253 } 254 return http || { 255 doApiCall: doApiCall, 256 doStreamingApiCall: doStreamingApiCall, 257 get: get$1, 258 post: post 259 }; 260 } 261 function createApiCaller(options) { 262 const fetchFunction = useHttp()[(options.method || "post").toLowerCase()]; 263 const isLoading = ref(false); 264 const hasError = ref(false); 265 const errorMessage = ref(); 266 return { 267 isLoading, 268 hasError, 269 errorMessage, 270 async run() { 271 isLoading.value = true; 272 hasError.value = false;
273 errorMessage.value = undefined; 274 for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { 275 args[_key] = arguments[_key]; 276 } 277 const params = typeof options.params === "function" ? options.params(...args) : options.params; 278 const data = typeof options.data === "function" ? options.data(...args) : options.data; 279 try { 280 const result = await fetchFunction(options.url, params, data); 281 if (result.isSuccess) { 282 if (typeof options.onComplete === "function") { 283 options.onComplete(result.data, ...args); 284 } 285 return result.data; 286 } else { 287 var _result$errorMessage; 288 hasError.value = true; 289 errorMessage.value = (_result$errorMessage = result.errorMessage) !== null && _result$errorMessage !== void 0 ? _result$errorMessage : undefined; 290 } 291 } catch (e) { 292 hasError.value = true; 293 if (e instanceof Error) { 294 errorMessage.value = e.message; 295 } else if (typeof e === "string") { 296 errorMessage.value = e; 297 } else { 298 errorMessage.value = "An unknown error occurred."; 299 } 300 } finally { 301 isLoading.value = false; 302 } 303 } 304 }; 305 } 306 class JsonDecodeStream { 307 constructor() { 308 const transformer = { 309 transform(chunk, controller) { 310 try { 311 const obj = JSON.parse(chunk.data); 312 controller.enqueue(obj); 313 } catch (e) { 314 controller.error(new Error("Invalid JSON: ".concat(e))); 315 } 316 } 317 }; 318 const ts = new TransformStream(transformer); 319 this.readable = ts.readable; 320 this.writable = ts.writable; 321 } 322 } 323 async function uploadFile(url, data, progress) { 324 let result; 325 try { 326 result = await axios.post(url, data, { 327 headers: { 328 "Content-Type": "multipart/form-data" 329 }, 330 onUploadProgress: event => { 331 if (progress && event.total !== undefined) { 332 progress(event.loaded, event.total, Math.floor(event.loaded * 100 / event.total)); 333 } 334 } 335 }); 336 } catch (e) { 337 result = e.response; 338 } 339 if (!result) { 340 throw new Error("Upload failed."); 341 } 342 if (result.status === 200 && typeof result.data === "object") { 343 return result.data; 344 } 345 if (result.status === 406) { 346 throw new Error("File type is not allowed."); 347 } 348 if (typeof result.data === "string") { 349 throw new Error(result.data); 350 } 351 throw new Error("Upload failed."); 352 } 353 async function uploadContentFile(file, encryptedRootFolder, folderPath, options) { 354 var _options$baseUrl; 355 const url = "".concat((_options$baseUrl = options === null || options === void 0 ? void 0 : options.baseUrl) !== null && _options$baseUrl !== void 0 ? _options$baseUrl : "/FileUploader.ashx", "?rootFolder=").concat(encodeURIComponent(encryptedRootFolder)); 356 const formData = new FormData(); 357 formData.append("file", file); 358 if (folderPath) { 359 formData.append("folderPath", folderPath); 360 } 361 const result = await uploadFile(url, formData, options === null || options === void 0 ? void 0 : options.progress); 362 return { 363 value: "", 364 text: result.FileName 365 }; 366 } 367 async function uploadAssetProviderFile(file, folderPath, assetStorageId, options) { 368 var _options$baseUrl2; 369 const url = "".concat((_options$baseUrl2 = options === null || options === void 0 ? void 0 : options.baseUrl) !== null && _options$baseUrl2 !== void 0 ? _options$baseUrl2 : "/FileUploader.ashx", "?rootFolder="); 370 const formData = new FormData(); 371 if (!assetStorageId) { 372 throw "Asset Storage Id and Key are required."; 373 } 374 formData.append("file", file); 375 formData.append("StorageId", assetStorageId); 376 formData.append("Key", folderPath); 377 formData.append("IsAssetStorageProviderAsset", "true"); 378 const result = await uploadFile(url, formData, options === null || options === void 0 ? void 0 : options.progress); 379 return { 380 value: "", 381 text: result.FileName 382 }; 383 } 384 async function uploadBinaryFile(file, binaryFileTypeGuid, options) { 385 var _options$baseUrl3; 386 let url = "".concat((_options$baseUrl3 = options === null || options === void 0 ? void 0 : options.baseUrl) !== null && _options$baseUrl3 !== void 0 ? _options$baseUrl3 : "/FileUploader.ashx", "?isBinaryFile=True&fileTypeGuid=").concat(binaryFileTypeGuid); 387 if ((options === null || options === void 0 ? void 0 : options.isTemporary) === false) { 388 url += "&isTemporary=False"; 389 } else { 390 url += "&isTemporary=True"; 391 } 392 if (options !== null && options !== void 0 && options.parentEntityTypeId) { 393 url += "&ParentEntityTypeId=" + options.parentEntityTypeId; 394 } 395 if (options !== null && options !== void 0 && options.parentEntityId) { 396 url += "&ParentEntityId=" + options.parentEntityId; 397 } 398 if (options !== null && options !== void 0 && options.securityGrantToken) { 399 url += "&SecurityGrantToken=" + encodeURIComponent(options.securityGrantToken); 400 } 401 const formData = new FormData(); 402 formData.append("file", file); 403 const result = await uploadFile(url, formData, options === null || options === void 0 ? void 0 : options.progress); 404 return { 405 value: result.Guid, 406 text: result.FileName 407 }; 408 } 409 var http$1 = { 410 doApiCall, 411 post, 412 get: get$1 413 }; 414 415 var http$2 = /*#__PURE__*/Object.freeze({ 416 __proto__: null, 417 createApiCaller: createApiCaller, 418 default: http$1, 419 doApiCall: doApiCall, 420 doStreamingApiCall: doStreamingApiCall, 421 get: get$1, 422 post: post, 423 provideHttp: provideHttp, 424 uploadAssetProviderFile: uploadAssetProviderFile, 425 uploadBinaryFile: uploadBinaryFile, 426 uploadContentFile: uploadContentFile, 427 useHttp: useHttp 428 }); 429 exports('http', http$2); 430 431 function getDefaultAddressControlModel() { 432 return { 433 state: "AZ", 434 country: "US" 435 }; 436 } 437 function validateAddress(address) { 438 const post = useHttp().post; 439 return post("/api/v2/Controls/AddressControlValidateAddress", undefined, address); 440 } 441 function getAddressString(address) { 442 const post = useHttp().post; 443 return post("/api/v2/Controls/AddressControlGetStreetAddressString", undefined, address); 444 } 445 446 var address = /*#__PURE__*/Object.freeze({ 447 __proto__: null, 448 getAddressString: getAddressString, 449 getDefaultAddressControlModel: getDefaultAddressControlModel, 450 validateAddress: validateAddress 451 }); 452 exports('address', address); 453 454 function flatten(arr) { 455 let depth = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1; 456 const result = [];
457 const forEach = result.forEach; 458 const flatDeep = function (arr, depth) { 459 forEach.call(arr, function (val) { 460 if (depth > 0 && Array.isArray(val)) { 461 flatDeep(val, depth - 1); 462 } else { 463 result.push(val); 464 } 465 }); 466 }; 467 flatDeep(arr, depth); 468 return result; 469 } 470 function forceToArray(value, multiple) { 471 if (value === undefined || value === null) { 472 return []; 473 } else if (Array.isArray(value)) { 474 if (!multiple && value.length > 1) { 475 return [value[0]]; 476 } else { 477 return value; 478 } 479 } else { 480 return [value]; 481 } 482 } 483 484 var arrayUtils = /*#__PURE__*/Object.freeze({ 485 __proto__: null, 486 flatten: flatten, 487 forceToArray: forceToArray 488 }); 489 exports('arrayUtils', arrayUtils); 490 491 const moreThanOneElement = "More than one element was found in collection."; 492 const noElementsFound = "No element was found in collection."; 493 function valueComparer(keySelector, descending) { 494 return (a, b) => { 495 const valueA = keySelector(a); 496 const valueB = keySelector(b); 497 if (valueA === undefined || valueA === null) { 498 if (valueB === undefined || valueB === null) { 499 return 0; 500 } 501 return !descending ? -1 : 1; 502 } 503 if (valueB === undefined || valueB === null) { 504 return !descending ? 1 : -1; 505 } 506 if (valueA > valueB) { 507 return !descending ? 1 : -1; 508 } else if (valueA < valueB) { 509 return !descending ? -1 : 1; 510 } else { 511 return 0; 512 } 513 }; 514 } 515 class List { 516 constructor(elements) { 517 if (elements === undefined) { 518 this.elements = []; 519 } else { 520 this.elements = [...elements]; 521 } 522 } 523 static fromArrayNoCopy(elements) { 524 const list = new List(); 525 list.elements = elements; 526 return list; 527 } 528 any(predicate) { 529 let elements = this.elements; 530 if (predicate !== undefined) { 531 elements = elements.filter(predicate); 532 } 533 return elements.length > 0; 534 } 535 first(predicate) { 536 let elements = this.elements; 537 if (predicate !== undefined) { 538 elements = elements.filter(predicate); 539 } 540 if (elements.length >= 1) { 541 return elements[0]; 542 } else { 543 throw noElementsFound; 544 } 545 } 546 firstOrUndefined(predicate) { 547 let elements = this.elements; 548 if (predicate !== undefined) { 549 elements = elements.filter(predicate); 550 } 551 if (elements.length === 1) { 552 return elements[0]; 553 } else { 554 return undefined; 555 } 556 } 557 lastOrUndefined(predicate) { 558 let elements = this.elements; 559 if (predicate !== undefined) { 560 elements = elements.filter(predicate); 561 } 562 if (elements.length) { 563 return elements[elements.length - 1]; 564 } else { 565 return undefined; 566 } 567 } 568 single(predicate) { 569 let elements = this.elements; 570 if (predicate !== undefined) { 571 elements = elements.filter(predicate); 572 } 573 if (elements.length === 1) { 574 return elements[0]; 575 } else { 576 throw moreThanOneElement; 577 } 578 } 579 singleOrUndefined(predicate) { 580 let elements = this.elements; 581 if (predicate !== undefined) { 582 elements = elements.filter(predicate); 583 } 584 if (elements.length === 0) { 585 return undefined; 586 } else if (elements.length === 1) { 587 return elements[0]; 588 } else { 589 throw moreThanOneElement; 590 } 591 } 592 orderBy(keySelector) { 593 const comparer = valueComparer(keySelector, false); 594 return new OrderedList(this.elements, comparer); 595 } 596 orderByDescending(keySelector) { 597 const comparer = valueComparer(keySelector, true); 598 return new OrderedList(this.elements, comparer); 599 } 600 where(predicate) { 601 return new List(this.elements.filter(predicate)); 602 } 603 toArray() { 604 return [...this.elements]; 605 } 606 } 607 class OrderedList extends List { 608 constructor(elements, baseComparer) { 609 super(elements); 610 this.baseComparer = baseComparer; 611 this.elements.sort(this.baseComparer); 612 } 613 thenBy(keySelector) { 614 const comparer = valueComparer(keySelector, false); 615 return new OrderedList(this.elements, (a, b) => this.baseComparer(a, b) || comparer(a, b)); 616 } 617 thenByDescending(keySelector) { 618 const comparer = valueComparer(keySelector, true); 619 return new OrderedList(this.elements, (a, b) => this.baseComparer(a, b) || comparer(a, b)); 620 } 621 } 622 class Enumerable { 623 constructor(iterableFactory) { 624 this.iterableFactory = iterableFactory; 625 } 626 static empty() { 627 return new Enumerable(() => []); 628 } 629 static from(source) { 630 if (typeof source === "function") { 631 return new Enumerable(source); 632 } else { 633 return new Enumerable(() => source); 634 } 635 } 636 *[Symbol.iterator]() { 637 yield* this.iterableFactory(); 638 } 639 aggregate(accumulator, seed) { 640 let result = seed; 641 let index = 0; 642 for (const item of this) { 643 result = accumulator(result, item, index++); 644 } 645 return result; 646 } 647 all(predicate) { 648 for (const item of this) { 649 if (!predicate(item)) { 650 return false;
651 } 652 } 653 return true; 654 } 655 any(predicate) { 656 for (const item of this) { 657 if (!predicate || predicate(item)) { 658 return true; 659 } 660 } 661 return false; 662 } 663 average(selector) { 664 let total = 0; 665 let count = 0; 666 for (const item of this) { 667 const value = selector(item); 668 if (typeof value === "number" && !isNaN(value)) { 669 total += value; 670 count++; 671 } 672 } 673 if (count === 0) { 674 return 0; 675 } else { 676 return total / count; 677 } 678 } 679 cast(typeCheck) { 680 const self = this; 681 return new Enumerable(function* () { 682 for (const item of self) { 683 if (!typeCheck(item)) { 684 throw new Error("Invalid cast: Value '".concat(item, "' cannot be cast to the specified type.")); 685 } 686 yield item; 687 } 688 }); 689 } 690 chunk(size) { 691 if (size < 1) { 692 throw new Error("Chunk size must be greater than 0."); 693 } 694 const self = this; 695 return new Enumerable(function* () { 696 let buffer = []; 697 for (const item of self) { 698 buffer.push(item); 699 if (buffer.length === size) { 700 yield buffer; 701 buffer = []; 702 } 703 } 704 if (buffer.length > 0) { 705 yield buffer; 706 } 707 }); 708 } 709 concat(second) { 710 const self = this; 711 return this.spawn(function* () { 712 yield* self; 713 yield* second; 714 }); 715 } 716 count(predicate) { 717 let total = 0; 718 for (const item of this) { 719 if (!predicate || predicate(item)) { 720 total++; 721 } 722 } 723 return total; 724 } 725 distinct() { 726 const self = this; 727 return this.spawn(function* () { 728 const seen = new Set(); 729 for (const item of self) { 730 if (!seen.has(item)) { 731 seen.add(item); 732 yield item; 733 } 734 } 735 }); 736 } 737 distinctBy(keySelector) { 738 const self = this; 739 return this.spawn(function* () { 740 const seenKeys = new Set(); 741 for (const item of self) { 742 const key = keySelector(item); 743 const keyString = JSON.stringify(key); 744 if (!seenKeys.has(keyString)) { 745 seenKeys.add(keyString); 746 yield item; 747 } 748 } 749 }); 750 } 751 first(predicate) { 752 let i = 0; 753 for (const item of this) { 754 if (!predicate || predicate(item, i)) { 755 return item; 756 } 757 i++; 758 } 759 throw noElementsFound; 760 } 761 firstOrDefault(arg) { 762 if (typeof arg === "function") { 763 const predicate = arg; 764 for (const item of this) { 765 if (predicate(item)) { 766 return item; 767 } 768 } 769 } else { 770 for (const item of this) { 771 return item; 772 } 773 return arg; 774 } 775 } 776 forEach(action) { 777 for (const item of this) { 778 action(item); 779 } 780 } 781 groupBy(keySelector) { 782 const self = this; 783 return new Enumerable(function* () { 784 const map = new Map(); 785 for (const item of self) { 786 const key = keySelector(item); 787 const keyString = JSON.stringify(key); 788 const entry = map.get(keyString); 789 if (entry) { 790 entry.values.push(item); 791 } else { 792 map.set(keyString, { 793 key, 794 values: [item] 795 }); 796 } 797 } 798 for (const { 799 key, 800 values 801 } of map.values()) { 802 yield new GroupedEnumerable(key, values); 803 } 804 }); 805 } 806 last(predicate) { 807 let found = false;
808 let lastMatch = undefined; 809 for (const item of this) { 810 if (!predicate || predicate(item)) { 811 found = true; 812 lastMatch = item; 813 } 814 } 815 if (!found || lastMatch === undefined) { 816 throw new Error("No element satisfies the condition in last()"); 817 } 818 return lastMatch; 819 } 820 lastOrDefault(arg) { 821 let last; 822 if (typeof arg === "function") { 823 const predicate = arg; 824 for (const item of this) { 825 if (predicate(item)) { 826 last = item; 827 } 828 } 829 } else { 830 for (const item of this) { 831 last = item; 832 } 833 } 834 return last; 835 } 836 max(selector) { 837 const self = this[Symbol.iterator](); 838 const first = self.next(); 839 if (first.done) return undefined; 840 let maxItem = selector(first.value); 841 for (let next = self.next(); !next.done; next = self.next()) { 842 const value = selector(next.value); 843 if (value > maxItem) { 844 maxItem = value; 845 } 846 } 847 return maxItem; 848 } 849 min(selector) { 850 const self = this[Symbol.iterator](); 851 const first = self.next(); 852 if (first.done) return undefined; 853 let minItem = selector(first.value); 854 for (let next = self.next(); !next.done; next = self.next()) { 855 const value = selector(next.value); 856 if (value < minItem) { 857 minItem = value; 858 } 859 } 860 return minItem; 861 } 862 ofType(typeCheck) { 863 const self = this; 864 return new Enumerable(function* () { 865 for (const item of self) { 866 if (typeCheck(item)) { 867 yield item; 868 } 869 } 870 }); 871 } 872 orderBy(keySelector) { 873 let comparer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : (a, b) => a > b ? 1 : a < b ? -1 : 0; 874 return new OrderedEnumerable(this.iterableFactory, (a, b) => comparer(keySelector(a), keySelector(b))); 875 } 876 orderByDescending(keySelector) { 877 let comparer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : (a, b) => a > b ? 1 : a < b ? -1 : 0; 878 const descendingComparer = (a, b) => -comparer(a, b); 879 return this.orderBy(keySelector, descendingComparer); 880 } 881 prepend(items) { 882 const self = this; 883 return this.spawn(function* () { 884 for (const item of items) { 885 yield item; 886 } 887 for (const item of self) { 888 yield item; 889 } 890 }); 891 } 892 scan(seed, accumulator) { 893 const self = this; 894 return new Enumerable(function* () { 895 let acc = seed; 896 let index = 0; 897 for (const item of self) { 898 acc = accumulator(acc, item, index++); 899 yield acc; 900 } 901 }); 902 } 903 select(selector) { 904 const self = this; 905 return new Enumerable(function* () { 906 for (const item of self) { 907 yield selector(item); 908 } 909 }); 910 } 911 selectMany(collectionSelector) { 912 const self = this; 913 return new Enumerable(function* () { 914 for (const item of self) { 915 const collection = collectionSelector(item); 916 for (const subItem of collection) { 917 yield subItem; 918 } 919 } 920 }); 921 } 922 sequenceEqual(other) { 923 let comparer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : (a, b) => a === b; 924 const it1 = this[Symbol.iterator](); 925 const it2 = other[Symbol.iterator](); 926 while (true) { 927 const n1 = it1.next(); 928 const n2 = it2.next(); 929 if (n1.done && n2.done) return true;
930 if (n1.done !== n2.done) return false; 931 if (!comparer(n1.value, n2.value)) return false; 932 } 933 } 934 skip(count) { 935 const self = this; 936 return this.spawn(function* () { 937 let skipped = 0; 938 for (const item of self) { 939 if (skipped++ >= count) { 940 yield item; 941 } 942 } 943 }); 944 } 945 spawn(factory) { 946 const ctor = this.constructor; 947 return new ctor(factory); 948 } 949 sum(selector) { 950 let total = 0; 951 for (const item of this) { 952 const value = selector(item); 953 if (typeof value === "number" && !isNaN(value)) { 954 total += value; 955 } 956 } 957 return total; 958 } 959 take(count) { 960 const self = this; 961 return this.spawn(function* () { 962 let i = 0; 963 for (const item of self) { 964 if (i++ < count) { 965 yield item; 966 } else { 967 break; 968 } 969 } 970 }); 971 } 972 toArray() { 973 return Array.from(this); 974 } 975 toDictionary(keySelector, valueSelector) { 976 return new Map(this.select(item => [keySelector(item), valueSelector ? valueSelector(item) : item])); 977 } 978 where(predicate) { 979 const self = this; 980 return this.spawn(function* () { 981 for (const item of self) { 982 if (predicate(item)) { 983 yield item; 984 } 985 } 986 }); 987 } 988 withIndex() { 989 const self = this; 990 return new Enumerable(function* () { 991 let index = 0; 992 for (const item of self) { 993 yield [item, index++]; 994 } 995 }); 996 } 997 } 998 class OrderedEnumerable extends Enumerable { 999 constructor(iterableFactory, initialComparer) { 1000 super(iterableFactory); 1001 this.sortComparers = [initialComparer]; 1002 } 1003 thenOrderBy(keySelector) { 1004 let comparer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : (a, b) => a > b ? 1 : a < b ? -1 : 0; 1005 const self = this; 1006 return new OrderedEnumerable(this.iterableFactory, (a, b) => { 1007 for (const cmp of self.sortComparers) { 1008 const result = cmp(a, b); 1009 if (result !== 0) return result; 1010 } 1011 return comparer(keySelector(a), keySelector(b)); 1012 }); 1013 } 1014 thenOrderByDescending(keySelector) { 1015 let comparer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : (a, b) => a > b ? 1 : a < b ? -1 : 0; 1016 const descendingComparer = (a, b) => -comparer(a, b); 1017 return this.thenOrderBy(keySelector, descendingComparer); 1018 } 1019 toArray() { 1020 return Array.from(this); 1021 } 1022 *[Symbol.iterator]() { 1023 const array = Array.from(this.iterableFactory()); 1024 array.sort((a, b) => { 1025 for (const comparer of this.sortComparers) { 1026 const result = comparer(a, b); 1027 if (result !== 0) return result; 1028 } 1029 return 0; 1030 }); 1031 yield* array; 1032 } 1033 } 1034 class GroupedEnumerable extends Enumerable { 1035 constructor(key, elements) { 1036 super(() => elements); 1037 this.key = key; 1038 } 1039 } 1040 1041 var linq = /*#__PURE__*/Object.freeze({ 1042 __proto__: null, 1043 Enumerable: Enumerable, 1044 GroupedEnumerable: GroupedEnumerable, 1045 List: List 1046 }); 1047 exports('linq', linq); 1048 1049 const emptyGuid = "00000000-0000-0000-0000-000000000000"; 1050 function newGuid() { 1051 return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, c => { 1052 const r = Math.random() * 16 | 0; 1053 const v = c === "x" ? r : r & 0x3 | 0x8; 1054 return v.toString(16); 1055 }); 1056 } 1057 function normalize(a) { 1058 if (!a) { 1059 return null; 1060 } 1061 return a.toLowerCase(); 1062 } 1063 function isValidGuid(guid) { 1064 return /^[0-9A-Fa-f]{8}-(?:[0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$/.test(guid); 1065 } 1066 function toGuidOrNull(value) { 1067 if (value === null || value === undefined) { 1068 return null; 1069 } 1070 if (!isValidGuid(value)) { 1071 return null; 1072 } 1073 return value; 1074 } 1075 function areEqual(a, b) { 1076 return normalize(a) === normalize(b); 1077 } 1078 var guid = { 1079 newGuid, 1080 normalize, 1081 areEqual 1082 }; 1083 1084 var guid$1 = /*#__PURE__*/Object.freeze({ 1085 __proto__: null, 1086 areEqual: areEqual, 1087 default: guid, 1088 emptyGuid: emptyGuid, 1089 isValidGuid: isValidGuid, 1090 newGuid: newGuid, 1091 normalize: normalize, 1092 toGuidOrNull: toGuidOrNull 1093 }); 1094 exports('guid', guid$1); 1095 1096 function isEmpty(val) { 1097 if (typeof val === "string") { 1098 return val.length === 0; 1099 } 1100 return false;
1101 } 1102 function isWhiteSpace(val) { 1103 if (typeof val === "string") { 1104 return val.trim().length === 0; 1105 } 1106 return false; 1107 } 1108 function isNullOrWhiteSpace(val) { 1109 return isWhiteSpace(val) || val === undefined || val === null; 1110 } 1111 function splitCase(val) { 1112 val = val.replace(/([A-Z]+)([A-Z][a-z])/g, "$1 $2"); 1113 return val.replace(/([a-z0-9])([A-Z])/g, "$1 $2"); 1114 } 1115 function asCommaAnd(strs, andStr) { 1116 if (strs.length === 0) { 1117 return ""; 1118 } 1119 if (strs.length === 1) { 1120 return strs[0]; 1121 } 1122 if (!andStr) { 1123 andStr = "and"; 1124 } 1125 if (strs.length === 2) { 1126 return "".concat(strs[0], " ").concat(andStr, " ").concat(strs[1]); 1127 } 1128 const last = strs.pop(); 1129 return "".concat(strs.join(", "), " ").concat(andStr, " ").concat(last); 1130 } 1131 function toTitleCase(str) { 1132 if (!str) { 1133 return ""; 1134 } 1135 return str.replace(/\w\S*/g, word => { 1136 return word.charAt(0).toUpperCase() + word.substring(1).toLowerCase(); 1137 }); 1138 } 1139 function toKebabCase(str) { 1140 let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; 1141 const { 1142 preserveMultipleDashes = false, 1143 allowLeadingDashes = false, 1144 allowTrailingDashes = false, 1145 allowSpecialChars = false 1146 } = options; 1147 let result = str.trim(); 1148 result = result.replace(/([a-z])([A-Z])/g, "$1-$2"); 1149 result = result.replace(/\s+/g, "-"); 1150 if (!allowSpecialChars) { 1151 result = result.replace(/[^a-zA-Z0-9-]/g, ""); 1152 } 1153 if (!preserveMultipleDashes) { 1154 result = result.replace(/-+/g, "-"); 1155 } 1156 result = result.toLowerCase(); 1157 if (!allowLeadingDashes) { 1158 result = result.replace(/^-+/, ""); 1159 } 1160 if (!allowTrailingDashes) { 1161 result = result.replace(/-+$/, ""); 1162 } 1163 return result; 1164 } 1165 function upperCaseFirstCharacter(str) { 1166 if (!str) { 1167 return ""; 1168 } 1169 return str.charAt(0).toUpperCase() + str.substring(1); 1170 } 1171 function pluralize(word, count) { 1172 return Pluralize(word, count); 1173 } 1174 function pluralConditional(num, singular, plural) { 1175 return num === 1 ? singular : plural; 1176 } 1177 function padLeft(str, length) { 1178 let padCharacter = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : " "; 1179 if (padCharacter === "") { 1180 padCharacter = " "; 1181 } else if (padCharacter.length > 1) { 1182 padCharacter = padCharacter.substring(0, 1); 1183 } 1184 if (!str) { 1185 return Array(length + 1).join(padCharacter); 1186 } 1187 if (str.length >= length) { 1188 return str; 1189 } 1190 return Array(length - str.length + 1).join(padCharacter) + str; 1191 } 1192 function padRight(str, length) { 1193 let padCharacter = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : " "; 1194 if (padCharacter === "") { 1195 padCharacter = " "; 1196 } else if (padCharacter.length > 1) { 1197 padCharacter = padCharacter.substring(0, 1); 1198 } 1199 if (!str) { 1200 return Array(length).join(padCharacter); 1201 } 1202 if (str.length >= length) { 1203 return str; 1204 } 1205 return str + Array(length - str.length + 1).join(padCharacter); 1206 } 1207 function truncate(str, limit, options) { 1208 if (str.length <= limit) { 1209 return str; 1210 } 1211 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"; 1212 const reg = new RegExp("(?=[".concat(trimmable, "])")); 1213 const words = str.split(reg); 1214 let count = 0; 1215 if (options && options.ellipsis === true) { 1216 limit -= 3; 1217 } 1218 const visibleWords = words.filter(function (word) { 1219 count += word.length; 1220 return count <= limit; 1221 }); 1222 return "".concat(visibleWords.join(""), "..."); 1223 } 1224 const escapeHtmlRegExp = /["'&<>]/g; 1225 const escapeHtmlMap = { 1226 '"': """, 1227 "&": "&", 1228 "'": "'", 1229 "<": "<", 1230 ">": ">" 1231 }; 1232 function escapeHtml(str) { 1233 return str.replace(escapeHtmlRegExp, ch => { 1234 return escapeHtmlMap[ch]; 1235 }); 1236 } 1237 function defaultControlCompareValue(value, itemValue) { 1238 const guidValue = toGuidOrNull(value); 1239 const guidItemValue = toGuidOrNull(itemValue); 1240 if (guidValue !== null && guidItemValue !== null) { 1241 return areEqual(guidValue, guidItemValue); 1242 } 1243 return value === itemValue; 1244 } 1245 function containsHtmlTag(value) { 1246 return /<[/0-9a-zA-Z]/.test(value); 1247 } 1248 function createHash(str) { 1249 let hash = 0; 1250 for (let i = 0; i < str.length; i++) { 1251 const chr = str.charCodeAt(i); 1252 hash = (hash << 5) - hash + chr; 1253 hash |= 0; 1254 } 1255 return hash; 1256 } 1257 async function createHashSha256(str) { 1258 const encoder = new TextEncoder(); 1259 const data = encoder.encode(str); 1260 const hashBuffer = await crypto.subtle.digest("SHA-256", data); 1261 return Array.from(new Uint8Array(hashBuffer)).map(b => b.toString(16).padStart(2, "0")).join(""); 1262 } 1263 function replaceAll(str, search, replace) { 1264 return str.replace(new RegExp(search, "g"), replace); 1265 } 1266 function safeParseJson$1(value) { 1267 if (!value) { 1268 return undefined; 1269 } 1270 try { 1271 return JSON.parse(value); 1272 } catch (_unused) { 1273 return undefined; 1274 } 1275 } 1276 function prependSingularIndefiniteArticle(singularWord) { 1277 if (!singularWord) { 1278 return singularWord; 1279 } 1280 const lower = singularWord.toLowerCase(); 1281 const silentH = ["honest", "hour", "honor", "heir"]; 1282 if (silentH.includes(lower)) { 1283 return "an ".concat(singularWord); 1284 } 1285 const hardURegex = /^(u[bcfhjkqrstn])/i; 1286 if (hardURegex.test(singularWord)) { 1287 return "a ".concat(singularWord); 1288 } 1289 const vowelSound = /^[aeiou]/i; 1290 if (vowelSound.test(singularWord)) { 1291 return "an ".concat(singularWord); 1292 } 1293 return "a ".concat(singularWord); 1294 } 1295 var stringUtils = { 1296 asCommaAnd, 1297 containsHtmlTag, 1298 escapeHtml, 1299 splitCase, 1300 isNullOrWhiteSpace, 1301 isWhiteSpace, 1302 isEmpty, 1303 toKebabCase, 1304 toTitleCase, 1305 upperCaseFirstCharacter, 1306 pluralize, 1307 pluralConditional, 1308 padLeft, 1309 padRight, 1310 truncate, 1311 createHash, 1312 replaceAll, 1313 safeParseJson: safeParseJson$1 1314 }; 1315 1316 var stringUtils$1 = /*#__PURE__*/Object.freeze({ 1317 __proto__: null, 1318 asCommaAnd: asCommaAnd, 1319 containsHtmlTag: containsHtmlTag, 1320 createHash: createHash, 1321 createHashSha256: createHashSha256,
1322 default: stringUtils, 1323 defaultControlCompareValue: defaultControlCompareValue, 1324 escapeHtml: escapeHtml, 1325 isEmpty: isEmpty, 1326 isNullOrWhiteSpace: isNullOrWhiteSpace, 1327 isWhiteSpace: isWhiteSpace, 1328 padLeft: padLeft, 1329 padRight: padRight, 1330 pluralConditional: pluralConditional, 1331 pluralize: pluralize, 1332 prependSingularIndefiniteArticle: prependSingularIndefiniteArticle, 1333 replaceAll: replaceAll, 1334 safeParseJson: safeParseJson$1, 1335 splitCase: splitCase, 1336 toKebabCase: toKebabCase, 1337 toTitleCase: toTitleCase, 1338 truncate: truncate, 1339 upperCaseFirstCharacter: upperCaseFirstCharacter 1340 }); 1341 exports('stringUtils', stringUtils$1); 1342 1343 class LocaleDateFormatter { 1344 constructor(jsDateFormatString) { 1345 this.jsDateFormatString = jsDateFormatString; 1346 } 1347 static fromCurrent() { 1348 const date = new Date(2222, 2, 4); 1349 const localeDateString = date.toLocaleDateString(undefined, { 1350 year: "numeric", 1351 month: "numeric", 1352 day: "numeric" 1353 }); 1354 const defaultFormatString = "MM/DD/YYYY"; 1355 let localeFormatString = localeDateString; 1356 if (localeDateString.includes("2222")) { 1357 localeFormatString = localeDateString.replace("2222", "YYYY"); 1358 } else if (localeDateString.includes("22")) { 1359 localeFormatString = localeDateString.replace("22", "YY"); 1360 } else { 1361 return new LocaleDateFormatter(defaultFormatString); 1362 } 1363 if (localeFormatString.includes("03")) { 1364 localeFormatString = localeFormatString.replace("03", "MM"); 1365 } else if (localeFormatString.includes("3")) { 1366 localeFormatString = localeFormatString.replace("3", "M"); 1367 } else { 1368 return new LocaleDateFormatter(defaultFormatString); 1369 } 1370 if (localeFormatString.includes("04")) { 1371 localeFormatString = localeFormatString.replace("04", "DD"); 1372 } else if (localeFormatString.includes("4")) { 1373 localeFormatString = localeFormatString.replace("4", "D"); 1374 } else { 1375 return new LocaleDateFormatter(defaultFormatString); 1376 } 1377 return new LocaleDateFormatter(localeFormatString); 1378 } 1379 get aspDateFormat() { 1380 if (!this.aspDateFormatString) { 1381 this.aspDateFormatString = this.jsDateFormatString.replace(/D/g, "d").replace(/Y/g, "y"); 1382 } 1383 return this.aspDateFormatString; 1384 } 1385 get datePickerFormat() { 1386 if (!this.datePickerFormatString) { 1387 this.datePickerFormatString = this.jsDateFormatString.replace(/D/g, "d").replace(/M/g, "m").replace(/Y/g, "y"); 1388 } 1389 return this.datePickerFormatString; 1390 } 1391 } 1392 1393 var localeDateFormatter = /*#__PURE__*/Object.freeze({ 1394 __proto__: null, 1395 LocaleDateFormatter: LocaleDateFormatter 1396 }); 1397 exports('localeDateFormatter', localeDateFormatter); 1398 1399 function blankIfZero(value) { 1400 return parseInt(value) === 0 ? "" : value; 1401 } 1402 function get12HourValue(hour) { 1403 if (hour === 0) { 1404 return 12; 1405 } else if (hour < 13) { 1406 return hour; 1407 } else { 1408 return hour - 12; 1409 } 1410 } 1411 const englishDayNames = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]; 1412 const englishMonthNames = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "
1412November", "December"]; 1413 const dateFormatters = { 1414 "yyyyy": date => padLeft(date.year.toString(), 5, "0"), 1415 "yyyy": date => padLeft(date.year.toString(), 4, "0"), 1416 "yyy": date => padLeft(date.year.toString(), 3, "0"), 1417 "yy": date => padLeft((date.year % 100).toString(), 2, "0"), 1418 "y": date => (date.year % 100).toString(), 1419 "MMMM": date => englishMonthNames[date.month - 1], 1420 "MMM": date => englishMonthNames[date.month - 1].substr(0, 3), 1421 "MM": date => padLeft(date.month.toString(), 2, "0"), 1422 "M": date => date.month.toString(), 1423 "dddd": date => englishDayNames[date.dayOfWeek], 1424 "ddd": date => englishDayNames[date.dayOfWeek].substr(0, 3), 1425 "dd": date => padLeft(date.day.toString(), 2, "0"), 1426 "d": date => date.day.toString(), 1427 "fffffff": date => padRight((date.millisecond * 10000).toString(), 7, "0"), 1428 "ffffff": date => padRight((date.millisecond * 1000).toString(), 6, "0"), 1429 "fffff": date => padRight((date.millisecond * 100).toString(), 5, "0"), 1430 "ffff": date => padRight((date.millisecond * 10).toString(), 4, "0"), 1431 "fff": date => padRight(date.millisecond.toString(), 3, "0"), 1432 "ff": date => padRight(Math.floor(date.millisecond / 10).toString(), 2, "0"), 1433 "f": date => padRight(Math.floor(date.millisecond / 100).toString(), 1, "0"), 1434 "FFFFFFF": date => blankIfZero(padRight((date.millisecond * 10000).toString(), 7, "0")), 1435 "FFFFFF": date => blankIfZero(padRight((date.millisecond * 1000).toString(), 6, "0")), 1436 "FFFFF": date => blankIfZero(padRight((date.millisecond * 100).toString(), 5, "0")), 1437 "FFFF": date => blankIfZero(padRight((date.millisecond * 10).toString(), 4, "0")), 1438 "FFF": date => blankIfZero(padRight(date.millisecond.toString(), 3, "0")), 1439 "FF": date => blankIfZero(padRight(Math.floor(date.millisecond / 10).toString(), 2, "0")), 1440 "F": date => blankIfZero(padRight(Math.floor(date.millisecond / 100).toString(), 1, "0")), 1441 "g": date => date.year < 0 ? "B.C." : "A.D.", 1442 "gg": date => date.year < 0 ? "B.C." : "A.D.", 1443 "hh": date => padLeft(get12HourValue(date.hour).toString(), 2, "0"), 1444 "h": date => get12HourValue(date.hour).toString(), 1445 "HH": date => padLeft(date.hour.toString(), 2, "0"), 1446 "H": date => date.hour.toString(), 1447 "mm": date => padLeft(date.minute.toString(), 2, "0"), 1448 "m": date => date.minute.toString(), 1449 "ss": date => padLeft(date.second.toString(), 2, "0"), 1450 "s": date => date.second.toString(), 1451 "K": date => { 1452 const offset = date.offset; 1453 const offsetHour = Math.abs(Math.floor(offset / 60)); 1454 const offsetMinute = Math.abs(offset % 60); 1455 return "".concat(offset >= 0 ? "+" : "-").concat(padLeft(offsetHour.toString(), 2, "0"), ":").concat(padLeft(offsetMinute.toString(), 2, "0")); 1456 }, 1457 "tt": date => date.hour >= 12 ? "PM" : "AM", 1458 "t": date => date.hour >= 12 ? "P" : "A", 1459 "zzz": date => { 1460 const offset = date.offset; 1461 const offsetHour = Math.abs(Math.floor(offset / 60)); 1462 const offsetMinute = Math.abs(offset % 60); 1463 return "".concat(offset >= 0 ? "+" : "-").concat(padLeft(offsetHour.toString(), 2, "0"), ":").concat(padLeft(offsetMinute.toString(), 2, "0")); 1464 }, 1465 "zz": date => { 1466 const offset = date.offset; 1467 const offsetHour = Math.abs(Math.floor(offset / 60)); 1468 return "".concat(offset >= 0 ? "+" : "-").concat(padLeft(offsetHour.toString(), 2, "0")); 1469 }, 1470 "z": date => { 1471 const offset = date.offset; 1472 const offsetHour = Math.abs(Math.floor(offset / 60)); 1473 return "".concat(offset >= 0 ? "+" : "-").concat(offsetHour); 1474 }, 1475 ":": () => ":", 1476 "/": () => "/" 1477 }; 1478 const dateFormatterKeys = new List(Object.keys(dateFormatters)).orderByDescending(k => k.length).toArray(); 1479 const currentLocaleDateFormatter = LocaleDateFormatter.fromCurrent(); 1480 const standardDateFormats = { 1481 "d": date => formatAspDate(date, currentLocaleDateFormatter.aspDateFormat), 1482 "D": date => formatAspDate(date, "dddd, MMMM dd, yyyy"), 1483 "t": date => formatAspDate(date, "h:mm tt"), 1484 "T": date => formatAspDate(date, "h:mm:ss tt"), 1485 "M": date => formatAspDate(date, "MMMM dd"), 1486 "m": date => formatAspDate(date, "MMMM dd"), 1487 "Y": date => formatAspDate(date, "yyyy MMMM"), 1488 "y": date => formatAspDate(date, "yyyy MMMM"), 1489 "f": date => "".concat(formatAspDate(date, "D"), " ").concat(formatAspDate(date, "t")), 1490 "F": date => "".concat(formatAspDate(date, "D"), " ").concat(formatAspDate(date, "T")), 1491 "g": date => "".concat(formatAspDate(date, "d"), " ").concat(formatAspDate(date, "t")), 1492 "G": date => "".concat(formatAspDate(date, "d"), " ").concat(formatAspDate(date, "T")), 1493 "o": date => formatAspDate(date, "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffffffzzz"), 1494 "O": date => formatAspDate(date, "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffffffzzz"), 1495 "r": date => formatAspDate(date, "ddd, dd MMM yyyy HH':'mm':'ss 'GMT'"), 1496 "R": date => formatAspDate(date, "ddd, dd MMM yyyy HH':'mm':'ss 'GMT'"), 1497 "s": date => formatAspDate(date, "yyyy'-'MM'-'dd'T'HH':'mm':'ss"),
1498 "u": date => formatAspDate(date, "yyyy'-'MM'-'dd HH':'mm':'ss'Z'"), 1499 "U": date => { 1500 return formatAspDate(date.universalDateTime, "F"); 1501 } 1502 }; 1503 function formatAspCustomDate(date, format) { 1504 let result = ""; 1505 for (let i = 0; i < format.length;) { 1506 let matchFound = false; 1507 for (const k of dateFormatterKeys) { 1508 if (format.substr(i, k.length) === k) { 1509 result += dateFormatters[k](date); 1510 matchFound = true; 1511 i += k.length; 1512 break; 1513 } 1514 } 1515 if (matchFound) { 1516 continue; 1517 } 1518 if (format[i] === "\\") { 1519 i++; 1520 if (i < format.length) { 1521 result += format[i++]; 1522 } 1523 } else if (format[i] === "'") { 1524 i++; 1525 for (; i < format.length && format[i] !== "'"; i++) { 1526 result += format[i]; 1527 } 1528 i++; 1529 } else if (format[i] === '"') { 1530 i++; 1531 for (; i < format.length && format[i] !== '"'; i++) { 1532 result += format[i]; 1533 } 1534 i++; 1535 } else { 1536 result += format[i++]; 1537 } 1538 } 1539 return result; 1540 } 1541 function formatAspStandardDate(date, format) { 1542 if (standardDateFormats[format] !== undefined) { 1543 return standardDateFormats[format](date); 1544 } 1545 return format; 1546 } 1547 function formatAspDate(date, format) { 1548 if (format.length === 1) { 1549 return formatAspStandardDate(date, format); 1550 } else if (format.length === 2 && format[0] === "%") { 1551 return formatAspCustomDate(date, format[1]); 1552 } else { 1553 return formatAspCustomDate(date, format); 1554 } 1555 } 1556 1557 var aspDateFormat = /*#__PURE__*/Object.freeze({ 1558 __proto__: null, 1559 formatAspDate: formatAspDate 1560 }); 1561 exports('aspDateFormat', aspDateFormat); 1562 1563 const DateTimeFormat = { 1564 DateFull: { 1565 year: "numeric", 1566 month: "long", 1567 day: "numeric" 1568 }, 1569 DateMedium: { 1570 year: "numeric", 1571 month: "short", 1572 day: "numeric" 1573 }, 1574 DateShort: { 1575 year: "numeric", 1576 month: "numeric", 1577 day: "numeric" 1578 }, 1579 TimeShort: { 1580 hour: "numeric", 1581 minute: "numeric" 1582 }, 1583 TimeWithSeconds: { 1584 hour: "numeric", 1585 minute: "numeric", 1586 second: "numeric" 1587 }, 1588 DateTimeShort: { 1589 year: "numeric", 1590 month: "numeric", 1591 day: "numeric", 1592 hour: "numeric", 1593 minute: "numeric" 1594 }, 1595 DateTimeShortWithSeconds: { 1596 year: "numeric", 1597 month: "numeric", 1598 day: "numeric", 1599 hour: "numeric", 1600 minute: "numeric", 1601 second: "numeric" 1602 }, 1603 DateTimeMedium: { 1604 year: "numeric", 1605 month: "short", 1606 day: "numeric", 1607 hour: "numeric", 1608 minute: "numeric" 1609 }, 1610 DateTimeMediumWithSeconds: { 1611 year: "numeric", 1612 month: "short", 1613 day: "numeric", 1614 hour: "numeric", 1615 minute: "numeric", 1616 second: "numeric" 1617 }, 1618 DateTimeFull: { 1619 year: "numeric", 1620 month: "long", 1621 day: "numeric", 1622 hour: "numeric", 1623 minute: "numeric" 1624 }, 1625 DateTimeFullWithSeconds: { 1626 year: "numeric", 1627 month: "long", 1628 day: "numeric", 1629 hour: "numeric", 1630 minute: "numeric", 1631 second: "numeric" 1632 } 1633 }; 1634 class RockDateTime { 1635 constructor(dateTime) { 1636 this.dateTime = dateTime; 1637 } 1638 static fromParts(year, month, day, hour, minute, second, millisecond, zone) { 1639 let luxonZone; 1640 if (zone !== undefined) { 1641 if (typeof zone === "number") { 1642 luxonZone = FixedOffsetZone.instance(zone); 1643 } else { 1644 luxonZone = zone; 1645 } 1646 } 1647 const dateTime = DateTime.fromObject({ 1648 year, 1649 month, 1650 day, 1651 hour, 1652 minute, 1653 second, 1654 millisecond 1655 }, { 1656 zone: luxonZone 1657 }); 1658 if (!dateTime.isValid) { 1659 return null; 1660 } 1661 return new RockDateTime(dateTime); 1662 } 1663 static fromMilliseconds(milliseconds) { 1664 const dateTime = DateTime.fromMillis(milliseconds); 1665 if (!dateTime.isValid) { 1666 return null; 1667 } 1668 return new RockDateTime(dateTime); 1669 } 1670 static fromJSDate(date) { 1671 const dateTime = DateTime.fromJSDate(date); 1672 if (!dateTime.isValid) { 1673 return null; 1674 } 1675 return new RockDateTime(dateTime); 1676 } 1677 static parseISO(dateString) { 1678 const dateTime = DateTime.fromISO(dateString, { 1679 setZone: true 1680 }); 1681 if (!dateTime.isValid) { 1682 return null; 1683 } 1684 return new RockDateTime(dateTime); 1685 } 1686 static parseHTTP(dateString) { 1687 const dateTime = DateTime.fromHTTP(dateString, { 1688 setZone: true 1689 }); 1690 if (!dateTime.isValid) { 1691 return null; 1692 } 1693 return new RockDateTime(dateTime); 1694 } 1695 static now() { 1696 return new RockDateTime(DateTime.now()); 1697 } 1698 static utcNow() { 1699 return new RockDateTime(DateTime.now().toUTC()); 1700 } 1701 get date() { 1702 const date = RockDateTime.fromParts(this.year, this.month, this.day, 0, 0, 0, 0, this.offset); 1703 if (date === null) { 1704 throw "Could not convert to date instance."; 1705 } 1706 return date; 1707 } 1708 get rawDate() { 1709 const date = RockDateTime.fromParts(this.year, this.month, this.day, 0, 0, 0, 0); 1710 if (date === null) { 1711 throw "Could not convert to date instance."; 1712 } 1713 return date; 1714 } 1715 get day() { 1716 return this.dateTime.day; 1717 } 1718 get dayOfWeek() { 1719 switch (this.dateTime.weekday) { 1720 case 1: 1721 return DayOfWeek.Monday; 1722 case 2: 1723 return DayOfWeek.Tuesday; 1724 case 3: 1725 return DayOfWeek.Wednesday; 1726 case 4: 1727 return DayOfWeek.Thursday; 1728 case 5: 1729 return DayOfWeek.Friday; 1730 case 6: 1731 return DayOfWeek.Saturday; 1732 case 7: 1733 return DayOfWeek.Sunday; 1734 } 1735 throw "Could not determine day of week."; 1736 } 1737 get dayOfYear() { 1738 return this.dateTime.ordinal; 1739 } 1740 get hour() { 1741 return this.dateTime.hour; 1742 } 1743 get millisecond() { 1744 return this.dateTime.millisecond; 1745 } 1746 get minute() { 1747 return this.dateTime.minute; 1748 } 1749 get month() { 1750 return this.dateTime.month; 1751 } 1752 get offset() { 1753 return this.dateTime.offset; 1754 } 1755 get second() { 1756 return this.dateTime.second; 1757 } 1758 get year() { 1759 return this.dateTime.year; 1760 } 1761 get localDateTime() { 1762 return new RockDateTime(this.dateTime.toLocal()); 1763 } 1764 get organizationDateTime() { 1765 throw "Not Implemented"; 1766 } 1767 get universalDateTime() { 1768 return new RockDateTime(this.dateTime.toUTC()); 1769 } 1770 addDays(days) { 1771 const dateTime = this.dateTime.plus({ 1772 days: days 1773 }); 1774 if (!dateTime.isValid) {
1775 throw "Operation produced an invalid date."; 1776 } 1777 return new RockDateTime(dateTime); 1778 } 1779 startOfWeek() { 1780 const dateTime = this.dateTime.startOf("week"); 1781 if (!dateTime.isValid) { 1782 throw "Operation produced an invalid date."; 1783 } 1784 return new RockDateTime(dateTime); 1785 } 1786 startOfMonth() { 1787 const dateTime = this.dateTime.startOf("month"); 1788 if (!dateTime.isValid) { 1789 throw "Operation produced an invalid date."; 1790 } 1791 return new RockDateTime(dateTime); 1792 } 1793 endOfMonth() { 1794 const dateTime = this.dateTime.endOf("month"); 1795 if (!dateTime.isValid) { 1796 throw "Operation produced an invalid date."; 1797 } 1798 return new RockDateTime(dateTime); 1799 } 1800 addHours(hours) { 1801 const dateTime = this.dateTime.plus({ 1802 hours: hours 1803 }); 1804 if (!dateTime.isValid) { 1805 throw "Operation produced an invalid date."; 1806 } 1807 return new RockDateTime(dateTime); 1808 } 1809 addMilliseconds(milliseconds) { 1810 const dateTime = this.dateTime.plus({ 1811 milliseconds: milliseconds 1812 }); 1813 if (!dateTime.isValid) { 1814 throw "Operation produced an invalid date."; 1815 } 1816 return new RockDateTime(dateTime); 1817 } 1818 addMinutes(minutes) { 1819 const dateTime = this.dateTime.plus({ 1820 minutes: minutes 1821 }); 1822 if (!dateTime.isValid) { 1823 throw "Operation produced an invalid date."; 1824 } 1825 return new RockDateTime(dateTime); 1826 } 1827 addMonths(months) { 1828 const dateTime = this.dateTime.plus({ 1829 months: months 1830 }); 1831 if (!dateTime.isValid) { 1832 throw "Operation produced an invalid date."; 1833 } 1834 return new RockDateTime(dateTime); 1835 } 1836 addSeconds(seconds) { 1837 const dateTime = this.dateTime.plus({ 1838 seconds: seconds 1839 }); 1840 if (!dateTime.isValid) { 1841 throw "Operation produced an invalid date."; 1842 } 1843 return new RockDateTime(dateTime); 1844 } 1845 addYears(years) { 1846 const dateTime = this.dateTime.plus({ 1847 years: years 1848 }); 1849 if (!dateTime.isValid) { 1850 throw "Operation produced an invalid date."; 1851 } 1852 return new RockDateTime(dateTime); 1853 } 1854 toMilliseconds() { 1855 return this.dateTime.toMillis(); 1856 } 1857 toOffset(zone) { 1858 let dateTime; 1859 if (typeof zone === "number") { 1860 dateTime = this.dateTime.setZone(FixedOffsetZone.instance(zone)); 1861 } else { 1862 dateTime = this.dateTime.setZone(zone); 1863 } 1864 if (!dateTime.isValid) { 1865 throw "Invalid time zone specified."; 1866 } 1867 return new RockDateTime(dateTime); 1868 } 1869 toASPString(format) { 1870 return formatAspDate(this, format); 1871 } 1872 toISOString() { 1873 return this.dateTime.toISO(); 1874 } 1875 toLocaleString(format) { 1876 return this.dateTime.toLocaleString(format); 1877 } 1878 toElapsedString(currentDateTime) { 1879 const msPerSecond = 1000; 1880 const msPerMinute = 1000 * 60; 1881 const msPerHour = 1000 * 60 * 60; 1882 const hoursPerDay = 24; 1883 const daysPerYear = 365; 1884 let start = new RockDateTime(this.dateTime); 1885 let end = currentDateTime !== null && currentDateTime !== void 0 ? currentDateTime : RockDateTime.now(); 1886 let direction = "Ago"; 1887 let totalMs = end.toMilliseconds() - start.toMilliseconds(); 1888 if (totalMs < 0) { 1889 direction = "From Now"; 1890 totalMs = Math.abs(totalMs); 1891 start = end; 1892 end = new RockDateTime(this.dateTime); 1893 } 1894 const totalSeconds = totalMs / msPerSecond; 1895 const totalMinutes = totalMs / msPerMinute; 1896 const totalHours = totalMs / msPerHour; 1897 const totalDays = totalHours / hoursPerDay; 1898 if (totalHours < 24) { 1899 if (totalSeconds < 2) { 1900 return "1 Second ".concat(direction); 1901 } 1902 if (totalSeconds < 60) { 1903 return "".concat(Math.floor(totalSeconds), " Seconds ").concat(direction); 1904 } 1905 if (totalMinutes < 2) { 1906 return "1 Minute ".concat(direction); 1907 } 1908 if (totalMinutes < 60) { 1909 return "".concat(Math.floor(totalMinutes), " Minutes ").concat(direction); 1910 } 1911 if (totalHours < 2) { 1912 return "1 Hour ".concat(direction); 1913 } 1914 if (totalHours < 60) { 1915 return "".concat(Math.floor(totalHours), " Hours ").concat(direction); 1916 } 1917 } 1918 if (totalDays < 2) { 1919 return "1 Day ".concat(direction); 1920 } 1921 if (totalDays < 31) { 1922 return "".concat(Math.floor(totalDays), " Days ").concat(direction); 1923 } 1924 const totalMonths = end.totalMonths(start); 1925 if (totalMonths <= 1) { 1926 return "1 Month ".concat(direction); 1927 } 1928 if (totalMonths <= 18) { 1929 return "".concat(Math.round(totalMonths), " Months ").concat(direction); 1930 } 1931 const totalYears = Math.floor(totalDays / daysPerYear); 1932 if (totalYears <= 1) { 1933 return "1 Year ".concat(direction); 1934 } 1935 return "".concat(Math.round(totalYears), " Years ").concat(direction); 1936 } 1937 toElapsedShortString(currentDateTime) { 1938 const start = this.dateTime; 1939 const end = (currentDateTime !== null && currentDateTime !== void 0 ? currentDateTime : RockDateTime.now()).dateTime; 1940 let diffMs = end.toMillis() - start.toMillis(); 1941 diffMs = Math.abs(diffMs); 1942 const seconds = diffMs / 1000; 1943 const minutes = seconds / 60; 1944 const hours = minutes / 60; 1945 const days = hours / 24; 1946 const weeks = days / 7; 1947 const years = days / 365; 1948 if (seconds < 60) { 1949 return "".concat(Math.floor(seconds), "s"); 1950 } 1951 if (minutes < 60) { 1952 return "".concat(Math.floor(minutes), "m"); 1953 } 1954 if (hours < 24) { 1955 return "".concat(Math.floor(hours), "h"); 1956 } 1957 if (days < 14) { 1958 return "".concat(Math.floor(days), "d"); 1959 } 1960 if (weeks < 52) { 1961 return "".concat(Math.floor(weeks), "w"); 1962 } 1963 return "".concat(Math.floor(years), "y"); 1964 } 1965 toHTTPString() { 1966 return this.dateTime.toHTTP(); 1967 } 1968 valueOf() { 1969 return this.dateTime.valueOf(); 1970 } 1971 toString() {
1972 return this.toLocaleString(DateTimeFormat.DateTimeFull); 1973 } 1974 isEqualTo(otherDateTime) { 1975 return this.dateTime.toMillis() === otherDateTime.dateTime.toMillis(); 1976 } 1977 isLaterThan(otherDateTime) { 1978 return this.dateTime.toMillis() > otherDateTime.dateTime.toMillis(); 1979 } 1980 isEarlierThan(otherDateTime) { 1981 return this.dateTime.toMillis() < otherDateTime.dateTime.toMillis(); 1982 } 1983 compareTo(otherDateTime) { 1984 if (this.isEqualTo(otherDateTime)) { 1985 return 0; 1986 } else if (this.isEarlierThan(otherDateTime)) { 1987 return -1; 1988 } else { 1989 return 1; 1990 } 1991 } 1992 humanizeElapsed(otherDateTime) { 1993 otherDateTime = otherDateTime !== null && otherDateTime !== void 0 ? otherDateTime : RockDateTime.now(); 1994 const totalSeconds = Math.floor((otherDateTime.dateTime.toMillis() - this.dateTime.toMillis()) / 1000); 1995 if (totalSeconds <= 1) { 1996 return "right now"; 1997 } else if (totalSeconds < 60) { 1998 return "".concat(totalSeconds, " seconds ago"); 1999 } else if (totalSeconds >= 60 && totalSeconds <= 119) { 2000 return "1 minute ago"; 2001 } else if (totalSeconds < 3600) { 2002 return "".concat(Math.floor(totalSeconds / 60), " minutes ago"); 2003 } else if (totalSeconds < 86400) { 2004 return "".concat(Math.floor(totalSeconds / 3600), " hours ago"); 2005 } else if (totalSeconds < 31536000) { 2006 return "".concat(Math.floor(totalSeconds / 86400), " days ago"); 2007 } else { 2008 return "".concat(Math.floor(totalSeconds / 31536000), " years ago"); 2009 } 2010 } 2011 totalMonths(otherDateTime) { 2012 return this.year * 12 + this.month - (otherDateTime.year * 12 + otherDateTime.month); 2013 } 2014 } 2015 function compareRockDateTimes(a, b) { 2016 return a.compareTo(b); 2017 } 2018 2019 var rockDateTime = /*#__PURE__*/Object.freeze({ 2020 __proto__: null, 2021 DateTimeFormat: DateTimeFormat, 2022 DayOfWeek: DayOfWeek, 2023 RockDateTime: RockDateTime, 2024 compareRockDateTimes: compareRockDateTimes 2025 }); 2026 exports('rockDateTime', rockDateTime); 2027 2028 function shortcutCancelledEvent(listener) { 2029 window.setTimeout(listener, 0); 2030 } 2031 function isCancellationToken(thing) { 2032 if (thing === CancellationTokenNone || thing === CancellationTokenCancelled) { 2033 return true; 2034 } 2035 if (thing instanceof MutableToken) { 2036 return true; 2037 } 2038 if (!thing || typeof thing !== "object") { 2039 return false; 2040 } 2041 return typeof thing.isCancellationRequested === "boolean" && typeof thing.onCancellationRequested === "function"; 2042 } 2043 const CancellationTokenNone = Object.freeze({ 2044 isCancellationRequested: false, 2045 onCancellationRequested() {} 2046 }); 2047 const CancellationTokenCancelled = Object.freeze({ 2048 isCancellationRequested: true, 2049 onCancellationRequested: shortcutCancelledEvent 2050 }); 2051 class MutableToken { 2052 constructor() { 2053 _defineProperty(this, "isCancelled", false); 2054 _defineProperty(this, "emitter", null); 2055 } 2056 cancel() { 2057 if (!this.isCancelled) { 2058 this.isCancelled = true; 2059 if (this.emitter) { 2060 this.emitter.emit("cancel", undefined); 2061 this.emitter = null; 2062 } 2063 } 2064 } 2065 get isCancellationRequested() { 2066 return this.isCancelled; 2067 } 2068 onCancellationRequested(listener) { 2069 if (this.isCancelled) { 2070 return shortcutCancelledEvent(listener); 2071 } 2072 if (!this.emitter) { 2073 this.emitter = mitt(); 2074 } 2075 this.emitter.on("cancel", listener); 2076 } 2077 } 2078 class CancellationTokenSource { 2079 constructor(parent) { 2080 _defineProperty(this, "internalToken", undefined); 2081 if (parent) { 2082 parent.onCancellationRequested(() => this.cancel()); 2083 } 2084 } 2085 get token() { 2086 if (!this.internalToken) { 2087 this.internalToken = new MutableToken(); 2088 } 2089 return this.internalToken; 2090 } 2091 cancel() { 2092 if (!this.internalToken) { 2093 this.internalToken = CancellationTokenCancelled; 2094 } else if (this.internalToken instanceof MutableToken) { 2095 this.internalToken.cancel(); 2096 } 2097 } 2098 } 2099 2100 var cancellation = /*#__PURE__*/Object.freeze({ 2101 __proto__: null, 2102 CancellationTokenCancelled: CancellationTokenCancelled, 2103 CancellationTokenNone: CancellationTokenNone, 2104 CancellationTokenSource: CancellationTokenSource, 2105 isCancellationToken: isCancellationToken 2106 }); 2107 exports('cancellation', cancellation); 2108 2109 function getUniqueCssSelector(el) { 2110 const path = []; 2111 let parent = el.parentNode; 2112 while (parent) { 2113 path.unshift("".concat(el.tagName, ":nth-child(").concat([].indexOf.call(parent.children, el) + 1, ")")); 2114 el = parent; 2115 parent = el.parentNode; 2116 } 2117 return "".concat(path.join(" > ")).toLowerCase(); 2118 } 2119 function* getAncestors(element) { 2120 let parent = element.parentElement; 2121 while (parent) { 2122 yield parent; 2123 parent = parent.parentElement; 2124 } 2125 } 2126 function isElementFullyVisible(element) { 2127 const rect = element.getBoundingClientRect(); 2128 return rect.top >= 0 && rect.left >= 0 && rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) && rect.right <= (window.innerWidth || document.documentElement.clientWidth); 2129 } 2130 function scrollElementStartToTop(element) { 2131 const isWithinScrolledContainer = Enumerable.from(getAncestors(element)).any(ancestorElement => { 2132 const { 2133 overflowY 2134 } = getComputedStyle(ancestorElement); 2135 const isScrollable = overflowY === "scroll" || overflowY === "auto"; 2136 return isScrollable && ancestorElement.scrollHeight > ancestorElement.clientHeight; 2137 }); 2138 if (isWithinScrolledContainer) { 2139 element.scrollIntoView({ 2140 block: "start", 2141 behavior: "smooth" 2142 }); 2143 } else { 2144 const rect = element.getBoundingClientRect(); 2145 const desiredLeft = rect.left < 0 ? 0 : rect.left; 2146 let desiredTop = 0; 2147 const elementsAtDesiredLocation = document.elementsFromPoint(desiredLeft + 1, desiredTop + 1); 2148 const fixedElementAtDesiredLocation = elementsAtDesiredLocation.find(el => getComputedStyle(el).position === "fixed"); 2149 if (fixedElementAtDesiredLocation) { 2150 const { 2151 height: fixedHeight 2152 } = fixedElementAtDesiredLocation.getBoundingClientRect(); 2153 desiredTop = fixedHeight; 2154 } 2155 window.scrollBy({ 2156 top: rect.top - desiredTop, 2157 behavior: "smooth" 2158 }); 2159 } 2160 } 2161 function findDirectChildContaining(element, descendantElement) {
2162 let current = descendantElement; 2163 while (current && current !== element) { 2164 if (current.parentElement === element && isHTMLElement(current)) { 2165 return current; 2166 } 2167 current = current.parentElement; 2168 } 2169 return null; 2170 } 2171 function findNearestIFrameElementFromPoint(iframe, x, y, selector) { 2172 var _iframe$contentWindow; 2173 let xRange = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 10; 2174 let yRange = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 10; 2175 const iframeDoc = iframe.contentDocument || ((_iframe$contentWindow = iframe.contentWindow) === null || _iframe$contentWindow === void 0 ? void 0 : _iframe$contentWindow.document); 2176 if (!iframeDoc) { 2177 console.error("Unable to access iframe content."); 2178 return { 2179 element: null, 2180 isAbove: false, 2181 isBelow: false, 2182 isLeft: false, 2183 isRight: false 2184 }; 2185 } 2186 const iframeRect = iframe.getBoundingClientRect(); 2187 let closestElement = null; 2188 let isAbove = false; 2189 let isBelow = false; 2190 let isLeft = false; 2191 let isRight = false; 2192 let smallestDistance = Infinity; 2193 for (let dx = -xRange; dx <= xRange; dx += 1) { 2194 for (let dy = -yRange; dy <= yRange; dy += 1) { 2195 Enumerable.from(iframeDoc.elementsFromPoint(x + dx, y + dy)).where(element => element.matches(selector)).ofType(isHTMLElement).forEach(element => { 2196 const rect = element.getBoundingClientRect(); 2197 const elementX = rect.left - iframeRect.left; 2198 const elementY = rect.top - iframeRect.top; 2199 const distance = Math.sqrt(Math.pow(elementX - x, 2) + Math.pow(elementY - y, 2)); 2200 if (distance < smallestDistance) { 2201 smallestDistance = distance; 2202 closestElement = element; 2203 isAbove = dy < 0; 2204 isBelow = dy > 0; 2205 isLeft = dx < 0; 2206 isRight = dx > 0; 2207 } 2208 }); 2209 } 2210 } 2211 return { 2212 element: closestElement, 2213 isAbove, 2214 isBelow, 2215 isLeft, 2216 isRight 2217 }; 2218 } 2219 function getWindow(el) { 2220 return el.ownerDocument.defaultView; 2221 } 2222 function isElement(el) { 2223 var _el$ownerDocument; 2224 const elWindow = el === null || el === void 0 || (_el$ownerDocument = el["ownerDocument"]) === null || _el$ownerDocument === void 0 ? void 0 : _el$ownerDocument["defaultView"]; 2225 return el instanceof Element || !!elWindow && el instanceof elWindow.Element; 2226 } 2227 function isHTMLElement(el) { 2228 var _el$ownerDocument2; 2229 const elWindow = el === null || el === void 0 || (_el$ownerDocument2 = el["ownerDocument"]) === null || _el$ownerDocument2 === void 0 ? void 0 : _el$ownerDocument2["defaultView"]; 2230 return el instanceof HTMLElement || !!elWindow && el instanceof elWindow.HTMLElement || typeof el === "object" && el !== null && typeof el.tagName === "string" && typeof el.classList === "object"; 2231 } 2232 function isHTMLTableElement(el) { 2233 var _el$ownerDocument3; 2234 const elWindow = el === null || el === void 0 || (_el$ownerDocument3 = el["ownerDocument"]) === null || _el$ownerDocument3 === void 0 ? void 0 : _el$ownerDocument3["defaultView"]; 2235 return el instanceof HTMLTableElement || !!elWindow && el instanceof elWindow.HTMLTableElement; 2236 } 2237 function isHTMLAnchorElement(el) { 2238 var _el$ownerDocument4; 2239 const elWindow = el === null || el === void 0 || (_el$ownerDocument4 = el["ownerDocument"]) === null || _el$ownerDocument4 === void 0 ? void 0 : _el$ownerDocument4["defaultView"]; 2240 return !!elWindow && el instanceof elWindow.HTMLAnchorElement; 2241 } 2242 function isDocument(doc) { 2243 const docWindow = doc === null || doc === void 0 ? void 0 : doc["defaultView"]; 2244 return !!docWindow && doc instanceof docWindow.Document; 2245 } 2246 function isMouseEvent(event) { 2247 const eventWindow = event === null || event === void 0 ? void 0 : event["view"]; 2248 return !!eventWindow && event instanceof eventWindow.MouseEvent; 2249 } 2250 function isTouchEvent(event) { 2251 const eventWindow = event === null || event === void 0 ? void 0 : event["view"]; 2252 return !!(eventWindow !== null && eventWindow !== void 0 && eventWindow.TouchEvent) && event instanceof eventWindow.TouchEvent; 2253 } 2254 function removeWhiteSpaceFromElement(element, selector) { 2255 var _element$textContent; 2256 if ((!selector || element.matches(selector)) && element.childNodes.length && Enumerable.from(element.childNodes).all(n => n.nodeType === Node.TEXT_NODE) && !((_element$textContent = element.textContent) !== null && _element$textContent !== void 0 && _element$textContent.trim())) { 2257 element.innerHTML = ""; 2258 } 2259 } 2260 function removeWhiteSpaceFromElementAndChildElements(element, selector) { 2261 removeWhiteSpaceFromChildElements(element, selector); 2262 removeWhiteSpaceFromElement(element, selector); 2263 } 2264 function removeWhiteSpaceFromChildElements(element, selector) { 2265 if (selector) { 2266 element.querySelectorAll(selector).forEach(el => { 2267 removeWhiteSpaceFromElement(el, selector); 2268 }); 2269 } else {
2270 Enumerable.from(element.children).forEach(el => { 2271 removeWhiteSpaceFromElement(el, selector); 2272 }); 2273 } 2274 } 2275 function replaceTagName(oldElement, newTagName) { 2276 const newElement = oldElement.ownerDocument.createElement(newTagName); 2277 Array.from(oldElement.attributes).forEach(attr => newElement.setAttribute(attr.name, attr.value)); 2278 while (oldElement.firstChild) { 2279 newElement.appendChild(oldElement.firstChild); 2280 } 2281 oldElement.replaceWith(newElement); 2282 return newElement; 2283 } 2284 2285 var dom = /*#__PURE__*/Object.freeze({ 2286 __proto__: null, 2287 findDirectChildContaining: findDirectChildContaining, 2288 findNearestIFrameElementFromPoint: findNearestIFrameElementFromPoint, 2289 getAncestors: getAncestors, 2290 getUniqueCssSelector: getUniqueCssSelector, 2291 getWindow: getWindow, 2292 isDocument: isDocument, 2293 isElement: isElement, 2294 isElementFullyVisible: isElementFullyVisible, 2295 isHTMLAnchorElement: isHTMLAnchorElement, 2296 isHTMLElement: isHTMLElement, 2297 isHTMLTableElement: isHTMLTableElement, 2298 isMouseEvent: isMouseEvent, 2299 isTouchEvent: isTouchEvent, 2300 removeWhiteSpaceFromChildElements: removeWhiteSpaceFromChildElements, 2301 removeWhiteSpaceFromElement: removeWhiteSpaceFromElement, 2302 removeWhiteSpaceFromElementAndChildElements: removeWhiteSpaceFromElementAndChildElements, 2303 replaceTagName: replaceTagName, 2304 scrollElementStartToTop: scrollElementStartToTop 2305 }); 2306 exports('dom', dom); 2307 2308 function deepEqual(a, b, strict) { 2309 if (strict && a === b) { 2310 return true; 2311 } else if (!strict && a == b) { 2312 return true; 2313 } 2314 if (typeof a === "number" && typeof b === "number" && isNaN(a) && isNaN(b)) { 2315 return true; 2316 } 2317 if (a && b && typeof a === "object" && typeof b === "object") { 2318 if (Array.isArray(a) !== Array.isArray(b)) { 2319 return false; 2320 } 2321 if (Array.isArray(a) && Array.isArray(b)) { 2322 if (a.length !== b.length) { 2323 return false; 2324 } 2325 for (let i = 0; i < a.length; i++) { 2326 if (!deepEqual(a[i], b[i], strict)) { 2327 return false; 2328 } 2329 } 2330 return true; 2331 } else { 2332 if (a.constructor !== b.constructor) { 2333 return false; 2334 } 2335 if (isHTMLElement(a) && isHTMLElement(b)) { 2336 return a === b; 2337 } 2338 const aEntries = Object.entries(a).sort((a, b) => a[0] < b[0] ? -1 : a[0] > b[0] ? 1 : 0); 2339 const bEntries = Object.entries(b).sort((a, b) => a[0] < b[0] ? -1 : a[0] > b[0] ? 1 : 0); 2340 if (aEntries.length !== bEntries.length) { 2341 return false; 2342 } 2343 for (let i = 0; i < aEntries.length; i++) { 2344 const aEntry = aEntries[i]; 2345 const bEntry = bEntries[i]; 2346 if (!deepEqual(aEntry[0], bEntry[0], true)) { 2347 return false; 2348 } 2349 if (!deepEqual(aEntry[1], bEntry[1], strict)) { 2350 return false; 2351 } 2352 } 2353 return true; 2354 } 2355 } 2356 return false; 2357 } 2358 function debounce(fn) { 2359 let delay = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 250; 2360 let eager = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; 2361 let timeout = null; 2362 return () => { 2363 if (timeout) { 2364 clearTimeout(timeout); 2365 } else if (eager) { 2366 fn(); 2367 timeout = setTimeout(() => timeout = null, delay); 2368 return; 2369 } 2370 timeout = setTimeout(() => { 2371 timeout = null; 2372 fn(); 2373 }, delay); 2374 }; 2375 } 2376 function debounceAsync(fn, options) { 2377 var _options$delay, _options$eager; 2378 const delay = (_options$delay = options === null || options === void 0 ? void 0 : options.delay) !== null && _options$delay !== void 0 ? _options$delay : 250; 2379 const eager = (_options$eager = options === null || options === void 0 ? void 0 : options.eager) !== null && _options$eager !== void 0 ? _options$eager : false;
2380 let timeout = null; 2381 let source = null; 2382 let isEagerExecutionInProgress = false; 2383 let pendingPromise = null; 2384 return async parentCancellationToken => { 2385 var _source; 2386 (_source = source) === null || _source === void 0 || _source.cancel(); 2387 if (timeout) { 2388 clearTimeout(timeout); 2389 timeout = null; 2390 } else if (eager && !isEagerExecutionInProgress) { 2391 isEagerExecutionInProgress = true; 2392 source = new CancellationTokenSource(parentCancellationToken); 2393 timeout = setTimeout(() => { 2394 timeout = null; 2395 isEagerExecutionInProgress = false; 2396 }, delay); 2397 try { 2398 pendingPromise = fn(source.token); 2399 return await pendingPromise; 2400 } catch (e) { 2401 console.error(e || "Unknown error while debouncing async function call."); 2402 throw e; 2403 } 2404 } 2405 source = new CancellationTokenSource(parentCancellationToken); 2406 const cts = source; 2407 return new Promise((resolve, reject) => { 2408 timeout = setTimeout(async () => { 2409 try { 2410 pendingPromise = fn(cts.token); 2411 resolve(await pendingPromise); 2412 } catch (e) { 2413 console.error(e || "Unknown error while debouncing async function call."); 2414 reject(e); 2415 } 2416 timeout = null; 2417 isEagerExecutionInProgress = false; 2418 }, delay); 2419 }); 2420 }; 2421 } 2422 function isNullish(value) { 2423 return (value !== null && value !== void 0 ? value : null) === null; 2424 } 2425 function isNotNullish(item) { 2426 return !isNullish(item); 2427 } 2428 function assertType(value) { 2429 return true; 2430 } 2431 2432 var util = /*#__PURE__*/Object.freeze({ 2433 __proto__: null, 2434 assertType: assertType, 2435 debounce: debounce, 2436 debounceAsync: debounceAsync, 2437 deepEqual: deepEqual, 2438 isNotNullish: isNotNullish, 2439 isNullish: isNullish 2440 }); 2441 exports('util', util); 2442 2443 const PageMessages = { 2444 QueryStringChanged: "page.core.queryStringChanged", 2445 ContextEntityChanged: "page.core.contextEntityChanged" 2446 }; 2447 const BlockMessages = { 2448 BeginEdit: "block.core.beginEdit", 2449 EndEdit: "block.core.endEdit" 2450 }; 2451 function useBrowserBus(options) { 2452 return new BrowserBus(options !== null && options !== void 0 ? options : {}); 2453 } 2454 const customDomEventName = "rockMessage"; 2455 class BrowserBus { 2456 constructor(options) { 2457 _defineProperty(this, "handlers", []); 2458 this.options = _objectSpread2({}, options); 2459 this.eventListener = e => this.onEvent(e); 2460 document.addEventListener(customDomEventName, this.eventListener); 2461 } 2462 onEvent(event) { 2463 if (!(event instanceof CustomEvent)) { 2464 return; 2465 } 2466 let message = event.detail; 2467 if (!message.name) { 2468 return; 2469 } 2470 if (typeof message.timestamp === "undefined") { 2471 message = _objectSpread2(_objectSpread2({}, message), {}, { 2472 timestamp: 0 2473 }); 2474 } 2475 this.onMessage(message); 2476 } 2477 onMessage(message) { 2478 const handlers = [...this.handlers]; 2479 for (const handler of handlers) { 2480 try { 2481 if (handler.name && handler.name !== message.name) { 2482 continue; 2483 } 2484 if (handler.blockType && !areEqual(handler.blockType, message.blockType)) { 2485 continue; 2486 } 2487 if (handler.block && !areEqual(handler.block, message.block)) { 2488 continue; 2489 } 2490 handler.callback(message); 2491 } catch (e) { 2492 console.error(e); 2493 } 2494 } 2495 } 2496 dispose() { 2497 document.removeEventListener(customDomEventName, this.eventListener); 2498 this.handlers.splice(0, this.handlers.length); 2499 } 2500 publish(messageName, data) { 2501 this.publishMessage({ 2502 name: messageName, 2503 timestamp: Date.now(), 2504 blockType: this.options.blockType, 2505 block: this.options.block, 2506 data 2507 }); 2508 } 2509 publishMessage(message) { 2510 const event = new CustomEvent(customDomEventName, { 2511 detail: message 2512 }); 2513 document.dispatchEvent(event); 2514 } 2515 subscribe(messageNameOrCallback, callback) { 2516 let name; 2517 if (typeof messageNameOrCallback === "string") { 2518 name = messageNameOrCallback; 2519 } else { 2520 name = undefined; 2521 callback = messageNameOrCallback; 2522 } 2523 if (!callback) { 2524 return; 2525 } 2526 this.handlers.push({ 2527 name, 2528 callback 2529 }); 2530 } 2531 subscribeToBlockType(messageNameOrBlockType, blockTypeOrCallback, callback) { 2532 let name; 2533 let blockType; 2534 if (typeof blockTypeOrCallback === "string") { 2535 name = messageNameOrBlockType; 2536 blockType = blockTypeOrCallback; 2537 } else { 2538 blockType = messageNameOrBlockType; 2539 callback = blockTypeOrCallback; 2540 } 2541 if (!blockType || !callback) { 2542 return; 2543 } 2544 this.handlers.push({ 2545 name, 2546 blockType, 2547 callback 2548 }); 2549 } 2550 subscribeToBlock(messageNameOrBlock, blockOrCallback, callback) { 2551 let name; 2552 let block; 2553 if (typeof blockOrCallback === "string") { 2554 name = messageNameOrBlock; 2555 block = blockOrCallback; 2556 } else { 2557 block = messageNameOrBlock; 2558 callback = blockOrCallback; 2559 } 2560 if (!block || !callback) { 2561 return; 2562 } 2563 this.handlers.push({ 2564 name, 2565 block, 2566 callback 2567 }); 2568 } 2569 } 2570 2571 var browserBus = /*#__PURE__*/Object.freeze({ 2572 __proto__: null, 2573 BlockMessages: BlockMessages, 2574 BrowserBus: BrowserBus, 2575 PageMessages: PageMessages, 2576 useBrowserBus: useBrowserBus 2577 }); 2578 exports('browserBus', browserBus); 2579 2580 const blockReloadSymbol = Symbol(); 2581 const blockRoleActionsSymbol = Symbol("block-role-actions"); 2582 const configurationValuesChangedSymbol = Symbol(); 2583 const staticContentSymbol = Symbol("static-content"); 2584 function useConfigurationValues() { 2585 const result = inject("configurationValues"); 2586 if (result === undefined) { 2587 throw "Attempted to access block configuration outside of a RockBlock."; 2588 } 2589 return result.value; 2590 } 2591 function useInvokeBlockAction() { 2592 const result = inject("invokeBlockAction"); 2593 if (result === undefined) { 2594 throw "Attempted to access block action invocation outside of a RockBlock."; 2595 } 2596 return result; 2597 } 2598 function useBlockActionUrl() { 2599 const result = inject("blockActionUrl"); 2600 if (result === undefined) { 2601 throw "Attempted to access block action URL outside of a RockBlock."; 2602 } 2603 return result; 2604 } 2605 function createInvokeBlockAction(post, pageGuid, blockGuid, pageParameters, sessionGuid, interactionGuid) { 2606 async function invokeBlockAction(actionName) { 2607 let data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : undefined; 2608 let actionContext = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : undefined; 2609 let cancellationToken = arguments.length > 3 ? arguments[3] : undefined; 2610 let context = {}; 2611 if (actionContext) {
2612 context = _objectSpread2({}, actionContext); 2613 } 2614 context.pageParameters = pageParameters; 2615 context.interactionGuid = interactionGuid; 2616 context.sessionGuid = sessionGuid; 2617 return await post("/api/v2/BlockActions/".concat(pageGuid, "/").concat(blockGuid, "/").concat(actionName), undefined, _objectSpread2({ 2618 __context: context 2619 }, data), cancellationToken); 2620 } 2621 return invokeBlockAction; 2622 } 2623 function useInvokeStreamingBlockAction() { 2624 const result = inject("invokeStreamingBlockAction"); 2625 if (result === undefined) { 2626 throw "Attempted to access block action invocation outside of a RockBlock."; 2627 } 2628 return result; 2629 } 2630 function createInvokeStreamingBlockAction(doStreamingApiCall, pageGuid, blockGuid, pageParameters, sessionGuid, interactionGuid) { 2631 async function invokeBlockAction(actionName) { 2632 let data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : undefined; 2633 let actionContext = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : undefined; 2634 let cancellationToken = arguments.length > 3 ? arguments[3] : undefined; 2635 let context = {}; 2636 if (actionContext) { 2637 context = _objectSpread2({}, actionContext); 2638 } 2639 context.pageParameters = pageParameters; 2640 context.interactionGuid = interactionGuid; 2641 context.sessionGuid = sessionGuid; 2642 return await doStreamingApiCall("POST", "/api/v2/BlockActions/".concat(pageGuid, "/").concat(blockGuid, "/").concat(actionName), undefined, _objectSpread2({ 2643 __context: context 2644 }, data), undefined, cancellationToken); 2645 } 2646 return invokeBlockAction; 2647 } 2648 function provideReloadBlock(callback) { 2649 provide(blockReloadSymbol, callback); 2650 } 2651 function useReloadBlock() { 2652 return inject(blockReloadSymbol, () => {}); 2653 } 2654 function provideConfigurationValuesChanged() { 2655 const callbacks = []; 2656 provide(configurationValuesChangedSymbol, callbacks); 2657 return { 2658 invoke: () => { 2659 for (const c of callbacks) { 2660 c(); 2661 } 2662 }, 2663 reset: () => { 2664 callbacks.splice(0, callbacks.length); 2665 } 2666 }; 2667 } 2668 function onConfigurationValuesChanged(callback) { 2669 const callbacks = inject(configurationValuesChangedSymbol, undefined); 2670 if (callbacks !== undefined) { 2671 callbacks.push(callback); 2672 } 2673 } 2674 function provideStaticContent(content) { 2675 provide(staticContentSymbol, content); 2676 } 2677 function useStaticContent() { 2678 const content = inject(staticContentSymbol); 2679 if (!content) { 2680 return []; 2681 } 2682 return content.value; 2683 } 2684 function useBlockBrowserBus() { 2685 const blockTypeGuid = useBlockTypeGuid(); 2686 const blockGuid = useBlockGuid(); 2687 return useBrowserBus({ 2688 blockType: blockTypeGuid, 2689 block: blockGuid 2690 }); 2691 } 2692 function setCustomSettingsBoxValue(box, propertyName, value) { 2693 if (!box.settings) { 2694 box.settings = {}; 2695 } 2696 box.settings[propertyName] = value; 2697 if (!box.validProperties) { 2698 box.validProperties = []; 2699 } 2700 if (!box.validProperties.includes(propertyName)) { 2701 box.validProperties.push(propertyName); 2702 } 2703 } 2704 function setPropertiesBoxValue(box, propertyName, value) { 2705 if (!box.bag) { 2706 box.bag = {}; 2707 } 2708 box.bag[propertyName] = value; 2709 if (!box.validProperties) { 2710 box.validProperties = []; 2711 } 2712 if (!box.validProperties.some(p => p.toLowerCase() === propertyName.toLowerCase())) { 2713 box.validProperties.push(propertyName); 2714 } 2715 } 2716 function dispatchBlockEvent(eventName, blockGuid, eventData) { 2717 const ev = new CustomEvent(eventName, { 2718 cancelable: true, 2719 detail: { 2720 guid: blockGuid, 2721 data: eventData 2722 } 2723 }); 2724 return document.dispatchEvent(ev); 2725 } 2726 function isBlockEvent(event) { 2727 return event instanceof CustomEvent && typeof event.detail === "object" && "guid" in event.detail && "data" in event.detail; 2728 } 2729 const entityTypeNameSymbol = Symbol("EntityTypeName"); 2730 const entityTypeGuidSymbol = Symbol("EntityTypeGuid"); 2731 function useEntityDetailBlock(options) { 2732 const securityGrant = getSecurityGrant(options.blockConfig.securityGrantToken); 2733 provideSecurityGrant(securityGrant); 2734 if (options.blockConfig.entityTypeName) { 2735 provideEntityTypeName(options.blockConfig.entityTypeName); 2736 } 2737 if (options.blockConfig.entityTypeGuid) { 2738 provideEntityTypeGuid(options.blockConfig.entityTypeGuid); 2739 } 2740 const entity = options.entity; 2741 const result = {}; 2742 if (entity) { 2743 const invokeBlockAction = useInvokeBlockAction(); 2744 const refreshAttributesDebounce = debounce(() => refreshEntityDetailAttributes(entity, invokeBlockAction), undefined, true); 2745 result.onPropertyChanged = propertyName => { 2746 if (!options.blockConfig.qualifiedAttributeProperties || !options.blockConfig.qualifiedAttributeProperties.some(n => n.toLowerCase() === propertyName.toLowerCase())) { 2747 return; 2748 } 2749 refreshAttributesDebounce(); 2750 }; 2751 } 2752 return result; 2753 } 2754 function provideEntityTypeName(name) { 2755 provide(entityTypeNameSymbol, name); 2756 } 2757 function useEntityTypeName() { 2758 return inject(entityTypeNameSymbol, undefined); 2759 } 2760 function provideEntityTypeGuid(guid) { 2761 provide(entityTypeGuidSymbol, guid); 2762 } 2763 function useEntityTypeGuid() { 2764 return inject(entityTypeGuidSymbol, undefined); 2765 } 2766 const securityGrantSymbol = Symbol(); 2767 function getSecurityGrant(token, renewTokenCallback) { 2768 const tokenRef = ref(token || null); 2769 const invokeBlockAction = !renewTokenCallback ? useInvokeBlockAction() : null; 2770 let renewalTimeout = null; 2771 const renewToken = async () => { 2772 if (renewTokenCallback) { 2773 tokenRef.value = await renewTokenCallback(); 2774 scheduleRenewal(); 2775 } else if (invokeBlockAction) { 2776 const result = await invokeBlockAction("RenewSecurityGrantToken"); 2777 if (result.isSuccess && result.data) { 2778 tokenRef.value = result.data; 2779 scheduleRenewal(); 2780 } 2781 } 2782 }; 2783 const scheduleRenewal = () => { 2784 var _tokenRef$value; 2785 if (renewalTimeout !== null) { 2786 clearTimeout(renewalTimeout); 2787 renewalTimeout = null; 2788 } 2789 if (tokenRef.value === null) { 2790 return; 2791 } 2792 const segments = (_tokenRef$value = tokenRef.value) === null || _tokenRef$value === void 0 ? void 0 : _tokenRef$value.split(";"); 2793 if (segments.length !== 3 || segments[0] !== "1") { 2794 return; 2795 } 2796 const expiresDateTime = RockDateTime.parseISO(segments[1]); 2797 if (expiresDateTime === null) { 2798 return; 2799 } 2800 const renewTimeout = expiresDateTime.addMinutes(-15).toMilliseconds() - RockDateTime.now().toMilliseconds(); 2801 if (renewTimeout < 0) { 2802 return; 2803 } 2804 renewalTimeout = setTimeout(renewToken, renewTimeout); 2805 }; 2806 scheduleRenewal(); 2807 return { 2808 token: tokenRef, 2809 updateToken(newToken) { 2810 tokenRef.value = newToken || null; 2811 scheduleRenewal(); 2812 } 2813 }; 2814 } 2815 function provideSecurityGrant(grant) { 2816 provide(securityGrantSymbol, grant); 2817 } 2818 function useSecurityGrantToken() { 2819 const grant = inject(securityGrantSymbol, undefined); 2820 return grant ? grant.token : ref(null); 2821 } 2822 function watchPropertyChanges(propertyRefs, emit) { 2823 for (const propRef of propertyRefs) { 2824 watch(propRef, () => { 2825 if (propRef.context.propertyName) { 2826 emit("propertyChanged", propRef.context.propertyName); 2827 } 2828 }); 2829 } 2830 } 2831 async function refreshEntityDetailAttributes(box, invokeBlockAction) { 2832 const result = await invokeBlockAction("RefreshAttributes", { 2833 box: box.value 2834 }); 2835 if (result.isSuccess) { 2836 if (result.statusCode === 200 && result.data && box.value) { 2837 var _result$data$bag, _result$data$bag2;
2838 const newBox = _objectSpread2(_objectSpread2({}, box.value), {}, { 2839 bag: _objectSpread2(_objectSpread2({}, box.value.bag), {}, { 2840 attributes: (_result$data$bag = result.data.bag) === null || _result$data$bag === void 0 ? void 0 : _result$data$bag.attributes, 2841 attributeValues: (_result$data$bag2 = result.data.bag) === null || _result$data$bag2 === void 0 ? void 0 : _result$data$bag2.attributeValues 2842 }) 2843 }); 2844 box.value = newBox; 2845 } 2846 } 2847 } 2848 async function refreshDetailAttributes(bag, validProperties, invokeBlockAction) { 2849 const data = { 2850 entity: bag.value, 2851 isEditable: true, 2852 validProperties: validProperties 2853 }; 2854 const result = await invokeBlockAction("RefreshAttributes", { 2855 box: data 2856 }); 2857 if (result.isSuccess) { 2858 if (result.statusCode === 200 && result.data && bag.value) { 2859 var _result$data$entity, _result$data$entity2; 2860 const newBag = _objectSpread2(_objectSpread2({}, bag.value), {}, { 2861 attributes: (_result$data$entity = result.data.entity) === null || _result$data$entity === void 0 ? void 0 : _result$data$entity.attributes, 2862 attributeValues: (_result$data$entity2 = result.data.entity) === null || _result$data$entity2 === void 0 ? void 0 : _result$data$entity2.attributeValues 2863 }); 2864 bag.value = newBag; 2865 } 2866 } 2867 } 2868 const blockGuidSymbol = Symbol("block-guid"); 2869 const blockTypeGuidSymbol = Symbol("block-type-guid"); 2870 function provideBlockGuid(blockGuid) { 2871 provide(blockGuidSymbol, blockGuid); 2872 } 2873 function useBlockGuid() { 2874 return inject(blockGuidSymbol); 2875 } 2876 function provideBlockTypeGuid(blockTypeGuid) { 2877 provide(blockTypeGuidSymbol, blockTypeGuid); 2878 } 2879 function useBlockTypeGuid() { 2880 return inject(blockTypeGuidSymbol); 2881 } 2882 const blockPreferenceProviderSymbol = Symbol(); 2883 const emptyPreferences = { 2884 getValue() { 2885 return ""; 2886 }, 2887 setValue() {}, 2888 getKeys() { 2889 return []; 2890 }, 2891 containsKey() { 2892 return false; 2893 }, 2894 save() { 2895 return Promise.resolve(); 2896 }, 2897 withPrefix() { 2898 return emptyPreferences; 2899 }, 2900 on() {}, 2901 off() {} 2902 }; 2903 const emptyPreferenceProvider = { 2904 blockPreferences: emptyPreferences, 2905 getGlobalPreferences() { 2906 return Promise.resolve(emptyPreferences); 2907 }, 2908 getEntityPreferences() { 2909 return Promise.resolve(emptyPreferences); 2910 } 2911 }; 2912 function providePersonPreferences(provider) { 2913 provide(blockPreferenceProviderSymbol, provider); 2914 } 2915 function usePersonPreferences() { 2916 var _inject; 2917 return (_inject = inject(blockPreferenceProviderSymbol)) !== null && _inject !== void 0 ? _inject : emptyPreferenceProvider; 2918 } 2919 const registeredBlocks = []; 2920 const hiddenBlockRoles = new Set(); 2921 function registerBlock(actions, role) { 2922 const block = { 2923 actions, 2924 role, 2925 hideCount: 0 2926 }; 2927 if (hiddenBlockRoles.has(role)) { 2928 block.hideCount = 1; 2929 if (block.actions.hideBlock) { 2930 block.actions.hideBlock(); 2931 } 2932 } 2933 registeredBlocks.push(block); 2934 } 2935 function unregisterBlock(actions, role) { 2936 const index = registeredBlocks.findIndex(entry => entry.actions === actions && entry.role === role); 2937 if (index !== -1) { 2938 registeredBlocks.splice(index, 1); 2939 } 2940 } 2941 function provideBlockActions(actions) { 2942 provide(blockRoleActionsSymbol, actions); 2943 } 2944 function useBlockActions() { 2945 var _inject2; 2946 return (_inject2 = inject(blockRoleActionsSymbol)) !== null && _inject2 !== void 0 ? _inject2 : {}; 2947 } 2948 async function hideBlockRole(role) { 2949 var _BlockRoleDescription; 2950 const roleName = (_BlockRoleDescription = BlockRoleDescription[role]) === null || _BlockRoleDescription === void 0 ? void 0 : _BlockRoleDescription.toLowerCase(); 2951 if (roleName) { 2952 window.document.body.classList.add("hide-block-role-".concat(roleName)); 2953 } 2954 const promises = []; 2955 for (const entry of registeredBlocks) { 2956 if (entry.role === role) { 2957 entry.hideCount++; 2958 if (entry.hideCount === 1 && entry.actions.hideBlock) { 2959 promises.push(entry.actions.hideBlock()); 2960 } 2961 } 2962 } 2963 hiddenBlockRoles.add(role); 2964 await Promise.all(promises); 2965 } 2966 async function showBlockRole(role) { 2967 var _BlockRoleDescription2; 2968 const roleName = (_BlockRoleDescription2 = BlockRoleDescription[role]) === null || _BlockRoleDescription2 === void 0 ? void 0 : _BlockRoleDescription2.toLowerCase(); 2969 if (roleName) { 2970 window.document.body.classList.remove("hide-block-role-".concat(roleName)); 2971 } 2972 const promises = []; 2973 for (const entry of registeredBlocks) { 2974 if (entry.role === role) { 2975 if (entry.hideCount > 0) { 2976 entry.hideCount--; 2977 } 2978 if (entry.hideCount === 0 && entry.actions.showBlock) { 2979 promises.push(entry.actions.showBlock()); 2980 } 2981 } 2982 } 2983 hiddenBlockRoles.delete(role); 2984 await Promise.all(promises); 2985 } 2986 async function reloadBlockRole(role) { 2987 const promises = []; 2988 for (const entry of registeredBlocks) { 2989 if (entry.role === role && entry.actions.reloadBlock) { 2990 promises.push(entry.actions.reloadBlock()); 2991 } 2992 } 2993 await Promise.all(promises); 2994 } 2995 2996 var block = /*#__PURE__*/Object.freeze({ 2997 __proto__: null, 2998 createInvokeBlockAction: createInvokeBlockAction, 2999 createInvokeStreamingBlockAction: createInvokeStreamingBlockAction, 3000 dispatchBlockEvent: dispatchBlockEvent, 3001 getSecurityGrant: getSecurityGrant, 3002 hideBlockRole: hideBlockRole, 3003 isBlockEvent: isBlockEvent, 3004 onConfigurationValuesChanged: onConfigurationValuesChanged, 3005 provideBlockActions: provideBlockActions, 3006 provideBlockGuid: provideBlockGuid, 3007 provideBlockTypeGuid: provideBlockTypeGuid, 3008 provideConfigurationValuesChanged: provideConfigurationValuesChanged, 3009 provideEntityTypeGuid: provideEntityTypeGuid, 3010 provideEntityTypeName: provideEntityTypeName, 3011 providePersonPreferences: providePersonPreferences, 3012 provideReloadBlock: provideReloadBlock, 3013 provideSecurityGrant: provideSecurityGrant, 3014 provideStaticContent: provideStaticContent, 3015 refreshDetailAttributes: refreshDetailAttributes, 3016 registerBlock: registerBlock, 3017 reloadBlockRole: reloadBlockRole, 3018 setCustomSettingsBoxValue: setCustomSettingsBoxValue, 3019 setPropertiesBoxValue: setPropertiesBoxValue, 3020 showBlockRole: showBlockRole, 3021 unregisterBlock: unregisterBlock, 3022 useBlockActionUrl: useBlockActionUrl, 3023 useBlockActions: useBlockActions, 3024 useBlockBrowserBus: useBlockBrowserBus, 3025 useBlockGuid: useBlockGuid, 3026 useBlockTypeGuid: useBlockTypeGuid, 3027 useConfigurationValues: useConfigurationValues, 3028 useEntityDetailBlock: useEntityDetailBlock, 3029 useEntityTypeGuid: useEntityTypeGuid, 3030 useEntityTypeName: useEntityTypeName, 3031 useInvokeBlockAction: useInvokeBlockAction, 3032 useInvokeStreamingBlockAction: useInvokeStreamingBlockAction, 3033 usePersonPreferences: usePersonPreferences, 3034 useReloadBlock: useReloadBlock, 3035 useSecurityGrantToken: useSecurityGrantToken, 3036 useStaticContent: useStaticContent,
3037 watchPropertyChanges: watchPropertyChanges 3038 }); 3039 exports('block', block); 3040 3041 function asBooleanOrNull(val) { 3042 if (val === undefined || val === null) { 3043 return null; 3044 } 3045 if (typeof val === "boolean") { 3046 return val; 3047 } 3048 if (typeof val === "string") { 3049 const asString = (val || "").trim().toLowerCase(); 3050 if (!asString) { 3051 return null; 3052 } 3053 return ["true", "yes", "t", "y", "1"].indexOf(asString) !== -1; 3054 } 3055 if (typeof val === "number") { 3056 return !!val; 3057 } 3058 return null; 3059 } 3060 function asBoolean(val) { 3061 return !!asBooleanOrNull(val); 3062 } 3063 function asYesNoOrNull(val) { 3064 const boolOrNull = asBooleanOrNull(val); 3065 if (boolOrNull === null) { 3066 return null; 3067 } 3068 return boolOrNull ? "Yes" : "No"; 3069 } 3070 function asTrueFalseOrNull(val) { 3071 const boolOrNull = asBooleanOrNull(val); 3072 if (boolOrNull === null) { 3073 return null; 3074 } 3075 return boolOrNull ? "True" : "False"; 3076 } 3077 function asTrueOrFalseString(val) { 3078 const boolOrNull = asBooleanOrNull(val); 3079 return boolOrNull ? "True" : "False"; 3080 } 3081 3082 var booleanUtils = /*#__PURE__*/Object.freeze({ 3083 __proto__: null, 3084 asBoolean: asBoolean, 3085 asBooleanOrNull: asBooleanOrNull, 3086 asTrueFalseOrNull: asTrueFalseOrNull, 3087 asTrueOrFalseString: asTrueOrFalseString, 3088 asYesNoOrNull: asYesNoOrNull 3089 }); 3090 exports('booleanUtils', booleanUtils); 3091 3092 const breakpointDisplays = { 3093 "xs": "none", 3094 "sm": "inline", 3095 "md": "inline-block", 3096 "lg": "block", 3097 "xl": "table" 3098 }; 3099 const displayBreakpoints = { 3100 "none": "xs", 3101 "inline": "sm", 3102 "inline-block": "md", 3103 "block": "lg", 3104 "table": "xl" 3105 }; 3106 let probeElement; 3107 const currentHelper = ref(createBreakpointHelper("unknown")); 3108 function createBreakpointHelper(breakpoint) { 3109 const partial = { 3110 breakpoint, 3111 isXs: breakpoint === "xs", 3112 isSm: breakpoint === "sm", 3113 isMd: breakpoint === "md", 3114 isLg: breakpoint === "lg", 3115 isXl: breakpoint === "xl", 3116 isXsOrSmaller: breakpoint === "xs", 3117 isSmOrSmaller: ["xs", "sm"].includes(breakpoint), 3118 isMdOrSmaller: ["xs", "sm", "md"].includes(breakpoint), 3119 isLgOrSmaller: ["xs", "sm", "md", "lg"].includes(breakpoint), 3120 isXlOrSmaller: true, 3121 isXsOrLarger: true, 3122 isSmOrLarger: ["sm", "md", "lg", "xl"].includes(breakpoint), 3123 isMdOrLarger: ["md", "lg", "xl"].includes(breakpoint), 3124 isLgOrLarger: ["lg", "xl"].includes(breakpoint), 3125 isXlOrLarger: breakpoint === "xl" 3126 }; 3127 const active = ["xs", "sm", "md", "lg", "xl"].filter(bp => partial["is".concat(bp.charAt(0).toUpperCase()).concat(bp.slice(1), "OrLarger")] === true); 3128 return _objectSpread2(_objectSpread2({}, partial), {}, { 3129 breakpoints: active.join(" ") 3130 }); 3131 } 3132 function readBreakpoint() { 3133 var _displayBreakpoints$d; 3134 if (!probeElement) { 3135 return; 3136 } 3137 const display = getComputedStyle(probeElement).display; 3138 const next = (_displayBreakpoints$d = displayBreakpoints[display]) !== null && _displayBreakpoints$d !== void 0 ? _displayBreakpoints$d : "unknown"; 3139 if (next !== currentHelper.value.breakpoint) { 3140 currentHelper.value = createBreakpointHelper(next); 3141 } 3142 } 3143 function ensureProbe() { 3144 if (probeElement || typeof document === "undefined") { 3145 return; 3146 } 3147 const element = document.createElement("div"); 3148 element.className = Object.keys(breakpointDisplays).map(bp => bp === "xs" ? "d-".concat(breakpointDisplays[bp]) : "d-".concat(bp, "-").concat(breakpointDisplays[bp])).join(" "); 3149 element.style.setProperty("position", "absolute"); 3150 element.style.setProperty("visibility", "collapse", "important"); 3151 document.body.appendChild(element); 3152 probeElement = element; 3153 readBreakpoint(); 3154 window.addEventListener("resize", readBreakpoint, { 3155 passive: true 3156 }); 3157 } 3158 const readonlyHelper = computed(() => currentHelper.value);
3159 function useBreakpointHelper() { 3160 ensureProbe(); 3161 return readonlyHelper; 3162 } 3163 3164 var breakpointHelper = /*#__PURE__*/Object.freeze({ 3165 __proto__: null, 3166 useBreakpointHelper: useBreakpointHelper 3167 }); 3168 exports('breakpointHelper', breakpointHelper); 3169 3170 const keyPrefix = "ObsidianCache_"; 3171 function set(key, value) { 3172 let ttl = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 60; 3173 if (typeof ttl !== "number") { 3174 ttl = 60; 3175 console.warn("Cache.set has been changed to use a Time-To-Live instead of an expiration date/time. Please update your code to use a Time-To-Live."); 3176 } 3177 const expiration = RockDateTime.now().addSeconds(ttl).toMilliseconds(); 3178 const cache = { 3179 expiration, 3180 value 3181 }; 3182 const cacheJson = JSON.stringify(cache); 3183 sessionStorage.setItem(keyPrefix + key, cacheJson); 3184 } 3185 function get(key) { 3186 const cacheJson = sessionStorage.getItem(keyPrefix + key); 3187 if (!cacheJson) { 3188 return null; 3189 } 3190 const cache = JSON.parse(cacheJson); 3191 if (!cache || !cache.expiration) { 3192 return null; 3193 } 3194 if (cache.expiration < RockDateTime.now().toMilliseconds()) { 3195 return null; 3196 } 3197 return cache.value; 3198 } 3199 const promiseCache = {}; 3200 function cachePromiseFactory(key, fn, ttl) { 3201 return async function () { 3202 var _promiseCache$key; 3203 if (typeof ttl !== "number" || ttl !== undefined) { 3204 console.warn("Cache.cachePromiseFactory has been changed to use a Time-To-Live instead of an expiration date/time. Please update your code to use a Time-To-Live."); 3205 } 3206 const cachedResult = get(key); 3207 if (cachedResult) { 3208 return cachedResult; 3209 } 3210 if (promiseCache[key]) { 3211 return promiseCache[key]; 3212 } 3213 promiseCache[key] = fn(); 3214 (_promiseCache$key = promiseCache[key]) === null || _promiseCache$key === void 0 || _promiseCache$key.then(result => { 3215 set(key, result, ttl); 3216 delete promiseCache[key]; 3217 return result; 3218 }).catch(e => { 3219 delete promiseCache[key]; 3220 throw e; 3221 }); 3222 return promiseCache[key]; 3223 }; 3224 } 3225 var Cache = { 3226 set, 3227 get, 3228 cachePromiseFactory 3229 }; 3230 3231 var cache = /*#__PURE__*/Object.freeze({ 3232 __proto__: null, 3233 default: Cache 3234 }); 3235 exports('cache', cache); 3236 3237 function getCssValue(variableName) { 3238 return getComputedStyle(document.documentElement).getPropertyValue(variableName).trim(); 3239 } 3240 const BarDatasetLabelsPlugin = { 3241 id: "barDatasetLabels", 3242 afterDatasetDraw(chart, _ref) { 3243 let { 3244 index: datasetIndex, 3245 meta: _meta 3246 } = _ref; 3247 const { 3248 ctx, 3249 data 3250 } = chart; 3251 ctx.save(); 3252 chart.getDatasetMeta(datasetIndex).data.forEach((datapoint, _datapointIndex) => { 3253 ctx.font = "normal 14px sans-serif"; 3254 ctx.fillStyle = getCssValue("--color-interface-medium"); 3255 ctx.textAlign = "center"; 3256 const label = "".concat(data.datasets[datasetIndex].label); 3257 ctx.fillText(label, datapoint.x, datapoint.y - 7); 3258 }); 3259 } 3260 }; 3261 const contrastColors = {}; 3262 const BarValueLabelsPlugin = { 3263 id: "barValueLabels", 3264 afterDatasetDraw(chart, _ref2, options) { 3265 let { 3266 index: datasetIndex, 3267 meta 3268 } = _ref2; 3269 const { 3270 ctx, 3271 data 3272 } = chart; 3273 ctx.save(); 3274 meta.data.forEach((dataElement, dataIndex) => { 3275 var _data$datasets$datase, _data$datasets$datase2; 3276 if (dataElement instanceof BarElement === false) { 3277 console.warn("BarValueLabelsPlugin can only be used with BarElement data elements.", dataElement); 3278 return; 3279 } 3280 const barProps = ["base"]; 3281 const { 3282 base 3283 } = dataElement.getProps(barProps); 3284 const fontSize = 12; 3285 const minimumSpaceBetweenTextAndBorder = 4; 3286 const desiredSpaceBetweenTextAndBar = 8; 3287 ctx.font = "normal ".concat(fontSize, "px sans-serif"); 3288 ctx.textAlign = "center"; 3289 const barColor = ((_data$datasets$datase = data.datasets[datasetIndex].backgroundColor) === null || _data$datasets$datase === void 0 ? void 0 : _data$datasets$datase[dataIndex]) || ((_data$datasets$datase2 = data.datasets[datasetIndex].borderColor) === null || _data$datasets$datase2 === void 0 ? void 0 : _data$datasets$datase2[dataIndex]) || ""; 3290 if (typeof barColor !== "string") { 3291 console.warn("Bar color must be a string to determine contrast color to use the BarValueLabelsPlugin.", barColor); 3292 return; 3293 } 3294 if (!contrastColors[barColor]) {
3295 var _options$isBackground; 3296 if (options !== null && options !== void 0 && (_options$isBackground = options.isBackgroundDark) !== null && _options$isBackground !== void 0 && _options$isBackground.call(options, barColor)) { 3297 contrastColors[barColor] = "white"; 3298 } else { 3299 contrastColors[barColor] = "black"; 3300 } 3301 } 3302 ctx.fillStyle = contrastColors[barColor] || getCssValue("--color-interface-contrast"); 3303 const value = "".concat(data.datasets[datasetIndex].data[dataIndex]); 3304 const formatted = options !== null && options !== void 0 && options.formatter ? options.formatter(value) : value; 3305 let textOffset = fontSize / 2 + minimumSpaceBetweenTextAndBorder; 3306 if (base - dataElement.y > fontSize / 2 + desiredSpaceBetweenTextAndBar + minimumSpaceBetweenTextAndBorder) { 3307 textOffset = fontSize / 2 + desiredSpaceBetweenTextAndBar; 3308 } 3309 ctx.fillText(formatted, dataElement.x, dataElement.y + textOffset); 3310 }); 3311 } 3312 }; 3313 class BarChartDataBuilder { 3314 constructor(dataPoints) { 3315 this.dataPoints = dataPoints; 3316 } 3317 static createFromDataPoints(dataPoints) { 3318 return new BarChartDataBuilder(dataPoints); 3319 } 3320 withSeriesOrder(orderBy) { 3321 if (Array.isArray(orderBy)) { 3322 const orderMap = new Map(orderBy.map((value, index) => [value, index])); 3323 this.seriesNameOrderBy = (a, b) => { 3324 const indexA = orderMap.has(a) ? orderMap.get(a) : Number.MAX_SAFE_INTEGER; 3325 const indexB = orderMap.has(b) ? orderMap.get(b) : Number.MAX_SAFE_INTEGER; 3326 if (indexA < indexB) { 3327 return -1; 3328 } 3329 if (indexA > indexB) { 3330 return 1; 3331 } 3332 return 0; 3333 }; 3334 } else { 3335 this.seriesNameOrderBy = orderBy; 3336 } 3337 return this; 3338 } 3339 build() { 3340 const dataPointsEnumerable = Enumerable.from(this.dataPoints); 3341 const labels = dataPointsEnumerable.select(d => d.label).ofType(d => !isNullish(d)).distinct().toArray(); 3342 let groupedBySeries = dataPointsEnumerable.where(d => !isNullish(d.seriesName)).groupBy(d => d.seriesName).ofType(group => { 3343 return !isNullish(group.key); 3344 }); 3345 if (this.seriesNameOrderBy) { 3346 groupedBySeries = groupedBySeries.orderBy(group => group.key, this.seriesNameOrderBy); 3347 } 3348 return { 3349 labels, 3350 datasets: groupedBySeries.select(group => { 3351 const seriesDataColors = group.select(d => { 3352 var _d$color; 3353 return (_d$color = d.color) !== null && _d$color !== void 0 ? _d$color : undefined; 3354 }).toArray(); 3355 return { 3356 label: group.key, 3357 data: group.select(d => d.value).toArray(), 3358 backgroundColor: seriesDataColors, 3359 borderColor: seriesDataColors, 3360 grouped: true 3361 }; 3362 }).toArray() 3363 }; 3364 } 3365 } 3366 class BarChartOptionsBuilder { 3367 constructor(options) { 3368 this.options = options; 3369 } 3370 static create() { 3371 return new BarChartOptionsBuilder({}); 3372 } 3373 build() { 3374 return _objectSpread2({}, this.options); 3375 } 3376 withXAxisAsDate() { 3377 let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : { 3378 timeUnit: "day" 3379 }; 3380 return new BarChartOptionsBuilder(_objectSpread2(_objectSpread2({}, this.options), {}, { 3381 scales: _objectSpread2(_objectSpread2({}, this.options.scales), {}, { 3382 x: { 3383 type: "time", 3384 time: { 3385 unit: options.timeUnit 3386 } 3387 } 3388 }) 3389 })); 3390 } 3391 withYAxisAsPercent() { 3392 var _this$options$scales, _this$options$scales2, _this$options$plugins, _this$options$plugins2, _this$options$plugins3; 3393 let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : { 3394 maxDecimalPlaces: undefined 3395 };
3396 return new BarChartOptionsBuilder(_objectSpread2(_objectSpread2({}, this.options), {}, { 3397 scales: _objectSpread2(_objectSpread2({}, this.options.scales), {}, { 3398 y: _objectSpread2(_objectSpread2({}, (_this$options$scales = this.options.scales) === null || _this$options$scales === void 0 ? void 0 : _this$options$scales.y), {}, { 3399 ticks: _objectSpread2(_objectSpread2({}, (_this$options$scales2 = this.options.scales) === null || _this$options$scales2 === void 0 || (_this$options$scales2 = _this$options$scales2.y) === null || _this$options$scales2 === void 0 ? void 0 : _this$options$scales2.ticks), {}, { 3400 callback(tickValue, _index, _ticks) { 3401 if (typeof tickValue !== "number") { 3402 tickValue = Number(tickValue); 3403 } 3404 if (isNaN(tickValue)) { 3405 return "".concat(tickValue); 3406 } 3407 return tickValue.toLocaleString(undefined, { 3408 style: "percent", 3409 maximumFractionDigits: options.maxDecimalPlaces 3410 }); 3411 } 3412 }) 3413 }) 3414 }), 3415 plugins: _objectSpread2(_objectSpread2({}, this.options.plugins), {}, { 3416 tooltip: _objectSpread2(_objectSpread2({}, (_this$options$plugins = this.options.plugins) === null || _this$options$plugins === void 0 ? void 0 : _this$options$plugins.tooltip), {}, { 3417 callbacks: _objectSpread2(_objectSpread2({}, (_this$options$plugins2 = this.options.plugins) === null || _this$options$plugins2 === void 0 || (_this$options$plugins2 = _this$options$plugins2.tooltip) === null || _this$options$plugins2 === void 0 ? void 0 : _this$options$plugins2.callbacks), {}, { 3418 label: function (context) { 3419 let label = context.dataset.label || ""; 3420 if (label) { 3421 label += ": "; 3422 } 3423 if (context.parsed.y !== null) { 3424 label += context.parsed.y.toLocaleString(undefined, { 3425 style: "percent", 3426 maximumFractionDigits: options.maxDecimalPlaces 3427 }); 3428 } 3429 return label; 3430 } 3431 }) 3432 }), 3433 barValueLabels: _objectSpread2(_objectSpread2({}, (_this$options$plugins3 = this.options.plugins) === null || _this$options$plugins3 === void 0 ? void 0 : _this$options$plugins3.barValueLabels), {}, { 3434 formatter: value => { 3435 const num = Number(value); 3436 if (isNaN(num)) { 3437 return value; 3438 } else { 3439 return num.toLocaleString(undefined, { 3440 style: "percent", 3441 maximumFractionDigits: options.maxDecimalPlaces 3442 }); 3443 } 3444 } 3445 }) 3446 }) 3447 })); 3448 } 3449 withoutLegend() { 3450 return new BarChartOptionsBuilder(_objectSpread2(_objectSpread2({}, this.options), {}, { 3451 plugins: _objectSpread2(_objectSpread2({}, this.options.plugins), {}, { 3452 legend: { 3453 display: false 3454 } 3455 }) 3456 })); 3457 } 3458 withResponsiveSizing() { 3459 return new BarChartOptionsBuilder(_objectSpread2(_objectSpread2({}, this.options), {}, { 3460 responsive: true, 3461 maintainAspectRatio: false 3462 })); 3463 } 3464 withoutTooltips() { 3465 return new BarChartOptionsBuilder(_objectSpread2(_objectSpread2({}, this.options), {}, { 3466 plugins: _objectSpread2(_objectSpread2({}, this.options.plugins), {}, { 3467 tooltip: { 3468 enabled: false 3469 } 3470 }) 3471 })); 3472 } 3473 withBarValueLabels(options) { 3474 var _this$options$plugins4; 3475 return new BarChartOptionsBuilder(_objectSpread2(_objectSpread2
3475({}, this.options), {}, { 3476 plugins: _objectSpread2(_objectSpread2({}, this.options.plugins), {}, { 3477 barValueLabels: _objectSpread2(_objectSpread2({}, (_this$options$plugins4 = this.options.plugins) === null || _this$options$plugins4 === void 0 ? void 0 : _this$options$plugins4.barValueLabels), options) 3478 }) 3479 })); 3480 } 3481 } 3482 class LineChartDataBuilder { 3483 constructor(dataPoints) { 3484 this.dataPoints = dataPoints; 3485 } 3486 static createFromData(dataPoints) { 3487 return new LineChartDataBuilder(dataPoints); 3488 } 3489 withSeriesOrder(orderBy) { 3490 if (Array.isArray(orderBy)) { 3491 const orderMap = new Map(orderBy.map((value, index) => [value, index])); 3492 this.seriesNameOrderBy = (a, b) => { 3493 const indexA = orderMap.has(a) ? orderMap.get(a) : Number.MAX_SAFE_INTEGER; 3494 const indexB = orderMap.has(b) ? orderMap.get(b) : Number.MAX_SAFE_INTEGER; 3495 if (indexA < indexB) { 3496 return -1; 3497 } 3498 if (indexA > indexB) { 3499 return 1; 3500 } 3501 return 0; 3502 }; 3503 } else { 3504 this.seriesNameOrderBy = orderBy; 3505 } 3506 return this; 3507 } 3508 build() { 3509 const dataPointsEnumerable = Enumerable.from(this.dataPoints); 3510 const labels = dataPointsEnumerable.select(d => d.label).ofType(d => !isNullish(d)).distinct().toArray(); 3511 let groupedBySeries = dataPointsEnumerable.groupBy(d => d.seriesName).ofType(group => { 3512 return !isNullish(group.key); 3513 }); 3514 if (this.seriesNameOrderBy) { 3515 groupedBySeries = groupedBySeries.orderBy(group => group.key, this.seriesNameOrderBy); 3516 } 3517 return { 3518 labels, 3519 datasets: groupedBySeries.select(group => { 3520 const groupArray = group.toArray(); 3521 const seriesDataColors = Enumerable.from(groupArray).select(d => { 3522 var _d$color2; 3523 return (_d$color2 = d.color) !== null && _d$color2 !== void 0 ? _d$color2 : undefined; 3524 }).toArray(); 3525 const dataDictionary = Enumerable.from(groupArray).toDictionary(d => d.label, d => d.value); 3526 let lastValue = 0; 3527 const data = Enumerable.from(labels).select(label => { 3528 if (dataDictionary.has(label)) { 3529 lastValue = dataDictionary.get(label); 3530 } 3531 return lastValue; 3532 }).toArray(); 3533 return { 3534 label: group.key, 3535 data, 3536 backgroundColor: seriesDataColors, 3537 borderColor: seriesDataColors 3538 }; 3539 }).toArray() 3540 }; 3541 } 3542 } 3543 class LineChartOptionsBuilder { 3544 constructor(options) { 3545 this.options = options; 3546 } 3547 static create() { 3548 return new LineChartOptionsBuilder({ 3549 scales: { 3550 y: { 3551 min: 0 3552 } 3553 } 3554 }); 3555 } 3556 static createFrom() { 3557 let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; 3558 return new LineChartOptionsBuilder(options); 3559 } 3560 build() { 3561 return _objectSpread2({}, this.options); 3562 } 3563 withXAxisAsDate() { 3564 let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : { 3565 timeUnit: "day" 3566 }; 3567 return new LineChartOptionsBuilder(_objectSpread2(_objectSpread2({}, this.options), {}, { 3568 scales: _objectSpread2(_objectSpread2({}, this.options.scales), {}, { 3569 x: { 3570 type: "time", 3571 time: { 3572 unit: options.timeUnit 3573 } 3574 } 3575 }) 3576 })); 3577 } 3578 withYAxisAsPercent() { 3579 var _this$options$scales3, _this$options$scales4, _this$options$plugins5, _this$options$plugins6; 3580 let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : { 3581 maxDecimalPlaces: undefined 3582 };
3583 return new LineChartOptionsBuilder(_objectSpread2(_objectSpread2({}, this.options), {}, { 3584 scales: _objectSpread2(_objectSpread2({}, this.options.scales), {}, { 3585 y: _objectSpread2(_objectSpread2({}, (_this$options$scales3 = this.options.scales) === null || _this$options$scales3 === void 0 ? void 0 : _this$options$scales3.y), {}, { 3586 ticks: _objectSpread2(_objectSpread2({}, (_this$options$scales4 = this.options.scales) === null || _this$options$scales4 === void 0 || (_this$options$scales4 = _this$options$scales4.y) === null || _this$options$scales4 === void 0 ? void 0 : _this$options$scales4.ticks), {}, { 3587 callback(tickValue, _index, _ticks) { 3588 if (typeof tickValue !== "number") { 3589 tickValue = Number(tickValue); 3590 } 3591 if (isNaN(tickValue)) { 3592 return "".concat(tickValue); 3593 } else { 3594 return tickValue.toLocaleString(undefined, { 3595 style: "percent", 3596 maximumFractionDigits: options.maxDecimalPlaces 3597 }); 3598 } 3599 } 3600 }) 3601 }) 3602 }), 3603 plugins: _objectSpread2(_objectSpread2({}, this.options.plugins), {}, { 3604 tooltip: _objectSpread2(_objectSpread2({}, (_this$options$plugins5 = this.options.plugins) === null || _this$options$plugins5 === void 0 ? void 0 : _this$options$plugins5.tooltip), {}, { 3605 callbacks: _objectSpread2(_objectSpread2({}, (_this$options$plugins6 = this.options.plugins) === null || _this$options$plugins6 === void 0 || (_this$options$plugins6 = _this$options$plugins6.tooltip) === null || _this$options$plugins6 === void 0 ? void 0 : _this$options$plugins6.callbacks), {}, { 3606 label: function (context) { 3607 let label = context.dataset.label || ""; 3608 if (label) { 3609 label += ": "; 3610 } 3611 if (context.parsed.y !== null) { 3612 label += context.parsed.y.toLocaleString(undefined, { 3613 style: "percent", 3614 maximumFractionDigits: options.maxDecimalPlaces 3615 }); 3616 } 3617 return label; 3618 } 3619 }) 3620 }) 3621 }) 3622 })); 3623 } 3624 withResponsiveSizing() { 3625 return new LineChartOptionsBuilder(_objectSpread2(_objectSpread2({}, this.options), {}, { 3626 responsive: true, 3627 maintainAspectRatio: false 3628 })); 3629 } 3630 } 3631 function buildCumulativeRates(dateEnumerable, options) { 3632 var _options$dateTransfor, _options$dateFormatte; 3633 const dateTransformer = (_options$dateTransfor = options.dateTransformer) !== null && _options$dateTransfor !== void 0 ? _options$dateTransfor : d => d; 3634 const dateFormatter = (_options$dateFormatte = options.dateFormatter) !== null && _options$dateFormatte !== void 0 ? _options$dateFormatte : d => d.toISOString(); 3635 return dateEnumerable.select(dateTransformer).groupBy(date => date.toMilliseconds()).orderBy(group => group.key).scan({ 3636 count: 0, 3637 dataPoint: undefined 3638 }, (state, group) => { 3639 const date = group.first(); 3640 const groupCount = group.count(); 3641 const count = state.count + groupCount; 3642 const dataPoint = { 3643 seriesName: options.seriesName, 3644 color: options.color, 3645 label: dateFormatter(date), 3646 value: count / options.totalCount, 3647 rockDateTime: date 3648 }; 3649 return { 3650 count, 3651 dataPoint 3652 }; 3653 }).select(state => state.dataPoint); 3654 } 3655 3656 var chartUtils = /*#__PURE__*/Object.freeze({ 3657 __proto__: null, 3658 BarChartDataBuilder: BarChartDataBuilder, 3659 BarChartOptionsBuilder: BarChartOptionsBuilder, 3660 BarDatasetLabelsPlugin: BarDatasetLabelsPlugin, 3661 BarValueLabelsPlugin: BarValueLabelsPlugin, 3662 LineChartDataBuilder: LineChartDataBuilder, 3663 LineChartOptionsBuilder: LineChartOptionsBuilder, 3664 buildCumulativeRates: buildCumulativeRates 3665 }); 3666 exports('chartUtils', chartUtils); 3667 3668 const suspenseSymbol = Symbol("RockSuspense"); 3669 class BasicSuspenseProvider { 3670 constructor(parentProvider) { 3671 this.operationKey = newGuid(); 3672 this.parentProvider = parentProvider; 3673 this.pendingOperations = []; 3674 this.finishedHandlers = []; 3675 } 3676 allOperationsComplete() { 3677 nextTick(() => { 3678 if (this.pendingOperations.length !== 0) { 3679 return; 3680 } 3681 for (const handler of this.finishedHandlers) { 3682 handler(); 3683 } 3684 this.finishedHandlers = []; 3685 if (this.parentProvider) { 3686 this.parentProvider.completeAsyncOperation(this.operationKey); 3687 } 3688 }); 3689 } 3690 addOperation(operation) { 3691 const operationKey = newGuid(); 3692 this.startAsyncOperation(operationKey); 3693 operation.then(() => this.completeAsyncOperation(operationKey)).catch(() => this.completeAsyncOperation(operationKey)); 3694 } 3695 startAsyncOperation(key) { 3696 this.pendingOperations.push(key); 3697 if (this.pendingOperations.length === 1 && this.parentProvider) { 3698 this.parentProvider.startAsyncOperation(this.operationKey); 3699 } 3700 } 3701 completeAsyncOperation(key) { 3702 const index = this.pendingOperations.indexOf(key); 3703 if (index !== -1) { 3704 this.pendingOperations.splice(index, 1); 3705 } 3706 if (this.pendingOperations.length === 0) { 3707 this.allOperationsComplete(); 3708 } 3709 } 3710 hasPendingOperations() { 3711 return this.pendingOperations.length > 0; 3712 }
3713 addFinishedHandler(callback) { 3714 this.finishedHandlers.push(callback); 3715 } 3716 } 3717 function provideSuspense(provider) { 3718 provide(suspenseSymbol, provider); 3719 } 3720 function useSuspense() { 3721 return inject(suspenseSymbol, undefined); 3722 } 3723 3724 var suspense = /*#__PURE__*/Object.freeze({ 3725 __proto__: null, 3726 BasicSuspenseProvider: BasicSuspenseProvider, 3727 provideSuspense: provideSuspense, 3728 useSuspense: useSuspense 3729 }); 3730 exports('suspense', suspense); 3731 3732 function asFormattedString(num, digits) { 3733 let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; 3734 if (num === null) { 3735 return ""; 3736 } 3737 return num.toLocaleString("en-US", _objectSpread2({ 3738 minimumFractionDigits: digits, 3739 maximumFractionDigits: digits !== null && digits !== void 0 ? digits : 9 3740 }, options)); 3741 } 3742 function toNumber(str) { 3743 return toNumberOrNull(str) || 0; 3744 } 3745 function toNumberOrNull(str) { 3746 if (str === null || str === undefined || str === "") { 3747 return null; 3748 } 3749 if (typeof str === "number") { 3750 return str; 3751 } 3752 const replaced = str.replace(/[$,]/g, ""); 3753 const num = Number(replaced); 3754 return !isNaN(num) ? num : null; 3755 } 3756 function toCurrencyOrNull(value) { 3757 var _currencyInfo$symbol, _currencyInfo$decimal; 3758 let currencyInfo = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; 3759 if (typeof value === "string") { 3760 value = toNumberOrNull(value); 3761 } 3762 if (value === null || value === undefined) { 3763 return null; 3764 } 3765 const currencySymbol = (_currencyInfo$symbol = currencyInfo === null || currencyInfo === void 0 ? void 0 : currencyInfo.symbol) !== null && _currencyInfo$symbol !== void 0 ? _currencyInfo$symbol : "$"; 3766 const currencyDecimalPlaces = (_currencyInfo$decimal = currencyInfo === null || currencyInfo === void 0 ? void 0 : currencyInfo.decimalPlaces) !== null && _currencyInfo$decimal !== void 0 ? _currencyInfo$decimal : 2; 3767 return "".concat(currencySymbol).concat(asFormattedString(value, currencyDecimalPlaces)); 3768 } 3769 function toOrdinalSuffix(num) { 3770 if (!num) { 3771 return ""; 3772 } 3773 const j = num % 10; 3774 const k = num % 100; 3775 if (j === 1 && k !== 11) { 3776 return num + "st"; 3777 } 3778 if (j === 2 && k !== 12) { 3779 return num + "nd"; 3780 } 3781 if (j === 3 && k !== 13) { 3782 return num + "rd"; 3783 } 3784 return num + "th"; 3785 } 3786 function toOrdinal(num) { 3787 if (!num) { 3788 return ""; 3789 } 3790 switch (num) { 3791 case 1: 3792 return "first"; 3793 case 2: 3794 return "second"; 3795 case 3: 3796 return "third"; 3797 case 4: 3798 return "fourth"; 3799 case 5: 3800 return "fifth"; 3801 case 6: 3802 return "sixth"; 3803 case 7: 3804 return "seventh"; 3805 case 8: 3806 return "eighth"; 3807 case 9: 3808 return "ninth"; 3809 case 10: 3810 return "tenth"; 3811 default: 3812 return toOrdinalSuffix(num); 3813 } 3814 } 3815 function toWord(num) { 3816 if (num === null || num === undefined) { 3817 return ""; 3818 } 3819 switch (num) { 3820 case 1: 3821 return "one"; 3822 case 2: 3823 return "two"; 3824 case 3: 3825 return "three"; 3826 case 4: 3827 return "four"; 3828 case 5: 3829 return "five"; 3830 case 6: 3831 return "six"; 3832 case 7: 3833 return "seven"; 3834 case 8: 3835 return "eight"; 3836 case 9: 3837 return "nine"; 3838 case 10: 3839 return "ten"; 3840 default: 3841 return "".concat(num); 3842 } 3843 } 3844 function zeroPad(num, length) { 3845 let str = num.toString(); 3846 while (str.length < length) { 3847 str = "0" + str; 3848 } 3849 return str; 3850 } 3851 function toDecimalPlaces(num, decimalPlaces) { 3852 decimalPlaces = Math.floor(decimalPlaces); 3853 return Math.round(num * 10 ** decimalPlaces) / 10 ** decimalPlaces; 3854 } 3855 function toWordFull(numb) { 3856 const numberWords = { 3857 0: "zero", 3858 1: "one", 3859 2: "two", 3860 3: "three", 3861 4: "four", 3862 5: "five", 3863 6: "six", 3864 7: "seven", 3865 8: "eight", 3866 9: "nine", 3867 10: "ten", 3868 11: "eleven", 3869 12: "twelve", 3870 13: "thirteen", 3871 14: "fourteen", 3872 15: "fifteen", 3873 16: "sixteen", 3874 17: "seventeen", 3875 18: "eighteen", 3876 19: "nineteen", 3877 20: "twenty", 3878 30: "thirty", 3879 40: "forty", 3880 50: "fifty", 3881 60: "sixty", 3882 70: "seventy", 3883 80: "eighty", 3884 90: "ninety", 3885 100: "one hundred", 3886 1000: "one thousand", 3887 1000000: "one million", 3888 1000000000: "one billion", 3889 1000000000000: "one trillion", 3890 1000000000000000: "one quadrillion" 3891 }; 3892 const oneHundred = 100; 3893 const oneThousand = 1000; 3894 const oneMillion = 1000000; 3895 const oneBillion = 1000000000; 3896 const oneTrillion = 1000000000000; 3897 const oneQuadrillion = 1000000000000000; 3898 if (numberWords[numb]) { 3899 return numberWords[numb]; 3900 } 3901 function quadrillionsToWord(numb) { 3902 const trillions = trillionsToWord(numb); 3903 if (numb >= oneQuadrillion) { 3904 const quadrillions = hundredsToWord(Number(numb.toString().slice(-18, -15))); 3905 if (trillions) { 3906 return "".concat(quadrillions, " quadrillion ").concat(trillions); 3907 } else { 3908 return "".concat(quadrillions, " quadrillion"); 3909 } 3910 } else { 3911 return trillions; 3912 } 3913 } 3914 function trillionsToWord(numb) { 3915 numb = Number(numb.toString().slice(-15)); 3916 const billions = billionsToWord(numb); 3917 if (numb >= oneTrillion) { 3918 const trillions = hundredsToWord(Number(numb.toString().slice(-15, -12))); 3919 if (billions) { 3920 return "".concat(trillions, " trillion ").concat(billions); 3921 } else { 3922 return "".concat(trillions, " trillion"); 3923 } 3924 } else { 3925 return billions; 3926 } 3927 } 3928 function billionsToWord(numb) { 3929 numb = Number(numb.toString().slice(-12)); 3930 const millions = millionsToWord(numb); 3931 if (numb >= oneBillion) { 3932 const billions = hundredsToWord(Number(numb.toString().slice(-12, -9))); 3933 if (millions) { 3934 return "".concat(billions, " billion ").concat(millions); 3935 } else { 3936 return "".concat(billions, " billion"); 3937 } 3938 } else { 3939 return millions; 3940 } 3941 } 3942 function millionsToWord(numb) { 3943 numb = Number(numb.toString().slice(-9)); 3944 const thousands = thousandsToWord(numb); 3945 if (numb >= oneMillion) { 3946 const millions = hundredsToWord(Number(numb.toString().slice(-9, -6))); 3947 if (thousands) { 3948 return "".concat(millions, " million ").concat(thousands); 3949 } else { 3950 return "".concat(millions, " million"); 3951 } 3952 } else { 3953 return thousands; 3954 } 3955 }
3956 function thousandsToWord(numb) { 3957 numb = Number(numb.toString().slice(-6)); 3958 const hundreds = hundredsToWord(numb); 3959 if (numb >= oneThousand) { 3960 const thousands = hundredsToWord(Number(numb.toString().slice(-6, -3))); 3961 if (hundreds) { 3962 return "".concat(thousands, " thousand ").concat(hundreds); 3963 } else { 3964 return "".concat(thousands, " thousandths"); 3965 } 3966 } else { 3967 return hundreds; 3968 } 3969 } 3970 function hundredsToWord(numb) { 3971 numb = Number(numb.toString().slice(-3)); 3972 if (numberWords[numb]) { 3973 return numberWords[numb]; 3974 } 3975 const tens = tensToWord(numb); 3976 if (numb >= oneHundred) { 3977 const hundreds = Number(numb.toString().slice(-3, -2)); 3978 if (tens) { 3979 return "".concat(numberWords[hundreds], " hundred ").concat(tens); 3980 } else { 3981 return "".concat(numberWords[hundreds], " hundred"); 3982 } 3983 } else { 3984 return tens; 3985 } 3986 } 3987 function tensToWord(numb) { 3988 numb = Number(numb.toString().slice(-2)); 3989 if (numberWords[numb]) { 3990 return numberWords[numb]; 3991 } 3992 const ones = onesToWord(numb); 3993 if (numb >= 20) { 3994 const tens = Number(numb.toString().slice(-2, -1)); 3995 if (ones) { 3996 return "".concat(numberWords[tens * 10], "-").concat(ones); 3997 } else { 3998 return numberWords[tens * 10]; 3999 } 4000 } else { 4001 return ones; 4002 } 4003 } 4004 function onesToWord(numb) { 4005 numb = Number(numb.toString().slice(-1)); 4006 return numberWords[numb]; 4007 } 4008 return quadrillionsToWord(numb); 4009 } 4010 var numberUtils = { 4011 toOrdinal, 4012 toOrdinalSuffix, 4013 toNumberOrNull, 4014 asFormattedString 4015 }; 4016 4017 var numberUtils$1 = /*#__PURE__*/Object.freeze({ 4018 __proto__: null, 4019 asFormattedString: asFormattedString, 4020 default: numberUtils, 4021 toCurrencyOrNull: toCurrencyOrNull, 4022 toDecimalPlaces: toDecimalPlaces, 4023 toNumber: toNumber, 4024 toNumberOrNull: toNumberOrNull, 4025 toOrdinal: toOrdinal, 4026 toOrdinalSuffix: toOrdinalSuffix, 4027 toWord: toWord, 4028 toWordFull: toWordFull, 4029 zeroPad: zeroPad 4030 }); 4031 exports('numberUtils', numberUtils$1); 4032 4033 function useVModelPassthrough(props, modelName, emit, options) { 4034 const internalValue = ref(props[modelName]); 4035 watch(() => props[modelName], val => updateRefValue(internalValue, val), options); 4036 watch(internalValue, val => { 4037 if (val !== props[modelName]) { 4038 emit("update:".concat(modelName), val); 4039 } 4040 }, options); 4041 return internalValue; 4042 } 4043 function useVModelPassthroughWithPropUpdateCheck(props, modelName, emit, options) { 4044 const internalValue = ref(props[modelName]); 4045 const listeners = []; 4046 watch(() => props[modelName], val => { 4047 if (updateRefValue(internalValue, val)) { 4048 onPropUpdate(); 4049 } 4050 }, options); 4051 watch(internalValue, val => emit("update:".concat(modelName), val), options); 4052 function onPropUpdate() { 4053 listeners.forEach(fn => fn()); 4054 } 4055 function addPropUpdateListener(fn) { 4056 listeners.push(fn); 4057 } 4058 return [internalValue, addPropUpdateListener]; 4059 } 4060 function updateRefValue(target, value) { 4061 if (deepEqual(target.value, value, true)) { 4062 return false; 4063 } 4064 target.value = value; 4065 return true; 4066 } 4067 function defineAsyncComponent(source) { 4068 return defineAsyncComponent$1(async () => { 4069 const suspense = useSuspense(); 4070 const operationKey = newGuid(); 4071 suspense === null || suspense === void 0 || suspense.startAsyncOperation(operationKey); 4072 const component = await source(); 4073 suspense === null || suspense === void 0 || suspense.completeAsyncOperation(operationKey); 4074 return component; 4075 }); 4076 }
4077 const standardRockFormFieldProps = { 4078 label: { 4079 type: String, 4080 default: "" 4081 }, 4082 disableLabel: { 4083 type: Boolean, 4084 default: false 4085 }, 4086 help: { 4087 type: String, 4088 default: "" 4089 }, 4090 rules: { 4091 type: [Array, Object, String], 4092 default: "" 4093 }, 4094 formGroupClasses: { 4095 type: String, 4096 default: "" 4097 }, 4098 validationTitle: { 4099 type: String, 4100 default: "" 4101 }, 4102 isRequiredIndicatorHidden: { 4103 type: Boolean, 4104 default: false 4105 }, 4106 trailblazerField: { 4107 type: Boolean, 4108 default: false 4109 } 4110 }; 4111 function copyStandardRockFormFieldProps(source, destination) { 4112 destination.formGroupClasses = source.formGroupClasses; 4113 destination.help = source.help; 4114 destination.label = source.label; 4115 destination.rules = source.rules; 4116 destination.validationTitle = source.validationTitle; 4117 } 4118 function useStandardRockFormFieldProps(props) { 4119 const propValues = reactive({ 4120 label: props.label, 4121 disableLabel: props.disableLabel, 4122 help: props.help, 4123 rules: props.rules, 4124 formGroupClasses: props.formGroupClasses, 4125 validationTitle: props.validationTitle, 4126 isRequiredIndicatorHidden: props.isRequiredIndicatorHidden, 4127 trailblazerField: props.trailblazerField 4128 }); 4129 watch([() => props.formGroupClasses, () => props.help, () => props.label, () => props.rules, () => props.validationTitle], () => { 4130 copyStandardRockFormFieldProps(props, propValues); 4131 }); 4132 return propValues; 4133 } 4134 const standardAsyncPickerProps = _objectSpread2(_objectSpread2({}, standardRockFormFieldProps), {}, { 4135 enhanceForLongLists: { 4136 type: Boolean, 4137 default: false 4138 }, 4139 lazyMode: { 4140 type: String, 4141 default: ControlLazyMode.OnDemand 4142 }, 4143 multiple: { 4144 type: Boolean, 4145 default: false 4146 }, 4147 showBlankItem: { 4148 type: Boolean, 4149 default: false 4150 }, 4151 blankValue: { 4152 type: String, 4153 default: "" 4154 }, 4155 displayStyle: { 4156 type: String, 4157 default: PickerDisplayStyle.Auto 4158 }, 4159 columnCount: { 4160 type: Number, 4161 default: 0 4162 } 4163 }); 4164 function copyStandardAsyncPickerProps(source, destination) { 4165 copyStandardRockFormFieldProps(source, destination); 4166 destination.enhanceForLongLists = source.enhanceForLongLists; 4167 destination.lazyMode = source.lazyMode; 4168 destination.multiple = source.multiple; 4169 destination.showBlankItem = source.showBlankItem; 4170 destination.blankValue = source.blankValue; 4171 destination.displayStyle = source.displayStyle; 4172 destination.columnCount = source.columnCount; 4173 } 4174 function useStandardAsyncPickerProps(props) { 4175 const standardFieldProps = useStandardRockFormFieldProps(props); 4176 const propValues = reactive(_objectSpread2(_objectSpread2({}, standardFieldProps), {}, { 4177 enhanceForLongLists: props.enhanceForLongLists, 4178 lazyMode: props.lazyMode, 4179 multiple: props.multiple, 4180 showBlankItem: props.showBlankItem, 4181 blankValue: props.blankValue, 4182 displayStyle: props.displayStyle, 4183 columnCount: props.columnCount 4184 })); 4185 watch(() => standardFieldProps, () => { 4186 copyStandardRockFormFieldProps(props, propValues); 4187 }, { 4188 deep: true 4189 }); 4190 watch([() => props.enhanceForLongLists, () => props.lazyMode, () => props.multiple, () => props.showBlankItem, () => props.displayStyle, () => props.columnCount], () => { 4191 copyStandardAsyncPickerProps(props, propValues); 4192 }); 4193 return propValues; 4194 } 4195 const standardDynamicComponentProps = { 4196 modelValue: { 4197 type: Object, 4198 required: true 4199 }, 4200 options: { 4201 type: Object, 4202 required: true 4203 }, 4204 executeRequest: { 4205 type: Function, 4206 required: true 4207 } 4208 }; 4209 async function loadDynamicComponentDefinition(definition) { 4210 if (!definition || !definition.url) { 4211 return; 4212 } 4213 try { 4214 const controlComponentModule = await module.import(definition.url); 4215 const controlModule = controlComponentModule ? controlComponentModule.default || controlComponentModule : null; 4216 if (controlModule) { 4217 Object.defineProperty(definition, "__component", { 4218 value: markRaw(controlModule), 4219 writable: false, 4220 enumerable: false 4221 }); 4222 } 4223 } catch (e) { 4224 console.error(e); 4225 } finally { 4226 if (!("__component" in definition)) { 4227 Object.defineProperty(definition, "__componentError", { 4228 value: "Could not load the control for '".concat(definition.url, "'"), 4229 writable: false, 4230 enumerable: false 4231 }); 4232 } 4233 } 4234 }
4235 const dataViewFilterProps = _objectSpread2(_objectSpread2({}, standardDynamicComponentProps), {}, { 4236 filterMode: { 4237 type: Number, 4238 required: true 4239 } 4240 }); 4241 const dataViewSelectProps = standardDynamicComponentProps; 4242 function extendedRef(value, context) { 4243 const refValue = ref(value); 4244 refValue.context = context; 4245 return refValue; 4246 } 4247 function propertyRef(value, propertyName) { 4248 return extendedRef(value, { 4249 propertyName 4250 }); 4251 } 4252 function getVNodeProp(node, propName) { 4253 if (node.props && node.props[propName] !== undefined) { 4254 return node.props[propName]; 4255 } 4256 if (typeof node.type === "object" && typeof node.type["props"] === "object") { 4257 const defaultProps = node.type["props"]; 4258 const defaultProp = defaultProps[propName]; 4259 if (defaultProp && typeof defaultProp === "object" && defaultProp["default"] !== undefined) { 4260 return defaultProp["default"]; 4261 } 4262 } 4263 return undefined; 4264 } 4265 function getVNodeProps(node) { 4266 const props = {}; 4267 if (typeof node.type === "object" && typeof node.type["props"] === "object") { 4268 const defaultProps = node.type["props"]; 4269 for (const p in defaultProps) { 4270 const defaultProp = defaultProps[p]; 4271 if (defaultProp && typeof defaultProp === "object" && defaultProp["default"] !== undefined) { 4272 props[p] = defaultProp["default"]; 4273 } 4274 } 4275 } 4276 if (node.props) { 4277 for (const p in node.props) { 4278 if (typeof node.type === "object" && typeof node.type["props"] === "object") { 4279 var _node$type$props$p; 4280 const propType = (_node$type$props$p = node.type["props"][p]) === null || _node$type$props$p === void 0 ? void 0 : _node$type$props$p.type; 4281 if (propType === Boolean) { 4282 props[p] = node.props[p] === true || node.props[p] === ""; 4283 } else if (propType === Number) { 4284 var _toNumberOrNull; 4285 props[p] = (_toNumberOrNull = toNumberOrNull(node.props[p])) !== null && _toNumberOrNull !== void 0 ? _toNumberOrNull : undefined; 4286 } else { 4287 props[p] = node.props[p]; 4288 } 4289 } else { 4290 props[p] = node.props[p]; 4291 } 4292 } 4293 } 4294 return props; 4295 } 4296 function extractText(node, props) { 4297 const el = document.createElement("div"); 4298 const vnode = createVNode(node, props); 4299 render(vnode, el); 4300 const text = el.innerText; 4301 render(null, el); 4302 return text.trim(); 4303 } 4304 function extractHtml(node, props) { 4305 const el = document.createElement("div"); 4306 const vnode = createVNode(node, props); 4307 render(vnode, el); 4308 const html = el.innerHTML; 4309 render(null, el); 4310 return html; 4311 } 4312 4313 var component = /*#__PURE__*/Object.freeze({ 4314 __proto__: null, 4315 dataViewFilterProps: dataViewFilterProps, 4316 dataViewSelectProps: dataViewSelectProps, 4317 defineAsyncComponent: defineAsyncComponent, 4318 extendedRef: extendedRef, 4319 extractHtml: extractHtml, 4320 extractText: extractText, 4321 getVNodeProp: getVNodeProp, 4322 getVNodeProps: getVNodeProps, 4323 loadDynamicComponentDefinition: loadDynamicComponentDefinition, 4324 propertyRef: propertyRef, 4325 standardAsyncPickerProps: standardAsyncPickerProps, 4326 standardDynamicComponentProps: standardDynamicComponentProps, 4327 standardRockFormFieldProps: standardRockFormFieldProps, 4328 updateRefValue: updateRefValue, 4329 useStandardAsyncPickerProps: useStandardAsyncPickerProps, 4330 useStandardRockFormFieldProps: useStandardRockFormFieldProps, 4331 useVModelPassthrough: useVModelPassthrough, 4332 useVModelPassthroughWithPropUpdateCheck: useVModelPassthroughWithPropUpdateCheck 4333 }); 4334 exports('component', component); 4335 4336 function getCssVariableValue(cssVariableName, fallbackValue, targetElement) { 4337 const element = targetElement ? typeof targetElement === "string" ? document.querySelector(targetElement) : targetElement : document.documentElement; 4338 if (!element) { 4339 return fallbackValue || ""; 4340 } 4341 const computedStyle = getComputedStyle(element).getPropertyValue(cssVariableName).trim(); 4342 return computedStyle || fallbackValue || ""; 4343 } 4344 4345 var cssUtils = /*#__PURE__*/Object.freeze({ 4346 __proto__: null, 4347 getCssVariableValue: getCssVariableValue 4348 }); 4349 exports('cssUtils', cssUtils); 4350 4351 const dateKeyLength = "YYYYMMDD".length; 4352 const dateKeyNoYearLength = "MMDD".length; 4353 function getYear(dateKey) { 4354 const defaultValue = 0; 4355 if (!dateKey || dateKey.length !== dateKeyLength) { 4356 return defaultValue; 4357 } 4358 const asString = dateKey.substring(0, 4); 4359 const year = toNumberOrNull(asString) || defaultValue; 4360 return year; 4361 } 4362 function getMonth(dateKey) { 4363 const defaultValue = 0; 4364 if (!dateKey) { 4365 return defaultValue; 4366 } 4367 if (dateKey.length === dateKeyLength) { 4368 const asString = dateKey.substring(4, 6); 4369 return toNumberOrNull(asString) || defaultValue; 4370 } 4371 if (dateKey.length === dateKeyNoYearLength) { 4372 const asString = dateKey.substring(0, 2); 4373 return toNumberOrNull(asString) || defaultValue; 4374 } 4375 return defaultValue; 4376 } 4377 function getDay(dateKey) { 4378 const defaultValue = 0; 4379 if (!dateKey) { 4380 return defaultValue; 4381 } 4382 if (dateKey.length === dateKeyLength) { 4383 const asString = dateKey.substring(6, 8); 4384 return toNumberOrNull(asString) || defaultValue; 4385 } 4386 if (dateKey.length === dateKeyNoYearLength) { 4387 const asString = dateKey.substring(2, 4); 4388 return toNumberOrNull(asString) || defaultValue; 4389 } 4390 return defaultValue; 4391 } 4392 function toDateKey(year, month, day) { 4393 if (!year || year > 9999 || year < 0) { 4394 year = 0; 4395 } 4396 if (!month || month > 12 || month < 0) {
4397 month = 0; 4398 } 4399 if (!day || day > 31 || day < 0) { 4400 day = 0; 4401 } 4402 const yearStr = zeroPad(year, 4); 4403 const monthStr = zeroPad(month, 2); 4404 const dayStr = zeroPad(day, 2); 4405 return "".concat(yearStr).concat(monthStr).concat(dayStr); 4406 } 4407 function toNoYearDateKey(month, day) { 4408 if (!month || month > 12 || month < 0) { 4409 month = 0; 4410 } 4411 if (!day || day > 31 || day < 0) { 4412 day = 0; 4413 } 4414 const monthStr = zeroPad(month, 2); 4415 const dayStr = zeroPad(day, 2); 4416 return "".concat(monthStr).concat(dayStr); 4417 } 4418 var dateKey = { 4419 getYear, 4420 getMonth, 4421 getDay, 4422 toDateKey, 4423 toNoYearDateKey 4424 }; 4425 4426 var dateKey$1 = /*#__PURE__*/Object.freeze({ 4427 __proto__: null, 4428 default: dateKey, 4429 getDay: getDay, 4430 getMonth: getMonth, 4431 getYear: getYear, 4432 toDateKey: toDateKey, 4433 toNoYearDateKey: toNoYearDateKey 4434 }); 4435 exports('dateKey', dateKey$1); 4436 4437 function smoothScrollToTop() { 4438 window.scrollTo({ 4439 top: 0, 4440 behavior: "smooth" 4441 }); 4442 } 4443 var page = { 4444 smoothScrollToTop 4445 }; 4446 let currentModalCount = 0; 4447 function trackModalState(state) { 4448 const body = document.body; 4449 const cssClasses = ["modal-open"]; 4450 if (state) { 4451 currentModalCount++; 4452 } else { 4453 currentModalCount = currentModalCount > 0 ? currentModalCount - 1 : 0; 4454 } 4455 if (currentModalCount > 0) { 4456 for (const cssClass of cssClasses) { 4457 body.classList.add(cssClass); 4458 } 4459 } else { 4460 for (const cssClass of cssClasses) { 4461 body.classList.remove(cssClass); 4462 } 4463 } 4464 } 4465 async function loadJavaScriptAsync(source, isScriptLoaded, attributes, fingerprint) { 4466 var _Obsidian; 4467 let src = source; 4468 if (fingerprint !== false && typeof Obsidian !== "undefined" && (_Obsidian = Obsidian) !== null && _Obsidian !== void 0 && (_Obsidian = _Obsidian.options) !== null && _Obsidian !== void 0 && _Obsidian.fingerprint) { 4469 if (src.indexOf("?") === -1) { 4470 src += "?".concat(Obsidian.options.fingerprint); 4471 } else { 4472 src += "&".concat(Obsidian.options.fingerprint); 4473 } 4474 } 4475 if (isScriptLoaded) { 4476 if (isScriptLoaded()) { 4477 return true; 4478 } 4479 } 4480 const scripts = Array.from(document.getElementsByTagName("script")); 4481 const thisScript = scripts.filter(s => s.src === src); 4482 if (thisScript.length > 0) { 4483 const promise = scriptLoadedPromise(thisScript[0]); 4484 return promise; 4485 } 4486 const script = document.createElement("script"); 4487 script.type = "text/javascript"; 4488 script.src = src; 4489 if (attributes) { 4490 for (const key in attributes) { 4491 script.setAttribute(key, attributes[key]); 4492 } 4493 } 4494 const promise = scriptLoadedPromise(script); 4495 document.getElementsByTagName("head")[0].appendChild(script); 4496 return promise; 4497 async function scriptLoadedPromise(scriptElement) { 4498 try { 4499 await new Promise((resolve, reject) => { 4500 scriptElement.addEventListener("load", () => resolve()); 4501 scriptElement.addEventListener("error", () => { 4502 reject(); 4503 }); 4504 }); 4505 if (isScriptLoaded) { 4506 return isScriptLoaded(); 4507 } 4508 return true; 4509 } catch (_unused) { 4510 return false; 4511 } 4512 } 4513 } 4514 function addQuickReturn(title, section, sectionOrder) { 4515 const rock = window["Rock"]; 4516 if (rock && rock.personalLinks) { 4517 rock.personalLinks.addQuickReturn(section, sectionOrder !== null && sectionOrder !== void 0 ? sectionOrder : 0, title); 4518 } 4519 } 4520 4521 var page$1 = /*#__PURE__*/Object.freeze({ 4522 __proto__: null, 4523 addQuickReturn: addQuickReturn, 4524 default: page, 4525 loadJavaScriptAsync: loadJavaScriptAsync, 4526 smoothScrollToTop: smoothScrollToTop, 4527 trackModalState: trackModalState 4528 }); 4529 exports('page', page$1); 4530 4531 function createDialog(body, footer) { 4532 const scrollable = document.createElement("div"); 4533 scrollable.classList.add("modal-scrollable"); 4534 scrollable.style.zIndex = "1060"; 4535 const modal = document.createElement("div"); 4536 scrollable.appendChild(modal); 4537 modal.classList.add("modal", "fade"); 4538 modal.tabIndex = -1; 4539 modal.setAttribute("role", "dialog"); 4540 modal.setAttribute("aria-hidden", "false"); 4541 modal.style.display = "block"; 4542 const modalDialog = document.createElement("div"); 4543 modal.appendChild(modalDialog); 4544 modalDialog.classList.add("modal-dialog"); 4545 const modalContent = document.createElement("div"); 4546 modalDialog.appendChild(modalContent); 4547 modalContent.classList.add("modal-content"); 4548 const modalBody = document.createElement("div"); 4549 modalContent.appendChild(modalBody); 4550 modalBody.classList.add("modal-body"); 4551 if (Array.isArray(body)) { 4552 for (const el of body) { 4553 modalBody.appendChild(el); 4554 } 4555 } else { 4556 modalBody.appendChild(body); 4557 } 4558 if (footer && (!Array.isArray(footer) || footer.length > 0)) { 4559 const modalFooter = document.createElement("div"); 4560 modalContent.appendChild(modalFooter); 4561 modalFooter.classList.add("modal-footer"); 4562 if (Array.isArray(footer)) { 4563 for (const el of footer) { 4564 modalFooter.appendChild(el); 4565 } 4566 } else { 4567 modalFooter.appendChild(footer); 4568 } 4569 } 4570 scrollable.addEventListener("click", () => { 4571 modal.classList.remove("animated", "shake"); 4572 setTimeout(() => { 4573 modal.classList.add("animated", "shake"); 4574 }, 0); 4575 }); 4576 return scrollable; 4577 } 4578 function createCloseButton() { 4579 const closeButton = document.createElement("button"); 4580 closeButton.classList.add("close"); 4581 closeButton.type = "button"; 4582 closeButton.style.marginTop = "-10px"; 4583 closeButton.innerHTML = "×"; 4584 return closeButton; 4585 } 4586 function createBackdrop() { 4587 const backdrop = document.createElement("div"); 4588 backdrop.classList.add("modal-backdrop"); 4589 backdrop.style.zIndex = "1050"; 4590 return backdrop; 4591 } 4592 function showDialog(options) { 4593 return new Promise(resolve => { 4594 var _options$cancellation; 4595 let timer = null; 4596 const container = document.fullscreenElement || document.body; 4597 const body = document.createElement("div"); 4598 let autoFocus = null; 4599 if (options.message instanceof HTMLElement) { 4600 body.appendChild(options.message); 4601 } else { 4602 body.innerText = options.message; 4603 } 4604 const buttons = []; 4605 function clearDialog(result) { 4606 if (timer !== null) { 4607 return; 4608 } 4609 timer = setTimeout(() => { 4610 backdrop.remove(); 4611 dialog.remove(); 4612 trackModalState(false); 4613 resolve(result); 4614 }, 1000); 4615 modal.addEventListener("transitionend", () => { 4616 if (timer) { 4617 clearTimeout(timer); 4618 } 4619 backdrop.remove(); 4620 dialog.remove(); 4621 trackModalState(false); 4622 resolve(result); 4623 }); 4624 modal.classList.remove("in"); 4625 backdrop.classList.remove("in"); 4626 } 4627 for (const button of options.buttons) { 4628 const btn = document.createElement("button"); 4629 btn.classList.value = button.className; 4630 btn.type = "button"; 4631 btn.innerText = button.label; 4632 btn.addEventListener("click", () => { 4633 clearDialog(button.key); 4634 }); 4635 if (button.autoFocus) { 4636 autoFocus = btn; 4637 } 4638 buttons.push(btn); 4639 } 4640 const dialogBody = [body]; 4641 if (!options.hideCloseButton) { 4642 const closeButton = createCloseButton(); 4643 closeButton.addEventListener("click", () => { 4644 clearDialog("cancel"); 4645 }); 4646 dialogBody.splice(0, 0, closeButton); 4647 } 4648 const dialog = createDialog(dialogBody, buttons); 4649 const backdrop = createBackdrop(); 4650 const modal = dialog.querySelector(".modal"); 4651 trackModalState(true); 4652 container.appendChild(dialog); 4653 container.appendChild(backdrop); 4654 modal.style.marginTop = "-".concat(modal.offsetHeight / 2.0, "px"); 4655 if (autoFocus) { 4656 autoFocus.focus(); 4657 } 4658 backdrop.classList.add("in"); 4659 modal.classList.add("in"); 4660 (_options$cancellation = options.cancellationToken) === null || _options$cancellation === void 0 || _options$cancellation.onCancellationRequested(() => { 4661 clearDialog("cancel"); 4662 }); 4663 }); 4664 } 4665 async function alert(message) { 4666 await showDialog({ 4667 message, 4668 buttons: [{ 4669 key: "ok", 4670 label: "OK", 4671 className: "btn btn-primary" 4672 }] 4673 }); 4674 } 4675 async function confirm(message) { 4676 const result = await showDialog({ 4677 message, 4678 buttons: [{ 4679 key: "ok", 4680 label: "OK", 4681 className: "btn btn-primary", 4682 autoFocus: true 4683 }, { 4684 key: "cancel", 4685 label: "Cancel", 4686 className: "btn btn-default" 4687 }] 4688 }); 4689 return result === "ok"; 4690 }
4691 function confirmDelete(typeName, additionalMessage) { 4692 let message = "Are you sure you want to delete this ".concat(typeName, "?"); 4693 if (additionalMessage) { 4694 message += " ".concat(additionalMessage); 4695 } 4696 return confirm(message); 4697 } 4698 function showSecurity(entityTypeIdKey, entityIdKey) { 4699 let entityTitle = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "Item"; 4700 Rock.controls.modal.show(undefined, "/Secure/".concat(entityTypeIdKey, "/").concat(entityIdKey, "?t=Secure ").concat(entityTitle, "&pb=&sb=Done")); 4701 } 4702 function showChildPages(pageId) { 4703 Rock.controls.modal.show(undefined, "/pages/".concat(pageId, "?t=Child Pages&pb=&sb=Done")); 4704 } 4705 4706 var dialogs = /*#__PURE__*/Object.freeze({ 4707 __proto__: null, 4708 alert: alert, 4709 confirm: confirm, 4710 confirmDelete: confirmDelete, 4711 showChildPages: showChildPages, 4712 showDialog: showDialog, 4713 showSecurity: showSecurity 4714 }); 4715 exports('dialogs', dialogs); 4716 4717 function isEmail(val) { 4718 if (typeof val === "string") { 4719 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,}))$/; 4720 return re.test(val.toLowerCase()); 4721 } 4722 return false; 4723 } 4724 4725 var email = /*#__PURE__*/Object.freeze({ 4726 __proto__: null, 4727 isEmail: isEmail 4728 }); 4729 exports('email', email); 4730 4731 function enumToListItemBag(description) { 4732 const listItemBagList = []; 4733 const order = description["__order"]; 4734 if (order) { 4735 for (const value of order) { 4736 listItemBagList.push({ 4737 text: description[value], 4738 value: value.toString() 4739 }); 4740 } 4741 } else { 4742 for (const property in description) { 4743 listItemBagList.push({ 4744 text: description[property], 4745 value: property.toString() 4746 }); 4747 } 4748 } 4749 return listItemBagList; 4750 } 4751 4752 var enumUtils = /*#__PURE__*/Object.freeze({ 4753 __proto__: null, 4754 enumToListItemBag: enumToListItemBag 4755 }); 4756 exports('enumUtils', enumUtils); 4757 4758 const fieldTypeTable = {}; 4759 const fieldTypeAttributeGuidSymbol = Symbol(); 4760 function registerFieldType(fieldTypeGuid, fieldType) { 4761 const normalizedGuid = normalize(fieldTypeGuid); 4762 if (!isValidGuid(fieldTypeGuid) || normalizedGuid === null) { 4763 throw "Invalid guid specified when registering field type."; 4764 } 4765 if (fieldTypeTable[normalizedGuid] !== undefined) { 4766 throw "Invalid attempt to replace existing field type."; 4767 } 4768 fieldTypeTable[normalizedGuid] = fieldType; 4769 } 4770 function getFieldType(fieldTypeGuid) { 4771 const normalizedGuid = normalize(fieldTypeGuid); 4772 if (normalizedGuid !== null) { 4773 const field = fieldTypeTable[normalizedGuid]; 4774 if (field) { 4775 return field; 4776 } 4777 } 4778 console.warn("Field type \"".concat(fieldTypeGuid, "\" was not found")); 4779 return null; 4780 } 4781 function provideFieldTypeAttributeGuid(guid) { 4782 provide(fieldTypeAttributeGuidSymbol, guid); 4783 } 4784 function useFieldTypeAttributeGuid() { 4785 return inject(fieldTypeAttributeGuidSymbol, ref()); 4786 } 4787 4788 var fieldTypes = /*#__PURE__*/Object.freeze({ 4789 __proto__: null, 4790 getFieldType: getFieldType, 4791 provideFieldTypeAttributeGuid: provideFieldTypeAttributeGuid, 4792 registerFieldType: registerFieldType, 4793 useFieldTypeAttributeGuid: useFieldTypeAttributeGuid 4794 }); 4795 exports('fieldTypes', fieldTypes); 4796 4797 async function downloadFile(data, filename) { 4798 const url = URL.createObjectURL(data); 4799 const element = document.createElement("a"); 4800 element.innerText = "Download"; 4801 element.style.position = "absolute"; 4802 element.style.top = "-100px"; 4803 element.style.left = "0"; 4804 element.href = url; 4805 element.download = filename; 4806 document.body.appendChild(element); 4807 element.click(); 4808 document.body.removeChild(element); 4809 setTimeout(() => URL.revokeObjectURL(url), 100); 4810 } 4811 async function fetchImageFileExtensions() { 4812 const http = useHttp(); 4813 const result = await http.post("/api/v2/Utilities/GetImageFileExtensions"); 4814 if (result.isSuccess && result.data) { 4815 return result.data.split(","); 4816 } 4817 return null; 4818 }
4819 const getImageFileExtensions = Cache.cachePromiseFactory("imageFileExtensions", fetchImageFileExtensions); 4820 async function isImage(filename) { 4821 var _imageExtensions$incl; 4822 const imageExtensions = await getImageFileExtensions(); 4823 const extension = filename.split(".").pop(); 4824 return !!extension && ((_imageExtensions$incl = imageExtensions === null || imageExtensions === void 0 ? void 0 : imageExtensions.includes(extension.toLowerCase())) !== null && _imageExtensions$incl !== void 0 ? _imageExtensions$incl : false); 4825 } 4826 function resizeImageFileProcessor() { 4827 let { 4828 minWidth, 4829 minHeight, 4830 maxWidth, 4831 maxHeight 4832 } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; 4833 return file => { 4834 if (!file.type.startsWith("image/")) { 4835 return file; 4836 } 4837 return new Promise((resolve, reject) => { 4838 const img = new Image(); 4839 const objectUrl = URL.createObjectURL(file); 4840 img.src = objectUrl; 4841 img.onload = () => { 4842 URL.revokeObjectURL(objectUrl); 4843 const { 4844 width, 4845 height 4846 } = img; 4847 if (!maxWidth && !maxHeight && !minWidth && !minHeight) { 4848 resolve(file); 4849 return; 4850 } 4851 const minScale = Math.max(minWidth ? minWidth / width : 0, minHeight ? minHeight / height : 0, 0); 4852 const maxScale = Math.min(maxWidth ? maxWidth / width : Infinity, maxHeight ? maxHeight / height : Infinity, 1); 4853 let scaleFactor = 1; 4854 if (minScale > 1) { 4855 scaleFactor = minScale; 4856 } else if (maxScale < 1) { 4857 scaleFactor = maxScale; 4858 } 4859 if (scaleFactor === 1) { 4860 resolve(file); 4861 return; 4862 } 4863 const newWidth = Math.round(width * scaleFactor); 4864 const newHeight = Math.round(height * scaleFactor); 4865 const canvas = document.createElement("canvas"); 4866 canvas.width = newWidth; 4867 canvas.height = newHeight; 4868 const ctx = canvas.getContext("2d"); 4869 if (!ctx) { 4870 reject(new Error("Failed to get canvas context")); 4871 return; 4872 } 4873 ctx.imageSmoothingEnabled = true; 4874 ctx.imageSmoothingQuality = "high"; 4875 ctx.drawImage(img, 0, 0, newWidth, newHeight); 4876 canvas.toBlob(blob => { 4877 if (!blob) { 4878 reject(new Error("Failed to resize image")); 4879 return; 4880 } 4881 const resizedFile = new File([blob], file.name, { 4882 type: file.type 4883 }); 4884 resolve(resizedFile); 4885 }, file.type); 4886 }; 4887 img.onerror = () => { 4888 URL.revokeObjectURL(objectUrl); 4889 reject(new Error("Failed to load image")); 4890 }; 4891 }); 4892 }; 4893 } 4894 4895 var file = /*#__PURE__*/Object.freeze({ 4896 __proto__: null, 4897 downloadFile: downloadFile, 4898 getImageFileExtensions: getImageFileExtensions, 4899 isImage: isImage, 4900 resizeImageFileProcessor: resizeImageFileProcessor 4901 }); 4902 exports('file', file); 4903 4904 const formStateSymbol = Symbol(); 4905 function provideFormState(state) { 4906 provide(formStateSymbol, state); 4907 } 4908 function useFormState() { 4909 return inject(formStateSymbol, undefined); 4910 } 4911 4912 var form = /*#__PURE__*/Object.freeze({ 4913 __proto__: null, 4914 provideFormState: provideFormState, 4915 useFormState: useFormState 4916 }); 4917 exports('form', form); 4918 4919 async function enterFullscreen(element, exitCallback) { 4920 try { 4921 if (element.requestFullscreen) { 4922 await element.requestFullscreen(); 4923 } else if (element.mozRequestFullscreen) { 4924 await element.mozRequestFullscreen(); 4925 } else if (element.webkitRequestFullscreen) { 4926 await element.webkitRequestFullscreen(); 4927 } else { 4928 return false;
4929 } 4930 element.classList.add("is-fullscreen"); 4931 const onFullscreenChange = () => { 4932 element.classList.remove("is-fullscreen"); 4933 document.removeEventListener("fullscreenchange", onFullscreenChange); 4934 document.removeEventListener("mozfullscreenchange", onFullscreenChange); 4935 document.removeEventListener("webkitfullscreenchange", onFullscreenChange); 4936 if (exitCallback) { 4937 exitCallback(); 4938 } 4939 }; 4940 document.addEventListener("fullscreenchange", onFullscreenChange); 4941 document.addEventListener("mozfullscreenchange", onFullscreenChange); 4942 document.addEventListener("webkitfullscreenchange", onFullscreenChange); 4943 return true; 4944 } catch (ex) { 4945 console.error(ex); 4946 return false; 4947 } 4948 } 4949 function isFullscreen() { 4950 return !!getFullscreenElement(); 4951 } 4952 function getFullscreenElement() { 4953 return document.fullscreenElement || document.mozFullScreenElement || document.webkitFullscreenElement; 4954 } 4955 async function exitFullscreen() { 4956 try { 4957 if (document.exitFullscreen) { 4958 await document.exitFullscreen(); 4959 } else if (document.mozCancelFullScreen) { 4960 await document.mozCancelFullScreen(); 4961 } else if (document.webkitExitFullscreen) { 4962 document.webkitExitFullscreen(); 4963 } else { 4964 return false; 4965 } 4966 return true; 4967 } catch (ex) { 4968 console.error(ex); 4969 return false; 4970 } 4971 } 4972 4973 var fullscreen = /*#__PURE__*/Object.freeze({ 4974 __proto__: null, 4975 enterFullscreen: enterFullscreen, 4976 exitFullscreen: exitFullscreen, 4977 getFullscreenElement: getFullscreenElement, 4978 isFullscreen: isFullscreen 4979 }); 4980 exports('fullscreen', fullscreen); 4981 4982 function toCoordinate(coord) { 4983 let isWellKnown = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; 4984 if (typeof coord == "string") { 4985 if (isWellKnown) { 4986 return coord.split(" ").reverse().map(val => parseFloat(val)); 4987 } else { 4988 return coord.split(",").map(val => parseFloat(val)); 4989 } 4990 } else { 4991 return [coord.lat(), coord.lng()]; 4992 } 4993 } 4994 function wellKnownToCoordinates(wellKnownText, type) { 4995 if (wellKnownText === "") { 4996 return []; 4997 } 4998 if (type === "Point") { 4999 return [toCoordinate(wellKnownText.replace(/(POINT *\( *)|( *\) *)/ig, ""), true)]; 5000 } else { 5001 return wellKnownText.replace(/(POLYGON *\(+ *)|( *\)+ *)/ig, "").split(/ *, */).map(coord => toCoordinate(coord, true)); 5002 } 5003 } 5004 function coordinatesToWellKnown(coordinates, type) { 5005 if (coordinates.length === 0) { 5006 return ""; 5007 } else if (type === "Point") { 5008 return "POINT(".concat(coordinates[0].reverse().join(" "), ")"); 5009 } else { 5010 if (isClockwisePolygon(coordinates)) { 5011 coordinates.reverse(); 5012 } 5013 const coordinateString = coordinates.map(coords => coords.reverse().join(" ")).join(", "); 5014 return "POLYGON((".concat(coordinateString, "))"); 5015 } 5016 } 5017 function nearAddressForCoordinate(coordinate) { 5018 return new Promise(resolve => { 5019 if (window.google) { 5020 const geocoder = new google.maps.Geocoder(); 5021 geocoder.geocode({ 5022 location: new google.maps.LatLng(...coordinate) 5023 }, function (results, status) { 5024 if (status === google.maps.GeocoderStatus.OK && results !== null && results !== void 0 && results[0]) { 5025 resolve("near " + results[0].formatted_address); 5026 } else { 5027 console.log("Geocoder failed due to: " + status); 5028 resolve(""); 5029 } 5030 }); 5031 } else { 5032 resolve(""); 5033 } 5034 }); 5035 } 5036 function nearAddressForCoordinates(coordinates) { 5037 if (!coordinates || coordinates.length === 0) { 5038 return Promise.resolve(""); 5039 } 5040 return nearAddressForCoordinate(coordinates[0]); 5041 } 5042 function isClockwisePolygon(polygon) { 5043 let sum = 0; 5044 for (let i = 0; i < polygon.length - 1; i++) {
5045 sum += (Math.abs(polygon[i + 1][0]) - Math.abs(polygon[i][0])) * (Math.abs(polygon[i + 1][1]) + Math.abs(polygon[i][1])); 5046 } 5047 return sum > 0; 5048 } 5049 async function loadMapResources() { 5050 var _response$data; 5051 let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : { 5052 mapStyleValueGuid: emptyGuid 5053 }; 5054 const response = await post("/api/v2/Controls/GeoPickerGetGoogleMapSettings", undefined, options); 5055 const googleMapSettings = (_response$data = response.data) !== null && _response$data !== void 0 ? _response$data : {}; 5056 let keyParam = ""; 5057 if (googleMapSettings.googleApiKey) { 5058 keyParam = "key=".concat(googleMapSettings.googleApiKey, "&"); 5059 } 5060 await loadJavaScriptAsync("https://maps.googleapis.com/maps/api/js?".concat(keyParam, "libraries=visualization,geometry,marker"), () => typeof google != "undefined" && typeof google.maps != "undefined", {}, false); 5061 return googleMapSettings; 5062 } 5063 function createLatLng(latOrLatLngOrLatLngLiteral, lngOrNoClampNoWrap, noClampNoWrap) { 5064 return new google.maps.LatLng(latOrLatLngOrLatLngLiteral, lngOrNoClampNoWrap, noClampNoWrap); 5065 } 5066 5067 var geo = /*#__PURE__*/Object.freeze({ 5068 __proto__: null, 5069 coordinatesToWellKnown: coordinatesToWellKnown, 5070 createLatLng: createLatLng, 5071 isClockwisePolygon: isClockwisePolygon, 5072 loadMapResources: loadMapResources, 5073 nearAddressForCoordinate: nearAddressForCoordinate, 5074 nearAddressForCoordinates: nearAddressForCoordinates, 5075 toCoordinate: toCoordinate, 5076 wellKnownToCoordinates: wellKnownToCoordinates 5077 }); 5078 exports('geo', geo); 5079 5080 const nthNamesAbbreviated = [[1, "1st"], [2, "2nd"], [3, "3rd"], [4, "4th"], [-1, "last"]]; 5081 function padZeroLeft(value, length) { 5082 const str = value.toString(); 5083 return "0".repeat(length - str.length) + str; 5084 } 5085 function getDateString(date) { 5086 const year = date.year;
5087 const month = date.month; 5088 const day = date.day; 5089 return "".concat(year).concat(padZeroLeft(month, 2)).concat(padZeroLeft(day, 2)); 5090 } 5091 function getTimeString(date) { 5092 const hour = date.hour; 5093 const minute = date.minute; 5094 const second = date.second; 5095 return "".concat(padZeroLeft(hour, 2)).concat(padZeroLeft(minute, 2)).concat(padZeroLeft(second, 2)); 5096 } 5097 function getDateTimeString(date) { 5098 return "".concat(getDateString(date), "T").concat(getTimeString(date)); 5099 } 5100 function getDatesFromRangeOrPeriod(value) { 5101 const segments = value.split("/"); 5102 if (segments.length === 0) { 5103 return []; 5104 } 5105 const startDate = getDateFromString(segments[0]); 5106 if (!startDate) { 5107 return []; 5108 } 5109 if (segments.length !== 2) { 5110 return [startDate]; 5111 } 5112 const dates = []; 5113 if (segments[1].startsWith("P")) { 5114 const days = getPeriodDurationInDays(segments[1]); 5115 for (let day = 0; day < days; day++) { 5116 const date = startDate.addDays(day); 5117 if (date) { 5118 dates.push(date); 5119 } 5120 } 5121 } else { 5122 const endDate = getDateFromString(segments[1]); 5123 if (endDate !== null) { 5124 let date = startDate; 5125 while (date <= endDate) { 5126 dates.push(date); 5127 date = date.addDays(1); 5128 } 5129 } 5130 } 5131 return dates; 5132 } 5133 function getDateFromString(value) { 5134 if (value.length < 8) { 5135 return null; 5136 } 5137 const year = parseInt(value.substring(0, 4));
5138 const month = parseInt(value.substring(4, 6)); 5139 const day = parseInt(value.substring(6, 8)); 5140 return RockDateTime.fromParts(year, month, day); 5141 } 5142 function getDateTimeFromString(value) { 5143 if (value.length < 15 || value[8] !== "T") { 5144 return null; 5145 } 5146 const year = parseInt(value.substring(0, 4)); 5147 const month = parseInt(value.substring(4, 6)); 5148 const day = parseInt(value.substring(6, 8)); 5149 const hour = parseInt(value.substring(9, 11)); 5150 const minute = parseInt(value.substring(11, 13)); 5151 const second = parseInt(value.substring(13, 15)); 5152 return RockDateTime.fromParts(year, month, day, hour, minute, second); 5153 } 5154 function getPeriodDurationInDays(period) { 5155 if (!period.startsWith("P")) { 5156 return 0; 5157 } 5158 if (period.endsWith("D")) { 5159 return parseInt(period.substring(1, period.length - 1)); 5160 } else if (period.endsWith("W")) { 5161 return parseInt(period.substring(1, period.length - 1)) * 7; 5162 } 5163 return 0; 5164 } 5165 function getRecurrenceDates(attributes, value) { 5166 const recurrenceDates = []; 5167 const valueParts = value.split(","); 5168 let valueType = attributes["VALUE"]; 5169 for (const valuePart of valueParts) { 5170 if (!valueType) { 5171 const length = valuePart.length; 5172 if (length === 8) { 5173 valueType = "DATE"; 5174 } else if ((length === 15 || length === 16) && valuePart[8] === "T") { 5175 valueType = "DATE-TIME"; 5176 } else { 5177 valueType = "PERIOD"; 5178 } 5179 } 5180 if (valueType === "PERIOD") { 5181 recurrenceDates.push(...getDatesFromRangeOrPeriod(valuePart)); 5182 } else if (valueType === "DATE") { 5183 const date = getDateFromString(valuePart); 5184 if (date) { 5185 recurrenceDates.push(date); 5186 } 5187 } else if (valueType === "DATE-TIME") { 5188 const date = getDateTimeFromString(valuePart); 5189 if (date) { 5190 recurrenceDates.push(date); 5191 } 5192 } 5193 } 5194 return recurrenceDates; 5195 } 5196 function getWeekdayName(day) { 5197 if (day === DayOfWeek.Sunday) { 5198 return "Sunday"; 5199 } else if (day === DayOfWeek.Monday) { 5200 return "Monday"; 5201 } else if (day === DayOfWeek.Tuesday) { 5202 return "Tuesday"; 5203 } else if (day === DayOfWeek.Wednesday) { 5204 return "Wednesday"; 5205 } else if (day === DayOfWeek.Thursday) { 5206 return "Thursday"; 5207 } else if (day === DayOfWeek.Friday) { 5208 return "Friday"; 5209 } else if (day === DayOfWeek.Saturday) { 5210 return "Saturday"; 5211 } else { 5212 return "Unknown"; 5213 } 5214 } 5215 function dateMatchesDays(rockDate, days) { 5216 for (const day of days) { 5217 if (rockDate.dayOfWeek === day) { 5218 return true; 5219 } 5220 } 5221 return false; 5222 } 5223 function dateMatchesOffsetDayOfWeeks(rockDate, dayOfWeek, offsets) { 5224 if (!dateMatchesDays(rockDate, [dayOfWeek])) { 5225 return false; 5226 } 5227 const dayOfMonth = rockDate.day; 5228 for (const offset of offsets) { 5229 if (offset === 1 && dayOfMonth >= 1 && dayOfMonth <= 7) { 5230 return true; 5231 } else if (offset === 2 && dayOfMonth >= 8 && dayOfMonth <= 14) { 5232 return true; 5233 } else if (offset === 3 && dayOfMonth >= 15 && dayOfMonth <= 21) { 5234 return true; 5235 } else if (offset === 4 && dayOfMonth >= 22 && dayOfMonth <= 28) { 5236 return true; 5237 } else if (offset === -1) { 5238 const lastDayOfMonth = rockDate.addDays(-(rockDate.day - 1)).addMonths(1).addDays(-1).day; 5239 if (dayOfMonth >= lastDayOfMonth - 7 && dayOfMonth <= lastDayOfMonth) { 5240 return true; 5241 } 5242 } 5243 } 5244 return false; 5245 } 5246 function getDayOfWeekFromIcalDay(day) { 5247 switch (day) { 5248 case "SU": 5249 return DayOfWeek.Sunday; 5250 case "MO": 5251 return DayOfWeek.Monday; 5252 case "TU": 5253 return DayOfWeek.Tuesday; 5254 case "WE": 5255 return DayOfWeek.Wednesday; 5256 case "TH": 5257 return DayOfWeek.Thursday; 5258 case "FR": 5259 return DayOfWeek.Friday; 5260 case "SA": 5261 return DayOfWeek.Saturday; 5262 } 5263 } 5264 function getiCalDay(day) { 5265 switch (day) { 5266 case DayOfWeek.Sunday: 5267 return "SU"; 5268 case DayOfWeek.Monday: 5269 return "MO"; 5270 case DayOfWeek.Tuesday: 5271 return "TU"; 5272 case DayOfWeek.Wednesday: 5273 return "WE"; 5274 case DayOfWeek.Thursday: 5275 return "TH"; 5276 case DayOfWeek.Friday: 5277 return "FR"; 5278 case DayOfWeek.Saturday: 5279 return "SA"; 5280 } 5281 } 5282 function normalizeLineLength(lines) { 5283 const newLines = [...lines]; 5284 for (let lineNumber = 0; lineNumber < newLines.length; lineNumber++) { 5285 if (newLines[lineNumber].length > 75) { 5286 const currentLine = newLines[lineNumber].substring(0, 75); 5287 const newLine = " " + newLines[lineNumber].substring(75); 5288 newLines.splice(lineNumber, 1, currentLine, newLine); 5289 } 5290 } 5291 return newLines; 5292 } 5293 function denormalizeLineLength(lines) { 5294 const newLines = [...lines]; 5295 for (let lineNumber = 1; lineNumber < newLines.length;) { 5296 if (newLines[lineNumber][0] === " ") { 5297 newLines[lineNumber - 1] += newLines[lineNumber].substring(1); 5298 newLines.splice(lineNumber, 1); 5299 } else { 5300 lineNumber++; 5301 } 5302 } 5303 return newLines; 5304 } 5305 class LineFeeder { 5306 constructor(content) { 5307 const lines = content.split(/\r\n|\n|\r/); 5308 this.lines = denormalizeLineLength(lines); 5309 } 5310 peek() { 5311 if (this.lines.length === 0) { 5312 return null; 5313 } 5314 return this.lines[0]; 5315 } 5316 pop() { 5317 if (this.lines.length === 0) { 5318 return null; 5319 } 5320 return this.lines.splice(0, 1)[0]; 5321 } 5322 } 5323 class RecurrenceRule { 5324 constructor() { 5325 var _values$UNTIL, _values$UNTIL2; 5326 let rule = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : undefined; 5327 _defineProperty(this, "interval", 1); 5328 _defineProperty(this, "byMonthDay", []); 5329 _defineProperty(this, "byDay", []); 5330 if (!rule) { 5331 return; 5332 } 5333 const values = {}; 5334 for (const attr of rule.split(";")) { 5335 const attrParts = attr.split("="); 5336 if (attrParts.length === 2) { 5337 values[attrParts[0]] = attrParts[1]; 5338 } 5339 } 5340 if (values["UNTIL"] !== undefined && values["COUNT"] !== undefined) { 5341 throw new Error("Recurrence rule '".concat(rule, "' cannot specify both UNTIL and COUNT.")); 5342 } 5343 if (values["FREQ"] !== "DAILY" && values["FREQ"] !== "WEEKLY" && values["FREQ"] !== "MONTHLY") { 5344 throw new Error("Invalid frequence for recurrence rule '".concat(rule, "'.")); 5345 } 5346 this.frequency = values["FREQ"]; 5347 if (((_values$UNTIL = values["UNTIL"]) === null || _values$UNTIL === void 0 ? void 0 : _values$UNTIL.length) === 8) { 5348 var _getDateFromString; 5349 this.endDate = (_getDateFromString = getDateFromString(values["UNTIL"])) !== null && _getDateFromString !== void 0 ? _getDateFromString : undefined; 5350 } else if (((_values$UNTIL2 = values["UNTIL"]) === null || _values$UNTIL2 === void 0 ? void 0 : _values$UNTIL2.length) >= 15) { 5351 var _getDateTimeFromStrin; 5352 this.endDate = (_getDateTimeFromStrin = getDateTimeFromString(values["UNTIL"])) !== null && _getDateTimeFromStrin !== void 0 ? _getDateTimeFromStrin : undefined; 5353 } 5354 if (values["COUNT"] !== undefined) { 5355 var _toNumberOrNull; 5356 this.count = (_toNumberOrNull = toNumberOrNull(values["COUNT"])) !== null && _toNumberOrNull !== void 0 ? _toNumberOrNull : undefined; 5357 } 5358 if (values["INTERVAL"] !== undefined) { 5359 var _toNumberOrNull2; 5360 this.interval = (_toNumberOrNull2 = toNumberOrNull(values["INTERVAL"])) !== null && _toNumberOrNull2 !== void 0 ? _toNumberOrNull2 : 1; 5361 } 5362 if (values["BYMONTHDAY"] !== undefined && values["BYMONTHDAY"].length > 0) { 5363 this.byMonthDay = []; 5364 for (const v of values["BYMONTHDAY"].split(",")) { 5365 const num = toNumberOrNull(v); 5366 if (num !== null) { 5367 this.byMonthDay.push(num); 5368 } 5369 } 5370 } 5371 if (values["BYDAY"] !== undefined && values["BYDAY"].length > 0) { 5372 this.byDay = []; 5373 for (const v of values["BYDAY"].split(",")) { 5374 if (v.length < 2) { 5375 continue; 5376 } 5377 const num = v.length > 2 ? toNumberOrNull(v.substring(0, v.length - 2)) : 1; 5378 const day = v.substring(v.length - 2); 5379 if (num === null) { 5380 continue; 5381 } 5382 if (day === "SU" || day === "MO" || day === "TU" || day === "WE" || day === "TH" || day === "FR" || day === "SA") { 5383 this.byDay.push({ 5384 value: num, 5385 day: getDayOfWeekFromIcalDay(day) 5386 }); 5387 } 5388 } 5389 } 5390 } 5391 build() { 5392 const attributes = []; 5393 attributes.push("FREQ=".concat(this.frequency)); 5394 if (this.count !== undefined) { 5395 attributes.push("COUNT=".concat(this.count)); 5396 } else if (this.endDate) { 5397 attributes.push("UNTIL=".concat(getDateTimeString(this.endDate))); 5398 } 5399 if (this.interval > 1) { 5400 attributes.push("INTERVAL=".concat(this.interval)); 5401 } 5402 if (this.byMonthDay.length > 0) { 5403 const monthDayValues = this.byMonthDay.map(md => md.toString()).join(","); 5404 attributes.push("BYMONTHDAY=".concat(monthDayValues)); 5405 } 5406 if (this.frequency === "MONTHLY" && this.byDay.length > 0) { 5407 const dayValues = this.byDay.map(d => "".concat(d.value).concat(getiCalDay(d.day))); 5408 attributes.push("BYDAY=".concat(dayValues)); 5409 } else if (this.byDay.length > 0) { 5410 const dayValues = this.byDay.map(d => d.value !== 1 ? "".concat(d.value).concat(getiCalDay(d.day)) : getiCalDay(d.day)); 5411 attributes.push("BYDAY=".concat(dayValues)); 5412 } 5413 return attributes.join(";"); 5414 } 5415 getDates(eventStartDateTime, startDateTime, endDateTime) { 5416 const dates = []; 5417 let rockDate = eventStartDateTime; 5418 let dateCount = 0; 5419 if (!rockDate) { 5420 return []; 5421 } 5422 if (this.endDate && this.endDate < endDateTime) { 5423 endDateTime = this.endDate; 5424 } 5425 while (rockDate < endDateTime && dateCount < 100000) { 5426 if (this.count && dateCount >= this.count) { 5427 break; 5428 } 5429 dateCount++; 5430 if (rockDate >= startDateTime) { 5431 dates.push(rockDate); 5432 } 5433 const nextDate = this.nextDateAfter(rockDate); 5434 if (nextDate === null) { 5435 break; 5436 } else { 5437 rockDate = nextDate; 5438 } 5439 } 5440 return dates; 5441 } 5442 nextDateAfter(rockDate) { 5443 if (this.frequency === "DAILY") { 5444 return rockDate.addDays(this.interval); 5445 } else if (this.frequency === "WEEKLY" && this.byDay.length > 0) { 5446 let nextDate = rockDate; 5447 if (nextDate.dayOfWeek === DayOfWeek.Saturday) { 5448 nextDate = nextDate.addDays(1 + (this.interval - 1) * 7); 5449 } else { 5450 nextDate = nextDate.addDays(1); 5451 } 5452 while (!dateMatchesDays(nextDate, this.byDay.map(d => d.day))) { 5453 if (nextDate.dayOfWeek === DayOfWeek.Saturday) { 5454 nextDate = nextDate.addDays(1 + (this.interval - 1) * 7); 5455 } else { 5456 nextDate = nextDate.addDays(1); 5457 } 5458 } 5459 return nextDate; 5460 } else if (this.frequency === "MONTHLY") { 5461 if (this.byMonthDay.length > 0) { 5462 let nextDate = rockDate.addDays(-(rockDate.day - 1)); 5463 if (rockDate.day >= this.byMonthDay[0]) { 5464 nextDate = nextDate.addMonths(this.interval); 5465 } 5466 let lastDayOfMonth = nextDate.addMonths(1).addDays(-1).day; 5467 let loopCount = 0; 5468 while (lastDayOfMonth < this.byMonthDay[0]) { 5469 nextDate = nextDate.addMonths(this.interval); 5470 lastDayOfMonth = nextDate.addMonths(1).addDays(-1).day; 5471 if (loopCount++ >= 100) { 5472 return null; 5473 } 5474 } 5475 nextDate = nextDate.addDays(this.byMonthDay[0] - 1); 5476 return nextDate; 5477 } else if (this.byDay.length > 0) { 5478 const dayOfWeek = this.byDay[0].day; 5479 const offsets = this.byDay.map(d => d.value); 5480 let nextDate = rockDate.addDays(1); 5481 while (!dateMatchesOffsetDayOfWeeks(nextDate, dayOfWeek, offsets)) { 5482 nextDate = nextDate.addDays(1); 5483 } 5484 return nextDate; 5485 } 5486 } 5487 return null; 5488 } 5489 } 5490 class Event { 5491 constructor() { 5492 let icsContent = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : undefined; 5493 _defineProperty(this, "excludedDates", []); 5494 _defineProperty(this, "recurrenceDates", []); 5495 _defineProperty(this, "recurrenceRules", []); 5496 if (icsContent === undefined) { 5497 this.uid = newGuid(); 5498 return; 5499 } 5500 let feeder; 5501 if (typeof icsContent === "string") { 5502 feeder = new LineFeeder(icsContent); 5503 } else { 5504 feeder = icsContent; 5505 } 5506 this.parse(feeder); 5507 } 5508 buildLines() { 5509 if (!this.startDateTime || !this.endDateTime) { 5510 return []; 5511 } 5512 const lines = []; 5513 lines.push("BEGIN:VEVENT"); 5514 lines.push("DTEND:".concat(getDateTimeString(this.endDateTime))); 5515 lines.push("DTSTAMP:".concat(getDateTimeString(RockDateTime.now()))); 5516 lines.push("DTSTART:".concat(getDateTimeString(this.startDateTime))); 5517 if (this.excludedDates.length > 0) { 5518 lines.push("EXDATE:".concat(this.excludedDates.map(d => getDateString(d) + "/P1D").join(","))); 5519 } 5520 if (this.recurrenceDates.length > 0) { 5521 const recurrenceDates = []; 5522 for (const date of this.recurrenceDates) { 5523 const rDate = RockDateTime.fromParts(date.year, date.month, date.day, this.startDateTime.hour, this.startDateTime.minute, this.startDateTime.second); 5524 if (rDate) { 5525 recurrenceDates.push(getDateTimeString(rDate)); 5526 } 5527 } 5528 lines.push("RDATE:".concat(recurrenceDates.join(","))); 5529 } else if (this.recurrenceRules.length > 0) { 5530 for (const rrule of this.recurrenceRules) { 5531 lines.push("RRULE:".concat(rrule.build())); 5532 } 5533 } 5534 lines.push("SEQUENCE:0"); 5535 lines.push("UID:".concat(this.uid)); 5536 lines.push("END:VEVENT"); 5537 return lines; 5538 } 5539 build() { 5540 const lines = this.buildLines(); 5541 if (lines.length === 0) { 5542 return null; 5543 } 5544 return normalizeLineLength(lines).join("\r\n"); 5545 } 5546 parse(feeder) { 5547 let line; 5548 if (feeder.peek() !== "BEGIN:VEVENT") { 5549 throw new Error("Invalid event."); 5550 } 5551 feeder.pop(); 5552 while ((line = feeder.pop()) !== null) { 5553 if (line === "END:VEVENT") { 5554
5554 break; 5555 } 5556 const splitAt = line.indexOf(":"); 5557 if (splitAt < 0) { 5558 continue; 5559 } 5560 let key = line.substring(0, splitAt); 5561 const value = line.substring(splitAt + 1); 5562 const keyAttributes = {}; 5563 const keySegments = key.split(";"); 5564 if (keySegments.length > 1) { 5565 key = keySegments[0]; 5566 keySegments.splice(0, 1); 5567 for (const attr of keySegments) { 5568 const attrSegments = attr.split("="); 5569 if (attr.length === 2) { 5570 keyAttributes[attrSegments[0]] = attrSegments[1]; 5571 } 5572 } 5573 } 5574 if (key === "DTSTART") { 5575 var _getDateTimeFromStrin2; 5576 this.startDateTime = (_getDateTimeFromStrin2 = getDateTimeFromString(value)) !== null && _getDateTimeFromStrin2 !== void 0 ? _getDateTimeFromStrin2 : undefined; 5577 } else if (key === "DTEND") { 5578 var _getDateTimeFromStrin3; 5579 this.endDateTime = (_getDateTimeFromStrin3 = getDateTimeFromString(value)) !== null && _getDateTimeFromStrin3 !== void 0 ? _getDateTimeFromStrin3 : undefined; 5580 } else if (key === "RRULE") { 5581 this.recurrenceRules.push(new RecurrenceRule(value)); 5582 } else if (key === "RDATE") { 5583 this.recurrenceDates = getRecurrenceDates(keyAttributes, value); 5584 } else if (key === "UID") { 5585 this.uid = value; 5586 } else if (key === "DURATION") ; else if (key === "EXDATE") { 5587 const dateValues = value.split(","); 5588 for (const dateValue of dateValues) { 5589 const dates = getDatesFromRangeOrPeriod(dateValue); 5590 this.excludedDates.push(...dates); 5591 } 5592 } 5593 } 5594 } 5595 isDateExcluded(rockDate) { 5596 const rockDateOnly = rockDate.date; 5597 for (const excludedDate of this.excludedDates) { 5598 if (excludedDate.date.isEqualTo(rockDateOnly)) { 5599 return true; 5600 } 5601 } 5602 return false; 5603 } 5604 getDates(startDateTime, endDateTime) { 5605 if (!this.startDateTime) { 5606 return []; 5607 } 5608 if (this.startDateTime > startDateTime) { 5609 startDateTime = this.startDateTime; 5610 } 5611 if (this.recurrenceDates.length > 0) { 5612 const dates = []; 5613 const recurrenceDates = [this.startDateTime, ...this.recurrenceDates]; 5614 for (const date of recurrenceDates) { 5615 if (date >= startDateTime && date < endDateTime) { 5616 dates.push(date); 5617 } 5618 } 5619 return dates; 5620 } else if (this.recurrenceRules.length > 0) { 5621 const rrule = this.recurrenceRules[0]; 5622 return rrule.getDates(this.startDateTime, startDateTime, endDateTime).filter(d => !this.isDateExcluded(d)); 5623 } else { 5624 if (this.startDateTime >= startDateTime && this.startDateTime < endDateTime) { 5625 return [this.startDateTime]; 5626 } 5627 return []; 5628 } 5629 } 5630 toFriendlyText() { 5631 return this.toFriendlyString(false); 5632 } 5633 toFriendlyHtml() { 5634 return this.toFriendlyString(true); 5635 } 5636 toFriendlyString(html) { 5637 if (!this.startDateTime) { 5638 return ""; 5639 } 5640 const startTimeText = this.startDateTime.toLocaleString({ 5641 hour: "numeric", 5642 minute: "2-digit", 5643 hour12: true 5644 }); 5645 if (this.recurrenceRules.length > 0) { 5646 const rrule = this.recurrenceRules[0]; 5647 if (rrule.frequency === "DAILY") { 5648 let result = "Daily"; 5649 if (rrule.interval > 1) { 5650 result += " every ".concat(rrule.interval, " ").concat(pluralConditional(rrule.interval, "day", "days")); 5651 } 5652 result += " at ".concat(startTimeText); 5653 return result; 5654 } else if (rrule.frequency === "WEEKLY") { 5655 if (rrule.byDay.length === 0) { 5656 return "No Scheduled Days"; 5657 } 5658 let result = rrule.byDay.map(d => getWeekdayName(d.day) + "s").join(","); 5659 if (rrule.interval > 1) { 5660 result = "Every ".concat(rrule.interval, " weeks: ").concat(result); 5661 } else { 5662 result = "Weekly: ".concat(result); 5663 } 5664 return "".concat(result, " at ").concat(startTimeText); 5665 } else if (rrule.frequency === "MONTHLY") { 5666 if (rrule.byMonthDay.length > 0) { 5667 let result = "Day ".concat(rrule.byMonthDay[0], " of every "); 5668 if (rrule.interval > 1) { 5669 result += "".concat(rrule.interval, " months"); 5670 } else { 5671 result += "month"; 5672 } 5673 return "".concat(result, " at ").concat(startTimeText); 5674 } else if (rrule.byDay.length > 0) { 5675 const byDay = rrule.byDay[0]; 5676 const offsetNames = nthNamesAbbreviated.filter(n => rrule.byDay.some(d => d.value === n[0])).map(n => n[1]); 5677 let result = ""; 5678 if (offsetNames.length > 0) { 5679 let nameText; 5680 if (offsetNames.length > 2) { 5681 nameText = "".concat(offsetNames.slice(0, offsetNames.length - 1).join(", "), " and ").concat(offsetNames[offsetNames.length - 1]); 5682 } else { 5683 nameText = offsetNames.join(" and "); 5684 } 5685 result = "The ".concat(nameText, " ").concat(getWeekdayName(byDay.day), " of every month"); 5686 } else { 5687 return ""; 5688 } 5689 return "".concat(result, " at ").concat(startTimeText); 5690 } else { 5691 return ""; 5692 } 5693 } else { 5694 return ""; 5695 } 5696 } else { 5697 const dates = [this.startDateTime, ...this.recurrenceDates]; 5698 if (dates.length === 1) { 5699 return "Once at ".concat(this.startDateTime.toASPString("g")); 5700 } else if (!html || dates.length > 99) { 5701 const firstDate = dates[0]; 5702 const lastDate = dates[dates.length - 1]; 5703 if (firstDate && lastDate) { 5704 return "Multiple dates between ".concat(firstDate.toASPString("g"), " and ").concat(lastDate.toASPString("g")); 5705 } else { 5706 return ""; 5707 } 5708 } else if (dates.length > 1) { 5709 let listHtml = "<ul class=\"list-unstyled\">"; 5710 for (const date of dates) { 5711 listHtml += "<li>".concat(date.toASPString("g"), "</li>"); 5712 } 5713 listHtml += "</li>"; 5714 return listHtml; 5715 } else { 5716 return "No Schedule"; 5717 } 5718 } 5719 } 5720 } 5721 class Calendar { 5722 constructor() { 5723 let icsContent = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : undefined; 5724 _defineProperty(this, "events", []); 5725 if (icsContent === undefined) { 5726 return; 5727 } 5728 const feeder = new LineFeeder(icsContent); 5729 this.parse(feeder); 5730 } 5731 build() { 5732 const lines = []; 5733 lines.push("BEGIN:VCALENDAR"); 5734 lines.push("PRODID:-//github.com/SparkDevNetwork/Rock//NONSGML Rock//EN"); 5735 lines.push("VERSION:2.0"); 5736 for (const event of this.events) { 5737 lines.push(...event.buildLines()); 5738 } 5739 lines.push("END:VCALENDAR"); 5740 return denormalizeLineLength(lines).join("\r\n"); 5741 } 5742 parse(feeder) { 5743 let line; 5744 while ((line = feeder.peek()) !== null) { 5745 if (line === "BEGIN:VEVENT") { 5746 const event = new Event(feeder); 5747 this.events.push(event); 5748 } else { 5749 feeder.pop(); 5750 } 5751 } 5752 } 5753 } 5754 5755 var internetCalendar = /*#__PURE__*/Object.freeze({ 5756 __proto__: null, 5757 Calendar: Calendar, 5758 Event: Event, 5759 RecurrenceRule: RecurrenceRule 5760 }); 5761 exports('internetCalendar', internetCalendar); 5762 5763 function safeParseJson(value) { 5764 if (!value) { 5765 return undefined; 5766 } 5767 try { 5768 return JSON.parse(value); 5769 } catch (_unused) { 5770 return undefined; 5771 } 5772 } 5773 5774 var jsonUtils = /*#__PURE__*/Object.freeze({ 5775 __proto__: null, 5776 safeParseJson: safeParseJson 5777 }); 5778 exports('jsonUtils', jsonUtils); 5779 5780 const engine = new Liquid({ 5781 cache: true 5782 }); 5783 const hasLavaCommandFieldsRegex = /\{%.+%\}/; 5784 const hasLavaShortcodeFieldsRegex = /\{\[.+\]\}/; 5785 const hasLavaVariableFieldsRegex = /\{\{\s*[^}}]+\s*\}\}/; 5786 function resolveMergeFields(template, mergeFields) { 5787 const tpl = engine.parse(template); 5788 return engine.renderSync(tpl, mergeFields); 5789 } 5790 function hasLavaVariableFields(template) { 5791 return hasLavaVariableFieldsRegex.test(template); 5792 } 5793 function hasLavaCommandFields(template) { 5794 return hasLavaCommandFieldsRegex.test(template); 5795 } 5796 function hasLavaShortcodeFields(template) { 5797 return hasLavaShortcodeFieldsRegex.test(template); 5798 } 5799 5800 var lava = /*#__PURE__*/Object.freeze({ 5801 __proto__: null, 5802 hasLavaCommandFields: hasLavaCommandFields, 5803 hasLavaShortcodeFields: hasLavaShortcodeFields, 5804 hasLavaVariableFields: hasLavaVariableFields, 5805 resolveMergeFields: resolveMergeFields 5806 }); 5807 exports('lava', lava); 5808 5809 const crossSiteForgeryHeaderKey = "X-Helix-CSRF-Protection"; 5810 const routeVersion = "1"; 5811 async function invokeEndpoint(applicationSlug, endpointSlug, data, options, parentTrace) { 5812 var _options$method; 5813 const method = (_options$method = options === null || options === void 0 ? void 0 : options.method) !== null && _options$method !== void 0 ? _options$method : "POST"; 5814 const url = "/api/v2/lava-app/".concat(routeVersion, "/").concat(applicationSlug, "/").concat(endpointSlug); 5815 const headers = { 5816 [crossSiteForgeryHeaderKey]: "true" 5817 }; 5818 if (parentTrace) { 5819 headers["traceparent"] = parentTrace; 5820 } 5821 const result = await doApiCall(method, url, method === "GET" ? data : undefined, method === "GET" ? undefined : data, { 5822 headers 5823 }); 5824 if (typeof result.data === "string") { 5825 try {
5826 return _objectSpread2(_objectSpread2({}, result), {}, { 5827 data: JSON.parse(result.data) 5828 }); 5829 } catch (e) { 5830 return { 5831 statusCode: result.statusCode, 5832 data: null, 5833 isSuccess: false, 5834 isError: true, 5835 errorMessage: "The response from the '".concat(endpointSlug, "' endpoint was not valid JSON: ").concat(e) 5836 }; 5837 } 5838 } 5839 return result; 5840 } 5841 function useLavaApp(applicationSlug) { 5842 const parentTrace = inject("blockParentTrace", null); 5843 return { 5844 invoke: (endpointSlug, data, options) => { 5845 return invokeEndpoint(applicationSlug, endpointSlug, data, options, parentTrace); 5846 } 5847 }; 5848 } 5849 5850 var lavaApp = /*#__PURE__*/Object.freeze({ 5851 __proto__: null, 5852 useLavaApp: useLavaApp 5853 }); 5854 exports('lavaApp', lavaApp); 5855 5856 function asListItemBagOrNull(bagJson) { 5857 try { 5858 const val = JSON.parse(bagJson); 5859 if ("value" in val || "text" in val) { 5860 return val; 5861 } 5862 return null; 5863 } catch (e) { 5864 return null; 5865 } 5866 } 5867 5868 var listItemBag = /*#__PURE__*/Object.freeze({ 5869 __proto__: null, 5870 asListItemBagOrNull: asListItemBagOrNull 5871 }); 5872 exports('listItemBag', listItemBag); 5873 5874 async function formatValue(value) { 5875 const http = useHttp(); 5876 const options = { 5877 selectedValue: value 5878 }; 5879 const response = await http.post("/api/v2/Controls/MergeFieldPickerFormatSelectedValue", {}, options); 5880 if (response.isSuccess && response.data) { 5881 return response.data; 5882 } else { 5883 console.error("Error", response.errorMessage || "Error formatting '".concat(value, "'.")); 5884 return ""; 5885 } 5886 } 5887 5888 var mergeField = /*#__PURE__*/Object.freeze({ 5889 __proto__: null, 5890 formatValue: formatValue 5891 }); 5892 exports('mergeField', mergeField); 5893 5894 function fromEntries(entries) { 5895 const res = {}; 5896 for (const entry of entries) { 5897 res[entry[0]] = entry[1]; 5898 } 5899 return res; 5900 } 5901 function clone(obj) { 5902 return JSON.parse(JSON.stringify(obj)); 5903 } 5904 function toListItemBagList(obj) { 5905 return Object.entries(obj).map(_ref => { 5906 let [key, value] = _ref; 5907 return { 5908 text: key, 5909 value: "".concat(value) 5910 }; 5911 }); 5912 } 5913 function getValueFromPath(object, path) { 5914 if (!object || !path) { 5915 return; 5916 } 5917 const pathNames = path.split("."); 5918 for (let i = 0; i < pathNames.length; i++) { 5919 const pathName = pathNames[i].trim(); 5920 if (!pathName || !Object.prototype.hasOwnProperty.call(object, pathName)) { 5921 return; 5922 } 5923 const value = object[pathName]; 5924 if (i === pathNames.length - 1) { 5925 return value; 5926 } 5927 if (typeof value !== "object") { 5928 return; 5929 } 5930 object = value; 5931 } 5932 return; 5933 } 5934 function getTypeMemberName(memberName) { 5935 return memberName; 5936 } 5937 function useGetTypeMemberName() { 5938 return memberName => { 5939 return getTypeMemberName(memberName); 5940 }; 5941 } 5942 5943 var objectUtils = /*#__PURE__*/Object.freeze({ 5944 __proto__: null, 5945 clone: clone, 5946 fromEntries: fromEntries, 5947 getTypeMemberName: getTypeMemberName, 5948 getValueFromPath: getValueFromPath, 5949 toListItemBagList: toListItemBagList, 5950 useGetTypeMemberName: useGetTypeMemberName 5951 }); 5952 exports('objectUtils', objectUtils); 5953 5954 async function fetchPhoneNumberConfiguration() { 5955 var _result$errorMessage; 5956 const http = useHttp(); 5957 const result = await http.post("/api/v2/Controls/PhoneNumberBoxGetConfiguration", undefined, null); 5958 if (result.isSuccess && result.data) { 5959 return result.data; 5960 } 5961 throw new Error((_result$errorMessage = result.errorMessage) !== null && _result$errorMessage !== void 0 ? _result$errorMessage : "Error fetching phone number configuration"); 5962 } 5963 async function fetchPhoneNumberAndSmsConfiguration() { 5964 var _result$errorMessage2;
5965 const http = useHttp(); 5966 const options = { 5967 showSmsOptIn: true 5968 }; 5969 const result = await http.post("/api/v2/Controls/PhoneNumberBoxGetConfiguration", undefined, options); 5970 if (result.isSuccess && result.data) { 5971 return result.data; 5972 } 5973 throw new Error((_result$errorMessage2 = result.errorMessage) !== null && _result$errorMessage2 !== void 0 ? _result$errorMessage2 : "Error fetching phone number configuration"); 5974 } 5975 const getPhoneNumberConfiguration = Cache.cachePromiseFactory("phoneNumberConfiguration", fetchPhoneNumberConfiguration); 5976 const getPhoneNumberAndSmsConfiguration = Cache.cachePromiseFactory("phoneNumberAndSmsConfiguration", fetchPhoneNumberAndSmsConfiguration); 5977 const defaultRulesConfig = [{ 5978 "match": "^(\\d{3})(\\d{4})$", 5979 "format": "$1-$2" 5980 }, { 5981 "match": "^(\\d{3})(\\d{3})(\\d{4})$", 5982 "format": "($1) $2-$3" 5983 }, { 5984 "match": "^1(\\d{3})(\\d{3})(\\d{4})$", 5985 "format": "($1) $2-$3" 5986 }]; 5987 function formatPhoneNumber(value) { 5988 let rules = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultRulesConfig; 5989 value = stripPhoneNumber(value); 5990 if (!value || rules.length === 0) { 5991 return value; 5992 } 5993 for (const rule of rules) { 5994 var _rule$match; 5995 const regex = new RegExp((_rule$match = rule.match) !== null && _rule$match !== void 0 ? _rule$match : ""); 5996 if (regex.test(value)) { 5997 var _rule$format; 5998 return value.replace(regex, (_rule$format = rule.format) !== null && _rule$format !== void 0 ? _rule$format : "") || value; 5999 } 6000 } 6001 return value; 6002 } 6003 function stripPhoneNumber(str) { 6004 if (!str) { 6005 return ""; 6006 } 6007 return str.replace(/\D/g, ""); 6008 } 6009 var phone = { 6010 getPhoneNumberConfiguration, 6011 formatPhoneNumber, 6012 stripPhoneNumber 6013 }; 6014 window.formatPhoneNumber = formatPhoneNumber; 6015 6016 var phone$1 = /*#__PURE__*/Object.freeze({ 6017 __proto__: null, 6018 default: phone, 6019 formatPhoneNumber: formatPhoneNumber, 6020 getPhoneNumberAndSmsConfiguration: getPhoneNumberAndSmsConfiguration, 6021 getPhoneNumberConfiguration: getPhoneNumberConfiguration, 6022 stripPhoneNumber: stripPhoneNumber 6023 }); 6024 exports('phone', phone$1); 6025 6026 function popover(node, options) { 6027 var _options$sanitize; 6028 if (Array.isArray(node)) { 6029 for (const n of node) { 6030 popover(n, options); 6031 } 6032 return; 6033 } 6034 $(node).popover({ 6035 html: options === null || options === void 0 ? void 0 : options.html, 6036 sanitize: (_options$sanitize = options === null || options === void 0 ? void 0 : options.sanitize) !== null && _options$sanitize !== void 0 ? _options$sanitize : true 6037 }); 6038 } 6039 6040 var popover$1 = /*#__PURE__*/Object.freeze({ 6041 __proto__: null, 6042 popover: popover 6043 }); 6044 exports('popover', popover$1); 6045 6046 function sleep(ms) { 6047 return new Promise(resolve => { 6048 setTimeout(resolve, ms); 6049 }); 6050 } 6051 function isPromise(obj) { 6052 return !!obj && (typeof obj === "object" || typeof obj === "function") && typeof obj.then === "function"; 6053 } 6054 class PromiseCompletionSource { 6055 constructor() { 6056 _defineProperty(this, "internalResolve", () => {}); 6057 _defineProperty(this, "internalReject", () => {}); 6058 this.internalPromise = new Promise((resolve, reject) => { 6059 this.internalResolve = resolve; 6060 this.internalReject = reject; 6061 }); 6062 } 6063 get promise() { 6064 return this.internalPromise; 6065 } 6066 resolve(value) { 6067 this.internalResolve(value); 6068 } 6069 reject(reason) { 6070 this.internalReject(reason); 6071 } 6072 } 6073 6074 var promiseUtils = /*#__PURE__*/Object.freeze({ 6075 __proto__: null, 6076 PromiseCompletionSource: PromiseCompletionSource, 6077 isPromise: isPromise, 6078 sleep: sleep 6079 }); 6080 exports('promiseUtils', promiseUtils); 6081 6082 let libraryObject = null; 6083 let libraryPromise = null; 6084 async function getRealTimeObject() { 6085 var _window$Rock2; 6086 if (libraryObject) { 6087 return libraryObject; 6088 } 6089 if (!libraryPromise) { 6090 libraryPromise = loadJavaScriptAsync("/Scripts/Rock/realtime.js", () => { 6091 var _window$Rock; 6092 return !!((_window$Rock = window["Rock"]) !== null && _window$Rock !== void 0 && _window$Rock["RealTime"]); 6093 }); 6094 } 6095 if (!(await libraryPromise)) { 6096 throw new Error("Unable to load RealTime library."); 6097 } 6098 libraryObject = (_window$Rock2 = window["Rock"]) === null || _window$Rock2 === void 0 ? void 0 : _window$Rock2["RealTime"]; 6099 return libraryObject; 6100 } 6101 async function getTopic(identifier) { 6102 const realTime = await getRealTimeObject(); 6103 return realTime.getTopic(identifier); 6104 } 6105 6106 var realTime = /*#__PURE__*/Object.freeze({ 6107 __proto__: null, 6108 getTopic: getTopic 6109 }); 6110 exports('realTime', realTime); 6111 6112 const regexPatterns = { 6113 specialCharacterPattern: /[({[\]})"]/, 6114 emojiPattern: /(?:[\u2600-\u27BF]|\uD83C[\uDC00-\uDFFF]|\uD83D[\uDC00-\uDEFF]|\uD83E[\uDD00-\uDDFF])/, 6115 specialFontPattern: /(?:\uD835[\uDC00-\uDFFF]|\uD83C[\uDD00-\uDDFF])/ 6116 }; 6117 const getSpecialCharacterPattern = () => regexPatterns.specialCharacterPattern; 6118 const getEmojiPattern = () => regexPatterns.emojiPattern; 6119 const getSpecialFontPattern = () => regexPatterns.specialFontPattern; 6120 6121 var regexPatterns$1 = /*#__PURE__*/Object.freeze({ 6122 __proto__: null, 6123 getEmojiPattern: getEmojiPattern, 6124 getSpecialCharacterPattern: getSpecialCharacterPattern, 6125 getSpecialFontPattern: getSpecialFontPattern, 6126 regexPatterns: regexPatterns 6127 }); 6128 exports('regexPatterns', regexPatterns$1); 6129 6130 class RockCurrency { 6131 get isZero() { 6132 return this.big.eq(0); 6133 } 6134 get number() { 6135 return this.big.toNumber(); 6136 } 6137 get isNegative() { 6138 return this.big.lt(0); 6139 } 6140 get units() { 6141 return this.big.times(new Big(10).pow(this.currencyInfo.decimalPlaces)).toNumber(); 6142 } 6143 constructor(value, currencyInfo) { 6144 this.currencyInfo = currencyInfo; 6145 if (value instanceof RockCurrency) { 6146 this.big = new Big(value.big).round(this.currencyInfo.decimalPlaces, Big.roundDown); 6147 } else { 6148 this.big = new Big(value !== null && value !== void 0 ? value : 0).round(this.currencyInfo.decimalPlaces, Big.roundDown); 6149 } 6150 } 6151 static create(value, currencyInfo) { 6152 return new RockCurrency(value, currencyInfo); 6153 } 6154 asRockCurrency(value) { 6155 return value instanceof RockCurrency ? value : new RockCurrency(value, this.currencyInfo); 6156 } 6157 add(value) { 6158 const currency = this.asRockCurrency(value); 6159 return new RockCurrency(this.big.plus(currency.big), this.currencyInfo); 6160 } 6161 negate() { 6162 return new RockCurrency(this.big.neg(), this.currencyInfo); 6163 } 6164 divide(divisor) { 6165 const quotient = this.big.div(divisor).round(this.currencyInfo.decimalPlaces, Big.roundDown); 6166 const remainder = this.big.minus(quotient.times(divisor)); 6167 return { 6168 quotient: new RockCurrency(quotient, this.currencyInfo), 6169 remainder: new RockCurrency(remainder, this.currencyInfo) 6170 }; 6171 } 6172 subtract(value) { 6173 const currency = this.asRockCurrency(value); 6174 return new RockCurrency(this.big.minus(currency.big), this.currencyInfo); 6175 } 6176 isEqualTo(value) { 6177 const currency = this.asRockCurrency(value); 6178 return this.big.eq(currency.big); 6179 } 6180 isNotEqualTo(value) { 6181 const currency = this.asRockCurrency(value); 6182 return !this.big.eq(currency.big); 6183 } 6184 isLessThan(value) { 6185 const currency = this.asRockCurrency(value); 6186 return this.big.lt(currency.big); 6187 } 6188 isLessThanOrEqualTo(value) { 6189 const currency = this.asRockCurrency(value); 6190 return this.big.lte(currency.big); 6191 } 6192 noLessThan(value) { 6193 const currency = this.asRockCurrency(value); 6194 if (this.big.lt(currency.big)) { 6195 return new RockCurrency(currency.big, this.currencyInfo); 6196 } else { 6197 return this; 6198 } 6199 } 6200 isGreaterThan(value) { 6201 const limit = this.asRockCurrency(value); 6202 return this.big.gt(limit.big); 6203 } 6204 noGreaterThan(value) { 6205 const currency = this.asRockCurrency(value); 6206 if (this.big.gt(currency.big)) { 6207 return currency; 6208 } else { 6209 return this; 6210 } 6211 } 6212 abs() { 6213 return new RockCurrency(this.big.abs(), this.currencyInfo); 6214 } 6215 mod(divisor) { 6216 const { 6217 remainder 6218 } = this.divide(divisor); 6219 return remainder; 6220 } 6221 format() { 6222 let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null; 6223 if (options !== null && options !== void 0 && options.excludeGroupingSeparators) { 6224 const valueString = this.big.toFixed(this.currencyInfo.decimalPlaces, Big.roundDown); 6225 return "".concat(this.currencyInfo.symbol).concat(valueString); 6226 } 6227 return this.toString(); 6228 } 6229 toString() { 6230 var _toCurrencyOrNull; 6231 const valueString = this.big.toFixed(this.currencyInfo.decimalPlaces, Big.roundDown); 6232 return (_toCurrencyOrNull = toCurrencyOrNull(valueString, this.currencyInfo)) !== null && _toCurrencyOrNull !== void 0 ? _toCurrencyOrNull : "".concat(this.currencyInfo.symbol).concat(valueString); 6233 } 6234 } 6235 6236 var rockCurrency = /*#__PURE__*/Object.freeze({ 6237 __proto__: null, 6238 RockCurrency: RockCurrency 6239 }); 6240 exports('rockCurrency', rockCurrency); 6241 6242 class RockTimeSpan { 6243 constructor(_milliseconds) { 6244 this._milliseconds = _milliseconds; 6245 this._milliseconds = Math.abs(_milliseconds); 6246 } 6247 static fromMilliseconds(milliseconds) { 6248 return new RockTimeSpan(milliseconds); 6249 } 6250 static fromSeconds(seconds) { 6251 return new RockTimeSpan(seconds * 1000); 6252 } 6253 static fromMinutes(minutes) { 6254 return new RockTimeSpan(minutes * 60 * 1000); 6255 } 6256 static fromHours(hours) { 6257 return new RockTimeSpan(hours * 60 * 60 * 1000); 6258 } 6259 static fromDays(days) { 6260 return new RockTimeSpan(days * 24 * 60 * 60 * 1000); 6261 } 6262 get totalMilliseconds() { 6263 return this._milliseconds; 6264 } 6265 get totalSeconds() { 6266 return this._milliseconds / 1000; 6267 } 6268 get totalMinutes() { 6269 return this._milliseconds / (60 * 1000); 6270 } 6271 get totalHours() { 6272 return this._milliseconds / (60 * 60 * 1000); 6273 } 6274 get totalDays() { 6275 return this._milliseconds / (24 * 60 * 60 * 1000); 6276 } 6277 get approximatedTotalMonths() { 6278 const msPerMonth = 31 * 24 * 60 * 60 * 1000; 6279 return this._milliseconds / msPerMonth; 6280 } 6281 get milliseconds() { 6282 return this._milliseconds % 1000; 6283 } 6284 get seconds() { 6285 return Math.floor(this._milliseconds / 1000 % 60); 6286 } 6287 get minutes() { 6288 return Math.floor(this._milliseconds / (60 * 1000) % 60); 6289 } 6290 get hours() { 6291 return Math.floor(this._milliseconds / (60 * 60 * 1000) % 24); 6292 } 6293 get days() { 6294 return Math.floor(this._milliseconds / (24 * 60 * 60 * 1000)); 6295 } 6296 toElapsedString() { 6297 const daysPerYear = 365; 6298 const totalHours = this.totalHours; 6299 const totalSeconds = this.totalSeconds; 6300 const totalMinutes = this.totalMinutes; 6301 const totalDays = this.totalDays; 6302 const approximatedTotalMonths = this.approximatedTotalMonths; 6303 if (totalHours < 24) { 6304 if (totalSeconds < 1) {
6305 return "".concat(0 .toLocaleString(undefined), " Seconds"); 6306 } 6307 if (totalSeconds < 2) { 6308 return "".concat(1 .toLocaleString(undefined), " Second"); 6309 } 6310 if (totalSeconds < 60) { 6311 return "".concat(Math.floor(totalSeconds).toLocaleString(undefined), " Seconds"); 6312 } 6313 if (totalMinutes < 2) { 6314 return "".concat(1 .toLocaleString(undefined), " Minute"); 6315 } 6316 if (totalMinutes < 60) { 6317 return "".concat(Math.floor(totalMinutes).toLocaleString(undefined), " Minutes"); 6318 } 6319 if (totalHours < 2) { 6320 return "".concat(1 .toLocaleString(undefined), " Hour"); 6321 } 6322 if (totalHours < 60) { 6323 return "".concat(Math.floor(totalHours).toLocaleString(undefined), " Hours"); 6324 } 6325 } 6326 if (totalDays < 2) { 6327 return "".concat(1 .toLocaleString(undefined), " Day"); 6328 } 6329 if (totalDays < 31) { 6330 return "".concat(Math.floor(totalDays).toLocaleString(undefined), " Days"); 6331 } 6332 if (approximatedTotalMonths <= 1) { 6333 return "".concat(1 .toLocaleString(undefined), " Month"); 6334 } 6335 if (approximatedTotalMonths <= 18) { 6336 return "".concat(Math.round(approximatedTotalMonths).toLocaleString(undefined), " Months"); 6337 } 6338 const totalYears = Math.floor(totalDays / daysPerYear); 6339 if (totalYears <= 1) { 6340 return "".concat(1 .toLocaleString(undefined), " Year"); 6341 } 6342 return "".concat(Math.round(totalYears).toLocaleString(undefined), " Years"); 6343 } 6344 } 6345 6346 var rockTimeSpan = /*#__PURE__*/Object.freeze({ 6347 __proto__: null, 6348 RockTimeSpan: RockTimeSpan 6349 }); 6350 exports('rockTimeSpan', rockTimeSpan); 6351 6352 function useScreenSize() { 6353 let mobileThreshold = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 480; 6354 const isMobile = ref(false); 6355 const screenSize = ref(screen.width); 6356 function onResize() { 6357 screenSize.value = screen.width; 6358 if (screen.width <= mobileThreshold) { 6359 isMobile.value = true; 6360 } else { 6361 isMobile.value = false; 6362 } 6363 } 6364 onMounted(() => { 6365 nextTick(() => { 6366 onResize(); 6367 }); 6368 window.addEventListener("resize", onResize); 6369 }); 6370 onUnmounted(() => { 6371 window.removeEventListener("resize", onResize); 6372 }); 6373 return { 6374 isMobile, 6375 screenSize 6376 }; 6377 } 6378 function useViewportWidth() { 6379 let mobileThreshold = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 480; 6380 const isMobile = ref(false); 6381 const viewportWidth = ref(window.innerWidth); 6382 function onResize() { 6383 viewportWidth.value = window.innerWidth; 6384 isMobile.value = viewportWidth.value <= mobileThreshold; 6385 } 6386 onMounted(() => { 6387 nextTick(() => { 6388 onResize(); 6389 }); 6390 window.addEventListener("resize", onResize); 6391 }); 6392 onUnmounted(() => { 6393 window.removeEventListener("resize", onResize); 6394 }); 6395 return { 6396 isMobile, 6397 viewportWidth: viewportWidth 6398 }; 6399 } 6400 6401 var screenSize = /*#__PURE__*/Object.freeze({ 6402 __proto__: null, 6403 useScreenSize: useScreenSize, 6404 useViewportWidth: useViewportWidth 6405 }); 6406 exports('screenSize', screenSize); 6407 6408 const rangeTypeOptions = [{ 6409 value: SlidingDateRangeType.Current.toString(), 6410 text: "Current" 6411 }, { 6412 value: SlidingDateRangeType.Previous.toString(), 6413 text: "Previous" 6414 }, { 6415 value: SlidingDateRangeType.Last.toString(), 6416 text: "Last" 6417 }, { 6418 value: SlidingDateRangeType.Next.toString(), 6419 text: "Next" 6420 }, { 6421 value: SlidingDateRangeType.Upcoming.toString(), 6422 text: "Upcoming" 6423 }, { 6424 value: SlidingDateRangeType.DateRange.toString(), 6425 text: "Date Range" 6426 }]; 6427 const timeUnitOptions = [{ 6428 value: TimeUnitType.Hour.toString(), 6429 text: "Hour" 6430 }, { 6431 value: TimeUnitType.Day.toString(), 6432 text: "Day" 6433 }, { 6434 value: TimeUnitType.Week.toString(), 6435 text: "Week" 6436 }, { 6437 value: TimeUnitType.Month.toString(), 6438 text: "Month" 6439 }, { 6440 value: TimeUnitType.Year.toString(), 6441 text: "Year" 6442 }]; 6443 function getTextForValue(value, options) { 6444 var _matches$0$text; 6445 const matches = options.filter(v => v.value === value); 6446 return matches.length > 0 ? (_matches$0$text = matches[0].text) !== null && _matches$0$text !== void 0 ? _matches$0$text : "" : ""; 6447 } 6448 function getRangeTypeText(rangeType) { 6449 var _rangeTypes$0$text; 6450 const rangeTypes = rangeTypeOptions.filter(o => o.value === rangeType.toString()); 6451 return rangeTypes.length > 0 ? (_rangeTypes$0$text = rangeTypes[0].text) !== null && _rangeTypes$0$text !== void 0 ? _rangeTypes$0$text : "" : ""; 6452 } 6453 function getTimeUnitText(timeUnit) { 6454 var _timeUnits$0$text; 6455 const timeUnits = timeUnitOptions.filter(o => o.value === timeUnit.toString()); 6456 return timeUnits.length > 0 ? (_timeUnits$0$text = timeUnits[0].text) !== null && _timeUnits$0$text !== void 0 ? _timeUnits$0$text : "" : ""; 6457 } 6458 function parseSlidingDateRangeString(value) { 6459 const segments = value.split("|"); 6460 if (segments.length < 3) { 6461 return null; 6462 } 6463 const rangeTypes = rangeTypeOptions.filter(o => { 6464 var _o$text; 6465 return ((_o$text = o.text) !== null && _o$text !== void 0 ? _o$text : "").replace(" ", "").toLowerCase() === segments[0].toLowerCase() || o.value === segments[0]; 6466 }); 6467 const timeUnits = timeUnitOptions.filter(o => { 6468 var _o$text2; 6469 return ((_o$text2 = o.text) !== null && _o$text2 !== void 0 ? _o$text2 : "").toLowerCase() === segments[2].toLowerCase() || o.value === segments[2]; 6470 }); 6471 if (rangeTypes.length === 0) { 6472 return null; 6473 } 6474 const range = { 6475 rangeType: toNumber(rangeTypes[0].value) 6476 }; 6477 if ([SlidingDateRangeType.Current, SlidingDateRangeType.Last, SlidingDateRangeType.Next, SlidingDateRangeType.Previous, SlidingDateRangeType.Upcoming].includes(range.rangeType)) { 6478 range.timeUnit = timeUnits.length > 0 ? toNumber(timeUnits[0].value) : TimeUnitType.Hour; 6479 if ([SlidingDateRangeType.Last, SlidingDateRangeType.Next, SlidingDateRangeType.Previous, SlidingDateRangeType.Upcoming].includes(range.rangeType)) { 6480 var _toNumberOrNull; 6481 range.timeValue = (_toNumberOrNull = toNumberOrNull(segments[1])) !== null && _toNumberOrNull !== void 0 ? _toNumberOrNull : 1; 6482 } 6483 } 6484 if (range.rangeType === SlidingDateRangeType.DateRange) { 6485 if (segments.length > 3) { 6486 var _RockDateTime$fromJSD, _RockDateTime$fromJSD2; 6487 range.lowerDate = (_RockDateTime$fromJSD = (_RockDateTime$fromJSD2 = RockDateTime.fromJSDate(new Date(segments[3]))) === null || _RockDateTime$fromJSD2 === void 0 || (_RockDateTime$fromJSD2 = _RockDateTime$fromJSD2.toOffset(0)) === null || _RockDateTime$fromJSD2 === void 0 ? void 0 : _RockDateTime$fromJSD2.toASPString("yyyy-MM-dd")) !== null && _RockDateTime$fromJSD !== void 0 ? _RockDateTime$fromJSD : ""; 6488 } 6489 if (segments.length > 4) { 6490 var _RockDateTime$fromJSD3, _RockDateTime$fromJSD4; 6491 range.upperDate = (_RockDateTime$fromJSD3 = (_RockDateTime$fromJSD4 = RockDateTime.fromJSDate(new Date(segments[4]))) === null || _RockDateTime$fromJSD4 === void 0 || (_RockDateTime$fromJSD4 = _RockDateTime$fromJSD4.toOffset(0)) === null || _RockDateTime$fromJSD4 === void 0 ? void 0 : _RockDateTime$fromJSD4.toASPString("yyyy-MM-dd")) !== null && _RockDateTime$fromJSD3 !== void 0 ? _RockDateTime$fromJSD3 : ""; 6492 } 6493 } 6494 return range; 6495 } 6496 function slidingDateRangeToString(value) { 6497 var _value$timeUnit$toStr, _value$timeUnit, _value$lowerDate, _value$upperDate, _value$timeValue, _value$timeUnit$toStr2, _value$timeUnit2; 6498 switch (value.rangeType) { 6499 case SlidingDateRangeType.Current: 6500 return "Current||".concat(getTextForValue((_value$timeUnit$toStr = (_value$timeUnit = value.timeUnit) === null || _value$timeUnit === void 0 ? void 0 : _value$timeUnit.toString()) !== null && _value$timeUnit$toStr !== void 0 ? _value$timeUnit$toStr : "", timeUnitOptions), "||"); 6501 case SlidingDateRangeType.DateRange: 6502 return "DateRange|||".concat((_value$lowerDate = value.lowerDate) !== null && _value$lowerDate !== void 0 ? _value$lowerDate : "", "|").concat((_value$upperDate = value.upperDate) !== null && _value$upperDate !== void 0 ? _value$upperDate : ""); 6503 default: 6504 return "".concat(getTextForValue(value.rangeType.toString(), rangeTypeOptions) || "All", "|").concat((_value$timeValue = value.timeValue) !== null && _value$timeValue !== void 0 ? _value$timeValue : "", "|").concat(getTextForValue((_value$timeUnit$toStr2 = (_value$timeUnit2 = value.timeUnit) === null || _value$timeUnit2 === void 0 ? void 0 : _value$timeUnit2.toString()) !== null && _value$timeUnit$toStr2 !== void 0 ? _value$timeUnit$toStr2 : "", timeUnitOptions), "||"); 6505 } 6506 } 6507 function calculateSlidingDateRange(value) { 6508 let currentDateTime = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : undefined; 6509 const result = { 6510 start: null, 6511 end: null 6512 }; 6513 if (!currentDateTime) { 6514 currentDateTime = RockDateTime.now(); 6515 } 6516 if (value.rangeType === SlidingDateRangeType.Current) { 6517 if (value.timeUnit === TimeUnitType.Hour) { 6518 var _result$start$addHour, _result$start; 6519 result.start = RockDateTime.fromParts(currentDateTime.year, currentDateTime.month, currentDateTime.day, currentDateTime.hour, 0, 0); 6520 result.end = (_result$start$addHour = (_result$start = result.start) === null || _result$start === void 0 ? void 0 : _result$start.addHours(1)) !== null && _result$start$addHour !== void 0 ? _result$start$addHour : null; 6521 } else if (value.timeUnit === TimeUnitType.Day) { 6522 result.start = currentDateTime.date; 6523 result.end = result.start.addDays(1); 6524 } else if (value.timeUnit === TimeUnitType.Week) { 6525 let diff = currentDateTime.dayOfWeek - DayOfWeek.Monday; 6526 if (diff < 0) { 6527 diff += 7; 6528 } 6529 result.start = currentDateTime.addDays(-1 * diff).date; 6530 result.end = result.start.addDays(7); 6531 } else if (value.timeUnit === TimeUnitType.Month) { 6532 var _result$start$addMont, _result$start2; 6533 result.start = RockDateTime.fromParts(currentDateTime.year, currentDateTime.month, 1); 6534 result.end = (_result$start$addMont = (_result$start2 = result.start) === null || _result$start2 === void 0 ? void 0 : _result$start2.addMonths(1)) !== null && _result$start$addMont !== void 0 ? _result$start$addMont : null; 6535 } else if (value.timeUnit === TimeUnitType.Year) { 6536 result.start = RockDateTime.fromParts(currentDateTime.year, 1, 1); 6537 result.end = RockDateTime.fromParts(currentDateTime.year + 1, 1, 1); 6538 } 6539 } else if (value.rangeType === SlidingDateRangeType.Last || value.rangeType === SlidingDateRangeType.Previous) { 6540 var _value$timeValue2; 6541 const count = (_value$timeValue2 = value.timeValue) !== null && _value$timeValue2 !== void 0 ? _value$timeValue2 : 1; 6542 const roundUpCount = value.rangeType === SlidingDateRangeType.Last ? 1 : 0; 6543 if (value.timeUnit === TimeUnitType.Hour) { 6544 var _RockDateTime$fromPar, _RockDateTime$fromPar2, _result$end$addHours, _result$end; 6545 result.end = (_RockDateTime$fromPar = (_RockDateTime$fromPar2 = RockDateTime.fromParts(currentDateTime.year, currentDateTime.month, currentDateTime.day, currentDateTime.hour, 0, 0)) === null || _RockDateTime$fromPar2 === void 0 ? void 0 : _RockDateTime$fromPar2.addHours(roundUpCount)) !== null && _RockDateTime$fromPar !== void 0 ? _RockDateTime$fromPar : null; 6546 result.start = (_result$end$addHours = (_result$end = result.end) === null || _result$end === void 0 ? void 0 : _result$end.addHours(-count)) !== null && _result$end$addHours !== void 0 ? _result$end$addHours : null; 6547 } else if (value.timeUnit === TimeUnitType.Day) { 6548 var _result$end$addDays, _result$end2; 6549 result.end = currentDateTime.date.addDays(roundUpCount); 6550 result.start = (_result$end$addDays = (_result$end2 = result.end) === null || _result$end2 === void 0 ? void 0 : _result$end2.addDays(-count)) !== null && _result$end$addDays !== void 0 ? _result$end$addDays : null; 6551 } else if (value.timeUnit === TimeUnitType.Week) { 6552 let diff = currentDateTime.dayOfWeek - DayOfWeek.Monday; 6553 if (diff < 0) { 6554 diff += 7; 6555 } 6556 result.end = currentDateTime.addDays(-1 * diff).date.addDays(7 * roundUpCount); 6557 result.start = result.end.addDays(-count * 7); 6558 } else if (value.timeUnit === TimeUnitType.Month) { 6559 var _RockDateTime$fromPar3, _RockDateTime$fromPar4, _result$end$addMonths, _result$end3; 6560 result.end = (_RockDateTime$fromPar3 = (_RockDateTime$fromPar4 = RockDateTime.fromParts(currentDateTime.year, currentDateTime.month, 1)) === null || _RockDateTime$fromPar4 === void 0 ? void 0 : _RockDateTime$fromPar4.addMonths(roundUpCount)) !== null && _RockDateTime$fromPar3 !== void 0 ? _RockDateTime$fromPar3 : null; 6561 result.start = (_result$end$addMonths = (_result$end3 = result.end) === null || _result$end3 === void 0 ? void 0 : _result$end3.addMonths(-count)) !== null && _result$end$addMonths !== void 0 ? _result$end$addMonths : null; 6562 } else if (value.timeUnit === TimeUnitType.Year) { 6563 var _RockDateTime$fromPar5, _RockDateTime$fromPar6, _result$end$addYears, _result$end4; 6564 result.end = (_RockDateTime$fromPar5 = (_RockDateTime$fromPar6 = RockDateTime.fromParts(currentDateTime.year, 1, 1)) === null || _RockDateTime$fromPar6 === void 0 ? void 0 : _RockDateTime$fromPar6.addYears(roundUpCount)) !== null && _RockDateTime$fromPar5 !== void 0 ? _RockDateTime$fromPar5 : null; 6565 result.start = (_result$end$addYears = (_result$end4 = result.end) === null || _result$end4 === void 0 ? void 0 : _result$end4.addYears(-count)) !== null && _result$end$addYears !== void 0 ? _result$end$addYears : null; 6566 } 6567 const cutoffDate = currentDateTime.date.addDays(1); 6568 if (result.end && result.end.date > cutoffDate) { 6569 result.end = cutoffDate; 6570 } 6571 } else if (value.rangeType === SlidingDateRangeType.Next || value.rangeType === SlidingDateRangeType.Upcoming) { 6572 var _value$timeValue3; 6573 const count = (_value$timeValue3 = value.timeValue) !== null && _value$timeValue3 !== void 0 ? _value$timeValue3 : 1; 6574 const roundUpCount = value.rangeType === SlidingDateRangeType.Upcoming ? 1 : 0; 6575 if (value.timeUnit === TimeUnitType.Hour) { 6576 var _RockDateTime$fromPar7, _RockDateTime$fromPar8, _result$start$addHour2, _result$start3; 6577 result.start = (_RockDateTime$fromPar7 = (_RockDateTime$fromPar8 = RockDateTime.fromParts(currentDateTime.year, currentDateTime.month, currentDateTime.day, currentDateTime.hour, 0, 0)) === null || _RockDateTime$fromPar8 === void 0 ? void 0 : _RockDateTime$fromPar8.addHours(roundUpCount)) !== null && _RockDateTime$fromPar7 !== void 0 ? _RockDateTime$fromPar7 : null; 6578 result.end = (_result$start$addHour2 = (_result$start3 = result.start) === null || _result$start3 === void 0 ? void 0 : _result$start3.addHours(count)) !== null && _result$start$addHour2 !== void 0 ? _result$start$addHour2 : null; 6579 } else if (value.timeUnit === TimeUnitType.Day) { 6580 res
6580ult.start = currentDateTime.date.addDays(roundUpCount); 6581 result.end = result.start.addDays(count); 6582 } else if (value.timeUnit === TimeUnitType.Week) { 6583 let diff = currentDateTime.dayOfWeek - DayOfWeek.Monday; 6584 if (diff < 0) { 6585 diff += 7; 6586 } 6587 result.start = currentDateTime.addDays(-1 * diff).date.addDays(7 * roundUpCount); 6588 result.end = result.start.addDays(count * 7); 6589 } else if (value.timeUnit === TimeUnitType.Month) { 6590 var _RockDateTime$fromPar9, _RockDateTime$fromPar0, _result$start$addMont2, _result$start4; 6591 result.start = (_RockDateTime$fromPar9 = (_RockDateTime$fromPar0 = RockDateTime.fromParts(currentDateTime.year, currentDateTime.month, 1)) === null || _RockDateTime$fromPar0 === void 0 ? void 0 : _RockDateTime$fromPar0.addMonths(roundUpCount)) !== null && _RockDateTime$fromPar9 !== void 0 ? _RockDateTime$fromPar9 : null; 6592 result.end = (_result$start$addMont2 = (_result$start4 = result.start) === null || _result$start4 === void 0 ? void 0 : _result$start4.addMonths(count)) !== null && _result$start$addMont2 !== void 0 ? _result$start$addMont2 : null; 6593 } else if (value.timeUnit === TimeUnitType.Year) { 6594 var _RockDateTime$fromPar1, _RockDateTime$fromPar10, _result$start$addYear, _result$start5; 6595 result.start = (_RockDateTime$fromPar1 = (_RockDateTime$fromPar10 = RockDateTime.fromParts(currentDateTime.year, 1, 1)) === null || _RockDateTime$fromPar10 === void 0 ? void 0 : _RockDateTime$fromPar10.addYears(roundUpCount)) !== null && _RockDateTime$fromPar1 !== void 0 ? _RockDateTime$fromPar1 : null; 6596 result.end = (_result$start$addYear = (_result$start5 = result.start) === null || _result$start5 === void 0 ? void 0 : _result$start5.addYears(count)) !== null && _result$start$addYear !== void 0 ? _result$start$addYear : null; 6597 } 6598 if (result.start && result.start.date < currentDateTime.date) { 6599 result.start = currentDateTime.date; 6600 } 6601 } else if (value.rangeType === SlidingDateRangeType.DateRange) { 6602 var _value$lowerDate2, _value$upperDate2; 6603 result.start = RockDateTime.parseISO((_value$lowerDate2 = value.lowerDate) !== null && _value$lowerDate2 !== void 0 ? _value$lowerDate2 : ""); 6604 result.end = RockDateTime.parseISO((_value$upperDate2 = value.upperDate) !== null && _value$upperDate2 !== void 0 ? _value$upperDate2 : ""); 6605 if (!result.start && value.lowerDate) { 6606 result.start = RockDateTime.fromJSDate(new Date(value.lowerDate)); 6607 } 6608 if (!result.end && value.upperDate) { 6609 result.end = RockDateTime.fromJSDate(new Date(value.upperDate)); 6610 } 6611 if (result.end) { 6612 result.end = result.end.addDays(1); 6613 } 6614 } 6615 if (result.end && value.timeUnit !== TimeUnitType.Hour) { 6616 result.end = result.end.addMilliseconds(-1); 6617 } 6618 return result; 6619 } 6620 6621 var slidingDateRange = /*#__PURE__*/Object.freeze({ 6622 __proto__: null, 6623 RangeType: SlidingDateRangeType, 6624 TimeUnit: TimeUnitType, 6625 calculateSlidingDateRange: calculateSlidingDateRange, 6626 getRangeTypeText: getRangeTypeText, 6627 getTimeUnitText: getTimeUnitText, 6628 parseSlidingDateRangeString: parseSlidingDateRangeString, 6629 rangeTypeOptions: rangeTypeOptions, 6630 slidingDateRangeToString: slidingDateRangeToString, 6631 timeUnitOptions: timeUnitOptions 6632 }); 6633 exports('slidingDateRange', slidingDateRange); 6634 6635 const http = useHttp(); 6636 async function getStructuredContentEditorConfiguration(options) { 6637 const result = await http.post("/api/v2/Controls/StructuredContentEditorGetConfiguration", undefined, options); 6638 if (result.isSuccess && result.data) { 6639 return result.data; 6640 } 6641 throw new Error(result.errorMessage || "Error fetching structured content editor configuration"); 6642 } 6643 var structuredContentEditor = { 6644 getStructuredContentEditorConfiguration 6645 }; 6646 6647 var structuredContentEditor$1 = /*#__PURE__*/Object.freeze({ 6648 __proto__: null, 6649 default: structuredContentEditor, 6650 getStructuredContentEditorConfiguration: getStructuredContentEditorConfiguration 6651 }); 6652 exports('structuredContentEditor', structuredContentEditor$1); 6653 6654 function tooltip(node, options) { 6655 if (Array.isArray(node)) { 6656 for (const n of node) { 6657 tooltip(n, options); 6658 } 6659 return; 6660 } 6661 if (typeof $ !== "function") { 6662 return; 6663 } 6664 const $node = $(node); 6665 let appliedContainer = undefined; 6666 let fsElement = undefined; 6667 const getContainer = () => { 6668 var _options$container2; 6669 if (!isFullscreen() && fsElement) { 6670 var _options$container; 6671 fsElement.style.position = ""; 6672 fsElement = undefined; 6673 return (_options$container = options === null || options === void 0 ? void 0 : options.container) !== null && _options$container !== void 0 ? _options$container : "body"; 6674 } 6675 const newFsElement = getFullscreenElement();
6676 if (newFsElement && newFsElement === fsElement) { 6677 return undefined; 6678 } 6679 if (newFsElement && newFsElement.contains(node)) { 6680 fsElement = newFsElement; 6681 const fsElementPosition = getComputedStyle(fsElement).position; 6682 if (fsElementPosition === "static") { 6683 fsElement.style.position = "relative"; 6684 } 6685 return getUniqueCssSelector(fsElement); 6686 } 6687 return (_options$container2 = options === null || options === void 0 ? void 0 : options.container) !== null && _options$container2 !== void 0 ? _options$container2 : "body"; 6688 }; 6689 const applyTooltip = container => { 6690 if (appliedContainer === container || container === undefined) { 6691 return; 6692 } 6693 if (appliedContainer) { 6694 $node === null || $node === void 0 || $node.tooltip("destroy"); 6695 setTimeout(() => { 6696 var _options$sanitize; 6697 $node === null || $node === void 0 || $node.tooltip({ 6698 container: container, 6699 html: options === null || options === void 0 ? void 0 : options.html, 6700 sanitize: (_options$sanitize = options === null || options === void 0 ? void 0 : options.sanitize) !== null && _options$sanitize !== void 0 ? _options$sanitize : true, 6701 delay: options === null || options === void 0 ? void 0 : options.delay, 6702 trigger: "hover focus" 6703 }); 6704 }, 151); 6705 } else { 6706 var _options$sanitize2; 6707 $node === null || $node === void 0 || $node.tooltip({ 6708 container: container, 6709 html: options === null || options === void 0 ? void 0 : options.html, 6710 sanitize: (_options$sanitize2 = options === null || options === void 0 ? void 0 : options.sanitize) !== null && _options$sanitize2 !== void 0 ? _options$sanitize2 : true, 6711 delay: options === null || options === void 0 ? void 0 : options.delay, 6712 trigger: "hover focus" 6713 }); 6714 } 6715 appliedContainer = container; 6716 }; 6717 if (!(options !== null && options !== void 0 && options.container) || options.container === "body" || options.container === "html") { 6718 document.addEventListener("fullscreenchange", () => applyTooltip(getContainer())); 6719 } 6720 applyTooltip(getContainer()); 6721 $(document).on("click", ".tooltip", function (e) { 6722 e.stopPropagation(); 6723 }); 6724 $node === null || $node === void 0 || $node.on("mouseleave", function () { 6725 if (!$(this).data("tooltip-pinned")) { 6726 $node === null || $node === void 0 || $node.tooltip("hide"); 6727 } 6728 }); 6729 } 6730 function showTooltip(node) { 6731 if (typeof $ === "function") { 6732 $(node).tooltip("show"); 6733 $(node).data("tooltip-pinned", true); 6734 } 6735 } 6736 function hideTooltip(node) { 6737 if (typeof $ === "function") { 6738 $(node).data("tooltip-pinned", false); 6739 $(node).tooltip("hide"); 6740 } 6741 } 6742 function destroyTooltip(node) { 6743 if (typeof $ === "function") { 6744 $(node).tooltip("destroy"); 6745 } 6746 } 6747 function resetTooltip(node, options) { 6748 return new Promise(res => { 6749 destroyTooltip(node); 6750 setTimeout(() => { 6751 tooltip(node, options); 6752 res(); 6753 }, 151); 6754 }); 6755 } 6756 function applyTooltip(el, options) { 6757 if (isElement(el)) { 6758 tooltip(el, options); 6759 } 6760 } 6761 6762 var tooltip$1 = /*#__PURE__*/Object.freeze({ 6763 __proto__: null, 6764 applyTooltip: applyTooltip, 6765 destroyTooltip: destroyTooltip, 6766 hideTooltip: hideTooltip, 6767 resetTooltip: resetTooltip, 6768 showTooltip: showTooltip, 6769 tooltip: tooltip 6770 }); 6771 exports('tooltip', tooltip$1); 6772 6773 class CategoryTreeItemProvider { 6774 constructor() { 6775 _defineProperty(this, "http", useHttp()); 6776 } 6777 async getItems(parentGuid) { 6778 var _this$getCategorizedI, _this$includeInactive, _this$includeUnnamedE; 6779 const options = { 6780 parentGuid: parentGuid, 6781 entityTypeGuid: this.entityTypeGuid, 6782 entityTypeQualifierColumn: this.entityTypeQualifierColumn, 6783 entityTypeQualifierValue: this.entityTypeQualifierValue, 6784 lazyLoad: false, 6785 securityGrantToken: this.securityGrantToken, 6786 getCategorizedItems: (_this$getCategorizedI = this.getCategorizedItems) !== null && _this$getCategorizedI !== void 0 ? _this$getCategorizedI : false, 6787 includeCategoriesWithoutChildren: true, 6788 includeInactiveItems: (_this$includeInactive = this.includeInactiveItems) !== null && _this$includeInactive !== void 0 ? _this$includeInactive : false, 6789 includeUnnamedEntityItems: (_this$includeUnnamedE = this.includeUnnamedEntityItems) !== null && _this$includeUnnamedE !== void 0 ? _this$includeUnnamedE : false 6790 }; 6791 const response = await this.http.post("/api/v2/Controls/CategoryPickerChildTreeItems", {}, options); 6792 if (response.isSuccess && response.data) { 6793 return this.applyClientOptions(response.data); 6794 } else { 6795 console.log("Error", response.errorMessage); 6796 return []; 6797 } 6798 } 6799 applyClientOptions(items) { 6800 var _this$excludedCategor; 6801 const excludedSet = new Set(((_this$excludedCategor = this.excludedCategoryGuids) !== null && _this$excludedCategor !== void 0 ? _this$excludedCategor : []).map(guid => guid.toLowerCase())); 6802 const filtered = excludedSet.size > 0 ? items.filter(item => !item.value || !excludedSet.has(item.value.toLowerCase())) : items; 6803 for (const item of filtered) { 6804 if (this.defaultIconCssClass && !item.iconCssClass) { 6805 item.iconCssClass = this.defaultIconCssClass; 6806 } 6807 if (item.children && item.children.length > 0) { 6808 item.children = this.applyClientOptions(item.children); 6809 } 6810 } 6811 return filtered; 6812 } 6813 async getRootItems() { 6814 return await this.getItems(this.rootCategoryGuid); 6815 } 6816 async getChildItems(item) { 6817 return this.getItems(item.value); 6818 } 6819 } 6820 class LocationTreeItemProvider { 6821 constructor() { 6822 _defineProperty(this, "http", useHttp()); 6823 _defineProperty(this, "includeInactive", false); 6824 } 6825 async getItems(parentGuid, expandToValues) { 6826 var _toGuidOrNull, _this$rootLocationGui; 6827 const options = { 6828 guid: (_toGuidOrNull = toGuidOrNull(parentGuid)) !== null && _toGuidOrNull !== void 0 ? _toGuidOrNull : emptyGuid, 6829 rootLocationGuid: (_this$rootLocationGui = this.rootLocationGuid) !== null && _this$rootLocationGui !== void 0 ? _this$rootLocationGui : emptyGuid, 6830 expandToValues: expandToValues, 6831 securityGrantToken: this.securityGrantToken, 6832 includeInactive: this.includeInactive 6833 }; 6834 const url = "/api/v2/Controls/LocationItemPickerGetActiveChildren"; 6835 const response = await this.http.post(url, undefined, options); 6836 if (response.isSuccess && response.data) { 6837 return response.data; 6838 } else { 6839 console.log("Error", response.errorMessage); 6840 return []; 6841 } 6842 } 6843 async getRootItems(expandToValues) { 6844 return await this.getItems(null, expandToValues); 6845 } 6846 async getChildItems(item) { 6847 return this.getItems(item.value); 6848 } 6849 } 6850 class DataViewTreeItemProvider { 6851 constructor() { 6852 _defineProperty(this, "http", useHttp()); 6853 _defineProperty(this, "displayPersistedOnly", false); 6854 } 6855 async getItems(parentGuid) { 6856 const options = { 6857 parentGuid, 6858 getCategorizedItems: true, 6859 includeCategoriesWithoutChildren: false, 6860 entityTypeGuidFilter: this.entityTypeGuid, 6861 lazyLoad: false, 6862 securityGrantToken: this.securityGrantToken, 6863 displayPersistedOnly: this.displayPersistedOnly, 6864 includeUnnamedEntityItems: false 6865 }; 6866 const response = await this.http.post("/api/v2/Controls/DataViewPickerGetDataViews", {}, options); 6867 if (response.isSuccess && response.data) { 6868 return response.data; 6869 } else { 6870 console.log("Error", response.errorMessage); 6871 return []; 6872 } 6873 } 6874 async getRootItems() { 6875 return await this.getItems(); 6876 } 6877 async getChildItems(item) { 6878 return this.getItems(item.value); 6879 } 6880 } 6881 class WorkflowTypeTreeItemProvider { 6882 constructor() { 6883 _defineProperty(this, "http", useHttp()); 6884 } 6885 async getItems(parentGuid) { 6886 var _this$includeInactive2; 6887 const options = { 6888 parentGuid, 6889 includeInactiveItems: (_this$includeInactive2 = this.includeInactiveItems) !== null && _this$includeInactive2 !== void 0 ? _this$includeInactive2 : false, 6890 securityGrantToken: this.securityGrantToken, 6891 getCategorizedItems: false, 6892 includeCategoriesWithoutChildren: false, 6893 includeUnnamedEntityItems: false, 6894 lazyLoad: false 6895 }; 6896 const response = await this.http.post("/api/v2/Controls/WorkflowTypePickerGetWorkflowTypes", {}, options); 6897 if (response.isSuccess && response.data) { 6898 return response.data; 6899 } else { 6900 console.log("Error", response.errorMessage); 6901 return []; 6902 } 6903 } 6904 async getRootItems() { 6905 return await this.getItems(); 6906 } 6907 async getChildItems(item) { 6908 return this.getItems(item.value); 6909 } 6910 } 6911 class PageTreeItemProvider { 6912 constructor() { 6913 _defineProperty(this, "http", useHttp()); 6914 } 6915 async getItems(parentGuid, expandToValues) { 6916 var _toGuidOrNull2, _this$rootPageGuid, _this$hidePageGuids; 6917 let result; 6918 const options = { 6919 guid: (_toGuidOrNull2 = toGuidOrNull(parentGuid)) !== null && _toGuidOrNull2 !== void 0 ? _toGuidOrNull2 : emptyGuid, 6920 rootPageGuid: (_this$rootPageGuid = this.rootPageGuid) !== null && _this$rootPageGuid !== void 0 ? _this$rootPageGuid : null, 6921 hidePageGuids: (_this$hidePageGuids = this.hidePageGuids) !== null && _this$hidePageGuids !== void 0 ? _this$hidePageGuids : [], 6922 securityGrantToken: this.securityGrantToken, 6923 siteType: this.siteType, 6924 expandToValues 6925 }; 6926 const url = "/api/v2/Controls/PagePickerGetChildren"; 6927 const response = await this.http.post(url, undefined, options); 6928 if (response.isSuccess && response.data) { 6929 result = response.data; 6930 } else { 6931 console.log("Error", response.errorMessage); 6932 return []; 6933 } 6934 if (parentGuid || !this.selectedPageGuids) { 6935 return result; 6936 } 6937 return this.getHierarchyToSelectedPage(result); 6938 } 6939 async getParentList() { 6940 const options = { 6941 selectedPageGuids: this.selectedPageGuids, 6942 securityGrantToken: this.securityGrantToken 6943 }; 6944 const url = "/api/v2/Controls/PagePickerGetSelectedPageHierarchy"; 6945 const response = await this.http.post(url, undefined, options); 6946 if (response.isSuccess && response.data) { 6947 return response.data; 6948 } else { 6949 console.log("Error", response.errorMessage); 6950 return []; 6951 } 6952 } 6953 async getHierarchyToSelectedPage(rootLayer) { 6954 const parents = await this.getParentList(); 6955 if (!parents || parents.length === 0) { 6956 return rootLayer; 6957 } 6958 const childLists = await Promise.all(parents.map(guid => this.getItems(guid))); 6959 const allPages = rootLayer.concat(flatten(childLists));
6960 parents.forEach((parentGuid, i) => { 6961 const parentPage = allPages.find(page => page.value === parentGuid); 6962 if (parentPage) { 6963 parentPage.children = childLists[i]; 6964 } 6965 }); 6966 return rootLayer; 6967 } 6968 async getRootItems(expandToValues) { 6969 return await this.getItems(null, expandToValues); 6970 } 6971 async getChildItems(item) { 6972 return this.getItems(item.value); 6973 } 6974 } 6975 class ConnectionRequestTreeItemProvider { 6976 constructor() { 6977 _defineProperty(this, "http", useHttp()); 6978 } 6979 async getItems(parentGuid, expandToValues) { 6980 const options = { 6981 parentGuid, 6982 securityGrantToken: this.securityGrantToken, 6983 expandToValues 6984 }; 6985 const url = "/api/v2/Controls/ConnectionRequestPickerGetChildren"; 6986 const response = await this.http.post(url, undefined, options); 6987 if (response.isSuccess && response.data) { 6988 return response.data; 6989 } else { 6990 console.log("Error", response.errorMessage); 6991 return []; 6992 } 6993 } 6994 async getRootItems(expandToValues) { 6995 return await this.getItems(null, expandToValues); 6996 } 6997 async getChildItems(item) { 6998 return this.getItems(item.value); 6999 } 7000 } 7001 class FinancialAccountTreeItemProvider { 7002 constructor() { 7003 _defineProperty(this, "http", useHttp()); 7004 _defineProperty(this, "securityGrantToken", null); 7005 _defineProperty(this, "includeInactive", false); 7006 _defineProperty(this, "displayPublicName", false); 7007 } 7008 async getItems() { 7009 var _toGuidOrNull3; 7010 let parentGuid = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null; 7011 const options = { 7012 parentGuid: (_toGuidOrNull3 = toGuidOrNull(parentGuid)) !== null && _toGuidOrNull3 !== void 0 ? _toGuidOrNull3 : emptyGuid, 7013 includeInactive: this.includeInactive, 7014 displayPublicName: this.displayPublicName, 7015 loadFullTree: false, 7016 securityGrantToken: this.securityGrantToken 7017 }; 7018 const url = "/api/v2/Controls/AccountPickerGetChildren"; 7019 const response = await this.http.post(url, undefined, options); 7020 if (response.isSuccess && response.data) { 7021 return response.data; 7022 } else { 7023 console.error("Error fetching accounts from server", response.errorMessage); 7024 return []; 7025 } 7026 } 7027 async getRootItems() { 7028 return await this.getItems(null); 7029 } 7030 async getChildItems(item) { 7031 return this.getItems(toGuidOrNull(item.value)); 7032 } 7033 } 7034 class GroupTreeItemProvider { 7035 constructor() { 7036 _defineProperty(this, "http", useHttp()); 7037 _defineProperty(this, "securityGrantToken", null); 7038 _defineProperty(this, "rootGroupGuid", null); 7039 _defineProperty(this, "includedGroupTypeGuids", []); 7040 _defineProperty(this, "excludedGroupTypeGuids", []); 7041 _defineProperty(this, "excludeAllByDefault", false); 7042 _defineProperty(this, "includeInactiveGroups", false); 7043 _defineProperty(this, "limitToSchedulingEnabled", false); 7044 _defineProperty(this, "limitToRSVPEnabled", false); 7045 _defineProperty(this, "limitToSecurityRoleGroups", false); 7046 _defineProperty(this, "campusGuid", null); 7047 _defineProperty(this, "includeNoCampus", false); 7048 _defineProperty(this, "limitToPublic", false); 7049 _defineProperty(this, "countsType", 0); 7050 } 7051 async getItems() { 7052 let parentGuid = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null; 7053 let expandToValues = arguments.length > 1 ? arguments[1] : undefined; 7054 const options = { 7055 guid: parentGuid, 7056 rootGroupGuid: this.rootGroupGuid, 7057 includedGroupTypeGuids: this.includedGroupTypeGuids, 7058 excludedGroupTypeGuids: this.excludedGroupTypeGuids, 7059 excludeAllByDefault: this.excludeAllByDefault, 7060 includeInactiveGroups: this.includeInactiveGroups, 7061 limitToSchedulingEnabled: this.limitToSchedulingEnabled, 7062 limitToRSVPEnabled: this.limitToRSVPEnabled, 7063 limitToSecurityRoleGroups: this.limitToSecurityRoleGroups, 7064 campusGuid: this.campusGuid, 7065 includeNoCampus: this.includeNoCampus, 7066 limitToPublic: this.limitToPublic, 7067 countsType: this.countsType, 7068 securityGrantToken: this.securityGrantToken, 7069 expandToValues 7070 }; 7071 const url = "/api/v2/Controls/GroupPickerGetChildren"; 7072 const response = await this.http.post(url, undefined, options); 7073 if (response.isSuccess && response.data) { 7074 return response.data; 7075 } else { 7076 console.log("Error", response.errorMessage); 7077 return []; 7078 } 7079 } 7080 async getRootItems(expandToValues) { 7081 return await this.getItems(null, expandToValues); 7082 } 7083 async getChildItems(item) { 7084 return this.getItems(item.value); 7085 } 7086 } 7087 class MergeTemplateTreeItemProvider { 7088 constructor() { 7089 _defineProperty(this, "http", useHttp()); 7090 _defineProperty(this, "securityGrantToken", null); 7091 _defineProperty(this, "mergeTemplateOwnership", MergeTemplateOwnership.Global); 7092 } 7093 async getItems() { 7094 var _toNumberOrNull; 7095 let parentGuid = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null; 7096 let expandToValues = arguments.length > 1 ? arguments[1] : undefined; 7097 const options = { 7098 parentGuid, 7099 mergeTemplateOwnership: (_toNumberOrNull = toNumberOrNull(this.mergeTemplateOwnership)) !== null && _toNumberOrNull !== void 0 ? _toNumberOrNull : 0, 7100 securityGrantToken: this.securityGrantToken, 7101 expandToValues 7102 }; 7103 const url = "/api/v2/Controls/MergeTemplatePickerGetMergeTemplates"; 7104 const response = await this.http.post(url, undefined, options); 7105 if (response.isSuccess && response.data) { 7106 return response.data; 7107 } else { 7108 console.log("Error", response.errorMessage); 7109 return []; 7110 } 7111 } 7112 async getRootItems(expandToValues) { 7113 return await this.getItems(null, expandToValues); 7114 } 7115 async getChildItems(item) { 7116 return this.getItems(item.value); 7117 } 7118 } 7119 class MetricCategoryTreeItemProvider { 7120 constructor() { 7121 _defineProperty(this, "http", useHttp()); 7122 _defineProperty(this, "securityGrantToken", null); 7123 } 7124 async getItems() { 7125 let parentGuid = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null; 7126 let expandToValues = arguments.length > 1 ? arguments[1] : undefined; 7127 const options = { 7128 parentGuid, 7129 securityGrantToken: this.securityGrantToken, 7130 expandToValues 7131 }; 7132 const url = "/api/v2/Controls/MetricCategoryPickerGetChildren"; 7133 const response = await this.http.post(url, undefined, options); 7134 if (response.isSuccess && response.data) { 7135 return response.data; 7136 } else { 7137 console.log("Error", response.errorMessage); 7138 return []; 7139 } 7140 } 7141 async getRootItems(expandToValues) { 7142 return await this.getItems(null, expandToValues); 7143 } 7144 async getChildItems(item) { 7145 return this.getItems(item.value); 7146 } 7147 } 7148 class MetricItemTreeItemProvider { 7149 constructor() { 7150 _defineProperty(this, "http", useHttp()); 7151 _defineProperty(this, "securityGrantToken", null); 7152 _defineProperty(this, "includeCategoryGuids", null); 7153 } 7154 async getItems() { 7155 let parentGuid = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null; 7156 const options = { 7157 parentGuid, 7158 includeCategoryGuids: this.includeCategoryGuids, 7159 securityGrantToken: this.securityGrantToken 7160 }; 7161 const url = "/api/v2/Controls/MetricItemPickerGetChildren"; 7162 const response = await this.http.post(url, undefined, options); 7163 if (response.isSuccess && response.data) { 7164 return response.data; 7165 } else { 7166 console.log("Error", response.errorMessage); 7167 return []; 7168 } 7169 } 7170 async getRootItems() { 7171 return await this.getItems(null); 7172 } 7173 async getChildItems(item) { 7174 return this.getItems(item.value); 7175 } 7176 } 7177 class RegistrationTemplateTreeItemProvider { 7178 constructor() { 7179 _defineProperty(this, "http", useHttp()); 7180 _defineProperty(this, "securityGrantToken", null); 7181 } 7182 async getItems() { 7183 let parentGuid = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null; 7184 let expandToValues = arguments.length > 1 ? arguments[1] : undefined; 7185 const options = { 7186 parentGuid, 7187 securityGrantToken: this.securityGrantToken, 7188 expandToValues 7189 }; 7190 const url = "/api/v2/Controls/RegistrationTemplatePickerGetChildren"; 7191 const response = await this.http.post(url, undefined, options); 7192 if (response.isSuccess && response.data) { 7193 return response.data; 7194 } else { 7195 console.log("Error", response.errorMessage); 7196 return []; 7197 } 7198 } 7199 async getRootItems(expandToValues) { 7200 return await this.getItems(null, expandToValues); 7201 } 7202 async getChildItems(item) { 7203 return this.getItems(item.value); 7204 } 7205 } 7206 class ReportTreeItemProvider { 7207 constructor() { 7208 _defineProperty(this, "http", useHttp()); 7209 _defineProperty(this, "securityGrantToken", null); 7210 _defineProperty(this, "includeCategoryGuids", null); 7211 _defineProperty(this, "entityTypeGuid", null); 7212 } 7213 async getItems() { 7214 let parentGuid = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null; 7215 let expandToValues = arguments.length > 1 ? arguments[1] : undefined; 7216 const options = { 7217 parentGuid, 7218 includeCategoryGuids: this.includeCategoryGuids, 7219 entityTypeGuid: this.entityTypeGuid, 7220 securityGrantToken: this.securityGrantToken, 7221 expandToValues 7222 }; 7223 const url = "/api/v2/Controls/ReportPickerGetChildren"; 7224 const response = await this.http.post(url, undefined, options); 7225 if (response.isSuccess && response.data) { 7226 return response.data; 7227 } else { 7228 console.log("Error", response.errorMessage); 7229 return []; 7230 } 7231 } 7232 async getRootItems(expandToValues) { 7233 return await this.getItems(null, expandToValues); 7234 } 7235 async getChildItems(item) { 7236 return this.getItems(item.value); 7237 } 7238 } 7239 class ScheduleTreeItemProvider { 7240 constructor() { 7241 _defineProperty(this, "http", useHttp()); 7242 _defineProperty(this, "securityGrantToken", null); 7243 _defineProperty(this, "includeInactive", false); 7244 _defineProperty(this, "includePublicOnly", false); 7245 _defineProperty(this, "includeCategoryGuids", null); 7246 _defineProperty(this, "includeCheckInSchedulesOnly", false); 7247 } 7248 async getItems() { 7249 let parentGuid = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null; 7250 let expandToValues = arguments.length > 1 ? arguments[1] : undefined; 7251 const options = { 7252 parentGuid, 7253 includeInactiveItems: this.includeInactive, 7254 includePublicItemsOnly: this.includePublicOnly, 7255 includeCategoryGuids: this.includeCategoryGuids, 7256 includeCheckInSchedulesOnly: this.includeCheckInSchedulesOnly, 7257 securityGrantToken: this.securityGrantToken, 7258 expandToValues 7259 }; 7260 const url = "/api/v2/Controls/SchedulePickerGetChildren"; 7261 const response = await this.http.post(url, undefined, options); 7262 if (response.isSuccess && response.data) { 7263 return response.data; 7264 } else { 7265 console.log("Error", response.errorMessage); 7266 return []; 7267 } 7268 } 7269 async getRootItems(expandToValues) { 7270 return await this.getItems(null, expandToValues); 7271 } 7272 async getChildItems(item) { 7273 return this.getItems(item.value); 7274 } 7275 } 7276 class WorkflowActionTypeTreeItemProvider { 7277 constructor() { 7278 _defineProperty(this, "http", useHttp()); 7279 _defineProperty(this, "securityGrantToken", null); 7280 _defineProperty(this, "includeInactive", false); 7281 } 7282 async getItems() { 7283 var _toNumberOrNull2; 7284 let parentId = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null; 7285 let expandToValues = arguments.length > 1 ? arguments[1] : undefined; 7286 const options = { 7287 parentId: (_toNumberOrNull2 = toNumberOrNull(parentId)) !== null && _toNumberOrNull2 !== void 0 ? _toNumberOrNull2 : 0, 7288 securityGrantToken: this.securityGrantToken, 7289 expandToValues 7290 }; 7291 const url = "/api/v2/Controls/WorkflowActionTypePickerGetChildren"; 7292 const response = await this.http.post(url, undefined, options); 7293 if (response.isSuccess && response.data) { 7294 return response.data; 7295 } else { 7296 console.log("Error", response.errorMessage); 7297 return []; 7298 } 7299 } 7300 async getRootItems(expandToValues) { 7301 return await this.getItems(null, expandToValues); 7302 } 7303 async getChildItems(item) { 7304 return this.getItems(item.value); 7305 } 7306 } 7307 class MergeFieldTreeItemProvider { 7308 constructor() { 7309 _defineProperty(this, "http", useHttp()); 7310 _defineProperty(this, "additionalFields", ""); 7311 } 7312 async getItems(parentId) { 7313 let result; 7314 const options = { 7315 id: parentId || "0", 7316 additionalFields: this.additionalFields 7317 }; 7318 const url = "/api/v2/Controls/MergeFieldPickerGetChildren"; 7319 const response = await this.http.post(url, undefined, options); 7320 if (response.isSuccess && response.data) { 7321 result = response.data; 7322 } else { 7323 console.log("Error", response.errorMessage); 7324 return []; 7325 } 7326 if (parentId || !this.selectedIds || this.selectedIds.length === 0) { 7327 return result; 7328 } 7329 return this.getHierarchyToSelectedMergeField(result); 7330 } 7331 async getHierarchyToSelectedMergeField(rootLayer) { 7332 const parents = this.getParentList(); 7333 if (!parents || parents.length === 0) { 7334 return rootLayer; 7335 } 7336 const childLists = await Promise.all(parents.map(id =>
7336 this.getItems(id))); 7337 const allMergeFields = rootLayer.concat(flatten(childLists)); 7338 parents.forEach((parentGuid, i) => { 7339 const parentMergeField = allMergeFields.find(page => page.value === parentGuid); 7340 if (parentMergeField) { 7341 parentMergeField.children = childLists[i]; 7342 } 7343 }); 7344 return rootLayer; 7345 } 7346 getParentList() { 7347 if (!this.selectedIds || this.selectedIds.length === 0) { 7348 return null; 7349 } 7350 if (typeof this.selectedIds == "string") { 7351 return this.splitSelectionIntoParents(this.selectedIds); 7352 } 7353 return flatten(this.selectedIds.map(sel => this.splitSelectionIntoParents(sel))); 7354 } 7355 splitSelectionIntoParents(selection) { 7356 const parentIds = []; 7357 const splitList = selection.split("|"); 7358 splitList.pop(); 7359 while (splitList.length >= 1) { 7360 parentIds.unshift(splitList.join("|")); 7361 splitList.pop(); 7362 } 7363 return parentIds; 7364 } 7365 async getRootItems() { 7366 return await this.getItems(); 7367 } 7368 async getChildItems(item) { 7369 return this.getItems(item.value); 7370 } 7371 } 7372 class AssetManagerTreeItemProvider { 7373 constructor() { 7374 _defineProperty(this, "http", useHttp()); 7375 _defineProperty(this, "openFolders", new Set()); 7376 _defineProperty(this, "selectedFolder", ""); 7377 _defineProperty(this, "enableAssetManager", false); 7378 _defineProperty(this, "enableFileManager", false); 7379 _defineProperty(this, "encryptedRootFolder", ""); 7380 _defineProperty(this, "securityGrantToken", ""); 7381 _defineProperty(this, "userSpecificRoot", false); 7382 } 7383 async getRootItems() { 7384 const options = { 7385 expandedFolders: this.openFolders.size > 0 ? Array.from(this.openFolders) : null, 7386 selectedFolder: this.selectedFolder, 7387 enableAssetManager: this.enableAssetManager, 7388 enableFileManager: this.enableFileManager, 7389 rootFolder: this.encryptedRootFolder, 7390 securityGrantToken: this.securityGrantToken, 7391 userSpecificRoot: this.userSpecificRoot 7392 }; 7393 const url = "/api/v2/Controls/AssetManagerGetRootFolders"; 7394 const response = await this.http.post(url, undefined, options); 7395 if (response.isSuccess && response.data) { 7396 this.openFolders = new Set(response.data.updatedExpandedFolders); 7397 return response.data.tree; 7398 } else { 7399 console.error("Error Fetching Root Asset Manager Items", response.errorMessage); 7400 return []; 7401 } 7402 } 7403 async getChildItems(item) { 7404 const options = { 7405 assetFolderId: item.value, 7406 securityGrantToken: this.securityGrantToken 7407 }; 7408 const url = "/api/v2/Controls/AssetManagerGetChildren"; 7409 const response = await this.http.post(url, undefined, options); 7410 if (response.isSuccess && response.data) { 7411 return response.data; 7412 } else { 7413 console.error("Error Fetching Asset Manager Children", response.errorMessage); 7414 return []; 7415 } 7416 } 7417 } 7418 class AdaptiveMessageTreeItemProvider { 7419 constructor() { 7420 _defineProperty(this, "http", useHttp()); 7421 } 7422 async getItems(parentGuid, expandToValues) { 7423 const options = { 7424 parentValue: parentGuid, 7425 securityGrantToken: this.securityGrantToken, 7426 expandToValues 7427 }; 7428 const response = await this.http.post("/api/v2/Controls/AdaptiveMessagePickerGetAdaptiveMessages", {}, options); 7429 if (response.isSuccess && response.data) { 7430 return response.data; 7431 } else { 7432 console.log("Error", response.errorMessage); 7433 return []; 7434 } 7435 } 7436 async getRootItems(expandToValues) { 7437 return await this.getItems(null, expandToValues); 7438 } 7439 async getChildItems(item) { 7440 return this.getItems(item.value); 7441 } 7442 } 7443 7444 var treeItemProviders = /*#__PURE__*/Object.freeze({ 7445 __proto__: null, 7446 AdaptiveMessageTreeItemProvider: AdaptiveMessageTreeItemProvider, 7447 AssetManagerTreeItemProvider: AssetManagerTreeItemProvider, 7448 CategoryTreeItemProvider: CategoryTreeItemProvider, 7449 ConnectionRequestTreeItemProvider: ConnectionRequestTreeItemProvider, 7450 DataViewTreeItemProvider: DataViewTreeItemProvider, 7451 FinancialAccountTreeItemProvider: FinancialAccountTreeItemProvider, 7452 GroupTreeItemProvider: GroupTreeItemProvider, 7453 LocationTreeItemProvider: LocationTreeItemProvider, 7454 MergeFieldTreeItemProvider: MergeFieldTreeItemProvider, 7455 MergeTemplateTreeItemProvider: MergeTemplateTreeItemProvider, 7456 MetricCategoryTreeItemProvider: MetricCategoryTreeItemProvider, 7457 MetricItemTreeItemProvider: MetricItemTreeItemProvider, 7458 PageTreeItemProvider: PageTreeItemProvider, 7459 RegistrationTemplateTreeItemProvider: RegistrationTemplateTreeItemProvider, 7460 ReportTreeItemProvider: ReportTreeItemProvider, 7461 ScheduleTreeItemProvider: ScheduleTreeItemProvider, 7462 WorkflowActionTypeTreeItemProvider: WorkflowActionTypeTreeItemProvider, 7463 WorkflowTypeTreeItemProvider: WorkflowTypeTreeItemProvider 7464 }); 7465 exports('treeItemProviders', treeItemProviders); 7466 7467 function isUrl(val) { 7468 if (typeof val === "string") { 7469 const re = /^(http[s]?:\/\/)?[^\s(["<,>]*\.?[^\s[",><]*$/; 7470 return re.test(val); 7471 } 7472 return false;
7473 } 7474 function makeUrlRedirectSafe(url) { 7475 try { 7476 const u = new URL(url); 7477 if (u.protocol !== "http:" && u.protocol !== "https:") { 7478 return "/"; 7479 } 7480 return makeUrlRedirectSafe("".concat(u.pathname).concat(u.search)); 7481 } catch (_unused) { 7482 if (url.indexOf(":") !== -1) { 7483 return "/"; 7484 } 7485 return url; 7486 } 7487 } 7488 function syncRefsWithQueryParams(bindings) { 7489 let isReplaceStateScheduled = false; 7490 function scheduleReplaceState() { 7491 if (isReplaceStateScheduled) { 7492 return; 7493 } 7494 isReplaceStateScheduled = true; 7495 queueMicrotask(() => { 7496 try { 7497 const qs = params.toString(); 7498 const { 7499 pathname, 7500 search, 7501 hash 7502 } = window.location; 7503 const nextUrl = qs ? "".concat(pathname, "?").concat(qs).concat(hash) : "".concat(pathname).concat(hash); 7504 const currentUrl = "".concat(pathname).concat(search).concat(hash); 7505 if (nextUrl !== currentUrl) { 7506 history.replaceState(null, "", nextUrl); 7507 } 7508 } finally { 7509 isReplaceStateScheduled = false; 7510 } 7511 }); 7512 } 7513 const params = new URLSearchParams(window.location.search); 7514 for (const binding of bindings) { 7515 const { 7516 param, 7517 ref, 7518 type 7519 } = binding; 7520 const raw = params.get(param); 7521 if (!isNullish(raw)) { 7522 const parsed = parse(raw, type); 7523 if (!isNullish(parsed)) { 7524 ref.value = parsed; 7525 } 7526 } 7527 watch(ref, value => { 7528 if (isNullish(value)) { 7529 params.delete(param); 7530 } else { 7531 const serialized = serialize(value, type); 7532 if (isNullish(serialized)) { 7533 params.delete(param); 7534 } else { 7535 params.set(param, serialized); 7536 } 7537 } 7538 scheduleReplaceState(); 7539 }); 7540 } 7541 function parse(raw, type) { 7542 switch (type) { 7543 case "string": 7544 return raw; 7545 case "boolean": 7546 { 7547 return asBooleanOrNull(raw); 7548 } 7549 case "number": 7550 { 7551 return toNumberOrNull(raw); 7552 } 7553 case "json": 7554 { 7555 try { 7556 return JSON.parse(raw); 7557 } catch (_unused2) { 7558 return null; 7559 } 7560 } 7561 } 7562 } 7563 function serialize(value, type) { 7564 switch (type) { 7565 case "string": 7566 return typeof value === "string" ? value : null; 7567 case "boolean": 7568 return typeof value === "boolean" ? asTrueOrFalseString(value) : null; 7569 case "number": 7570 return typeof value === "number" && Number.isFinite(value) ? String(value) : null; 7571 case "json": 7572 { 7573 try { 7574 return JSON.stringify(value); 7575 } catch (_unused3) { 7576 return null; 7577 } 7578 } 7579 } 7580 } 7581 } 7582 function appendQueryParam(url, key, value) { 7583 const hashIndex = url.indexOf("#"); 7584 const path = hashIndex >= 0 ? url.slice(0, hashIndex) : url; 7585 const hash = hashIndex >= 0 ? url.slice(hashIndex) : ""; 7586 const separator = path.includes("?") ? "&" : "?"; 7587 return "".concat(path).concat(separator).concat(encodeURIComponent(key), "=").concat(encodeURIComponent(value)).concat(hash); 7588 } 7589 function removeCurrentUrlQueryParams() { 7590 for (var _len = arguments.length, queryParamKeys = new Array(_len), _key = 0; _key < _len; _key++) { 7591 queryParamKeys[_key] = arguments[_key]; 7592 } 7593 return removeUrlQueryParams(window.location.href, ...queryParamKeys); 7594 } 7595 function removeUrlQueryParams(url) { 7596 for (var _len2 = arguments.length, queryParamKeys = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { 7597 queryParamKeys[_key2 - 1] = arguments[_key2]; 7598 } 7599 if (!queryParamKeys || !queryParamKeys.length) { 7600 return []; 7601 } 7602 if (typeof url === "string") { 7603 url = new URL(url); 7604 } 7605 const queryParams = url.searchParams; 7606 const removedQueryParams = []; 7607 for (let i = 0; i < queryParamKeys.length; i++) { 7608 const queryParamKey = queryParamKeys[i]; 7609 removedQueryParams.push(queryParams.get(queryParamKey)); 7610 queryParams.delete(queryParamKey); 7611 } 7612 window.history.replaceState(null, "", url); 7613 return removedQueryParams; 7614 } 7615 7616 var url = /*#__PURE__*/Object.freeze({ 7617 __proto__: null, 7618 appendQueryParam: appendQueryParam, 7619 isUrl: isUrl, 7620 makeUrlRedirectSafe: makeUrlRedirectSafe, 7621 removeCurrentUrlQueryParams: removeCurrentUrlQueryParams, 7622 removeUrlQueryParams: removeUrlQueryParams, 7623 syncRefsWithQueryParams: syncRefsWithQueryParams 7624 }); 7625 exports('url', url); 7626 7627 const definedRules = {}; 7628 const rulesPropType = { 7629 type: [Array, Object, String], 7630 default: "" 7631 }; 7632 function parseRule(rule) { 7633 let name = ""; 7634 let params = []; 7635 const colonIndex = rule.indexOf(":"); 7636 if (colonIndex === -1) { 7637 name = rule; 7638 } else { 7639 name = rule.substring(0, colonIndex); 7640 params = rule.substring(colonIndex + 1).split(","); 7641 } 7642 return { 7643 name, 7644 params 7645 }; 7646 } 7647 function normalizeRules(rules) { 7648 if (typeof rules === "string") { 7649 if (rules.indexOf("|") !== -1) { 7650 return rules.split("|").filter(r => r.trim() !== ""); 7651 } else if (rules.trim() !== "") { 7652 return [rules.trim()]; 7653 } 7654 } else if (Array.isArray(rules)) { 7655 const normalizedRules = []; 7656 for (const r of rules) {
7657 normalizedRules.push(...normalizeRules(r)); 7658 } 7659 return normalizedRules; 7660 } else if (typeof rules === "function") { 7661 return [rules]; 7662 } else if (typeof rules === "object") { 7663 return [rules]; 7664 } 7665 return []; 7666 } 7667 function containsRequiredRule(rules) { 7668 return normalizeRules(rules).some(r => r === "required"); 7669 } 7670 function normalizeRulesToFunctions(rules) { 7671 const ruleFunctions = []; 7672 for (const rule of rules) { 7673 if (typeof rule === "string") { 7674 const ruleRef = parseRule(rule); 7675 const fn = definedRules[ruleRef.name]; 7676 if (fn) { 7677 ruleFunctions.push(value => fn(value, ruleRef.params)); 7678 } else { 7679 console.warn("Attempt to validate with unknown rule ".concat(rule, ".")); 7680 } 7681 } else if (typeof rule === "function") { 7682 ruleFunctions.push(rule); 7683 } else if (typeof rule === "object") { 7684 const fn = definedRules[rule.name]; 7685 if (fn) { 7686 ruleFunctions.push(value => fn(value, rule.params)); 7687 } else { 7688 console.warn("Attempt to validate with unknown rule ".concat(rule.name, ".")); 7689 } 7690 } 7691 } 7692 return ruleFunctions; 7693 } 7694 function normalizeRuleResult(result) { 7695 if (typeof result === "string") { 7696 return result; 7697 } else if (result === true) { 7698 return ""; 7699 } else { 7700 return "failed validation"; 7701 } 7702 } 7703 function validateValue(value, rule) { 7704 const fns = normalizeRulesToFunctions(normalizeRules(rule)); 7705 const results = []; 7706 for (const fn of fns) { 7707 const result = normalizeRuleResult(fn(value)); 7708 if (result !== "") { 7709 results.push(result); 7710 } 7711 } 7712 return results; 7713 } 7714 function defineRule(ruleName, validator) { 7715 if (definedRules[ruleName] !== undefined) { 7716 console.warn("Attempt to redefine validation rule ".concat(ruleName, ".")); 7717 } else { 7718 definedRules[ruleName] = validator; 7719 } 7720 } 7721 7722 var validationRules = /*#__PURE__*/Object.freeze({ 7723 __proto__: null, 7724 containsRequiredRule: containsRequiredRule, 7725 defineRule: defineRule, 7726 normalizeRules: normalizeRules, 7727 parseRule: parseRule, 7728 rulesPropType: rulesPropType, 7729 validateValue: validateValue 7730 }); 7731 exports('validationRules', validationRules); 7732 7733 }) 7734 }; 7735})); 7736//# sourceMappingURL=Utility.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.