@usecapsule/core-components 3.4.1 → 3.5.1
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/capsule/capsule.esm.js +1 -1
- package/dist/capsule/capsule.esm.js.map +1 -1
- package/dist/capsule/index.esm.js +1 -1
- package/dist/capsule/index.esm.js.map +1 -1
- package/dist/capsule/p-286db996.js +2 -0
- package/dist/capsule/p-286db996.js.map +1 -0
- package/dist/capsule/{p-f0cd0482.entry.js → p-41bc3c58.entry.js} +2 -2
- package/dist/capsule/p-45496164.entry.js +20 -0
- package/dist/capsule/p-45496164.entry.js.map +1 -0
- package/dist/capsule/p-52bb30d8.entry.js +2 -0
- package/dist/capsule/p-52bb30d8.entry.js.map +1 -0
- package/dist/capsule/{p-5965b15e.entry.js → p-5cd62456.entry.js} +2 -2
- package/dist/capsule/{p-b96e357a.entry.js → p-9fa8efd0.entry.js} +2 -2
- package/dist/capsule/p-ab7b3141.entry.js +2 -0
- package/dist/capsule/{p-1bd11889.entry.js → p-c9e61114.entry.js} +2 -2
- package/dist/capsule/{p-9e64a60e.entry.js → p-d4bdb369.entry.js} +2 -2
- package/dist/capsule/{p-d165df27.entry.js → p-de2a16e4.entry.js} +2 -2
- package/dist/cjs/capsule.cjs.js +1 -1
- package/dist/cjs/cpsl-alert_34.cjs.entry.js +117 -44
- package/dist/cjs/cpsl-alert_34.cjs.entry.js.map +1 -1
- package/dist/cjs/cpsl-col.cjs.entry.js +1 -1
- package/dist/cjs/cpsl-grid.cjs.entry.js +2 -2
- package/dist/cjs/cpsl-hero.cjs.entry.js +2 -2
- package/dist/cjs/cpsl-identicon.cjs.entry.js +76 -30
- package/dist/cjs/cpsl-identicon.cjs.entry.js.map +1 -1
- package/dist/cjs/cpsl-info-box.cjs.entry.js +1 -1
- package/dist/cjs/cpsl-modal-v2.cjs.entry.js +1 -1
- package/dist/cjs/cpsl-nav-button.cjs.entry.js +1 -1
- package/dist/cjs/cpsl-row.cjs.entry.js +1 -1
- package/dist/cjs/index.cjs.js +2 -0
- package/dist/cjs/index.cjs.js.map +1 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/prand-a35ea6b2.js +209 -0
- package/dist/cjs/prand-a35ea6b2.js.map +1 -0
- package/dist/collection/assets/icons/alert-triangle.svg +5 -0
- package/dist/collection/assets/icons/check-circle-filled.svg +5 -0
- package/dist/collection/assets/icons/cosmos.svg +12 -0
- package/dist/collection/assets/icons/ethereum.svg +4 -0
- package/dist/collection/assets/icons/index.js +6 -1
- package/dist/collection/assets/icons/index.js.map +1 -1
- package/dist/collection/assets/icons/solana.svg +19 -0
- package/dist/collection/components/cpsl-alert/cpsl-alert.css +23 -2
- package/dist/collection/components/cpsl-alert/cpsl-alert.js +21 -3
- package/dist/collection/components/cpsl-alert/cpsl-alert.js.map +1 -1
- package/dist/collection/components/cpsl-app-bar/cpsl-app-bar.js +3 -3
- package/dist/collection/components/cpsl-auth-modal/cpsl-auth-modal.css +3 -1
- package/dist/collection/components/cpsl-avatar/cpsl-avatar.js +1 -1
- package/dist/collection/components/cpsl-button/cpsl-button.css +1 -1
- package/dist/collection/components/cpsl-button/cpsl-button.js +2 -2
- package/dist/collection/components/cpsl-button-group/cpsl-button-group.js +1 -1
- package/dist/collection/components/cpsl-card/cpsl-card.js +1 -1
- package/dist/collection/components/cpsl-checkbox/cpsl-checkbox.js +1 -1
- package/dist/collection/components/cpsl-code-input/cpsl-code-input.js +2 -2
- package/dist/collection/components/cpsl-col/cpsl-col.js +1 -1
- package/dist/collection/components/cpsl-divider/cpsl-divider.js +1 -1
- package/dist/collection/components/cpsl-drawer/cpsl-drawer.js +2 -2
- package/dist/collection/components/cpsl-dropdown/cpsl-dropdown.js +1 -1
- package/dist/collection/components/cpsl-file-upload/cpsl-file-upload.js +1 -1
- package/dist/collection/components/cpsl-grid/cpsl-grid.js +2 -2
- package/dist/collection/components/cpsl-hero/cpsl-hero.js +2 -2
- package/dist/collection/components/cpsl-icon/cpsl-icon.js +2 -2
- package/dist/collection/components/cpsl-icon-group/cpsl-icon-group.js +1 -1
- package/dist/collection/components/cpsl-identicon/cpsl-identicon.css +17 -10
- package/dist/collection/components/cpsl-identicon/cpsl-identicon.js +101 -36
- package/dist/collection/components/cpsl-identicon/cpsl-identicon.js.map +1 -1
- package/dist/collection/components/cpsl-identicon/cpsl-identicon.stories.js +1 -1
- package/dist/collection/components/cpsl-identicon/cpsl-identicon.stories.js.map +1 -1
- package/dist/collection/components/cpsl-info-box/cpsl-info-box.js +1 -1
- package/dist/collection/components/cpsl-input/cpsl-input.js +2 -2
- package/dist/collection/components/cpsl-modal-v2/cpsl-modal-v2.js +1 -1
- package/dist/collection/components/cpsl-nav-button/cpsl-nav-button.js +1 -1
- package/dist/collection/components/cpsl-nav-button-group/cpsl-nav-button-group.js +1 -1
- package/dist/collection/components/cpsl-overlay/cpsl-overlay.js +1 -1
- package/dist/collection/components/cpsl-pagination/cpsl-pagination.js +1 -1
- package/dist/collection/components/cpsl-pill/cpsl-pill.js +1 -1
- package/dist/collection/components/cpsl-popover/cpsl-popover.js +2 -2
- package/dist/collection/components/cpsl-qr-code/cpsl-qr-code.js +1 -1
- package/dist/collection/components/cpsl-radio/cpsl-radio.js +1 -1
- package/dist/collection/components/cpsl-row/cpsl-row.js +1 -1
- package/dist/collection/components/cpsl-select/cpsl-select.js +2 -2
- package/dist/collection/components/cpsl-select-item/cpsl-select-item.js +1 -1
- package/dist/collection/components/cpsl-slide-button/cpsl-slide-button.js +3 -3
- package/dist/collection/components/cpsl-spinner/cpsl-spinner.js +2 -2
- package/dist/collection/components/cpsl-switch/cpsl-switch.js +1 -1
- package/dist/collection/components/cpsl-tab/cpsl-tab.js +32 -1
- package/dist/collection/components/cpsl-tab/cpsl-tab.js.map +1 -1
- package/dist/collection/components/cpsl-tab/tab-interface.js.map +1 -1
- package/dist/collection/components/cpsl-table/cpsl-table.js +1 -1
- package/dist/collection/components/cpsl-tabs/cpsl-tabs.js +16 -1
- package/dist/collection/components/cpsl-tabs/cpsl-tabs.js.map +1 -1
- package/dist/collection/components/cpsl-text/cpsl-text.js +1 -1
- package/dist/collection/components/cpsl-tile-button/cpsl-tile-button.js +2 -2
- package/dist/collection/index.js +1 -0
- package/dist/collection/index.js.map +1 -1
- package/dist/collection/lib/prando.js +187 -0
- package/dist/collection/lib/prando.js.map +1 -0
- package/dist/collection/utils/prand.js +16 -0
- package/dist/collection/utils/prand.js.map +1 -0
- package/dist/esm/capsule.js +1 -1
- package/dist/esm/cpsl-alert_34.entry.js +117 -44
- package/dist/esm/cpsl-alert_34.entry.js.map +1 -1
- package/dist/esm/cpsl-col.entry.js +1 -1
- package/dist/esm/cpsl-grid.entry.js +2 -2
- package/dist/esm/cpsl-hero.entry.js +2 -2
- package/dist/esm/cpsl-identicon.entry.js +76 -30
- package/dist/esm/cpsl-identicon.entry.js.map +1 -1
- package/dist/esm/cpsl-info-box.entry.js +1 -1
- package/dist/esm/cpsl-modal-v2.entry.js +1 -1
- package/dist/esm/cpsl-nav-button.entry.js +1 -1
- package/dist/esm/cpsl-row.entry.js +1 -1
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/esm/prand-c8323494.js +205 -0
- package/dist/esm/prand-c8323494.js.map +1 -0
- package/dist/types/assets/icons/index.d.ts +5 -0
- package/dist/types/components/cpsl-alert/cpsl-alert.d.ts +4 -0
- package/dist/types/components/cpsl-identicon/cpsl-identicon.d.ts +5 -4
- package/dist/types/components/cpsl-tab/cpsl-tab.d.ts +7 -1
- package/dist/types/components/cpsl-tab/tab-interface.d.ts +3 -0
- package/dist/types/components/cpsl-tabs/cpsl-tabs.d.ts +2 -0
- package/dist/types/components.d.ts +19 -8
- package/dist/types/index.d.ts +1 -0
- package/dist/types/lib/prando.d.ts +92 -0
- package/dist/types/utils/prand.d.ts +3 -0
- package/package.json +4 -4
- package/dist/capsule/p-5d62e610.entry.js +0 -2
- package/dist/capsule/p-5d62e610.entry.js.map +0 -1
- package/dist/capsule/p-afbb1e6f.entry.js +0 -20
- package/dist/capsule/p-afbb1e6f.entry.js.map +0 -1
- package/dist/capsule/p-cfc382c0.entry.js +0 -2
- /package/dist/capsule/{p-f0cd0482.entry.js.map → p-41bc3c58.entry.js.map} +0 -0
- /package/dist/capsule/{p-5965b15e.entry.js.map → p-5cd62456.entry.js.map} +0 -0
- /package/dist/capsule/{p-b96e357a.entry.js.map → p-9fa8efd0.entry.js.map} +0 -0
- /package/dist/capsule/{p-cfc382c0.entry.js.map → p-ab7b3141.entry.js.map} +0 -0
- /package/dist/capsule/{p-1bd11889.entry.js.map → p-c9e61114.entry.js.map} +0 -0
- /package/dist/capsule/{p-9e64a60e.entry.js.map → p-d4bdb369.entry.js.map} +0 -0
- /package/dist/capsule/{p-d165df27.entry.js.map → p-de2a16e4.entry.js.map} +0 -0
package/dist/esm/loader.js
CHANGED
@@ -5,7 +5,7 @@ import { g as globalScripts } from './app-globals-0f993ce5.js';
|
|
5
5
|
const defineCustomElements = async (win, options) => {
|
6
6
|
if (typeof window === 'undefined') return undefined;
|
7
7
|
await globalScripts();
|
8
|
-
return bootstrapLazy([["cpsl-hero",[[1,"cpsl-hero",{"height":[2],"hideFadeOut":[4,"hide-fade-out"],"variant":[513],"title":[513],"subtitle":[513],"withDefaultTheme":[4,"with-default-theme"]}]]],["cpsl-modal-v2",[[1,"cpsl-modal-v2",{"enterTransitionDuration":[2,"enter-transition-duration"],"exitTransitionDuration":[2,"exit-transition-duration"],"elevated":[4],"noOverlay":[4,"no-overlay"],"open":[4],"zIndexOverride":[2,"z-index-override"]},null,{"open":["toggleHeight"]}]]],["cpsl-nav-button",[[1,"cpsl-nav-button",{"disabled":[516],"exactMainRouteMatch":[4,"exact-main-route-match"],"exactSubRouteMatch":[4,"exact-sub-route-match"],"route":[1],"subRoutes":[16],"path":[1]}]]],["cpsl-col",[[1,"cpsl-col",{"offset":[1],"offsetXs":[1,"offset-xs"],"offsetSm":[1,"offset-sm"],"offsetMd":[1,"offset-md"],"offsetLg":[1,"offset-lg"],"offsetXl":[1,"offset-xl"],"pull":[1],"pullXs":[1,"pull-xs"],"pullSm":[1,"pull-sm"],"pullMd":[1,"pull-md"],"pullLg":[1,"pull-lg"],"pullXl":[1,"pull-xl"],"push":[1],"pushXs":[1,"push-xs"],"pushSm":[1,"push-sm"],"pushMd":[1,"push-md"],"pushLg":[1,"push-lg"],"pushXl":[1,"push-xl"],"size":[1],"sizeXs":[1,"size-xs"],"sizeSm":[1,"size-sm"],"sizeMd":[1,"size-md"],"sizeLg":[1,"size-lg"],"sizeXl":[1,"size-xl"]},[[9,"resize","onResize"]]]]],["cpsl-grid",[[1,"cpsl-grid",{"fixed":[4]}]]],["cpsl-identicon",[[1,"cpsl-identicon",{"hash":[1],"size":[
|
8
|
+
return bootstrapLazy([["cpsl-hero",[[1,"cpsl-hero",{"height":[2],"hideFadeOut":[4,"hide-fade-out"],"variant":[513],"title":[513],"subtitle":[513],"withDefaultTheme":[4,"with-default-theme"]}]]],["cpsl-modal-v2",[[1,"cpsl-modal-v2",{"enterTransitionDuration":[2,"enter-transition-duration"],"exitTransitionDuration":[2,"exit-transition-duration"],"elevated":[4],"noOverlay":[4,"no-overlay"],"open":[4],"zIndexOverride":[2,"z-index-override"]},null,{"open":["toggleHeight"]}]]],["cpsl-nav-button",[[1,"cpsl-nav-button",{"disabled":[516],"exactMainRouteMatch":[4,"exact-main-route-match"],"exactSubRouteMatch":[4,"exact-sub-route-match"],"route":[1],"subRoutes":[16],"path":[1]}]]],["cpsl-col",[[1,"cpsl-col",{"offset":[1],"offsetXs":[1,"offset-xs"],"offsetSm":[1,"offset-sm"],"offsetMd":[1,"offset-md"],"offsetLg":[1,"offset-lg"],"offsetXl":[1,"offset-xl"],"pull":[1],"pullXs":[1,"pull-xs"],"pullSm":[1,"pull-sm"],"pullMd":[1,"pull-md"],"pullLg":[1,"pull-lg"],"pullXl":[1,"pull-xl"],"push":[1],"pushXs":[1,"push-xs"],"pushSm":[1,"push-sm"],"pushMd":[1,"push-md"],"pushLg":[1,"push-lg"],"pushXl":[1,"push-xl"],"size":[1],"sizeXs":[1,"size-xs"],"sizeSm":[1,"size-sm"],"sizeMd":[1,"size-md"],"sizeLg":[1,"size-lg"],"sizeXl":[1,"size-xl"]},[[9,"resize","onResize"]]]]],["cpsl-grid",[[1,"cpsl-grid",{"fixed":[4]}]]],["cpsl-identicon",[[1,"cpsl-identicon",{"hash":[1],"size":[1],"variant":[1]}]]],["cpsl-info-box",[[1,"cpsl-info-box"]]],["cpsl-row",[[1,"cpsl-row"]]],["cpsl-alert_34",[[1,"cpsl-pagination",{"initialPage":[2,"initial-page"],"totalPages":[2,"total-pages"],"visiblePages":[1026,"visible-pages"],"currentPage":[32]},null,{"currentPage":["watchChange"]}],[1,"cpsl-select",{"anchorElId":[1,"anchor-el-id"],"autoWidth":[4,"auto-width"],"disabled":[4],"dropdownMaxHeight":[2,"dropdown-max-height"],"errorText":[1,"error-text"],"formatValue":[16],"helperText":[1,"helper-text"],"id":[1],"label":[1],"placeholder":[1],"required":[4],"selectedValue":[1,"selected-value"],"showFormattedSelectedItem":[4,"show-formatted-selected-item"],"showOptionalLabel":[4,"show-optional-label"],"showSearch":[4,"show-search"],"searchPlaceholder":[1,"search-placeholder"],"anchorEl":[32],"hasFocus":[32],"popoverOpen":[32],"hasSelectedItem":[32]},[[0,"cpslSelectItemClick","selectItemClickHandler"],[0,"cpslOpen","onPopoverOpen"],[0,"cpslClose","onPopoverClose"]],{"selectedValue":["onValueChange","handleValueChange"]}],[1,"cpsl-file-upload",{"errorText":[1,"error-text"],"externalFilename":[1,"external-filename"],"externalSrc":[1,"external-src"],"fileTypes":[16],"helperText":[1,"helper-text"],"label":[1],"required":[4],"showOptionalLabel":[4,"show-optional-label"],"uploadFile":[16],"file":[32],"dragOver":[32],"dragError":[32],"isUploading":[32],"uploadError":[32]}],[1,"cpsl-auth-modal",{"enterTransitionDuration":[2,"enter-transition-duration"],"exitTransitionDuration":[2,"exit-transition-duration"],"noOverlay":[4,"no-overlay"],"open":[4],"zIndexOverride":[2,"z-index-override"],"hasFooter":[32],"isMobile":[32]},null,{"open":["toggleModal"]}],[1,"cpsl-alert",{"icon":[1],"variant":[1],"filled":[4]}],[1,"cpsl-checkbox",{"checked":[4]}],[1,"cpsl-code-input",{"code":[1025],"errorText":[1,"error-text"],"helperText":[1,"helper-text"],"length":[2],"type":[1]}],[1,"cpsl-drawer",{"anchor":[1],"anchorPosition":[2,"anchor-position"],"noOverlay":[4,"no-overlay"],"open":[4],"size":[8],"transitionDuration":[2,"transition-duration"],"transitionFunction":[1,"transition-function"],"variant":[1],"zIndexOverride":[2,"z-index-override"],"closedAnchorPosition":[32],"showTransition":[32]}],[1,"cpsl-icon-group",{"expandFrom":[1,"expand-from"],"disabled":[4],"icons":[16],"isHovered":[32]}],[1,"cpsl-slide-button",{"disabled":[4],"endIcon":[1,"end-icon"],"endText":[1,"end-text"],"startIcon":[1,"start-icon"],"startText":[1,"start-text"]}],[1,"cpsl-table",{"hasHorizontalScroll":[32],"hasVerticalScroll":[32]}],[1,"cpsl-tile-button",{"src":[1],"icon":[1]}],[1,"cpsl-app-bar",{"height":[2],"position":[1],"zIndexOverride":[2,"z-index-override"]}],[1,"cpsl-avatar",{"alt":[1],"src":[1],"variant":[1]}],[1,"cpsl-divider"],[1,"cpsl-dropdown",{"width":[1],"hasCpslSearch":[4,"has-cpsl-search"],"items":[16],"selectedItem":[1040],"isOpen":[32],"searchQuery":[32],"filteredItems":[32]},[[9,"resize","handleResize"]],{"selectedItem":["handleSelectedItemChange"],"isOpen":["handleOpenChange"]}],[1,"cpsl-nav-button-group"],[1,"cpsl-pill",{"text":[1]}],[1,"cpsl-progress-indicator",{"totalSteps":[2,"total-steps"],"step":[2]}],[1,"cpsl-qr-code",{"url":[1],"imageSrc":[1,"image-src"],"size":[2]}],[1,"cpsl-radio",{"checked":[4]}],[1,"cpsl-select-item",{"selected":[4],"value":[1]}],[1,"cpsl-switch",{"checked":[4]}],[1,"cpsl-tab",{"selected":[4],"tab":[1]},[[8,"cpslTabsChanged","onTabsChanged"],[8,"cpslTabsInit","onTabsInit"]]],[1,"cpsl-tabs",{"fullWidth":[4,"full-width"],"selectedTab":[1,"selected-tab"],"selectedTabRect":[32],"loaded":[32]},[[8,"cpslTabButtonSizeChange","onTabSizeChange"]],{"fullWidth":["updateSlider"],"selectedTab":["updateTab"]}],[1,"cpsl-button-group",{"selectedId":[1,"selected-id"]},null,{"selectedId":["selectItem"]}],[1,"cpsl-input",{"autocapitalize":[1],"autocomplete":[1],"autocorrect":[1],"noAutoDisable":[4,"no-auto-disable"],"autofocus":[4],"disabled":[4],"contrastText":[4,"contrast-text"],"enterkeyhint":[1],"errorText":[1,"error-text"],"mask":[1],"helperText":[1,"helper-text"],"inputmode":[1],"label":[1],"max":[8],"maxlength":[2],"min":[8],"minlength":[2],"multiple":[4],"name":[1],"pattern":[1],"placeholder":[1],"readonly":[4],"required":[4],"showOptionalLabel":[4,"show-optional-label"],"spellcheck":[4],"startIconSrc":[1,"start-icon-src"],"startIcon":[1,"start-icon"],"step":[1],"type":[1],"value":[1025],"hasFocus":[32],"maskedInput":[32]},null,{"disabled":["handleDisable"],"mask":["handleSetupMask"],"value":["handleValueChange"]}],[1,"cpsl-popover",{"anchorEl":[16],"anchorOriginHorizontal":[1,"anchor-origin-horizontal"],"anchorOriginVertical":[1,"anchor-origin-vertical"],"autoWidth":[4,"auto-width"],"disabled":[4],"preventBlur":[4,"prevent-blur"],"transformOriginHorizontal":[1,"transform-origin-horizontal"],"transformOriginVertical":[1,"transform-origin-vertical"],"triggerAction":[1,"trigger-action"],"trigger":[1],"windowPadding":[2,"window-padding"],"open":[32],"positionX":[32],"positionY":[32],"closePopover":[64]},null,{"trigger":["onTriggerChange"],"triggerAction":["onTriggerChange"],"preventBlur":["onTriggerChange"],"anchorOriginHorizontal":["onAnchorChange"],"anchorOriginVertical":["onAnchorChange"],"open":["onOpenChange"]}],[1,"cpsl-spinner",{"size":[2],"speed":[2]}],[1,"cpsl-button",{"as":[1],"disabled":[516],"fullWidth":[4,"full-width"],"href":[1],"size":[1],"target":[1],"variant":[513]}],[1,"cpsl-card"],[1,"cpsl-overlay",{"enterTransitionDuration":[2,"enter-transition-duration"],"exitTransitionDuration":[2,"exit-transition-duration"],"open":[4],"zIndexOverride":[2,"z-index-override"]},null,{"open":["toggleHeight"]}],[1,"cpsl-text",{"color":[1],"variant":[1],"weight":[1]}],[1,"cpsl-icon",{"src":[1],"icon":[1]}]]]], options);
|
9
9
|
};
|
10
10
|
|
11
11
|
export { defineCustomElements };
|
@@ -0,0 +1,205 @@
|
|
1
|
+
/*
|
2
|
+
* This file contains code from prando, which is licensed under the MIT License:
|
3
|
+
*
|
4
|
+
* Copyright (c) 2016 Zeh Fernando
|
5
|
+
*
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
11
|
+
* furnished to do so, subject to the following conditions:
|
12
|
+
*
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
14
|
+
* copies or substantial portions of the Software.
|
15
|
+
*
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
22
|
+
* SOFTWARE.
|
23
|
+
*/
|
24
|
+
class Prando {
|
25
|
+
// ================================================================================================================
|
26
|
+
// CONSTRUCTOR ----------------------------------------------------------------------------------------------------
|
27
|
+
/**
|
28
|
+
* Generate a new Prando pseudo-random number generator.
|
29
|
+
*
|
30
|
+
* @param seed - A number or string seed that determines which pseudo-random number sequence will be created. Defaults to a random seed based on `Math.random()`.
|
31
|
+
*/
|
32
|
+
constructor(seed) {
|
33
|
+
this._value = NaN;
|
34
|
+
if (typeof seed === 'string') {
|
35
|
+
// String seed
|
36
|
+
this._seed = this.hashCode(seed);
|
37
|
+
}
|
38
|
+
else if (typeof seed === 'number') {
|
39
|
+
// Numeric seed
|
40
|
+
this._seed = this.getSafeSeed(seed);
|
41
|
+
}
|
42
|
+
else {
|
43
|
+
// Pseudo-random seed
|
44
|
+
this._seed = this.getSafeSeed(Prando.MIN + Math.floor((Prando.MAX - Prando.MIN) * Math.random()));
|
45
|
+
}
|
46
|
+
this.reset();
|
47
|
+
}
|
48
|
+
// ================================================================================================================
|
49
|
+
// PUBLIC INTERFACE -----------------------------------------------------------------------------------------------
|
50
|
+
/**
|
51
|
+
* Generates a pseudo-random number between a lower (inclusive) and a higher (exclusive) bounds.
|
52
|
+
*
|
53
|
+
* @param min - The minimum number that can be randomly generated.
|
54
|
+
* @param pseudoMax - The maximum number that can be randomly generated (exclusive).
|
55
|
+
* @return The generated pseudo-random number.
|
56
|
+
*/
|
57
|
+
next(min = 0, pseudoMax = 1) {
|
58
|
+
this.recalculate();
|
59
|
+
return this.map(this._value, Prando.MIN, Prando.MAX, min, pseudoMax);
|
60
|
+
}
|
61
|
+
/**
|
62
|
+
* Generates a pseudo-random integer number in a range (inclusive).
|
63
|
+
*
|
64
|
+
* @param min - The minimum number that can be randomly generated.
|
65
|
+
* @param max - The maximum number that can be randomly generated.
|
66
|
+
* @return The generated pseudo-random number.
|
67
|
+
*/
|
68
|
+
nextInt(min = 10, max = 100) {
|
69
|
+
this.recalculate();
|
70
|
+
return Math.floor(this.map(this._value, Prando.MIN, Prando.MAX, min, max + 1));
|
71
|
+
}
|
72
|
+
/**
|
73
|
+
* Generates a pseudo-random string sequence of a particular length from a specific character range.
|
74
|
+
*
|
75
|
+
* Note: keep in mind that creating a random string sequence does not guarantee uniqueness; there is always a
|
76
|
+
* 1 in (char_length^string_length) chance of collision. For real unique string ids, always check for
|
77
|
+
* pre-existing ids, or employ a robust GUID/UUID generator.
|
78
|
+
*
|
79
|
+
* @param length - Length of the string to be generated.
|
80
|
+
* @param chars - Characters that are used when creating the random string. Defaults to all alphanumeric chars (A-Z, a-z, 0-9).
|
81
|
+
* @return The generated string sequence.
|
82
|
+
*/
|
83
|
+
nextString(length = 16, chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789') {
|
84
|
+
let str = '';
|
85
|
+
while (str.length < length) {
|
86
|
+
str += this.nextChar(chars);
|
87
|
+
}
|
88
|
+
return str;
|
89
|
+
}
|
90
|
+
/**
|
91
|
+
* Generates a pseudo-random string of 1 character specific character range.
|
92
|
+
*
|
93
|
+
* @param chars - Characters that are used when creating the random string. Defaults to all alphanumeric chars (A-Z, a-z, 0-9).
|
94
|
+
* @return The generated character.
|
95
|
+
*/
|
96
|
+
nextChar(chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789') {
|
97
|
+
return chars.substr(this.nextInt(0, chars.length - 1), 1);
|
98
|
+
}
|
99
|
+
/**
|
100
|
+
* Picks a pseudo-random item from an array. The array is left unmodified.
|
101
|
+
*
|
102
|
+
* Note: keep in mind that while the returned item will be random enough, picking one item from the array at a time
|
103
|
+
* does not guarantee nor imply that a sequence of random non-repeating items will be picked. If you want to
|
104
|
+
* *pick items in a random order* from an array, instead of *pick one random item from an array*, it's best to
|
105
|
+
* apply a *shuffle* transformation to the array instead, then read it linearly.
|
106
|
+
*
|
107
|
+
* @param array - Array of any type containing one or more candidates for random picking.
|
108
|
+
* @return An item from the array.
|
109
|
+
*/
|
110
|
+
nextArrayItem(array) {
|
111
|
+
return array[this.nextInt(0, array.length - 1)];
|
112
|
+
}
|
113
|
+
/**
|
114
|
+
* Generates a pseudo-random boolean.
|
115
|
+
*
|
116
|
+
* @return A value of true or false.
|
117
|
+
*/
|
118
|
+
nextBoolean() {
|
119
|
+
this.recalculate();
|
120
|
+
return this._value > 0.5;
|
121
|
+
}
|
122
|
+
/**
|
123
|
+
* Skips ahead in the sequence of numbers that are being generated. This is equivalent to
|
124
|
+
* calling next() a specified number of times, but faster since it doesn't need to map the
|
125
|
+
* new random numbers to a range and return it.
|
126
|
+
*
|
127
|
+
* @param iterations - The number of items to skip ahead.
|
128
|
+
*/
|
129
|
+
skip(iterations = 1) {
|
130
|
+
while (iterations-- > 0) {
|
131
|
+
this.recalculate();
|
132
|
+
}
|
133
|
+
}
|
134
|
+
/**
|
135
|
+
* Reset the pseudo-random number sequence back to its starting seed. Further calls to next()
|
136
|
+
* will then produce the same sequence of numbers it had produced before. This is equivalent to
|
137
|
+
* creating a new Prando instance with the same seed as another Prando instance.
|
138
|
+
*
|
139
|
+
* Example:
|
140
|
+
* let rng = new Prando(12345678);
|
141
|
+
* console.log(rng.next()); // 0.6177754114889017
|
142
|
+
* console.log(rng.next()); // 0.5784605181725837
|
143
|
+
* rng.reset();
|
144
|
+
* console.log(rng.next()); // 0.6177754114889017 again
|
145
|
+
* console.log(rng.next()); // 0.5784605181725837 again
|
146
|
+
*/
|
147
|
+
reset() {
|
148
|
+
this._value = this._seed;
|
149
|
+
}
|
150
|
+
// ================================================================================================================
|
151
|
+
// PRIVATE INTERFACE ----------------------------------------------------------------------------------------------
|
152
|
+
recalculate() {
|
153
|
+
this._value = this.xorshift(this._value);
|
154
|
+
}
|
155
|
+
xorshift(value) {
|
156
|
+
// Xorshift*32
|
157
|
+
// Based on George Marsaglia's work: http://www.jstatsoft.org/v08/i14/paper
|
158
|
+
value ^= value << 13;
|
159
|
+
value ^= value >> 17;
|
160
|
+
value ^= value << 5;
|
161
|
+
return value;
|
162
|
+
}
|
163
|
+
map(val, minFrom, maxFrom, minTo, maxTo) {
|
164
|
+
return ((val - minFrom) / (maxFrom - minFrom)) * (maxTo - minTo) + minTo;
|
165
|
+
}
|
166
|
+
hashCode(str) {
|
167
|
+
let hash = 0;
|
168
|
+
if (str) {
|
169
|
+
const l = str.length;
|
170
|
+
for (let i = 0; i < l; i++) {
|
171
|
+
hash = (hash << 5) - hash + str.charCodeAt(i);
|
172
|
+
hash |= 0;
|
173
|
+
hash = this.xorshift(hash);
|
174
|
+
}
|
175
|
+
}
|
176
|
+
return this.getSafeSeed(hash);
|
177
|
+
}
|
178
|
+
getSafeSeed(seed) {
|
179
|
+
if (seed === 0)
|
180
|
+
return 1;
|
181
|
+
return seed;
|
182
|
+
}
|
183
|
+
}
|
184
|
+
Prando.MIN = -2147483648; // Int32 min
|
185
|
+
Prando.MAX = 2147483647; // Int32 max
|
186
|
+
const Prando$1 = Prando;
|
187
|
+
|
188
|
+
const COLORS = ['red', 'orange', 'yellow', 'green', 'blue', 'purple'];
|
189
|
+
const GRADIENTS = {
|
190
|
+
red: ['#FF4270', '#FF7C7C'],
|
191
|
+
orange: ['#F45532', '#FF9B63'],
|
192
|
+
yellow: ['#FFA756', '#FBFF47'],
|
193
|
+
green: ['#0CAE60', '#7BFFD0'],
|
194
|
+
blue: ['#476FFF', '#47C8FF'],
|
195
|
+
purple: ['#9747FF', '#DA47FF'],
|
196
|
+
};
|
197
|
+
function getPseudoRandomBackground(seed) {
|
198
|
+
const rng = new Prando$1(seed);
|
199
|
+
const [start, stop] = GRADIENTS[COLORS[rng.nextInt(0, COLORS.length - 1)]];
|
200
|
+
return `linear-gradient(136deg, ${start} 6.86%, ${stop} 93.78%)`;
|
201
|
+
}
|
202
|
+
|
203
|
+
export { COLORS as C, Prando$1 as P, getPseudoRandomBackground as g };
|
204
|
+
|
205
|
+
//# sourceMappingURL=prand-c8323494.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{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;CAC/B,CAAC;SAEc,yBAAyB,CAAC,IAAY;IACpD,MAAM,GAAG,GAAG,IAAIA,QAAM,CAAC,IAAI,CAAC,CAAC;IAE7B,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,GAAG,SAAS,CAAC,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,EAAE,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IAE3E,OAAO,2BAA2B,KAAK,WAAW,IAAI,UAAU,CAAC;AACnE;;;;","names":["Prando"],"sources":["src/lib/prando.ts","src/utils/prand.ts"],"sourcesContent":["/*\n * This file contains code from prando, which is licensed under the MIT License:\n *\n * Copyright (c) 2016 Zeh Fernando\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nexport default class Prando {\n private static readonly MIN: number = -2147483648; // Int32 min\n private static readonly MAX: number = 2147483647; // Int32 max\n\n private _seed: number;\n private _value = NaN;\n\n // ================================================================================================================\n // CONSTRUCTOR ----------------------------------------------------------------------------------------------------\n\n /**\n * Generate a new Prando pseudo-random number generator.\n *\n * @param seed - A number or string seed that determines which pseudo-random number sequence will be created. Defaults to a random seed based on `Math.random()`.\n */\n constructor(seed?: number | string) {\n if (typeof seed === 'string') {\n // String seed\n this._seed = this.hashCode(seed);\n } else if (typeof seed === 'number') {\n // Numeric seed\n this._seed = this.getSafeSeed(seed);\n } else {\n // Pseudo-random seed\n this._seed = this.getSafeSeed(Prando.MIN + Math.floor((Prando.MAX - Prando.MIN) * Math.random()));\n }\n this.reset();\n }\n\n // ================================================================================================================\n // PUBLIC INTERFACE -----------------------------------------------------------------------------------------------\n\n /**\n * Generates a pseudo-random number between a lower (inclusive) and a higher (exclusive) bounds.\n *\n * @param min - The minimum number that can be randomly generated.\n * @param pseudoMax - The maximum number that can be randomly generated (exclusive).\n * @return The generated pseudo-random number.\n */\n public next(min = 0, pseudoMax = 1): number {\n this.recalculate();\n return this.map(this._value, Prando.MIN, Prando.MAX, min, pseudoMax);\n }\n\n /**\n * Generates a pseudo-random integer number in a range (inclusive).\n *\n * @param min - The minimum number that can be randomly generated.\n * @param max - The maximum number that can be randomly generated.\n * @return The generated pseudo-random number.\n */\n public nextInt(min = 10, max = 100): number {\n this.recalculate();\n return Math.floor(this.map(this._value, Prando.MIN, Prando.MAX, min, max + 1));\n }\n\n /**\n * Generates a pseudo-random string sequence of a particular length from a specific character range.\n *\n * Note: keep in mind that creating a random string sequence does not guarantee uniqueness; there is always a\n * 1 in (char_length^string_length) chance of collision. For real unique string ids, always check for\n * pre-existing ids, or employ a robust GUID/UUID generator.\n *\n * @param length - Length of the string to be generated.\n * @param chars - Characters that are used when creating the random string. Defaults to all alphanumeric chars (A-Z, a-z, 0-9).\n * @return The generated string sequence.\n */\n public nextString(length = 16, chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'): string {\n let str = '';\n while (str.length < length) {\n str += this.nextChar(chars);\n }\n return str;\n }\n\n /**\n * Generates a pseudo-random string of 1 character specific character range.\n *\n * @param chars - Characters that are used when creating the random string. Defaults to all alphanumeric chars (A-Z, a-z, 0-9).\n * @return The generated character.\n */\n public nextChar(chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'): string {\n return chars.substr(this.nextInt(0, chars.length - 1), 1);\n }\n\n /**\n * Picks a pseudo-random item from an array. The array is left unmodified.\n *\n * Note: keep in mind that while the returned item will be random enough, picking one item from the array at a time\n * does not guarantee nor imply that a sequence of random non-repeating items will be picked. If you want to\n * *pick items in a random order* from an array, instead of *pick one random item from an array*, it's best to\n * apply a *shuffle* transformation to the array instead, then read it linearly.\n *\n * @param array - Array of any type containing one or more candidates for random picking.\n * @return An item from the array.\n */\n public nextArrayItem<T>(array: T[]): T {\n return array[this.nextInt(0, array.length - 1)];\n }\n\n /**\n * Generates a pseudo-random boolean.\n *\n * @return A value of true or false.\n */\n public nextBoolean(): boolean {\n this.recalculate();\n return this._value > 0.5;\n }\n\n /**\n * Skips ahead in the sequence of numbers that are being generated. This is equivalent to\n * calling next() a specified number of times, but faster since it doesn't need to map the\n * new random numbers to a range and return it.\n *\n * @param iterations - The number of items to skip ahead.\n */\n public skip(iterations = 1): void {\n while (iterations-- > 0) {\n this.recalculate();\n }\n }\n\n /**\n * Reset the pseudo-random number sequence back to its starting seed. Further calls to next()\n * will then produce the same sequence of numbers it had produced before. This is equivalent to\n * creating a new Prando instance with the same seed as another Prando instance.\n *\n * Example:\n * let rng = new Prando(12345678);\n * console.log(rng.next()); // 0.6177754114889017\n * console.log(rng.next()); // 0.5784605181725837\n * rng.reset();\n * console.log(rng.next()); // 0.6177754114889017 again\n * console.log(rng.next()); // 0.5784605181725837 again\n */\n public reset(): void {\n this._value = this._seed;\n }\n\n // ================================================================================================================\n // PRIVATE INTERFACE ----------------------------------------------------------------------------------------------\n\n private recalculate(): void {\n this._value = this.xorshift(this._value);\n }\n\n private xorshift(value: number): number {\n // Xorshift*32\n // Based on George Marsaglia's work: http://www.jstatsoft.org/v08/i14/paper\n value ^= value << 13;\n value ^= value >> 17;\n value ^= value << 5;\n return value;\n }\n\n private map(val: number, minFrom: number, maxFrom: number, minTo: number, maxTo: number): number {\n return ((val - minFrom) / (maxFrom - minFrom)) * (maxTo - minTo) + minTo;\n }\n\n private hashCode(str: string): number {\n let hash = 0;\n if (str) {\n const l = str.length;\n for (let i = 0; i < l; i++) {\n hash = (hash << 5) - hash + str.charCodeAt(i);\n hash |= 0;\n hash = this.xorshift(hash);\n }\n }\n return this.getSafeSeed(hash);\n }\n\n private getSafeSeed(seed: number): number {\n if (seed === 0) return 1;\n return seed;\n }\n}\n","import Prando from '../lib/prando';\n\nexport type Color = 'red' | 'orange' | 'yellow' | 'green' | 'blue' | 'purple';\n\nexport const COLORS: Color[] = ['red', 'orange', 'yellow', 'green', 'blue', 'purple'];\n\nconst GRADIENTS = {\n red: ['#FF4270', '#FF7C7C'],\n orange: ['#F45532', '#FF9B63'],\n yellow: ['#FFA756', '#FBFF47'],\n green: ['#0CAE60', '#7BFFD0'],\n blue: ['#476FFF', '#47C8FF'],\n purple: ['#9747FF', '#DA47FF'],\n};\n\nexport function getPseudoRandomBackground(seed: string): string {\n const rng = new Prando(seed);\n\n const [start, stop] = GRADIENTS[COLORS[rng.nextInt(0, COLORS.length - 1)]];\n\n return `linear-gradient(136deg, ${start} 6.86%, ${stop} 93.78%)`;\n}\n"],"version":3}
|
@@ -1,5 +1,6 @@
|
|
1
1
|
export declare const Icons: {
|
2
2
|
alertCircle: string;
|
3
|
+
alertTriangle: string;
|
3
4
|
angelListBrand: string;
|
4
5
|
angelList: string;
|
5
6
|
appleBrand: string;
|
@@ -14,6 +15,7 @@ export declare const Icons: {
|
|
14
15
|
capsuleRingsDark: string;
|
15
16
|
capsuleRings: string;
|
16
17
|
capsule: string;
|
18
|
+
checkCircleFilled: string;
|
17
19
|
checkCircle: string;
|
18
20
|
check: string;
|
19
21
|
chevronUp: string;
|
@@ -22,6 +24,7 @@ export declare const Icons: {
|
|
22
24
|
clubhouseBrand: string;
|
23
25
|
clubhouse: string;
|
24
26
|
copy: string;
|
27
|
+
cosmos: string;
|
25
28
|
creditCard: string;
|
26
29
|
cube: string;
|
27
30
|
decentBrand: string;
|
@@ -34,6 +37,7 @@ export declare const Icons: {
|
|
34
37
|
dribbbleBrand: string;
|
35
38
|
dribbble: string;
|
36
39
|
earth: string;
|
40
|
+
ethereum: string;
|
37
41
|
eyeOff: string;
|
38
42
|
eye: string;
|
39
43
|
facebookBrand: string;
|
@@ -97,6 +101,7 @@ export declare const Icons: {
|
|
97
101
|
signal: string;
|
98
102
|
snapchatBrand: string;
|
99
103
|
snapchat: string;
|
104
|
+
solana: string;
|
100
105
|
stars: string;
|
101
106
|
stripeBrand: string;
|
102
107
|
telegramBrand: string;
|
@@ -10,6 +10,10 @@ export declare class CpslAlert {
|
|
10
10
|
* Default is: `"error"`.
|
11
11
|
*/
|
12
12
|
variant?: 'error' | 'warning' | 'success' | 'custom';
|
13
|
+
/**
|
14
|
+
* Whether to show the alert with a filled background based on the variant
|
15
|
+
*/
|
16
|
+
filled?: boolean;
|
13
17
|
private get iconType();
|
14
18
|
render(): any;
|
15
19
|
}
|
@@ -1,9 +1,10 @@
|
|
1
1
|
export declare class CpslIdenticon {
|
2
|
-
hash
|
2
|
+
hash?: string | undefined;
|
3
3
|
/**
|
4
|
-
* The
|
5
|
-
* Default is:
|
4
|
+
* The CSS width and height of the identicon.
|
5
|
+
* Default is: 40px.
|
6
6
|
*/
|
7
|
-
size:
|
7
|
+
size: string;
|
8
|
+
variant: 'default' | 'avatar';
|
8
9
|
render(): any;
|
9
10
|
}
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { EventEmitter } from '../../stencil-public-runtime';
|
2
|
-
import { TabClickEventDetail } from './tab-interface';
|
2
|
+
import { TabClickEventDetail, TabSizeChangeEventDetail } from './tab-interface';
|
3
3
|
import { TabsChangedEventDetail } from '../cpsl-tabs/tabs-interface';
|
4
4
|
export declare class CpslTab {
|
5
5
|
el: HTMLCpslTabElement;
|
@@ -17,8 +17,14 @@ export declare class CpslTab {
|
|
17
17
|
* @internal
|
18
18
|
*/
|
19
19
|
cpslTabButtonClick: EventEmitter<TabClickEventDetail>;
|
20
|
+
/**
|
21
|
+
* Emitted when tab size changes
|
22
|
+
* @internal
|
23
|
+
*/
|
24
|
+
cpslTabButtonSizeChange: EventEmitter<TabSizeChangeEventDetail>;
|
20
25
|
onTabsChanged(ev: CustomEvent<TabsChangedEventDetail>): void;
|
21
26
|
onTabsInit(ev: CustomEvent<TabsChangedEventDetail>): void;
|
27
|
+
componentDidLoad(): void;
|
22
28
|
private setSelected;
|
23
29
|
private onTabClicked;
|
24
30
|
render(): any;
|
@@ -1,4 +1,5 @@
|
|
1
1
|
import { EventEmitter } from '../../stencil-public-runtime';
|
2
|
+
import { TabSizeChangeEventDetail } from '../cpsl-tab/tab-interface';
|
2
3
|
import { TabsChangedEventDetail } from './tabs-interface';
|
3
4
|
export declare class CpslTabs {
|
4
5
|
el: HTMLCpslTabsElement;
|
@@ -23,6 +24,7 @@ export declare class CpslTabs {
|
|
23
24
|
cpslTabsInit: EventEmitter<TabsChangedEventDetail>;
|
24
25
|
updateSlider(): void;
|
25
26
|
updateTab(newValue?: string, oldValue?: string): void;
|
27
|
+
onTabSizeChange(ev: CustomEvent<TabSizeChangeEventDetail>): void;
|
26
28
|
componentWillLoad(): void;
|
27
29
|
componentDidLoad(): void;
|
28
30
|
private get tabs();
|
@@ -9,16 +9,20 @@ import { AutocompleteTypes, IconType, TextFieldTypes } from "./interface";
|
|
9
9
|
import { CodeChangeEventDetail } from "./components/cpsl-code-input/code-change-interface";
|
10
10
|
import { DropdownInputEventDetail } from "./components/cpsl-dropdown/dropdown-interface";
|
11
11
|
import { InputChangeEventDetail, InputInputEventDetail } from "./components/cpsl-input/input-interface";
|
12
|
-
import { TabClickEventDetail } from "./components/cpsl-tab/tab-interface";
|
12
|
+
import { TabClickEventDetail, TabSizeChangeEventDetail } from "./components/cpsl-tab/tab-interface";
|
13
13
|
import { TabsChangedEventDetail } from "./components/cpsl-tabs/tabs-interface";
|
14
14
|
export { AutocompleteTypes, IconType, TextFieldTypes } from "./interface";
|
15
15
|
export { CodeChangeEventDetail } from "./components/cpsl-code-input/code-change-interface";
|
16
16
|
export { DropdownInputEventDetail } from "./components/cpsl-dropdown/dropdown-interface";
|
17
17
|
export { InputChangeEventDetail, InputInputEventDetail } from "./components/cpsl-input/input-interface";
|
18
|
-
export { TabClickEventDetail } from "./components/cpsl-tab/tab-interface";
|
18
|
+
export { TabClickEventDetail, TabSizeChangeEventDetail } from "./components/cpsl-tab/tab-interface";
|
19
19
|
export { TabsChangedEventDetail } from "./components/cpsl-tabs/tabs-interface";
|
20
20
|
export namespace Components {
|
21
21
|
interface CpslAlert {
|
22
|
+
/**
|
23
|
+
* Whether to show the alert with a filled background based on the variant
|
24
|
+
*/
|
25
|
+
"filled"?: boolean;
|
22
26
|
/**
|
23
27
|
* The name of the icon to show.
|
24
28
|
*/
|
@@ -389,11 +393,12 @@ export namespace Components {
|
|
389
393
|
"icons": (IconType | string)[];
|
390
394
|
}
|
391
395
|
interface CpslIdenticon {
|
392
|
-
"hash"
|
396
|
+
"hash"?: string | undefined;
|
393
397
|
/**
|
394
|
-
* The
|
398
|
+
* The CSS width and height of the identicon. Default is: 40px.
|
395
399
|
*/
|
396
|
-
"size":
|
400
|
+
"size": string;
|
401
|
+
"variant": 'default' | 'avatar';
|
397
402
|
}
|
398
403
|
interface CpslInfoBox {
|
399
404
|
}
|
@@ -1332,6 +1337,7 @@ declare global {
|
|
1332
1337
|
};
|
1333
1338
|
interface HTMLCpslTabElementEventMap {
|
1334
1339
|
"cpslTabButtonClick": TabClickEventDetail;
|
1340
|
+
"cpslTabButtonSizeChange": TabSizeChangeEventDetail;
|
1335
1341
|
}
|
1336
1342
|
interface HTMLCpslTabElement extends Components.CpslTab, HTMLStencilElement {
|
1337
1343
|
addEventListener<K extends keyof HTMLCpslTabElementEventMap>(type: K, listener: (this: HTMLCpslTabElement, ev: CpslTabCustomEvent<HTMLCpslTabElementEventMap[K]>) => any, options?: boolean | AddEventListenerOptions): void;
|
@@ -1430,6 +1436,10 @@ declare global {
|
|
1430
1436
|
}
|
1431
1437
|
declare namespace LocalJSX {
|
1432
1438
|
interface CpslAlert {
|
1439
|
+
/**
|
1440
|
+
* Whether to show the alert with a filled background based on the variant
|
1441
|
+
*/
|
1442
|
+
"filled"?: boolean;
|
1433
1443
|
/**
|
1434
1444
|
* The name of the icon to show.
|
1435
1445
|
*/
|
@@ -1852,11 +1862,12 @@ declare namespace LocalJSX {
|
|
1852
1862
|
"icons"?: (IconType | string)[];
|
1853
1863
|
}
|
1854
1864
|
interface CpslIdenticon {
|
1855
|
-
"hash"?: string;
|
1865
|
+
"hash"?: string | undefined;
|
1856
1866
|
/**
|
1857
|
-
* The
|
1867
|
+
* The CSS width and height of the identicon. Default is: 40px.
|
1858
1868
|
*/
|
1859
|
-
"size"?:
|
1869
|
+
"size"?: string;
|
1870
|
+
"variant"?: 'default' | 'avatar';
|
1860
1871
|
}
|
1861
1872
|
interface CpslInfoBox {
|
1862
1873
|
}
|
package/dist/types/index.d.ts
CHANGED
@@ -0,0 +1,92 @@
|
|
1
|
+
export default class Prando {
|
2
|
+
private static readonly MIN;
|
3
|
+
private static readonly MAX;
|
4
|
+
private _seed;
|
5
|
+
private _value;
|
6
|
+
/**
|
7
|
+
* Generate a new Prando pseudo-random number generator.
|
8
|
+
*
|
9
|
+
* @param seed - A number or string seed that determines which pseudo-random number sequence will be created. Defaults to a random seed based on `Math.random()`.
|
10
|
+
*/
|
11
|
+
constructor(seed?: number | string);
|
12
|
+
/**
|
13
|
+
* Generates a pseudo-random number between a lower (inclusive) and a higher (exclusive) bounds.
|
14
|
+
*
|
15
|
+
* @param min - The minimum number that can be randomly generated.
|
16
|
+
* @param pseudoMax - The maximum number that can be randomly generated (exclusive).
|
17
|
+
* @return The generated pseudo-random number.
|
18
|
+
*/
|
19
|
+
next(min?: number, pseudoMax?: number): number;
|
20
|
+
/**
|
21
|
+
* Generates a pseudo-random integer number in a range (inclusive).
|
22
|
+
*
|
23
|
+
* @param min - The minimum number that can be randomly generated.
|
24
|
+
* @param max - The maximum number that can be randomly generated.
|
25
|
+
* @return The generated pseudo-random number.
|
26
|
+
*/
|
27
|
+
nextInt(min?: number, max?: number): number;
|
28
|
+
/**
|
29
|
+
* Generates a pseudo-random string sequence of a particular length from a specific character range.
|
30
|
+
*
|
31
|
+
* Note: keep in mind that creating a random string sequence does not guarantee uniqueness; there is always a
|
32
|
+
* 1 in (char_length^string_length) chance of collision. For real unique string ids, always check for
|
33
|
+
* pre-existing ids, or employ a robust GUID/UUID generator.
|
34
|
+
*
|
35
|
+
* @param length - Length of the string to be generated.
|
36
|
+
* @param chars - Characters that are used when creating the random string. Defaults to all alphanumeric chars (A-Z, a-z, 0-9).
|
37
|
+
* @return The generated string sequence.
|
38
|
+
*/
|
39
|
+
nextString(length?: number, chars?: string): string;
|
40
|
+
/**
|
41
|
+
* Generates a pseudo-random string of 1 character specific character range.
|
42
|
+
*
|
43
|
+
* @param chars - Characters that are used when creating the random string. Defaults to all alphanumeric chars (A-Z, a-z, 0-9).
|
44
|
+
* @return The generated character.
|
45
|
+
*/
|
46
|
+
nextChar(chars?: string): string;
|
47
|
+
/**
|
48
|
+
* Picks a pseudo-random item from an array. The array is left unmodified.
|
49
|
+
*
|
50
|
+
* Note: keep in mind that while the returned item will be random enough, picking one item from the array at a time
|
51
|
+
* does not guarantee nor imply that a sequence of random non-repeating items will be picked. If you want to
|
52
|
+
* *pick items in a random order* from an array, instead of *pick one random item from an array*, it's best to
|
53
|
+
* apply a *shuffle* transformation to the array instead, then read it linearly.
|
54
|
+
*
|
55
|
+
* @param array - Array of any type containing one or more candidates for random picking.
|
56
|
+
* @return An item from the array.
|
57
|
+
*/
|
58
|
+
nextArrayItem<T>(array: T[]): T;
|
59
|
+
/**
|
60
|
+
* Generates a pseudo-random boolean.
|
61
|
+
*
|
62
|
+
* @return A value of true or false.
|
63
|
+
*/
|
64
|
+
nextBoolean(): boolean;
|
65
|
+
/**
|
66
|
+
* Skips ahead in the sequence of numbers that are being generated. This is equivalent to
|
67
|
+
* calling next() a specified number of times, but faster since it doesn't need to map the
|
68
|
+
* new random numbers to a range and return it.
|
69
|
+
*
|
70
|
+
* @param iterations - The number of items to skip ahead.
|
71
|
+
*/
|
72
|
+
skip(iterations?: number): void;
|
73
|
+
/**
|
74
|
+
* Reset the pseudo-random number sequence back to its starting seed. Further calls to next()
|
75
|
+
* will then produce the same sequence of numbers it had produced before. This is equivalent to
|
76
|
+
* creating a new Prando instance with the same seed as another Prando instance.
|
77
|
+
*
|
78
|
+
* Example:
|
79
|
+
* let rng = new Prando(12345678);
|
80
|
+
* console.log(rng.next()); // 0.6177754114889017
|
81
|
+
* console.log(rng.next()); // 0.5784605181725837
|
82
|
+
* rng.reset();
|
83
|
+
* console.log(rng.next()); // 0.6177754114889017 again
|
84
|
+
* console.log(rng.next()); // 0.5784605181725837 again
|
85
|
+
*/
|
86
|
+
reset(): void;
|
87
|
+
private recalculate;
|
88
|
+
private xorshift;
|
89
|
+
private map;
|
90
|
+
private hashCode;
|
91
|
+
private getSafeSeed;
|
92
|
+
}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@usecapsule/core-components",
|
3
|
-
"version": "3.
|
3
|
+
"version": "3.5.1",
|
4
4
|
"description": "Capsule Core Components",
|
5
5
|
"main": "dist/index.cjs.js",
|
6
6
|
"module": "dist/index.js",
|
@@ -18,8 +18,8 @@
|
|
18
18
|
"scripts": {
|
19
19
|
"build": "yarn build:assets && yarn build:css && stencil build",
|
20
20
|
"start": "yarn build:assets && yarn build:css && stencil build --dev --watch --serve",
|
21
|
-
"test": "stencil test --spec
|
22
|
-
"test.watch": "stencil test --spec --
|
21
|
+
"test": "stencil test --spec",
|
22
|
+
"test.watch": "stencil test --spec --watchAll",
|
23
23
|
"generate": "stencil generate",
|
24
24
|
"build:css": "sass --embed-sources src/css:./css",
|
25
25
|
"build:assets": "ts-node -T ./scripts/buildAssets.ts",
|
@@ -60,5 +60,5 @@
|
|
60
60
|
"storybook-addon-stencil": "^0.2.1",
|
61
61
|
"ts-node": "^10.9.2"
|
62
62
|
},
|
63
|
-
"gitHead": "
|
63
|
+
"gitHead": "59624937c8ab48d266cfbf2604755ea38d2802b4"
|
64
64
|
}
|
@@ -1,2 +0,0 @@
|
|
1
|
-
import{r as t,h as e,H as o}from"./p-fa6b7678.js";const r=":host{--identicon-background-red:linear-gradient(136deg, #FF4270 6.86%, #FF7C7C 93.78%);--identicon-background-orange:linear-gradient(136deg, #F45532 6.86%, #FF9B63 93.78%);--identicon-background-yellow:linear-gradient(136deg, #FFA756 6.86%, #FBFF47 93.78%);--identicon-background-green:linear-gradient(136deg, #0CAE60 6.86%, #7BFFD0 93.78%);--identicon-background-blue:linear-gradient(136deg, #476FFF 6.86%, #47C8FF 93.78%);--identicon-background-purple:linear-gradient(136deg, #9747FF 6.86%, #DA47FF 93.78%);display:block;width:62px;height:62px;aspect-ratio:1;border-radius:6px;position:relative;border:1px solid var(--cpsl-color-background-8)}:host>svg{fill:rgba(255, 255, 255, 0.6);position:absolute;width:35%}:host>svg.rotate90{transform:rotate(0.25turn)}:host>svg.rotate180{transform:rotate(0.5turn)}:host>svg.rotate270{transform:rotate(0.75turn)}:host>svg:nth-child(1){right:50%;bottom:50%}:host>svg:nth-child(2){left:50%;bottom:50%}:host>svg:nth-child(3){right:50%;top:50%}:host>svg:nth-child(4){left:50%;top:50%}:host(.red){background:var(--identicon-background-red)}:host(.orange){background:var(--identicon-background-orange)}:host(.green){background:var(--identicon-background-green)}:host(.yellow){background:var(--identicon-background-yellow)}:host(.blue){background:var(--identicon-background-blue)}:host(.purple){background:var(--identicon-background-purple)}";const n=r;const d=t=>e("svg",{class:{rotate90:t===1,rotate180:t===2,rotate270:t===3},viewBox:"0 0 12 12",xmlns:"http://www.w3.org/2000/svg"},e("g",{"clip-path":"url(#clip0_674_66)"},e("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M12 24C18.6274 24 24 18.6274 24 12C24 5.37258 18.6274 0 12 0C5.37258 0 0 5.37258 0 12C0 18.6274 5.37258 24 12 24ZM12 21C16.9706 21 21 16.9706 21 12C21 7.02944 16.9706 3 12 3C7.02944 3 3 7.02944 3 12C3 16.9706 7.02944 21 12 21Z"})),e("defs",null,e("clipPath",{id:"clip0_674_66"},e("rect",{width:"12",height:"12"}))));const i=t=>e("svg",{class:{rotate90:t===1,rotate180:t===2,rotate270:t===3},viewBox:"0 0 12 12",xmlns:"http://www.w3.org/2000/svg"},e("g",{"clip-path":"url(#clip0_674_255)"},e("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M12 24C18.6274 24 24 18.6274 24 12C24 5.37258 18.6274 0 12 0C5.37258 0 0 5.37258 0 12C0 18.6274 5.37258 24 12 24ZM12 21C16.9706 21 21 16.9706 21 12C21 7.02944 16.9706 3 12 3C7.02944 3 3 7.02944 3 12C3 16.9706 7.02944 21 12 21Z"}),e("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M12 18C15.3137 18 18 15.3137 18 12C18 8.68629 15.3137 6 12 6C8.68629 6 6 8.68629 6 12C6 15.3137 8.68629 18 12 18ZM12 15C13.6569 15 15 13.6569 15 12C15 10.3431 13.6569 9 12 9C10.3431 9 9 10.3431 9 12C9 13.6569 10.3431 15 12 15Z"})),e("defs",null,e("clipPath",{id:"clip0_674_255"},e("rect",{width:"12",height:"12"}))));const a=class{constructor(e){t(this,e);this.hash=undefined;this.size=40}render(){const[t,r]=l(this.hash);const n=(t>>2&1)!==0;const a=(t>>3&1)!==0;const c=(t>>4&1)!==0;const s=(t>>5&1)!==0;const g=t>>6&3;const u=t>>7&3;const h=t>>8&3;const p=t>>9&3;const[b,v]=[[n,a,c,s],[g,u,h,p]];return e(o,{key:"39bcae00e3fd58ff94639fbb43c77fd942899e51",class:{red:r==="red",orange:r==="orange",yellow:r==="yellow",green:r==="green",blue:r==="blue",purple:r==="purple"}},b.map(((t,e)=>t?i(v[e]):d(v[e]))))}};const c=["red","orange","yellow","green","blue","purple"];function l(t){const e=t.charCodeAt(0)<<24|t.charCodeAt(1)<<16|t.charCodeAt(2)<<8|t.charCodeAt(3);const o=c[Math.abs(e%6)];return[e,o]}a.style=n;export{a as cpsl_identicon};
|
2
|
-
//# sourceMappingURL=p-5d62e610.entry.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"names":["cpslIdenticonCss","CpslIdenticonStyle0","SingleArc","rotation","h","class","rotate90","rotate180","rotate270","viewBox","xmlns","d","id","width","height","DoubleArc","CpslIdenticon","render","code","color","stringToBinaryAndColor","this","hash","shapeA","shapeB","shapeC","shapeD","rotationA","rotationB","rotationC","rotationD","shapes","rotations","Host","key","red","orange","yellow","green","blue","purple","map","isDouble","index","COLORS","charCodeAt","Math","abs"],"sources":["src/components/cpsl-identicon/cpsl-identicon.scss?tag=cpsl-identicon&encapsulation=shadow","src/components/cpsl-identicon/cpsl-identicon.tsx"],"sourcesContent":[":host {\n --identicon-background-red: linear-gradient(136deg, #FF4270 6.86%, #FF7C7C 93.78%);\n --identicon-background-orange: linear-gradient(136deg, #F45532 6.86%, #FF9B63 93.78%);\n --identicon-background-yellow: linear-gradient(136deg, #FFA756 6.86%, #FBFF47 93.78%);\n --identicon-background-green: linear-gradient(136deg, #0CAE60 6.86%, #7BFFD0 93.78%);\n --identicon-background-blue: linear-gradient(136deg, #476FFF 6.86%, #47C8FF 93.78%);\n --identicon-background-purple: linear-gradient(136deg, #9747FF 6.86%, #DA47FF 93.78%);\n\n display: block;\n width: 62px;\n height: 62px;\n aspect-ratio: 1;\n border-radius: 6px;\n position: relative;\n border: 1px solid var(--cpsl-color-background-8);\n\n & > svg {\n fill: rgba(255, 255, 255, 0.6);\n position: absolute;\n width: 35%;\n }\n\n & > svg.rotate90 {\n transform: rotate(.25turn);\n }\n\n & > svg.rotate180 {\n transform: rotate(.5turn);\n }\n\n & > svg.rotate270 {\n transform: rotate(.75turn);\n }\n\n & > svg:nth-child(1) {\n right: 50%;\n bottom: 50%;\n }\n\n & > svg:nth-child(2) {\n left: 50%;\n bottom: 50%;\n }\n\n & > svg:nth-child(3) {\n right: 50%;\n top: 50%;\n }\n\n & > svg:nth-child(4) {\n left: 50%;\n top: 50%;\n }\n}\n\n:host(.red) {\n background: var(--identicon-background-red);\n}\n\n:host(.orange) {\n background: var(--identicon-background-orange);\n}\n\n:host(.green) {\n background: var(--identicon-background-green);\n}\n\n:host(.yellow) {\n background: var(--identicon-background-yellow);\n}\n\n:host(.blue) {\n background: var(--identicon-background-blue);\n}\n\n:host(.purple) {\n background: var(--identicon-background-purple);\n}\n","import { Component, Host, Prop, h } from '@stencil/core';\n\nconst SingleArc = (rotation: number) => (\n <svg\n class={{\n rotate90: rotation === 1,\n rotate180: rotation === 2,\n rotate270: rotation === 3,\n }}\n viewBox=\"0 0 12 12\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <g clip-path=\"url(#clip0_674_66)\">\n <path\n fill-rule=\"evenodd\"\n clip-rule=\"evenodd\"\n d=\"M12 24C18.6274 24 24 18.6274 24 12C24 5.37258 18.6274 0 12 0C5.37258 0 0 5.37258 0 12C0 18.6274 5.37258 24 12 24ZM12 21C16.9706 21 21 16.9706 21 12C21 7.02944 16.9706 3 12 3C7.02944 3 3 7.02944 3 12C3 16.9706 7.02944 21 12 21Z\"\n />\n </g>\n <defs>\n <clipPath id=\"clip0_674_66\">\n <rect width=\"12\" height=\"12\" />\n </clipPath>\n </defs>\n </svg>\n);\n\nconst DoubleArc = (rotation: number) => (\n <svg\n class={{\n rotate90: rotation === 1,\n rotate180: rotation === 2,\n rotate270: rotation === 3,\n }}\n viewBox=\"0 0 12 12\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <g clip-path=\"url(#clip0_674_255)\">\n <path\n fill-rule=\"evenodd\"\n clip-rule=\"evenodd\"\n d=\"M12 24C18.6274 24 24 18.6274 24 12C24 5.37258 18.6274 0 12 0C5.37258 0 0 5.37258 0 12C0 18.6274 5.37258 24 12 24ZM12 21C16.9706 21 21 16.9706 21 12C21 7.02944 16.9706 3 12 3C7.02944 3 3 7.02944 3 12C3 16.9706 7.02944 21 12 21Z\"\n />\n <path\n fill-rule=\"evenodd\"\n clip-rule=\"evenodd\"\n d=\"M12 18C15.3137 18 18 15.3137 18 12C18 8.68629 15.3137 6 12 6C8.68629 6 6 8.68629 6 12C6 15.3137 8.68629 18 12 18ZM12 15C13.6569 15 15 13.6569 15 12C15 10.3431 13.6569 9 12 9C10.3431 9 9 10.3431 9 12C9 13.6569 10.3431 15 12 15Z\"\n />\n </g>\n <defs>\n <clipPath id=\"clip0_674_255\">\n <rect width=\"12\" height=\"12\" />\n </clipPath>\n </defs>\n </svg>\n);\n\n@Component({\n tag: 'cpsl-identicon',\n styleUrl: 'cpsl-identicon.scss',\n shadow: true,\n})\nexport class CpslIdenticon {\n @Prop() hash: string;\n\n /**\n * The size of the identicon.\n * Default is: 40.\n */\n @Prop() size: number = 40;\n\n render() {\n const [code, color] = stringToBinaryAndColor(this.hash);\n const shapeA = ((code >> 2) & 1) !== 0;\n const shapeB = ((code >> 3) & 1) !== 0;\n const shapeC = ((code >> 4) & 1) !== 0;\n const shapeD = ((code >> 5) & 1) !== 0;\n const rotationA = (code >> 6) & 3;\n const rotationB = (code >> 7) & 3;\n const rotationC = (code >> 8) & 3;\n const rotationD = (code >> 9) & 3;\n\n const [shapes, rotations] = [\n [shapeA, shapeB, shapeC, shapeD],\n [rotationA, rotationB, rotationC, rotationD],\n ];\n\n return (\n <Host\n class={{\n red: color === 'red',\n orange: color === 'orange',\n yellow: color === 'yellow',\n green: color === 'green',\n blue: color === 'blue',\n purple: color === 'purple',\n }}\n >\n {shapes.map((isDouble, index) => {\n return isDouble ? DoubleArc(rotations[index]) : SingleArc(rotations[index]);\n })}\n </Host>\n );\n }\n}\n\ntype Color = 'red' | 'orange' | 'yellow' | 'green' | 'blue' | 'purple';\n\nconst COLORS: Color[] = ['red', 'orange', 'yellow', 'green', 'blue', 'purple'];\n\nfunction stringToBinaryAndColor(hash: string): [number, Color] {\n const code = (hash.charCodeAt(0) << 24) | (hash.charCodeAt(1) << 16) | (hash.charCodeAt(2) << 8) | hash.charCodeAt(3);\n\n const color = COLORS[Math.abs(code % 6)];\n\n return [code, color];\n}\n"],"mappings":"kDAAA,MAAMA,EAAmB,k2CACzB,MAAAC,EAAeD,ECCf,MAAME,EAAaC,GACjBC,EAAA,OACEC,MAAO,CACLC,SAAUH,IAAa,EACvBI,UAAWJ,IAAa,EACxBK,UAAWL,IAAa,GAE1BM,QAAQ,YACRC,MAAM,8BAENN,EAAA,iBAAa,sBACXA,EAAA,oBACY,UAAS,YACT,UACVO,EAAE,wOAGNP,EAAA,YACEA,EAAA,YAAUQ,GAAG,gBACXR,EAAA,QAAMS,MAAM,KAAKC,OAAO,UAMhC,MAAMC,EAAaZ,GACjBC,EAAA,OACEC,MAAO,CACLC,SAAUH,IAAa,EACvBI,UAAWJ,IAAa,EACxBK,UAAWL,IAAa,GAE1BM,QAAQ,YACRC,MAAM,8BAENN,EAAA,iBAAa,uBACXA,EAAA,oBACY,UAAS,YACT,UACVO,EAAE,uOAEJP,EAAA,oBACY,UAAS,YACT,UACVO,EAAE,wOAGNP,EAAA,YACEA,EAAA,YAAUQ,GAAG,iBACXR,EAAA,QAAMS,MAAM,KAAKC,OAAO,U,MAWnBE,EAAa,M,uDAOD,E,CAEvB,MAAAC,GACE,MAAOC,EAAMC,GAASC,EAAuBC,KAAKC,MAClD,MAAMC,GAAWL,GAAQ,EAAK,KAAO,EACrC,MAAMM,GAAWN,GAAQ,EAAK,KAAO,EACrC,MAAMO,GAAWP,GAAQ,EAAK,KAAO,EACrC,MAAMQ,GAAWR,GAAQ,EAAK,KAAO,EACrC,MAAMS,EAAaT,GAAQ,EAAK,EAChC,MAAMU,EAAaV,GAAQ,E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