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