@digital-realty/ui-knowledgebase 0.1.2 → 0.1.3
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.
- package/README.md +45 -25
- package/dist/ui-knowledgebase.js +11 -9
- package/package.json +8 -4
package/README.md
CHANGED
|
@@ -9,8 +9,8 @@ component and API-integration tickets as we define them.
|
|
|
9
9
|
**Component approach:** self-contained components per content type / Post `behavior`
|
|
10
10
|
(mirroring v1: `kb-post-text`, `kb-post-accordion`, `kb-post-video-card`,
|
|
11
11
|
`kb-post-document-card`, `kb-category-tile`, `kb-topic-tile`, …) rather than reusable
|
|
12
|
-
atoms — favouring fast, easy-to-follow code.
|
|
13
|
-
(KB-2),
|
|
12
|
+
atoms — favouring fast, easy-to-follow code. Post bodies are the one shared concern: the API
|
|
13
|
+
client sanitizes them centrally (KB-2), so components just render the ready-made `post.body`.
|
|
14
14
|
|
|
15
15
|
## Page component maps
|
|
16
16
|
|
|
@@ -103,9 +103,11 @@ _UAT reference: the sanitized HTML body (paragraph, list, PDF link) inside an ex
|
|
|
103
103
|
**Type:** Story
|
|
104
104
|
|
|
105
105
|
**Summary**
|
|
106
|
-
Render a post's `text` field (raw CKEditor HTML from Strapi) safely. A
|
|
107
|
-
|
|
108
|
-
|
|
106
|
+
Render a post's `text` field (raw CKEditor HTML from Strapi) safely. A generic sanitizer and
|
|
107
|
+
a separate URL rewriter are composed by `toSafeHtml()`, which the **API client calls while
|
|
108
|
+
normalizing** — so a post exposes a ready-to-render, already-sanitized `body` (a Lit
|
|
109
|
+
`TemplateResult`) and the raw HTML string never reaches views. Sanitization is therefore
|
|
110
|
+
enforced by construction, not by every view remembering to call a helper.
|
|
109
111
|
|
|
110
112
|
**Background**
|
|
111
113
|
The legacy frontend did **no** sanitization — it injected the HTML directly (or parsed it
|
|
@@ -113,21 +115,29 @@ with `html-react-parser`, which only rewrote anchors/images). It got away with t
|
|
|
113
115
|
it ran in a separate-origin iframe. This MFE runs in the portal's own origin, so unsafe HTML
|
|
114
116
|
could run with portal privileges. The `text` HTML also contains messy pasted-Word markup and
|
|
115
117
|
inline `/uploads/...` links. GPv1 already wrapped rendering in a reused `RawHtml` component;
|
|
116
|
-
we
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
118
|
+
we go further: because a view-level helper is opt-in (a developer can forget it and inject the
|
|
119
|
+
raw string), we sanitize in the data layer so the unsafe string is never exposed at all.
|
|
120
|
+
|
|
121
|
+
**Scope** — sanitization and URL rewriting are **two separate functions** (the sanitizer is
|
|
122
|
+
kept generic so it can later be extracted into a shared package for other MFEs):
|
|
123
|
+
|
|
124
|
+
- `sanitize(html): string` — generic DOMPurify sanitizer (allowlist tolerant of legacy Word
|
|
125
|
+
markup). **Self-contained**: depends only on DOMPurify, no app/media logic. Candidate for
|
|
126
|
+
extraction to a shared lib.
|
|
127
|
+
- `rewriteMediaUrls(html, mediaBase): string` — KB-specific; runs on the sanitized output.
|
|
128
|
+
Resolves relative `/uploads/...` on `<a href>` / `<img src>` against the media base, and
|
|
129
|
+
gives off-origin links (media downloads, external sites) `target="_blank" rel="noopener noreferrer"`.
|
|
124
130
|
(Ports the URL logic from GPv1's `renderTextAsJsx`; the old `/api/files?url=` proxy is dropped.)
|
|
125
|
-
-
|
|
126
|
-
the single place `unsafeHTML` is used.
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
+
- `toSafeHtml(html, mediaBase): TemplateResult` — composes `sanitize` then `rewriteMediaUrls`
|
|
132
|
+
and wraps the result in `unsafeHTML(...)` (the single place `unsafeHTML` is used). The **API
|
|
133
|
+
client calls this while normalizing**, so `KbPost` exposes `body: TemplateResult` instead of a
|
|
134
|
+
raw `text: string`. Views interpolate it directly into an element of their choosing — no
|
|
135
|
+
wrapper is imposed, so the view controls the tag and the content inherits its styles:
|
|
136
|
+
`html\`<article>${post.body}</article>\``. Because the client never returns the raw HTML,
|
|
137
|
+
there is no unsanitized string a view could accidentally inject; the sanitizer, applied in the
|
|
138
|
+
data layer, is the security control. (Trade-off accepted: the API layer now depends on Lit and
|
|
139
|
+
needs a DOM at fetch time — fine for a browser MFE, and the generic `sanitize()` stays a pure
|
|
140
|
+
string→string function so it remains extractable to a shared package.)
|
|
131
141
|
|
|
132
142
|
**Out of scope**
|
|
133
143
|
|
|
@@ -140,6 +150,16 @@ we mirror that and add the missing sanitize step.
|
|
|
140
150
|
- External links open in a new tab with `rel="noopener noreferrer"`.
|
|
141
151
|
- Representative legacy content (incl. the pasted-Word Terms & Conditions post) renders without breaking layout.
|
|
142
152
|
|
|
153
|
+
**Implemented:** `src/rich-text/` — `sanitize.ts` (generic, DOMPurify-only), `rewrite-media-urls.ts`
|
|
154
|
+
(KB-specific, DOMParser-based; media resolution moved to `src/api/media-url.ts` to break the
|
|
155
|
+
normalize↔rich-text cycle), `to-safe-html.ts` (`toSafeHtml()` composing them into a sanitized
|
|
156
|
+
`TemplateResult`), `index.ts`. The client's `normalizePost` calls `toSafeHtml`, so `KbPost.body`
|
|
157
|
+
is sanitized at the source. Added `dompurify` dependency. Vitest tests under `test/rich-text/`
|
|
158
|
+
(jsdom): `toSafeHtml` projects sanitized content into the parent tag with no wrapper, strips
|
|
159
|
+
scripts/handlers (not executed), rewrites `/uploads`, and hardens off-origin links; plus a
|
|
160
|
+
sanitize test for the pasted-Word markup.
|
|
161
|
+
Typechecks clean, prettier green.
|
|
162
|
+
|
|
143
163
|
**Dependencies**
|
|
144
164
|
|
|
145
165
|
- KB-1 (media base URL / normalized models).
|
|
@@ -269,7 +289,7 @@ Post renderer for `behavior = text` (article-style body).
|
|
|
269
289
|
|
|
270
290
|
**Data:** `title`, `dateAdded`, `topics`, `text`.
|
|
271
291
|
|
|
272
|
-
**Renders:** title, date, topic chips, and
|
|
292
|
+
**Renders:** title, date, topic chips, and the sanitized `post.body`.
|
|
273
293
|
|
|
274
294
|
**Dependencies:** KB-1, KB-2.
|
|
275
295
|
|
|
@@ -285,7 +305,7 @@ Post renderer for `behavior = accordion` (used by FAQ categories).
|
|
|
285
305
|
|
|
286
306
|
**Data:** `title`, `text`.
|
|
287
307
|
|
|
288
|
-
**Renders:** an accordion item — title as the header,
|
|
308
|
+
**Renders:** an accordion item — title as the header, the sanitized `post.body` in the expandable panel (may use `ix-accordion`).
|
|
289
309
|
|
|
290
310
|
**Dependencies:** KB-1, KB-2.
|
|
291
311
|
|
|
@@ -301,7 +321,7 @@ Post renderer for `behavior = video_card`.
|
|
|
301
321
|
|
|
302
322
|
**Data:** `title`, `topics`, `thumbnail`, `video`, `duration`, `text`.
|
|
303
323
|
|
|
304
|
-
**Renders:** card with video thumbnail + duration and a play action that opens the video; title, topic chips, and
|
|
324
|
+
**Renders:** card with video thumbnail + duration and a play action that opens the video; title, topic chips, and the sanitized `post.body`.
|
|
305
325
|
|
|
306
326
|
**Dependencies:** KB-1, KB-2 (video player/embed is part of this component).
|
|
307
327
|
|
|
@@ -317,7 +337,7 @@ Post renderer for `behavior = document_card`.
|
|
|
317
337
|
|
|
318
338
|
**Data:** `title`, `topics`, `documents[]`, `text`.
|
|
319
339
|
|
|
320
|
-
**Renders:** card with title, topic chips,
|
|
340
|
+
**Renders:** card with title, topic chips, the sanitized `post.body`, and a list of downloadable document links from `documents[]`.
|
|
321
341
|
|
|
322
342
|
**Dependencies:** KB-1, KB-2.
|
|
323
343
|
|
|
@@ -409,7 +429,7 @@ launchpad widget depend on it.
|
|
|
409
429
|
**Scope**
|
|
410
430
|
|
|
411
431
|
- A Lit route view at `/details/:uid` calling `StrapiClient.getPost(uid)` (KB-1).
|
|
412
|
-
- Render: title, topic chips, `dateAdded`,
|
|
432
|
+
- Render: title, topic chips, `dateAdded`, the sanitized `post.body` (KB-2),
|
|
413
433
|
the `video` if present, and the `documents[]` as downloadable links.
|
|
414
434
|
- Loading, not-found (bad uid), and error states.
|
|
415
435
|
|
|
@@ -420,7 +440,7 @@ launchpad widget depend on it.
|
|
|
420
440
|
**Acceptance criteria**
|
|
421
441
|
|
|
422
442
|
- A post renders its title, body, and any video/documents.
|
|
423
|
-
- Body
|
|
443
|
+
- Body renders from the client-sanitized `post.body` (KB-2) and media links resolve.
|
|
424
444
|
- An unknown `uid` shows a not-found state, not a blank page.
|
|
425
445
|
|
|
426
446
|
**Dependencies:** KB-1, KB-2.
|
package/dist/ui-knowledgebase.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import{LitElement as e,css as t,html as n,nothing as r}from"lit";import{customElement as i,property as a,state as o}from"lit/decorators.js";import{Router as s}from"@vaadin/router";var
|
|
1
|
+
import{LitElement as e,css as t,html as n,nothing as r}from"lit";import{customElement as i,property as a,state as o}from"lit/decorators.js";import{Router as s}from"@vaadin/router";import{unsafeHTML as c}from"lit/directives/unsafe-html.js";var l=null;function u(e,t,n){l=new s(e,{baseUrl:t}),l.setRoutes(n)}function d(){return l}function f(){l?.unsubscribe(),l?.removeRoutes(),l=null}function p(e,t,n){if(e!=null){if(Array.isArray(e)){e.forEach((e,r)=>p(e,`${t}[${r}]`,n));return}if(typeof e==`object`){for(let[r,i]of Object.entries(e))i!==void 0&&p(i,`${t}[${r}]`,n);return}n.push(`${encodeURIComponent(t)}=${encodeURIComponent(String(e))}`)}}function ee(e){let t=[];for(let[n,r]of Object.entries(e))r!==void 0&&p(r,n,t);return t.length?`?${t.join(`&`)}`:``}function te(e,t){return e?/^https?:\/\//i.test(e)?e:`${t.replace(/\/+$/,``)}${e.startsWith(`/`)?e:`/${e}`}`:``}function m(e,t){this.v=e,this.k=t}function h(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function ne(e){if(Array.isArray(e))return e}function re(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function g(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
2
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function _(e,t){return ne(e)||re(e,t)||ie(e,t)||g()}function ie(e,t){if(e){if(typeof e==`string`)return h(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?h(e,t):void 0}}function v(e){var t,n;function r(t,n){try{var a=e[t](n),o=a.value,s=o instanceof m;Promise.resolve(s?o.v:o).then(function(n){if(s){var c=t===`return`&&o.k?t:`next`;if(!o.k||n.done)return r(c,n);n=e[c](n).value}i(!!a.done,n)},function(e){r(`throw`,e)})}catch(e){i(2,e)}}function i(e,i){e===2?t.reject(i):t.resolve({value:i,done:e}),(t=t.next)?r(t.key,t.arg):n=null}this._invoke=function(e,i){return new Promise(function(a,o){var s={key:e,arg:i,resolve:a,reject:o,next:null};n?n=n.next=s:(t=n=s,r(e,i))})},typeof e.return!=`function`&&(this.return=void 0)}v.prototype[typeof Symbol==`function`&&Symbol.asyncIterator||`@@asyncIterator`]=function(){return this},v.prototype.next=function(e){return this._invoke(`next`,e)},v.prototype.throw=function(e){return this._invoke(`throw`,e)},v.prototype.return=function(e){return this._invoke(`return`,e)};var ae=Object.entries,oe=Object.setPrototypeOf,y=Object.isFrozen,b=Object.getPrototypeOf,se=Object.getOwnPropertyDescriptor,x=Object.freeze,S=Object.seal,ce=Object.create,le=typeof Reflect<`u`&&Reflect,C=le.apply,ue=le.construct;x||=function(e){return e},S||=function(e){return e},C||=function(e,t){var n=[...arguments].slice(2);return e.apply(t,n)},ue||=function(e){return new e(...[...arguments].slice(1))};var w=A(Array.prototype.forEach);Array.prototype.indexOf;var de=A(Array.prototype.lastIndexOf),fe=A(Array.prototype.pop),pe=A(Array.prototype.push);Array.prototype.slice;var me=A(Array.prototype.splice),he=Array.isArray,ge=A(String.prototype.toLowerCase),_e=A(String.prototype.toString),ve=A(String.prototype.match),ye=A(String.prototype.replace),be=A(String.prototype.indexOf),xe=A(String.prototype.trim),T=A(Number.prototype.toString),Se=A(Boolean.prototype.toString),Ce=typeof BigInt>`u`?null:A(BigInt.prototype.toString),we=typeof Symbol>`u`?null:A(Symbol.prototype.toString),E=A(Object.prototype.hasOwnProperty),D=A(Object.prototype.toString),O=A(RegExp.prototype.test),k=Te(TypeError);function A(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);var n=[...arguments].slice(1);return C(e,t,n)}}function Te(e){return function(){return ue(e,[...arguments])}}function j(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:ge;if(oe&&oe(e,null),!he(t))return e;let r=t.length;for(;r--;){let i=t[r];if(typeof i==`string`){let e=n(i);e!==i&&(y(t)||(t[r]=e),i=e)}e[i]=!0}return e}function Ee(e){for(let t=0;t<e.length;t++)E(e,t)||(e[t]=null);return e}function M(e){let t=ce(null);for(let r of ae(e)){var n=_(r,2);let i=n[0],a=n[1];E(e,i)&&(t[i]=he(a)?Ee(a):a&&typeof a==`object`&&a.constructor===Object?M(a):a)}return t}function De(e){switch(typeof e){case`string`:return e;case`number`:return T(e);case`boolean`:return Se(e);case`bigint`:return Ce?Ce(e):`0`;case`symbol`:return we?we(e):`Symbol()`;case`undefined`:return D(e);case`function`:case`object`:{if(e===null)return D(e);let t=e,n=N(t,`toString`);if(typeof n==`function`){let e=n(t);return typeof e==`string`?e:D(e)}return D(e)}default:return D(e)}}function N(e,t){for(;e!==null;){let n=se(e,t);if(n){if(n.get)return A(n.get);if(typeof n.value==`function`)return A(n.value)}e=b(e)}function n(){return null}return n}function Oe(e){try{return O(e,``),!0}catch{return!1}}var ke=x(`a.abbr.acronym.address.area.article.aside.audio.b.bdi.bdo.big.blink.blockquote.body.br.button.canvas.caption.center.cite.code.col.colgroup.content.data.datalist.dd.decorator.del.details.dfn.dialog.dir.div.dl.dt.element.em.fieldset.figcaption.figure.font.footer.form.h1.h2.h3.h4.h5.h6.head.header.hgroup.hr.html.i.img.input.ins.kbd.label.legend.li.main.map.mark.marquee.menu.menuitem.meter.nav.nobr.ol.optgroup.option.output.p.picture.pre.progress.q.rp.rt.ruby.s.samp.search.section.select.shadow.slot.small.source.spacer.span.strike.strong.style.sub.summary.sup.table.tbody.td.template.textarea.tfoot.th.thead.time.tr.track.tt.u.ul.var.video.wbr`.split(`.`)),Ae=x(`svg.a.altglyph.altglyphdef.altglyphitem.animatecolor.animatemotion.animatetransform.circle.clippath.defs.desc.ellipse.enterkeyhint.exportparts.filter.font.g.glyph.glyphref.hkern.image.inputmode.line.lineargradient.marker.mask.metadata.mpath.part.path.pattern.polygon.polyline.radialgradient.rect.stop.style.switch.symbol.text.textpath.title.tref.tspan.view.vkern`.split(`.`)),je=x([`feBlend`,`feColorMatrix`,`feComponentTransfer`,`feComposite`,`feConvolveMatrix`,`feDiffuseLighting`,`feDisplacementMap`,`feDistantLight`,`feDropShadow`,`feFlood`,`feFuncA`,`feFuncB`,`feFuncG`,`feFuncR`,`feGaussianBlur`,`feImage`,`feMerge`,`feMergeNode`,`feMorphology`,`feOffset`,`fePointLight`,`feSpecularLighting`,`feSpotLight`,`feTile`,`feTurbulence`]),Me=x([`animate`,`color-profile`,`cursor`,`discard`,`font-face`,`font-face-format`,`font-face-name`,`font-face-src`,`font-face-uri`,`foreignobject`,`hatch`,`hatchpath`,`mesh`,`meshgradient`,`meshpatch`,`meshrow`,`missing-glyph`,`script`,`set`,`solidcolor`,`unknown`,`use`]),Ne=x(`math.menclose.merror.mfenced.mfrac.mglyph.mi.mlabeledtr.mmultiscripts.mn.mo.mover.mpadded.mphantom.mroot.mrow.ms.mspace.msqrt.mstyle.msub.msup.msubsup.mtable.mtd.mtext.mtr.munder.munderover.mprescripts`.split(`.`)),Pe=x([`maction`,`maligngroup`,`malignmark`,`mlongdiv`,`mscarries`,`mscarry`,`msgroup`,`mstack`,`msline`,`msrow`,`semantics`,`annotation`,`annotation-xml`,`mprescripts`,`none`]),Fe=x([`#text`]),Ie=x(`accept.action.align.alt.autocapitalize.autocomplete.autopictureinpicture.autoplay.background.bgcolor.border.capture.cellpadding.cellspacing.checked.cite.class.clear.color.cols.colspan.command.commandfor.controls.controlslist.coords.crossorigin.datetime.decoding.default.dir.disabled.disablepictureinpicture.disableremoteplayback.download.draggable.enctype.enterkeyhint.exportparts.face.for.headers.height.hidden.high.href.hreflang.id.inert.inputmode.integrity.ismap.kind.label.lang.list.loading.loop.low.max.maxlength.media.method.min.minlength.multiple.muted.name.nonce.noshade.novalidate.nowrap.open.optimum.part.pattern.placeholder.playsinline.popover.popovertarget.popovertargetaction.poster.preload.pubdate.radiogroup.readonly.rel.required.rev.reversed.role.rows.rowspan.spellcheck.scope.selected.shape.size.sizes.slot.span.srclang.start.src.srcset.step.style.summary.tabindex.title.translate.type.usemap.valign.value.width.wrap.xmlns`.split(`.`)),Le=x(`accent-height.accumulate.additive.alignment-baseline.amplitude.ascent.attributename.attributetype.azimuth.basefrequency.baseline-shift.begin.bias.by.class.clip.clippathunits.clip-path.clip-rule.color.color-interpolation.color-interpolation-filters.color-profile.color-rendering.cx.cy.d.dx.dy.diffuseconstant.direction.display.divisor.dominant-baseline.dur.edgemode.elevation.end.exponent.fill.fill-opacity.fill-rule.filter.filterunits.flood-color.flood-opacity.font-family.font-size.font-size-adjust.font-stretch.font-style.font-variant.font-weight.fx.fy.g1.g2.glyph-name.glyphref.gradientunits.gradienttransform.height.href.id.image-rendering.in.in2.intercept.k.k1.k2.k3.k4.kerning.keypoints.keysplines.keytimes.lang.lengthadjust.letter-spacing.kernelmatrix.kernelunitlength.lighting-color.local.marker-end.marker-mid.marker-start.markerheight.markerunits.markerwidth.maskcontentunits.maskunits.max.mask.mask-type.media.method.mode.min.name.numoctaves.offset.operator.opacity.order.orient.orientation.origin.overflow.paint-order.path.pathlength.patterncontentunits.patterntransform.patternunits.pointer-events.points.preservealpha.preserveaspectratio.primitiveunits.r.rx.ry.radius.refx.refy.repeatcount.repeatdur.restart.result.rotate.scale.seed.shape-rendering.slope.specularconstant.specularexponent.spreadmethod.startoffset.stddeviation.stitchtiles.stop-color.stop-opacity.stroke-dasharray.stroke-dashoffset.stroke-linecap.stroke-linejoin.stroke-miterlimit.stroke-opacity.stroke.stroke-width.style.surfacescale.systemlanguage.tabindex.tablevalues.targetx.targety.transform.transform-origin.text-anchor.text-decoration.text-orientation.text-rendering.textlength.type.u1.u2.unicode.values.vector-effect.viewbox.visibility.version.vert-adv-y.vert-origin-x.vert-origin-y.width.word-spacing.wrap.writing-mode.xchannelselector.ychannelselector.x.x1.x2.xmlns.y.y1.y2.z.zoomandpan`.split(`.`)),Re=x(`accent.accentunder.align.bevelled.close.columnalign.columnlines.columnspacing.columnspan.denomalign.depth.dir.display.displaystyle.encoding.fence.frame.height.href.id.largeop.length.linethickness.lquote.lspace.mathbackground.mathcolor.mathsize.mathvariant.maxsize.minsize.movablelimits.notation.numalign.open.rowalign.rowlines.rowspacing.rowspan.rspace.rquote.scriptlevel.scriptminsize.scriptsizemultiplier.selection.separator.separators.stretchy.subscriptshift.supscriptshift.symmetric.voffset.width.xmlns`.split(`.`)),ze=x([`xlink:href`,`xml:id`,`xlink:title`,`xml:space`,`xmlns:xlink`]),Be=S(/{{[\w\W]*|^[\w\W]*}}/g),Ve=S(/<%[\w\W]*|^[\w\W]*%>/g),He=S(/\${[\w\W]*/g),Ue=S(/^data-[\-\w.\u00B7-\uFFFF]+$/),We=S(/^aria-[\-\w]+$/),Ge=S(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Ke=S(/^(?:\w+script|data):/i),qe=S(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Je=S(/^html$/i),Ye=S(/^[a-z][.\w]*(-[.\w]+)+$/i),Xe=S(/<[/\w!]/g),Ze=S(/<[/\w]/g),Qe=S(/<\/no(script|embed|frames)/i),$e=S(/\/>/i),P={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},et=[`style`,`script`,`xmp`,`iframe`,`noembed`,`noframes`,`plaintext`,`noscript`],tt=x(j({},et)),nt=function(){let e={};return w(et,t=>{e[t]=S(RegExp(`</`+t+`(?=[\\t\\n\\f\\r />])`,`i`))}),x(e)}(),rt=function(){return typeof window>`u`?null:window},it=function(e,t){if(typeof e!=`object`||typeof e.createPolicy!=`function`)return null;let n=null,r=`data-tt-policy-suffix`;t&&t.hasAttribute(r)&&(n=t.getAttribute(r));let i=`dompurify`+(n?`#`+n:``);try{return e.createPolicy(i,{createHTML(e){return e},createScriptURL(e){return e}})}catch{return console.warn(`TrustedTypes policy `+i+` could not be created.`),null}},at=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},F=function(e,t,n,r){return E(e,t)&&he(e[t])?j(r.base?M(r.base):{},e[t],r.transform):n},ot=function(e,t,n){let r=E(e,t)?e[t]:void 0;return r&&typeof r==`object`?M(r):n()};function st(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:rt(),t=e=>st(e);if(t.version=`3.4.16`,t.removed=[],!e||!e.document||e.document.nodeType!==P.document||!e.Element)return t.isSupported=!1,t;let n=e.document,r=n,i=r.currentScript;e.DocumentFragment;let a=e.HTMLTemplateElement,o=e.Node,s=e.Element,c=e.NodeFilter;e.NamedNodeMap===void 0&&(e.NamedNodeMap||e.MozNamedAttrMap),e.HTMLFormElement;let l=e.DOMParser,u=e.trustedTypes,d=s.prototype,f=N(d,`cloneNode`),p=N(d,`remove`),ee=N(d,`removeAttributeNode`),te=N(d,`nextSibling`),m=N(d,`childNodes`),h=N(d,`parentNode`),ne=N(d,`shadowRoot`),re=N(d,`attributes`),g=o&&o.prototype?N(o.prototype,`nodeType`):null,_=o&&o.prototype?N(o.prototype,`nodeName`):null,ie=o&&o.prototype?N(o.prototype,`ownerDocument`):null,v=function(e){return g?g(e):e.nodeType},oe=function(e){return _?_(e):e.nodeName};if(typeof a==`function`){let e=n.createElement(`template`);e.content&&e.content.ownerDocument&&(n=e.content.ownerDocument)}let y,b=``,se,le=!1,C=0,ue=function(){if(C>0)throw k(`A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.`)},T=function(e){ue(),C++;try{return y.createHTML(e)}finally{C--}},Se=function(e){ue(),C++;try{return y.createScriptURL(e)}finally{C--}},Ce=function(){return le||=(se=it(u,i),!0),se},we=n,D=we.implementation,A=we.createNodeIterator,Te=we.createDocumentFragment,Ee=we.getElementsByTagName,et=r.importNode,I=at();t.isSupported=typeof ae==`function`&&typeof h==`function`&&D&&D.createHTMLDocument!==void 0;let ct=Be,lt=Ve,ut=He,dt=Ue,ft=We,pt=Ke,mt=qe,ht=Ye,gt=Ge,L=null,_t=j({},[...ke,...Ae,...je,...Ne,...Fe]),R=null,z=j({},[...Ie,...Le,...Re,...ze]),B=Object.seal(ce(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),vt=null,yt=null,V=Object.seal(ce(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),bt=!0,xt=!0,H=!1,U=!0,W=!1,G=!0,K=!1,q=!1,St=null,J=null,Ct=!1,Y=!1,wt=!1,Tt=!1,Et=!0,Dt=!1,Ot=`user-content-`,kt=!0,At=!1,jt={},Mt=null,Nt=j({},`annotation-xml.audio.colgroup.desc.foreignobject.head.iframe.math.mi.mn.mo.ms.mtext.noembed.noframes.noscript.plaintext.script.selectedcontent.style.svg.template.thead.title.video.xmp`.split(`.`)),Pt=null,Ft=j({},[`audio`,`video`,`img`,`source`,`image`,`track`]),It=null,Lt=j({},[`alt`,`class`,`for`,`id`,`label`,`name`,`pattern`,`placeholder`,`role`,`summary`,`title`,`value`,`style`,`xmlns`]),Rt=`http://www.w3.org/1998/Math/MathML`,zt=`http://www.w3.org/2000/svg`,X=`http://www.w3.org/1999/xhtml`,Bt=X,Vt=!1,Ht=null,Ut=j({},[Rt,zt,X],_e),Wt=x([`mi`,`mo`,`mn`,`ms`,`mtext`]),Gt=j({},Wt),Kt=x([`annotation-xml`]),qt=j({},Kt),Jt=j({},[`title`,`style`,`font`,`a`,`script`]),Yt=null,Xt=[`application/xhtml+xml`,`text/html`],Z=null,Zt=null,Qt=n.createElement(`form`),$t=function(e){return e instanceof RegExp||e instanceof Function},en=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(Zt&&Zt===e)return;(!e||typeof e!=`object`)&&(e={}),e=M(e),Yt=Xt.indexOf(e.PARSER_MEDIA_TYPE)===-1?`text/html`:e.PARSER_MEDIA_TYPE,Z=Yt===`application/xhtml+xml`?_e:ge,L=F(e,`ALLOWED_TAGS`,_t,{transform:Z}),R=F(e,`ALLOWED_ATTR`,z,{transform:Z}),Ht=F(e,`ALLOWED_NAMESPACES`,Ut,{transform:_e}),It=F(e,`ADD_URI_SAFE_ATTR`,Lt,{transform:Z,base:Lt}),Pt=F(e,`ADD_DATA_URI_TAGS`,Ft,{transform:Z,base:Ft}),Mt=F(e,`FORBID_CONTENTS`,Nt,{transform:Z}),vt=F(e,`FORBID_TAGS`,M({}),{transform:Z}),yt=F(e,`FORBID_ATTR`,M({}),{transform:Z}),jt=E(e,`USE_PROFILES`)?e.USE_PROFILES&&typeof e.USE_PROFILES==`object`?M(e.USE_PROFILES):e.USE_PROFILES:!1,bt=e.ALLOW_ARIA_ATTR!==!1,xt=e.ALLOW_DATA_ATTR!==!1,H=e.ALLOW_UNKNOWN_PROTOCOLS||!1,U=e.ALLOW_SELF_CLOSE_IN_ATTR!==!1,W=e.SAFE_FOR_TEMPLATES||!1,G=e.SAFE_FOR_XML!==!1,K=e.WHOLE_DOCUMENT||!1,Y=e.RETURN_DOM||!1,wt=e.RETURN_DOM_FRAGMENT||!1,Tt=e.RETURN_TRUSTED_TYPE||!1,Ct=e.FORCE_BODY||!1,Et=e.SANITIZE_DOM!==!1,Dt=e.SANITIZE_NAMED_PROPS||!1,kt=e.KEEP_CONTENT!==!1,At=e.IN_PLACE||!1,gt=Oe(e.ALLOWED_URI_REGEXP)?e.ALLOWED_URI_REGEXP:Ge,Bt=typeof e.NAMESPACE==`string`?e.NAMESPACE:X,Gt=ot(e,`MATHML_TEXT_INTEGRATION_POINTS`,()=>j({},Wt)),qt=ot(e,`HTML_INTEGRATION_POINTS`,()=>j({},Kt));let t=ot(e,`CUSTOM_ELEMENT_HANDLING`,()=>ce(null));if(B=ce(null),E(t,`tagNameCheck`)&&$t(t.tagNameCheck)&&(B.tagNameCheck=t.tagNameCheck),E(t,`attributeNameCheck`)&&$t(t.attributeNameCheck)&&(B.attributeNameCheck=t.attributeNameCheck),E(t,`allowCustomizedBuiltInElements`)&&typeof t.allowCustomizedBuiltInElements==`boolean`&&(B.allowCustomizedBuiltInElements=t.allowCustomizedBuiltInElements),S(B),W&&(xt=!1),wt&&(Y=!0),jt&&(L=j({},Fe),R=ce(null),jt.html===!0&&(j(L,ke),j(R,Ie)),jt.svg===!0&&(j(L,Ae),j(R,Le),j(R,ze)),jt.svgFilters===!0&&(j(L,je),j(R,Le),j(R,ze)),jt.mathMl===!0&&(j(L,Ne),j(R,Re),j(R,ze))),V.tagCheck=null,V.attributeCheck=null,E(e,`ADD_TAGS`)&&(typeof e.ADD_TAGS==`function`?V.tagCheck=e.ADD_TAGS:he(e.ADD_TAGS)&&(L===_t&&(L=M(L)),j(L,e.ADD_TAGS,Z))),E(e,`ADD_ATTR`)&&(typeof e.ADD_ATTR==`function`?V.attributeCheck=e.ADD_ATTR:he(e.ADD_ATTR)&&(R===z&&(R=M(R)),j(R,e.ADD_ATTR,Z))),E(e,`ADD_FORBID_CONTENTS`)&&he(e.ADD_FORBID_CONTENTS)&&(Mt===Nt&&(Mt=M(Mt)),j(Mt,e.ADD_FORBID_CONTENTS,Z)),kt&&(L[`#text`]=!0),K&&j(L,[`html`,`head`,`body`]),L.table&&(j(L,[`tbody`]),delete vt.tbody),e.TRUSTED_TYPES_POLICY){if(typeof e.TRUSTED_TYPES_POLICY.createHTML!=`function`)throw k(`TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.`);if(typeof e.TRUSTED_TYPES_POLICY.createScriptURL!=`function`)throw k(`TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.`);let t=y;y=e.TRUSTED_TYPES_POLICY;try{b=T(``)}catch(e){throw y=t,e}}else e.TRUSTED_TYPES_POLICY===null?(y=void 0,b=``):(y===void 0&&(y=Ce()),y&&typeof b==`string`&&(b=T(``)));x&&x(e),Zt=e},tn=j({},[...Ae,...je,...Me]),nn=j({},[...Ne,...Pe]),rn=function(e,t,n){return t.namespaceURI===X?e===`svg`:t.namespaceURI===Rt?e===`svg`&&(n===`annotation-xml`||Gt[n]):!!tn[e]},an=function(e,t,n){return t.namespaceURI===X?e===`math`:t.namespaceURI===zt?e===`math`&&qt[n]:!!nn[e]},on=function(e,t,n){return t.namespaceURI===zt&&!qt[n]||t.namespaceURI===Rt&&!Gt[n]?!1:!nn[e]&&(Jt[e]||!tn[e])},sn=function(e){let t=h(e);(!t||!t.tagName)&&(t={namespaceURI:Bt,tagName:`template`});let n=ge(e.tagName),r=ge(t.tagName);return Ht[e.namespaceURI]?e.namespaceURI===zt?rn(n,t,r):e.namespaceURI===Rt?an(n,t,r):e.namespaceURI===X?on(n,t,r):!!(Yt===`application/xhtml+xml`&&Ht[e.namespaceURI]):!1},Q=function(e){pe(t.removed,{element:e});try{h(e).removeChild(e)}catch{if(p(e),!h(e))throw k(`a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place`)}},cn=function(e,t,n){try{ee(e,t)}catch{try{e.removeAttribute(n)}catch{}}},ln=function(e){fn(e);let t=m(e);if(t){let e=[];w(t,t=>{pe(e,t)}),w(e,e=>{try{p(e)}catch{}})}let n=re(e);if(n)for(let t=n.length-1;t>=0;--t){let r=n[t],i=r&&r.name;typeof i==`string`&&cn(e,r,i)}},un=function(e,n,r){if(!r)try{r=n.getAttributeNode(e)}catch{r=null}pe(t.removed,{attribute:r||null,from:n});try{r?ee(n,r):n.removeAttribute(e)}catch{try{n.removeAttribute(e)}catch{}}if(e===`is`){if(Y||wt)try{Q(n)}catch{}else try{n.setAttribute(e,``)}catch{}}},dn=function(e){let t=re(e);if(t)for(let n=t.length-1;n>=0;--n){let r=t[n],i=r&&r.name;typeof i!=`string`||R[Z(i)]||cn(e,r,i)}},fn=function(e){let t=[e];for(;t.length>0;){let e=t.pop();v(e)===P.element&&dn(e);let n=m(e);if(n)for(let e=n.length-1;e>=0;--e)t.push(n[e])}},pn=function(e,t){return G?e===`patchsrc`||e===`for`&&t!==`label`&&t!==`output`:!1},mn=function(e){if(!G)return;let t=[e];for(;t.length>0;){let e=t.pop(),n=v(e);if(n===P.processingInstruction||n===P.comment&&O(Ze,e.data)){try{p(e)}catch{}continue}if(n===P.element){let t=e,n=Z(oe(e));try{t.hasAttribute&&t.hasAttribute(`patchsrc`)&&t.removeAttribute(`patchsrc`),t.hasAttribute&&t.hasAttribute(`for`)&&pn(`for`,n)&&t.removeAttribute(`for`)}catch{}}let r=m(e);if(r)for(let e=r.length-1;e>=0;--e)t.push(r[e])}},hn=function(e){let t=null,r=null;if(Ct)e=`<remove></remove>`+e;else{let t=ve(e,/^[\r\n\t ]+/);r=t&&t[0]}Yt===`application/xhtml+xml`&&Bt===X&&(e=`<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>`+e+`</body></html>`);let i=y?T(e):e;if(Bt===X)try{t=new l().parseFromString(i,Yt)}catch{}if(!t||!t.documentElement){t=D.createDocument(Bt,`template`,null);try{t.documentElement.innerHTML=Vt?b:i}catch{}}let a=t.body||t.documentElement;return e&&r&&a.insertBefore(n.createTextNode(r),a.childNodes[0]||null),Bt===X?Ee.call(t,K?`html`:`body`)[0]:K?t.documentElement:a},gn=function(e){let t=ie?ie(e):e.ownerDocument;return A.call(t||e,e,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},_n=function(e){return e=ye(e,ct,` `),e=ye(e,lt,` `),e=ye(e,ut,` `),e},vn=function(e){e.normalize();let t=ie?ie(e):e.ownerDocument,n=A.call(t||e,e,c.SHOW_TEXT|c.SHOW_COMMENT|c.SHOW_CDATA_SECTION|c.SHOW_PROCESSING_INSTRUCTION,null),r=n.nextNode();for(;r;)r.data=_n(r.data),r=n.nextNode();let i=e.querySelectorAll?.call(e,`template`);i&&w(i,e=>{bn(e.content)&&vn(e.content)})},yn=function(e){let t=_?_(e):null;return typeof t!=`string`||Z(t)!==`form`?!1:typeof e.nodeName!=`string`||typeof e.textContent!=`string`||typeof e.removeChild!=`function`||e.attributes!==re(e)||typeof e.removeAttribute!=`function`||typeof e.removeAttributeNode!=`function`||typeof e.getAttributeNode!=`function`||typeof e.setAttribute!=`function`||typeof e.namespaceURI!=`string`||typeof e.insertBefore!=`function`||typeof e.hasChildNodes!=`function`||e.nodeType!==g(e)||e.childNodes!==m(e)},bn=function(e){if(!g||typeof e!=`object`||!e)return!1;try{return g(e)===P.documentFragment}catch{return!1}},xn=function(e){if(!g||typeof e!=`object`||!e)return!1;try{return typeof g(e)==`number`}catch{return!1}};function $(e,n,r){e.length!==0&&w(e,e=>{e.call(t,n,r,Zt)})}let Sn=function(e,t){return!!(G&&e.hasChildNodes()&&!xn(e.firstElementChild)&&O(Xe,e.textContent)&&O(Xe,e.innerHTML)||G&&e.namespaceURI===X&&tt[t]&&(xn(e.firstElementChild)||typeof e.textContent==`string`&&O(nt[t],e.textContent))||e.nodeType===P.processingInstruction||G&&e.nodeType===P.comment&&O(Ze,e.data))},Cn=function(e,t){return e instanceof RegExp?O(e,t):e instanceof Function&&!!e(t,...[...arguments].slice(2))},wn=function(e,t,n){if(!vt[t]&&An(t)&&Cn(B.tagNameCheck,t))return!1;if(kt&&!Mt[t]){let t=h(e),r=m(e);if(r&&t){let i=r.length;for(let a=i-1;a>=0;--a){let i=e===n?f(r[a],!0):r[a];t.insertBefore(i,te(e))}}}return Q(e),!0},Tn=function(e,t,n,r){return e.length===0?t:t===n||t===r?M(t):t},En=function(e,t){return e===t||h(e)!==null?!1:(At&&fn(e),!0)},Dn=function(e,n){if($(I.beforeSanitizeElements,e,null),En(e,n))return!0;if(yn(e))return Q(e),!0;let r=Z(oe(e));if(L=Tn(I.uponSanitizeElement,L,_t,St),$(I.uponSanitizeElement,e,{tagName:r,allowedTags:L}),En(e,n))return!0;if(Sn(e,r))return Q(e),!0;if(vt[r]||!(V.tagCheck instanceof Function&&V.tagCheck(r))&&!L[r]){let t=wn(e,r,n);return t===!1&&($(I.afterSanitizeElements,e,null),En(e,n))?!0:t}if(v(e)===P.element&&!sn(e)||(r===`noscript`||r===`noembed`||r===`noframes`)&&O(Qe,e.innerHTML))return Q(e),!0;if(W&&e.nodeType===P.text){let n=_n(e.textContent);e.textContent!==n&&(pe(t.removed,{element:e.cloneNode()}),e.textContent=n)}return $(I.afterSanitizeElements,e,null),En(e,n)},On=function(e,t,r){if(yt[t]||pn(t,e)||Et&&(t===`id`||t===`name`)&&(r in n||r in Qt))return!1;let i=R[t]||V.attributeCheck instanceof Function&&V.attributeCheck(t,e);return xt&&O(dt,t)||bt&&O(ft,t)?!0:i?It[t]||O(gt,ye(r,mt,``))||(t===`src`||t===`xlink:href`||t===`href`)&&e!==`script`&&be(r,`data:`)===0&&Pt[e]||H&&!O(pt,ye(r,mt,``))?!0:!r:An(e)&&Cn(B.tagNameCheck,e)&&Cn(B.attributeNameCheck,t,e)||t===`is`&&B.allowCustomizedBuiltInElements&&Cn(B.tagNameCheck,r)},kn=j({},[`annotation-xml`,`color-profile`,`font-face`,`font-face-format`,`font-face-name`,`font-face-src`,`font-face-uri`,`missing-glyph`]),An=function(e){return!kn[ge(e)]&&O(ht,e)},jn=function(e,t,n,r){if(y&&typeof u==`object`&&typeof u.getAttributeType==`function`&&!n)switch(u.getAttributeType(e,t)){case`TrustedHTML`:return T(r);case`TrustedScriptURL`:return Se(r)}return r},Mn=function(e,t,n,r){try{return n?e.setAttributeNS(n,t,r):e.setAttribute(t,r),!yn(e)||(Q(e),!1)}catch{return un(t,e),!1}},Nn=function(e,n){if($(I.beforeSanitizeAttributes,e,null),En(e,n))return;let r=e.attributes;if(!r||yn(e))return;R=Tn(I.uponSanitizeAttribute,R,z,J);let i={attrName:``,attrValue:``,keepAttr:!0,allowedAttributes:R,forceKeepAttr:void 0},a=r.length,o=Z(e.nodeName);for(;a--;){let n=r[a],s=n.name,c=n.namespaceURI,l=n.value,u=Z(s),d=l,f=s===`value`?d:xe(d),p=!1;if(i.attrName=u,i.attrValue=f,i.keepAttr=!0,i.forceKeepAttr=void 0,$(I.uponSanitizeAttribute,e,i),f=i.attrValue,Dt&&(u===`id`||u===`name`)&&be(f,Ot)!==0&&(un(s,e,n),f=Ot+f,p=!0),G&&O(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,f)){un(s,e,n);continue}if(u===`attributename`&&ve(f,`href`)){un(s,e,n);continue}if(!i.forceKeepAttr){if(!i.keepAttr){un(s,e,n);continue}if(!U&&O($e,f)){un(s,e,n);continue}if(W&&(f=_n(f)),!On(o,u,f)){un(s,e,n);continue}f=jn(o,u,c,f),f!==d&&Mn(e,s,c,f)&&p&&fe(t.removed)}}$(I.afterSanitizeAttributes,e,null),En(e,n)},Pn=function(e){let t=null,n=gn(e);for($(I.beforeSanitizeShadowDOM,e,null);t=n.nextNode();)if($(I.uponSanitizeShadowNode,t,null),Dn(t,e),Nn(t,e),bn(t.content)&&Pn(t.content),v(t)===P.element){let e=ne(t);bn(e)&&(Fn(e),Pn(e))}$(I.afterSanitizeShadowDOM,e,null)},Fn=function(e){let t=[{node:e,shadow:null}];for(;t.length>0;){let e=t.pop();if(e.shadow){Pn(e.shadow);continue}let n=e.node,r=v(n)===P.element,i=m(n);if(i)for(let e=i.length-1;e>=0;--e)t.push({node:i[e],shadow:null});if(r){let e=_?_(n):null;if(typeof e==`string`&&Z(e)===`template`){let e=n.content;bn(e)&&t.push({node:e,shadow:null})}}if(r){let e=ne(n);bn(e)&&t.push({node:null,shadow:e},{node:e,shadow:null})}}};return t.sanitize=function(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},i=null,a=null,o=null,s=null;if(Vt=!e,Vt&&(e=`<!-->`),typeof e!=`string`&&!xn(e)&&(e=De(e),typeof e!=`string`))throw k(`dirty is not a string, aborting`);if(!t.isSupported)return e;q?(L=St,R=J):en(n),(I.uponSanitizeElement.length>0||I.uponSanitizeAttribute.length>0)&&(L=M(L)),I.uponSanitizeAttribute.length>0&&(R=M(R)),t.removed=[];let c=At&&typeof e!=`string`&&xn(e);if(c){mn(e);let t=oe(e);if(typeof t==`string`){let n=Z(t);if(!L[n]||vt[n])throw ln(e),k(`root node is forbidden and cannot be sanitized in-place`)}if(yn(e))throw ln(e),k(`root node is clobbered and cannot be sanitized in-place`);try{Fn(e)}catch(t){throw ln(e),t}}else if(xn(e))i=hn(`<!---->`),a=i.ownerDocument.importNode(e,!0),a.nodeType===P.element&&a.nodeName===`BODY`||a.nodeName===`HTML`?i=a:i.appendChild(a),Fn(i);else{if(!Y&&!W&&!K&&e.indexOf(`<`)===-1)return y&&Tt?T(e):e;if(i=hn(e),!i)return Y?null:Tt?b:``}i&&Ct&&Q(i.firstChild);let l=c?e:i;try{let e=gn(l);for(;o=e.nextNode();)Dn(o,l),Nn(o,l),bn(o.content)&&Pn(o.content)}catch(n){throw c&&(ln(e),w(t.removed,e=>{e.element&&fn(e.element)})),n}if(c){let n=!1;if(w(t.removed,t=>{t.element&&(t.element===e&&(n=!0),fn(t.element))}),n)throw k(`a node selected for removal could not be safely returned; refusing to sanitize in place`);return W&&vn(e),e}if(Y){if(W&&vn(i),wt)for(s=Te.call(i.ownerDocument);i.firstChild;)s.appendChild(i.firstChild);else s=i;return(R.shadowroot||R.shadowrootmode)&&(s=et.call(r,s,!0)),s}let u=K?i.outerHTML:i.innerHTML;return K&&L[`!doctype`]&&i.ownerDocument&&i.ownerDocument.doctype&&i.ownerDocument.doctype.name&&O(Je,i.ownerDocument.doctype.name)&&(u=`<!DOCTYPE `+i.ownerDocument.doctype.name+`>
|
|
3
|
+
`+u),W&&(u=_n(u)),y&&Tt?T(u):u},t.setConfig=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};en(e),q=!0,St=L,J=R},t.clearConfig=function(){Zt=null,q=!1,St=null,J=null,y=se,b=``},t.isValidAttribute=function(e,t,n){Zt||en({});let r=Z(e),i=Z(t);return On(r,i,n)},t.addHook=function(e,t){typeof t==`function`&&E(I,e)&&pe(I[e],t)},t.removeHook=function(e,t){if(E(I,e)){if(t!==void 0){let n=de(I[e],t);return n===-1?void 0:me(I[e],n,1)[0]}return fe(I[e])}},t.removeHooks=function(e){E(I,e)&&(I[e]=[])},t.removeAllHooks=function(){I=at()},t}var I=st();function ct(e){return I.sanitize(e,{USE_PROFILES:{html:!0}})}function lt(e,t){let n=new DOMParser().parseFromString(e,`text/html`);return n.querySelectorAll(`a[href]`).forEach(e=>{let n=e.getAttribute(`href`)??``,r=n.startsWith(`/uploads/`)?te(n,t):n;r!==n&&e.setAttribute(`href`,r),ut(r)&&(e.setAttribute(`target`,`_blank`),e.setAttribute(`rel`,`noopener noreferrer`))}),n.querySelectorAll(`img[src]`).forEach(e=>{let n=e.getAttribute(`src`)??``;n.startsWith(`/uploads/`)&&e.setAttribute(`src`,te(n,t))}),n.body.innerHTML}function ut(e){if(!/^https?:\/\//i.test(e))return!1;try{return new URL(e).origin!==window.location.origin}catch{return!1}}function dt(e,t){let r=lt(ct(e??``),t);return n`${c(r)}`}function ft(e,t){if(!e||!e.url)return null;let n;if(e.formats){n={};for(let[r,i]of Object.entries(e.formats))i?.url&&(n[r]={url:te(i.url,t),width:i.width,height:i.height})}return{url:te(e.url,t),alternativeText:e.alternativeText??null,mime:e.mime,name:e.name,width:e.width,height:e.height,formats:n}}var pt=e=>e===`text`||e===`accordion`||e===`video_card`||e===`document_card`?e:void 0;function mt(e){return{documentId:e.documentId??``,code:e.code??``,name:e.name??``,icon:e.icon}}function ht(e,t){return{documentId:e.documentId??``,uid:e.uid??``,title:e.title??``,subtitle:e.subtitle,icon:e.icon,image:ft(e.image,t),behavior:pt(e.behavior),order:e.order,showSortBy:e.showSortBy??!1,showFilterByTopic:e.showFilterByTopic??!1}}function gt(e,t){return{documentId:e.documentId??``,uid:e.uid??``,title:e.title??``,abstract:e.abstract,body:dt(e.text,t),behavior:pt(e.behavior),featured:e.featured??!1,duration:e.duration,dateAdded:e.dateAdded,publishedAt:e.publishedAt??null,topics:(e.topics??[]).map(mt),category:e.category?ht(e.category,t):null,thumbnail:ft(e.thumbnail,t),video:ft(e.video,t),documents:(e.documents??[]).map(e=>ft(e,t)).filter(e=>e!==null)}}function L(e,t){return e?{heading:e.heading??``,description:e.description??``,backgroundImage:ft(e.backgroundImage,t)}:null}var _t=class extends Error{constructor(e,t){super(e,t?.cause===void 0?void 0:{cause:t.cause}),this.name=`KbApiError`,this.status=t?.status}},R=`whats-new`,z=100,B={thumbnail:!0,video:!0,documents:!0,topics:!0,category:!0};function vt(e){let t=e.apiBaseUrl.replace(/\/+$/,``),n=e.mediaBaseUrl,r=e.previewDrafts?`draft`:`published`,i=e.locale,a=e.fetch??globalThis.fetch.bind(globalThis);async function o(e,n){let o=ee({...n,status:r,locale:i}),s=`${t}/api/${e}${o}`,c;try{c=await a(s)}catch(t){throw new _t(`Network error fetching ${e}`,{cause:t})}if(!c.ok)throw new _t(`Strapi responded ${c.status} for ${e}`,{status:c.status});let l;try{l=await c.json()}catch(t){throw new _t(`Invalid JSON from ${e}`,{cause:t})}return l.data}async function s(e,t){return await o(e,t)??[]}return{async getLanding(){let[e,t,r,i,a]=await Promise.all([o(`index-page`,{populate:{backgroundImage:!0}}),s(`categories`,{populate:{image:!0},sort:[`order:asc`],pagination:{pageSize:z}}),s(`topics`,{sort:[`order:asc`],pagination:{pageSize:z}}),s(`posts`,{filters:{featured:{$eq:!0}},populate:B,sort:[`dateAdded:desc`],pagination:{pageSize:z}}),s(`posts`,{filters:{category:{uid:{$eq:R}}},populate:B,sort:[`dateAdded:desc`],pagination:{pageSize:z}})]);return{indexPage:L(e,n),categories:t.map(e=>ht(e,n)),topics:r.map(e=>mt(e)),featured:i.map(e=>gt(e,n)),whatsNew:a.map(e=>gt(e,n))}},async getCategory(e){let[t,r]=await Promise.all([s(`categories`,{filters:{uid:{$eq:e}},populate:{image:!0},pagination:{pageSize:1}}),s(`posts`,{filters:{category:{uid:{$eq:e}}},populate:B,sort:[`dateAdded:desc`],pagination:{pageSize:z}})]);return{category:t[0]?ht(t[0],n):null,posts:r.map(e=>gt(e,n))}},async getTopic(e){let[t,r]=await Promise.all([s(`topics`,{filters:{code:{$eq:e}},pagination:{pageSize:1}}),s(`posts`,{filters:{topics:{code:{$eq:e}}},populate:B,sort:[`dateAdded:desc`],pagination:{pageSize:z}})]);return{topic:t[0]?mt(t[0]):null,posts:r.map(e=>gt(e,n))}},async getPost(e){let t=await s(`posts`,{filters:{uid:{$eq:e}},populate:B,pagination:{pageSize:1}});return t[0]?gt(t[0],n):null}}}function yt(e){let t=new Map;function n(e,n){let r=t.get(e);if(r)return r;let i=n().catch(n=>{throw t.delete(e),n});return t.set(e,i),i}return{getLanding:()=>n(`landing`,()=>e.getLanding()),getCategory:t=>n(`category:${t}`,()=>e.getCategory(t)),getTopic:t=>n(`topic:${t}`,()=>e.getTopic(t)),getPost:t=>n(`post:${t}`,()=>e.getPost(t)),invalidate:e=>{e?t.delete(e):t.clear()}}}function V(){let e=window.gpConfig?.[`ui-knowledgebase`],t=e?.[`KB:strapiBaseUrl`];if(!t)throw Error(`ui-knowledgebase config not loaded: window.gpConfig['ui-knowledgebase']['KB:strapiBaseUrl'] is missing. Ensure config.json is fetched before the KB route renders.`);return{apiBaseUrl:t,mediaBaseUrl:t,previewDrafts:e?.[`KB:previewDraftContent`]??!1,locale:`en`}}var bt;function xt(){return bt||=yt(vt(V())),bt}function H(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}var U=class extends e{constructor(...e){super(...e),this.loading=!0,this.error=!1,this.data=null}static{this.styles=t`
|
|
2
4
|
:host {
|
|
3
5
|
display: block;
|
|
4
6
|
padding: 1rem;
|
|
@@ -16,7 +18,7 @@ import{LitElement as e,css as t,html as n,nothing as r}from"lit";import{customEl
|
|
|
16
18
|
button {
|
|
17
19
|
cursor: pointer;
|
|
18
20
|
}
|
|
19
|
-
`}connectedCallback(){super.connectedCallback(),this.load()}async load(){this.loading=!0,this.error=!1;try{this.data=await
|
|
21
|
+
`}connectedCallback(){super.connectedCallback(),this.load()}async load(){this.loading=!0,this.error=!1;try{this.data=await xt().getLanding()}catch{this.error=!0}finally{this.loading=!1}}render(){if(this.loading)return n`<p class="muted">Loading…</p>`;if(this.error||!this.data)return n`
|
|
20
22
|
<p role="alert">Couldn't load the Knowledge Base.</p>
|
|
21
23
|
<button @click=${()=>void this.load()}>Retry</button>
|
|
22
24
|
`;let{indexPage:e,categories:t,topics:i,featured:a,whatsNew:o}=this.data;return n`
|
|
@@ -30,7 +32,7 @@ import{LitElement as e,css as t,html as n,nothing as r}from"lit";import{customEl
|
|
|
30
32
|
<ul>
|
|
31
33
|
${t.map(e=>n`
|
|
32
34
|
<li>
|
|
33
|
-
<a href="${
|
|
35
|
+
<a href="${q}/category/${e.uid}">${e.title}</a>
|
|
34
36
|
${e.subtitle?n`<span class="muted"> — ${e.subtitle}</span>`:r}
|
|
35
37
|
</li>
|
|
36
38
|
`)}
|
|
@@ -40,7 +42,7 @@ import{LitElement as e,css as t,html as n,nothing as r}from"lit";import{customEl
|
|
|
40
42
|
<section>
|
|
41
43
|
<h2>Topics</h2>
|
|
42
44
|
<ul>
|
|
43
|
-
${i.map(e=>n`<li><a href="${
|
|
45
|
+
${i.map(e=>n`<li><a href="${q}/topic/${e.code}">${e.name}</a></li>`)}
|
|
44
46
|
</ul>
|
|
45
47
|
</section>
|
|
46
48
|
|
|
@@ -57,12 +59,12 @@ import{LitElement as e,css as t,html as n,nothing as r}from"lit";import{customEl
|
|
|
57
59
|
<ul>
|
|
58
60
|
${e.map(e=>n`
|
|
59
61
|
<li>
|
|
60
|
-
<a href="${
|
|
62
|
+
<a href="${q}/details/${e.uid}">${e.title}</a>
|
|
61
63
|
${e.abstract?n`<span class="muted"> — ${e.abstract}</span>`:r}
|
|
62
64
|
</li>
|
|
63
65
|
`)}
|
|
64
66
|
</ul>
|
|
65
|
-
`}};
|
|
67
|
+
`}};H([o()],U.prototype,`loading`,void 0),H([o()],U.prototype,`error`,void 0),H([o()],U.prototype,`data`,void 0),U=H([i(`kb-landing-view`)],U);var W=class extends e{constructor(...e){super(...e),this.uid=``}static{this.styles=t`
|
|
66
68
|
:host {
|
|
67
69
|
display: block;
|
|
68
70
|
padding: 1rem;
|
|
@@ -70,7 +72,7 @@ import{LitElement as e,css as t,html as n,nothing as r}from"lit";import{customEl
|
|
|
70
72
|
`}onAfterEnter(e){this.uid=String(e.params.uid??``)}render(){return n`
|
|
71
73
|
<a href="/knowledge-base">← Knowledge Base</a>
|
|
72
74
|
<h1>Category: ${this.uid}</h1>
|
|
73
|
-
`}};
|
|
75
|
+
`}};H([o()],W.prototype,`uid`,void 0),W=H([i(`kb-category-view`)],W);var G=class extends e{constructor(...e){super(...e),this.code=``}static{this.styles=t`
|
|
74
76
|
:host {
|
|
75
77
|
display: block;
|
|
76
78
|
padding: 1rem;
|
|
@@ -78,7 +80,7 @@ import{LitElement as e,css as t,html as n,nothing as r}from"lit";import{customEl
|
|
|
78
80
|
`}onAfterEnter(e){this.code=String(e.params.code??``)}render(){return n`
|
|
79
81
|
<a href="/knowledge-base">← Knowledge Base</a>
|
|
80
82
|
<h1>Topic: ${this.code}</h1>
|
|
81
|
-
`}};
|
|
83
|
+
`}};H([o()],G.prototype,`code`,void 0),G=H([i(`kb-topic-view`)],G);var K=class extends e{constructor(...e){super(...e),this.uid=``}static{this.styles=t`
|
|
82
84
|
:host {
|
|
83
85
|
display: block;
|
|
84
86
|
padding: 1rem;
|
|
@@ -86,4 +88,4 @@ import{LitElement as e,css as t,html as n,nothing as r}from"lit";import{customEl
|
|
|
86
88
|
`}onAfterEnter(e){this.uid=String(e.params.uid??``)}render(){return n`
|
|
87
89
|
<a href="/knowledge-base">← Knowledge Base</a>
|
|
88
90
|
<h1>Details: ${this.uid}</h1>
|
|
89
|
-
`}};
|
|
91
|
+
`}};H([o()],K.prototype,`uid`,void 0),K=H([i(`kb-details-view`)],K);var q=`/knowledge-base`,St=e=>e===`/knowledge-base`||e.startsWith(`/knowledge-base/`),J={Landing:`kb-landing`,Category:`kb-category`,Topic:`kb-topic`,Details:`kb-details`},Ct=[{path:q,children:[{name:J.Landing,path:`/`,component:`kb-landing-view`},{name:J.Category,path:`/category/:uid`,component:`kb-category-view`},{name:J.Topic,path:`/topic/:code`,component:`kb-topic-view`},{name:J.Details,path:`/details/:uid`,component:`kb-details-view`}]},{path:`(.*)`,component:`no-elem`}],Y=class extends e{constructor(...e){super(...e),this.baseUrl=`/`,this.active=!1,this.outlet=document.createElement(`main`),this.onLocationChanged=e=>{let{router:t,location:n}=e.detail;t===d()&&(this.active=St(n.pathname))}}connectedCallback(){super.connectedCallback(),window.addEventListener(`vaadin-router-location-changed`,this.onLocationChanged),u(this.outlet,this.baseUrl,Ct),this.dispatchEvent(new CustomEvent(`mfe-loaded`,{detail:{routes:Ct}}))}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener(`vaadin-router-location-changed`,this.onLocationChanged),f(),this.active=!1}render(){return this.active?n`${this.outlet}`:r}};H([a({type:String})],Y.prototype,`baseUrl`,void 0),H([o()],Y.prototype,`active`,void 0),Y=H([i(`ui-knowledgebase`)],Y);export{Y as UiKnowledgebase};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@digital-realty/ui-knowledgebase",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -13,23 +13,27 @@
|
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
15
|
"@vaadin/router": "^1.7.5",
|
|
16
|
+
"dompurify": "^3.4.16",
|
|
16
17
|
"lit": "^3.1.4"
|
|
17
18
|
},
|
|
18
19
|
"devDependencies": {
|
|
20
|
+
"jsdom": "^30.1.1",
|
|
19
21
|
"prettier": "^3.9.9",
|
|
20
22
|
"rimraf": "^6.0.1",
|
|
21
23
|
"typescript": "^5.5.3",
|
|
22
|
-
"vite": "^8.1.0"
|
|
24
|
+
"vite": "^8.1.0",
|
|
25
|
+
"vitest": "^5.0.2"
|
|
23
26
|
},
|
|
24
27
|
"scripts": {
|
|
25
28
|
"dev": "vite",
|
|
26
29
|
"build": "tsc --noEmit && vite build",
|
|
27
30
|
"build:watch": "vite build --watch",
|
|
28
31
|
"build:workspace": "pnpm run build",
|
|
29
|
-
"test": "
|
|
32
|
+
"test": "vitest run",
|
|
30
33
|
"preview": "vite preview",
|
|
31
34
|
"format": "prettier --write .",
|
|
32
35
|
"format:check": "prettier --check .",
|
|
33
|
-
"clean": "rimraf node_modules dist"
|
|
36
|
+
"clean": "rimraf node_modules dist",
|
|
37
|
+
"test:watch": "vitest"
|
|
34
38
|
}
|
|
35
39
|
}
|