@swisspost/design-system-components 1.3.2 → 1.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. package/dist/cjs/{index-a8b23f1b.js → index-126f28cf.js} +1 -11
  2. package/dist/cjs/index-126f28cf.js.map +1 -0
  3. package/dist/cjs/loader.cjs.js +3 -3
  4. package/dist/cjs/loader.cjs.js.map +1 -1
  5. package/dist/cjs/{check-type-f24cf91d.js → package-3838cb5b.js} +4 -1
  6. package/dist/cjs/{check-type-f24cf91d.js.map → package-3838cb5b.js.map} +1 -1
  7. package/dist/cjs/post-collapsible.cjs.entry.js +6 -6
  8. package/dist/cjs/post-collapsible.cjs.entry.js.map +1 -1
  9. package/dist/cjs/post-components.cjs.js +3 -3
  10. package/dist/cjs/post-components.cjs.js.map +1 -1
  11. package/dist/cjs/post-icon.cjs.entry.js +101 -62
  12. package/dist/cjs/post-icon.cjs.entry.js.map +1 -1
  13. package/dist/collection/collection-manifest.json +1 -1
  14. package/dist/collection/components/post-collapsible/post-collapsible.css +184 -82
  15. package/dist/collection/components/post-collapsible/post-collapsible.js +3 -2
  16. package/dist/collection/components/post-collapsible/post-collapsible.js.map +1 -1
  17. package/dist/collection/components/post-icon/post-icon.css +10 -10
  18. package/dist/collection/components/post-icon/post-icon.js +119 -74
  19. package/dist/collection/components/post-icon/post-icon.js.map +1 -1
  20. package/dist/collection/index.js.map +1 -1
  21. package/dist/collection/utils/get-element-height.js.map +1 -1
  22. package/dist/collection/utils/index.js.map +1 -1
  23. package/dist/collection/utils/on-transition-end.js.map +1 -1
  24. package/dist/collection/utils/property-checkers/check-non-empty.js +7 -0
  25. package/dist/collection/utils/property-checkers/check-non-empty.js.map +1 -0
  26. package/dist/collection/utils/property-checkers/check-one-of.js.map +1 -1
  27. package/dist/collection/utils/property-checkers/check-type.js.map +1 -1
  28. package/dist/collection/utils/property-checkers/constants.js +2 -0
  29. package/dist/collection/utils/property-checkers/constants.js.map +1 -0
  30. package/dist/collection/utils/property-checkers/empty-or.js +1 -1
  31. package/dist/collection/utils/property-checkers/empty-or.js.map +1 -1
  32. package/dist/collection/utils/property-checkers/index.js +1 -0
  33. package/dist/collection/utils/property-checkers/index.js.map +1 -1
  34. package/dist/collection/utils/should-reduce-motion.js.map +1 -1
  35. package/dist/components/{check-type.js → package.js} +4 -2
  36. package/dist/components/package.js.map +1 -0
  37. package/dist/components/post-collapsible.js +4 -4
  38. package/dist/components/post-collapsible.js.map +1 -1
  39. package/dist/components/post-icon.js +99 -58
  40. package/dist/components/post-icon.js.map +1 -1
  41. package/dist/docs.json +35 -8
  42. package/dist/esm/{index-401f2d6a.js → index-286143e7.js} +1 -11
  43. package/dist/esm/index-286143e7.js.map +1 -0
  44. package/dist/esm/loader.js +4 -4
  45. package/dist/esm/loader.js.map +1 -1
  46. package/dist/esm/{check-type-67411ed3.js → package-fb4a74d0.js} +4 -2
  47. package/dist/esm/package-fb4a74d0.js.map +1 -0
  48. package/dist/esm/post-collapsible.entry.js +4 -4
  49. package/dist/esm/post-collapsible.entry.js.map +1 -1
  50. package/dist/esm/post-components.js +4 -4
  51. package/dist/esm/post-components.js.map +1 -1
  52. package/dist/esm/post-icon.entry.js +98 -59
  53. package/dist/esm/post-icon.entry.js.map +1 -1
  54. package/dist/post-components/{p-f214c52a.js → p-0c286590.js} +3 -3
  55. package/dist/post-components/p-0c286590.js.map +1 -0
  56. package/dist/post-components/p-6e225c16.entry.js +2 -0
  57. package/dist/post-components/p-6e225c16.entry.js.map +1 -0
  58. package/dist/post-components/p-7dd960f1.entry.js +2 -0
  59. package/dist/post-components/p-7dd960f1.entry.js.map +1 -0
  60. package/dist/post-components/p-87bf3416.js +2 -0
  61. package/dist/post-components/{p-f549b3fc.js.map → p-87bf3416.js.map} +1 -1
  62. package/dist/post-components/post-components.esm.js +1 -1
  63. package/dist/post-components/post-components.esm.js.map +1 -1
  64. package/dist/types/components/post-icon/post-icon.d.ts +21 -12
  65. package/dist/types/components.d.ts +17 -17
  66. package/dist/types/utils/property-checkers/check-non-empty.d.ts +1 -0
  67. package/dist/types/utils/property-checkers/constants.d.ts +1 -0
  68. package/dist/types/utils/property-checkers/index.d.ts +1 -0
  69. package/package.json +16 -17
  70. package/dist/cjs/index-a8b23f1b.js.map +0 -1
  71. package/dist/components/check-type.js.map +0 -1
  72. package/dist/esm/check-type-67411ed3.js.map +0 -1
  73. package/dist/esm/index-401f2d6a.js.map +0 -1
  74. package/dist/post-components/p-07a51673.entry.js +0 -2
  75. package/dist/post-components/p-07a51673.entry.js.map +0 -1
  76. package/dist/post-components/p-416f1e74.entry.js +0 -2
  77. package/dist/post-components/p-416f1e74.entry.js.map +0 -1
  78. package/dist/post-components/p-f214c52a.js.map +0 -1
  79. package/dist/post-components/p-f549b3fc.js +0 -2
@@ -1 +1 @@
1
- {"file":"post-collapsible.entry.js","mappings":";;;SAGgB,gBAAgB,CAAC,EAAe,EAAE,mBAAsC,EAAE;EACxF,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,gBAAgB,CAAC;IAAE,gBAAgB,GAAG,CAAC,gBAAgB,CAAC,CAAC;EAE5E,MAAM,YAAY,GAAG,gBAAgB,CAAC,MAAM,CAAC,KAAK,IAAI,CAAC,EAAE,CAAC,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC;EACrF,IAAI,YAAY,CAAC,MAAM;IAAE,EAAE,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,YAAY,CAAC,CAAC;EAE3D,MAAM,YAAY,GAAG,EAAE,CAAC,YAAY,CAAC;EAErC,IAAI,YAAY,CAAC,MAAM;IAAE,EAAE,CAAC,SAAS,CAAC,MAAM,CAAC,GAAG,YAAY,CAAC,CAAC;EAE9D,OAAO,YAAY,CAAC;AACtB;;SCdgB,kBAAkB;EAChC,OAAO,MAAM,CAAC,UAAU,CAAC,kCAAkC,CAAC,CAAC,OAAO,CAAC;AACvE;;ACAO,eAAe,eAAe,CAAC,EAAe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AC,cAAc,GAAG,GAAG,IAAI,CAAC,MAAM,GAAG,cAAc,GAAG,CAAC,IAAI,CAAC;KAC/D,EAAE,EAAE,CAAC,CAAC;GACR;EAEO,kBAAkB;IACxB,OAAO,IAAI,CAAC,MAAM,GAAG,eAAe,GAAG,UAAU,CAAC;GACnD;EAED,MAAM;IACJ,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE;MACnB,QACE,WACE,EAAE,EAAE,GAAG,IAAI,CAAC,aAAa,YAAY,EACrC,KAAK,EAAE,IAAI,CAAC,eAAe,EAC3B,KAAK,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,cAAc,EAAE,IAEtC,eAAO,CACH,EACN;KACH;IAED,QACE,WAAK,KAAK,EAAC,gBAAgB,IACzB,EAAC,IAAI,CAAC,UAAU,IAAC,KAAK,EAAC,kBAAkB,EAAC,EAAE,EAAE,GAAG,IAAI,CAAC,aAAa,UAAU,IAC3E,cACE,KAAK,EAAE,oBAAoB,IAAI,CAAC,MAAM,GAAG,EAAE,GAAG,WAAW,EAAE,EAC3D,IAAI,EAAC,QAAQ,mBACE,GAAG,IAAI,CAAC,MAAM,EAAE,mBAChB,GAAG,IAAI,CAAC,aAAa,YAAY,EAChD,OAAO,EAAE,IAAI,CAAC,sBAAsB,IAEpC,YAAM,IAAI,EAAC,QAAQ,GAAE,CACd,CACO,EAClB,WACE,EAAE,EAAE,GAAG,IAAI,CAAC,aAAa,YAAY,EACrC,KAAK,EAAE,sBAAsB,IAAI,CAAC,eAAe,EAAE,EACnD,KAAK,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,cAAc,EAAE,qBACrB,GAAG,IAAI,CAAC,aAAa,UAAU,IAEhD,WAAK,KAAK,EAAC,gBAAgB,IACzB,eAAO,CACH,CACF,CACF,EACN;GACH;;;;;;;;;;;","names":[],"sources":["./src/utils/get-element-height.ts","./src/utils/should-reduce-motion.ts","./src/utils/on-transition-end.ts","./src/components/post-collapsible/post-collapsible.scss?tag=post-collapsible&encapsulation=shadow","./src/components/post-collapsible/post-collapsible.tsx"],"sourcesContent":["export function getElementHeight(el: HTMLElement): number;\nexport function getElementHeight(el: HTMLElement, classWhenShown: string): number;\nexport function getElementHeight(el: HTMLElement, classesWhenShown: string[]): number;\nexport function getElementHeight(el: HTMLElement, classesWhenShown: string | string[] = []): number {\n if (!Array.isArray(classesWhenShown)) classesWhenShown = [classesWhenShown];\n\n const classesToAdd = classesWhenShown.filter(klass => !el.classList.contains(klass));\n if (classesToAdd.length) el.classList.add(...classesToAdd);\n\n const scrollHeight = el.scrollHeight;\n\n if (classesToAdd.length) el.classList.remove(...classesToAdd);\n\n return scrollHeight;\n}\n","export function shouldReduceMotion(): boolean {\n return window.matchMedia('(prefers-reduced-motion: reduce)').matches;\n}\n","import { shouldReduceMotion } from './should-reduce-motion';\n\nexport async function onTransitionEnd(el: HTMLElement): Promise<void> {\n return new Promise(resolve => {\n if (shouldReduceMotion()) {\n resolve();\n } else {\n el.ontransitionend = () => {\n resolve();\n el.ontransitionend = null;\n };\n }\n });\n}\n","@use '@swisspost/design-system-styles/basics';\n@use '@swisspost/design-system-styles/components/accordion';\n@use '@swisspost/design-system-styles/components/transitions';\n\n:host {\n display: block;\n}\n","import { Component, Element, h, Method, Prop, State, Watch } from '@stencil/core';\nimport { checkOneOf, checkType, getElementHeight, onTransitionEnd } from '../../utils';\n\nlet nextId = 0;\n\n@Component({\n tag: 'post-collapsible',\n styleUrl: 'post-collapsible.scss',\n shadow: true,\n})\nexport class PostCollapsible {\n private collapsibleElement: HTMLElement;\n private isLoaded = false;\n\n @Element() host: HTMLPostCollapsibleElement;\n\n @State() collapseClasses: string;\n @State() collapseHeight: string | null = null;\n @State() collapsibleId: string;\n @State() hasHeader: boolean;\n @State() headingTag: string | undefined;\n @State() isOpen = true;\n @State() onAccordionButtonClick = () => this.toggle();\n\n /**\n * If `true`, the element is initially collapsed otherwise it is displayed.\n */\n @Prop() readonly collapsed?: boolean = false;\n\n @Watch('collapsed')\n validateCollapsed(newValue = this.collapsed) {\n checkType(newValue, 'boolean', 'The post-collapsible \"collapsed\" prop should be a boolean.');\n\n if (!this.isLoaded) {\n this.isOpen = !newValue;\n this.collapseClasses = this.getCollapseClasses();\n } else {\n setTimeout(() => {\n this.toggle(!newValue);\n });\n }\n }\n\n /**\n * Defines the hierarchical level of the collapsible header within the headings structure.\n */\n @Prop() readonly headingLevel?: number = 2;\n\n @Watch('headingLevel')\n validateHeadingLevel(newValue = this.headingLevel) {\n checkOneOf(\n newValue,\n [ 1, 2, 3, 4, 5, 6 ],\n 'The post-collapsible element requires a heading level between 1 and 6.',\n );\n\n this.headingTag = `h${newValue}`;\n }\n\n componentWillLoad() {\n this.validateCollapsed();\n this.validateHeadingLevel();\n\n this.hasHeader = this.host.querySelectorAll('[slot=\"header\"]').length > 0;\n if (!this.hasHeader) {\n console.warn('Be sure to bind the post-collapsible to its control using aria-controls and aria-expanded attributes. More information here: https://getbootstrap.com/docs/5.2/components/collapse/#accessibility');\n }\n\n this.collapsibleId = this.host.id || `post-collapsible-${nextId++}`;\n this.collapseClasses = this.getCollapseClasses();\n }\n\n componentDidLoad() {\n this.isLoaded = true;\n this.collapsibleElement = this.host.shadowRoot.querySelector(`#${this.collapsibleId}--collapse`);\n }\n\n /**\n * Triggers the collapse programmatically.\n */\n @Method()\n async toggle(open = !this.isOpen): Promise<boolean> {\n if (open !== this.isOpen) {\n this.isOpen = !this.isOpen;\n\n this.startTransition();\n\n await onTransitionEnd(this.collapsibleElement).then(() => {\n this.collapseHeight = null;\n this.collapseClasses = this.getCollapseClasses();\n });\n\n return this.isOpen;\n }\n }\n\n private startTransition() {\n const expandedHeight = getElementHeight(this.collapsibleElement, 'show');\n\n this.collapseHeight = `${this.isOpen ? 0 : expandedHeight}px`;\n this.collapseClasses = 'collapsing';\n\n setTimeout(() => {\n this.collapseHeight = `${this.isOpen ? expandedHeight : 0}px`;\n }, 50);\n }\n\n private getCollapseClasses() {\n return this.isOpen ? 'collapse show' : 'collapse';\n }\n\n render() {\n if (!this.hasHeader) {\n return (\n <div\n id={`${this.collapsibleId}--collapse`}\n class={this.collapseClasses}\n style={{ height: this.collapseHeight }}\n >\n <slot/>\n </div>\n );\n }\n\n return (\n <div class=\"accordion-item\">\n <this.headingTag class=\"accordion-header\" id={`${this.collapsibleId}--header`}>\n <button\n class={`accordion-button ${this.isOpen ? '' : 'collapsed'}`}\n type=\"button\"\n aria-expanded={`${this.isOpen}`}\n aria-controls={`${this.collapsibleId}--collapse`}\n onClick={this.onAccordionButtonClick}\n >\n <slot name=\"header\"/>\n </button>\n </this.headingTag>\n <div\n id={`${this.collapsibleId}--collapse`}\n class={`accordion-collapse ${this.collapseClasses}`}\n style={{ height: this.collapseHeight }}\n aria-labelledby={`${this.collapsibleId}--header`}\n >\n <div class=\"accordion-body\">\n <slot/>\n </div>\n </div>\n </div>\n );\n }\n}\n"],"version":3}
1
+ {"file":"post-collapsible.entry.js","mappings":";;;SAGgB,gBAAgB,CAAC,EAAe,EAAE,mBAAsC,EAAE;EACxF,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,gBAAgB,CAAC;IAAE,gBAAgB,GAAG,CAAC,gBAAgB,CAAC,CAAC;EAE5E,MAAM,YAAY,GAAG,gBAAgB,CAAC,MAAM,CAAC,KAAK,IAAI,CAAC,EAAE,CAAC,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC;EACrF,IAAI,YAAY,CAAC,MAAM;IAAE,EAAE,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,YAAY,CAAC,CAAC;EAE3D,MAAM,YAAY,GAAG,EAAE,CAAC,YAAY,CAAC;EAErC,IAAI,YAAY,CAAC,MAAM;IAAE,EAAE,CAAC,SAAS,CAAC,MAAM,CAAC,GAAG,YAAY,CAAC,CAAC;EAE9D,OAAO,YAAY,CAAC;AACtB;;SCdgB,kBAAkB;EAChC,OAAO,MAAM,CAAC,UAAU,CAAC,kCAAkC,CAAC,CAAC,OAAO,CAAC;AACvE;;ACA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","./src/utils/on-transition-end.ts","./src/components/post-collapsible/post-collapsible.scss?tag=post-collapsible&encapsulation=shadow","./src/components/post-collapsible/post-collapsible.tsx"],"sourcesContent":["export function getElementHeight(el: HTMLElement): number;\nexport function getElementHeight(el: HTMLElement, classWhenShown: string): number;\nexport function getElementHeight(el: HTMLElement, classesWhenShown: string[]): number;\nexport function getElementHeight(el: HTMLElement, classesWhenShown: string | string[] = []): number {\n if (!Array.isArray(classesWhenShown)) classesWhenShown = [classesWhenShown];\n\n const classesToAdd = classesWhenShown.filter(klass => !el.classList.contains(klass));\n if (classesToAdd.length) el.classList.add(...classesToAdd);\n\n const scrollHeight = el.scrollHeight;\n\n if (classesToAdd.length) el.classList.remove(...classesToAdd);\n\n return scrollHeight;\n}\n","export function shouldReduceMotion(): boolean {\n return window.matchMedia('(prefers-reduced-motion: reduce)').matches;\n}\n","import { shouldReduceMotion } from './should-reduce-motion';\n\nexport async function onTransitionEnd(el: HTMLElement): Promise<void> {\n return new Promise(resolve => {\n if (shouldReduceMotion()) {\n resolve();\n } else {\n el.ontransitionend = () => {\n resolve();\n el.ontransitionend = null;\n };\n }\n });\n}\n","@use '@swisspost/design-system-styles/basics';\n@use '@swisspost/design-system-styles/components/accordion';\n@use '@swisspost/design-system-styles/components/transitions';\n\n:host {\n display: block;\n}\n","import { Component, Element, h, Host, Method, Prop, State, Watch } from '@stencil/core';\nimport { checkOneOf, checkType, getElementHeight, onTransitionEnd } from '../../utils';\nimport { version } from '../../../package.json';\n\nlet nextId = 0;\n\n@Component({\n tag: 'post-collapsible',\n styleUrl: 'post-collapsible.scss',\n shadow: true,\n})\nexport class PostCollapsible {\n private collapsibleElement: HTMLElement;\n private isLoaded = false;\n\n @Element() host: HTMLPostCollapsibleElement;\n\n @State() collapseClasses: string;\n @State() collapseHeight: string | null = null;\n @State() collapsibleId: string;\n @State() hasHeader: boolean;\n @State() headingTag: string | undefined;\n @State() isOpen = true;\n @State() onAccordionButtonClick = () => this.toggle();\n\n /**\n * If `true`, the element is initially collapsed otherwise it is displayed.\n */\n @Prop() readonly collapsed?: boolean = false;\n\n @Watch('collapsed')\n validateCollapsed(newValue = this.collapsed) {\n checkType(newValue, 'boolean', 'The post-collapsible \"collapsed\" prop should be a boolean.');\n\n if (!this.isLoaded) {\n this.isOpen = !newValue;\n this.collapseClasses = this.getCollapseClasses();\n } else {\n setTimeout(() => {\n this.toggle(!newValue);\n });\n }\n }\n\n /**\n * Defines the hierarchical level of the collapsible header within the headings structure.\n */\n @Prop() readonly headingLevel?: number = 2;\n\n @Watch('headingLevel')\n validateHeadingLevel(newValue = this.headingLevel) {\n checkOneOf(\n newValue,\n [1, 2, 3, 4, 5, 6],\n 'The post-collapsible element requires a heading level between 1 and 6.',\n );\n\n this.headingTag = `h${newValue}`;\n }\n\n componentWillLoad() {\n this.validateCollapsed();\n this.validateHeadingLevel();\n\n this.hasHeader = this.host.querySelectorAll('[slot=\"header\"]').length > 0;\n if (!this.hasHeader) {\n console.warn(\n 'Be sure to bind the post-collapsible to its control using aria-controls and aria-expanded attributes. More information here: https://getbootstrap.com/docs/5.2/components/collapse/#accessibility',\n );\n }\n\n this.collapsibleId = this.host.id || `post-collapsible-${nextId++}`;\n this.collapseClasses = this.getCollapseClasses();\n }\n\n componentDidLoad() {\n this.isLoaded = true;\n this.collapsibleElement = this.host.shadowRoot.querySelector(\n `#${this.collapsibleId}--collapse`,\n );\n }\n\n /**\n * Triggers the collapse programmatically.\n */\n @Method()\n async toggle(open = !this.isOpen): Promise<boolean> {\n if (open !== this.isOpen) {\n this.isOpen = !this.isOpen;\n\n this.startTransition();\n\n await onTransitionEnd(this.collapsibleElement).then(() => {\n this.collapseHeight = null;\n this.collapseClasses = this.getCollapseClasses();\n });\n\n return this.isOpen;\n }\n }\n\n private startTransition() {\n const expandedHeight = getElementHeight(this.collapsibleElement, 'show');\n\n this.collapseHeight = `${this.isOpen ? 0 : expandedHeight}px`;\n this.collapseClasses = 'collapsing';\n\n setTimeout(() => {\n this.collapseHeight = `${this.isOpen ? expandedHeight : 0}px`;\n }, 50);\n }\n\n private getCollapseClasses() {\n return this.isOpen ? 'collapse show' : 'collapse';\n }\n\n render() {\n if (!this.hasHeader) {\n return (\n <div\n id={`${this.collapsibleId}--collapse`}\n class={this.collapseClasses}\n style={{ height: this.collapseHeight }}\n >\n <slot />\n </div>\n );\n }\n\n return (\n <Host data-version={version}>\n <div class=\"accordion-item\">\n <this.headingTag class=\"accordion-header\" id={`${this.collapsibleId}--header`}>\n <button\n class={`accordion-button ${this.isOpen ? '' : 'collapsed'}`}\n type=\"button\"\n aria-expanded={`${this.isOpen}`}\n aria-controls={`${this.collapsibleId}--collapse`}\n onClick={this.onAccordionButtonClick}\n >\n <slot name=\"header\" />\n </button>\n </this.headingTag>\n <div\n id={`${this.collapsibleId}--collapse`}\n class={`accordion-collapse ${this.collapseClasses}`}\n style={{ height: this.collapseHeight }}\n aria-labelledby={`${this.collapsibleId}--header`}\n >\n <div class=\"accordion-body\">\n <slot />\n </div>\n </div>\n </div>\n </Host>\n );\n }\n}\n"],"version":3}
@@ -1,8 +1,8 @@
1
- import { p as promiseResolve, b as bootstrapLazy } from './index-401f2d6a.js';
2
- export { s as setNonce } from './index-401f2d6a.js';
1
+ import { p as promiseResolve, b as bootstrapLazy } from './index-286143e7.js';
2
+ export { s as setNonce } from './index-286143e7.js';
3
3
 
4
4
  /*
5
- Stencil Client Patch Browser v3.1.0 | MIT Licensed | https://stenciljs.com
5
+ Stencil Client Patch Browser v3.2.0 | MIT Licensed | https://stenciljs.com
6
6
  */
7
7
  const patchBrowser = () => {
8
8
  const importMeta = import.meta.url;
@@ -17,7 +17,7 @@ const patchBrowser = () => {
17
17
  };
18
18
 
19
19
  patchBrowser().then(options => {
20
- return bootstrapLazy([["post-collapsible",[[1,"post-collapsible",{"collapsed":[4],"headingLevel":[2,"heading-level"],"collapseClasses":[32],"collapseHeight":[32],"collapsibleId":[32],"hasHeader":[32],"headingTag":[32],"isOpen":[32],"onAccordionButtonClick":[32],"toggle":[64]}]]],["post-icon",[[1,"post-icon",{"animation":[1],"base":[1],"flipH":[4,"flip-h"],"flipV":[4,"flip-v"],"name":[1],"rotate":[2],"scale":[2],"svgOutput":[32]}]]]], options);
20
+ return bootstrapLazy([["post-collapsible",[[1,"post-collapsible",{"collapsed":[4],"headingLevel":[2,"heading-level"],"collapseClasses":[32],"collapseHeight":[32],"collapsibleId":[32],"hasHeader":[32],"headingTag":[32],"isOpen":[32],"onAccordionButtonClick":[32],"toggle":[64]}]]],["post-icon",[[1,"post-icon",{"animation":[1],"base":[1],"flipH":[4,"flip-h"],"flipV":[4,"flip-v"],"name":[1],"rotate":[2],"scale":[2],"pathForceCDN":[32],"svgStyles":[32],"svgOutput":[32]}]]]], options);
21
21
  });
22
22
 
23
23
  //# sourceMappingURL=post-components.js.map
@@ -1 +1 @@
1
- {"file":"post-components.js","mappings":";;;AAAA;AACA;AACA;AAiBA,MAAM,YAAY,GAAG,MAAM;AAkC3B,IAAI,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC;AACvC,IAAI,MAAM,IAAI,GAAiE,EAAE,CAAC;AAgBlF;AACA,IAAI,IAAuB,UAAU,KAAK,EAAE,EAAE;AAC9C,QAAQ,IAAI,CAAC,YAAY,GAAG,IAAI,GAAG,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC,IAAI,CAAC;AAC1D;AACA;AACA,KAaK;AACL,IAAI,OAAO,cAAc,CAAC,IAAI,CAAC,CAAC;AAChC,CAAC;;ACtFD,YAAY,EAAE,CAAC,IAAI,CAAC,OAAO,IAAI;AAE/B,EAAE,OAAO,aAAa,CAAC,4BAA4B,EAAE,OAAO,CAAC,CAAC;AAC9D,CAAC,CAAC","names":[],"sources":["../../node_modules/.pnpm/@stencil+core@3.1.0/node_modules/@stencil/core/internal/client/patch-browser.js","@lazy-browser-entrypoint?app-data=conditional"],"sourcesContent":["/*\n Stencil Client Patch Browser v3.1.0 | MIT Licensed | https://stenciljs.com\n */\nimport { BUILD, NAMESPACE } from '@stencil/core/internal/app-data';\nimport { consoleDevInfo, plt, win, doc, promiseResolve, H } from '@stencil/core';\n/**\n * Helper method for querying a `meta` tag that contains a nonce value\n * out of a DOM's head.\n *\n * @param doc The DOM containing the `head` to query against\n * @returns The content of the meta tag representing the nonce value, or `undefined` if no tag\n * exists or the tag has no content.\n */\nfunction queryNonceMetaTagContent(doc) {\n var _a, _b, _c;\n return (_c = (_b = (_a = doc.head) === null || _a === void 0 ? void 0 : _a.querySelector('meta[name=\"csp-nonce\"]')) === null || _b === void 0 ? void 0 : _b.getAttribute('content')) !== null && _c !== void 0 ? _c : undefined;\n}\n// TODO(STENCIL-661): Remove code related to the dynamic import shim\nconst getDynamicImportFunction = (namespace) => `__sc_import_${namespace.replace(/\\s|-/g, '_')}`;\nconst patchBrowser = () => {\n // NOTE!! This fn cannot use async/await!\n if (BUILD.isDev && !BUILD.isTesting) {\n consoleDevInfo('Running in development mode.');\n }\n // TODO(STENCIL-659): Remove code implementing the CSS variable shim\n if (BUILD.cssVarShim) {\n // shim css vars\n // TODO(STENCIL-659): Remove code implementing the CSS variable shim\n plt.$cssShim$ = win.__cssshim;\n }\n if (BUILD.cloneNodeFix) {\n // opted-in to polyfill cloneNode() for slot polyfilled components\n patchCloneNodeFix(H.prototype);\n }\n if (BUILD.profile && !performance.mark) {\n // not all browsers support performance.mark/measure (Safari 10)\n // because the mark/measure APIs are designed to write entries to a buffer in the browser that does not exist,\n // simply stub the implementations out.\n // TODO(STENCIL-323): Remove this patch when support for older browsers is removed (breaking)\n // @ts-ignore\n performance.mark = performance.measure = () => {\n /*noop*/\n };\n performance.getEntriesByName = () => [];\n }\n // @ts-ignore\n const scriptElm = \n // TODO(STENCIL-661): Remove code related to the dynamic import shim\n // TODO(STENCIL-663): Remove code related to deprecated `safari10` field.\n BUILD.scriptDataOpts || BUILD.safari10 || BUILD.dynamicImportShim\n ? Array.from(doc.querySelectorAll('script')).find((s) => new RegExp(`\\/${NAMESPACE}(\\\\.esm)?\\\\.js($|\\\\?|#)`).test(s.src) ||\n s.getAttribute('data-stencil-namespace') === NAMESPACE)\n : null;\n const importMeta = import.meta.url;\n const opts = BUILD.scriptDataOpts ? (scriptElm || {})['data-opts'] || {} : {};\n // TODO(STENCIL-663): Remove code related to deprecated `safari10` field.\n if (BUILD.safari10 && 'onbeforeload' in scriptElm && !history.scrollRestoration /* IS_ESM_BUILD */) {\n // Safari < v11 support: This IF is true if it's Safari below v11.\n // This fn cannot use async/await since Safari didn't support it until v11,\n // however, Safari 10 did support modules. Safari 10 also didn't support \"nomodule\",\n // so both the ESM file and nomodule file would get downloaded. Only Safari\n // has 'onbeforeload' in the script, and \"history.scrollRestoration\" was added\n // to Safari in v11. Return a noop then() so the async/await ESM code doesn't continue.\n // IS_ESM_BUILD is replaced at build time so this check doesn't happen in systemjs builds.\n return {\n then() {\n /* promise noop */\n },\n };\n }\n // TODO(STENCIL-663): Remove code related to deprecated `safari10` field.\n if (!BUILD.safari10 && importMeta !== '') {\n opts.resourcesUrl = new URL('.', importMeta).href;\n // TODO(STENCIL-661): Remove code related to the dynamic import shim\n // TODO(STENCIL-663): Remove code related to deprecated `safari10` field.\n }\n else if (BUILD.dynamicImportShim || BUILD.safari10) {\n opts.resourcesUrl = new URL('.', new URL(scriptElm.getAttribute('data-resources-url') || scriptElm.src, win.location.href)).href;\n // TODO(STENCIL-661): Remove code related to the dynamic import shim\n if (BUILD.dynamicImportShim) {\n patchDynamicImport(opts.resourcesUrl, scriptElm);\n }\n // TODO(STENCIL-661): Remove code related to the dynamic import shim\n if (BUILD.dynamicImportShim && !win.customElements) {\n // module support, but no custom elements support (Old Edge)\n // @ts-ignore\n return import(/* webpackChunkName: \"polyfills-dom\" */ './dom.js').then(() => opts);\n }\n }\n return promiseResolve(opts);\n};\n// TODO(STENCIL-661): Remove code related to the dynamic import shim\nconst patchDynamicImport = (base, orgScriptElm) => {\n const importFunctionName = getDynamicImportFunction(NAMESPACE);\n try {\n // test if this browser supports dynamic imports\n // There is a caching issue in V8, that breaks using import() in Function\n // By generating a random string, we can workaround it\n // Check https://bugs.chromium.org/p/chromium/issues/detail?id=990810 for more info\n win[importFunctionName] = new Function('w', `return import(w);//${Math.random()}`);\n }\n catch (e) {\n // this shim is specifically for browsers that do support \"esm\" imports\n // however, they do NOT support \"dynamic\" imports\n // basically this code is for old Edge, v18 and below\n const moduleMap = new Map();\n win[importFunctionName] = (src) => {\n var _a;\n const url = new URL(src, base).href;\n let mod = moduleMap.get(url);\n if (!mod) {\n const script = doc.createElement('script');\n script.type = 'module';\n script.crossOrigin = orgScriptElm.crossOrigin;\n script.src = URL.createObjectURL(new Blob([`import * as m from '${url}'; window.${importFunctionName}.m = m;`], {\n type: 'application/javascript',\n }));\n // Apply CSP nonce to the script tag if it exists\n const nonce = (_a = plt.$nonce$) !== null && _a !== void 0 ? _a : queryNonceMetaTagContent(doc);\n if (nonce != null) {\n script.setAttribute('nonce', nonce);\n }\n mod = new Promise((resolve) => {\n script.onload = () => {\n resolve(win[importFunctionName].m);\n script.remove();\n };\n });\n moduleMap.set(url, mod);\n doc.head.appendChild(script);\n }\n return mod;\n };\n }\n};\nconst patchCloneNodeFix = (HTMLElementPrototype) => {\n const nativeCloneNodeFn = HTMLElementPrototype.cloneNode;\n HTMLElementPrototype.cloneNode = function (deep) {\n if (this.nodeName === 'TEMPLATE') {\n return nativeCloneNodeFn.call(this, deep);\n }\n const clonedNode = nativeCloneNodeFn.call(this, false);\n const srcChildNodes = this.childNodes;\n if (deep) {\n for (let i = 0; i < srcChildNodes.length; i++) {\n // Node.ATTRIBUTE_NODE === 2, and checking because IE11\n if (srcChildNodes[i].nodeType !== 2) {\n clonedNode.appendChild(srcChildNodes[i].cloneNode(true));\n }\n }\n }\n return clonedNode;\n };\n};\nexport { patchBrowser };\n","export { setNonce } from '@stencil/core';\nimport { bootstrapLazy } from '@stencil/core';\nimport { patchBrowser } from '@stencil/core/internal/client/patch-browser';\nimport { globalScripts } from '@stencil/core/internal/app-globals';\npatchBrowser().then(options => {\n globalScripts();\n return bootstrapLazy([/*!__STENCIL_LAZY_DATA__*/], options);\n});\n"],"version":3}
1
+ {"file":"post-components.js","mappings":";;;AAAA;AACA;AACA;AAiBA,MAAM,YAAY,GAAG,MAAM;AAkC3B,IAAI,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC;AACvC,IAAI,MAAM,IAAI,GAAiE,EAAE,CAAC;AAgBlF;AACA,IAAI,IAAuB,UAAU,KAAK,EAAE,EAAE;AAC9C,QAAQ,IAAI,CAAC,YAAY,GAAG,IAAI,GAAG,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC,IAAI,CAAC;AAC1D;AACA;AACA,KAaK;AACL,IAAI,OAAO,cAAc,CAAC,IAAI,CAAC,CAAC;AAChC,CAAC;;ACtFD,YAAY,EAAE,CAAC,IAAI,CAAC,OAAO,IAAI;AAE/B,EAAE,OAAO,aAAa,CAAC,4BAA4B,EAAE,OAAO,CAAC,CAAC;AAC9D,CAAC,CAAC","names":[],"sources":["../../node_modules/.pnpm/@stencil+core@3.2.0/node_modules/@stencil/core/internal/client/patch-browser.js","@lazy-browser-entrypoint?app-data=conditional"],"sourcesContent":["/*\n Stencil Client Patch Browser v3.2.0 | MIT Licensed | https://stenciljs.com\n */\nimport { BUILD, NAMESPACE } from '@stencil/core/internal/app-data';\nimport { consoleDevInfo, plt, win, doc, promiseResolve, H } from '@stencil/core';\n/**\n * Helper method for querying a `meta` tag that contains a nonce value\n * out of a DOM's head.\n *\n * @param doc The DOM containing the `head` to query against\n * @returns The content of the meta tag representing the nonce value, or `undefined` if no tag\n * exists or the tag has no content.\n */\nfunction queryNonceMetaTagContent(doc) {\n var _a, _b, _c;\n return (_c = (_b = (_a = doc.head) === null || _a === void 0 ? void 0 : _a.querySelector('meta[name=\"csp-nonce\"]')) === null || _b === void 0 ? void 0 : _b.getAttribute('content')) !== null && _c !== void 0 ? _c : undefined;\n}\n// TODO(STENCIL-661): Remove code related to the dynamic import shim\nconst getDynamicImportFunction = (namespace) => `__sc_import_${namespace.replace(/\\s|-/g, '_')}`;\nconst patchBrowser = () => {\n // NOTE!! This fn cannot use async/await!\n if (BUILD.isDev && !BUILD.isTesting) {\n consoleDevInfo('Running in development mode.');\n }\n // TODO(STENCIL-659): Remove code implementing the CSS variable shim\n if (BUILD.cssVarShim) {\n // shim css vars\n // TODO(STENCIL-659): Remove code implementing the CSS variable shim\n plt.$cssShim$ = win.__cssshim;\n }\n if (BUILD.cloneNodeFix) {\n // opted-in to polyfill cloneNode() for slot polyfilled components\n patchCloneNodeFix(H.prototype);\n }\n if (BUILD.profile && !performance.mark) {\n // not all browsers support performance.mark/measure (Safari 10)\n // because the mark/measure APIs are designed to write entries to a buffer in the browser that does not exist,\n // simply stub the implementations out.\n // TODO(STENCIL-323): Remove this patch when support for older browsers is removed (breaking)\n // @ts-ignore\n performance.mark = performance.measure = () => {\n /*noop*/\n };\n performance.getEntriesByName = () => [];\n }\n // @ts-ignore\n const scriptElm = \n // TODO(STENCIL-661): Remove code related to the dynamic import shim\n // TODO(STENCIL-663): Remove code related to deprecated `safari10` field.\n BUILD.scriptDataOpts || BUILD.safari10 || BUILD.dynamicImportShim\n ? Array.from(doc.querySelectorAll('script')).find((s) => new RegExp(`\\/${NAMESPACE}(\\\\.esm)?\\\\.js($|\\\\?|#)`).test(s.src) ||\n s.getAttribute('data-stencil-namespace') === NAMESPACE)\n : null;\n const importMeta = import.meta.url;\n const opts = BUILD.scriptDataOpts ? (scriptElm || {})['data-opts'] || {} : {};\n // TODO(STENCIL-663): Remove code related to deprecated `safari10` field.\n if (BUILD.safari10 && 'onbeforeload' in scriptElm && !history.scrollRestoration /* IS_ESM_BUILD */) {\n // Safari < v11 support: This IF is true if it's Safari below v11.\n // This fn cannot use async/await since Safari didn't support it until v11,\n // however, Safari 10 did support modules. Safari 10 also didn't support \"nomodule\",\n // so both the ESM file and nomodule file would get downloaded. Only Safari\n // has 'onbeforeload' in the script, and \"history.scrollRestoration\" was added\n // to Safari in v11. Return a noop then() so the async/await ESM code doesn't continue.\n // IS_ESM_BUILD is replaced at build time so this check doesn't happen in systemjs builds.\n return {\n then() {\n /* promise noop */\n },\n };\n }\n // TODO(STENCIL-663): Remove code related to deprecated `safari10` field.\n if (!BUILD.safari10 && importMeta !== '') {\n opts.resourcesUrl = new URL('.', importMeta).href;\n // TODO(STENCIL-661): Remove code related to the dynamic import shim\n // TODO(STENCIL-663): Remove code related to deprecated `safari10` field.\n }\n else if (BUILD.dynamicImportShim || BUILD.safari10) {\n opts.resourcesUrl = new URL('.', new URL(scriptElm.getAttribute('data-resources-url') || scriptElm.src, win.location.href)).href;\n // TODO(STENCIL-661): Remove code related to the dynamic import shim\n if (BUILD.dynamicImportShim) {\n patchDynamicImport(opts.resourcesUrl, scriptElm);\n }\n // TODO(STENCIL-661): Remove code related to the dynamic import shim\n if (BUILD.dynamicImportShim && !win.customElements) {\n // module support, but no custom elements support (Old Edge)\n // @ts-ignore\n return import(/* webpackChunkName: \"polyfills-dom\" */ './dom.js').then(() => opts);\n }\n }\n return promiseResolve(opts);\n};\n// TODO(STENCIL-661): Remove code related to the dynamic import shim\nconst patchDynamicImport = (base, orgScriptElm) => {\n const importFunctionName = getDynamicImportFunction(NAMESPACE);\n try {\n // test if this browser supports dynamic imports\n // There is a caching issue in V8, that breaks using import() in Function\n // By generating a random string, we can workaround it\n // Check https://bugs.chromium.org/p/chromium/issues/detail?id=990810 for more info\n win[importFunctionName] = new Function('w', `return import(w);//${Math.random()}`);\n }\n catch (e) {\n // this shim is specifically for browsers that do support \"esm\" imports\n // however, they do NOT support \"dynamic\" imports\n // basically this code is for old Edge, v18 and below\n const moduleMap = new Map();\n win[importFunctionName] = (src) => {\n var _a;\n const url = new URL(src, base).href;\n let mod = moduleMap.get(url);\n if (!mod) {\n const script = doc.createElement('script');\n script.type = 'module';\n script.crossOrigin = orgScriptElm.crossOrigin;\n script.src = URL.createObjectURL(new Blob([`import * as m from '${url}'; window.${importFunctionName}.m = m;`], {\n type: 'application/javascript',\n }));\n // Apply CSP nonce to the script tag if it exists\n const nonce = (_a = plt.$nonce$) !== null && _a !== void 0 ? _a : queryNonceMetaTagContent(doc);\n if (nonce != null) {\n script.setAttribute('nonce', nonce);\n }\n mod = new Promise((resolve) => {\n script.onload = () => {\n resolve(win[importFunctionName].m);\n script.remove();\n };\n });\n moduleMap.set(url, mod);\n doc.head.appendChild(script);\n }\n return mod;\n };\n }\n};\nconst patchCloneNodeFix = (HTMLElementPrototype) => {\n const nativeCloneNodeFn = HTMLElementPrototype.cloneNode;\n HTMLElementPrototype.cloneNode = function (deep) {\n if (this.nodeName === 'TEMPLATE') {\n return nativeCloneNodeFn.call(this, deep);\n }\n const clonedNode = nativeCloneNodeFn.call(this, false);\n const srcChildNodes = this.childNodes;\n if (deep) {\n for (let i = 0; i < srcChildNodes.length; i++) {\n // Node.ATTRIBUTE_NODE === 2, and checking because IE11\n if (srcChildNodes[i].nodeType !== 2) {\n clonedNode.appendChild(srcChildNodes[i].cloneNode(true));\n }\n }\n }\n return clonedNode;\n };\n};\nexport { patchBrowser };\n","export { setNonce } from '@stencil/core';\nimport { bootstrapLazy } from '@stencil/core';\nimport { patchBrowser } from '@stencil/core/internal/client/patch-browser';\nimport { globalScripts } from '@stencil/core/internal/app-globals';\npatchBrowser().then(options => {\n globalScripts();\n return bootstrapLazy([/*!__STENCIL_LAZY_DATA__*/], options);\n});\n"],"version":3}
@@ -1,7 +1,8 @@
1
- import { r as registerInstance, h, H as Host } from './index-401f2d6a.js';
2
- import { c as checkType, a as checkOneOf } from './check-type-67411ed3.js';
1
+ import { r as registerInstance, h, g as getElement, H as Host } from './index-286143e7.js';
2
+ import { c as checkType, a as checkOneOf, v as version } from './package-fb4a74d0.js';
3
3
 
4
4
  const EMPTY_VALUES = [undefined, null, ''];
5
+
5
6
  function emptyOr(check) {
6
7
  return (...args) => {
7
8
  const value = args[0];
@@ -10,32 +11,41 @@ function emptyOr(check) {
10
11
  };
11
12
  }
12
13
 
14
+ function checkNonEmpty(value, error) {
15
+ if (EMPTY_VALUES.some(v => v === value)) {
16
+ throw new Error(error);
17
+ }
18
+ }
19
+
13
20
  const checkEmptyOrOneOf = emptyOr(checkOneOf);
14
21
  const checkEmptyOrType = emptyOr(checkType);
15
22
 
16
- const postIconCss = ":host{display:inline-block;width:1em;vertical-align:-0.15em}svg{display:block;width:100%;fill:currentColor}:host([flip-h]) svg{scale:-1 1}:host([flip-v]) svg{scale:1 -1}:host([flip-h][flip-v]) svg{scale:-1}:host([animation]) svg{transform-origin:center}:host([animation=cylon]) svg{animation:icon-animation-cylon 0.75s ease-in-out infinite alternate}:host([animation=cylon-vertical]) svg{animation:icon-animation-cylon-vertical 0.75s ease-in-out infinite alternate}:host([animation=spin]) svg{animation:icon-animation-spin 2s linear infinite normal}:host([animation=spin-reverse]) svg{animation:icon-animation-spin 2s linear infinite reverse}:host([animation=fade]) svg{animation:icon-animation-fade 0.75s ease-in-out infinite alternate}:host([animation=throb]) svg{animation:icon-animation-throb 0.75s ease-in-out infinite alternate}@keyframes icon-animation-cylon{from{transform:translateX(-25%)}to{transform:translateX(25%)}}@keyframes icon-animation-cylon-vertical{from{transform:translateY(25%)}to{transform:translateY(-25%)}}@keyframes icon-animation-fade{from{opacity:0.1}to{opacity:1}}@keyframes icon-animation-spin{from{transform:rotate(0deg)}to{transform:rotate(359deg)}}@keyframes icon-animation-throb{from{opacity:0.5;transform:scale(0.5)}to{opacity:1;transform:scale(1)}}";
23
+ const postIconCss = ":host{display:inline-block;width:1em;vertical-align:-0.15em}svg{display:block;width:100%;fill:currentColor}:host([flip-h]:not([flip-h=false])) svg{scale:-1 1}:host([flip-v]:not([flip-v=false])) svg{scale:1 -1}:host([flip-h][flip-v]:not([flip-h=false],[flip-v=false])) svg{scale:-1}:host([animation]){transform-origin:center}:host([animation=cylon]){animation:icon-animation-cylon 0.75s ease-in-out infinite alternate}:host([animation=cylon-vertical]){animation:icon-animation-cylon-vertical 0.75s ease-in-out infinite alternate}:host([animation=spin]){animation:icon-animation-spin 2s linear infinite normal}:host([animation=spin-reverse]){animation:icon-animation-spin 2s linear infinite reverse}:host([animation=fade]){animation:icon-animation-fade 0.75s ease-in-out infinite alternate}:host([animation=throb]){animation:icon-animation-throb 0.75s ease-in-out infinite alternate}@keyframes icon-animation-cylon{from{transform:translateX(-25%)}to{transform:translateX(25%)}}@keyframes icon-animation-cylon-vertical{from{transform:translateY(25%)}to{transform:translateY(-25%)}}@keyframes icon-animation-fade{from{opacity:0.1}to{opacity:1}}@keyframes icon-animation-spin{from{transform:rotate(0deg)}to{transform:rotate(359deg)}}@keyframes icon-animation-throb{from{opacity:0.5;transform:scale(0.5)}to{opacity:1;transform:scale(1)}}";
17
24
 
18
25
  const CDN_URL = 'https://unpkg.com/@swisspost/design-system-icons/public/post-icons';
19
- const ANIMATION_KEYS = [
26
+ const ANIMATION_NAMES = [
20
27
  'cylon',
21
28
  'cylon-vertical',
22
29
  'spin',
23
30
  'spin-reverse',
24
31
  'fade',
25
- 'throb'
32
+ 'throb',
26
33
  ];
34
+ const ANIMATION_KEYS = [...ANIMATION_NAMES];
27
35
  const PostIcon = class {
28
36
  constructor(hostRef) {
29
37
  registerInstance(this, hostRef);
30
38
  this.svgSource = '<svg viewBox="0 0 16 16"></svg>';
39
+ this.pathForceCDN = false;
40
+ this.svgStyles = undefined;
31
41
  this.svgOutput = undefined;
32
- this.animation = undefined;
33
- this.base = undefined;
34
- this.flipH = undefined;
35
- this.flipV = undefined;
42
+ this.animation = null;
43
+ this.base = null;
44
+ this.flipH = false;
45
+ this.flipV = false;
36
46
  this.name = undefined;
37
- this.rotate = undefined;
38
- this.scale = undefined;
47
+ this.rotate = null;
48
+ this.scale = null;
39
49
  }
40
50
  validateAnimation(newValue = this.animation) {
41
51
  if (newValue !== undefined)
@@ -51,6 +61,7 @@ const PostIcon = class {
51
61
  checkEmptyOrType(newValue, 'boolean', 'The post-icon "flipV" prop should be a boolean.');
52
62
  }
53
63
  validateName(newValue = this.name) {
64
+ checkNonEmpty(newValue, 'The post-icon "name" prop is required!.');
54
65
  checkType(newValue, 'string', 'The post-icon "name" prop should be a string.');
55
66
  }
56
67
  validateRotate(newValue = this.rotate) {
@@ -59,8 +70,35 @@ const PostIcon = class {
59
70
  validateScale(newValue = this.scale) {
60
71
  checkEmptyOrType(newValue, 'number', 'The post-icon "scale" prop should be a number.');
61
72
  }
62
- connectedCallback() {
63
- var _a;
73
+ componentWillLoad() {
74
+ this.validateBase();
75
+ this.validateName();
76
+ this.validateFlipH();
77
+ this.validateFlipV();
78
+ this.validateScale();
79
+ this.validateRotate();
80
+ this.validateAnimation();
81
+ }
82
+ componentWillRender() {
83
+ this.createIconFromStorage();
84
+ // create path dependant on the props
85
+ this.setPath();
86
+ // fetch icon if the prop "name" is defined and
87
+ // the path has not allready been loaded
88
+ if (this.name && this.path !== this.loadedPath) {
89
+ this.loadedPath = this.path;
90
+ this.fetchIcon()
91
+ .then(successfullyLoaded => {
92
+ // create icon only if an svg has been loaded successfully
93
+ if (successfullyLoaded)
94
+ this.createIcon();
95
+ })
96
+ .catch(error => {
97
+ console.error(error);
98
+ });
99
+ }
100
+ }
101
+ setPath() {
64
102
  // Construct icon path from different possible sources
65
103
  let basePath;
66
104
  const metaBase = document.head.querySelector('meta[name="design-system-settings"][data-post-icon-base]');
@@ -73,20 +111,51 @@ const PostIcon = class {
73
111
  else {
74
112
  basePath = CDN_URL;
75
113
  }
76
- this.path = this.getPath(basePath);
77
- this.svgSource = (_a = window.localStorage.getItem(`post-icon-${this.name}`)) !== null && _a !== void 0 ? _a : this.svgSource;
114
+ // use "basePath" only if "pathForceCDN" state is "false"
115
+ this.path = this.getPath(this.pathForceCDN ? CDN_URL : basePath);
116
+ // reset "pathForceCDN" after every try
117
+ this.pathForceCDN = false;
78
118
  }
79
- componentWillLoad() {
80
- this.validateAnimation();
81
- this.validateBase();
82
- this.validateFlipH();
83
- this.validateFlipV();
84
- this.validateName();
85
- this.validateRotate();
86
- this.validateScale();
87
- this.fetchSVG();
119
+ getPath(basePath) {
120
+ return new URL([...basePath.split('/'), `${this.name}.svg#icon`].join('/'), window.location.origin).toString();
88
121
  }
89
- componentWillRender() {
122
+ fetchIcon() {
123
+ return new Promise((resolve, reject) => {
124
+ fetch(this.path)
125
+ .then(response => response.text())
126
+ .then(textResponse => {
127
+ // match "svg" out of "textResponse"
128
+ const match = textResponse.match(/^<svg\b([\s\S]*)><\/svg>/);
129
+ if (match !== null) {
130
+ // set "svgSource" and return "successfullyLoaded" with true
131
+ this.svgSource = match[0];
132
+ window.localStorage.setItem(`post-icon-${this.name}`, this.svgSource);
133
+ resolve(true);
134
+ }
135
+ else if (this.path !== this.getPath(CDN_URL)) {
136
+ // if used "path" is not CDN path, and fetch has loaded something else than a "svg", try to reload it from the CDN
137
+ console.warn(`Warning in <post-icon/>: The path "${this.path}" seems to be no svg-only content. We'll gonna try to load the icon from the cdn.`);
138
+ // trigger a component update, which will result in a refetch of the icon with the "CDN_URL"
139
+ this.pathForceCDN = true;
140
+ // return "successfullyLoaded" with false
141
+ resolve(false);
142
+ }
143
+ })
144
+ .catch(reject);
145
+ });
146
+ }
147
+ createIconFromStorage() {
148
+ const storedIcon = window.localStorage.getItem(`post-icon-${this.name}`);
149
+ if (storedIcon) {
150
+ this.svgSource = storedIcon !== null && storedIcon !== void 0 ? storedIcon : this.svgSource;
151
+ this.createIcon();
152
+ }
153
+ }
154
+ createIcon() {
155
+ // create svg element from svgSource string
156
+ const domParser = new DOMParser();
157
+ this.svgElement = domParser.parseFromString(this.svgSource, 'text/html').querySelector('svg');
158
+ // create inline styles for some properties
90
159
  const svgStyles = Object.entries({
91
160
  scale: this.scale && !isNaN(Number(this.scale)) ? `${this.scale}` : null,
92
161
  rotate: this.rotate && !isNaN(Number(this.rotate)) ? `${this.rotate}deg` : null,
@@ -94,43 +163,13 @@ const PostIcon = class {
94
163
  .filter(([_key, value]) => value !== null)
95
164
  .map(([key, value]) => `${key}: ${value}`)
96
165
  .join(';');
97
- const helperElement = document.createElement('div');
98
- helperElement.innerHTML = this.svgSource;
99
- const svgElement = helperElement.querySelector('svg');
100
- svgElement.setAttribute('style', svgStyles);
101
- this.svgOutput = helperElement.innerHTML;
102
- }
103
- fetchSVG() {
104
- fetch(this.path)
105
- .then(response => response.text())
106
- .then(textResponse => {
107
- const match = textResponse.match(/^<svg\b([\s\S]*)><\/svg>/);
108
- if (match !== null) {
109
- this.svgSource = match[0];
110
- window.localStorage.setItem(`post-icon-${this.name}`, this.svgSource);
111
- }
112
- else {
113
- this.initialPath = this.path;
114
- this.path = this.getPath(CDN_URL);
115
- if (this.initialPath !== this.path) {
116
- console.warn(`Warning in <post-icon/>: The content on the path "${this.path}" seems to be no svg-only content. We'll gonna try to load the icon from the cdn.`);
117
- this.fetchSVG();
118
- }
119
- else {
120
- console.error(`Error in <post-icon/>: Could not load the svg on the path "${this.initialPath}"!`);
121
- }
122
- }
123
- })
124
- .catch(error => {
125
- console.log(error);
126
- });
127
- }
128
- getPath(basePath) {
129
- return new URL([...basePath.split('/'), `${this.name}.svg#icon`].join('/'), window.location.origin).toString();
166
+ this.svgElement.setAttribute('style', svgStyles);
167
+ this.host.shadowRoot.innerHTML = this.svgElement.outerHTML;
130
168
  }
131
169
  render() {
132
- return (h(Host, null, h("div", { innerHTML: this.svgOutput })));
170
+ return h(Host, { "data-version": version });
133
171
  }
172
+ get host() { return getElement(this); }
134
173
  static get watchers() { return {
135
174
  "animation": ["validateAnimation"],
136
175
  "base": ["validateBase"],
@@ -1 +1 @@
1
- {"file":"post-icon.entry.js","mappings":";;;AAAA,MAAM,YAAY,GAAG,CAAC,SAAS,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC;SAE3B,OAAO,CAAsB,KAA2B;EACtE,OAAO,CAAC,GAAG,IAAO;IAChB,MAAM,KAAK,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;IACtB,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,IAAI,C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C,CAAC;QAElC,IAAI,IAAI,CAAC,WAAW,KAAK,IAAI,CAAC,IAAI,EAAE;UAClC,OAAO,CAAC,IAAI,CACV,qDAAqD,IAAI,CAAC,IAAI,mFAAmF,CAClJ,CAAC;UACF,IAAI,CAAC,QAAQ,EAAE,CAAC;SACjB;aAAM;UACL,OAAO,CAAC,KAAK,CACX,8DAA8D,IAAI,CAAC,WAAW,IAAI,CACnF,CAAC;SACH;OACF;KACF,CAAC;OACD,KAAK,CAAC,KAAK;MACV,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;KACpB,CAAC,CAAC;GACN;EAEO,OAAO,CAAC,QAAgB;IAC9B,OAAO,IAAI,GAAG,CACZ,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,GAAG,IAAI,CAAC,IAAI,WAAW,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAC3D,MAAM,CAAC,QAAQ,CAAC,MAAM,CACvB,CAAC,QAAQ,EAAE,CAAC;GACd;EAED,MAAM;IACJ,QACE,EAAC,IAAI,QACH,WAAK,SAAS,EAAE,IAAI,CAAC,SAAS,GAAI,CAC7B,EACP;GACH;;;;;;;;;;;;;;;","names":[],"sources":["./src/utils/property-checkers/empty-or.ts","./src/utils/property-checkers/index.ts","./src/components/post-icon/post-icon.scss?tag=post-icon&encapsulation=shadow","./src/components/post-icon/post-icon.tsx"],"sourcesContent":["const EMPTY_VALUES = [undefined, null, ''];\n\nexport function emptyOr<T extends unknown[]>(check: (...args: T) => void) {\n return (...args: T) => {\n const value = args[0];\n if (!EMPTY_VALUES.some(v => v === value)) check(...args);\n };\n}\n","import { emptyOr } from './empty-or';\nimport { checkOneOf } from './check-one-of';\nimport { checkType } from './check-type';\n\nexport const checkEmptyOrOneOf = emptyOr(checkOneOf);\nexport const checkEmptyOrType = emptyOr(checkType);\n\nexport * from './check-one-of';\nexport * from './check-type';\n","@use 'sass:map';\n\n$post-icon-animations: (\n 'cylon': icon-animation-cylon .75s ease-in-out infinite alternate,\n 'cylon-vertical': icon-animation-cylon-vertical .75s ease-in-out infinite alternate,\n 'spin': icon-animation-spin 2s linear infinite normal,\n 'spin-reverse': icon-animation-spin 2s linear infinite reverse,\n 'fade': icon-animation-fade .75s ease-in-out infinite alternate,\n 'throb': icon-animation-throb .75s ease-in-out infinite alternate\n);\n\n:host {\n display: inline-block;\n width: 1em;\n vertical-align: -0.15em;\n}\n\nsvg {\n display: block;\n width: 100%;\n fill: currentColor;\n}\n\n// flip\n\n:host([flip-h]) {\n svg { scale: -1 1; }\n}\n\n:host([flip-v]) {\n svg { scale: 1 -1; }\n}\n\n:host([flip-h][flip-v]) {\n svg { scale: -1; }\n}\n\n// scale\n// done with inline styling\n\n// rotate\n// done with inline styling\n\n// animation\n\n:host([animation]) {\n svg {\n transform-origin: center;\n }\n}\n\n@each $key, $value in $post-icon-animations {\n :host([animation=\"#{$key}\"]) {\n svg {\n animation: $value;\n }\n }\n}\n\n@keyframes icon-animation-cylon {\n from { transform: translateX(-25%) }\n to { transform: translateX(25%) }\n}\n\n@keyframes icon-animation-cylon-vertical {\n from { transform: translateY(25%); }\n to { transform: translateY(-25%); }\n}\n\n@keyframes icon-animation-fade {\n from { opacity: .1; }\n to { opacity: 1; }\n}\n\n@keyframes icon-animation-spin {\n from { transform: rotate(0deg); }\n to { transform: rotate(359deg); }\n}\n\n@keyframes icon-animation-throb {\n from {\n opacity: .5;\n transform: scale(0.5);\n }\n to {\n opacity: 1;\n transform: scale(1);\n }\n}\n","import { Component, Host, h, Prop, State, Watch } from '@stencil/core';\nimport { checkType, checkEmptyOrType, checkEmptyOrOneOf } from '../../utils';\n\nconst CDN_URL = 'https://unpkg.com/@swisspost/design-system-icons/public/post-icons';\nconst ANIMATION_KEYS = [\n 'cylon',\n 'cylon-vertical',\n 'spin',\n 'spin-reverse',\n 'fade',\n 'throb'\n];\n\n/**\n * @class PostIcon - representing a stencil component\n */\n@Component({\n tag: 'post-icon',\n styleUrl: 'post-icon.scss',\n shadow: true,\n})\nexport class PostIcon {\n private initialPath: string;\n private path: string;\n private svgSource = '<svg viewBox=\"0 0 16 16\"></svg>';\n\n @State() svgOutput: string;\n\n /**\n * The name of the animation (`cylon`, `cylon-vertical`, `spin`, `spin-reverse`, `fade`, `throb`).\n */\n @Prop() readonly animation?: string;\n\n @Watch('animation')\n validateAnimation(newValue = this.animation) {\n if (newValue !== undefined) checkEmptyOrOneOf(newValue, ANIMATION_KEYS, `The post-icon \"animation\" prop requires one of the following values: ${ANIMATION_KEYS.join(', ')}.`);\n }\n\n /**\n * The base path, where the icons are located (must be a public url).\n */\n @Prop() readonly base?: string;\n\n @Watch('base')\n validateBase(newValue = this.base) {\n checkEmptyOrType(newValue, 'string', 'The post-icon \"base\" prop should be a string.');\n }\n\n /**\n * When set to `true`, the icon will be flipped horizontally.\n */\n @Prop() readonly flipH?: boolean;\n\n @Watch('flipH')\n validateFlipH(newValue = this.flipH) {\n checkEmptyOrType(newValue, 'boolean', 'The post-icon \"flipH\" prop should be a boolean.');\n }\n\n /**\n * When set to `true`, the icon will be flipped vertically.\n */\n @Prop() readonly flipV?: boolean;\n\n @Watch('flipV')\n validateFlipV(newValue = this.flipV) {\n checkEmptyOrType(newValue, 'boolean', 'The post-icon \"flipV\" prop should be a boolean.');\n }\n\n /**\n * The name/id of the icon (e.g. 1000, 1001, ...).\n */\n @Prop() readonly name: string;\n\n @Watch('name')\n validateName(newValue = this.name) {\n checkType(newValue, 'string', 'The post-icon \"name\" prop should be a string.');\n }\n\n /**\n * The `number` of degree for the css `rotate` transformation.\n */\n @Prop() readonly rotate?: number;\n\n @Watch('rotate')\n validateRotate(newValue = this.rotate) {\n checkEmptyOrType(newValue, 'number', 'The post-icon \"rotate\" prop should be a number.');\n }\n\n /**\n * The `number` for the css `scale` transformation.\n */\n @Prop() readonly scale?: number;\n\n @Watch('scale')\n validateScale(newValue = this.scale) {\n checkEmptyOrType(newValue, 'number', 'The post-icon \"scale\" prop should be a number.');\n }\n\n connectedCallback() {\n // Construct icon path from different possible sources\n let basePath: string;\n const metaBase = document.head.querySelector(\n 'meta[name=\"design-system-settings\"][data-post-icon-base]',\n );\n\n if (this.base) {\n basePath = this.base;\n } else if (metaBase) {\n basePath = metaBase.getAttribute('data-post-icon-base');\n } else {\n basePath = CDN_URL;\n }\n\n this.path = this.getPath(basePath);\n this.svgSource = window.localStorage.getItem(`post-icon-${this.name}`) ?? this.svgSource;\n }\n\n componentWillLoad() {\n this.validateAnimation();\n this.validateBase();\n this.validateFlipH();\n this.validateFlipV();\n this.validateName();\n this.validateRotate();\n this.validateScale();\n\n this.fetchSVG();\n }\n\n componentWillRender() {\n const svgStyles = Object.entries({\n scale: this.scale && !isNaN(Number(this.scale)) ? `${this.scale}` : null,\n rotate: this.rotate && !isNaN(Number(this.rotate)) ? `${this.rotate}deg` : null,\n })\n .filter(([_key, value]) => value !== null)\n .map(([key, value]) => `${key}: ${value}`)\n .join(';');\n\n const helperElement = document.createElement('div');\n helperElement.innerHTML = this.svgSource;\n\n const svgElement = helperElement.querySelector('svg');\n svgElement.setAttribute('style', svgStyles);\n\n this.svgOutput = helperElement.innerHTML;\n }\n\n private fetchSVG() {\n fetch(this.path)\n .then(response => response.text())\n .then(textResponse => {\n const match = textResponse.match(/^<svg\\b([\\s\\S]*)><\\/svg>/);\n\n if (match !== null) {\n this.svgSource = match[0];\n window.localStorage.setItem(`post-icon-${this.name}`, this.svgSource);\n } else {\n this.initialPath = this.path;\n this.path = this.getPath(CDN_URL);\n\n if (this.initialPath !== this.path) {\n console.warn(\n `Warning in <post-icon/>: The content on the path \"${this.path}\" seems to be no svg-only content. We'll gonna try to load the icon from the cdn.`,\n );\n this.fetchSVG();\n } else {\n console.error(\n `Error in <post-icon/>: Could not load the svg on the path \"${this.initialPath}\"!`,\n );\n }\n }\n })\n .catch(error => {\n console.log(error);\n });\n }\n\n private getPath(basePath: string) {\n return new URL(\n [...basePath.split('/'), `${this.name}.svg#icon`].join('/'),\n window.location.origin,\n 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MAC/B,KAAK,EAAE,IAAI,CAAC,KAAK,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,GAAG,IAAI,CAAC,KAAK,EAAE,GAAG,IAAI;MACxE,MAAM,EAAE,IAAI,CAAC,MAAM,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,GAAG,IAAI,CAAC,MAAM,KAAK,GAAG,IAAI;KAChF,CAAC;OACC,MAAM,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC,KAAK,KAAK,KAAK,IAAI,CAAC;OACzC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,KAAK,GAAG,GAAG,KAAK,KAAK,EAAE,CAAC;OACzC,IAAI,CAAC,GAAG,CAAC,CAAC;IAEb,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;IACjD,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,SAAS,GAAG,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC;GAC5D;EAED,MAAM;IACJ,OAAO,EAAC,IAAI,oBAAe,OAAO,GAAI,CAAC;GACxC;;;;;;;;;;;;;;;;","names":[],"sources":["./src/utils/property-checkers/constants.ts","./src/utils/property-checkers/empty-or.ts","./src/utils/property-checkers/check-non-empty.ts","./src/utils/property-checkers/index.ts","./src/components/post-icon/post-icon.scss?tag=post-icon&encapsulation=shadow","./src/components/post-icon/post-icon.tsx"],"sourcesContent":["export const EMPTY_VALUES = [undefined, null, ''];\n","import { EMPTY_VALUES } from './constants';\n\nexport function emptyOr<T extends unknown[]>(check: (...args: T) => void) {\n return (...args: T) => {\n const value = args[0];\n if (!EMPTY_VALUES.some(v => v === value)) check(...args);\n };\n}\n","import { EMPTY_VALUES } from './constants';\n\nexport function checkNonEmpty(value: unknown, error: string) {\n if (EMPTY_VALUES.some(v => v === value)) {\n throw new Error(error);\n }\n}\n","import { emptyOr } from './empty-or';\nimport { checkOneOf } from './check-one-of';\nimport { checkType } from './check-type';\n\nexport const checkEmptyOrOneOf = emptyOr(checkOneOf);\nexport const checkEmptyOrType = emptyOr(checkType);\n\nexport * from './check-non-empty';\nexport * from './check-one-of';\nexport * from './check-type';\n","@use 'sass:map';\n\n$post-icon-animations: (\n 'cylon': icon-animation-cylon 0.75s ease-in-out infinite alternate,\n 'cylon-vertical': icon-animation-cylon-vertical 0.75s ease-in-out infinite alternate,\n 'spin': icon-animation-spin 2s linear infinite normal,\n 'spin-reverse': icon-animation-spin 2s linear infinite reverse,\n 'fade': icon-animation-fade 0.75s ease-in-out infinite alternate,\n 'throb': icon-animation-throb 0.75s ease-in-out infinite alternate,\n);\n\n:host {\n display: inline-block;\n width: 1em;\n vertical-align: -0.15em;\n}\n\nsvg {\n display: block;\n width: 100%;\n fill: currentColor;\n}\n\n// flip\n\n:host([flip-h]:not([flip-h='false'])) {\n svg {\n scale: -1 1;\n }\n}\n\n:host([flip-v]:not([flip-v='false'])) {\n svg {\n scale: 1 -1;\n }\n}\n\n:host([flip-h][flip-v]:not([flip-h='false'], [flip-v='false'])) {\n svg {\n scale: -1;\n }\n}\n\n// scale\n// done with inline styling\n\n// rotate\n// done with inline styling\n\n// animation\n\n:host([animation]) {\n transform-origin: center;\n}\n\n@each $key, $value in $post-icon-animations {\n :host([animation='#{$key}']) {\n animation: $value;\n }\n}\n\n@keyframes icon-animation-cylon {\n from {\n transform: translateX(-25%);\n }\n to {\n transform: translateX(25%);\n }\n}\n\n@keyframes icon-animation-cylon-vertical {\n from {\n transform: translateY(25%);\n }\n to {\n transform: translateY(-25%);\n }\n}\n\n@keyframes icon-animation-fade {\n from {\n opacity: 0.1;\n }\n to {\n opacity: 1;\n }\n}\n\n@keyframes icon-animation-spin {\n from {\n transform: rotate(0deg);\n }\n to {\n transform: rotate(359deg);\n }\n}\n\n@keyframes icon-animation-throb {\n from {\n opacity: 0.5;\n transform: scale(0.5);\n }\n to {\n opacity: 1;\n transform: scale(1);\n }\n}\n","import { Component, Element, Host, h, Prop, State, Watch } from '@stencil/core';\nimport { checkNonEmpty, checkType, checkEmptyOrType, checkEmptyOrOneOf } from '../../utils';\nimport { version } from '../../../package.json';\n\nconst CDN_URL = 'https://unpkg.com/@swisspost/design-system-icons/public/post-icons';\nconst ANIMATION_NAMES = [\n 'cylon',\n 'cylon-vertical',\n 'spin',\n 'spin-reverse',\n 'fade',\n 'throb',\n] as const;\nconst ANIMATION_KEYS = [...ANIMATION_NAMES];\n\ntype Animation = (typeof ANIMATION_NAMES)[number];\n\n/**\n * @class PostIcon - representing a stencil component\n */\n@Component({\n tag: 'post-icon',\n styleUrl: 'post-icon.scss',\n shadow: true,\n})\nexport class PostIcon {\n private path: string;\n private loadedPath: string;\n private svgSource = '<svg viewBox=\"0 0 16 16\"></svg>';\n private svgElement: SVGElement;\n\n @Element() host: HTMLPostIconElement;\n\n @State() pathForceCDN = false;\n @State() svgStyles: string;\n @State() svgOutput: string;\n\n /**\n * The name of the animation.\n */\n @Prop() readonly animation?: Animation | null = null;\n\n @Watch('animation')\n validateAnimation(newValue = this.animation) {\n if (newValue !== undefined)\n checkEmptyOrOneOf(\n newValue,\n ANIMATION_KEYS,\n `The post-icon \"animation\" prop requires one of the following values: ${ANIMATION_KEYS.join(\n ', ',\n )}.`,\n );\n }\n\n /**\n * The base path, where the icons are located (must be a public url).<br/>Leave this field empty to use the default cdn url.\n */\n @Prop() readonly base?: string | null = null;\n\n @Watch('base')\n validateBase(newValue = this.base) {\n checkEmptyOrType(newValue, 'string', 'The post-icon \"base\" prop should be a string.');\n }\n\n /**\n * When set to `true`, the icon will be flipped horizontally.\n */\n @Prop() readonly flipH?: boolean = false;\n\n @Watch('flipH')\n validateFlipH(newValue = this.flipH) {\n checkEmptyOrType(newValue, 'boolean', 'The post-icon \"flipH\" prop should be a boolean.');\n }\n\n /**\n * When set to `true`, the icon will be flipped vertically.\n */\n @Prop() readonly flipV?: boolean = false;\n\n @Watch('flipV')\n validateFlipV(newValue = this.flipV) {\n checkEmptyOrType(newValue, 'boolean', 'The post-icon \"flipV\" prop should be a boolean.');\n }\n\n /**\n * The name/id of the icon (e.g. 1000, 1001, ...).\n */\n @Prop() readonly name!: string;\n\n @Watch('name')\n validateName(newValue = this.name) {\n checkNonEmpty(newValue, 'The post-icon \"name\" prop is required!.');\n checkType(newValue, 'string', 'The post-icon \"name\" prop should be a string.');\n }\n\n /**\n * The number of degree for the css rotate transformation.\n */\n @Prop() readonly rotate?: number | null = null;\n\n @Watch('rotate')\n validateRotate(newValue = this.rotate) {\n checkEmptyOrType(newValue, 'number', 'The post-icon \"rotate\" prop should be a number.');\n }\n\n /**\n * The number for the css scale transformation.\n */\n @Prop() readonly scale?: number | null = null;\n\n @Watch('scale')\n validateScale(newValue = this.scale) {\n checkEmptyOrType(newValue, 'number', 'The post-icon \"scale\" prop should be a number.');\n }\n\n componentWillLoad() {\n this.validateBase();\n this.validateName();\n this.validateFlipH();\n this.validateFlipV();\n this.validateScale();\n this.validateRotate();\n this.validateAnimation();\n }\n\n componentWillRender() {\n this.createIconFromStorage();\n\n // create path dependant on the props\n this.setPath();\n\n // fetch icon if the prop \"name\" is defined and\n // the path has not allready been loaded\n if (this.name && this.path !== this.loadedPath) {\n this.loadedPath = this.path;\n\n this.fetchIcon()\n .then(successfullyLoaded => {\n // create icon only if an svg has been loaded successfully\n if (successfullyLoaded) this.createIcon();\n })\n .catch(error => {\n console.error(error);\n });\n }\n }\n\n private setPath() {\n // Construct icon path from different possible sources\n let basePath: string;\n const metaBase = document.head.querySelector(\n 'meta[name=\"design-system-settings\"][data-post-icon-base]',\n );\n\n if (this.base) {\n basePath = this.base;\n } else if (metaBase) {\n basePath = metaBase.getAttribute('data-post-icon-base');\n } else {\n basePath = CDN_URL;\n }\n\n // use \"basePath\" only if \"pathForceCDN\" state is \"false\"\n this.path = this.getPath(this.pathForceCDN ? CDN_URL : basePath);\n // reset \"pathForceCDN\" after every try\n this.pathForceCDN = false;\n }\n\n private getPath(basePath: string) {\n return new URL(\n [...basePath.split('/'), `${this.name}.svg#icon`].join('/'),\n window.location.origin,\n ).toString();\n }\n\n private fetchIcon() {\n return new Promise((resolve, reject) => {\n fetch(this.path)\n .then(response => response.text())\n .then(textResponse => {\n // match \"svg\" out of \"textResponse\"\n const match = textResponse.match(/^<svg\\b([\\s\\S]*)><\\/svg>/);\n\n if (match !== null) {\n // set \"svgSource\" and return \"successfullyLoaded\" with true\n this.svgSource = match[0];\n window.localStorage.setItem(`post-icon-${this.name}`, this.svgSource);\n resolve(true);\n } else if (this.path !== this.getPath(CDN_URL)) {\n // if used \"path\" is not CDN path, and fetch has loaded something else than a \"svg\", try to reload it from the CDN\n console.warn(\n `Warning in <post-icon/>: The path \"${this.path}\" seems to be no svg-only content. We'll gonna try to load the icon from the cdn.`,\n );\n // trigger a component update, which will result in a refetch of the icon with the \"CDN_URL\"\n this.pathForceCDN = true;\n // return \"successfullyLoaded\" with false\n resolve(false);\n }\n })\n .catch(reject);\n });\n }\n\n private createIconFromStorage() {\n const storedIcon = window.localStorage.getItem(`post-icon-${this.name}`);\n\n if (storedIcon) {\n this.svgSource = storedIcon ?? this.svgSource;\n this.createIcon();\n }\n }\n\n private createIcon() {\n // create svg element from svgSource string\n const domParser = new DOMParser();\n this.svgElement = domParser.parseFromString(this.svgSource, 'text/html').querySelector('svg');\n\n // create inline styles for some properties\n const svgStyles = Object.entries({\n scale: this.scale && !isNaN(Number(this.scale)) ? `${this.scale}` : null,\n rotate: this.rotate && !isNaN(Number(this.rotate)) ? `${this.rotate}deg` : null,\n })\n .filter(([_key, value]) => value !== null)\n .map(([key, value]) => `${key}: ${value}`)\n .join(';');\n\n this.svgElement.setAttribute('style', svgStyles);\n this.host.shadowRoot.innerHTML = this.svgElement.outerHTML;\n }\n\n render() {\n return <Host data-version={version} />;\n }\n}\n"],"version":3}
@@ -1,3 +1,3 @@
1
- const t="post-components";let e;let n;let s=false;let o=false;const c=(t,e="")=>{{return()=>{}}};const l=(t,e)=>{{return()=>{}}};const i="{visibility:hidden}.hydrated{visibility:inherit}";const f={};const r="http://www.w3.org/2000/svg";const u="http://www.w3.org/1999/xhtml";const a=t=>t!=null;const d=t=>{t=typeof t;return t==="object"||t==="function"};function p(t){var e,n,s;return(s=(n=(e=t.head)===null||e===void 0?void 0:e.querySelector('meta[name="csp-nonce"]'))===null||n===void 0?void 0:n.getAttribute("content"))!==null&&s!==void 0?s:undefined}const h=(t,e,...n)=>{let s=null;let o=false;let c=false;const l=[];const i=e=>{for(let n=0;n<e.length;n++){s=e[n];if(Array.isArray(s)){i(s)}else if(s!=null&&typeof s!=="boolean"){if(o=typeof t!=="function"&&!d(s)){s=String(s)}if(o&&c){l[l.length-1].t+=s}else{l.push(o?y(null,s):s)}c=o}}};i(n);if(e){{const t=e.className||e.class;if(t){e.class=typeof t!=="object"?t:Object.keys(t).filter((e=>t[e])).join(" ")}}}if(typeof t==="function"){return t(e===null?{}:e,l,w)}const f=y(t,null);f.o=e;if(l.length>0){f.l=l}return f};const y=(t,e)=>{const n={i:0,u:t,t:e,p:null,l:null};{n.o=null}return n};const m={};const $=t=>t&&t.u===m;const w={forEach:(t,e)=>t.map(b).forEach(e),map:(t,e)=>t.map(b).map(e).map(g)};const b=t=>({vattrs:t.o,vchildren:t.l,vkey:t.h,vname:t.m,vtag:t.u,vtext:t.t});const g=t=>{if(typeof t.vtag==="function"){const e=Object.assign({},t.vattrs);if(t.vkey){e.key=t.vkey}if(t.vname){e.name=t.vname}return h(t.vtag,e,...t.vchildren||[])}const e=y(t.vtag,t.vtext);e.o=t.vattrs;e.l=t.vchildren;e.h=t.vkey;e.m=t.vname;return e};const v=(t,e)=>{if(t!=null&&!d(t)){if(e&4){return t==="false"?false:t===""||!!t}if(e&2){return parseFloat(t)}if(e&1){return String(t)}return t}return t};const S=t=>lt(t).$;const j=(t,e,n)=>{const s=mt.ce(e,n);t.dispatchEvent(s);return s};const O=new WeakMap;const k=(t,e,n)=>{let s=pt.get(t);if(wt&&n){s=s||new CSSStyleSheet;if(typeof s==="string"){s=e}else{s.replaceSync(e)}}else{s=e}pt.set(t,s)};const C=(t,e,n,s)=>{var o;let c=x(e);const l=pt.get(c);t=t.nodeType===11?t:yt;if(l){if(typeof l==="string"){t=t.head||t;let e=O.get(t);let n;if(!e){O.set(t,e=new Set)}if(!e.has(c)){{{n=yt.createElement("style");n.innerHTML=l}const e=(o=mt.g)!==null&&o!==void 0?o:p(yt);if(e!=null){n.setAttribute("nonce",e)}t.insertBefore(n,t.querySelector("link"))}if(e){e.add(c)}}}else if(!t.adoptedStyleSheets.includes(l)){t.adoptedStyleSheets=[...t.adoptedStyleSheets,l]}}return c};const M=t=>{const e=t.v;const n=t.$;const s=e.i;const o=c("attachStyles",e.S);const l=C(n.shadowRoot?n.shadowRoot:n.getRootNode(),e);if(s&10){n["s-sc"]=l;n.classList.add(l+"-h")}o()};const x=(t,e)=>"sc-"+t.S;const P=(t,e,n,s,o,c)=>{if(n!==s){let l=rt(t,e);let i=e.toLowerCase();if(e==="class"){const e=t.classList;const o=L(n);const c=L(s);e.remove(...o.filter((t=>t&&!c.includes(t))));e.add(...c.filter((t=>t&&!o.includes(t))))}else if(e==="style"){{for(const e in n){if(!s||s[e]==null){if(e.includes("-")){t.style.removeProperty(e)}else{t.style[e]=""}}}}for(const e in s){if(!n||s[e]!==n[e]){if(e.includes("-")){t.style.setProperty(e,s[e])}else{t.style[e]=s[e]}}}}else if(!l&&e[0]==="o"&&e[1]==="n"){if(e[2]==="-"){e=e.slice(3)}else if(rt(ht,i)){e=i.slice(2)}else{e=i[2]+e.slice(3)}if(n){mt.rel(t,e,n,false)}if(s){mt.ael(t,e,s,false)}}else{const i=d(s);if((l||i&&s!==null)&&!o){try{if(!t.tagName.includes("-")){const o=s==null?"":s;if(e==="list"){l=false}else if(n==null||t[e]!=o){t[e]=o}}else{t[e]=s}}catch(t){}}if(s==null||s===false){if(s!==false||t.getAttribute(e)===""){{t.removeAttribute(e)}}}else if((!l||c&4||o)&&!i){s=s===true?"":s;{t.setAttribute(e,s)}}}}};const E=/\s/;const L=t=>!t?[]:t.split(E);const U=(t,e,n,s)=>{const o=e.p.nodeType===11&&e.p.host?e.p.host:e.p;const c=t&&t.o||f;const l=e.o||f;{for(s in c){if(!(s in l)){P(o,s,c[s],undefined,n,e.i)}}}for(s in l){P(o,s,c[s],l[s],n,e.i)}};const W=(t,n,o,c)=>{const l=n.l[o];let i=0;let f;let d;{if(!s){s=l.u==="svg"}f=l.p=yt.createElementNS(s?r:u,l.u);if(s&&l.u==="foreignObject"){s=false}{U(null,l,s)}if(a(e)&&f["s-si"]!==e){f.classList.add(f["s-si"]=e)}if(l.l){for(i=0;i<l.l.length;++i){d=W(t,l,i);if(d){f.appendChild(d)}}}{if(l.u==="svg"){s=false}else if(f.tagName==="foreignObject"){s=true}}}return f};const N=(t,e,s,o,c,l)=>{let i=t;let f;if(i.shadowRoot&&i.tagName===n){i=i.shadowRoot}for(;c<=l;++c){if(o[c]){f=W(null,s,c);if(f){o[c].p=f;i.insertBefore(f,e)}}}};const R=(t,e,n,s,o)=>{for(;e<=n;++e){if(s=t[e]){o=s.p;o.remove()}}};const T=(t,e,n,s)=>{let o=0;let c=0;let l=e.length-1;let i=e[0];let f=e[l];let r=s.length-1;let u=s[0];let a=s[r];let d;while(o<=l&&c<=r){if(i==null){i=e[++o]}else if(f==null){f=e[--l]}else if(u==null){u=s[++c]}else if(a==null){a=s[--r]}else if(A(i,u)){F(i,u);i=e[++o];u=s[++c]}else if(A(f,a)){F(f,a);f=e[--l];a=s[--r]}else if(A(i,a)){F(i,a);t.insertBefore(i.p,f.p.nextSibling);i=e[++o];a=s[--r]}else if(A(f,u)){F(f,u);t.insertBefore(f.p,i.p);f=e[--l];u=s[++c]}else{{d=W(e&&e[c],n,c);u=s[++c]}if(d){{i.p.parentNode.insertBefore(d,i.p)}}}}if(o>l){N(t,s[r+1]==null?null:s[r+1].p,n,s,c,r)}else if(c>r){R(e,o,l)}};const A=(t,e)=>{if(t.u===e.u){return true}return false};const F=(t,e)=>{const n=e.p=t.p;const o=t.l;const c=e.l;const l=e.u;{{s=l==="svg"?true:l==="foreignObject"?false:s}{if(l==="slot");else{U(t,e,s)}}if(o!==null&&c!==null){T(n,o,e,c)}else if(c!==null){N(n,null,e,c,0,c.length-1)}else if(o!==null){R(o,0,o.length-1)}if(s&&l==="svg"){s=false}}};const H=(t,s)=>{const o=t.$;const c=t.j||y(null,null);const l=$(s)?s:h(null,null,s);n=o.tagName;l.u=null;l.i|=4;t.j=l;l.p=c.p=o.shadowRoot||o;{e=o["s-sc"]}F(c,l)};const q=(t,e)=>{if(e&&!t.O&&e["s-p"]){e["s-p"].push(new Promise((e=>t.O=e)))}};const D=(t,e)=>{{t.i|=16}if(t.i&4){t.i|=512;return}q(t,t.k);const n=()=>I(t,e);return kt(n)};const I=(t,e)=>{const n=c("scheduleUpdate",t.v.S);const s=t.C;let o;if(e){{o=G(s,"componentWillLoad")}}{o=J(o,(()=>G(s,"componentWillRender")))}n();return J(o,(()=>V(t,s,e)))};const V=async(t,e,n)=>{const s=t.$;const o=c("update",t.v.S);const l=s["s-rc"];if(n){M(t)}const i=c("render",t.v.S);{_(t,e)}if(l){l.map((t=>t()));s["s-rc"]=undefined}i();o();{const e=s["s-p"];const n=()=>z(t);if(e.length===0){n()}else{Promise.all(e).then(n);t.i|=4;e.length=0}}};const _=(t,e,n)=>{try{e=e.render();{t.i&=~16}{t.i|=2}{{{H(t,e)}}}}catch(e){ut(e,t.$)}return null};const z=t=>{const e=t.v.S;const n=t.$;const s=c("postUpdate",e);const o=t.C;const l=t.k;if(!(t.i&64)){t.i|=64;{K(n)}{G(o,"componentDidLoad")}s();{t.M(n);if(!l){B()}}}else{s()}{t.P(n)}{if(t.O){t.O();t.O=undefined}if(t.i&512){Ot((()=>D(t,false)))}t.i&=~(4|512)}};const B=e=>{{K(yt.documentElement)}Ot((()=>j(ht,"appload",{detail:{namespace:t}})))};const G=(t,e,n)=>{if(t&&t[e]){try{return t[e](n)}catch(t){ut(t)}}return undefined};const J=(t,e)=>t&&t.then?t.then(e):e();const K=t=>t.classList.add("hydrated");const Q=(t,e)=>lt(t).L.get(e);const X=(t,e,n,s)=>{const o=lt(t);const c=o.$;const l=o.L.get(e);const i=o.i;const f=o.C;n=v(n,s.U[e][0]);const r=Number.isNaN(l)&&Number.isNaN(n);const u=n!==l&&!r;if((!(i&8)||l===undefined)&&u){o.L.set(e,n);if(f){if(s.W&&i&128){const t=s.W[e];if(t){t.map((t=>{try{f[t](n,l,e)}catch(t){ut(t,c)}}))}}if((i&(2|16))===2){D(o,false)}}}};const Y=(t,e,n)=>{if(e.U){if(t.watchers){e.W=t.watchers}const s=Object.entries(e.U);const o=t.prototype;s.map((([t,[s]])=>{if(s&31||n&2&&s&32){Object.defineProperty(o,t,{get(){return Q(this,t)},set(n){X(this,t,n,e)},configurable:true,enumerable:true})}else if(n&1&&s&64){Object.defineProperty(o,t,{value(...e){const n=lt(this);return n.N.then((()=>n.C[t](...e)))}})}}));if(n&1){const e=new Map;o.attributeChangedCallback=function(t,n,s){mt.jmp((()=>{const n=e.get(t);if(this.hasOwnProperty(n)){s=this[n];delete this[n]}else if(o.hasOwnProperty(n)&&typeof this[n]==="number"&&this[n]==s){return}this[n]=s===null&&typeof this[n]==="boolean"?false:s}))};t.observedAttributes=s.filter((([t,e])=>e[0]&15)).map((([t,n])=>{const s=n[1]||t;e.set(s,t);return s}))}}return t};const Z=async(t,e,n,s,o)=>{if((e.i&32)===0){{e.i|=32;o=dt(n);if(o.then){const t=l();o=await o;t()}if(!o.isProxied){{n.W=o.watchers}Y(o,n,2);o.isProxied=true}const t=c("createInstance",n.S);{e.i|=8}try{new o(e)}catch(t){ut(t)}{e.i&=~8}{e.i|=128}t();tt(e.C)}if(o.style){let t=o.style;const e=x(n);if(!pt.has(e)){const s=c("registerStyles",n.S);k(e,t,!!(n.i&1));s()}}}const i=e.k;const f=()=>D(e,true);if(i&&i["s-rc"]){i["s-rc"].push(f)}else{f()}};const tt=t=>{{G(t,"connectedCallback")}};const et=t=>{if((mt.i&1)===0){const e=lt(t);const n=e.v;const s=c("connectedCallback",n.S);if(!(e.i&1)){e.i|=1;{let n=t;while(n=n.parentNode||n.host){if(n["s-p"]){q(e,e.k=n);break}}}if(n.U){Object.entries(n.U).map((([e,[n]])=>{if(n&31&&t.hasOwnProperty(e)){const n=t[e];delete t[e];t[e]=n}}))}{Z(t,e,n)}}else{tt(e.C)}s()}};const nt=t=>{if((mt.i&1)===0){lt(t)}};const st=(t,e={})=>{var n;const s=c();const o=[];const l=e.exclude||[];const f=ht.customElements;const r=yt.head;const u=r.querySelector("meta[charset]");const a=yt.createElement("style");const d=[];let h;let y=true;Object.assign(mt,e);mt.R=new URL(e.resourcesUrl||"./",yt.baseURI).href;t.map((t=>{t[1].map((e=>{const n={i:e[0],S:e[1],U:e[2],T:e[3]};{n.U=e[2]}{n.W={}}const s=n.S;const c=class extends HTMLElement{constructor(t){super(t);t=this;ft(t,n);if(n.i&1){{{t.attachShadow({mode:"open"})}}}}connectedCallback(){if(h){clearTimeout(h);h=null}if(y){d.push(this)}else{mt.jmp((()=>et(this)))}}disconnectedCallback(){mt.jmp((()=>nt(this)))}componentOnReady(){return lt(this).A}};n.F=t[0];if(!l.includes(s)&&!f.get(s)){o.push(s);f.define(s,Y(c,n,1))}}))}));{a.innerHTML=o+i;a.setAttribute("data-styles","");const t=(n=mt.g)!==null&&n!==void 0?n:p(yt);if(t!=null){a.setAttribute("nonce",t)}r.insertBefore(a,u?u.nextSibling:r.firstChild)}y=false;if(d.length){d.map((t=>t.connectedCallback()))}else{{mt.jmp((()=>h=setTimeout(B,30)))}}s()};const ot=t=>mt.g=t;const ct=new WeakMap;const lt=t=>ct.get(t);const it=(t,e)=>ct.set(e.C=t,e);const ft=(t,e)=>{const n={i:0,$:t,v:e,L:new Map};{n.N=new Promise((t=>n.P=t))}{n.A=new Promise((t=>n.M=t));t["s-p"]=[];t["s-rc"]=[]}return ct.set(t,n)};const rt=(t,e)=>e in t;const ut=(t,e)=>(0,console.error)(t,e);const at=new Map;const dt=(t,e,n)=>{const s=t.S.replace(/-/g,"_");const o=t.F;const c=at.get(o);if(c){return c[s]}
2
- /*!__STENCIL_STATIC_IMPORT_SWITCH__*/return import(`./${o}.entry.js${""}`).then((t=>{{at.set(o,t)}return t[s]}),ut)};const pt=new Map;const ht=typeof window!=="undefined"?window:{};const yt=ht.document||{head:{}};const mt={i:0,R:"",jmp:t=>t(),raf:t=>requestAnimationFrame(t),ael:(t,e,n,s)=>t.addEventListener(e,n,s),rel:(t,e,n,s)=>t.removeEventListener(e,n,s),ce:(t,e)=>new CustomEvent(t,e)};const $t=t=>Promise.resolve(t);const wt=(()=>{try{new CSSStyleSheet;return typeof(new CSSStyleSheet).replaceSync==="function"}catch(t){}return false})();const bt=[];const gt=[];const vt=(t,e)=>n=>{t.push(n);if(!o){o=true;if(e&&mt.i&4){Ot(jt)}else{mt.raf(jt)}}};const St=t=>{for(let e=0;e<t.length;e++){try{t[e](performance.now())}catch(t){ut(t)}}t.length=0};const jt=()=>{St(bt);{St(gt);if(o=bt.length>0){mt.raf(jt)}}};const Ot=t=>$t().then(t);const kt=vt(gt,true);export{m as H,st as b,S as g,h,$t as p,it as r,ot as s};
3
- //# sourceMappingURL=p-f214c52a.js.map
1
+ const t="post-components";let e;let n;let s=false;let o=false;const c=(t,e="")=>{{return()=>{}}};const l=(t,e)=>{{return()=>{}}};const i="{visibility:hidden}.hydrated{visibility:inherit}";const f={};const r="http://www.w3.org/2000/svg";const u="http://www.w3.org/1999/xhtml";const a=t=>t!=null;const d=t=>{t=typeof t;return t==="object"||t==="function"};function p(t){var e,n,s;return(s=(n=(e=t.head)===null||e===void 0?void 0:e.querySelector('meta[name="csp-nonce"]'))===null||n===void 0?void 0:n.getAttribute("content"))!==null&&s!==void 0?s:undefined}const h=(t,e,...n)=>{let s=null;let o=false;let c=false;const l=[];const i=e=>{for(let n=0;n<e.length;n++){s=e[n];if(Array.isArray(s)){i(s)}else if(s!=null&&typeof s!=="boolean"){if(o=typeof t!=="function"&&!d(s)){s=String(s)}if(o&&c){l[l.length-1].t+=s}else{l.push(o?y(null,s):s)}c=o}}};i(n);if(e){{const t=e.className||e.class;if(t){e.class=typeof t!=="object"?t:Object.keys(t).filter((e=>t[e])).join(" ")}}}if(typeof t==="function"){return t(e===null?{}:e,l,w)}const f=y(t,null);f.o=e;if(l.length>0){f.l=l}return f};const y=(t,e)=>{const n={i:0,u:t,t:e,p:null,l:null};{n.o=null}return n};const m={};const $=t=>t&&t.u===m;const w={forEach:(t,e)=>t.map(b).forEach(e),map:(t,e)=>t.map(b).map(e).map(g)};const b=t=>({vattrs:t.o,vchildren:t.l,vkey:t.h,vname:t.m,vtag:t.u,vtext:t.t});const g=t=>{if(typeof t.vtag==="function"){const e=Object.assign({},t.vattrs);if(t.vkey){e.key=t.vkey}if(t.vname){e.name=t.vname}return h(t.vtag,e,...t.vchildren||[])}const e=y(t.vtag,t.vtext);e.o=t.vattrs;e.l=t.vchildren;e.h=t.vkey;e.m=t.vname;return e};const v=(t,e)=>{if(t!=null&&!d(t)){if(e&4){return t==="false"?false:t===""||!!t}if(e&2){return parseFloat(t)}if(e&1){return String(t)}return t}return t};const S=t=>ct(t).$;const j=(t,e,n)=>{const s=yt.ce(e,n);t.dispatchEvent(s);return s};const O=new WeakMap;const k=(t,e,n)=>{let s=dt.get(t);if($t&&n){s=s||new CSSStyleSheet;if(typeof s==="string"){s=e}else{s.replaceSync(e)}}else{s=e}dt.set(t,s)};const M=(t,e,n,s)=>{var o;let c=x(e);const l=dt.get(c);t=t.nodeType===11?t:ht;if(l){if(typeof l==="string"){t=t.head||t;let e=O.get(t);let n;if(!e){O.set(t,e=new Set)}if(!e.has(c)){{{n=ht.createElement("style");n.innerHTML=l}const e=(o=yt.g)!==null&&o!==void 0?o:p(ht);if(e!=null){n.setAttribute("nonce",e)}t.insertBefore(n,t.querySelector("link"))}if(e){e.add(c)}}}else if(!t.adoptedStyleSheets.includes(l)){t.adoptedStyleSheets=[...t.adoptedStyleSheets,l]}}return c};const C=t=>{const e=t.v;const n=t.$;const s=e.i;const o=c("attachStyles",e.S);const l=M(n.shadowRoot?n.shadowRoot:n.getRootNode(),e);if(s&10){n["s-sc"]=l;n.classList.add(l+"-h")}o()};const x=(t,e)=>"sc-"+t.S;const P=(t,e,n,s,o,c)=>{if(n!==s){let l=ft(t,e);let i=e.toLowerCase();if(e==="class"){const e=t.classList;const o=L(n);const c=L(s);e.remove(...o.filter((t=>t&&!c.includes(t))));e.add(...c.filter((t=>t&&!o.includes(t))))}else if(e==="style"){{for(const e in n){if(!s||s[e]==null){if(e.includes("-")){t.style.removeProperty(e)}else{t.style[e]=""}}}}for(const e in s){if(!n||s[e]!==n[e]){if(e.includes("-")){t.style.setProperty(e,s[e])}else{t.style[e]=s[e]}}}}else if(!l&&e[0]==="o"&&e[1]==="n"){if(e[2]==="-"){e=e.slice(3)}else if(ft(pt,i)){e=i.slice(2)}else{e=i[2]+e.slice(3)}if(n){yt.rel(t,e,n,false)}if(s){yt.ael(t,e,s,false)}}else{const i=d(s);if((l||i&&s!==null)&&!o){try{if(!t.tagName.includes("-")){const o=s==null?"":s;if(e==="list"){l=false}else if(n==null||t[e]!=o){t[e]=o}}else{t[e]=s}}catch(t){}}if(s==null||s===false){if(s!==false||t.getAttribute(e)===""){{t.removeAttribute(e)}}}else if((!l||c&4||o)&&!i){s=s===true?"":s;{t.setAttribute(e,s)}}}}};const E=/\s/;const L=t=>!t?[]:t.split(E);const U=(t,e,n,s)=>{const o=e.p.nodeType===11&&e.p.host?e.p.host:e.p;const c=t&&t.o||f;const l=e.o||f;{for(s in c){if(!(s in l)){P(o,s,c[s],undefined,n,e.i)}}}for(s in l){P(o,s,c[s],l[s],n,e.i)}};const W=(t,n,o,c)=>{const l=n.l[o];let i=0;let f;let d;{if(!s){s=l.u==="svg"}f=l.p=ht.createElementNS(s?r:u,l.u);if(s&&l.u==="foreignObject"){s=false}{U(null,l,s)}if(a(e)&&f["s-si"]!==e){f.classList.add(f["s-si"]=e)}if(l.l){for(i=0;i<l.l.length;++i){d=W(t,l,i);if(d){f.appendChild(d)}}}{if(l.u==="svg"){s=false}else if(f.tagName==="foreignObject"){s=true}}}return f};const N=(t,e,s,o,c,l)=>{let i=t;let f;if(i.shadowRoot&&i.tagName===n){i=i.shadowRoot}for(;c<=l;++c){if(o[c]){f=W(null,s,c);if(f){o[c].p=f;i.insertBefore(f,e)}}}};const R=(t,e,n,s,o)=>{for(;e<=n;++e){if(s=t[e]){o=s.p;o.remove()}}};const T=(t,e,n,s)=>{let o=0;let c=0;let l=e.length-1;let i=e[0];let f=e[l];let r=s.length-1;let u=s[0];let a=s[r];let d;while(o<=l&&c<=r){if(i==null){i=e[++o]}else if(f==null){f=e[--l]}else if(u==null){u=s[++c]}else if(a==null){a=s[--r]}else if(A(i,u)){F(i,u);i=e[++o];u=s[++c]}else if(A(f,a)){F(f,a);f=e[--l];a=s[--r]}else if(A(i,a)){F(i,a);t.insertBefore(i.p,f.p.nextSibling);i=e[++o];a=s[--r]}else if(A(f,u)){F(f,u);t.insertBefore(f.p,i.p);f=e[--l];u=s[++c]}else{{d=W(e&&e[c],n,c);u=s[++c]}if(d){{i.p.parentNode.insertBefore(d,i.p)}}}}if(o>l){N(t,s[r+1]==null?null:s[r+1].p,n,s,c,r)}else if(c>r){R(e,o,l)}};const A=(t,e)=>{if(t.u===e.u){return true}return false};const F=(t,e)=>{const n=e.p=t.p;const o=t.l;const c=e.l;const l=e.u;{{s=l==="svg"?true:l==="foreignObject"?false:s}{if(l==="slot");else{U(t,e,s)}}if(o!==null&&c!==null){T(n,o,e,c)}else if(c!==null){N(n,null,e,c,0,c.length-1)}else if(o!==null){R(o,0,o.length-1)}if(s&&l==="svg"){s=false}}};const H=(t,s)=>{const o=t.$;const c=t.j||y(null,null);const l=$(s)?s:h(null,null,s);n=o.tagName;l.u=null;l.i|=4;t.j=l;l.p=c.p=o.shadowRoot||o;{e=o["s-sc"]}F(c,l)};const q=(t,e)=>{if(e&&!t.O&&e["s-p"]){e["s-p"].push(new Promise((e=>t.O=e)))}};const D=(t,e)=>{{t.i|=16}if(t.i&4){t.i|=512;return}q(t,t.k);const n=()=>I(t,e);return Ot(n)};const I=(t,e)=>{const n=c("scheduleUpdate",t.v.S);const s=t.M;let o;if(e){{o=G(s,"componentWillLoad")}}{o=J(o,(()=>G(s,"componentWillRender")))}n();return J(o,(()=>V(t,s,e)))};const V=async(t,e,n)=>{const s=t.$;const o=c("update",t.v.S);const l=s["s-rc"];if(n){C(t)}const i=c("render",t.v.S);{_(t,e)}if(l){l.map((t=>t()));s["s-rc"]=undefined}i();o();{const e=s["s-p"];const n=()=>z(t);if(e.length===0){n()}else{Promise.all(e).then(n);t.i|=4;e.length=0}}};const _=(t,e,n)=>{try{e=e.render();{t.i&=~16}{t.i|=2}{{{H(t,e)}}}}catch(e){rt(e,t.$)}return null};const z=t=>{const e=t.v.S;const n=t.$;const s=c("postUpdate",e);const o=t.M;const l=t.k;if(!(t.i&64)){t.i|=64;{K(n)}{G(o,"componentDidLoad")}s();{t.C(n);if(!l){B()}}}else{s()}{t.P(n)}{if(t.O){t.O();t.O=undefined}if(t.i&512){jt((()=>D(t,false)))}t.i&=~(4|512)}};const B=e=>{{K(ht.documentElement)}jt((()=>j(pt,"appload",{detail:{namespace:t}})))};const G=(t,e,n)=>{if(t&&t[e]){try{return t[e](n)}catch(t){rt(t)}}return undefined};const J=(t,e)=>t&&t.then?t.then(e):e();const K=t=>t.classList.add("hydrated");const Q=(t,e)=>ct(t).L.get(e);const X=(t,e,n,s)=>{const o=ct(t);const c=o.$;const l=o.L.get(e);const i=o.i;const f=o.M;n=v(n,s.U[e][0]);const r=Number.isNaN(l)&&Number.isNaN(n);const u=n!==l&&!r;if((!(i&8)||l===undefined)&&u){o.L.set(e,n);if(f){if(s.W&&i&128){const t=s.W[e];if(t){t.map((t=>{try{f[t](n,l,e)}catch(t){rt(t,c)}}))}}if((i&(2|16))===2){D(o,false)}}}};const Y=(t,e,n)=>{if(e.U){if(t.watchers){e.W=t.watchers}const s=Object.entries(e.U);const o=t.prototype;s.map((([t,[s]])=>{if(s&31||n&2&&s&32){Object.defineProperty(o,t,{get(){return Q(this,t)},set(n){X(this,t,n,e)},configurable:true,enumerable:true})}else if(n&1&&s&64){Object.defineProperty(o,t,{value(...e){const n=ct(this);return n.N.then((()=>n.M[t](...e)))}})}}));if(n&1){const e=new Map;o.attributeChangedCallback=function(t,n,s){yt.jmp((()=>{const n=e.get(t);if(this.hasOwnProperty(n)){s=this[n];delete this[n]}else if(o.hasOwnProperty(n)&&typeof this[n]==="number"&&this[n]==s){return}this[n]=s===null&&typeof this[n]==="boolean"?false:s}))};t.observedAttributes=s.filter((([t,e])=>e[0]&15)).map((([t,n])=>{const s=n[1]||t;e.set(s,t);return s}))}}return t};const Z=async(t,e,n,s,o)=>{if((e.i&32)===0){{e.i|=32;o=at(n);if(o.then){const t=l();o=await o;t()}if(!o.isProxied){{n.W=o.watchers}Y(o,n,2);o.isProxied=true}const t=c("createInstance",n.S);{e.i|=8}try{new o(e)}catch(t){rt(t)}{e.i&=~8}{e.i|=128}t()}if(o.style){let t=o.style;const e=x(n);if(!dt.has(e)){const s=c("registerStyles",n.S);k(e,t,!!(n.i&1));s()}}}const i=e.k;const f=()=>D(e,true);if(i&&i["s-rc"]){i["s-rc"].push(f)}else{f()}};const tt=t=>{if((yt.i&1)===0){const e=ct(t);const n=e.v;const s=c("connectedCallback",n.S);if(!(e.i&1)){e.i|=1;{let n=t;while(n=n.parentNode||n.host){if(n["s-p"]){q(e,e.k=n);break}}}if(n.U){Object.entries(n.U).map((([e,[n]])=>{if(n&31&&t.hasOwnProperty(e)){const n=t[e];delete t[e];t[e]=n}}))}{Z(t,e,n)}}s()}};const et=t=>{if((yt.i&1)===0){ct(t)}};const nt=(t,e={})=>{var n;const s=c();const o=[];const l=e.exclude||[];const f=pt.customElements;const r=ht.head;const u=r.querySelector("meta[charset]");const a=ht.createElement("style");const d=[];let h;let y=true;Object.assign(yt,e);yt.R=new URL(e.resourcesUrl||"./",ht.baseURI).href;t.map((t=>{t[1].map((e=>{const n={i:e[0],S:e[1],U:e[2],T:e[3]};{n.U=e[2]}{n.W={}}const s=n.S;const c=class extends HTMLElement{constructor(t){super(t);t=this;it(t,n);if(n.i&1){{{t.attachShadow({mode:"open"})}}}}connectedCallback(){if(h){clearTimeout(h);h=null}if(y){d.push(this)}else{yt.jmp((()=>tt(this)))}}disconnectedCallback(){yt.jmp((()=>et(this)))}componentOnReady(){return ct(this).A}};n.F=t[0];if(!l.includes(s)&&!f.get(s)){o.push(s);f.define(s,Y(c,n,1))}}))}));{a.innerHTML=o+i;a.setAttribute("data-styles","");const t=(n=yt.g)!==null&&n!==void 0?n:p(ht);if(t!=null){a.setAttribute("nonce",t)}r.insertBefore(a,u?u.nextSibling:r.firstChild)}y=false;if(d.length){d.map((t=>t.connectedCallback()))}else{{yt.jmp((()=>h=setTimeout(B,30)))}}s()};const st=t=>yt.g=t;const ot=new WeakMap;const ct=t=>ot.get(t);const lt=(t,e)=>ot.set(e.M=t,e);const it=(t,e)=>{const n={i:0,$:t,v:e,L:new Map};{n.N=new Promise((t=>n.P=t))}{n.A=new Promise((t=>n.C=t));t["s-p"]=[];t["s-rc"]=[]}return ot.set(t,n)};const ft=(t,e)=>e in t;const rt=(t,e)=>(0,console.error)(t,e);const ut=new Map;const at=(t,e,n)=>{const s=t.S.replace(/-/g,"_");const o=t.F;const c=ut.get(o);if(c){return c[s]}
2
+ /*!__STENCIL_STATIC_IMPORT_SWITCH__*/return import(`./${o}.entry.js${""}`).then((t=>{{ut.set(o,t)}return t[s]}),rt)};const dt=new Map;const pt=typeof window!=="undefined"?window:{};const ht=pt.document||{head:{}};const yt={i:0,R:"",jmp:t=>t(),raf:t=>requestAnimationFrame(t),ael:(t,e,n,s)=>t.addEventListener(e,n,s),rel:(t,e,n,s)=>t.removeEventListener(e,n,s),ce:(t,e)=>new CustomEvent(t,e)};const mt=t=>Promise.resolve(t);const $t=(()=>{try{new CSSStyleSheet;return typeof(new CSSStyleSheet).replaceSync==="function"}catch(t){}return false})();const wt=[];const bt=[];const gt=(t,e)=>n=>{t.push(n);if(!o){o=true;if(e&&yt.i&4){jt(St)}else{yt.raf(St)}}};const vt=t=>{for(let e=0;e<t.length;e++){try{t[e](performance.now())}catch(t){rt(t)}}t.length=0};const St=()=>{vt(wt);{vt(bt);if(o=wt.length>0){yt.raf(St)}}};const jt=t=>mt().then(t);const Ot=gt(bt,true);export{m as H,nt as b,S as g,h,mt as p,lt as r,st as s};
3
+ //# sourceMappingURL=p-0c286590.js.map