@pod-os/elements 0.26.1-rc.e49d800.0 → 0.27.0

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 (151) hide show
  1. package/dist/cjs/{BrokenFile-26f83028.js → BrokenFile-a5fc0832.js} +22 -6
  2. package/dist/cjs/BrokenFile-a5fc0832.js.map +1 -0
  3. package/dist/cjs/app-globals-97a7ec18.js +23 -0
  4. package/dist/cjs/app-globals-97a7ec18.js.map +1 -0
  5. package/dist/cjs/elements.cjs.js +2 -2
  6. package/dist/cjs/ion-badge_5.cjs.entry.js +1 -1
  7. package/dist/cjs/ion-icon_32.cjs.entry.js +9150 -0
  8. package/dist/cjs/ion-icon_32.cjs.entry.js.map +1 -0
  9. package/dist/cjs/loader.cjs.js +2 -2
  10. package/dist/cjs/pos-app-generic.cjs.entry.js +1 -1
  11. package/dist/cjs/pos-app-ldp-container.cjs.entry.js +1 -1
  12. package/dist/cjs/pos-app-rdf-document.cjs.entry.js +1 -1
  13. package/dist/cjs/pos-document.cjs.entry.js +1 -1
  14. package/dist/collection/apps/pos-app-browser/pos-app-browser.js +2 -1
  15. package/dist/collection/apps/pos-app-browser/pos-app-browser.js.map +1 -1
  16. package/dist/collection/apps/pos-app-dashboard/pos-app-dashboard.js +1 -1
  17. package/dist/collection/apps/pos-app-dashboard/pos-example-resources/pos-example-resources.js +1 -1
  18. package/dist/collection/apps/pos-app-dashboard/pos-getting-started/pos-getting-started.js +1 -1
  19. package/dist/collection/apps/pos-app-generic/pos-app-generic.js +1 -1
  20. package/dist/collection/apps/pos-app-ldp-container/pos-app-ldp-container.js +1 -1
  21. package/dist/collection/apps/pos-app-rdf-document/pos-app-rdf-document.js +1 -1
  22. package/dist/collection/apps/pos-app-settings/pos-app-settings.js +1 -1
  23. package/dist/collection/apps/pos-app-settings/pos-setting-offline-cache/pos-setting-offline-cache.js +1 -1
  24. package/dist/collection/collection-manifest.json +1 -0
  25. package/dist/collection/components/pos-add-new-thing/pos-add-new-thing.js +1 -1
  26. package/dist/collection/components/pos-app/pos-app.js +1 -1
  27. package/dist/collection/components/pos-dialog/pos-dialog.js +15 -5
  28. package/dist/collection/components/pos-dialog/pos-dialog.js.map +1 -1
  29. package/dist/collection/components/pos-error-toast/pos-error-toast.js +1 -1
  30. package/dist/collection/components/pos-literals/pos-literals.js +1 -1
  31. package/dist/collection/components/pos-login/pos-login.js +21 -2
  32. package/dist/collection/components/pos-login/pos-login.js.map +1 -1
  33. package/dist/collection/components/pos-login-form/pos-login-form.js +1 -1
  34. package/dist/collection/components/pos-make-findable/pos-make-findable.css +2 -55
  35. package/dist/collection/components/pos-make-findable/pos-make-findable.js +15 -26
  36. package/dist/collection/components/pos-make-findable/pos-make-findable.js.map +1 -1
  37. package/dist/collection/components/pos-make-findable/shoelace.js +4 -0
  38. package/dist/collection/components/pos-make-findable/shoelace.js.map +1 -0
  39. package/dist/collection/components/pos-navigation/bar/pos-navigation-bar.js +1 -1
  40. package/dist/collection/components/pos-navigation/pos-navigation.js +1 -1
  41. package/dist/collection/components/pos-new-thing-form/pos-new-thing-form.js +1 -1
  42. package/dist/collection/components/pos-picture/pos-picture.js +1 -1
  43. package/dist/collection/components/pos-picture/pos-picture.js.map +1 -1
  44. package/dist/collection/components/pos-rich-link/pos-rich-link.js +2 -2
  45. package/dist/collection/components/pos-router/pos-router.js +1 -1
  46. package/dist/collection/components/pos-select-term/pos-select-term.js +1 -1
  47. package/dist/collection/components/pos-user-menu/pos-user-menu.css +23 -0
  48. package/dist/collection/components/pos-user-menu/pos-user-menu.js +102 -0
  49. package/dist/collection/components/pos-user-menu/pos-user-menu.js.map +1 -0
  50. package/dist/collection/components/pos-user-menu/shoelace.js +6 -0
  51. package/dist/collection/components/pos-user-menu/shoelace.js.map +1 -0
  52. package/dist/collection/global.js +6 -0
  53. package/dist/collection/global.js.map +1 -1
  54. package/dist/components/chunk.HVTXQL7M.js +4775 -0
  55. package/dist/components/chunk.HVTXQL7M.js.map +1 -0
  56. package/dist/components/index.js +7 -0
  57. package/dist/components/index.js.map +1 -1
  58. package/dist/components/index11.js +21 -5
  59. package/dist/components/index11.js.map +1 -1
  60. package/dist/components/pos-add-new-thing2.js +1 -1
  61. package/dist/components/pos-app-browser.js +68 -61
  62. package/dist/components/pos-app-browser.js.map +1 -1
  63. package/dist/components/pos-app-dashboard2.js +1 -1
  64. package/dist/components/pos-app-generic.js +1 -1
  65. package/dist/components/pos-app-ldp-container.js +1 -1
  66. package/dist/components/pos-app-rdf-document.js +1 -1
  67. package/dist/components/pos-app-settings2.js +1 -1
  68. package/dist/components/pos-app2.js +1 -1
  69. package/dist/components/pos-dialog2.js +3 -3
  70. package/dist/components/pos-dialog2.js.map +1 -1
  71. package/dist/components/pos-error-toast2.js +1 -1
  72. package/dist/components/pos-example-resources2.js +1 -1
  73. package/dist/components/pos-getting-started2.js +1 -1
  74. package/dist/components/pos-literals2.js +1 -1
  75. package/dist/components/pos-login-form2.js +1 -1
  76. package/dist/components/pos-login2.js +16 -3
  77. package/dist/components/pos-login2.js.map +1 -1
  78. package/dist/components/pos-make-findable2.js +16 -21
  79. package/dist/components/pos-make-findable2.js.map +1 -1
  80. package/dist/components/pos-navigation-bar2.js +1 -1
  81. package/dist/components/pos-navigation2.js +1 -1
  82. package/dist/components/pos-new-thing-form2.js +1 -1
  83. package/dist/components/pos-picture2.js +1 -1
  84. package/dist/components/pos-picture2.js.map +1 -1
  85. package/dist/components/pos-rich-link2.js +2 -2
  86. package/dist/components/pos-router2.js +1 -1
  87. package/dist/components/pos-select-term2.js +1 -1
  88. package/dist/components/pos-setting-offline-cache2.js +1 -1
  89. package/dist/components/pos-user-menu.d.ts +11 -0
  90. package/dist/components/pos-user-menu.js +8 -0
  91. package/dist/components/pos-user-menu.js.map +1 -0
  92. package/dist/components/pos-user-menu2.js +293 -0
  93. package/dist/components/pos-user-menu2.js.map +1 -0
  94. package/dist/elements/elements.css +8 -2
  95. package/dist/elements/elements.esm.js +1 -1
  96. package/dist/elements/elements.esm.js.map +1 -1
  97. package/dist/elements/{p-650db824.entry.js → p-38edfa6d.entry.js} +2 -2
  98. package/dist/elements/p-61cd1259.js +2 -0
  99. package/dist/elements/p-61cd1259.js.map +1 -0
  100. package/dist/elements/p-74bdf05f.entry.js +652 -0
  101. package/dist/elements/p-74bdf05f.entry.js.map +1 -0
  102. package/dist/elements/p-93f5c8ec.js +2 -0
  103. package/dist/elements/p-93f5c8ec.js.map +1 -0
  104. package/dist/elements/p-b1de75a4.entry.js +2 -0
  105. package/dist/elements/{p-178b3852.entry.js → p-c466d5bf.entry.js} +2 -2
  106. package/dist/elements/{p-2cda3231.entry.js → p-dbb94429.entry.js} +2 -2
  107. package/dist/elements/p-ff684bff.entry.js +2 -0
  108. package/dist/esm/{BrokenFile-0b9882ef.js → BrokenFile-a47d9850.js} +22 -6
  109. package/dist/esm/BrokenFile-a47d9850.js.map +1 -0
  110. package/dist/esm/app-globals-fd9221d0.js +21 -0
  111. package/dist/esm/app-globals-fd9221d0.js.map +1 -0
  112. package/dist/esm/elements.js +2 -2
  113. package/dist/esm/ion-badge_5.entry.js +1 -1
  114. package/dist/esm/ion-icon_32.entry.js +9115 -0
  115. package/dist/esm/ion-icon_32.entry.js.map +1 -0
  116. package/dist/esm/loader.js +2 -2
  117. package/dist/esm/pos-app-generic.entry.js +1 -1
  118. package/dist/esm/pos-app-ldp-container.entry.js +1 -1
  119. package/dist/esm/pos-app-rdf-document.entry.js +1 -1
  120. package/dist/esm/pos-document.entry.js +1 -1
  121. package/dist/types/components/pos-dialog/pos-dialog.d.ts +2 -2
  122. package/dist/types/components/pos-login/pos-login.d.ts +4 -0
  123. package/dist/types/components/pos-make-findable/pos-make-findable.d.ts +6 -3
  124. package/dist/types/components/pos-make-findable/shoelace.d.ts +3 -0
  125. package/dist/types/components/pos-user-menu/pos-user-menu.d.ts +13 -0
  126. package/dist/types/components/pos-user-menu/shoelace.d.ts +5 -0
  127. package/dist/types/components.d.ts +33 -0
  128. package/package.json +5 -4
  129. package/dist/cjs/BrokenFile-26f83028.js.map +0 -1
  130. package/dist/cjs/app-globals-1c06b5ae.js +0 -16
  131. package/dist/cjs/app-globals-1c06b5ae.js.map +0 -1
  132. package/dist/cjs/ion-icon_31.cjs.entry.js +0 -4144
  133. package/dist/cjs/ion-icon_31.cjs.entry.js.map +0 -1
  134. package/dist/elements/p-5e8a3893.js +0 -2
  135. package/dist/elements/p-5e8a3893.js.map +0 -1
  136. package/dist/elements/p-b80dbf24.entry.js +0 -20
  137. package/dist/elements/p-b80dbf24.entry.js.map +0 -1
  138. package/dist/elements/p-c27a94bc.entry.js +0 -2
  139. package/dist/elements/p-e1957ea1.entry.js +0 -2
  140. package/dist/elements/p-ec7a6c44.js +0 -2
  141. package/dist/elements/p-ec7a6c44.js.map +0 -1
  142. package/dist/esm/BrokenFile-0b9882ef.js.map +0 -1
  143. package/dist/esm/app-globals-31ecda4c.js +0 -14
  144. package/dist/esm/app-globals-31ecda4c.js.map +0 -1
  145. package/dist/esm/ion-icon_31.entry.js +0 -4110
  146. package/dist/esm/ion-icon_31.entry.js.map +0 -1
  147. /package/dist/elements/{p-650db824.entry.js.map → p-38edfa6d.entry.js.map} +0 -0
  148. /package/dist/elements/{p-e1957ea1.entry.js.map → p-b1de75a4.entry.js.map} +0 -0
  149. /package/dist/elements/{p-178b3852.entry.js.map → p-c466d5bf.entry.js.map} +0 -0
  150. /package/dist/elements/{p-2cda3231.entry.js.map → p-dbb94429.entry.js.map} +0 -0
  151. /package/dist/elements/{p-c27a94bc.entry.js.map → p-ff684bff.entry.js.map} +0 -0
@@ -1,4110 +0,0 @@
1
- import { d as getAssetPath, r as registerInstance, h, H as Host, e as getElement, f as readTask, w as writeTask, i as createEvent, j as getRenderingRef, k as forceUpdate } from './index-46d8987d.js';
2
- import { c as clamp, g as getElementRoot, r as raf } from './helpers-bc137989.js';
3
- import { c as createColorClasses$1, h as hostContext, g as getClassMap } from './theme-d75c68ae.js';
4
- import { c as config$1, g as getIonMode$1 } from './ionic-global-dc58df6a.js';
5
- import { E as ENABLE_HTML_CONTENT_DEFAULT, s as sanitizeDOMString } from './index-ce4e7029.js';
6
- import { c as createLockController } from './lock-controller-10217ff6.js';
7
- import { p as printIonWarning } from './index-f7ac0403.js';
8
- import { O as OVERLAY_GESTURE_PRIORITY, c as createDelegateController, a as createTriggerController, i as isCancel, p as prepareOverlay, s as setOverlayId, b as present, d as dismiss, e as eventMethod, f as safeCall, G as GESTURE, t as toastController } from './overlays-d7fc4ce2.js';
9
- import { c as createAnimation } from './animation-756697b9.js';
10
- import { w as win } from './index-6b94f340.js';
11
- import { createGesture } from './index-38fe935b.js';
12
- import { c as createStore$1, s as store, B as BrokenFile } from './BrokenFile-0b9882ef.js';
13
- import { P as PodOS, N as NoOfflineCache, L as LabelIndex } from './index-f3176f87.js';
14
- import { s as subscribeResource } from './ResourceAware-5f237305.js';
15
- import './gesture-controller-958242a2.js';
16
- import { s as subscribePodOs } from './PodOsAware-132573cd.js';
17
- import './hardware-back-button-87b1549b.js';
18
- import './framework-delegate-65b5c396.js';
19
-
20
- let CACHED_MAP;
21
- const getIconMap = () => {
22
- if (typeof window === 'undefined') {
23
- return new Map();
24
- }
25
- else {
26
- if (!CACHED_MAP) {
27
- const win = window;
28
- win.Ionicons = win.Ionicons || {};
29
- CACHED_MAP = win.Ionicons.map = win.Ionicons.map || new Map();
30
- }
31
- return CACHED_MAP;
32
- }
33
- };
34
- const getUrl = (i) => {
35
- let url = getSrc(i.src);
36
- if (url) {
37
- return url;
38
- }
39
- url = getName(i.name, i.icon, i.mode, i.ios, i.md);
40
- if (url) {
41
- return getNamedUrl(url, i);
42
- }
43
- if (i.icon) {
44
- url = getSrc(i.icon);
45
- if (url) {
46
- return url;
47
- }
48
- url = getSrc(i.icon[i.mode]);
49
- if (url) {
50
- return url;
51
- }
52
- }
53
- return null;
54
- };
55
- const getNamedUrl = (iconName, iconEl) => {
56
- const url = getIconMap().get(iconName);
57
- if (url) {
58
- return url;
59
- }
60
- try {
61
- return getAssetPath(`svg/${iconName}.svg`);
62
- }
63
- catch (e) {
64
- /**
65
- * In the custom elements build version of ionicons, referencing an icon
66
- * by name will throw an invalid URL error because the asset path is not defined.
67
- * This catches that error and logs something that is more developer-friendly.
68
- * We also include a reference to the ion-icon element so developers can
69
- * figure out which instance of ion-icon needs to be updated.
70
- */
71
- console.warn(`[Ionicons Warning]: Could not load icon with name "${iconName}". Ensure that the icon is registered using addIcons or that the icon SVG data is passed directly to the icon component.`, iconEl);
72
- }
73
- };
74
- const getName = (iconName, icon, mode, ios, md) => {
75
- // default to "md" if somehow the mode wasn't set
76
- mode = (mode && toLower(mode)) === 'ios' ? 'ios' : 'md';
77
- // if an icon was passed in using the ios or md attributes
78
- // set the iconName to whatever was passed in
79
- if (ios && mode === 'ios') {
80
- iconName = toLower(ios);
81
- }
82
- else if (md && mode === 'md') {
83
- iconName = toLower(md);
84
- }
85
- else {
86
- if (!iconName && icon && !isSrc(icon)) {
87
- iconName = icon;
88
- }
89
- if (isStr(iconName)) {
90
- iconName = toLower(iconName);
91
- }
92
- }
93
- if (!isStr(iconName) || iconName.trim() === '') {
94
- return null;
95
- }
96
- // only allow alpha characters and dash
97
- const invalidChars = iconName.replace(/[a-z]|-|\d/gi, '');
98
- if (invalidChars !== '') {
99
- return null;
100
- }
101
- return iconName;
102
- };
103
- const getSrc = (src) => {
104
- if (isStr(src)) {
105
- src = src.trim();
106
- if (isSrc(src)) {
107
- return src;
108
- }
109
- }
110
- return null;
111
- };
112
- const isSrc = (str) => str.length > 0 && /(\/|\.)/.test(str);
113
- const isStr = (val) => typeof val === 'string';
114
- const toLower = (val) => val.toLowerCase();
115
- /**
116
- * Elements inside of web components sometimes need to inherit global attributes
117
- * set on the host. For example, the inner input in `ion-input` should inherit
118
- * the `title` attribute that developers set directly on `ion-input`. This
119
- * helper function should be called in componentWillLoad and assigned to a variable
120
- * that is later used in the render function.
121
- *
122
- * This does not need to be reactive as changing attributes on the host element
123
- * does not trigger a re-render.
124
- */
125
- const inheritAttributes = (el, attributes = []) => {
126
- const attributeObject = {};
127
- attributes.forEach(attr => {
128
- if (el.hasAttribute(attr)) {
129
- const value = el.getAttribute(attr);
130
- if (value !== null) {
131
- attributeObject[attr] = el.getAttribute(attr);
132
- }
133
- el.removeAttribute(attr);
134
- }
135
- });
136
- return attributeObject;
137
- };
138
- /**
139
- * Returns `true` if the document or host element
140
- * has a `dir` set to `rtl`. The host value will always
141
- * take priority over the root document value.
142
- */
143
- const isRTL = (hostEl) => {
144
- if (hostEl) {
145
- if (hostEl.dir !== '') {
146
- return hostEl.dir.toLowerCase() === 'rtl';
147
- }
148
- }
149
- return (document === null || document === void 0 ? void 0 : document.dir.toLowerCase()) === 'rtl';
150
- };
151
-
152
- const validateContent = (svgContent) => {
153
- const div = document.createElement('div');
154
- div.innerHTML = svgContent;
155
- // setup this way to ensure it works on our buddy IE
156
- for (let i = div.childNodes.length - 1; i >= 0; i--) {
157
- if (div.childNodes[i].nodeName.toLowerCase() !== 'svg') {
158
- div.removeChild(div.childNodes[i]);
159
- }
160
- }
161
- // must only have 1 root element
162
- const svgElm = div.firstElementChild;
163
- if (svgElm && svgElm.nodeName.toLowerCase() === 'svg') {
164
- const svgClass = svgElm.getAttribute('class') || '';
165
- svgElm.setAttribute('class', (svgClass + ' s-ion-icon').trim());
166
- // root element must be an svg
167
- // lets double check we've got valid elements
168
- // do not allow scripts
169
- if (isValid(svgElm)) {
170
- return div.innerHTML;
171
- }
172
- }
173
- return '';
174
- };
175
- const isValid = (elm) => {
176
- if (elm.nodeType === 1) {
177
- if (elm.nodeName.toLowerCase() === 'script') {
178
- return false;
179
- }
180
- for (let i = 0; i < elm.attributes.length; i++) {
181
- const name = elm.attributes[i].name;
182
- if (isStr(name) && name.toLowerCase().indexOf('on') === 0) {
183
- return false;
184
- }
185
- }
186
- for (let i = 0; i < elm.childNodes.length; i++) {
187
- if (!isValid(elm.childNodes[i])) {
188
- return false;
189
- }
190
- }
191
- }
192
- return true;
193
- };
194
- const isSvgDataUrl = (url) => url.startsWith('data:image/svg+xml');
195
- const isEncodedDataUrl = (url) => url.indexOf(';utf8,') !== -1;
196
-
197
- const ioniconContent = new Map();
198
- const requests = new Map();
199
- let parser;
200
- const getSvgContent = (url, sanitize) => {
201
- // see if we already have a request for this url
202
- let req = requests.get(url);
203
- if (!req) {
204
- if (typeof fetch !== 'undefined' && typeof document !== 'undefined') {
205
- /**
206
- * If the url is a data url of an svg, then try to parse it
207
- * with the DOMParser. This works with content security policies enabled.
208
- */
209
- if (isSvgDataUrl(url) && isEncodedDataUrl(url)) {
210
- if (!parser) {
211
- /**
212
- * Create an instance of the DOM parser. This creates a single
213
- * parser instance for the entire app, which is more efficient.
214
- */
215
- parser = new DOMParser();
216
- }
217
- const doc = parser.parseFromString(url, 'text/html');
218
- const svg = doc.querySelector('svg');
219
- if (svg) {
220
- ioniconContent.set(url, svg.outerHTML);
221
- }
222
- return Promise.resolve();
223
- }
224
- else {
225
- // we don't already have a request
226
- req = fetch(url).then((rsp) => {
227
- if (rsp.ok) {
228
- return rsp.text().then((svgContent) => {
229
- if (svgContent && sanitize !== false) {
230
- svgContent = validateContent(svgContent);
231
- }
232
- ioniconContent.set(url, svgContent || '');
233
- });
234
- }
235
- ioniconContent.set(url, '');
236
- });
237
- // cache for the same requests
238
- requests.set(url, req);
239
- }
240
- }
241
- else {
242
- // set to empty for ssr scenarios and resolve promise
243
- ioniconContent.set(url, '');
244
- return Promise.resolve();
245
- }
246
- }
247
- return req;
248
- };
249
-
250
- const iconCss = ":host{display:inline-block;width:1em;height:1em;contain:strict;fill:currentColor;box-sizing:content-box !important}:host .ionicon{stroke:currentColor}.ionicon-fill-none{fill:none}.ionicon-stroke-width{stroke-width:32px;stroke-width:var(--ionicon-stroke-width, 32px)}.icon-inner,.ionicon,svg{display:block;height:100%;width:100%}@supports (background: -webkit-named-image(i)){:host(.icon-rtl) .icon-inner{transform:scaleX(-1)}}@supports not selector(:dir(rtl)) and selector(:host-context([dir='rtl'])){:host(.icon-rtl) .icon-inner{transform:scaleX(-1)}}:host(.flip-rtl):host-context([dir='rtl']) .icon-inner{transform:scaleX(-1)}@supports selector(:dir(rtl)){:host(.flip-rtl:dir(rtl)) .icon-inner{transform:scaleX(-1)}:host(.flip-rtl:dir(ltr)) .icon-inner{transform:scaleX(1)}}:host(.icon-small){font-size:1.125rem !important}:host(.icon-large){font-size:2rem !important}:host(.ion-color){color:var(--ion-color-base) !important}:host(.ion-color-primary){--ion-color-base:var(--ion-color-primary, #3880ff)}:host(.ion-color-secondary){--ion-color-base:var(--ion-color-secondary, #0cd1e8)}:host(.ion-color-tertiary){--ion-color-base:var(--ion-color-tertiary, #f4a942)}:host(.ion-color-success){--ion-color-base:var(--ion-color-success, #10dc60)}:host(.ion-color-warning){--ion-color-base:var(--ion-color-warning, #ffce00)}:host(.ion-color-danger){--ion-color-base:var(--ion-color-danger, #f14141)}:host(.ion-color-light){--ion-color-base:var(--ion-color-light, #f4f5f8)}:host(.ion-color-medium){--ion-color-base:var(--ion-color-medium, #989aa2)}:host(.ion-color-dark){--ion-color-base:var(--ion-color-dark, #222428)}";
251
- const IonIconStyle0 = iconCss;
252
-
253
- const Icon = class {
254
- constructor(hostRef) {
255
- registerInstance(this, hostRef);
256
- this.iconName = null;
257
- this.inheritedAttributes = {};
258
- this.didLoadIcon = false;
259
- this.svgContent = undefined;
260
- this.isVisible = false;
261
- this.mode = getIonMode();
262
- this.color = undefined;
263
- this.ios = undefined;
264
- this.md = undefined;
265
- this.flipRtl = undefined;
266
- this.name = undefined;
267
- this.src = undefined;
268
- this.icon = undefined;
269
- this.size = undefined;
270
- this.lazy = false;
271
- this.sanitize = true;
272
- }
273
- componentWillLoad() {
274
- this.inheritedAttributes = inheritAttributes(this.el, ['aria-label']);
275
- }
276
- connectedCallback() {
277
- // purposely do not return the promise here because loading
278
- // the svg file should not hold up loading the app
279
- // only load the svg if it's visible
280
- this.waitUntilVisible(this.el, '50px', () => {
281
- this.isVisible = true;
282
- this.loadIcon();
283
- });
284
- }
285
- componentDidLoad() {
286
- /**
287
- * Addresses an Angular issue where property values are assigned after the 'connectedCallback' but prior to the registration of watchers.
288
- * This enhancement ensures the loading of an icon when the component has finished rendering and the icon has yet to apply the SVG data.
289
- * This modification pertains to the usage of Angular's binding syntax:
290
- * `<ion-icon [name]="myIconName"></ion-icon>`
291
- */
292
- if (!this.didLoadIcon) {
293
- this.loadIcon();
294
- }
295
- }
296
- disconnectedCallback() {
297
- if (this.io) {
298
- this.io.disconnect();
299
- this.io = undefined;
300
- }
301
- }
302
- waitUntilVisible(el, rootMargin, cb) {
303
- if (this.lazy && typeof window !== 'undefined' && window.IntersectionObserver) {
304
- const io = (this.io = new window.IntersectionObserver((data) => {
305
- if (data[0].isIntersecting) {
306
- io.disconnect();
307
- this.io = undefined;
308
- cb();
309
- }
310
- }, { rootMargin }));
311
- io.observe(el);
312
- }
313
- else {
314
- // browser doesn't support IntersectionObserver
315
- // so just fallback to always show it
316
- cb();
317
- }
318
- }
319
- loadIcon() {
320
- if (this.isVisible) {
321
- const url = getUrl(this);
322
- if (url) {
323
- if (ioniconContent.has(url)) {
324
- // sync if it's already loaded
325
- this.svgContent = ioniconContent.get(url);
326
- }
327
- else {
328
- // async if it hasn't been loaded
329
- getSvgContent(url, this.sanitize).then(() => (this.svgContent = ioniconContent.get(url)));
330
- }
331
- this.didLoadIcon = true;
332
- }
333
- }
334
- this.iconName = getName(this.name, this.icon, this.mode, this.ios, this.md);
335
- }
336
- render() {
337
- const { flipRtl, iconName, inheritedAttributes, el } = this;
338
- const mode = this.mode || 'md';
339
- // we have designated that arrows & chevrons should automatically flip (unless flip-rtl is set to false) because "back" is left in ltr and right in rtl, and "forward" is the opposite
340
- const shouldAutoFlip = iconName
341
- ? (iconName.includes('arrow') || iconName.includes('chevron')) && flipRtl !== false
342
- : false;
343
- // if shouldBeFlippable is true, the icon should change direction when `dir` changes
344
- const shouldBeFlippable = flipRtl || shouldAutoFlip;
345
- return (h(Host, Object.assign({ role: "img", class: Object.assign(Object.assign({ [mode]: true }, createColorClasses(this.color)), { [`icon-${this.size}`]: !!this.size, 'flip-rtl': shouldBeFlippable, 'icon-rtl': shouldBeFlippable && isRTL(el) }) }, inheritedAttributes), this.svgContent ? (h("div", { class: "icon-inner", innerHTML: this.svgContent })) : (h("div", { class: "icon-inner" }))));
346
- }
347
- static get assetsDirs() { return ["svg"]; }
348
- get el() { return getElement(this); }
349
- static get watchers() { return {
350
- "name": ["loadIcon"],
351
- "src": ["loadIcon"],
352
- "icon": ["loadIcon"],
353
- "ios": ["loadIcon"],
354
- "md": ["loadIcon"]
355
- }; }
356
- };
357
- const getIonMode = () => (typeof document !== 'undefined' && document.documentElement.getAttribute('mode')) || 'md';
358
- const createColorClasses = (color) => {
359
- return color
360
- ? {
361
- 'ion-color': true,
362
- [`ion-color-${color}`]: true,
363
- }
364
- : null;
365
- };
366
- Icon.style = IonIconStyle0;
367
-
368
- const progressBarIosCss = ":host{--background:rgba(var(--ion-color-primary-rgb, 56, 128, 255), 0.3);--progress-background:var(--ion-color-primary, #3880ff);--buffer-background:var(--background);display:block;position:relative;width:100%;contain:strict;direction:ltr;overflow:hidden}.progress,.progress-indeterminate,.indeterminate-bar-primary,.indeterminate-bar-secondary,.progress-buffer-bar{left:0;right:0;top:0;bottom:0;position:absolute;width:100%;height:100%}.buffer-circles-container,.buffer-circles{left:0;right:0;top:0;bottom:0;position:absolute}.buffer-circles{right:-10px;left:-10px;}.progress,.progress-buffer-bar,.buffer-circles-container{transform-origin:left top;transition:transform 150ms linear}.progress,.progress-indeterminate{background:var(--progress-background);z-index:2}.progress-buffer-bar{background:var(--buffer-background);z-index:1}.buffer-circles-container{overflow:hidden}.indeterminate-bar-primary{top:0;right:0;bottom:0;left:-145.166611%;animation:primary-indeterminate-translate 2s infinite linear}.indeterminate-bar-primary .progress-indeterminate{animation:primary-indeterminate-scale 2s infinite linear;animation-play-state:inherit}.indeterminate-bar-secondary{top:0;right:0;bottom:0;left:-54.888891%;animation:secondary-indeterminate-translate 2s infinite linear}.indeterminate-bar-secondary .progress-indeterminate{animation:secondary-indeterminate-scale 2s infinite linear;animation-play-state:inherit}.buffer-circles{background-image:radial-gradient(ellipse at center, var(--buffer-background) 0%, var(--buffer-background) 30%, transparent 30%);background-repeat:repeat-x;background-position:5px center;background-size:10px 10px;z-index:0;animation:buffering 450ms infinite linear}:host(.progress-bar-reversed){transform:scaleX(-1)}:host(.progress-paused) .indeterminate-bar-secondary,:host(.progress-paused) .indeterminate-bar-primary,:host(.progress-paused) .buffer-circles{animation-play-state:paused}:host(.ion-color) .progress-buffer-bar{background:rgba(var(--ion-color-base-rgb), 0.3)}:host(.ion-color) .buffer-circles{background-image:radial-gradient(ellipse at center, rgba(var(--ion-color-base-rgb), 0.3) 0%, rgba(var(--ion-color-base-rgb), 0.3) 30%, transparent 30%)}:host(.ion-color) .progress,:host(.ion-color) .progress-indeterminate{background:var(--ion-color-base)}@keyframes primary-indeterminate-translate{0%{transform:translateX(0)}20%{animation-timing-function:cubic-bezier(0.5, 0, 0.701732, 0.495819);transform:translateX(0)}59.15%{animation-timing-function:cubic-bezier(0.302435, 0.381352, 0.55, 0.956352);transform:translateX(83.67142%)}100%{transform:translateX(200.611057%)}}@keyframes primary-indeterminate-scale{0%{transform:scaleX(0.08)}36.65%{animation-timing-function:cubic-bezier(0.334731, 0.12482, 0.785844, 1);transform:scaleX(0.08)}69.15%{animation-timing-function:cubic-bezier(0.06, 0.11, 0.6, 1);transform:scaleX(0.661479)}100%{transform:scaleX(0.08)}}@keyframes secondary-indeterminate-translate{0%{animation-timing-function:cubic-bezier(0.15, 0, 0.515058, 0.409685);transform:translateX(0)}25%{animation-timing-function:cubic-bezier(0.31033, 0.284058, 0.8, 0.733712);transform:translateX(37.651913%)}48.35%{animation-timing-function:cubic-bezier(0.4, 0.627035, 0.6, 0.902026);transform:translateX(84.386165%)}100%{transform:translateX(160.277782%)}}@keyframes secondary-indeterminate-scale{0%{animation-timing-function:cubic-bezier(0.205028, 0.057051, 0.57661, 0.453971);transform:scaleX(0.08)}19.15%{animation-timing-function:cubic-bezier(0.152313, 0.196432, 0.648374, 1.004315);transform:scaleX(0.457104)}44.15%{animation-timing-function:cubic-bezier(0.257759, -0.003163, 0.211762, 1.38179);transform:scaleX(0.72796)}100%{transform:scaleX(0.08)}}@keyframes buffering{to{transform:translateX(-10px)}}:host{height:3px}";
369
- const IonProgressBarIosStyle0 = progressBarIosCss;
370
-
371
- const progressBarMdCss = ":host{--background:rgba(var(--ion-color-primary-rgb, 56, 128, 255), 0.3);--progress-background:var(--ion-color-primary, #3880ff);--buffer-background:var(--background);display:block;position:relative;width:100%;contain:strict;direction:ltr;overflow:hidden}.progress,.progress-indeterminate,.indeterminate-bar-primary,.indeterminate-bar-secondary,.progress-buffer-bar{left:0;right:0;top:0;bottom:0;position:absolute;width:100%;height:100%}.buffer-circles-container,.buffer-circles{left:0;right:0;top:0;bottom:0;position:absolute}.buffer-circles{right:-10px;left:-10px;}.progress,.progress-buffer-bar,.buffer-circles-container{transform-origin:left top;transition:transform 150ms linear}.progress,.progress-indeterminate{background:var(--progress-background);z-index:2}.progress-buffer-bar{background:var(--buffer-background);z-index:1}.buffer-circles-container{overflow:hidden}.indeterminate-bar-primary{top:0;right:0;bottom:0;left:-145.166611%;animation:primary-indeterminate-translate 2s infinite linear}.indeterminate-bar-primary .progress-indeterminate{animation:primary-indeterminate-scale 2s infinite linear;animation-play-state:inherit}.indeterminate-bar-secondary{top:0;right:0;bottom:0;left:-54.888891%;animation:secondary-indeterminate-translate 2s infinite linear}.indeterminate-bar-secondary .progress-indeterminate{animation:secondary-indeterminate-scale 2s infinite linear;animation-play-state:inherit}.buffer-circles{background-image:radial-gradient(ellipse at center, var(--buffer-background) 0%, var(--buffer-background) 30%, transparent 30%);background-repeat:repeat-x;background-position:5px center;background-size:10px 10px;z-index:0;animation:buffering 450ms infinite linear}:host(.progress-bar-reversed){transform:scaleX(-1)}:host(.progress-paused) .indeterminate-bar-secondary,:host(.progress-paused) .indeterminate-bar-primary,:host(.progress-paused) .buffer-circles{animation-play-state:paused}:host(.ion-color) .progress-buffer-bar{background:rgba(var(--ion-color-base-rgb), 0.3)}:host(.ion-color) .buffer-circles{background-image:radial-gradient(ellipse at center, rgba(var(--ion-color-base-rgb), 0.3) 0%, rgba(var(--ion-color-base-rgb), 0.3) 30%, transparent 30%)}:host(.ion-color) .progress,:host(.ion-color) .progress-indeterminate{background:var(--ion-color-base)}@keyframes primary-indeterminate-translate{0%{transform:translateX(0)}20%{animation-timing-function:cubic-bezier(0.5, 0, 0.701732, 0.495819);transform:translateX(0)}59.15%{animation-timing-function:cubic-bezier(0.302435, 0.381352, 0.55, 0.956352);transform:translateX(83.67142%)}100%{transform:translateX(200.611057%)}}@keyframes primary-indeterminate-scale{0%{transform:scaleX(0.08)}36.65%{animation-timing-function:cubic-bezier(0.334731, 0.12482, 0.785844, 1);transform:scaleX(0.08)}69.15%{animation-timing-function:cubic-bezier(0.06, 0.11, 0.6, 1);transform:scaleX(0.661479)}100%{transform:scaleX(0.08)}}@keyframes secondary-indeterminate-translate{0%{animation-timing-function:cubic-bezier(0.15, 0, 0.515058, 0.409685);transform:translateX(0)}25%{animation-timing-function:cubic-bezier(0.31033, 0.284058, 0.8, 0.733712);transform:translateX(37.651913%)}48.35%{animation-timing-function:cubic-bezier(0.4, 0.627035, 0.6, 0.902026);transform:translateX(84.386165%)}100%{transform:translateX(160.277782%)}}@keyframes secondary-indeterminate-scale{0%{animation-timing-function:cubic-bezier(0.205028, 0.057051, 0.57661, 0.453971);transform:scaleX(0.08)}19.15%{animation-timing-function:cubic-bezier(0.152313, 0.196432, 0.648374, 1.004315);transform:scaleX(0.457104)}44.15%{animation-timing-function:cubic-bezier(0.257759, -0.003163, 0.211762, 1.38179);transform:scaleX(0.72796)}100%{transform:scaleX(0.08)}}@keyframes buffering{to{transform:translateX(-10px)}}:host{height:4px}";
372
- const IonProgressBarMdStyle0 = progressBarMdCss;
373
-
374
- const ProgressBar = class {
375
- constructor(hostRef) {
376
- registerInstance(this, hostRef);
377
- this.type = 'determinate';
378
- this.reversed = false;
379
- this.value = 0;
380
- this.buffer = 1;
381
- this.color = undefined;
382
- }
383
- render() {
384
- const { color, type, reversed, value, buffer } = this;
385
- const paused = config$1.getBoolean('_testing');
386
- const mode = getIonMode$1(this);
387
- return (h(Host, { key: '944b79ed6fce1b2c0ed48681cd8517a5abbddd80', role: "progressbar", "aria-valuenow": type === 'determinate' ? value : null, "aria-valuemin": "0", "aria-valuemax": "1", class: createColorClasses$1(color, {
388
- [mode]: true,
389
- [`progress-bar-${type}`]: true,
390
- 'progress-paused': paused,
391
- 'progress-bar-reversed': document.dir === 'rtl' ? !reversed : reversed,
392
- }) }, type === 'indeterminate' ? renderIndeterminate() : renderProgress(value, buffer)));
393
- }
394
- };
395
- const renderIndeterminate = () => {
396
- return (h("div", { part: "track", class: "progress-buffer-bar" }, h("div", { class: "indeterminate-bar-primary" }, h("span", { part: "progress", class: "progress-indeterminate" })), h("div", { class: "indeterminate-bar-secondary" }, h("span", { part: "progress", class: "progress-indeterminate" }))));
397
- };
398
- const renderProgress = (value, buffer) => {
399
- const finalValue = clamp(0, value, 1);
400
- const finalBuffer = clamp(0, buffer, 1);
401
- return [
402
- h("div", { part: "progress", class: "progress", style: { transform: `scaleX(${finalValue})` } }),
403
- /**
404
- * Buffer circles with two container to move
405
- * the circles behind the buffer progress
406
- * with respecting the animation.
407
- * When finalBuffer === 1, we use display: none
408
- * instead of removing the element to avoid flickering.
409
- */
410
- h("div", { class: { 'buffer-circles-container': true, 'ion-hide': finalBuffer === 1 }, style: { transform: `translateX(${finalBuffer * 100}%)` } }, h("div", { class: "buffer-circles-container", style: { transform: `translateX(-${finalBuffer * 100}%)` } }, h("div", { part: "stream", class: "buffer-circles" }))),
411
- h("div", { part: "track", class: "progress-buffer-bar", style: { transform: `scaleX(${finalBuffer})` } }),
412
- ];
413
- };
414
- ProgressBar.style = {
415
- ios: IonProgressBarIosStyle0,
416
- md: IonProgressBarMdStyle0
417
- };
418
-
419
- const rippleEffectCss = ":host{left:0;right:0;top:0;bottom:0;position:absolute;contain:strict;pointer-events:none}:host(.unbounded){contain:layout size style}.ripple-effect{border-radius:50%;position:absolute;background-color:currentColor;color:inherit;contain:strict;opacity:0;animation:225ms rippleAnimation forwards, 75ms fadeInAnimation forwards;will-change:transform, opacity;pointer-events:none}.fade-out{transform:translate(var(--translate-end)) scale(var(--final-scale, 1));animation:150ms fadeOutAnimation forwards}@keyframes rippleAnimation{from{animation-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transform:scale(1)}to{transform:translate(var(--translate-end)) scale(var(--final-scale, 1))}}@keyframes fadeInAnimation{from{animation-timing-function:linear;opacity:0}to{opacity:0.16}}@keyframes fadeOutAnimation{from{animation-timing-function:linear;opacity:0.16}to{opacity:0}}";
420
- const IonRippleEffectStyle0 = rippleEffectCss;
421
-
422
- const RippleEffect = class {
423
- constructor(hostRef) {
424
- registerInstance(this, hostRef);
425
- this.type = 'bounded';
426
- }
427
- /**
428
- * Adds the ripple effect to the parent element.
429
- *
430
- * @param x The horizontal coordinate of where the ripple should start.
431
- * @param y The vertical coordinate of where the ripple should start.
432
- */
433
- async addRipple(x, y) {
434
- return new Promise((resolve) => {
435
- readTask(() => {
436
- const rect = this.el.getBoundingClientRect();
437
- const width = rect.width;
438
- const height = rect.height;
439
- const hypotenuse = Math.sqrt(width * width + height * height);
440
- const maxDim = Math.max(height, width);
441
- const maxRadius = this.unbounded ? maxDim : hypotenuse + PADDING;
442
- const initialSize = Math.floor(maxDim * INITIAL_ORIGIN_SCALE);
443
- const finalScale = maxRadius / initialSize;
444
- let posX = x - rect.left;
445
- let posY = y - rect.top;
446
- if (this.unbounded) {
447
- posX = width * 0.5;
448
- posY = height * 0.5;
449
- }
450
- const styleX = posX - initialSize * 0.5;
451
- const styleY = posY - initialSize * 0.5;
452
- const moveX = width * 0.5 - posX;
453
- const moveY = height * 0.5 - posY;
454
- writeTask(() => {
455
- const div = document.createElement('div');
456
- div.classList.add('ripple-effect');
457
- const style = div.style;
458
- style.top = styleY + 'px';
459
- style.left = styleX + 'px';
460
- style.width = style.height = initialSize + 'px';
461
- style.setProperty('--final-scale', `${finalScale}`);
462
- style.setProperty('--translate-end', `${moveX}px, ${moveY}px`);
463
- const container = this.el.shadowRoot || this.el;
464
- container.appendChild(div);
465
- setTimeout(() => {
466
- resolve(() => {
467
- removeRipple(div);
468
- });
469
- }, 225 + 100);
470
- });
471
- });
472
- });
473
- }
474
- get unbounded() {
475
- return this.type === 'unbounded';
476
- }
477
- render() {
478
- const mode = getIonMode$1(this);
479
- return (h(Host, { key: 'f1129019a6d556b008c754aeb79618c69baea9f8', role: "presentation", class: {
480
- [mode]: true,
481
- unbounded: this.unbounded,
482
- } }));
483
- }
484
- get el() { return getElement(this); }
485
- };
486
- const removeRipple = (ripple) => {
487
- ripple.classList.add('fade-out');
488
- setTimeout(() => {
489
- ripple.remove();
490
- }, 200);
491
- };
492
- const PADDING = 10;
493
- const INITIAL_ORIGIN_SCALE = 0.5;
494
- RippleEffect.style = IonRippleEffectStyle0;
495
-
496
- const skeletonTextCss = ":host{--background:rgba(var(--background-rgb, var(--ion-text-color-rgb, 0, 0, 0)), 0.065);border-radius:var(--border-radius, inherit);display:block;width:100%;height:inherit;margin-top:4px;margin-bottom:4px;background:var(--background);line-height:10px;user-select:none;pointer-events:none}span{display:inline-block}:host(.in-media){margin-left:0;margin-right:0;margin-top:0;margin-bottom:0;height:100%}:host(.skeleton-text-animated){position:relative;background:linear-gradient(to right, rgba(var(--background-rgb, var(--ion-text-color-rgb, 0, 0, 0)), 0.065) 8%, rgba(var(--background-rgb, var(--ion-text-color-rgb, 0, 0, 0)), 0.135) 18%, rgba(var(--background-rgb, var(--ion-text-color-rgb, 0, 0, 0)), 0.065) 33%);background-size:800px 104px;animation-duration:1s;animation-fill-mode:forwards;animation-iteration-count:infinite;animation-name:shimmer;animation-timing-function:linear}@keyframes shimmer{0%{background-position:-400px 0}100%{background-position:400px 0}}";
497
- const IonSkeletonTextStyle0 = skeletonTextCss;
498
-
499
- const SkeletonText = class {
500
- constructor(hostRef) {
501
- registerInstance(this, hostRef);
502
- this.ionStyle = createEvent(this, "ionStyle", 7);
503
- this.animated = false;
504
- }
505
- componentWillLoad() {
506
- this.emitStyle();
507
- }
508
- emitStyle() {
509
- // The emitted property is used by item in order
510
- // to add the item-skeleton-text class which applies
511
- // overflow: hidden to its label
512
- const style = {
513
- 'skeleton-text': true,
514
- };
515
- this.ionStyle.emit(style);
516
- }
517
- render() {
518
- const animated = this.animated && config$1.getBoolean('animated', true);
519
- const inMedia = hostContext('ion-avatar', this.el) || hostContext('ion-thumbnail', this.el);
520
- const mode = getIonMode$1(this);
521
- return (h(Host, { key: '4dab0fd2de666de12ad8f6dc6ed1e1de0be67ddd', class: {
522
- [mode]: true,
523
- 'skeleton-text-animated': animated,
524
- 'in-media': inMedia,
525
- } }, h("span", { key: 'f8f908ec24d65e63b14d9a54640a5f18f0fa8fa5' }, "\u00A0")));
526
- }
527
- get el() { return getElement(this); }
528
- };
529
- SkeletonText.style = IonSkeletonTextStyle0;
530
-
531
- /*!
532
- * (C) Ionic http://ionicframework.com - MIT License
533
- */
534
- /**
535
- * Calculate the CSS top and bottom position of the toast, to be used
536
- * as starting points for the animation keyframes.
537
- *
538
- * The default animations for both MD and iOS
539
- * use translateY, which calculates from the
540
- * top edge of the screen. This behavior impacts
541
- * how we compute the offset when a toast has
542
- * position='bottom' since we need to calculate from
543
- * the bottom edge of the screen instead.
544
- *
545
- * @param position The value of the toast's position prop.
546
- * @param positionAnchor The element the toast should be anchored to,
547
- * if applicable.
548
- * @param mode The toast component's mode (md, ios, etc).
549
- * @param toast A reference to the toast element itself.
550
- */
551
- function getAnimationPosition(position, positionAnchor, mode, toast) {
552
- /**
553
- * Start with a predefined offset from the edge the toast will be
554
- * positioned relative to, whether on the screen or anchor element.
555
- */
556
- let offset;
557
- if (mode === 'md') {
558
- offset = position === 'top' ? 8 : -8;
559
- }
560
- else {
561
- offset = position === 'top' ? 10 : -10;
562
- }
563
- /**
564
- * If positionAnchor is defined, add in the distance from the target
565
- * screen edge to the target anchor edge. For position="top", the
566
- * bottom anchor edge is targeted. For position="bottom", the top
567
- * anchor edge is targeted.
568
- */
569
- if (positionAnchor && win) {
570
- warnIfAnchorIsHidden(positionAnchor, toast);
571
- const box = positionAnchor.getBoundingClientRect();
572
- if (position === 'top') {
573
- offset += box.bottom;
574
- }
575
- else if (position === 'bottom') {
576
- /**
577
- * Just box.top is the distance from the top edge of the screen
578
- * to the top edge of the anchor. We want to calculate from the
579
- * bottom edge of the screen instead.
580
- */
581
- offset -= win.innerHeight - box.top;
582
- }
583
- /**
584
- * We don't include safe area here because that should already be
585
- * accounted for when checking the position of the anchor.
586
- */
587
- return {
588
- top: `${offset}px`,
589
- bottom: `${offset}px`,
590
- };
591
- }
592
- else {
593
- return {
594
- top: `calc(${offset}px + var(--ion-safe-area-top, 0px))`,
595
- bottom: `calc(${offset}px - var(--ion-safe-area-bottom, 0px))`,
596
- };
597
- }
598
- }
599
- /**
600
- * If the anchor element is hidden, getBoundingClientRect()
601
- * will return all 0s for it, which can cause unexpected
602
- * results in the position calculation when animating.
603
- */
604
- function warnIfAnchorIsHidden(positionAnchor, toast) {
605
- if (positionAnchor.offsetParent === null) {
606
- printIonWarning('The positionAnchor element for ion-toast was found in the DOM, but appears to be hidden. This may lead to unexpected positioning of the toast.', toast);
607
- }
608
- }
609
- /**
610
- * Returns the top offset required to place
611
- * the toast in the middle of the screen.
612
- * Only needed when position="toast".
613
- * @param toastHeight - The height of the ion-toast element
614
- * @param wrapperHeight - The height of the .toast-wrapper element
615
- * inside the toast's shadow root.
616
- */
617
- const getOffsetForMiddlePosition = (toastHeight, wrapperHeight) => {
618
- return Math.floor(toastHeight / 2 - wrapperHeight / 2);
619
- };
620
-
621
- /*!
622
- * (C) Ionic http://ionicframework.com - MIT License
623
- */
624
- /**
625
- * iOS Toast Enter Animation
626
- */
627
- const iosEnterAnimation = (baseEl, opts) => {
628
- const baseAnimation = createAnimation();
629
- const wrapperAnimation = createAnimation();
630
- const { position, top, bottom } = opts;
631
- const root = getElementRoot(baseEl);
632
- const wrapperEl = root.querySelector('.toast-wrapper');
633
- wrapperAnimation.addElement(wrapperEl);
634
- switch (position) {
635
- case 'top':
636
- wrapperAnimation.fromTo('transform', 'translateY(-100%)', `translateY(${top})`);
637
- break;
638
- case 'middle':
639
- const topPosition = getOffsetForMiddlePosition(baseEl.clientHeight, wrapperEl.clientHeight);
640
- wrapperEl.style.top = `${topPosition}px`;
641
- wrapperAnimation.fromTo('opacity', 0.01, 1);
642
- break;
643
- default:
644
- wrapperAnimation.fromTo('transform', 'translateY(100%)', `translateY(${bottom})`);
645
- break;
646
- }
647
- return baseAnimation.easing('cubic-bezier(.155,1.105,.295,1.12)').duration(400).addAnimation(wrapperAnimation);
648
- };
649
-
650
- /*!
651
- * (C) Ionic http://ionicframework.com - MIT License
652
- */
653
- /**
654
- * iOS Toast Leave Animation
655
- */
656
- const iosLeaveAnimation = (baseEl, opts) => {
657
- const baseAnimation = createAnimation();
658
- const wrapperAnimation = createAnimation();
659
- const { position, top, bottom } = opts;
660
- const root = getElementRoot(baseEl);
661
- const wrapperEl = root.querySelector('.toast-wrapper');
662
- wrapperAnimation.addElement(wrapperEl);
663
- switch (position) {
664
- case 'top':
665
- wrapperAnimation.fromTo('transform', `translateY(${top})`, 'translateY(-100%)');
666
- break;
667
- case 'middle':
668
- wrapperAnimation.fromTo('opacity', 0.99, 0);
669
- break;
670
- default:
671
- wrapperAnimation.fromTo('transform', `translateY(${bottom})`, 'translateY(100%)');
672
- break;
673
- }
674
- return baseAnimation.easing('cubic-bezier(.36,.66,.04,1)').duration(300).addAnimation(wrapperAnimation);
675
- };
676
-
677
- /*!
678
- * (C) Ionic http://ionicframework.com - MIT License
679
- */
680
- /**
681
- * MD Toast Enter Animation
682
- */
683
- const mdEnterAnimation = (baseEl, opts) => {
684
- const baseAnimation = createAnimation();
685
- const wrapperAnimation = createAnimation();
686
- const { position, top, bottom } = opts;
687
- const root = getElementRoot(baseEl);
688
- const wrapperEl = root.querySelector('.toast-wrapper');
689
- wrapperAnimation.addElement(wrapperEl);
690
- switch (position) {
691
- case 'top':
692
- wrapperEl.style.setProperty('transform', `translateY(${top})`);
693
- wrapperAnimation.fromTo('opacity', 0.01, 1);
694
- break;
695
- case 'middle':
696
- const topPosition = getOffsetForMiddlePosition(baseEl.clientHeight, wrapperEl.clientHeight);
697
- wrapperEl.style.top = `${topPosition}px`;
698
- wrapperAnimation.fromTo('opacity', 0.01, 1);
699
- break;
700
- default:
701
- wrapperEl.style.setProperty('transform', `translateY(${bottom})`);
702
- wrapperAnimation.fromTo('opacity', 0.01, 1);
703
- break;
704
- }
705
- return baseAnimation.easing('cubic-bezier(.36,.66,.04,1)').duration(400).addAnimation(wrapperAnimation);
706
- };
707
-
708
- /*!
709
- * (C) Ionic http://ionicframework.com - MIT License
710
- */
711
- /**
712
- * md Toast Leave Animation
713
- */
714
- const mdLeaveAnimation = (baseEl) => {
715
- const baseAnimation = createAnimation();
716
- const wrapperAnimation = createAnimation();
717
- const root = getElementRoot(baseEl);
718
- const wrapperEl = root.querySelector('.toast-wrapper');
719
- wrapperAnimation.addElement(wrapperEl).fromTo('opacity', 0.99, 0);
720
- return baseAnimation.easing('cubic-bezier(.36,.66,.04,1)').duration(300).addAnimation(wrapperAnimation);
721
- };
722
-
723
- /*!
724
- * (C) Ionic http://ionicframework.com - MIT License
725
- */
726
- /**
727
- * Create a gesture that allows the Toast
728
- * to be swiped to dismiss.
729
- * @param el - The Toast element
730
- * @param toastPosition - The last computed position of the Toast. This is computed in the "present" method.
731
- * @param onDismiss - A callback to fire when the Toast was swiped to dismiss.
732
- */
733
- const createSwipeToDismissGesture = (el, toastPosition, onDismiss) => {
734
- /**
735
- * Users should swipe on the visible toast wrapper
736
- * rather than on ion-toast which covers the entire screen.
737
- * When testing the class instance the inner wrapper will not
738
- * be defined. As a result, we use a placeholder element in those environments.
739
- */
740
- const wrapperEl = getElementRoot(el).querySelector('.toast-wrapper');
741
- const hostElHeight = el.clientHeight;
742
- const wrapperElBox = wrapperEl.getBoundingClientRect();
743
- /**
744
- * The maximum amount that
745
- * the toast can be swiped. This should
746
- * account for the wrapper element's height
747
- * too so the toast can be swiped offscreen
748
- * completely.
749
- */
750
- let MAX_SWIPE_DISTANCE = 0;
751
- /**
752
- * The step value at which a toast
753
- * is eligible for dismissing via gesture.
754
- */
755
- const DISMISS_THRESHOLD = 0.5;
756
- /**
757
- * The middle position Toast starts 50% of the way
758
- * through the animation, so we need to use this
759
- * as the starting point for our step values.
760
- */
761
- const STEP_OFFSET = el.position === 'middle' ? 0.5 : 0;
762
- /**
763
- * When the Toast is at the top users will be
764
- * swiping up. As a result, the delta values will be
765
- * negative numbers which will result in negative steps
766
- * and thresholds. As a result, we need to make those numbers
767
- * positive.
768
- */
769
- const INVERSION_FACTOR = el.position === 'top' ? -1 : 1;
770
- /**
771
- * The top offset that places the
772
- * toast in the middle of the screen.
773
- * Only needed when position="middle".
774
- */
775
- const topPosition = getOffsetForMiddlePosition(hostElHeight, wrapperElBox.height);
776
- const SWIPE_UP_DOWN_KEYFRAMES = [
777
- { offset: 0, transform: `translateY(-${topPosition + wrapperElBox.height}px)` },
778
- { offset: 0.5, transform: `translateY(0px)` },
779
- { offset: 1, transform: `translateY(${topPosition + wrapperElBox.height}px)` },
780
- ];
781
- const swipeAnimation = createAnimation('toast-swipe-to-dismiss-animation')
782
- .addElement(wrapperEl)
783
- /**
784
- * The specific value here does not actually
785
- * matter. We just need this to be a positive
786
- * value so the animation does not jump
787
- * to the end when the user beings to drag.
788
- */
789
- .duration(100);
790
- switch (el.position) {
791
- case 'middle':
792
- MAX_SWIPE_DISTANCE = hostElHeight + wrapperElBox.height;
793
- swipeAnimation.keyframes(SWIPE_UP_DOWN_KEYFRAMES);
794
- /**
795
- * Toast can be swiped up or down but
796
- * should start in the middle of the screen.
797
- */
798
- swipeAnimation.progressStart(true, 0.5);
799
- break;
800
- case 'top':
801
- /**
802
- * The bottom edge of the wrapper
803
- * includes the distance between the top
804
- * of the screen and the top of the wrapper
805
- * as well as the wrapper height so the wrapper
806
- * can be dragged fully offscreen.
807
- */
808
- MAX_SWIPE_DISTANCE = wrapperElBox.bottom;
809
- swipeAnimation.keyframes([
810
- { offset: 0, transform: `translateY(${toastPosition.top})` },
811
- { offset: 1, transform: 'translateY(-100%)' },
812
- ]);
813
- swipeAnimation.progressStart(true, 0);
814
- break;
815
- case 'bottom':
816
- default:
817
- /**
818
- * This computes the distance between the
819
- * top of the wrapper and the bottom of the
820
- * screen including the height of the wrapper
821
- * element so it can be dragged fully offscreen.
822
- */
823
- MAX_SWIPE_DISTANCE = hostElHeight - wrapperElBox.top;
824
- swipeAnimation.keyframes([
825
- { offset: 0, transform: `translateY(${toastPosition.bottom})` },
826
- { offset: 1, transform: 'translateY(100%)' },
827
- ]);
828
- swipeAnimation.progressStart(true, 0);
829
- break;
830
- }
831
- const computeStep = (delta) => {
832
- return (delta * INVERSION_FACTOR) / MAX_SWIPE_DISTANCE;
833
- };
834
- const onMove = (detail) => {
835
- const step = STEP_OFFSET + computeStep(detail.deltaY);
836
- swipeAnimation.progressStep(step);
837
- };
838
- const onEnd = (detail) => {
839
- const velocity = detail.velocityY;
840
- const threshold = ((detail.deltaY + velocity * 1000) / MAX_SWIPE_DISTANCE) * INVERSION_FACTOR;
841
- /**
842
- * Disable the gesture for the remainder of the animation.
843
- * It will be re-enabled if the toast animates back to
844
- * its initial presented position.
845
- */
846
- gesture.enable(false);
847
- let shouldDismiss = true;
848
- let playTo = 1;
849
- let step = 0;
850
- let remainingDistance = 0;
851
- if (el.position === 'middle') {
852
- /**
853
- * A middle positioned Toast appears
854
- * in the middle of the screen (at animation offset 0.5).
855
- * As a result, the threshold will be calculated relative
856
- * to this starting position. In other words at animation offset 0.5
857
- * the threshold will be 0. We want the middle Toast to be eligible
858
- * for dismiss when the user has swiped either half way up or down the
859
- * screen. As a result, we divide DISMISS_THRESHOLD in half. We also
860
- * consider when the threshold is a negative in the event the
861
- * user drags up (since the deltaY will also be negative).
862
- */
863
- shouldDismiss = threshold >= DISMISS_THRESHOLD / 2 || threshold <= -DISMISS_THRESHOLD / 2;
864
- /**
865
- * Since we are replacing the keyframes
866
- * below the animation always starts from
867
- * the beginning of the new keyframes.
868
- * Similarly, we are always playing to
869
- * the end of the new keyframes.
870
- */
871
- playTo = 1;
872
- step = 0;
873
- /**
874
- * The Toast should animate from wherever its
875
- * current position is to the desired end state.
876
- *
877
- * To begin, we get the current position of the
878
- * Toast for its starting state.
879
- */
880
- const wrapperElBox = wrapperEl.getBoundingClientRect();
881
- const startOffset = wrapperElBox.top - topPosition;
882
- const startPosition = `${startOffset}px`;
883
- /**
884
- * If the deltaY is negative then the user is swiping
885
- * up, so the Toast should animate to the top of the screen.
886
- * If the deltaY is positive then the user is swiping
887
- * down, so the Toast should animate to the bottom of the screen.
888
- * We also account for when the deltaY is 0, but realistically
889
- * that should never happen because it means the user did not drag
890
- * the toast.
891
- */
892
- const offsetFactor = detail.deltaY <= 0 ? -1 : 1;
893
- const endOffset = (topPosition + wrapperElBox.height) * offsetFactor;
894
- /**
895
- * If the Toast should dismiss
896
- * then we need to figure out which edge of
897
- * the screen it should animate towards.
898
- * By default, the Toast will come
899
- * back to its default state in the
900
- * middle of the screen.
901
- */
902
- const endPosition = shouldDismiss ? `${endOffset}px` : '0px';
903
- const KEYFRAMES = [
904
- { offset: 0, transform: `translateY(${startPosition})` },
905
- { offset: 1, transform: `translateY(${endPosition})` },
906
- ];
907
- swipeAnimation.keyframes(KEYFRAMES);
908
- /**
909
- * Compute the remaining amount of pixels the
910
- * toast needs to move to be fully dismissed.
911
- */
912
- remainingDistance = endOffset - startOffset;
913
- }
914
- else {
915
- shouldDismiss = threshold >= DISMISS_THRESHOLD;
916
- playTo = shouldDismiss ? 1 : 0;
917
- step = computeStep(detail.deltaY);
918
- /**
919
- * Compute the remaining amount of pixels the
920
- * toast needs to move to be fully dismissed.
921
- */
922
- const remainingStepAmount = shouldDismiss ? 1 - step : step;
923
- remainingDistance = remainingStepAmount * MAX_SWIPE_DISTANCE;
924
- }
925
- /**
926
- * The animation speed should depend on how quickly
927
- * the user flicks the toast across the screen. However,
928
- * it should be no slower than 200ms.
929
- * We use Math.abs on the remainingDistance because that value
930
- * can be negative when swiping up on a middle position toast.
931
- */
932
- const duration = Math.min(Math.abs(remainingDistance) / Math.abs(velocity), 200);
933
- swipeAnimation
934
- .onFinish(() => {
935
- if (shouldDismiss) {
936
- onDismiss();
937
- swipeAnimation.destroy();
938
- }
939
- else {
940
- if (el.position === 'middle') {
941
- /**
942
- * If the toast snapped back to
943
- * the middle of the screen we need
944
- * to reset the keyframes
945
- * so the toast can be swiped
946
- * up or down again.
947
- */
948
- swipeAnimation.keyframes(SWIPE_UP_DOWN_KEYFRAMES).progressStart(true, 0.5);
949
- }
950
- else {
951
- swipeAnimation.progressStart(true, 0);
952
- }
953
- /**
954
- * If the toast did not dismiss then
955
- * the user should be able to swipe again.
956
- */
957
- gesture.enable(true);
958
- }
959
- /**
960
- * This must be a one time callback
961
- * otherwise a new callback will
962
- * be added every time onEnd runs.
963
- */
964
- }, { oneTimeCallback: true })
965
- .progressEnd(playTo, step, duration);
966
- };
967
- const gesture = createGesture({
968
- el: wrapperEl,
969
- gestureName: 'toast-swipe-to-dismiss',
970
- gesturePriority: OVERLAY_GESTURE_PRIORITY,
971
- /**
972
- * Toast only supports vertical swipes.
973
- * This needs to be updated if we later
974
- * support horizontal swipes.
975
- */
976
- direction: 'y',
977
- onMove,
978
- onEnd,
979
- });
980
- return gesture;
981
- };
982
-
983
- const toastIosCss = ":host{--border-width:0;--border-style:none;--border-color:initial;--box-shadow:none;--min-width:auto;--width:auto;--min-height:auto;--height:auto;--max-height:auto;--white-space:normal;top:0;display:block;position:absolute;width:100%;height:100%;outline:none;color:var(--color);font-family:var(--ion-font-family, inherit);contain:strict;z-index:1001;pointer-events:none}@supports (inset-inline-start: 0){:host{inset-inline-start:0}}@supports not (inset-inline-start: 0){:host{left:0}:host-context([dir=rtl]){left:unset;right:unset;right:0}@supports selector(:dir(rtl)){:host(:dir(rtl)){left:unset;right:unset;right:0}}}:host(.overlay-hidden){display:none}:host(.ion-color){--button-color:inherit;color:var(--ion-color-contrast)}:host(.ion-color) .toast-button-cancel{color:inherit}:host(.ion-color) .toast-wrapper{background:var(--ion-color-base)}.toast-wrapper{border-radius:var(--border-radius);width:var(--width);min-width:var(--min-width);max-width:var(--max-width);height:var(--height);min-height:var(--min-height);max-height:var(--max-height);border-width:var(--border-width);border-style:var(--border-style);border-color:var(--border-color);background:var(--background);box-shadow:var(--box-shadow)}@supports (inset-inline-start: 0){.toast-wrapper{inset-inline-start:var(--start);inset-inline-end:var(--end)}}@supports not (inset-inline-start: 0){.toast-wrapper{left:var(--start);right:var(--end)}:host-context([dir=rtl]) .toast-wrapper{left:unset;right:unset;left:var(--end);right:var(--start)}[dir=rtl] .toast-wrapper{left:unset;right:unset;left:var(--end);right:var(--start)}@supports selector(:dir(rtl)){.toast-wrapper:dir(rtl){left:unset;right:unset;left:var(--end);right:var(--start)}}}.toast-wrapper.toast-top{transform:translate3d(0, -100%, 0);top:0}.toast-wrapper.toast-bottom{transform:translate3d(0, 100%, 0);bottom:0}.toast-container{display:flex;align-items:center;pointer-events:auto;height:inherit;min-height:inherit;max-height:inherit;contain:content}.toast-layout-stacked .toast-container{flex-wrap:wrap}.toast-layout-baseline .toast-content{display:flex;flex:1;flex-direction:column;justify-content:center}.toast-icon{-webkit-margin-start:16px;margin-inline-start:16px}.toast-content{min-width:0}.toast-message{flex:1;white-space:var(--white-space)}.toast-button-group{display:flex}.toast-layout-stacked .toast-button-group{justify-content:end;width:100%}.toast-button{border:0;outline:none;color:var(--button-color);z-index:0}.toast-icon,.toast-button-icon{font-size:1.4em}.toast-button-inner{display:flex;align-items:center}@media (any-hover: hover){.toast-button:hover{cursor:pointer}}:host{--background:var(--ion-color-step-50, #f2f2f2);--border-radius:14px;--button-color:var(--ion-color-primary, #3880ff);--color:var(--ion-color-step-850, #262626);--max-width:700px;--max-height:478px;--start:10px;--end:10px;font-size:clamp(14px, 0.875rem, 43.4px)}.toast-wrapper{-webkit-margin-start:auto;margin-inline-start:auto;-webkit-margin-end:auto;margin-inline-end:auto;margin-top:auto;margin-bottom:auto;display:block;position:absolute;z-index:10}@supports (backdrop-filter: blur(0)){:host(.toast-translucent) .toast-wrapper{background:rgba(var(--ion-background-color-rgb, 255, 255, 255), 0.8);backdrop-filter:saturate(180%) blur(20px)}:host(.ion-color.toast-translucent) .toast-wrapper{background:rgba(var(--ion-color-base-rgb), 0.8)}}.toast-wrapper.toast-middle{opacity:0.01}.toast-content{-webkit-padding-start:15px;padding-inline-start:15px;-webkit-padding-end:15px;padding-inline-end:15px;padding-top:15px;padding-bottom:15px}.toast-header{margin-bottom:2px;font-weight:500}.toast-button{-webkit-padding-start:15px;padding-inline-start:15px;-webkit-padding-end:15px;padding-inline-end:15px;padding-top:10px;padding-bottom:10px;min-height:44px;transition:background-color, opacity 100ms linear;border:0;background-color:transparent;font-family:var(--ion-font-family);font-size:clamp(17px, 1.0625rem, 21.998px);font-weight:500;overflow:hidden}.toast-button.ion-activated{opacity:0.4}@media (any-hover: hover){.toast-button:hover{opacity:0.6}}";
984
- const IonToastIosStyle0 = toastIosCss;
985
-
986
- const toastMdCss = ":host{--border-width:0;--border-style:none;--border-color:initial;--box-shadow:none;--min-width:auto;--width:auto;--min-height:auto;--height:auto;--max-height:auto;--white-space:normal;top:0;display:block;position:absolute;width:100%;height:100%;outline:none;color:var(--color);font-family:var(--ion-font-family, inherit);contain:strict;z-index:1001;pointer-events:none}@supports (inset-inline-start: 0){:host{inset-inline-start:0}}@supports not (inset-inline-start: 0){:host{left:0}:host-context([dir=rtl]){left:unset;right:unset;right:0}@supports selector(:dir(rtl)){:host(:dir(rtl)){left:unset;right:unset;right:0}}}:host(.overlay-hidden){display:none}:host(.ion-color){--button-color:inherit;color:var(--ion-color-contrast)}:host(.ion-color) .toast-button-cancel{color:inherit}:host(.ion-color) .toast-wrapper{background:var(--ion-color-base)}.toast-wrapper{border-radius:var(--border-radius);width:var(--width);min-width:var(--min-width);max-width:var(--max-width);height:var(--height);min-height:var(--min-height);max-height:var(--max-height);border-width:var(--border-width);border-style:var(--border-style);border-color:var(--border-color);background:var(--background);box-shadow:var(--box-shadow)}@supports (inset-inline-start: 0){.toast-wrapper{inset-inline-start:var(--start);inset-inline-end:var(--end)}}@supports not (inset-inline-start: 0){.toast-wrapper{left:var(--start);right:var(--end)}:host-context([dir=rtl]) .toast-wrapper{left:unset;right:unset;left:var(--end);right:var(--start)}[dir=rtl] .toast-wrapper{left:unset;right:unset;left:var(--end);right:var(--start)}@supports selector(:dir(rtl)){.toast-wrapper:dir(rtl){left:unset;right:unset;left:var(--end);right:var(--start)}}}.toast-wrapper.toast-top{transform:translate3d(0, -100%, 0);top:0}.toast-wrapper.toast-bottom{transform:translate3d(0, 100%, 0);bottom:0}.toast-container{display:flex;align-items:center;pointer-events:auto;height:inherit;min-height:inherit;max-height:inherit;contain:content}.toast-layout-stacked .toast-container{flex-wrap:wrap}.toast-layout-baseline .toast-content{display:flex;flex:1;flex-direction:column;justify-content:center}.toast-icon{-webkit-margin-start:16px;margin-inline-start:16px}.toast-content{min-width:0}.toast-message{flex:1;white-space:var(--white-space)}.toast-button-group{display:flex}.toast-layout-stacked .toast-button-group{justify-content:end;width:100%}.toast-button{border:0;outline:none;color:var(--button-color);z-index:0}.toast-icon,.toast-button-icon{font-size:1.4em}.toast-button-inner{display:flex;align-items:center}@media (any-hover: hover){.toast-button:hover{cursor:pointer}}:host{--background:var(--ion-color-step-800, #333333);--border-radius:4px;--box-shadow:0 3px 5px -1px rgba(0, 0, 0, 0.2), 0 6px 10px 0 rgba(0, 0, 0, 0.14), 0 1px 18px 0 rgba(0, 0, 0, 0.12);--button-color:var(--ion-color-primary, #3880ff);--color:var(--ion-color-step-50, #f2f2f2);--max-width:700px;--start:8px;--end:8px;font-size:0.875rem}.toast-wrapper{-webkit-margin-start:auto;margin-inline-start:auto;-webkit-margin-end:auto;margin-inline-end:auto;margin-top:auto;margin-bottom:auto;display:block;position:absolute;opacity:0.01;z-index:10}.toast-content{-webkit-padding-start:16px;padding-inline-start:16px;-webkit-padding-end:16px;padding-inline-end:16px;padding-top:14px;padding-bottom:14px}.toast-header{margin-bottom:2px;font-weight:500;line-height:1.25rem}.toast-message{line-height:1.25rem}.toast-layout-baseline .toast-button-group-start{-webkit-margin-start:8px;margin-inline-start:8px}.toast-layout-stacked .toast-button-group-start{-webkit-margin-end:8px;margin-inline-end:8px;margin-top:8px}.toast-layout-baseline .toast-button-group-end{-webkit-margin-end:8px;margin-inline-end:8px}.toast-layout-stacked .toast-button-group-end{-webkit-margin-end:8px;margin-inline-end:8px;margin-bottom:8px}.toast-button{-webkit-padding-start:15px;padding-inline-start:15px;-webkit-padding-end:15px;padding-inline-end:15px;padding-top:10px;padding-bottom:10px;position:relative;background-color:transparent;font-family:var(--ion-font-family);font-size:0.875rem;font-weight:500;letter-spacing:0.84px;text-transform:uppercase;overflow:hidden}.toast-button-cancel{color:var(--ion-color-step-100, #e6e6e6)}.toast-button-icon-only{border-radius:50%;-webkit-padding-start:9px;padding-inline-start:9px;-webkit-padding-end:9px;padding-inline-end:9px;padding-top:9px;padding-bottom:9px;width:36px;height:36px}@media (any-hover: hover){.toast-button:hover{background-color:rgba(var(--ion-color-primary-rgb, 56, 128, 255), 0.08)}.toast-button-cancel:hover{background-color:rgba(var(--ion-background-color-rgb, 255, 255, 255), 0.08)}}";
987
- const IonToastMdStyle0 = toastMdCss;
988
-
989
- const Toast = class {
990
- constructor(hostRef) {
991
- registerInstance(this, hostRef);
992
- this.didPresent = createEvent(this, "ionToastDidPresent", 7);
993
- this.willPresent = createEvent(this, "ionToastWillPresent", 7);
994
- this.willDismiss = createEvent(this, "ionToastWillDismiss", 7);
995
- this.didDismiss = createEvent(this, "ionToastDidDismiss", 7);
996
- this.didPresentShorthand = createEvent(this, "didPresent", 7);
997
- this.willPresentShorthand = createEvent(this, "willPresent", 7);
998
- this.willDismissShorthand = createEvent(this, "willDismiss", 7);
999
- this.didDismissShorthand = createEvent(this, "didDismiss", 7);
1000
- this.delegateController = createDelegateController(this);
1001
- this.lockController = createLockController();
1002
- this.triggerController = createTriggerController();
1003
- this.customHTMLEnabled = config$1.get('innerHTMLTemplatesEnabled', ENABLE_HTML_CONTENT_DEFAULT);
1004
- this.presented = false;
1005
- this.dispatchCancelHandler = (ev) => {
1006
- const role = ev.detail.role;
1007
- if (isCancel(role)) {
1008
- const cancelButton = this.getButtons().find((b) => b.role === 'cancel');
1009
- this.callButtonHandler(cancelButton);
1010
- }
1011
- };
1012
- /**
1013
- * Create a new swipe gesture so Toast
1014
- * can be swiped to dismiss.
1015
- */
1016
- this.createSwipeGesture = (toastPosition) => {
1017
- const gesture = (this.gesture = createSwipeToDismissGesture(this.el, toastPosition, () => {
1018
- /**
1019
- * If the gesture completed then
1020
- * we should dismiss the toast.
1021
- */
1022
- this.dismiss(undefined, GESTURE);
1023
- }));
1024
- gesture.enable(true);
1025
- };
1026
- /**
1027
- * Destroy an existing swipe gesture
1028
- * so Toast can no longer be swiped to dismiss.
1029
- */
1030
- this.destroySwipeGesture = () => {
1031
- const { gesture } = this;
1032
- if (gesture === undefined) {
1033
- return;
1034
- }
1035
- gesture.destroy();
1036
- this.gesture = undefined;
1037
- };
1038
- /**
1039
- * Returns `true` if swipeGesture
1040
- * is configured to a value that enables the swipe behavior.
1041
- * Returns `false` otherwise.
1042
- */
1043
- this.prefersSwipeGesture = () => {
1044
- const { swipeGesture } = this;
1045
- return swipeGesture === 'vertical';
1046
- };
1047
- this.revealContentToScreenReader = false;
1048
- this.overlayIndex = undefined;
1049
- this.delegate = undefined;
1050
- this.hasController = false;
1051
- this.color = undefined;
1052
- this.enterAnimation = undefined;
1053
- this.leaveAnimation = undefined;
1054
- this.cssClass = undefined;
1055
- this.duration = config$1.getNumber('toastDuration', 0);
1056
- this.header = undefined;
1057
- this.layout = 'baseline';
1058
- this.message = undefined;
1059
- this.keyboardClose = false;
1060
- this.position = 'bottom';
1061
- this.positionAnchor = undefined;
1062
- this.buttons = undefined;
1063
- this.translucent = false;
1064
- this.animated = true;
1065
- this.icon = undefined;
1066
- this.htmlAttributes = undefined;
1067
- this.swipeGesture = undefined;
1068
- this.isOpen = false;
1069
- this.trigger = undefined;
1070
- }
1071
- swipeGestureChanged() {
1072
- /**
1073
- * If the Toast is presented, then we need to destroy
1074
- * any actives gestures before a new gesture is potentially
1075
- * created below.
1076
- *
1077
- * If the Toast is dismissed, then no gesture should be available
1078
- * since the Toast is not visible. This case should never
1079
- * happen since the "dismiss" method handles destroying
1080
- * any active swipe gestures, but we keep this code
1081
- * around to handle the first case.
1082
- */
1083
- this.destroySwipeGesture();
1084
- /**
1085
- * A new swipe gesture should only be created
1086
- * if the Toast is presented. If the Toast is not
1087
- * yet presented then the "present" method will
1088
- * handle calling the swipe gesture setup function.
1089
- */
1090
- if (this.presented && this.prefersSwipeGesture()) {
1091
- /**
1092
- * If the Toast is presented then
1093
- * lastPresentedPosition is defined.
1094
- */
1095
- this.createSwipeGesture(this.lastPresentedPosition);
1096
- }
1097
- }
1098
- onIsOpenChange(newValue, oldValue) {
1099
- if (newValue === true && oldValue === false) {
1100
- this.present();
1101
- }
1102
- else if (newValue === false && oldValue === true) {
1103
- this.dismiss();
1104
- }
1105
- }
1106
- triggerChanged() {
1107
- const { trigger, el, triggerController } = this;
1108
- if (trigger) {
1109
- triggerController.addClickListener(el, trigger);
1110
- }
1111
- }
1112
- connectedCallback() {
1113
- prepareOverlay(this.el);
1114
- this.triggerChanged();
1115
- }
1116
- disconnectedCallback() {
1117
- this.triggerController.removeClickListener();
1118
- }
1119
- componentWillLoad() {
1120
- setOverlayId(this.el);
1121
- }
1122
- componentDidLoad() {
1123
- /**
1124
- * If toast was rendered with isOpen="true"
1125
- * then we should open toast immediately.
1126
- */
1127
- if (this.isOpen === true) {
1128
- raf(() => this.present());
1129
- }
1130
- /**
1131
- * When binding values in frameworks such as Angular
1132
- * it is possible for the value to be set after the Web Component
1133
- * initializes but before the value watcher is set up in Stencil.
1134
- * As a result, the watcher callback may not be fired.
1135
- * We work around this by manually calling the watcher
1136
- * callback when the component has loaded and the watcher
1137
- * is configured.
1138
- */
1139
- this.triggerChanged();
1140
- }
1141
- /**
1142
- * Present the toast overlay after it has been created.
1143
- */
1144
- async present() {
1145
- const unlock = await this.lockController.lock();
1146
- await this.delegateController.attachViewToDom();
1147
- const { el, position } = this;
1148
- const anchor = this.getAnchorElement();
1149
- const animationPosition = getAnimationPosition(position, anchor, getIonMode$1(this), el);
1150
- /**
1151
- * Cache the calculated position of the toast, so we can re-use it
1152
- * in the dismiss animation.
1153
- */
1154
- this.lastPresentedPosition = animationPosition;
1155
- await present(this, 'toastEnter', iosEnterAnimation, mdEnterAnimation, {
1156
- position,
1157
- top: animationPosition.top,
1158
- bottom: animationPosition.bottom,
1159
- });
1160
- /**
1161
- * Content is revealed to screen readers after
1162
- * the transition to avoid jank since this
1163
- * state updates will cause a re-render.
1164
- */
1165
- this.revealContentToScreenReader = true;
1166
- if (this.duration > 0) {
1167
- this.durationTimeout = setTimeout(() => this.dismiss(undefined, 'timeout'), this.duration);
1168
- }
1169
- /**
1170
- * If the Toast has a swipe gesture then we can
1171
- * create the gesture so users can swipe the
1172
- * presented Toast.
1173
- */
1174
- if (this.prefersSwipeGesture()) {
1175
- this.createSwipeGesture(animationPosition);
1176
- }
1177
- unlock();
1178
- }
1179
- /**
1180
- * Dismiss the toast overlay after it has been presented.
1181
- *
1182
- * @param data Any data to emit in the dismiss events.
1183
- * @param role The role of the element that is dismissing the toast.
1184
- * This can be useful in a button handler for determining which button was
1185
- * clicked to dismiss the toast.
1186
- * Some examples include: ``"cancel"`, `"destructive"`, "selected"`, and `"backdrop"`.
1187
- *
1188
- * This is a no-op if the overlay has not been presented yet. If you want
1189
- * to remove an overlay from the DOM that was never presented, use the
1190
- * [remove](https://developer.mozilla.org/en-US/docs/Web/API/Element/remove) method.
1191
- */
1192
- async dismiss(data, role) {
1193
- var _a, _b;
1194
- const unlock = await this.lockController.lock();
1195
- const { durationTimeout, position, lastPresentedPosition } = this;
1196
- if (durationTimeout) {
1197
- clearTimeout(durationTimeout);
1198
- }
1199
- const dismissed = await dismiss(this, data, role, 'toastLeave', iosLeaveAnimation, mdLeaveAnimation,
1200
- /**
1201
- * Fetch the cached position that was calculated back in the present
1202
- * animation. We always want to animate the dismiss from the same
1203
- * position the present stopped at, so the animation looks continuous.
1204
- */
1205
- {
1206
- position,
1207
- top: (_a = lastPresentedPosition === null || lastPresentedPosition === void 0 ? void 0 : lastPresentedPosition.top) !== null && _a !== void 0 ? _a : '',
1208
- bottom: (_b = lastPresentedPosition === null || lastPresentedPosition === void 0 ? void 0 : lastPresentedPosition.bottom) !== null && _b !== void 0 ? _b : '',
1209
- });
1210
- if (dismissed) {
1211
- this.delegateController.removeViewFromDom();
1212
- this.revealContentToScreenReader = false;
1213
- }
1214
- this.lastPresentedPosition = undefined;
1215
- /**
1216
- * If the Toast has a swipe gesture then we can
1217
- * safely destroy it now that it is dismissed.
1218
- */
1219
- this.destroySwipeGesture();
1220
- unlock();
1221
- return dismissed;
1222
- }
1223
- /**
1224
- * Returns a promise that resolves when the toast did dismiss.
1225
- */
1226
- onDidDismiss() {
1227
- return eventMethod(this.el, 'ionToastDidDismiss');
1228
- }
1229
- /**
1230
- * Returns a promise that resolves when the toast will dismiss.
1231
- */
1232
- onWillDismiss() {
1233
- return eventMethod(this.el, 'ionToastWillDismiss');
1234
- }
1235
- getButtons() {
1236
- const buttons = this.buttons
1237
- ? this.buttons.map((b) => {
1238
- return typeof b === 'string' ? { text: b } : b;
1239
- })
1240
- : [];
1241
- return buttons;
1242
- }
1243
- /**
1244
- * Returns the element specified by the positionAnchor prop,
1245
- * or undefined if prop's value is an ID string and the element
1246
- * is not found in the DOM.
1247
- */
1248
- getAnchorElement() {
1249
- const { position, positionAnchor, el } = this;
1250
- /**
1251
- * If positionAnchor is undefined then
1252
- * no anchor should be used when presenting the toast.
1253
- */
1254
- if (positionAnchor === undefined) {
1255
- return;
1256
- }
1257
- if (position === 'middle' && positionAnchor !== undefined) {
1258
- printIonWarning('The positionAnchor property is ignored when using position="middle".', this.el);
1259
- return undefined;
1260
- }
1261
- if (typeof positionAnchor === 'string') {
1262
- /**
1263
- * If the anchor is defined as an ID, find the element.
1264
- * We do this on every present so the toast doesn't need
1265
- * to account for the surrounding DOM changing since the
1266
- * last time it was presented.
1267
- */
1268
- const foundEl = document.getElementById(positionAnchor);
1269
- if (foundEl === null) {
1270
- printIonWarning(`An anchor element with an ID of "${positionAnchor}" was not found in the DOM.`, el);
1271
- return undefined;
1272
- }
1273
- return foundEl;
1274
- }
1275
- if (positionAnchor instanceof HTMLElement) {
1276
- return positionAnchor;
1277
- }
1278
- printIonWarning('Invalid positionAnchor value:', positionAnchor, el);
1279
- return undefined;
1280
- }
1281
- async buttonClick(button) {
1282
- const role = button.role;
1283
- if (isCancel(role)) {
1284
- return this.dismiss(undefined, role);
1285
- }
1286
- const shouldDismiss = await this.callButtonHandler(button);
1287
- if (shouldDismiss) {
1288
- return this.dismiss(undefined, role);
1289
- }
1290
- return Promise.resolve();
1291
- }
1292
- async callButtonHandler(button) {
1293
- if (button === null || button === void 0 ? void 0 : button.handler) {
1294
- // a handler has been provided, execute it
1295
- // pass the handler the values from the inputs
1296
- try {
1297
- const rtn = await safeCall(button.handler);
1298
- if (rtn === false) {
1299
- // if the return value of the handler is false then do not dismiss
1300
- return false;
1301
- }
1302
- }
1303
- catch (e) {
1304
- console.error(e);
1305
- }
1306
- }
1307
- return true;
1308
- }
1309
- renderButtons(buttons, side) {
1310
- if (buttons.length === 0) {
1311
- return;
1312
- }
1313
- const mode = getIonMode$1(this);
1314
- const buttonGroupsClasses = {
1315
- 'toast-button-group': true,
1316
- [`toast-button-group-${side}`]: true,
1317
- };
1318
- return (h("div", { class: buttonGroupsClasses }, buttons.map((b) => (h("button", Object.assign({}, b.htmlAttributes, { type: "button", class: buttonClass(b), tabIndex: 0, onClick: () => this.buttonClick(b), part: buttonPart(b) }), h("div", { class: "toast-button-inner" }, b.icon && (h("ion-icon", { "aria-hidden": "true", icon: b.icon, slot: b.text === undefined ? 'icon-only' : undefined, class: "toast-button-icon" })), b.text), mode === 'md' && (h("ion-ripple-effect", { type: b.icon !== undefined && b.text === undefined ? 'unbounded' : 'bounded' })))))));
1319
- }
1320
- /**
1321
- * Render the `message` property.
1322
- * @param key - A key to give the element a stable identity. This is used to improve compatibility with screen readers.
1323
- * @param ariaHidden - If "true" then content will be hidden from screen readers.
1324
- */
1325
- renderToastMessage(key, ariaHidden = null) {
1326
- const { customHTMLEnabled, message } = this;
1327
- if (customHTMLEnabled) {
1328
- return (h("div", { key: key, "aria-hidden": ariaHidden, class: "toast-message", part: "message", innerHTML: sanitizeDOMString(message) }));
1329
- }
1330
- return (h("div", { key: key, "aria-hidden": ariaHidden, class: "toast-message", part: "message" }, message));
1331
- }
1332
- /**
1333
- * Render the `header` property.
1334
- * @param key - A key to give the element a stable identity. This is used to improve compatibility with screen readers.
1335
- * @param ariaHidden - If "true" then content will be hidden from screen readers.
1336
- */
1337
- renderHeader(key, ariaHidden = null) {
1338
- return (h("div", { key: key, class: "toast-header", "aria-hidden": ariaHidden, part: "header" }, this.header));
1339
- }
1340
- render() {
1341
- const { layout, el, revealContentToScreenReader, header, message } = this;
1342
- const allButtons = this.getButtons();
1343
- const startButtons = allButtons.filter((b) => b.side === 'start');
1344
- const endButtons = allButtons.filter((b) => b.side !== 'start');
1345
- const mode = getIonMode$1(this);
1346
- const wrapperClass = {
1347
- 'toast-wrapper': true,
1348
- [`toast-${this.position}`]: true,
1349
- [`toast-layout-${layout}`]: true,
1350
- };
1351
- /**
1352
- * Stacked buttons are only meant to be
1353
- * used with one type of button.
1354
- */
1355
- if (layout === 'stacked' && startButtons.length > 0 && endButtons.length > 0) {
1356
- printIonWarning('This toast is using start and end buttons with the stacked toast layout. We recommend following the best practice of using either start or end buttons with the stacked toast layout.', el);
1357
- }
1358
- return (h(Host, Object.assign({ key: '23803334fb668f6ce7044d3a321cb84bc753bd16', tabindex: "-1" }, this.htmlAttributes, { style: {
1359
- zIndex: `${60000 + this.overlayIndex}`,
1360
- }, class: createColorClasses$1(this.color, Object.assign(Object.assign({ [mode]: true }, getClassMap(this.cssClass)), { 'overlay-hidden': true, 'toast-translucent': this.translucent })), onIonToastWillDismiss: this.dispatchCancelHandler }), h("div", { key: '7cd7138ba079fccf97f318b91e9986491ab4214d', class: wrapperClass }, h("div", { key: '93b78fa64e24435adeb77a04c1d1d53d2f093864', class: "toast-container", part: "container" }, this.renderButtons(startButtons, 'start'), this.icon !== undefined && (h("ion-icon", { key: '9a3c71b164ebcfba2540acb7568beffa76b62f47', class: "toast-icon", part: "icon", icon: this.icon, lazy: false, "aria-hidden": "true" })), h("div", { key: 'feb9268102d844f1314205f7440de7066cf0620e', class: "toast-content", role: "status", "aria-atomic": "true", "aria-live": "polite" }, !revealContentToScreenReader && header !== undefined && this.renderHeader('oldHeader', 'true'), !revealContentToScreenReader && message !== undefined && this.renderToastMessage('oldMessage', 'true'), revealContentToScreenReader && header !== undefined && this.renderHeader('header'), revealContentToScreenReader && message !== undefined && this.renderToastMessage('header')), this.renderButtons(endButtons, 'end')))));
1361
- }
1362
- get el() { return getElement(this); }
1363
- static get watchers() { return {
1364
- "swipeGesture": ["swipeGestureChanged"],
1365
- "isOpen": ["onIsOpenChange"],
1366
- "trigger": ["triggerChanged"]
1367
- }; }
1368
- };
1369
- const buttonClass = (button) => {
1370
- return Object.assign({ 'toast-button': true, 'toast-button-icon-only': button.icon !== undefined && button.text === undefined, [`toast-button-${button.role}`]: button.role !== undefined, 'ion-focusable': true, 'ion-activatable': true }, getClassMap(button.cssClass));
1371
- };
1372
- const buttonPart = (button) => {
1373
- return isCancel(button.role) ? 'button cancel' : 'button';
1374
- };
1375
- Toast.style = {
1376
- ios: IonToastIosStyle0,
1377
- md: IonToastMdStyle0
1378
- };
1379
-
1380
- const posAddNewThingCss = ":host{font-family:var(--font-sans);display:block}button#new{cursor:pointer;display:flex;align-items:center;justify-content:center;border:none;width:var(--size-10);height:var(--size-10);background-color:var(--pos-primary-color);color:var(--pos-primary-text-color);font-size:var(--scale-6);border-radius:var(--radius-xs)}button#new:hover,button#new:focus{outline:none;filter:brightness(110%);box-shadow:var(--shadow-sm)}pos-new-thing-form{margin:var(--scale-3)}";
1381
- const PosAddNewThingStyle0 = posAddNewThingCss;
1382
-
1383
- const PosAddNewThing = class {
1384
- constructor(hostRef) {
1385
- registerInstance(this, hostRef);
1386
- }
1387
- openDialog() {
1388
- this.dialog.showModal();
1389
- }
1390
- render() {
1391
- return (h(Host, { key: '5ed3ba3982467778ed2b9b02090c230acb6b1762' }, h("button", { key: '96ff5dbd0ba4ca4d8c1d25045efa06fea062e9cf', id: "new", title: "Add a new thing", onClick: () => this.openDialog() }, h("ion-icon", { key: '201a19c8ecb39e0e913d3fb8cf1ebee06bc41df5', name: "add-circle-outline" })), h("pos-dialog", { key: '421da81e6faf52119fe600cc388663299eab67ec', ref: el => (this.dialog = el) }, h("span", { key: '454e6e05dc478e9c1b378cb3308f006fab4d8738', slot: "title" }, "Add a new thing"), h("pos-new-thing-form", { key: 'a469379848776a4c7e9f8e3f94da76ba048d7fab', slot: "content", referenceUri: this.referenceUri }))));
1392
- }
1393
- };
1394
- PosAddNewThing.style = PosAddNewThingStyle0;
1395
-
1396
- const storedSettings = localStorage.getItem('settings');
1397
- const initialSettings = storedSettings
1398
- ? JSON.parse(storedSettings)
1399
- : {
1400
- offlineCache: false,
1401
- };
1402
- const localSettings = createStore$1(initialSettings);
1403
- persistChanges();
1404
- syncChangesAcrossTabs();
1405
- function persistChanges() {
1406
- localSettings.on('set', () => {
1407
- const snapshot = JSON.stringify(localSettings.state);
1408
- localStorage.setItem('settings', snapshot);
1409
- });
1410
- }
1411
- function syncChangesAcrossTabs() {
1412
- window.addEventListener('storage', event => {
1413
- if (event.key === 'settings' && event.newValue) {
1414
- const newSettings = JSON.parse(event.newValue);
1415
- localSettings.state.offlineCache = newSettings.offlineCache;
1416
- }
1417
- });
1418
- }
1419
-
1420
- const instanceOfAny = (object, constructors) => constructors.some((c) => object instanceof c);
1421
-
1422
- let idbProxyableTypes;
1423
- let cursorAdvanceMethods;
1424
- // This is a function to prevent it throwing up in node environments.
1425
- function getIdbProxyableTypes() {
1426
- return (idbProxyableTypes ||
1427
- (idbProxyableTypes = [
1428
- IDBDatabase,
1429
- IDBObjectStore,
1430
- IDBIndex,
1431
- IDBCursor,
1432
- IDBTransaction,
1433
- ]));
1434
- }
1435
- // This is a function to prevent it throwing up in node environments.
1436
- function getCursorAdvanceMethods() {
1437
- return (cursorAdvanceMethods ||
1438
- (cursorAdvanceMethods = [
1439
- IDBCursor.prototype.advance,
1440
- IDBCursor.prototype.continue,
1441
- IDBCursor.prototype.continuePrimaryKey,
1442
- ]));
1443
- }
1444
- const transactionDoneMap = new WeakMap();
1445
- const transformCache = new WeakMap();
1446
- const reverseTransformCache = new WeakMap();
1447
- function promisifyRequest(request) {
1448
- const promise = new Promise((resolve, reject) => {
1449
- const unlisten = () => {
1450
- request.removeEventListener('success', success);
1451
- request.removeEventListener('error', error);
1452
- };
1453
- const success = () => {
1454
- resolve(wrap(request.result));
1455
- unlisten();
1456
- };
1457
- const error = () => {
1458
- reject(request.error);
1459
- unlisten();
1460
- };
1461
- request.addEventListener('success', success);
1462
- request.addEventListener('error', error);
1463
- });
1464
- // This mapping exists in reverseTransformCache but doesn't exist in transformCache. This
1465
- // is because we create many promises from a single IDBRequest.
1466
- reverseTransformCache.set(promise, request);
1467
- return promise;
1468
- }
1469
- function cacheDonePromiseForTransaction(tx) {
1470
- // Early bail if we've already created a done promise for this transaction.
1471
- if (transactionDoneMap.has(tx))
1472
- return;
1473
- const done = new Promise((resolve, reject) => {
1474
- const unlisten = () => {
1475
- tx.removeEventListener('complete', complete);
1476
- tx.removeEventListener('error', error);
1477
- tx.removeEventListener('abort', error);
1478
- };
1479
- const complete = () => {
1480
- resolve();
1481
- unlisten();
1482
- };
1483
- const error = () => {
1484
- reject(tx.error || new DOMException('AbortError', 'AbortError'));
1485
- unlisten();
1486
- };
1487
- tx.addEventListener('complete', complete);
1488
- tx.addEventListener('error', error);
1489
- tx.addEventListener('abort', error);
1490
- });
1491
- // Cache it for later retrieval.
1492
- transactionDoneMap.set(tx, done);
1493
- }
1494
- let idbProxyTraps = {
1495
- get(target, prop, receiver) {
1496
- if (target instanceof IDBTransaction) {
1497
- // Special handling for transaction.done.
1498
- if (prop === 'done')
1499
- return transactionDoneMap.get(target);
1500
- // Make tx.store return the only store in the transaction, or undefined if there are many.
1501
- if (prop === 'store') {
1502
- return receiver.objectStoreNames[1]
1503
- ? undefined
1504
- : receiver.objectStore(receiver.objectStoreNames[0]);
1505
- }
1506
- }
1507
- // Else transform whatever we get back.
1508
- return wrap(target[prop]);
1509
- },
1510
- set(target, prop, value) {
1511
- target[prop] = value;
1512
- return true;
1513
- },
1514
- has(target, prop) {
1515
- if (target instanceof IDBTransaction &&
1516
- (prop === 'done' || prop === 'store')) {
1517
- return true;
1518
- }
1519
- return prop in target;
1520
- },
1521
- };
1522
- function replaceTraps(callback) {
1523
- idbProxyTraps = callback(idbProxyTraps);
1524
- }
1525
- function wrapFunction(func) {
1526
- // Due to expected object equality (which is enforced by the caching in `wrap`), we
1527
- // only create one new func per func.
1528
- // Cursor methods are special, as the behaviour is a little more different to standard IDB. In
1529
- // IDB, you advance the cursor and wait for a new 'success' on the IDBRequest that gave you the
1530
- // cursor. It's kinda like a promise that can resolve with many values. That doesn't make sense
1531
- // with real promises, so each advance methods returns a new promise for the cursor object, or
1532
- // undefined if the end of the cursor has been reached.
1533
- if (getCursorAdvanceMethods().includes(func)) {
1534
- return function (...args) {
1535
- // Calling the original function with the proxy as 'this' causes ILLEGAL INVOCATION, so we use
1536
- // the original object.
1537
- func.apply(unwrap(this), args);
1538
- return wrap(this.request);
1539
- };
1540
- }
1541
- return function (...args) {
1542
- // Calling the original function with the proxy as 'this' causes ILLEGAL INVOCATION, so we use
1543
- // the original object.
1544
- return wrap(func.apply(unwrap(this), args));
1545
- };
1546
- }
1547
- function transformCachableValue(value) {
1548
- if (typeof value === 'function')
1549
- return wrapFunction(value);
1550
- // This doesn't return, it just creates a 'done' promise for the transaction,
1551
- // which is later returned for transaction.done (see idbObjectHandler).
1552
- if (value instanceof IDBTransaction)
1553
- cacheDonePromiseForTransaction(value);
1554
- if (instanceOfAny(value, getIdbProxyableTypes()))
1555
- return new Proxy(value, idbProxyTraps);
1556
- // Return the same value back if we're not going to transform it.
1557
- return value;
1558
- }
1559
- function wrap(value) {
1560
- // We sometimes generate multiple promises from a single IDBRequest (eg when cursoring), because
1561
- // IDB is weird and a single IDBRequest can yield many responses, so these can't be cached.
1562
- if (value instanceof IDBRequest)
1563
- return promisifyRequest(value);
1564
- // If we've already transformed this value before, reuse the transformed value.
1565
- // This is faster, but it also provides object equality.
1566
- if (transformCache.has(value))
1567
- return transformCache.get(value);
1568
- const newValue = transformCachableValue(value);
1569
- // Not all types are transformed.
1570
- // These may be primitive types, so they can't be WeakMap keys.
1571
- if (newValue !== value) {
1572
- transformCache.set(value, newValue);
1573
- reverseTransformCache.set(newValue, value);
1574
- }
1575
- return newValue;
1576
- }
1577
- const unwrap = (value) => reverseTransformCache.get(value);
1578
-
1579
- /**
1580
- * Open a database.
1581
- *
1582
- * @param name Name of the database.
1583
- * @param version Schema version.
1584
- * @param callbacks Additional callbacks.
1585
- */
1586
- function openDB(name, version, { blocked, upgrade, blocking, terminated } = {}) {
1587
- const request = indexedDB.open(name, version);
1588
- const openPromise = wrap(request);
1589
- if (upgrade) {
1590
- request.addEventListener('upgradeneeded', (event) => {
1591
- upgrade(wrap(request.result), event.oldVersion, event.newVersion, wrap(request.transaction), event);
1592
- });
1593
- }
1594
- if (blocked) {
1595
- request.addEventListener('blocked', (event) => blocked(
1596
- // Casting due to https://github.com/microsoft/TypeScript-DOM-lib-generator/pull/1405
1597
- event.oldVersion, event.newVersion, event));
1598
- }
1599
- openPromise
1600
- .then((db) => {
1601
- if (terminated)
1602
- db.addEventListener('close', () => terminated());
1603
- if (blocking) {
1604
- db.addEventListener('versionchange', (event) => blocking(event.oldVersion, event.newVersion, event));
1605
- }
1606
- })
1607
- .catch(() => { });
1608
- return openPromise;
1609
- }
1610
-
1611
- const readMethods = ['get', 'getKey', 'getAll', 'getAllKeys', 'count'];
1612
- const writeMethods = ['put', 'add', 'delete', 'clear'];
1613
- const cachedMethods = new Map();
1614
- function getMethod(target, prop) {
1615
- if (!(target instanceof IDBDatabase &&
1616
- !(prop in target) &&
1617
- typeof prop === 'string')) {
1618
- return;
1619
- }
1620
- if (cachedMethods.get(prop))
1621
- return cachedMethods.get(prop);
1622
- const targetFuncName = prop.replace(/FromIndex$/, '');
1623
- const useIndex = prop !== targetFuncName;
1624
- const isWrite = writeMethods.includes(targetFuncName);
1625
- if (
1626
- // Bail if the target doesn't exist on the target. Eg, getAll isn't in Edge.
1627
- !(targetFuncName in (useIndex ? IDBIndex : IDBObjectStore).prototype) ||
1628
- !(isWrite || readMethods.includes(targetFuncName))) {
1629
- return;
1630
- }
1631
- const method = async function (storeName, ...args) {
1632
- // isWrite ? 'readwrite' : undefined gzipps better, but fails in Edge :(
1633
- const tx = this.transaction(storeName, isWrite ? 'readwrite' : 'readonly');
1634
- let target = tx.store;
1635
- if (useIndex)
1636
- target = target.index(args.shift());
1637
- // Must reject if op rejects.
1638
- // If it's a write operation, must reject if tx.done rejects.
1639
- // Must reject with op rejection first.
1640
- // Must resolve with op value.
1641
- // Must handle both promises (no unhandled rejections)
1642
- return (await Promise.all([
1643
- target[targetFuncName](...args),
1644
- isWrite && tx.done,
1645
- ]))[0];
1646
- };
1647
- cachedMethods.set(prop, method);
1648
- return method;
1649
- }
1650
- replaceTraps((oldTraps) => ({
1651
- ...oldTraps,
1652
- get: (target, prop, receiver) => getMethod(target, prop) || oldTraps.get(target, prop, receiver),
1653
- has: (target, prop) => !!getMethod(target, prop) || oldTraps.has(target, prop),
1654
- }));
1655
-
1656
- const advanceMethodProps = ['continue', 'continuePrimaryKey', 'advance'];
1657
- const methodMap = {};
1658
- const advanceResults = new WeakMap();
1659
- const ittrProxiedCursorToOriginalProxy = new WeakMap();
1660
- const cursorIteratorTraps = {
1661
- get(target, prop) {
1662
- if (!advanceMethodProps.includes(prop))
1663
- return target[prop];
1664
- let cachedFunc = methodMap[prop];
1665
- if (!cachedFunc) {
1666
- cachedFunc = methodMap[prop] = function (...args) {
1667
- advanceResults.set(this, ittrProxiedCursorToOriginalProxy.get(this)[prop](...args));
1668
- };
1669
- }
1670
- return cachedFunc;
1671
- },
1672
- };
1673
- async function* iterate(...args) {
1674
- // tslint:disable-next-line:no-this-assignment
1675
- let cursor = this;
1676
- if (!(cursor instanceof IDBCursor)) {
1677
- cursor = await cursor.openCursor(...args);
1678
- }
1679
- if (!cursor)
1680
- return;
1681
- cursor = cursor;
1682
- const proxiedCursor = new Proxy(cursor, cursorIteratorTraps);
1683
- ittrProxiedCursorToOriginalProxy.set(proxiedCursor, cursor);
1684
- // Map this double-proxy back to the original, so other cursor methods work.
1685
- reverseTransformCache.set(proxiedCursor, unwrap(cursor));
1686
- while (cursor) {
1687
- yield proxiedCursor;
1688
- // If one of the advancing methods was not called, call continue().
1689
- cursor = await (advanceResults.get(proxiedCursor) || cursor.continue());
1690
- advanceResults.delete(proxiedCursor);
1691
- }
1692
- }
1693
- function isIteratorProp(target, prop) {
1694
- return ((prop === Symbol.asyncIterator &&
1695
- instanceOfAny(target, [IDBIndex, IDBObjectStore, IDBCursor])) ||
1696
- (prop === 'iterate' && instanceOfAny(target, [IDBIndex, IDBObjectStore])));
1697
- }
1698
- replaceTraps((oldTraps) => ({
1699
- ...oldTraps,
1700
- get(target, prop, receiver) {
1701
- if (isIteratorProp(target, prop))
1702
- return iterate;
1703
- return oldTraps.get(target, prop, receiver);
1704
- },
1705
- has(target, prop) {
1706
- return isIteratorProp(target, prop) || oldTraps.has(target, prop);
1707
- },
1708
- }));
1709
-
1710
- /**
1711
- * An offline cache backed by the browsers IndexedDB storage
1712
- */
1713
- class IndexedDbOfflineCache {
1714
- constructor() {
1715
- this.dbPromise = openDB('OfflineCacheDB', 1, {
1716
- upgrade(db) {
1717
- if (!db.objectStoreNames.contains('documents')) {
1718
- const store = db.createObjectStore('documents', { keyPath: 'url' });
1719
- store.createIndex('url-revision', ['url', 'revision']);
1720
- }
1721
- },
1722
- });
1723
- }
1724
- async clear() {
1725
- const db = await this.dbPromise;
1726
- return db.clear('documents');
1727
- }
1728
- async get(url) {
1729
- const db = await this.dbPromise;
1730
- return await db.get('documents', url);
1731
- }
1732
- async put(document) {
1733
- const db = await this.dbPromise;
1734
- const existing = await db.getFromIndex('documents', 'url-revision', [document.url, document.revision]);
1735
- if (existing) {
1736
- return; // No need to update if the revision is the same
1737
- }
1738
- await db.put('documents', document);
1739
- }
1740
- }
1741
-
1742
- class NavigatorOnlineStatus {
1743
- isOnline() {
1744
- return navigator.onLine;
1745
- }
1746
- }
1747
-
1748
- const createPodOS = (settings) => {
1749
- return new PodOS({
1750
- offlineCache: settings.offlineCache ? new IndexedDbOfflineCache() : new NoOfflineCache(),
1751
- onlineStatus: new NavigatorOnlineStatus(),
1752
- });
1753
- };
1754
-
1755
- function isFunction(value) {
1756
- return typeof value === 'function';
1757
- }
1758
-
1759
- function createErrorClass(createImpl) {
1760
- const _super = (instance) => {
1761
- Error.call(instance);
1762
- instance.stack = new Error().stack;
1763
- };
1764
- const ctorFunc = createImpl(_super);
1765
- ctorFunc.prototype = Object.create(Error.prototype);
1766
- ctorFunc.prototype.constructor = ctorFunc;
1767
- return ctorFunc;
1768
- }
1769
-
1770
- const UnsubscriptionError = createErrorClass((_super) => function UnsubscriptionErrorImpl(errors) {
1771
- _super(this);
1772
- this.message = errors
1773
- ? `${errors.length} errors occurred during unsubscription:
1774
- ${errors.map((err, i) => `${i + 1}) ${err.toString()}`).join('\n ')}`
1775
- : '';
1776
- this.name = 'UnsubscriptionError';
1777
- this.errors = errors;
1778
- });
1779
-
1780
- function arrRemove(arr, item) {
1781
- if (arr) {
1782
- const index = arr.indexOf(item);
1783
- 0 <= index && arr.splice(index, 1);
1784
- }
1785
- }
1786
-
1787
- class Subscription {
1788
- constructor(initialTeardown) {
1789
- this.initialTeardown = initialTeardown;
1790
- this.closed = false;
1791
- this._parentage = null;
1792
- this._finalizers = null;
1793
- }
1794
- unsubscribe() {
1795
- let errors;
1796
- if (!this.closed) {
1797
- this.closed = true;
1798
- const { _parentage } = this;
1799
- if (_parentage) {
1800
- this._parentage = null;
1801
- if (Array.isArray(_parentage)) {
1802
- for (const parent of _parentage) {
1803
- parent.remove(this);
1804
- }
1805
- }
1806
- else {
1807
- _parentage.remove(this);
1808
- }
1809
- }
1810
- const { initialTeardown: initialFinalizer } = this;
1811
- if (isFunction(initialFinalizer)) {
1812
- try {
1813
- initialFinalizer();
1814
- }
1815
- catch (e) {
1816
- errors = e instanceof UnsubscriptionError ? e.errors : [e];
1817
- }
1818
- }
1819
- const { _finalizers } = this;
1820
- if (_finalizers) {
1821
- this._finalizers = null;
1822
- for (const finalizer of _finalizers) {
1823
- try {
1824
- execFinalizer(finalizer);
1825
- }
1826
- catch (err) {
1827
- errors = errors !== null && errors !== void 0 ? errors : [];
1828
- if (err instanceof UnsubscriptionError) {
1829
- errors = [...errors, ...err.errors];
1830
- }
1831
- else {
1832
- errors.push(err);
1833
- }
1834
- }
1835
- }
1836
- }
1837
- if (errors) {
1838
- throw new UnsubscriptionError(errors);
1839
- }
1840
- }
1841
- }
1842
- add(teardown) {
1843
- var _a;
1844
- if (teardown && teardown !== this) {
1845
- if (this.closed) {
1846
- execFinalizer(teardown);
1847
- }
1848
- else {
1849
- if (teardown instanceof Subscription) {
1850
- if (teardown.closed || teardown._hasParent(this)) {
1851
- return;
1852
- }
1853
- teardown._addParent(this);
1854
- }
1855
- (this._finalizers = (_a = this._finalizers) !== null && _a !== void 0 ? _a : []).push(teardown);
1856
- }
1857
- }
1858
- }
1859
- _hasParent(parent) {
1860
- const { _parentage } = this;
1861
- return _parentage === parent || (Array.isArray(_parentage) && _parentage.includes(parent));
1862
- }
1863
- _addParent(parent) {
1864
- const { _parentage } = this;
1865
- this._parentage = Array.isArray(_parentage) ? (_parentage.push(parent), _parentage) : _parentage ? [_parentage, parent] : parent;
1866
- }
1867
- _removeParent(parent) {
1868
- const { _parentage } = this;
1869
- if (_parentage === parent) {
1870
- this._parentage = null;
1871
- }
1872
- else if (Array.isArray(_parentage)) {
1873
- arrRemove(_parentage, parent);
1874
- }
1875
- }
1876
- remove(teardown) {
1877
- const { _finalizers } = this;
1878
- _finalizers && arrRemove(_finalizers, teardown);
1879
- if (teardown instanceof Subscription) {
1880
- teardown._removeParent(this);
1881
- }
1882
- }
1883
- }
1884
- Subscription.EMPTY = (() => {
1885
- const empty = new Subscription();
1886
- empty.closed = true;
1887
- return empty;
1888
- })();
1889
- const EMPTY_SUBSCRIPTION = Subscription.EMPTY;
1890
- function isSubscription(value) {
1891
- return (value instanceof Subscription ||
1892
- (value && 'closed' in value && isFunction(value.remove) && isFunction(value.add) && isFunction(value.unsubscribe)));
1893
- }
1894
- function execFinalizer(finalizer) {
1895
- if (isFunction(finalizer)) {
1896
- finalizer();
1897
- }
1898
- else {
1899
- finalizer.unsubscribe();
1900
- }
1901
- }
1902
-
1903
- const config = {
1904
- onUnhandledError: null,
1905
- onStoppedNotification: null,
1906
- Promise: undefined,
1907
- useDeprecatedSynchronousErrorHandling: false,
1908
- useDeprecatedNextContext: false,
1909
- };
1910
-
1911
- const timeoutProvider = {
1912
- setTimeout(handler, timeout, ...args) {
1913
- const { delegate } = timeoutProvider;
1914
- if (delegate === null || delegate === void 0 ? void 0 : delegate.setTimeout) {
1915
- return delegate.setTimeout(handler, timeout, ...args);
1916
- }
1917
- return setTimeout(handler, timeout, ...args);
1918
- },
1919
- clearTimeout(handle) {
1920
- const { delegate } = timeoutProvider;
1921
- return ((delegate === null || delegate === void 0 ? void 0 : delegate.clearTimeout) || clearTimeout)(handle);
1922
- },
1923
- delegate: undefined,
1924
- };
1925
-
1926
- function reportUnhandledError(err) {
1927
- timeoutProvider.setTimeout(() => {
1928
- const { onUnhandledError } = config;
1929
- if (onUnhandledError) {
1930
- onUnhandledError(err);
1931
- }
1932
- else {
1933
- throw err;
1934
- }
1935
- });
1936
- }
1937
-
1938
- function noop() { }
1939
-
1940
- const COMPLETE_NOTIFICATION = (() => createNotification('C', undefined, undefined))();
1941
- function errorNotification(error) {
1942
- return createNotification('E', undefined, error);
1943
- }
1944
- function nextNotification(value) {
1945
- return createNotification('N', value, undefined);
1946
- }
1947
- function createNotification(kind, value, error) {
1948
- return {
1949
- kind,
1950
- value,
1951
- error,
1952
- };
1953
- }
1954
-
1955
- let context = null;
1956
- function errorContext(cb) {
1957
- if (config.useDeprecatedSynchronousErrorHandling) {
1958
- const isRoot = !context;
1959
- if (isRoot) {
1960
- context = { errorThrown: false, error: null };
1961
- }
1962
- cb();
1963
- if (isRoot) {
1964
- const { errorThrown, error } = context;
1965
- context = null;
1966
- if (errorThrown) {
1967
- throw error;
1968
- }
1969
- }
1970
- }
1971
- else {
1972
- cb();
1973
- }
1974
- }
1975
-
1976
- class Subscriber extends Subscription {
1977
- constructor(destination) {
1978
- super();
1979
- this.isStopped = false;
1980
- if (destination) {
1981
- this.destination = destination;
1982
- if (isSubscription(destination)) {
1983
- destination.add(this);
1984
- }
1985
- }
1986
- else {
1987
- this.destination = EMPTY_OBSERVER;
1988
- }
1989
- }
1990
- static create(next, error, complete) {
1991
- return new SafeSubscriber(next, error, complete);
1992
- }
1993
- next(value) {
1994
- if (this.isStopped) {
1995
- handleStoppedNotification(nextNotification(value), this);
1996
- }
1997
- else {
1998
- this._next(value);
1999
- }
2000
- }
2001
- error(err) {
2002
- if (this.isStopped) {
2003
- handleStoppedNotification(errorNotification(err), this);
2004
- }
2005
- else {
2006
- this.isStopped = true;
2007
- this._error(err);
2008
- }
2009
- }
2010
- complete() {
2011
- if (this.isStopped) {
2012
- handleStoppedNotification(COMPLETE_NOTIFICATION, this);
2013
- }
2014
- else {
2015
- this.isStopped = true;
2016
- this._complete();
2017
- }
2018
- }
2019
- unsubscribe() {
2020
- if (!this.closed) {
2021
- this.isStopped = true;
2022
- super.unsubscribe();
2023
- this.destination = null;
2024
- }
2025
- }
2026
- _next(value) {
2027
- this.destination.next(value);
2028
- }
2029
- _error(err) {
2030
- try {
2031
- this.destination.error(err);
2032
- }
2033
- finally {
2034
- this.unsubscribe();
2035
- }
2036
- }
2037
- _complete() {
2038
- try {
2039
- this.destination.complete();
2040
- }
2041
- finally {
2042
- this.unsubscribe();
2043
- }
2044
- }
2045
- }
2046
- const _bind = Function.prototype.bind;
2047
- function bind(fn, thisArg) {
2048
- return _bind.call(fn, thisArg);
2049
- }
2050
- class ConsumerObserver {
2051
- constructor(partialObserver) {
2052
- this.partialObserver = partialObserver;
2053
- }
2054
- next(value) {
2055
- const { partialObserver } = this;
2056
- if (partialObserver.next) {
2057
- try {
2058
- partialObserver.next(value);
2059
- }
2060
- catch (error) {
2061
- handleUnhandledError(error);
2062
- }
2063
- }
2064
- }
2065
- error(err) {
2066
- const { partialObserver } = this;
2067
- if (partialObserver.error) {
2068
- try {
2069
- partialObserver.error(err);
2070
- }
2071
- catch (error) {
2072
- handleUnhandledError(error);
2073
- }
2074
- }
2075
- else {
2076
- handleUnhandledError(err);
2077
- }
2078
- }
2079
- complete() {
2080
- const { partialObserver } = this;
2081
- if (partialObserver.complete) {
2082
- try {
2083
- partialObserver.complete();
2084
- }
2085
- catch (error) {
2086
- handleUnhandledError(error);
2087
- }
2088
- }
2089
- }
2090
- }
2091
- class SafeSubscriber extends Subscriber {
2092
- constructor(observerOrNext, error, complete) {
2093
- super();
2094
- let partialObserver;
2095
- if (isFunction(observerOrNext) || !observerOrNext) {
2096
- partialObserver = {
2097
- next: (observerOrNext !== null && observerOrNext !== void 0 ? observerOrNext : undefined),
2098
- error: error !== null && error !== void 0 ? error : undefined,
2099
- complete: complete !== null && complete !== void 0 ? complete : undefined,
2100
- };
2101
- }
2102
- else {
2103
- let context;
2104
- if (this && config.useDeprecatedNextContext) {
2105
- context = Object.create(observerOrNext);
2106
- context.unsubscribe = () => this.unsubscribe();
2107
- partialObserver = {
2108
- next: observerOrNext.next && bind(observerOrNext.next, context),
2109
- error: observerOrNext.error && bind(observerOrNext.error, context),
2110
- complete: observerOrNext.complete && bind(observerOrNext.complete, context),
2111
- };
2112
- }
2113
- else {
2114
- partialObserver = observerOrNext;
2115
- }
2116
- }
2117
- this.destination = new ConsumerObserver(partialObserver);
2118
- }
2119
- }
2120
- function handleUnhandledError(error) {
2121
- {
2122
- reportUnhandledError(error);
2123
- }
2124
- }
2125
- function defaultErrorHandler(err) {
2126
- throw err;
2127
- }
2128
- function handleStoppedNotification(notification, subscriber) {
2129
- const { onStoppedNotification } = config;
2130
- onStoppedNotification && timeoutProvider.setTimeout(() => onStoppedNotification(notification, subscriber));
2131
- }
2132
- const EMPTY_OBSERVER = {
2133
- closed: true,
2134
- next: noop,
2135
- error: defaultErrorHandler,
2136
- complete: noop,
2137
- };
2138
-
2139
- const observable = (() => (typeof Symbol === 'function' && Symbol.observable) || '@@observable')();
2140
-
2141
- function identity(x) {
2142
- return x;
2143
- }
2144
-
2145
- function pipeFromArray(fns) {
2146
- if (fns.length === 0) {
2147
- return identity;
2148
- }
2149
- if (fns.length === 1) {
2150
- return fns[0];
2151
- }
2152
- return function piped(input) {
2153
- return fns.reduce((prev, fn) => fn(prev), input);
2154
- };
2155
- }
2156
-
2157
- class Observable {
2158
- constructor(subscribe) {
2159
- if (subscribe) {
2160
- this._subscribe = subscribe;
2161
- }
2162
- }
2163
- lift(operator) {
2164
- const observable = new Observable();
2165
- observable.source = this;
2166
- observable.operator = operator;
2167
- return observable;
2168
- }
2169
- subscribe(observerOrNext, error, complete) {
2170
- const subscriber = isSubscriber(observerOrNext) ? observerOrNext : new SafeSubscriber(observerOrNext, error, complete);
2171
- errorContext(() => {
2172
- const { operator, source } = this;
2173
- subscriber.add(operator
2174
- ?
2175
- operator.call(subscriber, source)
2176
- : source
2177
- ?
2178
- this._subscribe(subscriber)
2179
- :
2180
- this._trySubscribe(subscriber));
2181
- });
2182
- return subscriber;
2183
- }
2184
- _trySubscribe(sink) {
2185
- try {
2186
- return this._subscribe(sink);
2187
- }
2188
- catch (err) {
2189
- sink.error(err);
2190
- }
2191
- }
2192
- forEach(next, promiseCtor) {
2193
- promiseCtor = getPromiseCtor(promiseCtor);
2194
- return new promiseCtor((resolve, reject) => {
2195
- const subscriber = new SafeSubscriber({
2196
- next: (value) => {
2197
- try {
2198
- next(value);
2199
- }
2200
- catch (err) {
2201
- reject(err);
2202
- subscriber.unsubscribe();
2203
- }
2204
- },
2205
- error: reject,
2206
- complete: resolve,
2207
- });
2208
- this.subscribe(subscriber);
2209
- });
2210
- }
2211
- _subscribe(subscriber) {
2212
- var _a;
2213
- return (_a = this.source) === null || _a === void 0 ? void 0 : _a.subscribe(subscriber);
2214
- }
2215
- [observable]() {
2216
- return this;
2217
- }
2218
- pipe(...operations) {
2219
- return pipeFromArray(operations)(this);
2220
- }
2221
- toPromise(promiseCtor) {
2222
- promiseCtor = getPromiseCtor(promiseCtor);
2223
- return new promiseCtor((resolve, reject) => {
2224
- let value;
2225
- this.subscribe((x) => (value = x), (err) => reject(err), () => resolve(value));
2226
- });
2227
- }
2228
- }
2229
- Observable.create = (subscribe) => {
2230
- return new Observable(subscribe);
2231
- };
2232
- function getPromiseCtor(promiseCtor) {
2233
- var _a;
2234
- return (_a = promiseCtor !== null && promiseCtor !== void 0 ? promiseCtor : config.Promise) !== null && _a !== void 0 ? _a : Promise;
2235
- }
2236
- function isObserver(value) {
2237
- return value && isFunction(value.next) && isFunction(value.error) && isFunction(value.complete);
2238
- }
2239
- function isSubscriber(value) {
2240
- return (value && value instanceof Subscriber) || (isObserver(value) && isSubscription(value));
2241
- }
2242
-
2243
- function hasLift(source) {
2244
- return isFunction(source === null || source === void 0 ? void 0 : source.lift);
2245
- }
2246
- function operate(init) {
2247
- return (source) => {
2248
- if (hasLift(source)) {
2249
- return source.lift(function (liftedSource) {
2250
- try {
2251
- return init(liftedSource, this);
2252
- }
2253
- catch (err) {
2254
- this.error(err);
2255
- }
2256
- });
2257
- }
2258
- throw new TypeError('Unable to lift unknown Observable type');
2259
- };
2260
- }
2261
-
2262
- function createOperatorSubscriber(destination, onNext, onComplete, onError, onFinalize) {
2263
- return new OperatorSubscriber(destination, onNext, onComplete, onError, onFinalize);
2264
- }
2265
- class OperatorSubscriber extends Subscriber {
2266
- constructor(destination, onNext, onComplete, onError, onFinalize, shouldUnsubscribe) {
2267
- super(destination);
2268
- this.onFinalize = onFinalize;
2269
- this.shouldUnsubscribe = shouldUnsubscribe;
2270
- this._next = onNext
2271
- ? function (value) {
2272
- try {
2273
- onNext(value);
2274
- }
2275
- catch (err) {
2276
- destination.error(err);
2277
- }
2278
- }
2279
- : super._next;
2280
- this._error = onError
2281
- ? function (err) {
2282
- try {
2283
- onError(err);
2284
- }
2285
- catch (err) {
2286
- destination.error(err);
2287
- }
2288
- finally {
2289
- this.unsubscribe();
2290
- }
2291
- }
2292
- : super._error;
2293
- this._complete = onComplete
2294
- ? function () {
2295
- try {
2296
- onComplete();
2297
- }
2298
- catch (err) {
2299
- destination.error(err);
2300
- }
2301
- finally {
2302
- this.unsubscribe();
2303
- }
2304
- }
2305
- : super._complete;
2306
- }
2307
- unsubscribe() {
2308
- var _a;
2309
- if (!this.shouldUnsubscribe || this.shouldUnsubscribe()) {
2310
- const { closed } = this;
2311
- super.unsubscribe();
2312
- !closed && ((_a = this.onFinalize) === null || _a === void 0 ? void 0 : _a.call(this));
2313
- }
2314
- }
2315
- }
2316
-
2317
- const ObjectUnsubscribedError = createErrorClass((_super) => function ObjectUnsubscribedErrorImpl() {
2318
- _super(this);
2319
- this.name = 'ObjectUnsubscribedError';
2320
- this.message = 'object unsubscribed';
2321
- });
2322
-
2323
- class Subject extends Observable {
2324
- constructor() {
2325
- super();
2326
- this.closed = false;
2327
- this.currentObservers = null;
2328
- this.observers = [];
2329
- this.isStopped = false;
2330
- this.hasError = false;
2331
- this.thrownError = null;
2332
- }
2333
- lift(operator) {
2334
- const subject = new AnonymousSubject(this, this);
2335
- subject.operator = operator;
2336
- return subject;
2337
- }
2338
- _throwIfClosed() {
2339
- if (this.closed) {
2340
- throw new ObjectUnsubscribedError();
2341
- }
2342
- }
2343
- next(value) {
2344
- errorContext(() => {
2345
- this._throwIfClosed();
2346
- if (!this.isStopped) {
2347
- if (!this.currentObservers) {
2348
- this.currentObservers = Array.from(this.observers);
2349
- }
2350
- for (const observer of this.currentObservers) {
2351
- observer.next(value);
2352
- }
2353
- }
2354
- });
2355
- }
2356
- error(err) {
2357
- errorContext(() => {
2358
- this._throwIfClosed();
2359
- if (!this.isStopped) {
2360
- this.hasError = this.isStopped = true;
2361
- this.thrownError = err;
2362
- const { observers } = this;
2363
- while (observers.length) {
2364
- observers.shift().error(err);
2365
- }
2366
- }
2367
- });
2368
- }
2369
- complete() {
2370
- errorContext(() => {
2371
- this._throwIfClosed();
2372
- if (!this.isStopped) {
2373
- this.isStopped = true;
2374
- const { observers } = this;
2375
- while (observers.length) {
2376
- observers.shift().complete();
2377
- }
2378
- }
2379
- });
2380
- }
2381
- unsubscribe() {
2382
- this.isStopped = this.closed = true;
2383
- this.observers = this.currentObservers = null;
2384
- }
2385
- get observed() {
2386
- var _a;
2387
- return ((_a = this.observers) === null || _a === void 0 ? void 0 : _a.length) > 0;
2388
- }
2389
- _trySubscribe(subscriber) {
2390
- this._throwIfClosed();
2391
- return super._trySubscribe(subscriber);
2392
- }
2393
- _subscribe(subscriber) {
2394
- this._throwIfClosed();
2395
- this._checkFinalizedStatuses(subscriber);
2396
- return this._innerSubscribe(subscriber);
2397
- }
2398
- _innerSubscribe(subscriber) {
2399
- const { hasError, isStopped, observers } = this;
2400
- if (hasError || isStopped) {
2401
- return EMPTY_SUBSCRIPTION;
2402
- }
2403
- this.currentObservers = null;
2404
- observers.push(subscriber);
2405
- return new Subscription(() => {
2406
- this.currentObservers = null;
2407
- arrRemove(observers, subscriber);
2408
- });
2409
- }
2410
- _checkFinalizedStatuses(subscriber) {
2411
- const { hasError, thrownError, isStopped } = this;
2412
- if (hasError) {
2413
- subscriber.error(thrownError);
2414
- }
2415
- else if (isStopped) {
2416
- subscriber.complete();
2417
- }
2418
- }
2419
- asObservable() {
2420
- const observable = new Observable();
2421
- observable.source = this;
2422
- return observable;
2423
- }
2424
- }
2425
- Subject.create = (destination, source) => {
2426
- return new AnonymousSubject(destination, source);
2427
- };
2428
- class AnonymousSubject extends Subject {
2429
- constructor(destination, source) {
2430
- super();
2431
- this.destination = destination;
2432
- this.source = source;
2433
- }
2434
- next(value) {
2435
- var _a, _b;
2436
- (_b = (_a = this.destination) === null || _a === void 0 ? void 0 : _a.next) === null || _b === void 0 ? void 0 : _b.call(_a, value);
2437
- }
2438
- error(err) {
2439
- var _a, _b;
2440
- (_b = (_a = this.destination) === null || _a === void 0 ? void 0 : _a.error) === null || _b === void 0 ? void 0 : _b.call(_a, err);
2441
- }
2442
- complete() {
2443
- var _a, _b;
2444
- (_b = (_a = this.destination) === null || _a === void 0 ? void 0 : _a.complete) === null || _b === void 0 ? void 0 : _b.call(_a);
2445
- }
2446
- _subscribe(subscriber) {
2447
- var _a, _b;
2448
- return (_b = (_a = this.source) === null || _a === void 0 ? void 0 : _a.subscribe(subscriber)) !== null && _b !== void 0 ? _b : EMPTY_SUBSCRIPTION;
2449
- }
2450
- }
2451
-
2452
- const dateTimestampProvider = {
2453
- now() {
2454
- return (dateTimestampProvider.delegate || Date).now();
2455
- },
2456
- delegate: undefined,
2457
- };
2458
-
2459
- class Action extends Subscription {
2460
- constructor(scheduler, work) {
2461
- super();
2462
- }
2463
- schedule(state, delay = 0) {
2464
- return this;
2465
- }
2466
- }
2467
-
2468
- const intervalProvider = {
2469
- setInterval(handler, timeout, ...args) {
2470
- const { delegate } = intervalProvider;
2471
- if (delegate === null || delegate === void 0 ? void 0 : delegate.setInterval) {
2472
- return delegate.setInterval(handler, timeout, ...args);
2473
- }
2474
- return setInterval(handler, timeout, ...args);
2475
- },
2476
- clearInterval(handle) {
2477
- const { delegate } = intervalProvider;
2478
- return ((delegate === null || delegate === void 0 ? void 0 : delegate.clearInterval) || clearInterval)(handle);
2479
- },
2480
- delegate: undefined,
2481
- };
2482
-
2483
- class AsyncAction extends Action {
2484
- constructor(scheduler, work) {
2485
- super(scheduler, work);
2486
- this.scheduler = scheduler;
2487
- this.work = work;
2488
- this.pending = false;
2489
- }
2490
- schedule(state, delay = 0) {
2491
- var _a;
2492
- if (this.closed) {
2493
- return this;
2494
- }
2495
- this.state = state;
2496
- const id = this.id;
2497
- const scheduler = this.scheduler;
2498
- if (id != null) {
2499
- this.id = this.recycleAsyncId(scheduler, id, delay);
2500
- }
2501
- this.pending = true;
2502
- this.delay = delay;
2503
- this.id = (_a = this.id) !== null && _a !== void 0 ? _a : this.requestAsyncId(scheduler, this.id, delay);
2504
- return this;
2505
- }
2506
- requestAsyncId(scheduler, _id, delay = 0) {
2507
- return intervalProvider.setInterval(scheduler.flush.bind(scheduler, this), delay);
2508
- }
2509
- recycleAsyncId(_scheduler, id, delay = 0) {
2510
- if (delay != null && this.delay === delay && this.pending === false) {
2511
- return id;
2512
- }
2513
- if (id != null) {
2514
- intervalProvider.clearInterval(id);
2515
- }
2516
- return undefined;
2517
- }
2518
- execute(state, delay) {
2519
- if (this.closed) {
2520
- return new Error('executing a cancelled action');
2521
- }
2522
- this.pending = false;
2523
- const error = this._execute(state, delay);
2524
- if (error) {
2525
- return error;
2526
- }
2527
- else if (this.pending === false && this.id != null) {
2528
- this.id = this.recycleAsyncId(this.scheduler, this.id, null);
2529
- }
2530
- }
2531
- _execute(state, _delay) {
2532
- let errored = false;
2533
- let errorValue;
2534
- try {
2535
- this.work(state);
2536
- }
2537
- catch (e) {
2538
- errored = true;
2539
- errorValue = e ? e : new Error('Scheduled action threw falsy error');
2540
- }
2541
- if (errored) {
2542
- this.unsubscribe();
2543
- return errorValue;
2544
- }
2545
- }
2546
- unsubscribe() {
2547
- if (!this.closed) {
2548
- const { id, scheduler } = this;
2549
- const { actions } = scheduler;
2550
- this.work = this.state = this.scheduler = null;
2551
- this.pending = false;
2552
- arrRemove(actions, this);
2553
- if (id != null) {
2554
- this.id = this.recycleAsyncId(scheduler, id, null);
2555
- }
2556
- this.delay = null;
2557
- super.unsubscribe();
2558
- }
2559
- }
2560
- }
2561
-
2562
- class Scheduler {
2563
- constructor(schedulerActionCtor, now = Scheduler.now) {
2564
- this.schedulerActionCtor = schedulerActionCtor;
2565
- this.now = now;
2566
- }
2567
- schedule(work, delay = 0, state) {
2568
- return new this.schedulerActionCtor(this, work).schedule(state, delay);
2569
- }
2570
- }
2571
- Scheduler.now = dateTimestampProvider.now;
2572
-
2573
- class AsyncScheduler extends Scheduler {
2574
- constructor(SchedulerAction, now = Scheduler.now) {
2575
- super(SchedulerAction, now);
2576
- this.actions = [];
2577
- this._active = false;
2578
- }
2579
- flush(action) {
2580
- const { actions } = this;
2581
- if (this._active) {
2582
- actions.push(action);
2583
- return;
2584
- }
2585
- let error;
2586
- this._active = true;
2587
- do {
2588
- if ((error = action.execute(action.state, action.delay))) {
2589
- break;
2590
- }
2591
- } while ((action = actions.shift()));
2592
- this._active = false;
2593
- if (error) {
2594
- while ((action = actions.shift())) {
2595
- action.unsubscribe();
2596
- }
2597
- throw error;
2598
- }
2599
- }
2600
- }
2601
-
2602
- const asyncScheduler = new AsyncScheduler(AsyncAction);
2603
-
2604
- /******************************************************************************
2605
- Copyright (c) Microsoft Corporation.
2606
-
2607
- Permission to use, copy, modify, and/or distribute this software for any
2608
- purpose with or without fee is hereby granted.
2609
-
2610
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
2611
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
2612
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
2613
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
2614
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
2615
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
2616
- PERFORMANCE OF THIS SOFTWARE.
2617
- ***************************************************************************** */
2618
-
2619
- function __awaiter(thisArg, _arguments, P, generator) {
2620
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
2621
- return new (P || (P = Promise))(function (resolve, reject) {
2622
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
2623
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
2624
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
2625
- step((generator = generator.apply(thisArg, _arguments || [])).next());
2626
- });
2627
- }
2628
-
2629
- function __values(o) {
2630
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
2631
- if (m) return m.call(o);
2632
- if (o && typeof o.length === "number") return {
2633
- next: function () {
2634
- if (o && i >= o.length) o = void 0;
2635
- return { value: o && o[i++], done: !o };
2636
- }
2637
- };
2638
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
2639
- }
2640
-
2641
- function __await(v) {
2642
- return this instanceof __await ? (this.v = v, this) : new __await(v);
2643
- }
2644
-
2645
- function __asyncGenerator(thisArg, _arguments, generator) {
2646
- if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
2647
- var g = generator.apply(thisArg, _arguments || []), i, q = [];
2648
- return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
2649
- function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
2650
- function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
2651
- function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
2652
- function fulfill(value) { resume("next", value); }
2653
- function reject(value) { resume("throw", value); }
2654
- function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
2655
- }
2656
-
2657
- function __asyncValues(o) {
2658
- if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
2659
- var m = o[Symbol.asyncIterator], i;
2660
- return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
2661
- function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
2662
- function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
2663
- }
2664
-
2665
- typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
2666
- var e = new Error(message);
2667
- return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
2668
- };
2669
-
2670
- const isArrayLike = ((x) => x && typeof x.length === 'number' && typeof x !== 'function');
2671
-
2672
- function isPromise(value) {
2673
- return isFunction(value === null || value === void 0 ? void 0 : value.then);
2674
- }
2675
-
2676
- function isInteropObservable(input) {
2677
- return isFunction(input[observable]);
2678
- }
2679
-
2680
- function isAsyncIterable(obj) {
2681
- return Symbol.asyncIterator && isFunction(obj === null || obj === void 0 ? void 0 : obj[Symbol.asyncIterator]);
2682
- }
2683
-
2684
- function createInvalidObservableTypeError(input) {
2685
- return new TypeError(`You provided ${input !== null && typeof input === 'object' ? 'an invalid object' : `'${input}'`} where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.`);
2686
- }
2687
-
2688
- function getSymbolIterator() {
2689
- if (typeof Symbol !== 'function' || !Symbol.iterator) {
2690
- return '@@iterator';
2691
- }
2692
- return Symbol.iterator;
2693
- }
2694
- const iterator = getSymbolIterator();
2695
-
2696
- function isIterable(input) {
2697
- return isFunction(input === null || input === void 0 ? void 0 : input[iterator]);
2698
- }
2699
-
2700
- function readableStreamLikeToAsyncGenerator(readableStream) {
2701
- return __asyncGenerator(this, arguments, function* readableStreamLikeToAsyncGenerator_1() {
2702
- const reader = readableStream.getReader();
2703
- try {
2704
- while (true) {
2705
- const { value, done } = yield __await(reader.read());
2706
- if (done) {
2707
- return yield __await(void 0);
2708
- }
2709
- yield yield __await(value);
2710
- }
2711
- }
2712
- finally {
2713
- reader.releaseLock();
2714
- }
2715
- });
2716
- }
2717
- function isReadableStreamLike(obj) {
2718
- return isFunction(obj === null || obj === void 0 ? void 0 : obj.getReader);
2719
- }
2720
-
2721
- function innerFrom(input) {
2722
- if (input instanceof Observable) {
2723
- return input;
2724
- }
2725
- if (input != null) {
2726
- if (isInteropObservable(input)) {
2727
- return fromInteropObservable(input);
2728
- }
2729
- if (isArrayLike(input)) {
2730
- return fromArrayLike(input);
2731
- }
2732
- if (isPromise(input)) {
2733
- return fromPromise(input);
2734
- }
2735
- if (isAsyncIterable(input)) {
2736
- return fromAsyncIterable(input);
2737
- }
2738
- if (isIterable(input)) {
2739
- return fromIterable(input);
2740
- }
2741
- if (isReadableStreamLike(input)) {
2742
- return fromReadableStreamLike(input);
2743
- }
2744
- }
2745
- throw createInvalidObservableTypeError(input);
2746
- }
2747
- function fromInteropObservable(obj) {
2748
- return new Observable((subscriber) => {
2749
- const obs = obj[observable]();
2750
- if (isFunction(obs.subscribe)) {
2751
- return obs.subscribe(subscriber);
2752
- }
2753
- throw new TypeError('Provided object does not correctly implement Symbol.observable');
2754
- });
2755
- }
2756
- function fromArrayLike(array) {
2757
- return new Observable((subscriber) => {
2758
- for (let i = 0; i < array.length && !subscriber.closed; i++) {
2759
- subscriber.next(array[i]);
2760
- }
2761
- subscriber.complete();
2762
- });
2763
- }
2764
- function fromPromise(promise) {
2765
- return new Observable((subscriber) => {
2766
- promise
2767
- .then((value) => {
2768
- if (!subscriber.closed) {
2769
- subscriber.next(value);
2770
- subscriber.complete();
2771
- }
2772
- }, (err) => subscriber.error(err))
2773
- .then(null, reportUnhandledError);
2774
- });
2775
- }
2776
- function fromIterable(iterable) {
2777
- return new Observable((subscriber) => {
2778
- for (const value of iterable) {
2779
- subscriber.next(value);
2780
- if (subscriber.closed) {
2781
- return;
2782
- }
2783
- }
2784
- subscriber.complete();
2785
- });
2786
- }
2787
- function fromAsyncIterable(asyncIterable) {
2788
- return new Observable((subscriber) => {
2789
- process(asyncIterable, subscriber).catch((err) => subscriber.error(err));
2790
- });
2791
- }
2792
- function fromReadableStreamLike(readableStream) {
2793
- return fromAsyncIterable(readableStreamLikeToAsyncGenerator(readableStream));
2794
- }
2795
- function process(asyncIterable, subscriber) {
2796
- var asyncIterable_1, asyncIterable_1_1;
2797
- var e_1, _a;
2798
- return __awaiter(this, void 0, void 0, function* () {
2799
- try {
2800
- for (asyncIterable_1 = __asyncValues(asyncIterable); asyncIterable_1_1 = yield asyncIterable_1.next(), !asyncIterable_1_1.done;) {
2801
- const value = asyncIterable_1_1.value;
2802
- subscriber.next(value);
2803
- if (subscriber.closed) {
2804
- return;
2805
- }
2806
- }
2807
- }
2808
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
2809
- finally {
2810
- try {
2811
- if (asyncIterable_1_1 && !asyncIterable_1_1.done && (_a = asyncIterable_1.return)) yield _a.call(asyncIterable_1);
2812
- }
2813
- finally { if (e_1) throw e_1.error; }
2814
- }
2815
- subscriber.complete();
2816
- });
2817
- }
2818
-
2819
- function debounceTime(dueTime, scheduler = asyncScheduler) {
2820
- return operate((source, subscriber) => {
2821
- let activeTask = null;
2822
- let lastValue = null;
2823
- let lastTime = null;
2824
- const emit = () => {
2825
- if (activeTask) {
2826
- activeTask.unsubscribe();
2827
- activeTask = null;
2828
- const value = lastValue;
2829
- lastValue = null;
2830
- subscriber.next(value);
2831
- }
2832
- };
2833
- function emitWhenIdle() {
2834
- const targetTime = lastTime + dueTime;
2835
- const now = scheduler.now();
2836
- if (now < targetTime) {
2837
- activeTask = this.schedule(undefined, targetTime - now);
2838
- subscriber.add(activeTask);
2839
- return;
2840
- }
2841
- emit();
2842
- }
2843
- source.subscribe(createOperatorSubscriber(subscriber, (value) => {
2844
- lastValue = value;
2845
- lastTime = scheduler.now();
2846
- if (!activeTask) {
2847
- activeTask = scheduler.schedule(emitWhenIdle, dueTime);
2848
- subscriber.add(activeTask);
2849
- }
2850
- }, () => {
2851
- emit();
2852
- subscriber.complete();
2853
- }, undefined, () => {
2854
- lastValue = activeTask = null;
2855
- }));
2856
- });
2857
- }
2858
-
2859
- function takeUntil(notifier) {
2860
- return operate((source, subscriber) => {
2861
- innerFrom(notifier).subscribe(createOperatorSubscriber(subscriber, () => subscriber.complete(), noop));
2862
- !subscriber.closed && source.subscribe(subscriber);
2863
- });
2864
- }
2865
-
2866
- const PosApp = class {
2867
- constructor(hostRef) {
2868
- registerInstance(this, hostRef);
2869
- this.sessionRestoredEmitter = createEvent(this, "pod-os:session-restored", 7);
2870
- this.restorePreviousSession = false;
2871
- this.disconnected$ = new Subject();
2872
- }
2873
- componentWillLoad() {
2874
- this.unsubscribeSettings = localSettings.on('set', () => {
2875
- this.os = createPodOS(localSettings.state);
2876
- });
2877
- this.os = createPodOS(localSettings.state);
2878
- this.os.onSessionRestore(url => {
2879
- this.sessionRestoredEmitter.emit({ url });
2880
- });
2881
- this.os.handleIncomingRedirect(this.restorePreviousSession);
2882
- this.os
2883
- .observeSession()
2884
- .pipe(takeUntil(this.disconnected$))
2885
- .subscribe(async (sessionInfo) => {
2886
- store.state.webId = sessionInfo.webId;
2887
- if (sessionInfo.isLoggedIn) {
2888
- const profile = await this.os.fetchProfile(sessionInfo.webId);
2889
- store.state.profile = profile;
2890
- }
2891
- store.state.isLoggedIn = sessionInfo.isLoggedIn;
2892
- });
2893
- }
2894
- disconnectedCallback() {
2895
- this.unsubscribeSettings();
2896
- this.disconnected$.next();
2897
- this.disconnected$.unsubscribe();
2898
- }
2899
- async initializeOs(event) {
2900
- event.stopPropagation();
2901
- event.detail(this.os);
2902
- }
2903
- async loadModule(event) {
2904
- event.stopPropagation();
2905
- if (event.detail.module === 'contacts') {
2906
- const module = await this.os.loadContactsModule();
2907
- event.detail.receiver(module);
2908
- }
2909
- else {
2910
- throw Error(`Unknown module "${event.detail.module}"`);
2911
- }
2912
- }
2913
- render() {
2914
- return h("slot", { key: '402887f3383b6053da157df211c28977720db8e2' });
2915
- }
2916
- };
2917
-
2918
- const posAppBrowserCss = "pos-router {\n margin: 0;\n padding: 0;\n display: flex;\n flex-direction: column;\n height: 100%;\n}\n\npos-navigation {\n max-width: var(--width-lg);\n margin: 0;\n min-width: var(--size-32);\n flex-shrink: 1; /* Ensure navigation can shrink */\n}\n\npos-add-new-thing,\npos-login {\n flex: 0 1 auto;\n flex-shrink: 0; /* Ensure those items don't shrink */\n}\n\nheader,\nfooter {\n display: flex;\n gap: var(--size-1);\n height: auto;\n justify-content: center;\n align-items: center;\n padding: var(--size-1);\n}\n\nfooter svg {\n width: var(--size-5);\n height: var(--size-5);\n}\n\nfooter {\n font-size: var(--scale-fluid-000);\n\n .settings {\n padding: 0 var(--size-1);\n text-decoration: none;\n background-color: var(--pos-background-color);\n border: 1px solid var(--pos-secondary-border-color);\n color: var(--pos-secondary-border-color);\n border-radius: var(--radius-xs);\n\n &:hover {\n background-color: var(--pos-secondary-border-color);\n color: var(--pos-background-color);\n }\n }\n}\n\nheader {\n flex-wrap: nowrap;\n padding: var(--size-1) var(--size-8);\n}\n\nmain {\n flex: 1;\n max-height: 100vh;\n overflow: auto;\n}\n\n@media (max-width: 640px) {\n header {\n padding: var(--size-1);\n justify-content: space-between;\n }\n}\n";
2919
- const PosAppBrowserStyle0 = posAppBrowserCss;
2920
-
2921
- const PosAppBrowser = class {
2922
- constructor(hostRef) {
2923
- registerInstance(this, hostRef);
2924
- this.restorePreviousSession = false;
2925
- /**
2926
- * The mode the app is running in:
2927
- *
2928
- * - standalone: use this when you deploy it as a standalone web application
2929
- * - pod: use this when you host this app as a default interface for you pod
2930
- */
2931
- this.mode = 'standalone';
2932
- this.uri = '';
2933
- }
2934
- render() {
2935
- return (h(Host, { key: 'd2c863f8abf790352cdf9c830a1baa8d7aee95a8' }, h("pos-app", { key: '163415bea00a0a18f5e97f5cb7f3e5b9f5910f61', restorePreviousSession: this.restorePreviousSession }, h("pos-error-toast", { key: '799735b00aff86946259013132079814520ced7e' }, h("pos-router", { key: 'bdb89d03d93937399ec38b0b2c1d695feea248b9', mode: this.mode, "onPod-os:route-changed": e => (this.uri = e.detail) }, h("header", { key: 'e828af57fa2d8842c058197a826ac488cbb2a968' }, h("pos-add-new-thing", { key: '28eed0a89a4e554e88ea4fce13b2dd59c5ce0149', referenceUri: this.uri }), h("pos-navigation", { key: '16a06ae6aea6ac316cacc4ffa52442b3ada62d62', uri: this.uri === 'pod-os:dashboard' ? '' : this.uri }), h("pos-login", { key: '9577c4aa8a18af341715b6e51946dbb4481ef963' })), h("main", { key: '73dc7ba162440c5198a31f5a4b060dc2c2d1c70a' }, this.mainContent()), h("footer", { key: 'cb18c8eb3abc1ee62426db39a61e650df2906241' }, h(Logo, { key: 'e9205f06faa7153310a17470f55b97a423cf6691' }), h("span", { key: '7be0a255d0ca50d961f122fdfc9fd3bb3fdfd624' }, "PodOS Browser"), h("span", { key: '3ed17bc88faffbcfa973278c76f63a2a199ec026' }, "|"), h("a", { key: 'ab88d3e93e59b918dd21b8cd42b70522dc532730', class: "settings", href: "?uri=pod-os%3Asettings" }, "\u2699 Settings")))))));
2936
- }
2937
- mainContent() {
2938
- if (this.uri === '') {
2939
- return null;
2940
- }
2941
- if (this.uri.startsWith('pod-os:')) {
2942
- return h("pos-internal-router", { uri: this.uri });
2943
- }
2944
- return (h("pos-resource", { key: this.uri, uri: this.uri }, h("pos-type-router", null)));
2945
- }
2946
- };
2947
- const Logo = () => {
2948
- return (h("svg", { viewBox: "0 0 400 400", xmlns: "http://www.w3.org/2000/svg" }, h("path", { d: "M50 350 L50 100 L200 50 L350 100 L350 350 Z", style: {
2949
- 'fill': '#008BF8',
2950
- 'stroke': '#008BF8',
2951
- 'stroke-width': '70',
2952
- }, "stroke-linejoin": "round" }), h("path", { d: "M100 300 L100 150 L200 120 L300 150 L300 300 L130 300 L130 370 L100 370Z", style: {
2953
- 'fill': 'white',
2954
- 'stroke': 'white',
2955
- 'stroke-width': '45',
2956
- }, "stroke-linejoin": "round" }), h("path", { d: "M150 250 L150 200 L200 180 L250 200 L250 250 Z", style: {
2957
- 'fill': '#DC0073',
2958
- 'stroke': '#DC0073',
2959
- 'stroke-width': '20',
2960
- }, "stroke-linejoin": "round" })));
2961
- };
2962
- PosAppBrowser.style = PosAppBrowserStyle0;
2963
-
2964
- const posAppDashboardCss = ":host{display:grid;grid-template-columns:repeat(auto-fit, minmax(var(--size-12), var(--size-96)));gap:var(--size-4);padding:var(--size-2);justify-content:center;align-items:start;justify-items:stretch}";
2965
- const PosAppDashboardStyle0 = posAppDashboardCss;
2966
-
2967
- const PosAppDashboard = class {
2968
- constructor(hostRef) {
2969
- registerInstance(this, hostRef);
2970
- }
2971
- render() {
2972
- return (h(Host, { key: 'c467fa44eac028bc1a1546423ac92a5e1e9a98d2' }, h("pos-getting-started", { key: 'f62088d7cc2c199617eecbfd771b2f22db1a7431' }), h("pos-example-resources", { key: '6285bd2160042582ee113f81e7e6e02139d67f45' })));
2973
- }
2974
- };
2975
- PosAppDashboard.style = PosAppDashboardStyle0;
2976
-
2977
- const posAppSettingsCss = ":host{display:grid;grid-template-columns:repeat(auto-fit, minmax(var(--size-12), var(--size-96)));gap:var(--size-4);padding:var(--size-2);justify-content:center;align-items:start;justify-items:stretch}";
2978
- const PosAppSettingsStyle0 = posAppSettingsCss;
2979
-
2980
- const PosAppSettings = class {
2981
- constructor(hostRef) {
2982
- registerInstance(this, hostRef);
2983
- }
2984
- render() {
2985
- return h("pos-setting-offline-cache", { key: '0da588136a4c7c4238e0387bfe0649464ccd1c7d' });
2986
- }
2987
- };
2988
- PosAppSettings.style = PosAppSettingsStyle0;
2989
-
2990
- const PosDescription = class {
2991
- constructor(hostRef) {
2992
- registerInstance(this, hostRef);
2993
- this.subscribeResource = createEvent(this, "pod-os:resource", 7);
2994
- this.receiveResource = (resource) => {
2995
- this.resource = resource;
2996
- };
2997
- }
2998
- componentWillLoad() {
2999
- subscribeResource(this);
3000
- }
3001
- render() {
3002
- return this.resource ? this.resource.description() : null;
3003
- }
3004
- };
3005
-
3006
- const posDialogCss = "dialog{background-color:var(--pos-background-color);color:var(--pos-normal-text-color);border:none;border-radius:var(--radius-md);box-shadow:var(--shadow-md);max-width:var(--width-xs);animation:slideIn 0.2s ease-out}dialog::backdrop{background:rgba(0, 0, 0, 0.5);backdrop-filter:var(--blur-sm);animation:fadeIn 0.2s ease-out}@media (prefers-color-scheme: dark){dialog::backdrop{background:rgb(100, 100, 100, 0.5)}}dialog header>:first-child{flex-grow:1;font-weight:var(--weight-light);font-size:var(--scale-2);font-family:var(--font-sans);margin:0}dialog header{display:flex;flex-direction:row;justify-content:space-between;align-items:center;gap:var(--scale-0);border-bottom-style:inset;padding:0 0 var(--scale-0) 0}dialog>:last-child{display:block;margin-top:var(--scale-3)}button#close{cursor:pointer;display:flex;align-items:center;justify-content:center;border:none;background:none;font-size:var(--scale-3);color:var(--color-grey-500)}button#close:hover{color:var(--pos-secondary-border-color)}@keyframes fadeIn{from{opacity:0}to{opacity:1}}@keyframes slideIn{from{opacity:0;transform:translateY(-20px) scale(0.95)}to{opacity:1;transform:translateY(0) scale(1)}}";
3007
- const PosDialogStyle0 = posDialogCss;
3008
-
3009
- const PosDialog = class {
3010
- constructor(hostRef) {
3011
- registerInstance(this, hostRef);
3012
- }
3013
- showModal() {
3014
- this.dialog.showModal();
3015
- }
3016
- close() {
3017
- this.dialog.close();
3018
- }
3019
- render() {
3020
- return (h(Host, { key: '52b46535cab915321a93f84fa8b2f662d2e8e4ea' }, h("dialog", { key: 'e6c57b54805f48084c0a0ef2fa32fda9938f4c17', ref: el => (this.dialog = el) }, h("header", { key: 'aee8b90512a18b8e87084009433e963d1a9b3fd1' }, h("slot", { key: '3aa5a212f5774316ffaf0b9a1a04607690a2bcac', name: "title" }), h("button", { key: 'f3da0669f952023cfcc792b2b801670c94e49400', tabindex: -1, id: "close", title: "Close", onClick: () => this.close() }, h("ion-icon", { key: '90b5835a6f79c587c651d1d5e599fa9079a1d1e9', name: "close-outline" }))), h("slot", { key: '9fa7fa1e7f6077aca2a6eb40d806b1d7b9237eef', name: "content" }))));
3021
- }
3022
- };
3023
- PosDialog.style = PosDialogStyle0;
3024
-
3025
- const PosErrorToast = class {
3026
- constructor(hostRef) {
3027
- registerInstance(this, hostRef);
3028
- }
3029
- async unhandledRejection(event) {
3030
- event.stopPropagation();
3031
- console.error('unhandled promise rejection', event);
3032
- await this.showToast(event.reason.toString());
3033
- }
3034
- async catchError(event) {
3035
- event.stopPropagation();
3036
- console.error(event.detail);
3037
- await this.showToast(event.detail.message);
3038
- }
3039
- async showToast(message) {
3040
- const toast = await toastController.create({
3041
- message,
3042
- duration: 10000,
3043
- position: 'top',
3044
- color: 'danger',
3045
- buttons: [
3046
- {
3047
- text: 'Dismiss',
3048
- role: 'cancel',
3049
- },
3050
- ],
3051
- });
3052
- await toast.present();
3053
- }
3054
- render() {
3055
- return (h(Host, { key: '0dce513e04101d3b9011c635f5aab8897a246385' }, h("ion-toast", { key: '956224c61589fca317f8143055344c857aa894cf', trigger: "never", message: "Workarround to preload ion-toast and ion-ripple-effect to be able to show errors while offline", duration: 0 }, h("ion-ripple-effect", { key: 'e96e65e2f06b61970e241639e7c429a90404517e' })), h("slot", { key: '8869125c64fb97f9736e30df0a748c9ce6aec1da' })));
3056
- }
3057
- };
3058
-
3059
- const posExampleResourcesCss = ":host{border:var(--size-px) solid var(--pos-border-color);border-radius:var(--radius-lg);box-shadow:var(--shadow-md);padding:var(--size-8);max-width:var(--size-96);background:var(--pos-card-background)}.links{display:flex;flex-direction:column;gap:var(--size-3);max-width:80vw}";
3060
- const PosExampleResourcesStyle0 = posExampleResourcesCss;
3061
-
3062
- const PosExampleResources = class {
3063
- constructor(hostRef) {
3064
- registerInstance(this, hostRef);
3065
- }
3066
- render() {
3067
- return (h(Host, { key: 'b6a491caa9ea624cdba3cca92fcc9444a3c38290' }, h("div", { key: '458ceb259d7070d38eb13aea9f3b303f174a5c56' }, h("h2", { key: '1d571afb47c256f2ac873840c6fe8bc8408cc9a6' }, "Try these... \uD83D\uDCA1"), h("p", { key: '7de1dac7a92becb01ec7aab4cf96c45fa95f7de6' }, "No idea where to start? Try these example resources, and follow your nose \uD83D\uDC43"), h("div", { key: 'b94cc5571f5b7af0bcc660fc8812ca08ca2db482', class: "links" }, h("pos-rich-link", { key: 'e2c414d51b79e27667a42d04fa66e879a2ecf2a2', uri: "https://pod-os.solidcommunity.net/profile/card#me" }), h("pos-rich-link", { key: 'e54479349363d67d027612bbcdb2167f9ab6ec03', uri: "https://angelo.veltens.org/profile/card#me" }), h("pos-rich-link", { key: '1c743eafd11d46f6bdd31face3bf1083abd1e045', uri: "https://angelo.veltens.org/public/bookmarks" }), h("pos-rich-link", { key: '3e47cd67a0ab44a1921ec4f0e5e9f24404826494', uri: "https://solidos.solidcommunity.net/profile/card#me" })))));
3068
- }
3069
- };
3070
- PosExampleResources.style = PosExampleResourcesStyle0;
3071
-
3072
- const posGettingStartedCss = ":host{border:var(--size-px) solid var(--pos-border-color);border-radius:var(--radius-lg);box-shadow:var(--shadow-md);padding:var(--size-8);max-width:var(--size-96);background:var(--pos-card-background)}.question{font-weight:var(--weight-semibold)}a{font-weight:var(--weight-bold);color:var(--pos-primary-color)}button.login{background:none;color:var(--pos-primary-color);display:inline;text-decoration:underline;border:none;padding:0;margin:0;cursor:pointer;font-size:unset}";
3073
- const PosGettingStartedStyle0 = posGettingStartedCss;
3074
-
3075
- const PosGettingStarted = class {
3076
- constructor(hostRef) {
3077
- registerInstance(this, hostRef);
3078
- this.login = createEvent(this, "pod-os:login", 7);
3079
- }
3080
- render() {
3081
- return (h(Host, { key: '963476081378811bc5623921ca7f4dc5ac18b9f7' }, h("div", { key: 'df6a7a5bab3c026d1960c03a4d008f8bff0b1c9d' }, h("h2", { key: '9e7a1e2c081f87275641fe99afb72c1f8ef65115' }, "Getting started \uD83D\uDE80"), h("p", { key: 'dac8ca58a733d66ab80fa79ef59d62a254b3b83f' }, "\uD83D\uDD0E Enter a URL into the above navigation bar to browse through the web of data. "), h("p", { key: 'c90fbc4f7c09893f6ded65befe4c77f673df6db2' }, "\uD83D\uDD10", ' ', h("button", { key: '2688b10503c6d518a7a48601f35e1f20741d71c7', class: "login", onClick: () => this.login.emit() }, "Sign in"), ' ', "to access private resources on your Solid Pod or those of your friends or coworkers.")), h("div", { key: '5990c65adc978df16ec7b73c3be2b6b4b3a48ce3' }, h("p", { key: '8fd4cb0941da30c3b438338a557a6d4fb9d7ff33', class: "question" }, "New to Solid?"), h("p", { key: 'd6b06063acaac1d55dc0aea86c3d80f4e7c8ca6f' }, h("a", { key: 'b0a49b4e170c89f736cf9bd2dd567cfafbcec31c', href: "https://solidproject.org/for-developers#hosted-pod-services" }, "Get a Pod \u2192"))), h("div", { key: '7c88ea4bb3982346343cf10e6196d2d07057a24e' }, h("p", { key: '22cfb601fada05ca7b5f274f0b6a81d360344764', class: "question" }, "Want to dig deeper into PodOS?"), h("p", { key: 'fb03d0f84714feb53b1b053390a5e7b9686e610e' }, h("a", { key: '1681d6d1c860589ca1624abc3c05121ccde3f951', href: "http://pod-os.org" }, "Learn more \u2192")))));
3082
- }
3083
- };
3084
- PosGettingStarted.style = PosGettingStartedStyle0;
3085
-
3086
- const posImageCss = ":host{display:flex;background-size:cover;background-repeat:no-repeat;background-position:center;border-radius:inherit}img,ion-skeleton-text,div.error{border-radius:var(--border-radius);width:var(--width);height:var(--height);max-width:var(--max-width);max-height:var(--max-height);object-fit:var(--object-fit)}img{backdrop-filter:var(--blur-xl)}.error{display:flex;opacity:0.8;background:repeating-linear-gradient(-45deg, rgba(150, 0, 0, 0.1), rgba(150, 0, 0, 0.1) 10px, #fff 5px, #fff 25px);flex-direction:column;border:1px solid red;color:black;align-items:center;justify-content:center;word-break:break-all;padding:1rem;box-sizing:border-box}.error ion-icon{color:#282828;--ionicon-stroke-width:calc(var(--width) / 5);font-size:calc(var(--width) / 2)}a.error{text-decoration:none;width:var(--width);height:var(--height)}.code{font-weight:bold;font-size:calc(var(--width) / 8)}.text{font-size:calc(var(--width) / 20)}";
3087
- const PosImageStyle0 = posImageCss;
3088
-
3089
- const PosImage = class {
3090
- constructor(hostRef) {
3091
- registerInstance(this, hostRef);
3092
- this.initializeOsEmitter = createEvent(this, "pod-os:init", 7);
3093
- this.resourceLoadedEmitter = createEvent(this, "pod-os:resource-loaded", 7);
3094
- /**
3095
- * Use a blurred version of the image as its own background, if the image is scaled down to fit into the container.
3096
- */
3097
- this.blurredBackground = false;
3098
- this.loading = true;
3099
- this.setOs = async (os) => {
3100
- this.os = os;
3101
- };
3102
- }
3103
- componentWillLoad() {
3104
- store.onChange('isLoggedIn', () => this.fetchBlob());
3105
- this.initializeOsEmitter.emit(this.setOs);
3106
- }
3107
- async fetchBlob() {
3108
- try {
3109
- this.loading = true;
3110
- this.imageError = null;
3111
- this.networkError = null;
3112
- this.brokenFile = null;
3113
- const file = await this.os.fetchFile(this.src);
3114
- this.resourceLoadedEmitter.emit(this.src);
3115
- if (file.blob()) {
3116
- this.dataUri = URL.createObjectURL(file.blob());
3117
- }
3118
- else {
3119
- this.brokenFile = file;
3120
- }
3121
- }
3122
- catch (err) {
3123
- this.networkError = err;
3124
- }
3125
- finally {
3126
- this.loading = false;
3127
- }
3128
- }
3129
- onImageError(err) {
3130
- this.networkError = null;
3131
- this.imageError = err;
3132
- }
3133
- render() {
3134
- if (this.loading) {
3135
- return h("ion-skeleton-text", { animated: true });
3136
- }
3137
- if (this.networkError) {
3138
- // probably a CORS error
3139
- return h("img", { alt: this.alt, src: this.src, onError: err => this.onImageError(err) });
3140
- }
3141
- if (this.brokenFile) {
3142
- // fetching worked, but HTTP response was not ok
3143
- return h(BrokenFile, { file: this.brokenFile });
3144
- }
3145
- if (this.imageError) {
3146
- // if even the loading via classic <img src="..."> failed, render a link
3147
- return (h("div", { class: "error" }, h("a", { href: this.src }, this.src)));
3148
- }
3149
- return (h(Host, { style: {
3150
- backgroundImage: this.blurredBackground ? `url('${this.dataUri}')` : null,
3151
- } }, h("img", { src: this.dataUri, alt: this.alt })));
3152
- }
3153
- static get watchers() { return {
3154
- "os": ["fetchBlob"],
3155
- "src": ["fetchBlob"]
3156
- }; }
3157
- };
3158
- PosImage.style = PosImageStyle0;
3159
-
3160
- const PosInternalRouter = class {
3161
- constructor(hostRef) {
3162
- registerInstance(this, hostRef);
3163
- this.uri = 'pod-os:dashboard';
3164
- }
3165
- render() {
3166
- return this.uri === 'pod-os:settings' ? (h("pos-app-settings", null)) : (h("pos-app-dashboard", null));
3167
- }
3168
- };
3169
-
3170
- const PosLabel = class {
3171
- constructor(hostRef) {
3172
- registerInstance(this, hostRef);
3173
- this.subscribeResource = createEvent(this, "pod-os:resource", 7);
3174
- this.receiveResource = (resource) => {
3175
- this.resource = resource;
3176
- };
3177
- }
3178
- componentWillLoad() {
3179
- subscribeResource(this);
3180
- }
3181
- render() {
3182
- return this.resource ? this.resource.label() : null;
3183
- }
3184
- };
3185
-
3186
- const posLoginCss = ".container{display:flex;align-items:center;gap:var(--size-2)}.user-data{align-items:center;display:inline-flex;gap:10px}.user-data pos-picture{--width:40px;--height:40px;--border-radius:50%}pos-login-form{margin:var(--size-2)}dialog{margin-top:var(--size-10)}button#login,button#logout{outline:none;font-weight:var(--weight-bold);letter-spacing:var(--letter-xl);border:none;box-sizing:border-box;border-radius:var(--radius-xs);padding:var(--size-2);box-shadow:var(--shadow-sm);color:var(--pos-primary-text-color);background-color:var(--pos-primary-color)}button#login:focus-within,button#logout:focus-within{outline:var(--pos-input-focus-outline)}button#login:focus,button#login:hover,button#logout:focus,button#logout:hover{filter:brightness(110%);box-shadow:var(--shadow-md)}";
3187
- const PosLoginStyle0 = posLoginCss;
3188
-
3189
- const PosLogin = class {
3190
- constructor(hostRef) {
3191
- registerInstance(this, hostRef);
3192
- this.initializeOsEmitter = createEvent(this, "pod-os:init", 7);
3193
- this.setOs = async (os) => {
3194
- this.os = os;
3195
- };
3196
- }
3197
- componentWillLoad() {
3198
- this.initializeOsEmitter.emit(this.setOs);
3199
- }
3200
- login(event) {
3201
- const idpUrl = event.detail;
3202
- this.os.login(idpUrl);
3203
- }
3204
- logout() {
3205
- this.os.logout();
3206
- }
3207
- onLogin() {
3208
- this.openDialog();
3209
- }
3210
- openDialog() {
3211
- this.dialog.showModal();
3212
- }
3213
- render() {
3214
- return (h(Host, { key: '3a9b64d2fde82e4067095067d852f3a793c9c6a2' }, h("div", { key: '36ce0bb0f9d85b90f5faf9dc47c64c8d0dcf88e9', class: "container" }, store.state.isLoggedIn ? (h("pos-resource", { uri: store.state.webId }, h("span", { class: "user-data" }, h("pos-picture", null), h("pos-label", null)))) : (''), !store.state.isLoggedIn && (h("button", { key: '228a4dd94d2497acc6f3ecd13f70e2ff40daf8dc', id: "login", onClick: () => this.openDialog() }, "Login")), store.state.isLoggedIn && (h("button", { key: '2212c8e0c939656179a66c2b3ff74227dab42476', id: "logout", onClick: () => this.logout() }, "Logout"))), h("pos-dialog", { key: '2cd9a1060b1494606848d3dcaea21cad2ede8103', ref: el => (this.dialog = el) }, h("span", { key: '4852dc345b9271c6aca71d4615627d76985d548d', slot: "title" }, "Sign in to your Pod"), h("pos-login-form", { key: 'f6919d6a8863d3c8535ba786a5334741550bc8a5', "onPod-os:idp-url-selected": ev => this.login(ev), slot: "content" }))));
3215
- }
3216
- };
3217
- PosLogin.style = PosLoginStyle0;
3218
-
3219
- const posLoginFormCss = ":host{display:block;margin:0}form{display:flex;flex-direction:column;gap:var(--size-4)}input{outline:var(--pos-input-outline);padding:var(--scale-000);border:none;border-radius:var(--radius-xs);width:var(--size-full);box-sizing:border-box;background:var(--pos-input-background-color);color:var(--pos-normal-text-color)}input:focus-within{outline:var(--pos-input-focus-outline)}input#login{outline:none;box-shadow:var(--shadow-sm);cursor:pointer;color:var(--pos-primary-text-color);background-color:var(--pos-primary-color)}input#login:disabled{cursor:default;color:var(--pos-disabled-text-color);background-color:var(--pos-disabled-color);box-shadow:none}input#login:hover:not(:disabled),input#login:focus{filter:brightness(110%);box-shadow:var(--shadow-md)}";
3220
- const PosLoginFormStyle0 = posLoginFormCss;
3221
-
3222
- const PosLoginForm = class {
3223
- constructor(hostRef) {
3224
- registerInstance(this, hostRef);
3225
- this.idpUrlSelected = createEvent(this, "pod-os:idp-url-selected", 7);
3226
- this.idpUrl = '';
3227
- this.canSubmit = false;
3228
- }
3229
- validate() {
3230
- this.canSubmit = Boolean(this.idpUrl);
3231
- }
3232
- render() {
3233
- return (h("form", { key: '6c54aa03972bf5af3779c1e3f874b99574232821', method: "dialog", onSubmit: () => this.handleSubmit() }, h("label", { key: 'a5def7569abeb0a2591886d48fa0deb2c7f6039c', htmlFor: "idpUrl" }, "Please enter your Identity Provider"), h("input", { key: '1da8575dccea9a777f00cb8a7f96435654a582bc', id: "idpUrl", type: "url", value: this.idpUrl, required: true, onInput: e => this.handleChange(e), list: "suggestedIssuers", placeholder: "Type to search..." }), h("datalist", { key: '1818988df2f8a825194eb3503979d6c6adac3619', id: "suggestedIssuers" }, h("option", { key: '25e1b3fd84610e0664c25c3ca9cd535bf7558357', value: "https://solidcommunity.net" }, "solidcommunity.net"), h("option", { key: '5635e434dc4bf406a3664cf5cb28489b5b9218fc', value: "https://solidweb.org" }, "solidweb.org"), h("option", { key: 'd4d301023b40f84b5f445d14290ef3bc589cff56', value: "https://solidweb.me" }, "solidweb.me"), h("option", { key: '39f968af206347c83e4271724e9090543fcec43e', value: "https://inrupt.net" }, "inrupt.net"), h("option", { key: '381767d06a60e16b9323cb15b4298db2eac71d82', value: "https://login.inrupt.com" }, "Inrupt PodSpaces"), h("option", { key: 'd4461d0bb2bfba0ec97f276951b6534dee1ffd51', value: "https://trinpod.us" }, "trinpod.us"), h("option", { key: '80aa0ef7de3ec8dd53d06402c116a6c97747a24f', value: "https://use.id" }, "use.id"), h("option", { key: '794bee3c5a2b29738f25bb67bfb918754fe016ef', value: "https://solid.redpencil.io" }, "redpencil.io"), h("option", { key: '88e27225e7252c90bfb24f21a72bd70c9e3408f4', value: "https://datapod.grant.io" }, "Data Pod (grant.io)"), h("option", { key: '033b75773e898b4fed2507c5064686fb0ad56e03', value: "https://teamid.live" }, "teamid.live")), h("input", { key: 'c8dc41c5d6a892e623d42f5b1839af2728929abd', id: "login", type: "submit", value: "Login", disabled: !this.canSubmit })));
3234
- }
3235
- handleChange(event) {
3236
- this.validate();
3237
- this.idpUrl = event.target.value;
3238
- }
3239
- async handleSubmit() {
3240
- this.idpUrlSelected.emit(this.idpUrl);
3241
- }
3242
- static get delegatesFocus() { return true; }
3243
- static get watchers() { return {
3244
- "idpUrl": ["validate"]
3245
- }; }
3246
- };
3247
- PosLoginForm.style = PosLoginFormStyle0;
3248
-
3249
- const posMakeFindableCss = "button.main {\n display: flex;\n transition:\n width 200ms,\n background-color 500ms,\n color 500ms,\n border-color 500ms;\n max-width: var(--size-40);\n flex-direction: row;\n overflow: hidden;\n height: var(--pos-navigation-bar-height);\n width: var(--pos-navigation-bar-height);\n align-items: center;\n justify-content: center;\n border-radius: var(--radius-md);\n color: var(--pos-subtle-text-color);\n border: var(--size-px) dashed var(--pos-subtle-text-color);\n background-color: var(--pos-background-color);\n\n p {\n padding: 0;\n margin: 0;\n display: none;\n white-space: nowrap;\n }\n\n &.success {\n color: var(--color-green-700);\n border-color: var(--color-green-700);\n border-style: solid;\n background-color: var(--color-green-100);\n }\n\n &:active {\n transform: scale(0.99);\n filter: brightness(90%);\n }\n &:focus {\n outline: var(--pos-input-focus-outline);\n }\n}\n\n.options {\n position: absolute;\n animation: fadeIn 300ms;\n padding: 0;\n margin-top: var(--size-1);\n z-index: var(--layer-top);\n\n ol {\n display: flex;\n flex-direction: column;\n box-shadow: var(--shadow-md);\n backdrop-filter: var(--blur-md);\n border-radius: var(--radius-xs);\n overflow: hidden;\n color: var(--color-grey-900);\n background-color: var(--color-grey-200);\n padding: 0;\n margin: 0;\n list-style: none;\n label {\n display: flex;\n justify-content: flex-start;\n align-items: center;\n transition: all 300ms var(--ease-in-out-sine);\n margin: 0;\n border: none;\n outline: none;\n padding: var(--size-2);\n width: var(--size-full);\n\n &:hover,\n &:focus {\n filter: brightness(80%);\n }\n\n &:active {\n filter: brightness(90%);\n }\n }\n }\n label:has(input:checked) {\n background-color: var(--color-green-100);\n }\n}\n\nsvg {\n display: inline-block;\n height: var(--size-6);\n flex-shrink: 0;\n flex-grow: 0;\n width: var(--size-6);\n}\n\nbutton.main:hover,\nbutton.open {\n &.success {\n background: var(--color-green-200);\n }\n width: var(--size-full);\n height: var(--pos-navigation-bar-height);\n background: var(--pos-background-color);\n color: var(--pos-normal-text-color);\n\n p {\n display: inline-block;\n }\n}\n\n@keyframes fadeIn {\n 0% {\n opacity: 0;\n }\n 100% {\n opacity: 1;\n }\n}\n";
3250
- const PosMakeFindableStyle0 = posMakeFindableCss;
3251
-
3252
- const PosMakeFindable = class {
3253
- constructor(hostRef) {
3254
- registerInstance(this, hostRef);
3255
- this.subscribePodOs = createEvent(this, "pod-os:init", 7);
3256
- this.errorEmitter = createEvent(this, "pod-os:error", 7);
3257
- this.indexUpdatedEmitter = createEvent(this, "pod-os:search:index-updated", 7);
3258
- this.indexCreatedEmitter = createEvent(this, "pod-os:search:index-created", 7);
3259
- this.indexes = [];
3260
- this.showOptions = false;
3261
- this.isIndexed = false;
3262
- this.receivePodOs = async (os) => {
3263
- this.os = os;
3264
- this.thing = this.os.store.get(this.uri);
3265
- this.getLabelIndexes(store.state.profile);
3266
- this.unsubscribeSessionChange = store.onChange('profile', profile => {
3267
- this.getLabelIndexes(profile);
3268
- });
3269
- };
3270
- }
3271
- componentWillLoad() {
3272
- subscribePodOs(this);
3273
- }
3274
- disconnectedCallback() {
3275
- this.unsubscribeSessionChange && this.unsubscribeSessionChange();
3276
- }
3277
- hideOptions(event) {
3278
- // @ts-ignore
3279
- if (!this.el.contains(event.target)) {
3280
- this.showOptions = false;
3281
- }
3282
- }
3283
- handleKeyDown(ev) {
3284
- if (ev.key === 'Escape') {
3285
- this.showOptions = false;
3286
- }
3287
- }
3288
- updateUri(uri) {
3289
- this.thing = this.os.store.get(uri);
3290
- this.isIndexed = this.checkIfIndexed(uri);
3291
- }
3292
- checkIfIndexed(uri) {
3293
- return this.indexes.some(it => it.contains(uri));
3294
- }
3295
- getLabelIndexes(profile) {
3296
- if (profile) {
3297
- this.indexes = profile.getPrivateLabelIndexes().map(it => this.os.store.get(it).assume(LabelIndex));
3298
- this.isIndexed = this.checkIfIndexed(this.uri);
3299
- }
3300
- }
3301
- async onClick(e) {
3302
- e.preventDefault();
3303
- if (this.indexes.length === 1) {
3304
- const index = this.indexes[0];
3305
- await this.addToLabelIndex(index);
3306
- this.indexUpdatedEmitter.emit(index);
3307
- }
3308
- else if (this.indexes.length > 1) {
3309
- this.showOptions = !this.showOptions;
3310
- }
3311
- else {
3312
- const index = await this.createDefaultLabelIndex();
3313
- await this.addToLabelIndex(index);
3314
- this.indexCreatedEmitter.emit(index);
3315
- }
3316
- }
3317
- async addToLabelIndex(index) {
3318
- try {
3319
- await this.os.addToLabelIndex(this.thing, index);
3320
- this.isIndexed = true;
3321
- }
3322
- catch (e) {
3323
- this.errorEmitter.emit(e);
3324
- }
3325
- this.showOptions = false;
3326
- }
3327
- async createDefaultLabelIndex() {
3328
- try {
3329
- return await this.os.createDefaultLabelIndex(store.state.profile);
3330
- }
3331
- catch (e) {
3332
- this.errorEmitter.emit(e);
3333
- }
3334
- }
3335
- render() {
3336
- if (!store.state.isLoggedIn || !this.uri) {
3337
- return null;
3338
- }
3339
- const label = 'Make this findable';
3340
- return (h(Host, null, h("button", { type: "button", "aria-label": label, class: { main: true, open: this.showOptions, success: this.isIndexed }, onClick: e => this.onClick(e), title: "" }, this.isIndexed ? h(IconSuccess, null) : h(IconMakeFindable, null), h("p", null, label)), this.showOptions && (h("div", { class: "options" }, h("ol", { role: "listbox" }, this.indexes.map((index) => (h("li", { role: "option" }, h("label", null, h("input", { type: "checkbox", checked: index.contains(this.uri), onChange: e => this.chooseOption(e, index) }), h("pos-resource", { uri: index.uri, lazy: true }, h("pos-label", null)))))))))));
3341
- }
3342
- async chooseOption(e, index) {
3343
- e.preventDefault();
3344
- await this.addToLabelIndex(index);
3345
- this.indexUpdatedEmitter.emit(index);
3346
- }
3347
- get el() { return getElement(this); }
3348
- static get watchers() { return {
3349
- "uri": ["updateUri"]
3350
- }; }
3351
- };
3352
- const IconMakeFindable = () => (h("svg", { role: "presentation", xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", "stroke-width": "1.5", stroke: "currentColor" }, h("path", { "stroke-linecap": "round", "stroke-linejoin": "round", d: "M19.5 14.25v-2.625a3.375 3.375 0 0 0-3.375-3.375h-1.5A1.125 1.125 0 0 1 13.5 7.125v-1.5a3.375 3.375 0 0 0-3.375-3.375H8.25m5.231 13.481L15 17.25m-4.5-15H5.625c-.621 0-1.125.504-1.125 1.125v16.5c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 0 0-9-9Zm3.75 11.625a2.625 2.625 0 1 1-5.25 0 2.625 2.625 0 0 1 5.25 0Z" })));
3353
- const IconSuccess = () => (h("svg", { role: "presentation", xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", "stroke-width": "1.5", stroke: "currentColor" }, h("path", { "stroke-linecap": "round", "stroke-linejoin": "round", d: "M10.125 2.25h-4.5c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125v-9M10.125 2.25h.375a9 9 0 0 1 9 9v.375M10.125 2.25A3.375 3.375 0 0 1 13.5 5.625v1.5c0 .621.504 1.125 1.125 1.125h1.5a3.375 3.375 0 0 1 3.375 3.375M9 15l2.25 2.25L15 12" })));
3354
- PosMakeFindable.style = PosMakeFindableStyle0;
3355
-
3356
- const posNavigationCss = ":host {\n --pos-navigation-bar-height: var(--size-10);\n}\n\nsearch {\n position: relative;\n}\n\n.suggestions ol {\n border: 1px solid var(--pos-border-color);\n display: flex;\n flex-direction: column;\n margin: 0;\n padding: 0;\n list-style-type: none;\n}\n\n.suggestions {\n width: 100%;\n overflow-y: auto;\n max-height: 90dvh;\n li {\n padding: 1rem;\n background-color: var(--pos-background-color);\n pos-rich-link {\n --background-color: inherit;\n }\n &[aria-selected='true'] {\n background-color: var(--pos-primary-color);\n &:hover {\n background-color: var(--pos-primary-color);\n }\n }\n &:hover {\n background-color: var(--pos-border-color);\n }\n }\n}\n\n.suggestions li.selected pos-rich-link {\n --label-color: white;\n --description-color: var(--pos-border-color);\n --uri-color: var(--pos-subtle-text-color);\n}\n\ndialog {\n position: absolute;\n margin-top: calc(-1 * var(--pos-navigation-bar-height));\n padding: 0;\n width: 100%;\n max-width: 100%;\n min-width: 100%;\n overflow: hidden;\n max-height: 100dvh;\n background-color: var(--pos-background-color);\n color: var(--pos-normal-text-color);\n border: var(--pos-border-color);\n border-radius: var(--radius-md);\n box-shadow: var(--shadow-md);\n form {\n display: flex;\n flex-direction: column;\n height: 100%;\n width: 100%;\n align-items: center;\n input {\n display: flex;\n font-size: var(--scale-1);\n height: var(--pos-navigation-bar-height);\n border-top-left-radius: var(--radius-md);\n border-top-right-radius: var(--radius-md);\n padding-left: var(--size-2);\n width: 100%;\n border: none;\n outline: none;\n color: var(--pos-normal-text-color);\n background-color: var(--pos-input-background-color);\n box-sizing: border-box;\n }\n }\n}\n\ndialog[open] {\n display: flex;\n z-index: var(--layer-top);\n animation: slideIn 100ms ease-out;\n}\n\n@media (max-width: 640px) {\n search {\n position: unset;\n }\n dialog {\n margin-top: var(--size-1);\n top: 0;\n width: 95dvw;\n max-width: unset;\n min-width: unset;\n form {\n input {\n height: var(--size-12);\n font-size: var(--scale-fluid-3);\n }\n }\n }\n}\n\n@keyframes fadeIn {\n from {\n opacity: 0;\n }\n to {\n opacity: 1;\n }\n}\n";
3357
- const PosNavigationStyle0 = posNavigationCss;
3358
-
3359
- const PosNavigation = class {
3360
- constructor(hostRef) {
3361
- registerInstance(this, hostRef);
3362
- this.subscribePodOs = createEvent(this, "pod-os:init", 7);
3363
- this.linkEmitter = createEvent(this, "pod-os:link", 7);
3364
- /**
3365
- * Initial value of the navigation bar
3366
- */
3367
- this.uri = '';
3368
- /**
3369
- * Current value of the input field
3370
- */
3371
- this.inputValue = this.uri;
3372
- this.searchIndex = undefined;
3373
- this.suggestions = [];
3374
- this.selectedIndex = -1;
3375
- this.resource = null;
3376
- this.changeEvents = new Subject();
3377
- this.debouncedSearch = null;
3378
- this.receivePodOs = async (os) => {
3379
- this.os = os;
3380
- };
3381
- }
3382
- updateResource() {
3383
- var _a;
3384
- try {
3385
- this.resource = this.uri ? (_a = this.os) === null || _a === void 0 ? void 0 : _a.store.get(this.uri) : null;
3386
- }
3387
- catch (_b) {
3388
- this.resource = null;
3389
- }
3390
- }
3391
- componentWillLoad() {
3392
- subscribePodOs(this);
3393
- this.updateResource();
3394
- store.onChange('isLoggedIn', async (isLoggedIn) => {
3395
- if (isLoggedIn) {
3396
- await this.buildSearchIndex();
3397
- }
3398
- else {
3399
- this.clearSearchIndex();
3400
- }
3401
- });
3402
- this.debouncedSearch = this.changeEvents.pipe(debounceTime(300)).subscribe(() => this.search());
3403
- }
3404
- disconnectedCallback() {
3405
- var _a;
3406
- (_a = this.debouncedSearch) === null || _a === void 0 ? void 0 : _a.unsubscribe();
3407
- }
3408
- async buildSearchIndex() {
3409
- this.searchIndex = await this.os.buildSearchIndex(store.state.profile);
3410
- }
3411
- rebuildSearchIndex() {
3412
- this.searchIndex.rebuild();
3413
- }
3414
- openNavigationDialog(e) {
3415
- var _a, _b;
3416
- this.resource = e.detail;
3417
- if (e.detail) {
3418
- this.inputValue = e.detail.uri;
3419
- this.search();
3420
- }
3421
- (_a = this.inputRef) === null || _a === void 0 ? void 0 : _a.select();
3422
- (_b = this.dialogRef) === null || _b === void 0 ? void 0 : _b.show();
3423
- }
3424
- clearSearchIndex() {
3425
- var _a;
3426
- (_a = this.searchIndex) === null || _a === void 0 ? void 0 : _a.clear();
3427
- }
3428
- onChange(event) {
3429
- this.inputValue = event.target.value;
3430
- this.changeEvents.next();
3431
- }
3432
- closeDialog() {
3433
- var _a;
3434
- (_a = this.dialogRef) === null || _a === void 0 ? void 0 : _a.close();
3435
- this.selectedIndex = -1;
3436
- }
3437
- clearSuggestions() {
3438
- var _a;
3439
- this.suggestions = [];
3440
- (_a = this.dialogRef) === null || _a === void 0 ? void 0 : _a.close();
3441
- this.selectedIndex = -1;
3442
- }
3443
- onClickSelf(event) {
3444
- event.stopPropagation();
3445
- }
3446
- handleKeyDown(ev) {
3447
- if (ev.key === 'Escape') {
3448
- this.closeDialog();
3449
- }
3450
- else if (ev.key === 'ArrowDown') {
3451
- ev.preventDefault();
3452
- this.selectedIndex = Math.min(this.selectedIndex + 1, this.suggestions.length - 1);
3453
- }
3454
- else if (ev.key === 'ArrowUp') {
3455
- ev.preventDefault();
3456
- this.selectedIndex = Math.max(this.selectedIndex - 1, 0);
3457
- }
3458
- }
3459
- search() {
3460
- if (this.searchIndex) {
3461
- this.suggestions = this.inputValue ? this.searchIndex.search(this.inputValue) : [];
3462
- }
3463
- }
3464
- onSubmit() {
3465
- if (this.suggestions && this.selectedIndex > -1) {
3466
- this.linkEmitter.emit(this.suggestions[this.selectedIndex].ref);
3467
- }
3468
- else {
3469
- this.linkEmitter.emit(this.inputValue);
3470
- }
3471
- }
3472
- render() {
3473
- return (h("nav", { key: '311e48ae67c07f4e04bbd0c78ae85103c937a2d6' }, h("search", { key: 'd39bad3a0e6fdd3eabb5fc019fbe9c311dc9adea' }, h("pos-navigation-bar", { key: '032bf46e40d5f857c6ce597f6c43875f054c65e7', searchIndexReady: this.searchIndex !== undefined, current: this.resource }), h("dialog", { key: '5e54d2658efb7b494fc585456e3b7c72782c8938', ref: el => (this.dialogRef = el) }, h("form", { key: '59d12120091dc9f343d006d7e01fde90c1e2e3ea', method: "dialog", onSubmit: () => this.onSubmit() }, h("input", { key: '5d415b87143ab28c8db0a003e235db63305d3094', ref: el => (this.inputRef = el), enterkeyhint: "search", "aria-label": "Search or enter URI", placeholder: "Search or enter URI", value: this.uri, onChange: e => this.onChange(e), onInput: e => this.onChange(e), role: "combobox", "aria-autocomplete": "list", "aria-expanded": this.suggestions.length > 0, "aria-controls": "suggestions-list", "aria-activedescendant": this.selectedIndex >= 0 ? `option-${this.selectedIndex}` : null }), this.suggestions.length > 0 ? (h("div", { class: "suggestions" }, h("ol", { id: "suggestions-list", role: "listbox", "aria-label": "Search results" }, this.suggestions.map((it, index) => (h("li", { id: `option-${index}`, role: "option", "aria-selected": index === this.selectedIndex ? 'true' : 'false' }, h("pos-rich-link", { uri: it.ref }))))))) : null)))));
3474
- }
3475
- static get watchers() { return {
3476
- "uri": ["updateResource"],
3477
- "os": ["updateResource"]
3478
- }; }
3479
- };
3480
- PosNavigation.style = PosNavigationStyle0;
3481
-
3482
- const posNavigationBarCss = "section.current {\n display: flex;\n height: var(--pos-navigation-bar-height);\n flex-grow: 1;\n gap: 0;\n background-color: var(--pos-input-background-color);\n border-radius: var(--radius-md);\n width: 100%;\n &:focus-within {\n outline: var(--pos-input-focus-outline);\n }\n}\n\nsection.current button {\n cursor: pointer;\n font-size: var(--scale-1);\n display: flex;\n align-items: center;\n justify-content: center;\n flex-grow: 1;\n background: none;\n color: var(--pos-normal-text-color);\n outline: none;\n border: none;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n &:focus {\n text-decoration: underline;\n }\n :first-child {\n flex-grow: 1;\n }\n svg {\n width: var(--size-6);\n color: var(--pos-subtle-text-color);\n }\n}\n";
3483
- const PosNavigationBarStyle0 = posNavigationBarCss;
3484
-
3485
- const PosNavigationBar = class {
3486
- constructor(hostRef) {
3487
- registerInstance(this, hostRef);
3488
- this.navigate = createEvent(this, "pod-os:navigate", 7);
3489
- }
3490
- onClick() {
3491
- this.navigate.emit(this.current);
3492
- }
3493
- activate(e) {
3494
- if ((e.ctrlKey || e.metaKey) && e.key === 'k') {
3495
- e.preventDefault();
3496
- this.navigate.emit(this.current);
3497
- }
3498
- }
3499
- render() {
3500
- const ariaLabel = this.current ? `${this.current.label()} (Click to search or enter URI)` : 'Search or enter URI';
3501
- return (h("section", { key: '3bdf8dfb639a32796ffec2e5f8b65d553ea7bf60', class: "current" }, this.current && this.searchIndexReady && h("pos-make-findable", { key: '4cb1e1c567be23d856564e3a7404b1be73cda8d7', uri: this.current.uri }), h("button", { key: '0b29bcc329bc9f5d053ff711109b1c06b368c33e', "aria-label": ariaLabel, onClick: () => this.onClick() }, h("div", { key: '48c7c2f062a87f8e5f7742f5839e351d56ff2c13' }, this.current ? this.current.label() : 'Search or enter URI'), this.icon())));
3502
- }
3503
- icon() {
3504
- return (h("svg", { "aria-hidden": "true", xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", "stroke-width": "1.5", stroke: "currentColor" }, h("path", { "stroke-linecap": "round", "stroke-linejoin": "round", d: "m21 21-5.197-5.197m0 0A7.5 7.5 0 1 0 5.196 5.196a7.5 7.5 0 0 0 10.607 10.607Z" })));
3505
- }
3506
- };
3507
- PosNavigationBar.style = PosNavigationBarStyle0;
3508
-
3509
- const posNewThingFormCss = ":host{display:block}form{display:grid;grid-template-columns:var(--size-16) 1fr;grid-gap:var(--scale-0)}label{grid-column:1 / 2;display:flex;align-items:center;justify-content:flex-end}input,pos-select-term,button{grid-column:2 / 3}input,pos-select-term::part(input){outline:var(--pos-input-outline);padding:var(--scale-000);border:none;border-radius:var(--radius-xs);width:var(--size-full);box-sizing:border-box;background:var(--pos-input-background-color);color:var(--pos-normal-text-color)}input:focus-within,pos-select-term::part(input):focus-within{outline:var(--pos-input-focus-outline)}#new-uri{grid-column:1/3;cursor:default;word-break:break-all;color:var(--pos-normal-text-color);font-weight:var(--weight-light);background:var(--pos-disabled-color);padding:var(--scale-000);border-radius:var(--radius-xs)}input#create{outline:none;box-shadow:var(--shadow-sm);cursor:pointer;color:var(--pos-primary-text-color);background-color:var(--pos-primary-color)}input#create:disabled{cursor:default;color:var(--pos-disabled-text-color);background-color:var(--pos-disabled-color);box-shadow:none}input#create:hover:not(:disabled),input#create:focus{filter:brightness(110%);box-shadow:var(--shadow-md)}";
3510
- const PosNewThingFormStyle0 = posNewThingFormCss;
3511
-
3512
- const PosNewThingForm = class {
3513
- constructor(hostRef) {
3514
- registerInstance(this, hostRef);
3515
- this.linkEmitter = createEvent(this, "pod-os:link", 7);
3516
- this.errorEmitter = createEvent(this, "pod-os:error", 7);
3517
- this.subscribePodOs = createEvent(this, "pod-os:init", 7);
3518
- this.canSubmit = false;
3519
- this.receivePodOs = async (os) => {
3520
- this.os = os;
3521
- };
3522
- }
3523
- validate() {
3524
- this.canSubmit = Boolean(this.name && this.selectedTypeUri);
3525
- }
3526
- componentWillLoad() {
3527
- subscribePodOs(this);
3528
- }
3529
- render() {
3530
- return (h("form", { key: '1091c0db993d79f6d1f0c9ac9003c544b2894709', method: "dialog", onSubmit: e => this.handleSubmit(e) }, h("label", { key: 'cce3f98c89a7e820556e18ea28553774324a01a1', htmlFor: "type" }, "Type"), h("pos-select-term", { key: '72708f95553609006df33b02047421599d0167f0', id: "type", placeholder: "", value: this.selectedTypeUri, "onPod-os:term-selected": e => this.onTermSelected(e) }), h("label", { key: 'a1344f66396ec7b9a0a6a298694f832e62329ce3', htmlFor: "name" }, "Name"), h("input", { key: '5f006bac7be0734dbd39edbad0f30d392bf09bad', id: "name", type: "text", value: this.name, onInput: e => this.handleChange(e) }), this.newUri ? (h("div", { id: "new-uri", title: "This will be the URI of the new thing" }, this.newUri)) : null, h("input", { key: '91c88406fd206ba0211e75d01cca16434fe7f74a', id: "create", type: "submit", value: "Create", disabled: !this.canSubmit })));
3531
- }
3532
- handleChange(event) {
3533
- this.name = event.target.value;
3534
- this.newUri = this.os.proposeUriForNewThing(this.referenceUri, this.name);
3535
- }
3536
- onTermSelected(event) {
3537
- this.selectedTypeUri = event.detail.uri;
3538
- }
3539
- async handleSubmit(event) {
3540
- try {
3541
- await this.os.addNewThing(this.newUri, this.name, this.selectedTypeUri);
3542
- this.linkEmitter.emit(this.newUri);
3543
- this.reset();
3544
- }
3545
- catch (error) {
3546
- event.preventDefault();
3547
- this.errorEmitter.emit(error);
3548
- }
3549
- }
3550
- reset() {
3551
- this.name = '';
3552
- this.newUri = '';
3553
- this.selectedTypeUri = '';
3554
- }
3555
- static get delegatesFocus() { return true; }
3556
- static get watchers() { return {
3557
- "name": ["validate"],
3558
- "selectedTypeUri": ["validate"]
3559
- }; }
3560
- };
3561
- PosNewThingForm.style = PosNewThingFormStyle0;
3562
-
3563
- const posPictureCss = ":host{--width:300px;--height:300px;--border-radius:var(--border-radius, 0);--object-fit:var(--object-fit, cover)}";
3564
- const PosPictureStyle0 = posPictureCss;
3565
-
3566
- const PosPicture = class {
3567
- constructor(hostRef) {
3568
- registerInstance(this, hostRef);
3569
- this.subscribeResource = createEvent(this, "pod-os:resource", 7);
3570
- /**
3571
- * Use a blurred version of the image as its own background, if the image is scaled down to fit into the container.
3572
- */
3573
- this.blurredBackground = false;
3574
- this.receiveResource = (resource) => {
3575
- this.resource = resource;
3576
- };
3577
- }
3578
- componentWillLoad() {
3579
- subscribeResource(this);
3580
- }
3581
- render() {
3582
- const pic = this.resource ? this.resource.picture() : null;
3583
- if (!pic)
3584
- return null;
3585
- return h("pos-image", { blurredBackground: this.blurredBackground, src: pic.url, alt: this.resource.label() });
3586
- }
3587
- };
3588
- PosPicture.style = PosPictureStyle0;
3589
-
3590
- const posResourceCss = "details.error {\n margin: var(--size-2);\n background-color: var(--pos-error-background-color);\n border: var(--size-px) solid var(--pos-error-border-color);\n padding: var(--size-2);\n border-radius: var(--radius-md);\n\n a {\n color: var(--pos-normal-text-color);\n }\n}\n";
3591
- const PosResourceStyle0 = posResourceCss;
3592
-
3593
- const PosResource = class {
3594
- constructor(hostRef) {
3595
- registerInstance(this, hostRef);
3596
- this.subscribePodOs = createEvent(this, "pod-os:init", 7);
3597
- this.resourceLoadedEmitter = createEvent(this, "pod-os:resource-loaded", 7);
3598
- this.consumers = [];
3599
- this.lazy = false;
3600
- this.loading = true;
3601
- this.receivePodOs = async (os) => {
3602
- this.os = os;
3603
- };
3604
- }
3605
- componentWillLoad() {
3606
- store.onChange('isLoggedIn', () => this.loadResource());
3607
- subscribePodOs(this);
3608
- }
3609
- async provideResource(event) {
3610
- event.stopPropagation();
3611
- if (this.resource) {
3612
- event.detail(this.resource);
3613
- }
3614
- this.consumers.push(event);
3615
- }
3616
- async loadResource() {
3617
- await this.getResource(!this.lazy);
3618
- }
3619
- async fetch() {
3620
- await this.getResource(true);
3621
- }
3622
- async getResource(fetch = false) {
3623
- try {
3624
- if (fetch) {
3625
- this.loading = true;
3626
- await this.os.fetch(this.uri);
3627
- this.resourceLoadedEmitter.emit(this.uri);
3628
- }
3629
- this.resource = this.os.store.get(this.uri);
3630
- this.error = null;
3631
- this.consumers.forEach(consumer => {
3632
- consumer.detail(this.resource);
3633
- });
3634
- }
3635
- catch (err) {
3636
- this.error = err;
3637
- }
3638
- finally {
3639
- this.loading = false;
3640
- }
3641
- }
3642
- render() {
3643
- if (this.loading) {
3644
- return h("ion-progress-bar", { type: "indeterminate" });
3645
- }
3646
- if (this.error) {
3647
- return (h("details", { class: "error" }, h("summary", { title: "Click to expand" }, "\u26A0 Sorry, something went wrong"), h("p", null, "Status:",
3648
- // @ts-ignore
3649
- this.error.status), h("p", null, this.error.message), h("p", null, "You can try to open the link outside PodOS: ", h("a", { href: this.uri }, this.uri))));
3650
- }
3651
- return h("slot", null);
3652
- }
3653
- static get watchers() { return {
3654
- "os": ["loadResource"],
3655
- "uri": ["loadResource"]
3656
- }; }
3657
- };
3658
- PosResource.style = PosResourceStyle0;
3659
-
3660
- const posRichLinkCss = ":host {\n --background-color: inherit;\n --label-color: var(--pos-normal-text-color);\n --description-color: var(--pos-normal-text-color);\n --uri-color: var(--pos-subtle-text-color);\n --font-family: var(--font-sans);\n}\n\np.content {\n background-color: var(--background-color);\n line-height: var(--line-xs);\n margin: 0;\n display: flex;\n flex-direction: column;\n align-items: baseline;\n gap: var(--size-1);\n\n .url {\n font-size: var(--scale-fluid-1);\n color: var(--pos-subtle-text-color);\n }\n}\n\na {\n color: var(--label-color);\n max-width: min(100%, var(--prose-lg));\n text-decoration: underline;\n overflow: hidden;\n white-space: nowrap;\n text-overflow: ellipsis;\n text-decoration-thickness: var(--size-px);\n}\n\npos-label {\n color: var(--label-color);\n font-size: var(--scale-fluid-2);\n margin-bottom: var(--size-1);\n}\n\npos-description {\n display: -webkit-box;\n -webkit-box-orient: vertical;\n -webkit-line-clamp: 2;\n text-overflow: ellipsis;\n overflow: hidden;\n font-weight: var(--weight-light);\n color: var(--description-color);\n font-size: var(--scale-fluid-2);\n}\n\n@media (min-width: 640px) {\n pos-label {\n font-size: var(--scale-fluid-0);\n }\n pos-description {\n font-size: var(--scale-fluid-1);\n }\n\n p.content {\n .url {\n font-size: var(--scale-fluid-000);\n }\n }\n}\n";
3661
- const PosRichLinkStyle0 = posRichLinkCss;
3662
-
3663
- const PosRichLink = class {
3664
- constructor(hostRef) {
3665
- registerInstance(this, hostRef);
3666
- this.linkEmitter = createEvent(this, "pod-os:link", 7);
3667
- }
3668
- render() {
3669
- return (h("pos-resource", { key: '95aa9fbc121e27b106845f4c6de96088f7538310', lazy: true, uri: this.uri }, h("p", { key: 'a277291f4c795c7c2e9c9e41ab899fe660ec67a9', class: "content" }, h("a", { key: 'b83e27d371214673bc8fe740573b4b65b2479af8', href: this.uri, onClick: e => {
3670
- e.preventDefault();
3671
- this.linkEmitter.emit(this.uri);
3672
- } }, h("pos-label", { key: '5c4dacc2f5b0dc18664ef5e04bc024efb2547e34' })), h("span", { key: '35cb283d89ce6f631c5e3fde3035244a0374daa0', class: "url" }, new URL(this.uri).host), h("pos-description", { key: '12d5833f05f5759c16d579d5a62742b871ff964f' }))));
3673
- }
3674
- };
3675
- PosRichLink.style = PosRichLinkStyle0;
3676
-
3677
- const appendToMap = (map, propName, value) => {
3678
- const items = map.get(propName);
3679
- if (!items) {
3680
- map.set(propName, [value]);
3681
- }
3682
- else if (!items.includes(value)) {
3683
- items.push(value);
3684
- }
3685
- };
3686
- const debounce = (fn, ms) => {
3687
- let timeoutId;
3688
- return (...args) => {
3689
- if (timeoutId) {
3690
- clearTimeout(timeoutId);
3691
- }
3692
- timeoutId = setTimeout(() => {
3693
- timeoutId = 0;
3694
- fn(...args);
3695
- }, ms);
3696
- };
3697
- };
3698
-
3699
- /**
3700
- * Check if a possible element isConnected.
3701
- * The property might not be there, so we check for it.
3702
- *
3703
- * We want it to return true if isConnected is not a property,
3704
- * otherwise we would remove these elements and would not update.
3705
- *
3706
- * Better leak in Edge than to be useless.
3707
- */
3708
- const isConnected = (maybeElement) => !('isConnected' in maybeElement) || maybeElement.isConnected;
3709
- const cleanupElements = debounce((map) => {
3710
- for (let key of map.keys()) {
3711
- map.set(key, map.get(key).filter(isConnected));
3712
- }
3713
- }, 2000);
3714
- const stencilSubscription = () => {
3715
- if (typeof getRenderingRef !== 'function') {
3716
- // If we are not in a stencil project, we do nothing.
3717
- // This function is not really exported by @stencil/core.
3718
- return {};
3719
- }
3720
- const elmsToUpdate = new Map();
3721
- return {
3722
- dispose: () => elmsToUpdate.clear(),
3723
- get: (propName) => {
3724
- const elm = getRenderingRef();
3725
- if (elm) {
3726
- appendToMap(elmsToUpdate, propName, elm);
3727
- }
3728
- },
3729
- set: (propName) => {
3730
- const elements = elmsToUpdate.get(propName);
3731
- if (elements) {
3732
- elmsToUpdate.set(propName, elements.filter(forceUpdate));
3733
- }
3734
- cleanupElements(elmsToUpdate);
3735
- },
3736
- reset: () => {
3737
- elmsToUpdate.forEach((elms) => elms.forEach(forceUpdate));
3738
- cleanupElements(elmsToUpdate);
3739
- },
3740
- };
3741
- };
3742
-
3743
- const createObservableMap = (defaultState, shouldUpdate = (a, b) => a !== b) => {
3744
- let states = new Map(Object.entries(defaultState !== null && defaultState !== void 0 ? defaultState : {}));
3745
- const handlers = {
3746
- dispose: [],
3747
- get: [],
3748
- set: [],
3749
- reset: [],
3750
- };
3751
- const reset = () => {
3752
- states = new Map(Object.entries(defaultState !== null && defaultState !== void 0 ? defaultState : {}));
3753
- handlers.reset.forEach((cb) => cb());
3754
- };
3755
- const dispose = () => {
3756
- // Call first dispose as resetting the state would
3757
- // cause less updates ;)
3758
- handlers.dispose.forEach((cb) => cb());
3759
- reset();
3760
- };
3761
- const get = (propName) => {
3762
- handlers.get.forEach((cb) => cb(propName));
3763
- return states.get(propName);
3764
- };
3765
- const set = (propName, value) => {
3766
- const oldValue = states.get(propName);
3767
- if (shouldUpdate(value, oldValue, propName)) {
3768
- states.set(propName, value);
3769
- handlers.set.forEach((cb) => cb(propName, value, oldValue));
3770
- }
3771
- };
3772
- const state = (typeof Proxy === 'undefined'
3773
- ? {}
3774
- : new Proxy(defaultState, {
3775
- get(_, propName) {
3776
- return get(propName);
3777
- },
3778
- ownKeys(_) {
3779
- return Array.from(states.keys());
3780
- },
3781
- getOwnPropertyDescriptor() {
3782
- return {
3783
- enumerable: true,
3784
- configurable: true,
3785
- };
3786
- },
3787
- has(_, propName) {
3788
- return states.has(propName);
3789
- },
3790
- set(_, propName, value) {
3791
- set(propName, value);
3792
- return true;
3793
- },
3794
- }));
3795
- const on = (eventName, callback) => {
3796
- handlers[eventName].push(callback);
3797
- return () => {
3798
- removeFromArray(handlers[eventName], callback);
3799
- };
3800
- };
3801
- const onChange = (propName, cb) => {
3802
- const unSet = on('set', (key, newValue) => {
3803
- if (key === propName) {
3804
- cb(newValue);
3805
- }
3806
- });
3807
- const unReset = on('reset', () => cb(defaultState[propName]));
3808
- return () => {
3809
- unSet();
3810
- unReset();
3811
- };
3812
- };
3813
- const use = (...subscriptions) => {
3814
- const unsubs = subscriptions.reduce((unsubs, subscription) => {
3815
- if (subscription.set) {
3816
- unsubs.push(on('set', subscription.set));
3817
- }
3818
- if (subscription.get) {
3819
- unsubs.push(on('get', subscription.get));
3820
- }
3821
- if (subscription.reset) {
3822
- unsubs.push(on('reset', subscription.reset));
3823
- }
3824
- if (subscription.dispose) {
3825
- unsubs.push(on('dispose', subscription.dispose));
3826
- }
3827
- return unsubs;
3828
- }, []);
3829
- return () => unsubs.forEach((unsub) => unsub());
3830
- };
3831
- const forceUpdate = (key) => {
3832
- const oldValue = states.get(key);
3833
- handlers.set.forEach((cb) => cb(key, oldValue, oldValue));
3834
- };
3835
- return {
3836
- state,
3837
- get,
3838
- set,
3839
- on,
3840
- onChange,
3841
- use,
3842
- dispose,
3843
- reset,
3844
- forceUpdate,
3845
- };
3846
- };
3847
- const removeFromArray = (array, item) => {
3848
- const index = array.indexOf(item);
3849
- if (index >= 0) {
3850
- array[index] = array[array.length - 1];
3851
- array.length--;
3852
- }
3853
- };
3854
-
3855
- const createStore = (defaultState, shouldUpdate) => {
3856
- const map = createObservableMap(defaultState, shouldUpdate);
3857
- map.use(stencilSubscription());
3858
- return map;
3859
- };
3860
-
3861
- const createRouter = (opts) => {
3862
- var _a;
3863
- const win = window;
3864
- const url = new URL(win.location.href);
3865
- const parseURL = (_a = opts === null || opts === void 0 ? void 0 : opts.parseURL) !== null && _a !== void 0 ? _a : DEFAULT_PARSE_URL;
3866
- const { state, onChange, dispose } = createStore({
3867
- url,
3868
- activePath: parseURL(url)
3869
- }, (newV, oldV, prop) => {
3870
- if (prop === 'url') {
3871
- return newV.href !== oldV.href;
3872
- }
3873
- return newV !== oldV;
3874
- });
3875
- const push = (href) => {
3876
- history.pushState(null, null, href);
3877
- const url = new URL(href, document.baseURI);
3878
- state.url = url;
3879
- state.activePath = parseURL(url);
3880
- };
3881
- const match = (routes) => {
3882
- const { activePath } = state;
3883
- for (let route of routes) {
3884
- const params = matchPath(activePath, route.path);
3885
- if (params) {
3886
- if (route.to != null) {
3887
- const to = (typeof route.to === 'string')
3888
- ? route.to
3889
- : route.to(activePath);
3890
- push(to);
3891
- return match(routes);
3892
- }
3893
- else {
3894
- return { params, route };
3895
- }
3896
- }
3897
- }
3898
- return undefined;
3899
- };
3900
- const navigationChanged = () => {
3901
- const url = new URL(win.location.href);
3902
- state.url = url;
3903
- state.activePath = parseURL(url);
3904
- };
3905
- const Switch = (_, childrenRoutes) => {
3906
- const result = match(childrenRoutes);
3907
- if (result) {
3908
- if (typeof result.route.jsx === 'function') {
3909
- return result.route.jsx(result.params);
3910
- }
3911
- else {
3912
- return result.route.jsx;
3913
- }
3914
- }
3915
- };
3916
- const disposeRouter = () => {
3917
- win.removeEventListener('popstate', navigationChanged);
3918
- dispose();
3919
- };
3920
- const router = {
3921
- Switch,
3922
- get url() {
3923
- return state.url;
3924
- },
3925
- get activePath() {
3926
- return state.activePath;
3927
- },
3928
- push,
3929
- onChange: onChange,
3930
- dispose: disposeRouter,
3931
- };
3932
- // Initial update
3933
- navigationChanged();
3934
- // Listen URL changes
3935
- win.addEventListener('popstate', navigationChanged);
3936
- return router;
3937
- };
3938
- const matchPath = (pathname, path) => {
3939
- if (typeof path === 'string') {
3940
- if (path === pathname) {
3941
- return {};
3942
- }
3943
- }
3944
- else if (typeof path === 'function') {
3945
- const params = path(pathname);
3946
- if (params) {
3947
- return params === true
3948
- ? {}
3949
- : { ...params };
3950
- }
3951
- }
3952
- else {
3953
- const results = path.exec(pathname);
3954
- if (results) {
3955
- path.lastIndex = 0;
3956
- return { ...results };
3957
- }
3958
- }
3959
- return undefined;
3960
- };
3961
- const DEFAULT_PARSE_URL = (url) => {
3962
- return url.pathname.toLowerCase();
3963
- };
3964
-
3965
- const posRouterCss = ".toolbar{display:flex;flex-direction:row;gap:0;align-items:center;margin-left:0.5rem}pos-navigation{flex-grow:1}";
3966
- const PosRouterStyle0 = posRouterCss;
3967
-
3968
- const Router = createRouter();
3969
- const PosRouter = class {
3970
- constructor(hostRef) {
3971
- registerInstance(this, hostRef);
3972
- this.routeChanged = createEvent(this, "pod-os:route-changed", 7);
3973
- /**
3974
- * The mode defines what default URI will be used, if no URI param is given
3975
- *
3976
- * - standalone: reroute to pod-os:dashboard
3977
- * - pod: reroute to the URI that is shown in the actual browser
3978
- */
3979
- this.mode = 'standalone';
3980
- }
3981
- linkClicked(e) {
3982
- this.navigate(e.detail);
3983
- }
3984
- sessionRestored(e) {
3985
- Router.push(e.detail.url);
3986
- }
3987
- componentWillLoad() {
3988
- this.updateUri();
3989
- Router.onChange('url', () => {
3990
- this.updateUri();
3991
- });
3992
- }
3993
- navigate(uri) {
3994
- Router.push('?uri=' + encodeURIComponent(uri));
3995
- }
3996
- updateUri() {
3997
- this.uri =
3998
- new URLSearchParams(window.location.search).get('uri') ||
3999
- (this.mode === 'standalone' ? 'pod-os:dashboard' : window.location.href);
4000
- this.routeChanged.emit(this.uri);
4001
- }
4002
- render() {
4003
- return h("slot", { key: '2775fc2835158ccd8d540e4f27edfd497eafe7a9' });
4004
- }
4005
- };
4006
- PosRouter.style = PosRouterStyle0;
4007
-
4008
- const posSelectTermCss = ":host{display:block}input{background-color:transparent;color:var(--pos-normal-text-color);border:none;padding-top:1rem;padding-bottom:1rem}input:focus{outline:none}";
4009
- const PosSelectTermStyle0 = posSelectTermCss;
4010
-
4011
- const PosSelectTerm = class {
4012
- constructor(hostRef) {
4013
- registerInstance(this, hostRef);
4014
- this.subscribePodOs = createEvent(this, "pod-os:init", 7);
4015
- this.termSelected = createEvent(this, "pod-os:term-selected", 7);
4016
- this.placeholder = 'Type to search...';
4017
- this.value = '';
4018
- this.terms = [];
4019
- this.receivePodOs = async (os) => {
4020
- this.os = os;
4021
- };
4022
- }
4023
- componentWillLoad() {
4024
- subscribePodOs(this);
4025
- }
4026
- setTerms() {
4027
- this.terms = this.os.listKnownTerms();
4028
- }
4029
- handleChange(event) {
4030
- this.termSelected.emit({ uri: event.target.value });
4031
- }
4032
- render() {
4033
- return (h(Host, { key: '87e4eddf409058ee5fc4c3da0d26f06b10814baa' }, h("input", { key: 'b7c3c9644cfd438806263a1f5cc721f8409cfe45', part: "input", list: "terms", placeholder: this.placeholder, value: this.value, onChange: ev => this.handleChange(ev) }), h("datalist", { key: '834ad0a974db76a5295501ba7231bd190d57b98b', part: "terms", id: "terms" }, this.terms.map(term => (h("option", { value: term.uri }, term.shorthand))))));
4034
- }
4035
- static get delegatesFocus() { return true; }
4036
- static get watchers() { return {
4037
- "os": ["setTerms"]
4038
- }; }
4039
- };
4040
- PosSelectTerm.style = PosSelectTermStyle0;
4041
-
4042
- const posSettingOfflineCacheCss = ":host{border:var(--size-px) solid var(--pos-border-color);border-radius:var(--radius-lg);box-shadow:var(--shadow-md);padding:var(--size-8);max-width:var(--size-96);background:var(--pos-card-background)}svg{width:var(--size-8)}h2{display:flex;align-items:center}p{padding:var(--size-2)}.info{color:var(--color-grey-900);background-color:var(--color-blue-200)}.warn{color:var(--color-grey-900);background-color:var(--color-yellow-200)}";
4043
- const PosSettingOfflineCacheStyle0 = posSettingOfflineCacheCss;
4044
-
4045
- const PosSettingOfflineCache = class {
4046
- constructor(hostRef) {
4047
- registerInstance(this, hostRef);
4048
- }
4049
- render() {
4050
- return (h(Host, { key: 'b598a0dbe21fe9e7f1aa0f51f0b53c270feb8add' }, h("div", { key: '5cec10cc63203c8421bbb627643f1365899cc850' }, h("h2", { key: '094528da7d8567e8a2ba6e82fb1c05b2f4dc7b22' }, h("svg", { key: '3d3e8b17420ba7352877eb1c6bca17d3791b1bd6', xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", "stroke-width": "1.5", stroke: "currentColor" }, h("path", { key: '065bc78382b03bd2bcc3c812a71e9f27c4e3251c', "stroke-linecap": "round", "stroke-linejoin": "round", d: "M20.25 6.375c0 2.278-3.694 4.125-8.25 4.125S3.75 8.653 3.75 6.375m16.5 0c0-2.278-3.694-4.125-8.25-4.125S3.75 4.097 3.75 6.375m16.5 0v11.25c0 2.278-3.694 4.125-8.25 4.125s-8.25-1.847-8.25-4.125V6.375m16.5 0v3.75m-16.5-3.75v3.75m16.5 0v3.75C20.25 16.153 16.556 18 12 18s-8.25-1.847-8.25-4.125v-3.75m16.5 0c0 2.278-3.694 4.125-8.25 4.125s-8.25-1.847-8.25-4.125" })), "Cache Settings"), h("p", { key: '5e5d2ec497039791f82a857a709157e6b97efdfe', class: "info" }, "\u2139 Enable offline cache to be able to access previously loaded data while offline."), h("p", { key: 'd4ff4a3a17df1e5ed7ce076abbf98def4ebdac7d', class: "warn" }, "\u26A0 Private data may be stored on this device. Only enable it, if you trust this device."), h("label", { key: '1d1aa4f7b4b5fa53080cc5635a20ccee3faee29d' }, h("input", { key: '4223888802ea51dec26a3d23abdd9c28098de5aa', type: "checkbox", checked: localSettings.state.offlineCache, onChange: ev => (localSettings.state.offlineCache = ev.target.checked) }), "Enable offline cache"))));
4051
- }
4052
- };
4053
- PosSettingOfflineCache.style = PosSettingOfflineCacheStyle0;
4054
-
4055
- var AvailableApps;
4056
- (function (AvailableApps) {
4057
- AvailableApps["Generic"] = "pos-app-generic";
4058
- AvailableApps["RdfDocument"] = "pos-app-rdf-document";
4059
- AvailableApps["DocumentViewer"] = "pos-app-document-viewer";
4060
- AvailableApps["ImageViewer"] = "pos-app-image-viewer";
4061
- AvailableApps["LdpContainer"] = "pos-app-ldp-container";
4062
- })(AvailableApps || (AvailableApps = {}));
4063
- // TODO: remove duplication with pos-container-contents/selectIconForTypes
4064
- function containsType(types, typeUri) {
4065
- return types.some(type => type.uri === typeUri);
4066
- }
4067
- function selectAppForTypes(types) {
4068
- if (containsType(types, 'http://www.w3.org/ns/ldp#Container')) {
4069
- return AvailableApps.LdpContainer;
4070
- }
4071
- else if (containsType(types, 'http://www.w3.org/2007/ont/link#RDFDocument')) {
4072
- return AvailableApps.RdfDocument;
4073
- }
4074
- else if (containsType(types, 'http://www.w3.org/ns/iana/media-types/application/pdf#Resource')) {
4075
- return AvailableApps.DocumentViewer;
4076
- }
4077
- else if (containsType(types, 'http://purl.org/dc/terms/Image')) {
4078
- return AvailableApps.ImageViewer;
4079
- }
4080
- else if (containsType(types, 'http://www.w3.org/2007/ont/link#Document')) {
4081
- return AvailableApps.DocumentViewer;
4082
- }
4083
- else {
4084
- return AvailableApps.Generic;
4085
- }
4086
- }
4087
-
4088
- const PosTypeRouter = class {
4089
- constructor(hostRef) {
4090
- registerInstance(this, hostRef);
4091
- this.subscribeResource = createEvent(this, "pod-os:resource", 7);
4092
- this.receiveResource = (resource) => {
4093
- this.types = resource.types();
4094
- };
4095
- }
4096
- componentWillLoad() {
4097
- subscribeResource(this);
4098
- }
4099
- render() {
4100
- return this.types ? this.renderApp() : null;
4101
- }
4102
- renderApp() {
4103
- const App = selectAppForTypes(this.types);
4104
- return h(App, null);
4105
- }
4106
- };
4107
-
4108
- export { Icon as ion_icon, ProgressBar as ion_progress_bar, RippleEffect as ion_ripple_effect, SkeletonText as ion_skeleton_text, Toast as ion_toast, PosAddNewThing as pos_add_new_thing, PosApp as pos_app, PosAppBrowser as pos_app_browser, PosAppDashboard as pos_app_dashboard, PosAppSettings as pos_app_settings, PosDescription as pos_description, PosDialog as pos_dialog, PosErrorToast as pos_error_toast, PosExampleResources as pos_example_resources, PosGettingStarted as pos_getting_started, PosImage as pos_image, PosInternalRouter as pos_internal_router, PosLabel as pos_label, PosLogin as pos_login, PosLoginForm as pos_login_form, PosMakeFindable as pos_make_findable, PosNavigation as pos_navigation, PosNavigationBar as pos_navigation_bar, PosNewThingForm as pos_new_thing_form, PosPicture as pos_picture, PosResource as pos_resource, PosRichLink as pos_rich_link, PosRouter as pos_router, PosSelectTerm as pos_select_term, PosSettingOfflineCache as pos_setting_offline_cache, PosTypeRouter as pos_type_router };
4109
-
4110
- //# sourceMappingURL=ion-icon_31.entry.js.map