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