dsh-plugin-github-issues 0.5.0 → 0.7.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.
- package/README.md +15 -17
- package/assets/panel.png +0 -0
- package/docs/README.zh.md +10 -14
- package/lib/client.js +3727 -329
- package/lib/controller.js +2 -37
- package/lib/controller.js.map +1 -1
- package/lib/github/client.js +33 -12
- package/lib/github/client.js.map +1 -1
- package/lib/github/list-request.js +62 -0
- package/lib/github/list-request.js.map +1 -0
- package/lib/github/queries.js +17 -5
- package/lib/github/queries.js.map +1 -1
- package/lib/github/types.js.map +1 -1
- package/lib/types/controller.d.ts +3 -3
- package/lib/types/controller.d.ts.map +1 -1
- package/lib/types/github/client.d.ts.map +1 -1
- package/lib/types/github/list-request.d.ts +31 -0
- package/lib/types/github/list-request.d.ts.map +1 -0
- package/lib/types/github/queries.d.ts +2 -0
- package/lib/types/github/queries.d.ts.map +1 -1
- package/lib/types/github/types.d.ts +3 -3
- package/lib/types/github/types.d.ts.map +1 -1
- package/lib/types/vm.d.ts +8 -0
- package/lib/types/vm.d.ts.map +1 -1
- package/lib/vm.js.map +1 -1
- package/package.json +3 -1
package/lib/client.js
CHANGED
|
@@ -26,7 +26,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
26
26
|
// src/client/index.tsx
|
|
27
27
|
var index_exports = {};
|
|
28
28
|
__export(index_exports, {
|
|
29
|
-
apply: () =>
|
|
29
|
+
apply: () => apply3,
|
|
30
30
|
inject: () => inject
|
|
31
31
|
});
|
|
32
32
|
module.exports = __toCommonJS(index_exports);
|
|
@@ -83,20 +83,20 @@ function priorityText(issue) {
|
|
|
83
83
|
}
|
|
84
84
|
function renderPrompt(issue, template) {
|
|
85
85
|
const source = template === "" ? DEFAULT_PROMPT_TEMPLATE : template;
|
|
86
|
-
let
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
if (
|
|
86
|
+
let text2 = source;
|
|
87
|
+
text2 = fill(text2, "repo", issue.repo);
|
|
88
|
+
text2 = fill(text2, "number", String(issue.number));
|
|
89
|
+
text2 = fill(text2, "title", issue.title);
|
|
90
|
+
text2 = fill(text2, "url", issue.url);
|
|
91
|
+
text2 = fill(text2, "state", stateText(issue));
|
|
92
|
+
text2 = fill(text2, "milestone", milestoneText(issue));
|
|
93
|
+
text2 = fill(text2, "priority", priorityText(issue));
|
|
94
|
+
text2 = fill(text2, "assignees", issue.assignees.length === 0 ? "\u672A\u6307\u6D3E" : issue.assignees.map((a3) => a3.login).join(", "));
|
|
95
|
+
text2 = fill(text2, "labels", issue.labels.length === 0 ? "\u65E0" : issue.labels.map((l) => l.name).join(", "));
|
|
96
|
+
text2 = fill(text2, "prs", prsText(issue));
|
|
97
|
+
if (text2.length > 8e3) return `${text2.slice(0, 7990)}
|
|
98
98
|
\u2026\uFF08\u5DF2\u622A\u65AD\uFF09`;
|
|
99
|
-
return
|
|
99
|
+
return text2;
|
|
100
100
|
}
|
|
101
101
|
var EMPTY_DRAFT_HOLD = "\u200B\n";
|
|
102
102
|
function composeHandoffPrompt(prompt, memo) {
|
|
@@ -358,7 +358,6 @@ var TONE = {
|
|
|
358
358
|
dot: "var(--dsw-alias-state-business-primary, var(--dsw-alias-link))"
|
|
359
359
|
}
|
|
360
360
|
};
|
|
361
|
-
var PROJECT_SCOPE_COMMAND = "gh auth refresh -h github.com -s read:project";
|
|
362
361
|
function Button({ children, onClick, variant = "outline", size = "md", disabled, title, ariaLabel }) {
|
|
363
362
|
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
364
363
|
"button",
|
|
@@ -506,22 +505,13 @@ function ErrorBanner({ message, retryLabel, onRetry, children }) {
|
|
|
506
505
|
children
|
|
507
506
|
] });
|
|
508
507
|
}
|
|
509
|
-
function Toast({ text, onDismiss, dismissLabel }) {
|
|
510
|
-
if (
|
|
508
|
+
function Toast({ text: text2, onDismiss, dismissLabel }) {
|
|
509
|
+
if (text2 === "") return null;
|
|
511
510
|
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "gh-toast", role: "status", children: [
|
|
512
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "gh-toast-text", children:
|
|
511
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "gh-toast-text", children: text2 }),
|
|
513
512
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { type: "button", className: "gh-toast-close", "aria-label": dismissLabel, title: dismissLabel, onClick: onDismiss, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(CloseGlyph, { size: 12 }) })
|
|
514
513
|
] });
|
|
515
514
|
}
|
|
516
|
-
function CommandBlock({ command, copyLabel, onCopy }) {
|
|
517
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "gh-command", children: [
|
|
518
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("code", { className: "gh-command-text", children: command }),
|
|
519
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(Button, { size: "sm", variant: "ghost", onClick: onCopy, children: [
|
|
520
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(CopyGlyph, { size: 12 }),
|
|
521
|
-
copyLabel
|
|
522
|
-
] })
|
|
523
|
-
] });
|
|
524
|
-
}
|
|
525
515
|
function StyleSheet({ chunks }) {
|
|
526
516
|
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("style", { children: chunks.join("\n") });
|
|
527
517
|
}
|
|
@@ -745,88 +735,3504 @@ function GitHubDock({ chips, t, onRemoveChip, onOpenChip }) {
|
|
|
745
735
|
onRemoveChip(open);
|
|
746
736
|
}
|
|
747
737
|
}
|
|
748
|
-
)
|
|
749
|
-
] });
|
|
738
|
+
)
|
|
739
|
+
] });
|
|
740
|
+
}
|
|
741
|
+
|
|
742
|
+
// src/client/views/DropZone.tsx
|
|
743
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
744
|
+
var DROPZONE_CSS = `
|
|
745
|
+
.ghz-bar{display:flex;align-items:center;gap:8px;box-sizing:border-box;margin-bottom:6px;padding:10px 12px;border:1px dashed var(--dsw-alias-state-business-primary,var(--dsw-alias-border-l3));border-radius:10px;background:var(--dsw-alias-bg-layer-2);color:var(--dsw-alias-label-primary);font-size:12px;line-height:18px}
|
|
746
|
+
.ghz-bar strong{font-weight:600}
|
|
747
|
+
.ghz-hint{color:var(--dsw-alias-label-tertiary)}
|
|
748
|
+
`.trim();
|
|
749
|
+
function GitHubDropZone({ dragging, t, onDrop, onCancel }) {
|
|
750
|
+
if (dragging === void 0) return null;
|
|
751
|
+
const ref = `${dragging.repo}#${String(dragging.number)}`;
|
|
752
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
753
|
+
"div",
|
|
754
|
+
{
|
|
755
|
+
className: "ghz-bar",
|
|
756
|
+
"data-github-dropzone": true,
|
|
757
|
+
onDragOver: (event) => {
|
|
758
|
+
event.preventDefault();
|
|
759
|
+
event.dataTransfer.dropEffect = "copy";
|
|
760
|
+
},
|
|
761
|
+
onDrop: (event) => {
|
|
762
|
+
event.preventDefault();
|
|
763
|
+
event.stopPropagation();
|
|
764
|
+
onDrop();
|
|
765
|
+
},
|
|
766
|
+
children: [
|
|
767
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(StyleSheet, { chunks: [CONTROLS_CSS, DROPZONE_CSS] }),
|
|
768
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(GitHubIcon, { size: 14 }),
|
|
769
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { children: t("drop.release") }),
|
|
770
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("strong", { children: ref }),
|
|
771
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "ghz-hint", children: t("drop.hint") }),
|
|
772
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { style: { flex: 1 } }),
|
|
773
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
774
|
+
"button",
|
|
775
|
+
{
|
|
776
|
+
type: "button",
|
|
777
|
+
className: "ghz-hint",
|
|
778
|
+
style: { border: 0, background: "transparent", cursor: "pointer", font: "inherit" },
|
|
779
|
+
onClick: onCancel,
|
|
780
|
+
children: t("drop.cancel")
|
|
781
|
+
}
|
|
782
|
+
)
|
|
783
|
+
]
|
|
784
|
+
}
|
|
785
|
+
);
|
|
786
|
+
}
|
|
787
|
+
|
|
788
|
+
// src/client/views/Pending.tsx
|
|
789
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
790
|
+
var PENDING_CSS = `
|
|
791
|
+
.ghp3-row{position:absolute;top:8px;left:12px;right:12px;z-index:2;display:flex;align-items:center;gap:6px;min-width:0;height:22px;font-size:12px;line-height:18px;pointer-events:none}
|
|
792
|
+
.ghp3-chip{pointer-events:auto;display:inline-flex;align-items:center;gap:5px;box-sizing:border-box;height:22px;max-width:100%;padding:0 8px;border-radius:999px;background:var(--dsw-alias-bg-layer-2);color:var(--dsw-alias-label-secondary);font-size:11px;line-height:18px;cursor:pointer;border:0.5px solid var(--dsw-alias-border-l2)}
|
|
793
|
+
.ghp3-chip:hover{background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-primary)}
|
|
794
|
+
.ghp3-chip:focus-visible{outline:2px solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline-offset:1px}
|
|
795
|
+
.ghp3-ref{font-family:var(--dsh-font-family-code,ui-monospace,SFMono-Regular,Menlo,monospace);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
|
|
796
|
+
.ghp3-remove{pointer-events:auto;display:inline-flex;align-items:center;justify-content:center;width:22px;height:22px;padding:0;border:0;border-radius:50%;background:transparent;color:var(--dsw-alias-label-tertiary);cursor:pointer;flex:none}
|
|
797
|
+
.ghp3-remove:hover{background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-primary)}
|
|
798
|
+
`.trim();
|
|
799
|
+
function GitHubPendingChip(props) {
|
|
800
|
+
const { card, t, onOpenPanel, onRemove } = props;
|
|
801
|
+
const ref = `${card.repo}#${String(card.number)}`;
|
|
802
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "ghp3-row", "data-github-pending": true, children: [
|
|
803
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(StyleSheet, { chunks: [CONTROLS_CSS, PENDING_CSS] }),
|
|
804
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("button", { type: "button", className: "ghp3-chip", title: `${ref} \xB7 ${card.title}
|
|
805
|
+
${t("pending.tip")}`, onClick: onOpenPanel, children: [
|
|
806
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(GitHubIcon, { size: 12 }),
|
|
807
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "ghp3-ref", children: ref })
|
|
808
|
+
] }),
|
|
809
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("button", { type: "button", className: "ghp3-remove", "aria-label": t("dock.removeDraft"), onClick: onRemove, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(CloseGlyph, { size: 12 }) })
|
|
810
|
+
] });
|
|
811
|
+
}
|
|
812
|
+
|
|
813
|
+
// src/client/views/Page.tsx
|
|
814
|
+
var import_react2 = require("react");
|
|
815
|
+
|
|
816
|
+
// node_modules/dompurify/dist/purify.es.mjs
|
|
817
|
+
function _OverloadYield(e, d) {
|
|
818
|
+
this.v = e, this.k = d;
|
|
819
|
+
}
|
|
820
|
+
function _arrayLikeToArray(r, a3) {
|
|
821
|
+
(null == a3 || a3 > r.length) && (a3 = r.length);
|
|
822
|
+
for (var e = 0, n = Array(a3); e < a3; e++) n[e] = r[e];
|
|
823
|
+
return n;
|
|
824
|
+
}
|
|
825
|
+
function _arrayWithHoles(r) {
|
|
826
|
+
if (Array.isArray(r)) return r;
|
|
827
|
+
}
|
|
828
|
+
function _iterableToArrayLimit(r, l) {
|
|
829
|
+
var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
|
|
830
|
+
if (null != t) {
|
|
831
|
+
var e, n, i, u, a3 = [], f = true, o = false;
|
|
832
|
+
try {
|
|
833
|
+
if (i = (t = t.call(r)).next, 0 === l) {
|
|
834
|
+
if (Object(t) !== t) return;
|
|
835
|
+
f = false;
|
|
836
|
+
} else for (; !(f = (e = i.call(t)).done) && (a3.push(e.value), a3.length !== l); f = true) ;
|
|
837
|
+
} catch (r2) {
|
|
838
|
+
o = true, n = r2;
|
|
839
|
+
} finally {
|
|
840
|
+
try {
|
|
841
|
+
if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
|
|
842
|
+
} finally {
|
|
843
|
+
if (o) throw n;
|
|
844
|
+
}
|
|
845
|
+
}
|
|
846
|
+
return a3;
|
|
847
|
+
}
|
|
848
|
+
}
|
|
849
|
+
function _nonIterableRest() {
|
|
850
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
851
|
+
}
|
|
852
|
+
function _slicedToArray(r, e) {
|
|
853
|
+
return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
|
|
854
|
+
}
|
|
855
|
+
function _unsupportedIterableToArray(r, a3) {
|
|
856
|
+
if (r) {
|
|
857
|
+
if ("string" == typeof r) return _arrayLikeToArray(r, a3);
|
|
858
|
+
var t = {}.toString.call(r).slice(8, -1);
|
|
859
|
+
return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a3) : void 0;
|
|
860
|
+
}
|
|
861
|
+
}
|
|
862
|
+
function AsyncGenerator(e) {
|
|
863
|
+
var t, n;
|
|
864
|
+
function resume(t2, n2) {
|
|
865
|
+
try {
|
|
866
|
+
var r = e[t2](n2), o = r.value, u = o instanceof _OverloadYield;
|
|
867
|
+
Promise.resolve(u ? o.v : o).then(function(n3) {
|
|
868
|
+
if (u) {
|
|
869
|
+
var i = "return" === t2 && o.k ? t2 : "next";
|
|
870
|
+
if (!o.k || n3.done) return resume(i, n3);
|
|
871
|
+
n3 = e[i](n3).value;
|
|
872
|
+
}
|
|
873
|
+
settle(!!r.done, n3);
|
|
874
|
+
}, function(e2) {
|
|
875
|
+
resume("throw", e2);
|
|
876
|
+
});
|
|
877
|
+
} catch (e2) {
|
|
878
|
+
settle(2, e2);
|
|
879
|
+
}
|
|
880
|
+
}
|
|
881
|
+
function settle(e2, r) {
|
|
882
|
+
2 === e2 ? t.reject(r) : t.resolve({
|
|
883
|
+
value: r,
|
|
884
|
+
done: e2
|
|
885
|
+
}), (t = t.next) ? resume(t.key, t.arg) : n = null;
|
|
886
|
+
}
|
|
887
|
+
this._invoke = function(e2, r) {
|
|
888
|
+
return new Promise(function(o, u) {
|
|
889
|
+
var i = {
|
|
890
|
+
key: e2,
|
|
891
|
+
arg: r,
|
|
892
|
+
resolve: o,
|
|
893
|
+
reject: u,
|
|
894
|
+
next: null
|
|
895
|
+
};
|
|
896
|
+
n ? n = n.next = i : (t = n = i, resume(e2, r));
|
|
897
|
+
});
|
|
898
|
+
}, "function" != typeof e.return && (this.return = void 0);
|
|
899
|
+
}
|
|
900
|
+
AsyncGenerator.prototype["function" == typeof Symbol && Symbol.asyncIterator || "@@asyncIterator"] = function() {
|
|
901
|
+
return this;
|
|
902
|
+
}, AsyncGenerator.prototype.next = function(e) {
|
|
903
|
+
return this._invoke("next", e);
|
|
904
|
+
}, AsyncGenerator.prototype.throw = function(e) {
|
|
905
|
+
return this._invoke("throw", e);
|
|
906
|
+
}, AsyncGenerator.prototype.return = function(e) {
|
|
907
|
+
return this._invoke("return", e);
|
|
908
|
+
};
|
|
909
|
+
var entries = Object.entries;
|
|
910
|
+
var setPrototypeOf = Object.setPrototypeOf;
|
|
911
|
+
var isFrozen = Object.isFrozen;
|
|
912
|
+
var getPrototypeOf = Object.getPrototypeOf;
|
|
913
|
+
var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
|
|
914
|
+
var freeze = Object.freeze;
|
|
915
|
+
var seal = Object.seal;
|
|
916
|
+
var create = Object.create;
|
|
917
|
+
var _ref = typeof Reflect !== "undefined" && Reflect;
|
|
918
|
+
var apply = _ref.apply;
|
|
919
|
+
var construct = _ref.construct;
|
|
920
|
+
if (!freeze) freeze = function freeze2(x) {
|
|
921
|
+
return x;
|
|
922
|
+
};
|
|
923
|
+
if (!seal) seal = function seal2(x) {
|
|
924
|
+
return x;
|
|
925
|
+
};
|
|
926
|
+
if (!apply) apply = function apply2(func, thisArg) {
|
|
927
|
+
for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) args[_key - 2] = arguments[_key];
|
|
928
|
+
return func.apply(thisArg, args);
|
|
929
|
+
};
|
|
930
|
+
if (!construct) construct = function construct2(Func) {
|
|
931
|
+
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) args[_key2 - 1] = arguments[_key2];
|
|
932
|
+
return new Func(...args);
|
|
933
|
+
};
|
|
934
|
+
var arrayForEach = unapply(Array.prototype.forEach);
|
|
935
|
+
Array.prototype.indexOf;
|
|
936
|
+
var arrayLastIndexOf = unapply(Array.prototype.lastIndexOf);
|
|
937
|
+
var arrayPop = unapply(Array.prototype.pop);
|
|
938
|
+
var arrayPush = unapply(Array.prototype.push);
|
|
939
|
+
var arraySlice = unapply(Array.prototype.slice);
|
|
940
|
+
var arraySplice = unapply(Array.prototype.splice);
|
|
941
|
+
var arrayIsArray = Array.isArray;
|
|
942
|
+
var setCreate = unconstruct(Set);
|
|
943
|
+
var setAdd = unapply(Set.prototype.add);
|
|
944
|
+
var setHas = unapply(Set.prototype.has);
|
|
945
|
+
var stringToLowerCase = unapply(String.prototype.toLowerCase);
|
|
946
|
+
var stringToString = unapply(String.prototype.toString);
|
|
947
|
+
var stringMatch = unapply(String.prototype.match);
|
|
948
|
+
var stringReplace = unapply(String.prototype.replace);
|
|
949
|
+
var stringIndexOf = unapply(String.prototype.indexOf);
|
|
950
|
+
var stringTrim = unapply(String.prototype.trim);
|
|
951
|
+
var numberToString = unapply(Number.prototype.toString);
|
|
952
|
+
var booleanToString = unapply(Boolean.prototype.toString);
|
|
953
|
+
var bigintToString = typeof BigInt === "undefined" ? null : unapply(BigInt.prototype.toString);
|
|
954
|
+
var symbolToString = typeof Symbol === "undefined" ? null : unapply(Symbol.prototype.toString);
|
|
955
|
+
var objectHasOwnProperty = unapply(Object.prototype.hasOwnProperty);
|
|
956
|
+
var objectToString = unapply(Object.prototype.toString);
|
|
957
|
+
var regExpTest = unapply(RegExp.prototype.test);
|
|
958
|
+
var typeErrorCreate = unconstruct(TypeError);
|
|
959
|
+
function unapply(func) {
|
|
960
|
+
return function(thisArg) {
|
|
961
|
+
if (thisArg instanceof RegExp) thisArg.lastIndex = 0;
|
|
962
|
+
for (var _len3 = arguments.length, args = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) args[_key3 - 1] = arguments[_key3];
|
|
963
|
+
return apply(func, thisArg, args);
|
|
964
|
+
};
|
|
965
|
+
}
|
|
966
|
+
function unconstruct(Func) {
|
|
967
|
+
return function() {
|
|
968
|
+
for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) args[_key4] = arguments[_key4];
|
|
969
|
+
return construct(Func, args);
|
|
970
|
+
};
|
|
971
|
+
}
|
|
972
|
+
function addToSet(set, array) {
|
|
973
|
+
let transformCaseFunc = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : stringToLowerCase;
|
|
974
|
+
if (setPrototypeOf) setPrototypeOf(set, null);
|
|
975
|
+
if (!arrayIsArray(array)) return set;
|
|
976
|
+
let l = array.length;
|
|
977
|
+
while (l--) {
|
|
978
|
+
let element = array[l];
|
|
979
|
+
if (typeof element === "string") {
|
|
980
|
+
const lcElement = transformCaseFunc(element);
|
|
981
|
+
if (lcElement !== element) {
|
|
982
|
+
if (!isFrozen(array)) array[l] = lcElement;
|
|
983
|
+
element = lcElement;
|
|
984
|
+
}
|
|
985
|
+
}
|
|
986
|
+
set[element] = true;
|
|
987
|
+
}
|
|
988
|
+
return set;
|
|
989
|
+
}
|
|
990
|
+
function cleanArray(array) {
|
|
991
|
+
for (let index = 0; index < array.length; index++) if (!objectHasOwnProperty(array, index)) array[index] = null;
|
|
992
|
+
return array;
|
|
993
|
+
}
|
|
994
|
+
function clone(object) {
|
|
995
|
+
const newObject = create(null);
|
|
996
|
+
for (const _ref2 of entries(object)) {
|
|
997
|
+
var _ref3 = _slicedToArray(_ref2, 2);
|
|
998
|
+
const property = _ref3[0];
|
|
999
|
+
const value = _ref3[1];
|
|
1000
|
+
if (objectHasOwnProperty(object, property)) {
|
|
1001
|
+
if (arrayIsArray(value)) newObject[property] = cleanArray(value);
|
|
1002
|
+
else if (value && typeof value === "object" && value.constructor === Object) newObject[property] = clone(value);
|
|
1003
|
+
else newObject[property] = value;
|
|
1004
|
+
}
|
|
1005
|
+
}
|
|
1006
|
+
return newObject;
|
|
1007
|
+
}
|
|
1008
|
+
function stringifyValue(value) {
|
|
1009
|
+
switch (typeof value) {
|
|
1010
|
+
case "string":
|
|
1011
|
+
return value;
|
|
1012
|
+
case "number":
|
|
1013
|
+
return numberToString(value);
|
|
1014
|
+
case "boolean":
|
|
1015
|
+
return booleanToString(value);
|
|
1016
|
+
case "bigint":
|
|
1017
|
+
return bigintToString ? bigintToString(value) : "0";
|
|
1018
|
+
case "symbol":
|
|
1019
|
+
return symbolToString ? symbolToString(value) : "Symbol()";
|
|
1020
|
+
case "undefined":
|
|
1021
|
+
return objectToString(value);
|
|
1022
|
+
case "function":
|
|
1023
|
+
case "object": {
|
|
1024
|
+
if (value === null) return objectToString(value);
|
|
1025
|
+
const valueAsRecord = value;
|
|
1026
|
+
const valueToString = lookupGetter(valueAsRecord, "toString");
|
|
1027
|
+
if (typeof valueToString === "function") {
|
|
1028
|
+
const stringified = valueToString(valueAsRecord);
|
|
1029
|
+
return typeof stringified === "string" ? stringified : objectToString(stringified);
|
|
1030
|
+
}
|
|
1031
|
+
return objectToString(value);
|
|
1032
|
+
}
|
|
1033
|
+
default:
|
|
1034
|
+
return objectToString(value);
|
|
1035
|
+
}
|
|
1036
|
+
}
|
|
1037
|
+
function lookupGetter(object, prop) {
|
|
1038
|
+
while (object !== null) {
|
|
1039
|
+
const desc = getOwnPropertyDescriptor(object, prop);
|
|
1040
|
+
if (desc) {
|
|
1041
|
+
if (desc.get) return unapply(desc.get);
|
|
1042
|
+
if (typeof desc.value === "function") return unapply(desc.value);
|
|
1043
|
+
}
|
|
1044
|
+
object = getPrototypeOf(object);
|
|
1045
|
+
}
|
|
1046
|
+
function fallbackValue() {
|
|
1047
|
+
return null;
|
|
1048
|
+
}
|
|
1049
|
+
return fallbackValue;
|
|
1050
|
+
}
|
|
1051
|
+
function lookupAccessor(object, prop) {
|
|
1052
|
+
while (object !== null) {
|
|
1053
|
+
const desc = getOwnPropertyDescriptor(object, prop);
|
|
1054
|
+
if (desc) return desc.get ? unapply(desc.get) : null;
|
|
1055
|
+
object = getPrototypeOf(object);
|
|
1056
|
+
}
|
|
1057
|
+
return null;
|
|
1058
|
+
}
|
|
1059
|
+
function isRegex(value) {
|
|
1060
|
+
try {
|
|
1061
|
+
regExpTest(value, "");
|
|
1062
|
+
return true;
|
|
1063
|
+
} catch (_unused) {
|
|
1064
|
+
return false;
|
|
1065
|
+
}
|
|
1066
|
+
}
|
|
1067
|
+
var html$1 = freeze([
|
|
1068
|
+
"a",
|
|
1069
|
+
"abbr",
|
|
1070
|
+
"acronym",
|
|
1071
|
+
"address",
|
|
1072
|
+
"area",
|
|
1073
|
+
"article",
|
|
1074
|
+
"aside",
|
|
1075
|
+
"audio",
|
|
1076
|
+
"b",
|
|
1077
|
+
"bdi",
|
|
1078
|
+
"bdo",
|
|
1079
|
+
"big",
|
|
1080
|
+
"blink",
|
|
1081
|
+
"blockquote",
|
|
1082
|
+
"body",
|
|
1083
|
+
"br",
|
|
1084
|
+
"button",
|
|
1085
|
+
"canvas",
|
|
1086
|
+
"caption",
|
|
1087
|
+
"center",
|
|
1088
|
+
"cite",
|
|
1089
|
+
"code",
|
|
1090
|
+
"col",
|
|
1091
|
+
"colgroup",
|
|
1092
|
+
"content",
|
|
1093
|
+
"data",
|
|
1094
|
+
"datalist",
|
|
1095
|
+
"dd",
|
|
1096
|
+
"decorator",
|
|
1097
|
+
"del",
|
|
1098
|
+
"details",
|
|
1099
|
+
"dfn",
|
|
1100
|
+
"dialog",
|
|
1101
|
+
"dir",
|
|
1102
|
+
"div",
|
|
1103
|
+
"dl",
|
|
1104
|
+
"dt",
|
|
1105
|
+
"element",
|
|
1106
|
+
"em",
|
|
1107
|
+
"fieldset",
|
|
1108
|
+
"figcaption",
|
|
1109
|
+
"figure",
|
|
1110
|
+
"font",
|
|
1111
|
+
"footer",
|
|
1112
|
+
"form",
|
|
1113
|
+
"h1",
|
|
1114
|
+
"h2",
|
|
1115
|
+
"h3",
|
|
1116
|
+
"h4",
|
|
1117
|
+
"h5",
|
|
1118
|
+
"h6",
|
|
1119
|
+
"head",
|
|
1120
|
+
"header",
|
|
1121
|
+
"hgroup",
|
|
1122
|
+
"hr",
|
|
1123
|
+
"html",
|
|
1124
|
+
"i",
|
|
1125
|
+
"img",
|
|
1126
|
+
"input",
|
|
1127
|
+
"ins",
|
|
1128
|
+
"kbd",
|
|
1129
|
+
"label",
|
|
1130
|
+
"legend",
|
|
1131
|
+
"li",
|
|
1132
|
+
"main",
|
|
1133
|
+
"map",
|
|
1134
|
+
"mark",
|
|
1135
|
+
"marquee",
|
|
1136
|
+
"menu",
|
|
1137
|
+
"menuitem",
|
|
1138
|
+
"meter",
|
|
1139
|
+
"nav",
|
|
1140
|
+
"nobr",
|
|
1141
|
+
"ol",
|
|
1142
|
+
"optgroup",
|
|
1143
|
+
"option",
|
|
1144
|
+
"output",
|
|
1145
|
+
"p",
|
|
1146
|
+
"picture",
|
|
1147
|
+
"pre",
|
|
1148
|
+
"progress",
|
|
1149
|
+
"q",
|
|
1150
|
+
"rp",
|
|
1151
|
+
"rt",
|
|
1152
|
+
"ruby",
|
|
1153
|
+
"s",
|
|
1154
|
+
"samp",
|
|
1155
|
+
"search",
|
|
1156
|
+
"section",
|
|
1157
|
+
"select",
|
|
1158
|
+
"shadow",
|
|
1159
|
+
"slot",
|
|
1160
|
+
"small",
|
|
1161
|
+
"source",
|
|
1162
|
+
"spacer",
|
|
1163
|
+
"span",
|
|
1164
|
+
"strike",
|
|
1165
|
+
"strong",
|
|
1166
|
+
"style",
|
|
1167
|
+
"sub",
|
|
1168
|
+
"summary",
|
|
1169
|
+
"sup",
|
|
1170
|
+
"table",
|
|
1171
|
+
"tbody",
|
|
1172
|
+
"td",
|
|
1173
|
+
"template",
|
|
1174
|
+
"textarea",
|
|
1175
|
+
"tfoot",
|
|
1176
|
+
"th",
|
|
1177
|
+
"thead",
|
|
1178
|
+
"time",
|
|
1179
|
+
"tr",
|
|
1180
|
+
"track",
|
|
1181
|
+
"tt",
|
|
1182
|
+
"u",
|
|
1183
|
+
"ul",
|
|
1184
|
+
"var",
|
|
1185
|
+
"video",
|
|
1186
|
+
"wbr"
|
|
1187
|
+
]);
|
|
1188
|
+
var svg$1 = freeze([
|
|
1189
|
+
"svg",
|
|
1190
|
+
"a",
|
|
1191
|
+
"altglyph",
|
|
1192
|
+
"altglyphdef",
|
|
1193
|
+
"altglyphitem",
|
|
1194
|
+
"animatecolor",
|
|
1195
|
+
"animatemotion",
|
|
1196
|
+
"animatetransform",
|
|
1197
|
+
"circle",
|
|
1198
|
+
"clippath",
|
|
1199
|
+
"defs",
|
|
1200
|
+
"desc",
|
|
1201
|
+
"ellipse",
|
|
1202
|
+
"enterkeyhint",
|
|
1203
|
+
"exportparts",
|
|
1204
|
+
"filter",
|
|
1205
|
+
"font",
|
|
1206
|
+
"g",
|
|
1207
|
+
"glyph",
|
|
1208
|
+
"glyphref",
|
|
1209
|
+
"hkern",
|
|
1210
|
+
"image",
|
|
1211
|
+
"inputmode",
|
|
1212
|
+
"line",
|
|
1213
|
+
"lineargradient",
|
|
1214
|
+
"marker",
|
|
1215
|
+
"mask",
|
|
1216
|
+
"metadata",
|
|
1217
|
+
"mpath",
|
|
1218
|
+
"part",
|
|
1219
|
+
"path",
|
|
1220
|
+
"pattern",
|
|
1221
|
+
"polygon",
|
|
1222
|
+
"polyline",
|
|
1223
|
+
"radialgradient",
|
|
1224
|
+
"rect",
|
|
1225
|
+
"stop",
|
|
1226
|
+
"style",
|
|
1227
|
+
"switch",
|
|
1228
|
+
"symbol",
|
|
1229
|
+
"text",
|
|
1230
|
+
"textpath",
|
|
1231
|
+
"title",
|
|
1232
|
+
"tref",
|
|
1233
|
+
"tspan",
|
|
1234
|
+
"view",
|
|
1235
|
+
"vkern"
|
|
1236
|
+
]);
|
|
1237
|
+
var svgFilters = freeze([
|
|
1238
|
+
"feBlend",
|
|
1239
|
+
"feColorMatrix",
|
|
1240
|
+
"feComponentTransfer",
|
|
1241
|
+
"feComposite",
|
|
1242
|
+
"feConvolveMatrix",
|
|
1243
|
+
"feDiffuseLighting",
|
|
1244
|
+
"feDisplacementMap",
|
|
1245
|
+
"feDistantLight",
|
|
1246
|
+
"feDropShadow",
|
|
1247
|
+
"feFlood",
|
|
1248
|
+
"feFuncA",
|
|
1249
|
+
"feFuncB",
|
|
1250
|
+
"feFuncG",
|
|
1251
|
+
"feFuncR",
|
|
1252
|
+
"feGaussianBlur",
|
|
1253
|
+
"feImage",
|
|
1254
|
+
"feMerge",
|
|
1255
|
+
"feMergeNode",
|
|
1256
|
+
"feMorphology",
|
|
1257
|
+
"feOffset",
|
|
1258
|
+
"fePointLight",
|
|
1259
|
+
"feSpecularLighting",
|
|
1260
|
+
"feSpotLight",
|
|
1261
|
+
"feTile",
|
|
1262
|
+
"feTurbulence"
|
|
1263
|
+
]);
|
|
1264
|
+
var svgDisallowed = freeze([
|
|
1265
|
+
"animate",
|
|
1266
|
+
"color-profile",
|
|
1267
|
+
"cursor",
|
|
1268
|
+
"discard",
|
|
1269
|
+
"font-face",
|
|
1270
|
+
"font-face-format",
|
|
1271
|
+
"font-face-name",
|
|
1272
|
+
"font-face-src",
|
|
1273
|
+
"font-face-uri",
|
|
1274
|
+
"foreignobject",
|
|
1275
|
+
"hatch",
|
|
1276
|
+
"hatchpath",
|
|
1277
|
+
"mesh",
|
|
1278
|
+
"meshgradient",
|
|
1279
|
+
"meshpatch",
|
|
1280
|
+
"meshrow",
|
|
1281
|
+
"missing-glyph",
|
|
1282
|
+
"script",
|
|
1283
|
+
"set",
|
|
1284
|
+
"solidcolor",
|
|
1285
|
+
"unknown",
|
|
1286
|
+
"use"
|
|
1287
|
+
]);
|
|
1288
|
+
var mathMl$1 = freeze([
|
|
1289
|
+
"math",
|
|
1290
|
+
"menclose",
|
|
1291
|
+
"merror",
|
|
1292
|
+
"mfenced",
|
|
1293
|
+
"mfrac",
|
|
1294
|
+
"mglyph",
|
|
1295
|
+
"mi",
|
|
1296
|
+
"mlabeledtr",
|
|
1297
|
+
"mmultiscripts",
|
|
1298
|
+
"mn",
|
|
1299
|
+
"mo",
|
|
1300
|
+
"mover",
|
|
1301
|
+
"mpadded",
|
|
1302
|
+
"mphantom",
|
|
1303
|
+
"mroot",
|
|
1304
|
+
"mrow",
|
|
1305
|
+
"ms",
|
|
1306
|
+
"mspace",
|
|
1307
|
+
"msqrt",
|
|
1308
|
+
"mstyle",
|
|
1309
|
+
"msub",
|
|
1310
|
+
"msup",
|
|
1311
|
+
"msubsup",
|
|
1312
|
+
"mtable",
|
|
1313
|
+
"mtd",
|
|
1314
|
+
"mtext",
|
|
1315
|
+
"mtr",
|
|
1316
|
+
"munder",
|
|
1317
|
+
"munderover",
|
|
1318
|
+
"mprescripts"
|
|
1319
|
+
]);
|
|
1320
|
+
var mathMlDisallowed = freeze([
|
|
1321
|
+
"maction",
|
|
1322
|
+
"maligngroup",
|
|
1323
|
+
"malignmark",
|
|
1324
|
+
"mlongdiv",
|
|
1325
|
+
"mscarries",
|
|
1326
|
+
"mscarry",
|
|
1327
|
+
"msgroup",
|
|
1328
|
+
"mstack",
|
|
1329
|
+
"msline",
|
|
1330
|
+
"msrow",
|
|
1331
|
+
"semantics",
|
|
1332
|
+
"annotation",
|
|
1333
|
+
"annotation-xml",
|
|
1334
|
+
"mprescripts",
|
|
1335
|
+
"none"
|
|
1336
|
+
]);
|
|
1337
|
+
var text = freeze(["#text"]);
|
|
1338
|
+
var html = freeze([
|
|
1339
|
+
"accept",
|
|
1340
|
+
"action",
|
|
1341
|
+
"align",
|
|
1342
|
+
"alt",
|
|
1343
|
+
"autocapitalize",
|
|
1344
|
+
"autocomplete",
|
|
1345
|
+
"autopictureinpicture",
|
|
1346
|
+
"autoplay",
|
|
1347
|
+
"background",
|
|
1348
|
+
"bgcolor",
|
|
1349
|
+
"border",
|
|
1350
|
+
"capture",
|
|
1351
|
+
"cellpadding",
|
|
1352
|
+
"cellspacing",
|
|
1353
|
+
"checked",
|
|
1354
|
+
"cite",
|
|
1355
|
+
"class",
|
|
1356
|
+
"clear",
|
|
1357
|
+
"color",
|
|
1358
|
+
"cols",
|
|
1359
|
+
"colspan",
|
|
1360
|
+
"command",
|
|
1361
|
+
"commandfor",
|
|
1362
|
+
"controls",
|
|
1363
|
+
"controlslist",
|
|
1364
|
+
"coords",
|
|
1365
|
+
"crossorigin",
|
|
1366
|
+
"datetime",
|
|
1367
|
+
"decoding",
|
|
1368
|
+
"default",
|
|
1369
|
+
"dir",
|
|
1370
|
+
"disabled",
|
|
1371
|
+
"disablepictureinpicture",
|
|
1372
|
+
"disableremoteplayback",
|
|
1373
|
+
"download",
|
|
1374
|
+
"draggable",
|
|
1375
|
+
"enctype",
|
|
1376
|
+
"enterkeyhint",
|
|
1377
|
+
"exportparts",
|
|
1378
|
+
"face",
|
|
1379
|
+
"for",
|
|
1380
|
+
"headers",
|
|
1381
|
+
"height",
|
|
1382
|
+
"hidden",
|
|
1383
|
+
"high",
|
|
1384
|
+
"href",
|
|
1385
|
+
"hreflang",
|
|
1386
|
+
"id",
|
|
1387
|
+
"inert",
|
|
1388
|
+
"inputmode",
|
|
1389
|
+
"integrity",
|
|
1390
|
+
"ismap",
|
|
1391
|
+
"kind",
|
|
1392
|
+
"label",
|
|
1393
|
+
"lang",
|
|
1394
|
+
"list",
|
|
1395
|
+
"loading",
|
|
1396
|
+
"loop",
|
|
1397
|
+
"low",
|
|
1398
|
+
"max",
|
|
1399
|
+
"maxlength",
|
|
1400
|
+
"media",
|
|
1401
|
+
"method",
|
|
1402
|
+
"min",
|
|
1403
|
+
"minlength",
|
|
1404
|
+
"multiple",
|
|
1405
|
+
"muted",
|
|
1406
|
+
"name",
|
|
1407
|
+
"nonce",
|
|
1408
|
+
"noshade",
|
|
1409
|
+
"novalidate",
|
|
1410
|
+
"nowrap",
|
|
1411
|
+
"open",
|
|
1412
|
+
"optimum",
|
|
1413
|
+
"part",
|
|
1414
|
+
"pattern",
|
|
1415
|
+
"placeholder",
|
|
1416
|
+
"playsinline",
|
|
1417
|
+
"popover",
|
|
1418
|
+
"popovertarget",
|
|
1419
|
+
"popovertargetaction",
|
|
1420
|
+
"poster",
|
|
1421
|
+
"preload",
|
|
1422
|
+
"pubdate",
|
|
1423
|
+
"radiogroup",
|
|
1424
|
+
"readonly",
|
|
1425
|
+
"rel",
|
|
1426
|
+
"required",
|
|
1427
|
+
"rev",
|
|
1428
|
+
"reversed",
|
|
1429
|
+
"role",
|
|
1430
|
+
"rows",
|
|
1431
|
+
"rowspan",
|
|
1432
|
+
"spellcheck",
|
|
1433
|
+
"scope",
|
|
1434
|
+
"selected",
|
|
1435
|
+
"shape",
|
|
1436
|
+
"size",
|
|
1437
|
+
"sizes",
|
|
1438
|
+
"slot",
|
|
1439
|
+
"span",
|
|
1440
|
+
"srclang",
|
|
1441
|
+
"start",
|
|
1442
|
+
"src",
|
|
1443
|
+
"srcset",
|
|
1444
|
+
"step",
|
|
1445
|
+
"style",
|
|
1446
|
+
"summary",
|
|
1447
|
+
"tabindex",
|
|
1448
|
+
"title",
|
|
1449
|
+
"translate",
|
|
1450
|
+
"type",
|
|
1451
|
+
"usemap",
|
|
1452
|
+
"valign",
|
|
1453
|
+
"value",
|
|
1454
|
+
"width",
|
|
1455
|
+
"wrap",
|
|
1456
|
+
"xmlns"
|
|
1457
|
+
]);
|
|
1458
|
+
var svg = freeze([
|
|
1459
|
+
"accent-height",
|
|
1460
|
+
"accumulate",
|
|
1461
|
+
"additive",
|
|
1462
|
+
"alignment-baseline",
|
|
1463
|
+
"amplitude",
|
|
1464
|
+
"ascent",
|
|
1465
|
+
"attributename",
|
|
1466
|
+
"attributetype",
|
|
1467
|
+
"azimuth",
|
|
1468
|
+
"basefrequency",
|
|
1469
|
+
"baseline-shift",
|
|
1470
|
+
"begin",
|
|
1471
|
+
"bias",
|
|
1472
|
+
"by",
|
|
1473
|
+
"class",
|
|
1474
|
+
"clip",
|
|
1475
|
+
"clippathunits",
|
|
1476
|
+
"clip-path",
|
|
1477
|
+
"clip-rule",
|
|
1478
|
+
"color",
|
|
1479
|
+
"color-interpolation",
|
|
1480
|
+
"color-interpolation-filters",
|
|
1481
|
+
"color-profile",
|
|
1482
|
+
"color-rendering",
|
|
1483
|
+
"cx",
|
|
1484
|
+
"cy",
|
|
1485
|
+
"d",
|
|
1486
|
+
"dx",
|
|
1487
|
+
"dy",
|
|
1488
|
+
"diffuseconstant",
|
|
1489
|
+
"direction",
|
|
1490
|
+
"display",
|
|
1491
|
+
"divisor",
|
|
1492
|
+
"dominant-baseline",
|
|
1493
|
+
"dur",
|
|
1494
|
+
"edgemode",
|
|
1495
|
+
"elevation",
|
|
1496
|
+
"end",
|
|
1497
|
+
"exponent",
|
|
1498
|
+
"fill",
|
|
1499
|
+
"fill-opacity",
|
|
1500
|
+
"fill-rule",
|
|
1501
|
+
"filter",
|
|
1502
|
+
"filterunits",
|
|
1503
|
+
"flood-color",
|
|
1504
|
+
"flood-opacity",
|
|
1505
|
+
"font-family",
|
|
1506
|
+
"font-size",
|
|
1507
|
+
"font-size-adjust",
|
|
1508
|
+
"font-stretch",
|
|
1509
|
+
"font-style",
|
|
1510
|
+
"font-variant",
|
|
1511
|
+
"font-weight",
|
|
1512
|
+
"fx",
|
|
1513
|
+
"fy",
|
|
1514
|
+
"g1",
|
|
1515
|
+
"g2",
|
|
1516
|
+
"glyph-name",
|
|
1517
|
+
"glyphref",
|
|
1518
|
+
"gradientunits",
|
|
1519
|
+
"gradienttransform",
|
|
1520
|
+
"height",
|
|
1521
|
+
"href",
|
|
1522
|
+
"id",
|
|
1523
|
+
"image-rendering",
|
|
1524
|
+
"in",
|
|
1525
|
+
"in2",
|
|
1526
|
+
"intercept",
|
|
1527
|
+
"k",
|
|
1528
|
+
"k1",
|
|
1529
|
+
"k2",
|
|
1530
|
+
"k3",
|
|
1531
|
+
"k4",
|
|
1532
|
+
"kerning",
|
|
1533
|
+
"keypoints",
|
|
1534
|
+
"keysplines",
|
|
1535
|
+
"keytimes",
|
|
1536
|
+
"lang",
|
|
1537
|
+
"lengthadjust",
|
|
1538
|
+
"letter-spacing",
|
|
1539
|
+
"kernelmatrix",
|
|
1540
|
+
"kernelunitlength",
|
|
1541
|
+
"lighting-color",
|
|
1542
|
+
"local",
|
|
1543
|
+
"marker-end",
|
|
1544
|
+
"marker-mid",
|
|
1545
|
+
"marker-start",
|
|
1546
|
+
"markerheight",
|
|
1547
|
+
"markerunits",
|
|
1548
|
+
"markerwidth",
|
|
1549
|
+
"maskcontentunits",
|
|
1550
|
+
"maskunits",
|
|
1551
|
+
"max",
|
|
1552
|
+
"mask",
|
|
1553
|
+
"mask-type",
|
|
1554
|
+
"media",
|
|
1555
|
+
"method",
|
|
1556
|
+
"mode",
|
|
1557
|
+
"min",
|
|
1558
|
+
"name",
|
|
1559
|
+
"numoctaves",
|
|
1560
|
+
"offset",
|
|
1561
|
+
"operator",
|
|
1562
|
+
"opacity",
|
|
1563
|
+
"order",
|
|
1564
|
+
"orient",
|
|
1565
|
+
"orientation",
|
|
1566
|
+
"origin",
|
|
1567
|
+
"overflow",
|
|
1568
|
+
"paint-order",
|
|
1569
|
+
"path",
|
|
1570
|
+
"pathlength",
|
|
1571
|
+
"patterncontentunits",
|
|
1572
|
+
"patterntransform",
|
|
1573
|
+
"patternunits",
|
|
1574
|
+
"pointer-events",
|
|
1575
|
+
"points",
|
|
1576
|
+
"preservealpha",
|
|
1577
|
+
"preserveaspectratio",
|
|
1578
|
+
"primitiveunits",
|
|
1579
|
+
"r",
|
|
1580
|
+
"rx",
|
|
1581
|
+
"ry",
|
|
1582
|
+
"radius",
|
|
1583
|
+
"refx",
|
|
1584
|
+
"refy",
|
|
1585
|
+
"repeatcount",
|
|
1586
|
+
"repeatdur",
|
|
1587
|
+
"restart",
|
|
1588
|
+
"result",
|
|
1589
|
+
"rotate",
|
|
1590
|
+
"scale",
|
|
1591
|
+
"seed",
|
|
1592
|
+
"shape-rendering",
|
|
1593
|
+
"slope",
|
|
1594
|
+
"specularconstant",
|
|
1595
|
+
"specularexponent",
|
|
1596
|
+
"spreadmethod",
|
|
1597
|
+
"startoffset",
|
|
1598
|
+
"stddeviation",
|
|
1599
|
+
"stitchtiles",
|
|
1600
|
+
"stop-color",
|
|
1601
|
+
"stop-opacity",
|
|
1602
|
+
"stroke-dasharray",
|
|
1603
|
+
"stroke-dashoffset",
|
|
1604
|
+
"stroke-linecap",
|
|
1605
|
+
"stroke-linejoin",
|
|
1606
|
+
"stroke-miterlimit",
|
|
1607
|
+
"stroke-opacity",
|
|
1608
|
+
"stroke",
|
|
1609
|
+
"stroke-width",
|
|
1610
|
+
"style",
|
|
1611
|
+
"surfacescale",
|
|
1612
|
+
"systemlanguage",
|
|
1613
|
+
"tabindex",
|
|
1614
|
+
"tablevalues",
|
|
1615
|
+
"targetx",
|
|
1616
|
+
"targety",
|
|
1617
|
+
"transform",
|
|
1618
|
+
"transform-origin",
|
|
1619
|
+
"text-anchor",
|
|
1620
|
+
"text-decoration",
|
|
1621
|
+
"text-orientation",
|
|
1622
|
+
"text-rendering",
|
|
1623
|
+
"textlength",
|
|
1624
|
+
"type",
|
|
1625
|
+
"u1",
|
|
1626
|
+
"u2",
|
|
1627
|
+
"unicode",
|
|
1628
|
+
"values",
|
|
1629
|
+
"vector-effect",
|
|
1630
|
+
"viewbox",
|
|
1631
|
+
"visibility",
|
|
1632
|
+
"version",
|
|
1633
|
+
"vert-adv-y",
|
|
1634
|
+
"vert-origin-x",
|
|
1635
|
+
"vert-origin-y",
|
|
1636
|
+
"width",
|
|
1637
|
+
"word-spacing",
|
|
1638
|
+
"wrap",
|
|
1639
|
+
"writing-mode",
|
|
1640
|
+
"xchannelselector",
|
|
1641
|
+
"ychannelselector",
|
|
1642
|
+
"x",
|
|
1643
|
+
"x1",
|
|
1644
|
+
"x2",
|
|
1645
|
+
"xmlns",
|
|
1646
|
+
"y",
|
|
1647
|
+
"y1",
|
|
1648
|
+
"y2",
|
|
1649
|
+
"z",
|
|
1650
|
+
"zoomandpan"
|
|
1651
|
+
]);
|
|
1652
|
+
var mathMl = freeze([
|
|
1653
|
+
"accent",
|
|
1654
|
+
"accentunder",
|
|
1655
|
+
"align",
|
|
1656
|
+
"bevelled",
|
|
1657
|
+
"close",
|
|
1658
|
+
"columnalign",
|
|
1659
|
+
"columnlines",
|
|
1660
|
+
"columnspacing",
|
|
1661
|
+
"columnspan",
|
|
1662
|
+
"denomalign",
|
|
1663
|
+
"depth",
|
|
1664
|
+
"dir",
|
|
1665
|
+
"display",
|
|
1666
|
+
"displaystyle",
|
|
1667
|
+
"encoding",
|
|
1668
|
+
"fence",
|
|
1669
|
+
"frame",
|
|
1670
|
+
"height",
|
|
1671
|
+
"href",
|
|
1672
|
+
"id",
|
|
1673
|
+
"largeop",
|
|
1674
|
+
"length",
|
|
1675
|
+
"linethickness",
|
|
1676
|
+
"lquote",
|
|
1677
|
+
"lspace",
|
|
1678
|
+
"mathbackground",
|
|
1679
|
+
"mathcolor",
|
|
1680
|
+
"mathsize",
|
|
1681
|
+
"mathvariant",
|
|
1682
|
+
"maxsize",
|
|
1683
|
+
"minsize",
|
|
1684
|
+
"movablelimits",
|
|
1685
|
+
"notation",
|
|
1686
|
+
"numalign",
|
|
1687
|
+
"open",
|
|
1688
|
+
"rowalign",
|
|
1689
|
+
"rowlines",
|
|
1690
|
+
"rowspacing",
|
|
1691
|
+
"rowspan",
|
|
1692
|
+
"rspace",
|
|
1693
|
+
"rquote",
|
|
1694
|
+
"scriptlevel",
|
|
1695
|
+
"scriptminsize",
|
|
1696
|
+
"scriptsizemultiplier",
|
|
1697
|
+
"selection",
|
|
1698
|
+
"separator",
|
|
1699
|
+
"separators",
|
|
1700
|
+
"stretchy",
|
|
1701
|
+
"subscriptshift",
|
|
1702
|
+
"supscriptshift",
|
|
1703
|
+
"symmetric",
|
|
1704
|
+
"voffset",
|
|
1705
|
+
"width",
|
|
1706
|
+
"xmlns"
|
|
1707
|
+
]);
|
|
1708
|
+
var xml = freeze([
|
|
1709
|
+
"xlink:href",
|
|
1710
|
+
"xml:id",
|
|
1711
|
+
"xlink:title",
|
|
1712
|
+
"xml:space",
|
|
1713
|
+
"xmlns:xlink"
|
|
1714
|
+
]);
|
|
1715
|
+
var MUSTACHE_EXPR = seal(/{{[\w\W]*|^[\w\W]*}}/g);
|
|
1716
|
+
var ERB_EXPR = seal(/<%[\w\W]*|^[\w\W]*%>/g);
|
|
1717
|
+
var TMPLIT_EXPR = seal(/\${[\w\W]*/g);
|
|
1718
|
+
var DATA_ATTR = seal(/^data-[\-\w.\u00B7-\uFFFF]+$/);
|
|
1719
|
+
var ARIA_ATTR = seal(/^aria-[\-\w]+$/);
|
|
1720
|
+
var IS_ALLOWED_URI = seal(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i);
|
|
1721
|
+
var IS_SCRIPT_OR_DATA = seal(/^(?:\w+script|data):/i);
|
|
1722
|
+
var ATTR_WHITESPACE = seal(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g);
|
|
1723
|
+
var DOCTYPE_NAME = seal(/^html$/i);
|
|
1724
|
+
var CUSTOM_ELEMENT = seal(/^[a-z][.\w]*(-[.\w]+)+$/i);
|
|
1725
|
+
var ELEMENT_MARKUP_PROBE = seal(/<[/\w!]/g);
|
|
1726
|
+
var COMMENT_MARKUP_PROBE = seal(/<[/\w]/g);
|
|
1727
|
+
var FALLBACK_TAG_CLOSE = seal(/<\/no(script|embed|frames)/i);
|
|
1728
|
+
var SELF_CLOSING_TAG = seal(/\/>/i);
|
|
1729
|
+
var NODE_TYPE = {
|
|
1730
|
+
element: 1,
|
|
1731
|
+
attribute: 2,
|
|
1732
|
+
text: 3,
|
|
1733
|
+
cdataSection: 4,
|
|
1734
|
+
entityReference: 5,
|
|
1735
|
+
entityNode: 6,
|
|
1736
|
+
processingInstruction: 7,
|
|
1737
|
+
comment: 8,
|
|
1738
|
+
document: 9,
|
|
1739
|
+
documentType: 10,
|
|
1740
|
+
documentFragment: 11,
|
|
1741
|
+
notation: 12
|
|
1742
|
+
};
|
|
1743
|
+
var LITERAL_TEXT_ELEMENTS = freeze(addToSet({}, [
|
|
1744
|
+
"style",
|
|
1745
|
+
"script",
|
|
1746
|
+
"xmp",
|
|
1747
|
+
"iframe",
|
|
1748
|
+
"noembed",
|
|
1749
|
+
"noframes",
|
|
1750
|
+
"plaintext",
|
|
1751
|
+
"noscript"
|
|
1752
|
+
]));
|
|
1753
|
+
var getGlobal = function getGlobal2() {
|
|
1754
|
+
return typeof window === "undefined" ? null : window;
|
|
1755
|
+
};
|
|
1756
|
+
var _createTrustedTypesPolicy = function _createTrustedTypesPolicy2(trustedTypes, purifyHostElement) {
|
|
1757
|
+
if (typeof trustedTypes !== "object" || typeof trustedTypes.createPolicy !== "function") return null;
|
|
1758
|
+
let suffix = null;
|
|
1759
|
+
const ATTR_NAME = "data-tt-policy-suffix";
|
|
1760
|
+
if (purifyHostElement && purifyHostElement.hasAttribute(ATTR_NAME)) suffix = purifyHostElement.getAttribute(ATTR_NAME);
|
|
1761
|
+
const policyName = "dompurify" + (suffix ? "#" + suffix : "");
|
|
1762
|
+
try {
|
|
1763
|
+
return trustedTypes.createPolicy(policyName, {
|
|
1764
|
+
createHTML(html2) {
|
|
1765
|
+
return html2;
|
|
1766
|
+
},
|
|
1767
|
+
createScriptURL(scriptUrl) {
|
|
1768
|
+
return scriptUrl;
|
|
1769
|
+
}
|
|
1770
|
+
});
|
|
1771
|
+
} catch (_2) {
|
|
1772
|
+
console.warn("TrustedTypes policy " + policyName + " could not be created.");
|
|
1773
|
+
return null;
|
|
1774
|
+
}
|
|
1775
|
+
};
|
|
1776
|
+
var _createHooksMap = function _createHooksMap2() {
|
|
1777
|
+
return {
|
|
1778
|
+
afterSanitizeAttributes: [],
|
|
1779
|
+
afterSanitizeElements: [],
|
|
1780
|
+
afterSanitizeShadowDOM: [],
|
|
1781
|
+
beforeSanitizeAttributes: [],
|
|
1782
|
+
beforeSanitizeElements: [],
|
|
1783
|
+
beforeSanitizeShadowDOM: [],
|
|
1784
|
+
uponSanitizeAttribute: [],
|
|
1785
|
+
uponSanitizeElement: [],
|
|
1786
|
+
uponSanitizeShadowNode: []
|
|
1787
|
+
};
|
|
1788
|
+
};
|
|
1789
|
+
var _resolveSetOption = function _resolveSetOption2(cfg, key, fallback, options) {
|
|
1790
|
+
return objectHasOwnProperty(cfg, key) && arrayIsArray(cfg[key]) ? addToSet(options.base ? clone(options.base) : {}, cfg[key], options.transform) : fallback;
|
|
1791
|
+
};
|
|
1792
|
+
var _resolveObjectOption = function _resolveObjectOption2(cfg, key, makeFallback) {
|
|
1793
|
+
const value = objectHasOwnProperty(cfg, key) ? cfg[key] : void 0;
|
|
1794
|
+
return value && typeof value === "object" ? clone(value) : makeFallback();
|
|
1795
|
+
};
|
|
1796
|
+
function createDOMPurify() {
|
|
1797
|
+
let window2 = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : getGlobal();
|
|
1798
|
+
const DOMPurify = (root) => createDOMPurify(root);
|
|
1799
|
+
DOMPurify.version = "3.4.17";
|
|
1800
|
+
DOMPurify.removed = [];
|
|
1801
|
+
if (!window2 || !window2.document || window2.document.nodeType !== NODE_TYPE.document || !window2.Element) {
|
|
1802
|
+
DOMPurify.isSupported = false;
|
|
1803
|
+
return DOMPurify;
|
|
1804
|
+
}
|
|
1805
|
+
let document2 = window2.document;
|
|
1806
|
+
const originalDocument = document2;
|
|
1807
|
+
const currentScript = originalDocument.currentScript;
|
|
1808
|
+
window2.DocumentFragment;
|
|
1809
|
+
const HTMLTemplateElement = window2.HTMLTemplateElement, Node = window2.Node, Element = window2.Element, NodeFilter = window2.NodeFilter;
|
|
1810
|
+
window2.NamedNodeMap === void 0 && (window2.NamedNodeMap || window2.MozNamedAttrMap);
|
|
1811
|
+
window2.HTMLFormElement;
|
|
1812
|
+
const DOMParser = window2.DOMParser, trustedTypes = window2.trustedTypes;
|
|
1813
|
+
const ElementPrototype = Element.prototype;
|
|
1814
|
+
const cloneNode = lookupGetter(ElementPrototype, "cloneNode");
|
|
1815
|
+
const remove = lookupGetter(ElementPrototype, "remove");
|
|
1816
|
+
const removeAttributeNode = lookupGetter(ElementPrototype, "removeAttributeNode");
|
|
1817
|
+
const getNextSibling = lookupGetter(ElementPrototype, "nextSibling");
|
|
1818
|
+
const getChildNodes = lookupGetter(ElementPrototype, "childNodes");
|
|
1819
|
+
const getParentNode = lookupGetter(ElementPrototype, "parentNode");
|
|
1820
|
+
const getShadowRoot = lookupGetter(ElementPrototype, "shadowRoot");
|
|
1821
|
+
const getAttributes = lookupGetter(ElementPrototype, "attributes");
|
|
1822
|
+
const getNodeType = Node && Node.prototype ? lookupGetter(Node.prototype, "nodeType") : null;
|
|
1823
|
+
const getNodeName = Node && Node.prototype ? lookupGetter(Node.prototype, "nodeName") : null;
|
|
1824
|
+
const getOwnerDocument = Node && Node.prototype ? lookupGetter(Node.prototype, "ownerDocument") : null;
|
|
1825
|
+
const _readNodeType = function _readNodeType2(node) {
|
|
1826
|
+
return getNodeType ? getNodeType(node) : node.nodeType;
|
|
1827
|
+
};
|
|
1828
|
+
const _readNodeName = function _readNodeName2(node) {
|
|
1829
|
+
return getNodeName ? getNodeName(node) : node.nodeName;
|
|
1830
|
+
};
|
|
1831
|
+
const getNamespaceURI = lookupAccessor(ElementPrototype, "namespaceURI");
|
|
1832
|
+
const _readNamespaceURI = function _readNamespaceURI2(element) {
|
|
1833
|
+
return getNamespaceURI ? getNamespaceURI(element) : element.namespaceURI;
|
|
1834
|
+
};
|
|
1835
|
+
if (typeof HTMLTemplateElement === "function") {
|
|
1836
|
+
const template = document2.createElement("template");
|
|
1837
|
+
if (template.content && template.content.ownerDocument) document2 = template.content.ownerDocument;
|
|
1838
|
+
}
|
|
1839
|
+
let trustedTypesPolicy;
|
|
1840
|
+
let emptyHTML = "";
|
|
1841
|
+
let defaultTrustedTypesPolicy;
|
|
1842
|
+
let defaultTrustedTypesPolicyResolved = false;
|
|
1843
|
+
let IN_TRUSTED_TYPES_POLICY = 0;
|
|
1844
|
+
const _assertNotInTrustedTypesPolicy = function _assertNotInTrustedTypesPolicy2() {
|
|
1845
|
+
if (IN_TRUSTED_TYPES_POLICY > 0) throw typeErrorCreate('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.');
|
|
1846
|
+
};
|
|
1847
|
+
const _createTrustedHTML = function _createTrustedHTML2(html2) {
|
|
1848
|
+
_assertNotInTrustedTypesPolicy();
|
|
1849
|
+
IN_TRUSTED_TYPES_POLICY++;
|
|
1850
|
+
try {
|
|
1851
|
+
return trustedTypesPolicy.createHTML(html2);
|
|
1852
|
+
} finally {
|
|
1853
|
+
IN_TRUSTED_TYPES_POLICY--;
|
|
1854
|
+
}
|
|
1855
|
+
};
|
|
1856
|
+
const _createTrustedScriptURL = function _createTrustedScriptURL2(scriptUrl) {
|
|
1857
|
+
_assertNotInTrustedTypesPolicy();
|
|
1858
|
+
IN_TRUSTED_TYPES_POLICY++;
|
|
1859
|
+
try {
|
|
1860
|
+
return trustedTypesPolicy.createScriptURL(scriptUrl);
|
|
1861
|
+
} finally {
|
|
1862
|
+
IN_TRUSTED_TYPES_POLICY--;
|
|
1863
|
+
}
|
|
1864
|
+
};
|
|
1865
|
+
const _getDefaultTrustedTypesPolicy = function _getDefaultTrustedTypesPolicy2() {
|
|
1866
|
+
if (!defaultTrustedTypesPolicyResolved) {
|
|
1867
|
+
defaultTrustedTypesPolicy = _createTrustedTypesPolicy(trustedTypes, currentScript);
|
|
1868
|
+
defaultTrustedTypesPolicyResolved = true;
|
|
1869
|
+
}
|
|
1870
|
+
return defaultTrustedTypesPolicy;
|
|
1871
|
+
};
|
|
1872
|
+
const _document = document2, implementation = _document.implementation, createNodeIterator = _document.createNodeIterator, createDocumentFragment = _document.createDocumentFragment, getElementsByTagName = _document.getElementsByTagName;
|
|
1873
|
+
const importNode = originalDocument.importNode;
|
|
1874
|
+
let hooks = _createHooksMap();
|
|
1875
|
+
DOMPurify.isSupported = typeof entries === "function" && typeof getParentNode === "function" && implementation && implementation.createHTMLDocument !== void 0;
|
|
1876
|
+
const MUSTACHE_EXPR$1 = MUSTACHE_EXPR, ERB_EXPR$1 = ERB_EXPR, TMPLIT_EXPR$1 = TMPLIT_EXPR, DATA_ATTR$1 = DATA_ATTR, ARIA_ATTR$1 = ARIA_ATTR, IS_SCRIPT_OR_DATA$1 = IS_SCRIPT_OR_DATA, ATTR_WHITESPACE$1 = ATTR_WHITESPACE, CUSTOM_ELEMENT$1 = CUSTOM_ELEMENT;
|
|
1877
|
+
let IS_ALLOWED_URI$1 = IS_ALLOWED_URI;
|
|
1878
|
+
let ALLOWED_TAGS = null;
|
|
1879
|
+
const DEFAULT_ALLOWED_TAGS = addToSet({}, [
|
|
1880
|
+
...html$1,
|
|
1881
|
+
...svg$1,
|
|
1882
|
+
...svgFilters,
|
|
1883
|
+
...mathMl$1,
|
|
1884
|
+
...text
|
|
1885
|
+
]);
|
|
1886
|
+
let ALLOWED_ATTR = null;
|
|
1887
|
+
const DEFAULT_ALLOWED_ATTR = addToSet({}, [
|
|
1888
|
+
...html,
|
|
1889
|
+
...svg,
|
|
1890
|
+
...mathMl,
|
|
1891
|
+
...xml
|
|
1892
|
+
]);
|
|
1893
|
+
let CUSTOM_ELEMENT_HANDLING = Object.seal(create(null, {
|
|
1894
|
+
tagNameCheck: {
|
|
1895
|
+
writable: true,
|
|
1896
|
+
configurable: false,
|
|
1897
|
+
enumerable: true,
|
|
1898
|
+
value: null
|
|
1899
|
+
},
|
|
1900
|
+
attributeNameCheck: {
|
|
1901
|
+
writable: true,
|
|
1902
|
+
configurable: false,
|
|
1903
|
+
enumerable: true,
|
|
1904
|
+
value: null
|
|
1905
|
+
},
|
|
1906
|
+
allowCustomizedBuiltInElements: {
|
|
1907
|
+
writable: true,
|
|
1908
|
+
configurable: false,
|
|
1909
|
+
enumerable: true,
|
|
1910
|
+
value: false
|
|
1911
|
+
}
|
|
1912
|
+
}));
|
|
1913
|
+
let FORBID_TAGS = null;
|
|
1914
|
+
let FORBID_ATTR = null;
|
|
1915
|
+
const EXTRA_ELEMENT_HANDLING = Object.seal(create(null, {
|
|
1916
|
+
tagCheck: {
|
|
1917
|
+
writable: true,
|
|
1918
|
+
configurable: false,
|
|
1919
|
+
enumerable: true,
|
|
1920
|
+
value: null
|
|
1921
|
+
},
|
|
1922
|
+
attributeCheck: {
|
|
1923
|
+
writable: true,
|
|
1924
|
+
configurable: false,
|
|
1925
|
+
enumerable: true,
|
|
1926
|
+
value: null
|
|
1927
|
+
}
|
|
1928
|
+
}));
|
|
1929
|
+
let ALLOW_ARIA_ATTR = true;
|
|
1930
|
+
let ALLOW_DATA_ATTR = true;
|
|
1931
|
+
let ALLOW_UNKNOWN_PROTOCOLS = false;
|
|
1932
|
+
let ALLOW_SELF_CLOSE_IN_ATTR = true;
|
|
1933
|
+
let SAFE_FOR_TEMPLATES = false;
|
|
1934
|
+
let SAFE_FOR_XML = true;
|
|
1935
|
+
let WHOLE_DOCUMENT = false;
|
|
1936
|
+
let SET_CONFIG = false;
|
|
1937
|
+
let SET_CONFIG_ALLOWED_TAGS = null;
|
|
1938
|
+
let SET_CONFIG_ALLOWED_ATTR = null;
|
|
1939
|
+
let FORCE_BODY = false;
|
|
1940
|
+
let RETURN_DOM = false;
|
|
1941
|
+
let RETURN_DOM_FRAGMENT = false;
|
|
1942
|
+
let RETURN_TRUSTED_TYPE = false;
|
|
1943
|
+
let SANITIZE_DOM = true;
|
|
1944
|
+
let SANITIZE_NAMED_PROPS = false;
|
|
1945
|
+
const SANITIZE_NAMED_PROPS_PREFIX = "user-content-";
|
|
1946
|
+
let KEEP_CONTENT = true;
|
|
1947
|
+
let IN_PLACE = false;
|
|
1948
|
+
let IN_PLACE_VISITED = null;
|
|
1949
|
+
let USE_PROFILES = {};
|
|
1950
|
+
let FORBID_CONTENTS = null;
|
|
1951
|
+
const DEFAULT_FORBID_CONTENTS = addToSet({}, [
|
|
1952
|
+
"annotation-xml",
|
|
1953
|
+
"audio",
|
|
1954
|
+
"colgroup",
|
|
1955
|
+
"desc",
|
|
1956
|
+
"foreignobject",
|
|
1957
|
+
"head",
|
|
1958
|
+
"iframe",
|
|
1959
|
+
"math",
|
|
1960
|
+
"mi",
|
|
1961
|
+
"mn",
|
|
1962
|
+
"mo",
|
|
1963
|
+
"ms",
|
|
1964
|
+
"mtext",
|
|
1965
|
+
"noembed",
|
|
1966
|
+
"noframes",
|
|
1967
|
+
"noscript",
|
|
1968
|
+
"plaintext",
|
|
1969
|
+
"script",
|
|
1970
|
+
"selectedcontent",
|
|
1971
|
+
"style",
|
|
1972
|
+
"svg",
|
|
1973
|
+
"template",
|
|
1974
|
+
"thead",
|
|
1975
|
+
"title",
|
|
1976
|
+
"video",
|
|
1977
|
+
"xmp"
|
|
1978
|
+
]);
|
|
1979
|
+
let DATA_URI_TAGS = null;
|
|
1980
|
+
const DEFAULT_DATA_URI_TAGS = addToSet({}, [
|
|
1981
|
+
"audio",
|
|
1982
|
+
"video",
|
|
1983
|
+
"img",
|
|
1984
|
+
"source",
|
|
1985
|
+
"image",
|
|
1986
|
+
"track"
|
|
1987
|
+
]);
|
|
1988
|
+
let URI_SAFE_ATTRIBUTES = null;
|
|
1989
|
+
const DEFAULT_URI_SAFE_ATTRIBUTES = addToSet({}, [
|
|
1990
|
+
"alt",
|
|
1991
|
+
"class",
|
|
1992
|
+
"for",
|
|
1993
|
+
"id",
|
|
1994
|
+
"label",
|
|
1995
|
+
"name",
|
|
1996
|
+
"pattern",
|
|
1997
|
+
"placeholder",
|
|
1998
|
+
"role",
|
|
1999
|
+
"summary",
|
|
2000
|
+
"title",
|
|
2001
|
+
"value",
|
|
2002
|
+
"style",
|
|
2003
|
+
"xmlns"
|
|
2004
|
+
]);
|
|
2005
|
+
const MATHML_NAMESPACE = "http://www.w3.org/1998/Math/MathML";
|
|
2006
|
+
const SVG_NAMESPACE = "http://www.w3.org/2000/svg";
|
|
2007
|
+
const HTML_NAMESPACE = "http://www.w3.org/1999/xhtml";
|
|
2008
|
+
let NAMESPACE = HTML_NAMESPACE;
|
|
2009
|
+
let IS_EMPTY_INPUT = false;
|
|
2010
|
+
let ALLOWED_NAMESPACES = null;
|
|
2011
|
+
const DEFAULT_ALLOWED_NAMESPACES = addToSet({}, [
|
|
2012
|
+
MATHML_NAMESPACE,
|
|
2013
|
+
SVG_NAMESPACE,
|
|
2014
|
+
HTML_NAMESPACE
|
|
2015
|
+
], stringToString);
|
|
2016
|
+
const DEFAULT_MATHML_TEXT_INTEGRATION_POINTS = freeze([
|
|
2017
|
+
"mi",
|
|
2018
|
+
"mo",
|
|
2019
|
+
"mn",
|
|
2020
|
+
"ms",
|
|
2021
|
+
"mtext"
|
|
2022
|
+
]);
|
|
2023
|
+
let MATHML_TEXT_INTEGRATION_POINTS = addToSet({}, DEFAULT_MATHML_TEXT_INTEGRATION_POINTS);
|
|
2024
|
+
const DEFAULT_HTML_INTEGRATION_POINTS = freeze(["annotation-xml"]);
|
|
2025
|
+
let HTML_INTEGRATION_POINTS = addToSet({}, DEFAULT_HTML_INTEGRATION_POINTS);
|
|
2026
|
+
const COMMON_SVG_AND_HTML_ELEMENTS = addToSet({}, [
|
|
2027
|
+
"title",
|
|
2028
|
+
"style",
|
|
2029
|
+
"font",
|
|
2030
|
+
"a",
|
|
2031
|
+
"script"
|
|
2032
|
+
]);
|
|
2033
|
+
let PARSER_MEDIA_TYPE = null;
|
|
2034
|
+
const SUPPORTED_PARSER_MEDIA_TYPES = ["application/xhtml+xml", "text/html"];
|
|
2035
|
+
const DEFAULT_PARSER_MEDIA_TYPE = "text/html";
|
|
2036
|
+
let transformCaseFunc = null;
|
|
2037
|
+
let CONFIG = null;
|
|
2038
|
+
const formElement = document2.createElement("form");
|
|
2039
|
+
const isRegexOrFunction = function isRegexOrFunction2(testValue) {
|
|
2040
|
+
return testValue instanceof RegExp || testValue instanceof Function;
|
|
2041
|
+
};
|
|
2042
|
+
const _parseConfig = function _parseConfig2() {
|
|
2043
|
+
let cfg = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
2044
|
+
if (CONFIG && CONFIG === cfg) return;
|
|
2045
|
+
if (!cfg || typeof cfg !== "object") cfg = {};
|
|
2046
|
+
cfg = clone(cfg);
|
|
2047
|
+
PARSER_MEDIA_TYPE = SUPPORTED_PARSER_MEDIA_TYPES.indexOf(cfg.PARSER_MEDIA_TYPE) === -1 ? DEFAULT_PARSER_MEDIA_TYPE : cfg.PARSER_MEDIA_TYPE;
|
|
2048
|
+
transformCaseFunc = PARSER_MEDIA_TYPE === "application/xhtml+xml" ? stringToString : stringToLowerCase;
|
|
2049
|
+
ALLOWED_TAGS = _resolveSetOption(cfg, "ALLOWED_TAGS", DEFAULT_ALLOWED_TAGS, { transform: transformCaseFunc });
|
|
2050
|
+
ALLOWED_ATTR = _resolveSetOption(cfg, "ALLOWED_ATTR", DEFAULT_ALLOWED_ATTR, { transform: transformCaseFunc });
|
|
2051
|
+
ALLOWED_NAMESPACES = _resolveSetOption(cfg, "ALLOWED_NAMESPACES", DEFAULT_ALLOWED_NAMESPACES, { transform: stringToString });
|
|
2052
|
+
URI_SAFE_ATTRIBUTES = _resolveSetOption(cfg, "ADD_URI_SAFE_ATTR", DEFAULT_URI_SAFE_ATTRIBUTES, {
|
|
2053
|
+
transform: transformCaseFunc,
|
|
2054
|
+
base: DEFAULT_URI_SAFE_ATTRIBUTES
|
|
2055
|
+
});
|
|
2056
|
+
DATA_URI_TAGS = _resolveSetOption(cfg, "ADD_DATA_URI_TAGS", DEFAULT_DATA_URI_TAGS, {
|
|
2057
|
+
transform: transformCaseFunc,
|
|
2058
|
+
base: DEFAULT_DATA_URI_TAGS
|
|
2059
|
+
});
|
|
2060
|
+
FORBID_CONTENTS = _resolveSetOption(cfg, "FORBID_CONTENTS", DEFAULT_FORBID_CONTENTS, { transform: transformCaseFunc });
|
|
2061
|
+
FORBID_TAGS = _resolveSetOption(cfg, "FORBID_TAGS", clone({}), { transform: transformCaseFunc });
|
|
2062
|
+
FORBID_ATTR = _resolveSetOption(cfg, "FORBID_ATTR", clone({}), { transform: transformCaseFunc });
|
|
2063
|
+
USE_PROFILES = objectHasOwnProperty(cfg, "USE_PROFILES") ? cfg.USE_PROFILES && typeof cfg.USE_PROFILES === "object" ? clone(cfg.USE_PROFILES) : cfg.USE_PROFILES : false;
|
|
2064
|
+
ALLOW_ARIA_ATTR = cfg.ALLOW_ARIA_ATTR !== false;
|
|
2065
|
+
ALLOW_DATA_ATTR = cfg.ALLOW_DATA_ATTR !== false;
|
|
2066
|
+
ALLOW_UNKNOWN_PROTOCOLS = cfg.ALLOW_UNKNOWN_PROTOCOLS || false;
|
|
2067
|
+
ALLOW_SELF_CLOSE_IN_ATTR = cfg.ALLOW_SELF_CLOSE_IN_ATTR !== false;
|
|
2068
|
+
SAFE_FOR_TEMPLATES = cfg.SAFE_FOR_TEMPLATES || false;
|
|
2069
|
+
SAFE_FOR_XML = cfg.SAFE_FOR_XML !== false;
|
|
2070
|
+
WHOLE_DOCUMENT = cfg.WHOLE_DOCUMENT || false;
|
|
2071
|
+
RETURN_DOM = cfg.RETURN_DOM || false;
|
|
2072
|
+
RETURN_DOM_FRAGMENT = cfg.RETURN_DOM_FRAGMENT || false;
|
|
2073
|
+
RETURN_TRUSTED_TYPE = cfg.RETURN_TRUSTED_TYPE || false;
|
|
2074
|
+
FORCE_BODY = cfg.FORCE_BODY || false;
|
|
2075
|
+
SANITIZE_DOM = cfg.SANITIZE_DOM !== false;
|
|
2076
|
+
SANITIZE_NAMED_PROPS = cfg.SANITIZE_NAMED_PROPS || false;
|
|
2077
|
+
KEEP_CONTENT = cfg.KEEP_CONTENT !== false;
|
|
2078
|
+
IN_PLACE = cfg.IN_PLACE || false;
|
|
2079
|
+
IS_ALLOWED_URI$1 = isRegex(cfg.ALLOWED_URI_REGEXP) ? cfg.ALLOWED_URI_REGEXP : IS_ALLOWED_URI;
|
|
2080
|
+
NAMESPACE = typeof cfg.NAMESPACE === "string" ? cfg.NAMESPACE : HTML_NAMESPACE;
|
|
2081
|
+
MATHML_TEXT_INTEGRATION_POINTS = _resolveObjectOption(cfg, "MATHML_TEXT_INTEGRATION_POINTS", () => addToSet({}, DEFAULT_MATHML_TEXT_INTEGRATION_POINTS));
|
|
2082
|
+
HTML_INTEGRATION_POINTS = _resolveObjectOption(cfg, "HTML_INTEGRATION_POINTS", () => addToSet({}, DEFAULT_HTML_INTEGRATION_POINTS));
|
|
2083
|
+
const customElementHandling = _resolveObjectOption(cfg, "CUSTOM_ELEMENT_HANDLING", () => create(null));
|
|
2084
|
+
CUSTOM_ELEMENT_HANDLING = create(null);
|
|
2085
|
+
if (objectHasOwnProperty(customElementHandling, "tagNameCheck") && isRegexOrFunction(customElementHandling.tagNameCheck)) CUSTOM_ELEMENT_HANDLING.tagNameCheck = customElementHandling.tagNameCheck;
|
|
2086
|
+
if (objectHasOwnProperty(customElementHandling, "attributeNameCheck") && isRegexOrFunction(customElementHandling.attributeNameCheck)) CUSTOM_ELEMENT_HANDLING.attributeNameCheck = customElementHandling.attributeNameCheck;
|
|
2087
|
+
if (objectHasOwnProperty(customElementHandling, "allowCustomizedBuiltInElements") && typeof customElementHandling.allowCustomizedBuiltInElements === "boolean") CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements = customElementHandling.allowCustomizedBuiltInElements;
|
|
2088
|
+
seal(CUSTOM_ELEMENT_HANDLING);
|
|
2089
|
+
if (SAFE_FOR_TEMPLATES) ALLOW_DATA_ATTR = false;
|
|
2090
|
+
if (RETURN_DOM_FRAGMENT) RETURN_DOM = true;
|
|
2091
|
+
if (USE_PROFILES) {
|
|
2092
|
+
ALLOWED_TAGS = addToSet({}, text);
|
|
2093
|
+
ALLOWED_ATTR = create(null);
|
|
2094
|
+
if (USE_PROFILES.html === true) {
|
|
2095
|
+
addToSet(ALLOWED_TAGS, html$1);
|
|
2096
|
+
addToSet(ALLOWED_ATTR, html);
|
|
2097
|
+
}
|
|
2098
|
+
if (USE_PROFILES.svg === true) {
|
|
2099
|
+
addToSet(ALLOWED_TAGS, svg$1);
|
|
2100
|
+
addToSet(ALLOWED_ATTR, svg);
|
|
2101
|
+
addToSet(ALLOWED_ATTR, xml);
|
|
2102
|
+
}
|
|
2103
|
+
if (USE_PROFILES.svgFilters === true) {
|
|
2104
|
+
addToSet(ALLOWED_TAGS, svgFilters);
|
|
2105
|
+
addToSet(ALLOWED_ATTR, svg);
|
|
2106
|
+
addToSet(ALLOWED_ATTR, xml);
|
|
2107
|
+
}
|
|
2108
|
+
if (USE_PROFILES.mathMl === true) {
|
|
2109
|
+
addToSet(ALLOWED_TAGS, mathMl$1);
|
|
2110
|
+
addToSet(ALLOWED_ATTR, mathMl);
|
|
2111
|
+
addToSet(ALLOWED_ATTR, xml);
|
|
2112
|
+
}
|
|
2113
|
+
}
|
|
2114
|
+
EXTRA_ELEMENT_HANDLING.tagCheck = null;
|
|
2115
|
+
EXTRA_ELEMENT_HANDLING.attributeCheck = null;
|
|
2116
|
+
if (objectHasOwnProperty(cfg, "ADD_TAGS")) {
|
|
2117
|
+
if (typeof cfg.ADD_TAGS === "function") EXTRA_ELEMENT_HANDLING.tagCheck = cfg.ADD_TAGS;
|
|
2118
|
+
else if (arrayIsArray(cfg.ADD_TAGS)) {
|
|
2119
|
+
if (ALLOWED_TAGS === DEFAULT_ALLOWED_TAGS) ALLOWED_TAGS = clone(ALLOWED_TAGS);
|
|
2120
|
+
addToSet(ALLOWED_TAGS, cfg.ADD_TAGS, transformCaseFunc);
|
|
2121
|
+
}
|
|
2122
|
+
}
|
|
2123
|
+
if (objectHasOwnProperty(cfg, "ADD_ATTR")) {
|
|
2124
|
+
if (typeof cfg.ADD_ATTR === "function") EXTRA_ELEMENT_HANDLING.attributeCheck = cfg.ADD_ATTR;
|
|
2125
|
+
else if (arrayIsArray(cfg.ADD_ATTR)) {
|
|
2126
|
+
if (ALLOWED_ATTR === DEFAULT_ALLOWED_ATTR) ALLOWED_ATTR = clone(ALLOWED_ATTR);
|
|
2127
|
+
addToSet(ALLOWED_ATTR, cfg.ADD_ATTR, transformCaseFunc);
|
|
2128
|
+
}
|
|
2129
|
+
}
|
|
2130
|
+
if (objectHasOwnProperty(cfg, "ADD_FORBID_CONTENTS") && arrayIsArray(cfg.ADD_FORBID_CONTENTS)) {
|
|
2131
|
+
if (FORBID_CONTENTS === DEFAULT_FORBID_CONTENTS) FORBID_CONTENTS = clone(FORBID_CONTENTS);
|
|
2132
|
+
addToSet(FORBID_CONTENTS, cfg.ADD_FORBID_CONTENTS, transformCaseFunc);
|
|
2133
|
+
}
|
|
2134
|
+
if (KEEP_CONTENT) ALLOWED_TAGS["#text"] = true;
|
|
2135
|
+
if (WHOLE_DOCUMENT) addToSet(ALLOWED_TAGS, [
|
|
2136
|
+
"html",
|
|
2137
|
+
"head",
|
|
2138
|
+
"body"
|
|
2139
|
+
]);
|
|
2140
|
+
if (ALLOWED_TAGS.table) {
|
|
2141
|
+
addToSet(ALLOWED_TAGS, ["tbody"]);
|
|
2142
|
+
delete FORBID_TAGS.tbody;
|
|
2143
|
+
}
|
|
2144
|
+
if (cfg.TRUSTED_TYPES_POLICY) {
|
|
2145
|
+
if (typeof cfg.TRUSTED_TYPES_POLICY.createHTML !== "function") throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');
|
|
2146
|
+
if (typeof cfg.TRUSTED_TYPES_POLICY.createScriptURL !== "function") throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');
|
|
2147
|
+
const previousTrustedTypesPolicy = trustedTypesPolicy;
|
|
2148
|
+
trustedTypesPolicy = cfg.TRUSTED_TYPES_POLICY;
|
|
2149
|
+
try {
|
|
2150
|
+
emptyHTML = _createTrustedHTML("");
|
|
2151
|
+
} catch (error) {
|
|
2152
|
+
trustedTypesPolicy = previousTrustedTypesPolicy;
|
|
2153
|
+
throw error;
|
|
2154
|
+
}
|
|
2155
|
+
} else if (cfg.TRUSTED_TYPES_POLICY === null) {
|
|
2156
|
+
trustedTypesPolicy = void 0;
|
|
2157
|
+
emptyHTML = "";
|
|
2158
|
+
} else {
|
|
2159
|
+
if (trustedTypesPolicy === void 0) trustedTypesPolicy = _getDefaultTrustedTypesPolicy();
|
|
2160
|
+
if (trustedTypesPolicy && typeof emptyHTML === "string") emptyHTML = _createTrustedHTML("");
|
|
2161
|
+
}
|
|
2162
|
+
if (freeze) freeze(cfg);
|
|
2163
|
+
CONFIG = cfg;
|
|
2164
|
+
};
|
|
2165
|
+
const ALL_SVG_TAGS = addToSet({}, [
|
|
2166
|
+
...svg$1,
|
|
2167
|
+
...svgFilters,
|
|
2168
|
+
...svgDisallowed
|
|
2169
|
+
]);
|
|
2170
|
+
const ALL_MATHML_TAGS = addToSet({}, [...mathMl$1, ...mathMlDisallowed]);
|
|
2171
|
+
const _checkSvgNamespace = function _checkSvgNamespace2(tagName, parent, parentTagName) {
|
|
2172
|
+
if (parent.namespaceURI === HTML_NAMESPACE) return tagName === "svg";
|
|
2173
|
+
if (parent.namespaceURI === MATHML_NAMESPACE) return tagName === "svg" && (parentTagName === "annotation-xml" || MATHML_TEXT_INTEGRATION_POINTS[parentTagName]);
|
|
2174
|
+
return Boolean(ALL_SVG_TAGS[tagName]);
|
|
2175
|
+
};
|
|
2176
|
+
const _checkMathMlNamespace = function _checkMathMlNamespace2(tagName, parent, parentTagName) {
|
|
2177
|
+
if (parent.namespaceURI === HTML_NAMESPACE) return tagName === "math";
|
|
2178
|
+
if (parent.namespaceURI === SVG_NAMESPACE) return tagName === "math" && HTML_INTEGRATION_POINTS[parentTagName];
|
|
2179
|
+
return Boolean(ALL_MATHML_TAGS[tagName]);
|
|
2180
|
+
};
|
|
2181
|
+
const _checkHtmlNamespace = function _checkHtmlNamespace2(tagName, parent, parentTagName) {
|
|
2182
|
+
if (parent.namespaceURI === SVG_NAMESPACE && !HTML_INTEGRATION_POINTS[parentTagName]) return false;
|
|
2183
|
+
if (parent.namespaceURI === MATHML_NAMESPACE && !MATHML_TEXT_INTEGRATION_POINTS[parentTagName]) return false;
|
|
2184
|
+
return !ALL_MATHML_TAGS[tagName] && (COMMON_SVG_AND_HTML_ELEMENTS[tagName] || !ALL_SVG_TAGS[tagName]);
|
|
2185
|
+
};
|
|
2186
|
+
const _checkValidNamespace = function _checkValidNamespace2(element) {
|
|
2187
|
+
const elementNamespace = _readNamespaceURI(element);
|
|
2188
|
+
const tagName = stringToLowerCase(_readNodeName(element));
|
|
2189
|
+
const parentNode = getParentNode(element);
|
|
2190
|
+
let parent;
|
|
2191
|
+
let parentTagName;
|
|
2192
|
+
if (parentNode && _readNodeType(parentNode) === NODE_TYPE.element) {
|
|
2193
|
+
parent = { namespaceURI: _readNamespaceURI(parentNode) };
|
|
2194
|
+
parentTagName = stringToLowerCase(_readNodeName(parentNode));
|
|
2195
|
+
} else {
|
|
2196
|
+
parent = { namespaceURI: NAMESPACE };
|
|
2197
|
+
parentTagName = "template";
|
|
2198
|
+
}
|
|
2199
|
+
if (!ALLOWED_NAMESPACES[elementNamespace]) return false;
|
|
2200
|
+
if (elementNamespace === SVG_NAMESPACE) return _checkSvgNamespace(tagName, parent, parentTagName);
|
|
2201
|
+
if (elementNamespace === MATHML_NAMESPACE) return _checkMathMlNamespace(tagName, parent, parentTagName);
|
|
2202
|
+
if (elementNamespace === HTML_NAMESPACE) return _checkHtmlNamespace(tagName, parent, parentTagName);
|
|
2203
|
+
if (PARSER_MEDIA_TYPE === "application/xhtml+xml" && ALLOWED_NAMESPACES[elementNamespace]) return true;
|
|
2204
|
+
return false;
|
|
2205
|
+
};
|
|
2206
|
+
const _forceRemove = function _forceRemove2(node) {
|
|
2207
|
+
arrayPush(DOMPurify.removed, { element: node });
|
|
2208
|
+
try {
|
|
2209
|
+
getParentNode(node).removeChild(node);
|
|
2210
|
+
} catch (_2) {
|
|
2211
|
+
remove(node);
|
|
2212
|
+
if (!getParentNode(node)) throw typeErrorCreate("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place");
|
|
2213
|
+
}
|
|
2214
|
+
};
|
|
2215
|
+
const _stripAttributeNode = function _stripAttributeNode2(element, attribute, name) {
|
|
2216
|
+
try {
|
|
2217
|
+
removeAttributeNode(element, attribute);
|
|
2218
|
+
} catch (_2) {
|
|
2219
|
+
try {
|
|
2220
|
+
element.removeAttribute(name);
|
|
2221
|
+
} catch (_3) {
|
|
2222
|
+
}
|
|
2223
|
+
}
|
|
2224
|
+
};
|
|
2225
|
+
const _neutralizeRoot = function _neutralizeRoot2(root) {
|
|
2226
|
+
_neutralizeSubtree(root);
|
|
2227
|
+
const childNodes = getChildNodes(root);
|
|
2228
|
+
if (childNodes) arrayForEach(arraySlice(childNodes), (child) => {
|
|
2229
|
+
try {
|
|
2230
|
+
remove(child);
|
|
2231
|
+
} catch (_2) {
|
|
2232
|
+
}
|
|
2233
|
+
});
|
|
2234
|
+
const attributes = _readNodeType(root) === NODE_TYPE.element ? getAttributes(root) : null;
|
|
2235
|
+
if (attributes) for (let i = attributes.length - 1; i >= 0; --i) {
|
|
2236
|
+
const attribute = attributes[i];
|
|
2237
|
+
const name = attribute && attribute.name;
|
|
2238
|
+
if (typeof name === "string") _stripAttributeNode(root, attribute, name);
|
|
2239
|
+
}
|
|
2240
|
+
};
|
|
2241
|
+
const _removeAttribute = function _removeAttribute2(name, element, attr) {
|
|
2242
|
+
if (!attr) try {
|
|
2243
|
+
attr = element.getAttributeNode(name);
|
|
2244
|
+
} catch (_2) {
|
|
2245
|
+
attr = null;
|
|
2246
|
+
}
|
|
2247
|
+
arrayPush(DOMPurify.removed, {
|
|
2248
|
+
attribute: attr || null,
|
|
2249
|
+
from: element
|
|
2250
|
+
});
|
|
2251
|
+
try {
|
|
2252
|
+
if (attr) removeAttributeNode(element, attr);
|
|
2253
|
+
else element.removeAttribute(name);
|
|
2254
|
+
} catch (_2) {
|
|
2255
|
+
try {
|
|
2256
|
+
element.removeAttribute(name);
|
|
2257
|
+
} catch (_3) {
|
|
2258
|
+
}
|
|
2259
|
+
}
|
|
2260
|
+
if (name === "is") {
|
|
2261
|
+
if (RETURN_DOM || RETURN_DOM_FRAGMENT) try {
|
|
2262
|
+
_forceRemove(element);
|
|
2263
|
+
} catch (_2) {
|
|
2264
|
+
}
|
|
2265
|
+
else try {
|
|
2266
|
+
element.setAttribute(name, "");
|
|
2267
|
+
} catch (_2) {
|
|
2268
|
+
}
|
|
2269
|
+
}
|
|
2270
|
+
};
|
|
2271
|
+
const _stripDisallowedAttributes = function _stripDisallowedAttributes2(element) {
|
|
2272
|
+
const attributes = getAttributes(element);
|
|
2273
|
+
if (!attributes) return;
|
|
2274
|
+
for (let i = attributes.length - 1; i >= 0; --i) {
|
|
2275
|
+
const attribute = attributes[i];
|
|
2276
|
+
const name = attribute && attribute.name;
|
|
2277
|
+
if (typeof name !== "string" || ALLOWED_ATTR[transformCaseFunc(name)]) continue;
|
|
2278
|
+
_stripAttributeNode(element, attribute, name);
|
|
2279
|
+
}
|
|
2280
|
+
};
|
|
2281
|
+
const _walkTree = function _walkTree2(root, visit) {
|
|
2282
|
+
let intoShadow = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : false;
|
|
2283
|
+
const stack = [root];
|
|
2284
|
+
while (stack.length > 0) {
|
|
2285
|
+
const node = stack.pop();
|
|
2286
|
+
if (visit(node) === false) continue;
|
|
2287
|
+
if (intoShadow && _readNodeType(node) === NODE_TYPE.element) {
|
|
2288
|
+
const shadowRoot = getShadowRoot(node);
|
|
2289
|
+
if (_isDocumentFragment(shadowRoot)) stack.push(shadowRoot);
|
|
2290
|
+
}
|
|
2291
|
+
const childNodes = getChildNodes(node);
|
|
2292
|
+
if (childNodes) for (let i = childNodes.length - 1; i >= 0; --i) stack.push(childNodes[i]);
|
|
2293
|
+
}
|
|
2294
|
+
};
|
|
2295
|
+
const _neutralizeSubtree = function _neutralizeSubtree2(root) {
|
|
2296
|
+
_walkTree(root, (node) => {
|
|
2297
|
+
if (_readNodeType(node) === NODE_TYPE.element) _stripDisallowedAttributes(node);
|
|
2298
|
+
});
|
|
2299
|
+
};
|
|
2300
|
+
const _collectLiveNodes = function _collectLiveNodes2(root) {
|
|
2301
|
+
const nodes = [];
|
|
2302
|
+
_walkTree(root, (node) => {
|
|
2303
|
+
nodes.push(node);
|
|
2304
|
+
}, true);
|
|
2305
|
+
return nodes;
|
|
2306
|
+
};
|
|
2307
|
+
const _neutralizeEscapedElements = function _neutralizeEscapedElements2(root, before) {
|
|
2308
|
+
const reachable = setCreate();
|
|
2309
|
+
arrayForEach(_collectLiveNodes(root), (node) => {
|
|
2310
|
+
if (_readNodeType(node) === NODE_TYPE.element) setAdd(reachable, node);
|
|
2311
|
+
});
|
|
2312
|
+
arrayForEach(before, (node) => {
|
|
2313
|
+
if (_readNodeType(node) === NODE_TYPE.element && !setHas(reachable, node)) _stripDisallowedAttributes(node);
|
|
2314
|
+
});
|
|
2315
|
+
};
|
|
2316
|
+
const _neutralizeDiscarded = function _neutralizeDiscarded2(root, before) {
|
|
2317
|
+
let rootRemoved = false;
|
|
2318
|
+
arrayForEach(DOMPurify.removed, (entry) => {
|
|
2319
|
+
if (entry.element) {
|
|
2320
|
+
rootRemoved = rootRemoved || entry.element === root;
|
|
2321
|
+
_neutralizeSubtree(entry.element);
|
|
2322
|
+
}
|
|
2323
|
+
});
|
|
2324
|
+
_neutralizeEscapedElements(root, before);
|
|
2325
|
+
return rootRemoved;
|
|
2326
|
+
};
|
|
2327
|
+
const MAX_UNVISITED_ROUNDS = 8;
|
|
2328
|
+
const _sanitizeUnvisitedNodes = function _sanitizeUnvisitedNodes2(root, before) {
|
|
2329
|
+
const visited = IN_PLACE_VISITED;
|
|
2330
|
+
let original = null;
|
|
2331
|
+
const getOriginal = () => {
|
|
2332
|
+
if (!original) {
|
|
2333
|
+
original = setCreate();
|
|
2334
|
+
arrayForEach(before, (beforeNode) => {
|
|
2335
|
+
setAdd(original, beforeNode);
|
|
2336
|
+
});
|
|
2337
|
+
}
|
|
2338
|
+
return original;
|
|
2339
|
+
};
|
|
2340
|
+
for (let round = 0; ; round++) {
|
|
2341
|
+
const live = _collectLiveNodes(root);
|
|
2342
|
+
const containers = [root];
|
|
2343
|
+
let pending = false;
|
|
2344
|
+
arrayForEach(live, (node) => {
|
|
2345
|
+
if (_readNodeType(node) === NODE_TYPE.documentFragment) arrayPush(containers, node);
|
|
2346
|
+
else if (!pending && !setHas(visited, node)) pending = setHas(getOriginal(), node);
|
|
2347
|
+
});
|
|
2348
|
+
if (!pending) return;
|
|
2349
|
+
if (round >= MAX_UNVISITED_ROUNDS) throw typeErrorCreate("the tree kept changing during in-place sanitization; refusing to return it");
|
|
2350
|
+
arrayForEach(containers, (container, index) => {
|
|
2351
|
+
_sanitizeUnvisitedIn(container, index > 0, root, getOriginal());
|
|
2352
|
+
});
|
|
2353
|
+
}
|
|
2354
|
+
};
|
|
2355
|
+
const _sanitizeUnvisitedIn = function _sanitizeUnvisitedIn2(container, inShadow, root, original) {
|
|
2356
|
+
const iterator = _createNodeIterator(container);
|
|
2357
|
+
let node;
|
|
2358
|
+
while (node = iterator.nextNode()) {
|
|
2359
|
+
if (!setHas(original, node) || setHas(IN_PLACE_VISITED, node)) continue;
|
|
2360
|
+
if (inShadow) _executeHooks(hooks.uponSanitizeShadowNode, node, null);
|
|
2361
|
+
_sanitizeElements(node, root);
|
|
2362
|
+
_sanitizeAttributes(node, root);
|
|
2363
|
+
if (_isDocumentFragment(node.content)) _sanitizeShadowDOM2(node.content);
|
|
2364
|
+
}
|
|
2365
|
+
};
|
|
2366
|
+
const _markVisited = function _markVisited2(node) {
|
|
2367
|
+
if (IN_PLACE_VISITED) setAdd(IN_PLACE_VISITED, node);
|
|
2368
|
+
};
|
|
2369
|
+
const _isPatchLinkageAttribute = function _isPatchLinkageAttribute2(lcName, lcTag) {
|
|
2370
|
+
if (!SAFE_FOR_XML) return false;
|
|
2371
|
+
if (lcName === "patchsrc") return true;
|
|
2372
|
+
return lcName === "for" && lcTag !== "label" && lcTag !== "output";
|
|
2373
|
+
};
|
|
2374
|
+
const _neutralizePatchLinkage = function _neutralizePatchLinkage2(root) {
|
|
2375
|
+
if (!SAFE_FOR_XML) return;
|
|
2376
|
+
_walkTree(root, (node) => {
|
|
2377
|
+
const nodeType = _readNodeType(node);
|
|
2378
|
+
if (nodeType === NODE_TYPE.processingInstruction || nodeType === NODE_TYPE.comment && regExpTest(COMMENT_MARKUP_PROBE, node.data)) {
|
|
2379
|
+
try {
|
|
2380
|
+
remove(node);
|
|
2381
|
+
} catch (_2) {
|
|
2382
|
+
}
|
|
2383
|
+
return false;
|
|
2384
|
+
}
|
|
2385
|
+
if (nodeType === NODE_TYPE.element) {
|
|
2386
|
+
const element = node;
|
|
2387
|
+
const lcTag = transformCaseFunc(_readNodeName(node));
|
|
2388
|
+
try {
|
|
2389
|
+
if (element.hasAttribute && element.hasAttribute("patchsrc")) element.removeAttribute("patchsrc");
|
|
2390
|
+
if (element.hasAttribute && element.hasAttribute("for") && _isPatchLinkageAttribute("for", lcTag)) element.removeAttribute("for");
|
|
2391
|
+
} catch (_2) {
|
|
2392
|
+
}
|
|
2393
|
+
}
|
|
2394
|
+
return true;
|
|
2395
|
+
});
|
|
2396
|
+
};
|
|
2397
|
+
const _initDocument = function _initDocument2(dirty) {
|
|
2398
|
+
let doc = null;
|
|
2399
|
+
let leadingWhitespace = null;
|
|
2400
|
+
if (FORCE_BODY) dirty = "<remove></remove>" + dirty;
|
|
2401
|
+
else {
|
|
2402
|
+
const matches = stringMatch(dirty, /^[\r\n\t ]+/);
|
|
2403
|
+
leadingWhitespace = matches && matches[0];
|
|
2404
|
+
}
|
|
2405
|
+
if (PARSER_MEDIA_TYPE === "application/xhtml+xml" && NAMESPACE === HTML_NAMESPACE) dirty = '<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>' + dirty + "</body></html>";
|
|
2406
|
+
const dirtyPayload = trustedTypesPolicy ? _createTrustedHTML(dirty) : dirty;
|
|
2407
|
+
if (NAMESPACE === HTML_NAMESPACE) try {
|
|
2408
|
+
doc = new DOMParser().parseFromString(dirtyPayload, PARSER_MEDIA_TYPE);
|
|
2409
|
+
} catch (_2) {
|
|
2410
|
+
}
|
|
2411
|
+
if (!doc || !doc.documentElement) {
|
|
2412
|
+
doc = implementation.createDocument(NAMESPACE, "template", null);
|
|
2413
|
+
try {
|
|
2414
|
+
doc.documentElement.innerHTML = IS_EMPTY_INPUT ? emptyHTML : dirtyPayload;
|
|
2415
|
+
} catch (_2) {
|
|
2416
|
+
}
|
|
2417
|
+
}
|
|
2418
|
+
const body = doc.body || doc.documentElement;
|
|
2419
|
+
if (dirty && leadingWhitespace) body.insertBefore(document2.createTextNode(leadingWhitespace), body.childNodes[0] || null);
|
|
2420
|
+
if (NAMESPACE === HTML_NAMESPACE) return getElementsByTagName.call(doc, WHOLE_DOCUMENT ? "html" : "body")[0];
|
|
2421
|
+
return WHOLE_DOCUMENT ? doc.documentElement : body;
|
|
2422
|
+
};
|
|
2423
|
+
const _createNodeIterator = function _createNodeIterator2(root) {
|
|
2424
|
+
const doc = getOwnerDocument ? getOwnerDocument(root) : root.ownerDocument;
|
|
2425
|
+
return createNodeIterator.call(doc || root, root, NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_TEXT | NodeFilter.SHOW_PROCESSING_INSTRUCTION | NodeFilter.SHOW_CDATA_SECTION, null);
|
|
2426
|
+
};
|
|
2427
|
+
const _stripTemplateExpressions = function _stripTemplateExpressions2(value) {
|
|
2428
|
+
value = stringReplace(value, MUSTACHE_EXPR$1, " ");
|
|
2429
|
+
value = stringReplace(value, ERB_EXPR$1, " ");
|
|
2430
|
+
value = stringReplace(value, TMPLIT_EXPR$1, " ");
|
|
2431
|
+
return value;
|
|
2432
|
+
};
|
|
2433
|
+
const _scrubTemplateExpressions2 = function _scrubTemplateExpressions(node) {
|
|
2434
|
+
var _node$querySelectorAl;
|
|
2435
|
+
_scrubOwnCharacterData(node);
|
|
2436
|
+
const templates = (_node$querySelectorAl = node.querySelectorAll) === null || _node$querySelectorAl === void 0 ? void 0 : _node$querySelectorAl.call(node, "template");
|
|
2437
|
+
if (templates) arrayForEach(templates, (tmpl) => {
|
|
2438
|
+
if (_isDocumentFragment(tmpl.content)) _scrubTemplateExpressions2(tmpl.content);
|
|
2439
|
+
});
|
|
2440
|
+
};
|
|
2441
|
+
const _scrubOwnCharacterData = function _scrubOwnCharacterData2(node) {
|
|
2442
|
+
node.normalize();
|
|
2443
|
+
const doc = getOwnerDocument ? getOwnerDocument(node) : node.ownerDocument;
|
|
2444
|
+
const walker = createNodeIterator.call(doc || node, node, NodeFilter.SHOW_TEXT | NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_CDATA_SECTION | NodeFilter.SHOW_PROCESSING_INSTRUCTION, null);
|
|
2445
|
+
let currentNode = walker.nextNode();
|
|
2446
|
+
while (currentNode) {
|
|
2447
|
+
currentNode.data = _stripTemplateExpressions(currentNode.data);
|
|
2448
|
+
currentNode = walker.nextNode();
|
|
2449
|
+
}
|
|
2450
|
+
};
|
|
2451
|
+
const _isClobbered = function _isClobbered2(element) {
|
|
2452
|
+
const realTagName = getNodeName ? getNodeName(element) : null;
|
|
2453
|
+
if (typeof realTagName !== "string") return false;
|
|
2454
|
+
if (transformCaseFunc(realTagName) !== "form") return false;
|
|
2455
|
+
return typeof element.nodeName !== "string" || typeof element.textContent !== "string" || typeof element.removeChild !== "function" || element.attributes !== getAttributes(element) || typeof element.removeAttribute !== "function" || typeof element.removeAttributeNode !== "function" || typeof element.getAttributeNode !== "function" || typeof element.setAttribute !== "function" || typeof element.namespaceURI !== "string" || typeof element.insertBefore !== "function" || typeof element.hasChildNodes !== "function" || element.nodeType !== getNodeType(element) || element.childNodes !== getChildNodes(element);
|
|
2456
|
+
};
|
|
2457
|
+
const _isDocumentFragment = function _isDocumentFragment2(value) {
|
|
2458
|
+
if (!getNodeType || typeof value !== "object" || value === null) return false;
|
|
2459
|
+
try {
|
|
2460
|
+
return getNodeType(value) === NODE_TYPE.documentFragment;
|
|
2461
|
+
} catch (_2) {
|
|
2462
|
+
return false;
|
|
2463
|
+
}
|
|
2464
|
+
};
|
|
2465
|
+
const _isNode = function _isNode2(value) {
|
|
2466
|
+
if (!getNodeType || typeof value !== "object" || value === null) return false;
|
|
2467
|
+
try {
|
|
2468
|
+
return typeof getNodeType(value) === "number";
|
|
2469
|
+
} catch (_2) {
|
|
2470
|
+
return false;
|
|
2471
|
+
}
|
|
2472
|
+
};
|
|
2473
|
+
function _executeHooks(hooks2, currentNode, data) {
|
|
2474
|
+
if (hooks2.length === 0) return;
|
|
2475
|
+
arrayForEach(hooks2, (hook) => {
|
|
2476
|
+
hook.call(DOMPurify, currentNode, data, CONFIG);
|
|
2477
|
+
});
|
|
2478
|
+
}
|
|
2479
|
+
const _isUnsafeNode = function _isUnsafeNode2(currentNode, tagName) {
|
|
2480
|
+
if (SAFE_FOR_XML && currentNode.hasChildNodes() && !_isNode(currentNode.firstElementChild) && regExpTest(ELEMENT_MARKUP_PROBE, currentNode.textContent) && regExpTest(ELEMENT_MARKUP_PROBE, currentNode.innerHTML)) return true;
|
|
2481
|
+
if (SAFE_FOR_XML && LITERAL_TEXT_ELEMENTS[tagName] && _readNodeType(currentNode) === NODE_TYPE.element && _readNamespaceURI(currentNode) === HTML_NAMESPACE && (_isNode(currentNode.firstElementChild) || typeof currentNode.textContent === "string" && regExpTest(ELEMENT_MARKUP_PROBE, currentNode.textContent))) return true;
|
|
2482
|
+
if (currentNode.nodeType === NODE_TYPE.processingInstruction) return true;
|
|
2483
|
+
if (SAFE_FOR_XML && currentNode.nodeType === NODE_TYPE.comment && regExpTest(COMMENT_MARKUP_PROBE, currentNode.data)) return true;
|
|
2484
|
+
return false;
|
|
2485
|
+
};
|
|
2486
|
+
const _matchesNameCheck = function _matchesNameCheck2(check, name) {
|
|
2487
|
+
if (check instanceof RegExp) return regExpTest(check, name);
|
|
2488
|
+
if (check instanceof Function) {
|
|
2489
|
+
for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) args[_key - 2] = arguments[_key];
|
|
2490
|
+
return Boolean(check(name, ...args));
|
|
2491
|
+
}
|
|
2492
|
+
return false;
|
|
2493
|
+
};
|
|
2494
|
+
const _sanitizeDisallowedNode = function _sanitizeDisallowedNode2(currentNode, tagName, root) {
|
|
2495
|
+
if (!FORBID_TAGS[tagName] && _isBasicCustomElement(tagName) && _matchesNameCheck(CUSTOM_ELEMENT_HANDLING.tagNameCheck, tagName)) return false;
|
|
2496
|
+
if (KEEP_CONTENT && !FORBID_CONTENTS[tagName] && !FORBID_CONTENTS[stringToLowerCase(tagName)]) {
|
|
2497
|
+
const parentNode = getParentNode(currentNode);
|
|
2498
|
+
const childNodes = getChildNodes(currentNode);
|
|
2499
|
+
if (childNodes && parentNode) {
|
|
2500
|
+
const childCount = childNodes.length;
|
|
2501
|
+
for (let i = childCount - 1; i >= 0; --i) {
|
|
2502
|
+
const hoisted = currentNode === root ? cloneNode(childNodes[i], true) : childNodes[i];
|
|
2503
|
+
parentNode.insertBefore(hoisted, getNextSibling(currentNode));
|
|
2504
|
+
}
|
|
2505
|
+
}
|
|
2506
|
+
}
|
|
2507
|
+
_forceRemove(currentNode);
|
|
2508
|
+
return true;
|
|
2509
|
+
};
|
|
2510
|
+
const _forkSharedAllowlist = function _forkSharedAllowlist2(hookList, set, defaultSet, setConfigSet) {
|
|
2511
|
+
if (hookList.length === 0) return set;
|
|
2512
|
+
return set === defaultSet || set === setConfigSet ? clone(set) : set;
|
|
2513
|
+
};
|
|
2514
|
+
const _handleHookDetachedNode = function _handleHookDetachedNode2(currentNode, root) {
|
|
2515
|
+
if (currentNode === root || getParentNode(currentNode) !== null) return false;
|
|
2516
|
+
if (IN_PLACE) _neutralizeSubtree(currentNode);
|
|
2517
|
+
return true;
|
|
2518
|
+
};
|
|
2519
|
+
const _sanitizeElements = function _sanitizeElements2(currentNode, root) {
|
|
2520
|
+
_markVisited(currentNode);
|
|
2521
|
+
_executeHooks(hooks.beforeSanitizeElements, currentNode, null);
|
|
2522
|
+
if (_handleHookDetachedNode(currentNode, root)) return true;
|
|
2523
|
+
if (_isClobbered(currentNode)) {
|
|
2524
|
+
_forceRemove(currentNode);
|
|
2525
|
+
return true;
|
|
2526
|
+
}
|
|
2527
|
+
const tagName = transformCaseFunc(_readNodeName(currentNode));
|
|
2528
|
+
ALLOWED_TAGS = _forkSharedAllowlist(hooks.uponSanitizeElement, ALLOWED_TAGS, DEFAULT_ALLOWED_TAGS, SET_CONFIG_ALLOWED_TAGS);
|
|
2529
|
+
_executeHooks(hooks.uponSanitizeElement, currentNode, {
|
|
2530
|
+
tagName,
|
|
2531
|
+
allowedTags: ALLOWED_TAGS
|
|
2532
|
+
});
|
|
2533
|
+
if (_handleHookDetachedNode(currentNode, root)) return true;
|
|
2534
|
+
if (_isUnsafeNode(currentNode, tagName)) {
|
|
2535
|
+
_forceRemove(currentNode);
|
|
2536
|
+
return true;
|
|
2537
|
+
}
|
|
2538
|
+
if (FORBID_TAGS[tagName] || !(EXTRA_ELEMENT_HANDLING.tagCheck instanceof Function && EXTRA_ELEMENT_HANDLING.tagCheck(tagName)) && !ALLOWED_TAGS[tagName]) {
|
|
2539
|
+
const removed = _sanitizeDisallowedNode(currentNode, tagName, root);
|
|
2540
|
+
if (removed === false) {
|
|
2541
|
+
_executeHooks(hooks.afterSanitizeElements, currentNode, null);
|
|
2542
|
+
if (_handleHookDetachedNode(currentNode, root)) return true;
|
|
2543
|
+
}
|
|
2544
|
+
return removed;
|
|
2545
|
+
}
|
|
2546
|
+
if (_readNodeType(currentNode) === NODE_TYPE.element && !_checkValidNamespace(currentNode)) {
|
|
2547
|
+
_forceRemove(currentNode);
|
|
2548
|
+
return true;
|
|
2549
|
+
}
|
|
2550
|
+
if ((tagName === "noscript" || tagName === "noembed" || tagName === "noframes") && regExpTest(FALLBACK_TAG_CLOSE, currentNode.innerHTML)) {
|
|
2551
|
+
_forceRemove(currentNode);
|
|
2552
|
+
return true;
|
|
2553
|
+
}
|
|
2554
|
+
if (SAFE_FOR_TEMPLATES && currentNode.nodeType === NODE_TYPE.text) {
|
|
2555
|
+
const content = _stripTemplateExpressions(currentNode.textContent);
|
|
2556
|
+
if (currentNode.textContent !== content) {
|
|
2557
|
+
arrayPush(DOMPurify.removed, { element: currentNode.cloneNode() });
|
|
2558
|
+
currentNode.textContent = content;
|
|
2559
|
+
}
|
|
2560
|
+
}
|
|
2561
|
+
_executeHooks(hooks.afterSanitizeElements, currentNode, null);
|
|
2562
|
+
return _handleHookDetachedNode(currentNode, root);
|
|
2563
|
+
};
|
|
2564
|
+
const _isValidAttribute = function _isValidAttribute2(lcTag, lcName, value) {
|
|
2565
|
+
if (FORBID_ATTR[lcName]) return false;
|
|
2566
|
+
if (_isPatchLinkageAttribute(lcName, lcTag)) return false;
|
|
2567
|
+
if (SANITIZE_DOM && (lcName === "id" || lcName === "name") && (value in document2 || value in formElement)) return false;
|
|
2568
|
+
const nameIsPermitted = ALLOWED_ATTR[lcName] || EXTRA_ELEMENT_HANDLING.attributeCheck instanceof Function && EXTRA_ELEMENT_HANDLING.attributeCheck(lcName, lcTag);
|
|
2569
|
+
if (ALLOW_DATA_ATTR && regExpTest(DATA_ATTR$1, lcName)) return true;
|
|
2570
|
+
if (ALLOW_ARIA_ATTR && regExpTest(ARIA_ATTR$1, lcName)) return true;
|
|
2571
|
+
if (!nameIsPermitted) return _isBasicCustomElement(lcTag) && _matchesNameCheck(CUSTOM_ELEMENT_HANDLING.tagNameCheck, lcTag) && _matchesNameCheck(CUSTOM_ELEMENT_HANDLING.attributeNameCheck, lcName, lcTag) || lcName === "is" && CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements && _matchesNameCheck(CUSTOM_ELEMENT_HANDLING.tagNameCheck, value);
|
|
2572
|
+
if (URI_SAFE_ATTRIBUTES[lcName]) return true;
|
|
2573
|
+
if (regExpTest(IS_ALLOWED_URI$1, stringReplace(value, ATTR_WHITESPACE$1, ""))) return true;
|
|
2574
|
+
if ((lcName === "src" || lcName === "xlink:href" || lcName === "href") && lcTag !== "script" && stringIndexOf(value, "data:") === 0 && DATA_URI_TAGS[lcTag]) return true;
|
|
2575
|
+
if (ALLOW_UNKNOWN_PROTOCOLS && !regExpTest(IS_SCRIPT_OR_DATA$1, stringReplace(value, ATTR_WHITESPACE$1, ""))) return true;
|
|
2576
|
+
return !value;
|
|
2577
|
+
};
|
|
2578
|
+
const RESERVED_CUSTOM_ELEMENT_NAMES = addToSet({}, [
|
|
2579
|
+
"annotation-xml",
|
|
2580
|
+
"color-profile",
|
|
2581
|
+
"font-face",
|
|
2582
|
+
"font-face-format",
|
|
2583
|
+
"font-face-name",
|
|
2584
|
+
"font-face-src",
|
|
2585
|
+
"font-face-uri",
|
|
2586
|
+
"missing-glyph"
|
|
2587
|
+
]);
|
|
2588
|
+
const _isBasicCustomElement = function _isBasicCustomElement2(tagName) {
|
|
2589
|
+
return !RESERVED_CUSTOM_ELEMENT_NAMES[stringToLowerCase(tagName)] && regExpTest(CUSTOM_ELEMENT$1, tagName);
|
|
2590
|
+
};
|
|
2591
|
+
const _applyTrustedTypesToAttribute = function _applyTrustedTypesToAttribute2(lcTag, lcName, namespaceURI, value) {
|
|
2592
|
+
if (trustedTypesPolicy && typeof trustedTypes === "object" && typeof trustedTypes.getAttributeType === "function" && !namespaceURI) switch (trustedTypes.getAttributeType(lcTag, lcName)) {
|
|
2593
|
+
case "TrustedHTML":
|
|
2594
|
+
return _createTrustedHTML(value);
|
|
2595
|
+
case "TrustedScriptURL":
|
|
2596
|
+
return _createTrustedScriptURL(value);
|
|
2597
|
+
}
|
|
2598
|
+
return value;
|
|
2599
|
+
};
|
|
2600
|
+
const _setAttributeValue = function _setAttributeValue2(currentNode, name, namespaceURI, value) {
|
|
2601
|
+
try {
|
|
2602
|
+
if (namespaceURI) currentNode.setAttributeNS(namespaceURI, name, value);
|
|
2603
|
+
else currentNode.setAttribute(name, value);
|
|
2604
|
+
if (_isClobbered(currentNode)) {
|
|
2605
|
+
_forceRemove(currentNode);
|
|
2606
|
+
return false;
|
|
2607
|
+
}
|
|
2608
|
+
return true;
|
|
2609
|
+
} catch (_2) {
|
|
2610
|
+
_removeAttribute(name, currentNode);
|
|
2611
|
+
return false;
|
|
2612
|
+
}
|
|
2613
|
+
};
|
|
2614
|
+
const _isUnsafeAttributeValue = function _isUnsafeAttributeValue2(name, value) {
|
|
2615
|
+
if (SAFE_FOR_XML && regExpTest(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i, value)) return true;
|
|
2616
|
+
return stringToLowerCase(name) === "attributename" && stringMatch(value, "href") !== null;
|
|
2617
|
+
};
|
|
2618
|
+
const _sanitizeAttributes = function _sanitizeAttributes2(currentNode, root) {
|
|
2619
|
+
_executeHooks(hooks.beforeSanitizeAttributes, currentNode, null);
|
|
2620
|
+
if (_handleHookDetachedNode(currentNode, root)) return;
|
|
2621
|
+
const attributes = currentNode.attributes;
|
|
2622
|
+
if (!attributes || _isClobbered(currentNode)) return;
|
|
2623
|
+
ALLOWED_ATTR = _forkSharedAllowlist(hooks.uponSanitizeAttribute, ALLOWED_ATTR, DEFAULT_ALLOWED_ATTR, SET_CONFIG_ALLOWED_ATTR);
|
|
2624
|
+
const hookEvent = {
|
|
2625
|
+
attrName: "",
|
|
2626
|
+
attrValue: "",
|
|
2627
|
+
keepAttr: true,
|
|
2628
|
+
allowedAttributes: ALLOWED_ATTR,
|
|
2629
|
+
forceKeepAttr: void 0
|
|
2630
|
+
};
|
|
2631
|
+
let l = attributes.length;
|
|
2632
|
+
const lcTag = transformCaseFunc(currentNode.nodeName);
|
|
2633
|
+
while (l--) {
|
|
2634
|
+
const attr = attributes[l];
|
|
2635
|
+
const name = attr.name, namespaceURI = attr.namespaceURI, attrValue = attr.value;
|
|
2636
|
+
const lcName = transformCaseFunc(name);
|
|
2637
|
+
const initValue = attrValue;
|
|
2638
|
+
let value = name === "value" ? initValue : stringTrim(initValue);
|
|
2639
|
+
let recreatedNamedProp = false;
|
|
2640
|
+
hookEvent.attrName = lcName;
|
|
2641
|
+
hookEvent.attrValue = value;
|
|
2642
|
+
hookEvent.keepAttr = true;
|
|
2643
|
+
hookEvent.forceKeepAttr = void 0;
|
|
2644
|
+
_executeHooks(hooks.uponSanitizeAttribute, currentNode, hookEvent);
|
|
2645
|
+
value = hookEvent.attrValue;
|
|
2646
|
+
if (SANITIZE_NAMED_PROPS && (lcName === "id" || lcName === "name") && stringIndexOf(value, SANITIZE_NAMED_PROPS_PREFIX) !== 0) {
|
|
2647
|
+
_removeAttribute(name, currentNode, attr);
|
|
2648
|
+
value = SANITIZE_NAMED_PROPS_PREFIX + value;
|
|
2649
|
+
recreatedNamedProp = true;
|
|
2650
|
+
}
|
|
2651
|
+
if (_isUnsafeAttributeValue(name, value)) {
|
|
2652
|
+
_removeAttribute(name, currentNode, attr);
|
|
2653
|
+
continue;
|
|
2654
|
+
}
|
|
2655
|
+
if (hookEvent.forceKeepAttr) continue;
|
|
2656
|
+
if (!hookEvent.keepAttr) {
|
|
2657
|
+
_removeAttribute(name, currentNode, attr);
|
|
2658
|
+
continue;
|
|
2659
|
+
}
|
|
2660
|
+
if (!ALLOW_SELF_CLOSE_IN_ATTR && regExpTest(SELF_CLOSING_TAG, value)) {
|
|
2661
|
+
_removeAttribute(name, currentNode, attr);
|
|
2662
|
+
continue;
|
|
2663
|
+
}
|
|
2664
|
+
if (SAFE_FOR_TEMPLATES) value = _stripTemplateExpressions(value);
|
|
2665
|
+
if (!_isValidAttribute(lcTag, lcName, value)) {
|
|
2666
|
+
_removeAttribute(name, currentNode, attr);
|
|
2667
|
+
continue;
|
|
2668
|
+
}
|
|
2669
|
+
value = _applyTrustedTypesToAttribute(lcTag, lcName, namespaceURI, value);
|
|
2670
|
+
if (value !== initValue) {
|
|
2671
|
+
if (_setAttributeValue(currentNode, name, namespaceURI, value) && recreatedNamedProp) arrayPop(DOMPurify.removed);
|
|
2672
|
+
}
|
|
2673
|
+
}
|
|
2674
|
+
_executeHooks(hooks.afterSanitizeAttributes, currentNode, null);
|
|
2675
|
+
_handleHookDetachedNode(currentNode, root);
|
|
2676
|
+
};
|
|
2677
|
+
const _sanitizeShadowDOM2 = function _sanitizeShadowDOM(fragment) {
|
|
2678
|
+
let shadowNode = null;
|
|
2679
|
+
const shadowIterator = _createNodeIterator(fragment);
|
|
2680
|
+
_executeHooks(hooks.beforeSanitizeShadowDOM, fragment, null);
|
|
2681
|
+
while (shadowNode = shadowIterator.nextNode()) {
|
|
2682
|
+
_executeHooks(hooks.uponSanitizeShadowNode, shadowNode, null);
|
|
2683
|
+
_sanitizeElements(shadowNode, fragment);
|
|
2684
|
+
_sanitizeAttributes(shadowNode, fragment);
|
|
2685
|
+
if (_isDocumentFragment(shadowNode.content)) _sanitizeShadowDOM2(shadowNode.content);
|
|
2686
|
+
if (_readNodeType(shadowNode) === NODE_TYPE.element) {
|
|
2687
|
+
const innerSr = getShadowRoot(shadowNode);
|
|
2688
|
+
if (_isDocumentFragment(innerSr)) {
|
|
2689
|
+
_sanitizeAttachedShadowRoots(innerSr);
|
|
2690
|
+
_sanitizeShadowDOM2(innerSr);
|
|
2691
|
+
}
|
|
2692
|
+
}
|
|
2693
|
+
}
|
|
2694
|
+
if (SAFE_FOR_TEMPLATES) _scrubOwnCharacterData(fragment);
|
|
2695
|
+
_executeHooks(hooks.afterSanitizeShadowDOM, fragment, null);
|
|
2696
|
+
};
|
|
2697
|
+
const _sanitizeAttachedShadowRoots = function _sanitizeAttachedShadowRoots2(root) {
|
|
2698
|
+
const stack = [{
|
|
2699
|
+
node: root,
|
|
2700
|
+
shadow: null
|
|
2701
|
+
}];
|
|
2702
|
+
while (stack.length > 0) {
|
|
2703
|
+
const item = stack.pop();
|
|
2704
|
+
if (item.shadow) {
|
|
2705
|
+
_sanitizeShadowDOM2(item.shadow);
|
|
2706
|
+
continue;
|
|
2707
|
+
}
|
|
2708
|
+
const node = item.node;
|
|
2709
|
+
const isElement = _readNodeType(node) === NODE_TYPE.element;
|
|
2710
|
+
const childNodes = getChildNodes(node);
|
|
2711
|
+
if (childNodes) for (let i = childNodes.length - 1; i >= 0; --i) stack.push({
|
|
2712
|
+
node: childNodes[i],
|
|
2713
|
+
shadow: null
|
|
2714
|
+
});
|
|
2715
|
+
if (isElement) {
|
|
2716
|
+
const rootName = getNodeName ? getNodeName(node) : null;
|
|
2717
|
+
if (typeof rootName === "string" && transformCaseFunc(rootName) === "template") {
|
|
2718
|
+
const content = node.content;
|
|
2719
|
+
if (_isDocumentFragment(content)) stack.push({
|
|
2720
|
+
node: content,
|
|
2721
|
+
shadow: null
|
|
2722
|
+
});
|
|
2723
|
+
}
|
|
2724
|
+
}
|
|
2725
|
+
if (isElement) {
|
|
2726
|
+
const sr = getShadowRoot(node);
|
|
2727
|
+
if (_isDocumentFragment(sr)) stack.push({
|
|
2728
|
+
node: null,
|
|
2729
|
+
shadow: sr
|
|
2730
|
+
}, {
|
|
2731
|
+
node: sr,
|
|
2732
|
+
shadow: null
|
|
2733
|
+
});
|
|
2734
|
+
}
|
|
2735
|
+
}
|
|
2736
|
+
};
|
|
2737
|
+
DOMPurify.sanitize = function(dirty) {
|
|
2738
|
+
let cfg = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
2739
|
+
let body = null;
|
|
2740
|
+
let importedNode = null;
|
|
2741
|
+
let currentNode = null;
|
|
2742
|
+
let returnNode = null;
|
|
2743
|
+
IS_EMPTY_INPUT = !dirty;
|
|
2744
|
+
if (IS_EMPTY_INPUT) dirty = "<!-->";
|
|
2745
|
+
if (typeof dirty !== "string" && !_isNode(dirty)) {
|
|
2746
|
+
dirty = stringifyValue(dirty);
|
|
2747
|
+
if (typeof dirty !== "string") throw typeErrorCreate("dirty is not a string, aborting");
|
|
2748
|
+
}
|
|
2749
|
+
if (!DOMPurify.isSupported) return dirty;
|
|
2750
|
+
if (SET_CONFIG) {
|
|
2751
|
+
ALLOWED_TAGS = SET_CONFIG_ALLOWED_TAGS;
|
|
2752
|
+
ALLOWED_ATTR = SET_CONFIG_ALLOWED_ATTR;
|
|
2753
|
+
} else _parseConfig(cfg);
|
|
2754
|
+
if (hooks.uponSanitizeElement.length > 0 || hooks.uponSanitizeAttribute.length > 0) ALLOWED_TAGS = clone(ALLOWED_TAGS);
|
|
2755
|
+
if (hooks.uponSanitizeAttribute.length > 0) ALLOWED_ATTR = clone(ALLOWED_ATTR);
|
|
2756
|
+
DOMPurify.removed = [];
|
|
2757
|
+
const inPlace = IN_PLACE && typeof dirty !== "string" && _isNode(dirty);
|
|
2758
|
+
let inPlaceNodes = [];
|
|
2759
|
+
const outerVisited = IN_PLACE_VISITED;
|
|
2760
|
+
if (inPlace) {
|
|
2761
|
+
_neutralizePatchLinkage(dirty);
|
|
2762
|
+
const nn = _readNodeName(dirty);
|
|
2763
|
+
if (typeof nn === "string") {
|
|
2764
|
+
const tagName = transformCaseFunc(nn);
|
|
2765
|
+
if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) {
|
|
2766
|
+
_neutralizeRoot(dirty);
|
|
2767
|
+
throw typeErrorCreate("root node is forbidden and cannot be sanitized in-place");
|
|
2768
|
+
}
|
|
2769
|
+
}
|
|
2770
|
+
if (_isClobbered(dirty)) {
|
|
2771
|
+
_neutralizeRoot(dirty);
|
|
2772
|
+
throw typeErrorCreate("root node is clobbered and cannot be sanitized in-place");
|
|
2773
|
+
}
|
|
2774
|
+
inPlaceNodes = _collectLiveNodes(dirty);
|
|
2775
|
+
IN_PLACE_VISITED = setCreate();
|
|
2776
|
+
} else if (_isNode(dirty)) {
|
|
2777
|
+
body = _initDocument("<!---->");
|
|
2778
|
+
importedNode = body.ownerDocument.importNode(dirty, true);
|
|
2779
|
+
if (importedNode.nodeType === NODE_TYPE.element && importedNode.nodeName === "BODY") body = importedNode;
|
|
2780
|
+
else if (importedNode.nodeName === "HTML") body = importedNode;
|
|
2781
|
+
else body.appendChild(importedNode);
|
|
2782
|
+
_sanitizeAttachedShadowRoots(body);
|
|
2783
|
+
} else {
|
|
2784
|
+
if (!RETURN_DOM && !SAFE_FOR_TEMPLATES && !WHOLE_DOCUMENT && dirty.indexOf("<") === -1) return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? _createTrustedHTML(dirty) : dirty;
|
|
2785
|
+
body = _initDocument(dirty);
|
|
2786
|
+
if (!body) return RETURN_DOM ? null : RETURN_TRUSTED_TYPE ? emptyHTML : "";
|
|
2787
|
+
}
|
|
2788
|
+
if (body && FORCE_BODY) _forceRemove(body.firstChild);
|
|
2789
|
+
const walkRoot = inPlace ? dirty : body;
|
|
2790
|
+
try {
|
|
2791
|
+
if (inPlace) _sanitizeAttachedShadowRoots(dirty);
|
|
2792
|
+
const nodeIterator = _createNodeIterator(walkRoot);
|
|
2793
|
+
while (currentNode = nodeIterator.nextNode()) {
|
|
2794
|
+
_sanitizeElements(currentNode, walkRoot);
|
|
2795
|
+
_sanitizeAttributes(currentNode, walkRoot);
|
|
2796
|
+
if (_isDocumentFragment(currentNode.content)) _sanitizeShadowDOM2(currentNode.content);
|
|
2797
|
+
}
|
|
2798
|
+
if (inPlace) _sanitizeUnvisitedNodes(dirty, inPlaceNodes);
|
|
2799
|
+
} catch (error) {
|
|
2800
|
+
if (inPlace) {
|
|
2801
|
+
_neutralizeRoot(dirty);
|
|
2802
|
+
_neutralizeDiscarded(dirty, inPlaceNodes);
|
|
2803
|
+
}
|
|
2804
|
+
throw error;
|
|
2805
|
+
} finally {
|
|
2806
|
+
IN_PLACE_VISITED = outerVisited;
|
|
2807
|
+
}
|
|
2808
|
+
if (inPlace) {
|
|
2809
|
+
if (_neutralizeDiscarded(dirty, inPlaceNodes)) throw typeErrorCreate("a node selected for removal could not be safely returned; refusing to sanitize in place");
|
|
2810
|
+
if (SAFE_FOR_TEMPLATES) _scrubTemplateExpressions2(dirty);
|
|
2811
|
+
return dirty;
|
|
2812
|
+
}
|
|
2813
|
+
if (RETURN_DOM) {
|
|
2814
|
+
if (SAFE_FOR_TEMPLATES) _scrubTemplateExpressions2(body);
|
|
2815
|
+
if (RETURN_DOM_FRAGMENT) {
|
|
2816
|
+
returnNode = createDocumentFragment.call(body.ownerDocument);
|
|
2817
|
+
while (body.firstChild) returnNode.appendChild(body.firstChild);
|
|
2818
|
+
} else returnNode = body;
|
|
2819
|
+
if (ALLOWED_ATTR.shadowroot || ALLOWED_ATTR.shadowrootmode) returnNode = importNode.call(originalDocument, returnNode, true);
|
|
2820
|
+
return returnNode;
|
|
2821
|
+
}
|
|
2822
|
+
let serializedHTML = WHOLE_DOCUMENT ? body.outerHTML : body.innerHTML;
|
|
2823
|
+
if (WHOLE_DOCUMENT && ALLOWED_TAGS["!doctype"] && body.ownerDocument && body.ownerDocument.doctype && body.ownerDocument.doctype.name && regExpTest(DOCTYPE_NAME, body.ownerDocument.doctype.name)) serializedHTML = "<!DOCTYPE " + body.ownerDocument.doctype.name + ">\n" + serializedHTML;
|
|
2824
|
+
if (SAFE_FOR_TEMPLATES) serializedHTML = _stripTemplateExpressions(serializedHTML);
|
|
2825
|
+
return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? _createTrustedHTML(serializedHTML) : serializedHTML;
|
|
2826
|
+
};
|
|
2827
|
+
DOMPurify.setConfig = function() {
|
|
2828
|
+
let cfg = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
2829
|
+
_parseConfig(cfg);
|
|
2830
|
+
SET_CONFIG = true;
|
|
2831
|
+
SET_CONFIG_ALLOWED_TAGS = ALLOWED_TAGS;
|
|
2832
|
+
SET_CONFIG_ALLOWED_ATTR = ALLOWED_ATTR;
|
|
2833
|
+
};
|
|
2834
|
+
DOMPurify.clearConfig = function() {
|
|
2835
|
+
CONFIG = null;
|
|
2836
|
+
SET_CONFIG = false;
|
|
2837
|
+
SET_CONFIG_ALLOWED_TAGS = null;
|
|
2838
|
+
SET_CONFIG_ALLOWED_ATTR = null;
|
|
2839
|
+
trustedTypesPolicy = defaultTrustedTypesPolicy;
|
|
2840
|
+
emptyHTML = "";
|
|
2841
|
+
};
|
|
2842
|
+
DOMPurify.isValidAttribute = function(tag, attr, value) {
|
|
2843
|
+
if (!CONFIG) _parseConfig({});
|
|
2844
|
+
const lcTag = transformCaseFunc(tag);
|
|
2845
|
+
const lcName = transformCaseFunc(attr);
|
|
2846
|
+
if (typeof value === "string" && (_isUnsafeAttributeValue(attr, value) || !ALLOW_SELF_CLOSE_IN_ATTR && regExpTest(SELF_CLOSING_TAG, value))) return false;
|
|
2847
|
+
return _isValidAttribute(lcTag, lcName, value);
|
|
2848
|
+
};
|
|
2849
|
+
DOMPurify.addHook = function(entryPoint, hookFunction) {
|
|
2850
|
+
if (typeof hookFunction !== "function") return;
|
|
2851
|
+
if (!objectHasOwnProperty(hooks, entryPoint)) return;
|
|
2852
|
+
arrayPush(hooks[entryPoint], hookFunction);
|
|
2853
|
+
};
|
|
2854
|
+
DOMPurify.removeHook = function(entryPoint, hookFunction) {
|
|
2855
|
+
if (!objectHasOwnProperty(hooks, entryPoint)) return;
|
|
2856
|
+
if (hookFunction !== void 0) {
|
|
2857
|
+
const index = arrayLastIndexOf(hooks[entryPoint], hookFunction);
|
|
2858
|
+
return index === -1 ? void 0 : arraySplice(hooks[entryPoint], index, 1)[0];
|
|
2859
|
+
}
|
|
2860
|
+
return arrayPop(hooks[entryPoint]);
|
|
2861
|
+
};
|
|
2862
|
+
DOMPurify.removeHooks = function(entryPoint) {
|
|
2863
|
+
if (!objectHasOwnProperty(hooks, entryPoint)) return;
|
|
2864
|
+
hooks[entryPoint] = [];
|
|
2865
|
+
};
|
|
2866
|
+
DOMPurify.removeAllHooks = function() {
|
|
2867
|
+
hooks = _createHooksMap();
|
|
2868
|
+
};
|
|
2869
|
+
return DOMPurify;
|
|
2870
|
+
}
|
|
2871
|
+
var purify_default = createDOMPurify();
|
|
2872
|
+
|
|
2873
|
+
// node_modules/marked/lib/marked.esm.js
|
|
2874
|
+
function v() {
|
|
2875
|
+
return { async: false, breaks: false, extensions: null, gfm: true, hooks: null, pedantic: false, renderer: null, silent: false, tokenizer: null, walkTokens: null };
|
|
2876
|
+
}
|
|
2877
|
+
var y = v();
|
|
2878
|
+
function ee(a3) {
|
|
2879
|
+
y = a3;
|
|
2880
|
+
}
|
|
2881
|
+
var B = { exec: () => null };
|
|
2882
|
+
function I(a3) {
|
|
2883
|
+
let e = [];
|
|
2884
|
+
return (t) => {
|
|
2885
|
+
let n = Math.max(0, Math.min(3, t - 1)), s = e[n];
|
|
2886
|
+
return s || (s = a3(n), e[n] = s), s;
|
|
2887
|
+
};
|
|
2888
|
+
}
|
|
2889
|
+
function c(a3, e = "") {
|
|
2890
|
+
let t = typeof a3 == "string" ? a3 : a3.source, n = { replace: (s, r) => {
|
|
2891
|
+
let o = typeof r == "string" ? r : r.source;
|
|
2892
|
+
return o = o.replace(T.caret, "$1"), t = t.replace(s, o), n;
|
|
2893
|
+
}, getRegex: () => new RegExp(t, e) };
|
|
2894
|
+
return n;
|
|
2895
|
+
}
|
|
2896
|
+
var Me = ((a3 = "") => {
|
|
2897
|
+
try {
|
|
2898
|
+
return !!new RegExp("(?<=1)(?<!1)" + a3);
|
|
2899
|
+
} catch {
|
|
2900
|
+
return false;
|
|
2901
|
+
}
|
|
2902
|
+
})();
|
|
2903
|
+
var T = { codeRemoveIndent: /^(?: {0,3}\t| {1,4})/gm, outputLinkReplace: /\\([\[\]])/g, indentCodeCompensation: /^(\s+)(?:```)/, beginningSpace: /^\s+/, endingHash: /#$/, startingSpaceChar: /^ /, endingSpaceChar: / $/, endingSpaceTabChar: /[ \t]$/, nonSpaceChar: /[^ ]/, newLineCharGlobal: /\n/g, tabCharGlobal: /\t/g, leadingSpaceTab: /^[ \t]+/, multipleSpaceGlobal: /\s+/g, blankLine: /^[ \t]*$/, doubleBlankLine: /\n[ \t]*\n[ \t]*$/, blockquoteStart: /^ {0,3}>/, blockquoteSetextReplace: /\n {0,3}((?:=+|-+) *)(?=\n|$)/g, blockquoteSetextReplace2: /^ {0,3}>[ \t]?/gm, blockquoteMarkerWhitespace: /^( {0,3}>)([ \t]+)/gm, listReplaceNesting: /^ {1,4}(?=( {4})*[^ ])/g, listIsTask: /^\[[ xX]\] +\S/, listReplaceTask: /^\[[ xX]\] +/, listTaskCheckbox: /\[[ xX]\]/, anyLine: /\n.*\n/, hrefBrackets: /^<(.*)>$/, tableDelimiter: /[:|]/, tableAlignChars: /^\||\| *$/g, tableRowBlankLine: /\n[ \t]*$/, tableAlignRight: /^ *-+: *$/, tableAlignCenter: /^ *:-+: *$/, tableAlignLeft: /^ *:-+ *$/, startATag: /^<a /i, endATag: /^<\/a>/i, startPreScriptTag: /^<(pre|code|kbd|script)(\s|>)/i, endPreScriptTag: /^<\/(pre|code|kbd|script)(\s|>)/i, startAngleBracket: /^</, endAngleBracket: />$/, pedanticHrefTitle: /^([^'"]*[^\s])\s+(['"])(.*)\2/, unicodeAlphaNumeric: /[\p{L}\p{N}]/u, numericCharacterReference: /&#(?:(\d{1,7})|[Xx]([A-Fa-f0-9]{1,6}));/, numericCharacterReferenceOrAmpersand: /&#(?:(\d{1,7})|[Xx]([A-Fa-f0-9]{1,6}));|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g, escapeTest: /[&<>"']/, escapeReplace: /[&<>"']/g, escapeTestNoEncode: /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/, escapeReplaceNoEncode: /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g, caret: /(^|[^\[])\^/g, percentDecode: /%25/g, findPipe: /\|/g, splitPipe: / \|/, slashPipe: /\\\|/g, carriageReturn: /\r\n|\r/g, spaceLine: /^ +$/gm, notSpaceStart: /^\S*/, endingNewline: /\n$/, listItemRegex: (a3) => new RegExp(`^( {0,3}${a3})((?:[ ][^\\n]*)?(?:\\n|$))`), nextBulletRegex: I((a3) => new RegExp(`^ {0,${a3}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)), hrRegex: I((a3) => new RegExp(`^ {0,${a3}}((?:-[ ]*){3,}|(?:_[ ]*){3,}|(?:\\*[ ]*){3,})(?:\\n+|$)`)), fencesBeginRegex: I((a3) => new RegExp(`^ {0,${a3}}(?:\`\`\`|~~~)`)), headingBeginRegex: I((a3) => new RegExp(`^ {0,${a3}}#{1,6}(?:\\s|$)`)), pedanticHeadingBeginRegex: I((a3) => new RegExp(`^ {0,${a3}}#`)), htmlBeginRegex: I((a3) => new RegExp(`^ {0,${a3}}(?:</?(?:${K})(?: +|$|/?>)|<(?:(?:script|pre|style|textarea)(?:[\\s>]|$)|!--)|<\\?|<![A-Za-z]|<!\\[CDATA\\[)`, "i")), blockquoteBeginRegex: I((a3) => new RegExp(`^ {0,${a3}}>`)) };
|
|
2904
|
+
var Ce = /^(?:[ \t]*(?:\n|$))+/;
|
|
2905
|
+
var Ee = /^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/;
|
|
2906
|
+
var Ie = /^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/;
|
|
2907
|
+
var U = /^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/;
|
|
2908
|
+
var Be = /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/;
|
|
2909
|
+
var ne = / {0,3}(?:[*+-]|\d{1,9}[.)])/;
|
|
2910
|
+
var me = /^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |fences|blockquote|heading|hr|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/;
|
|
2911
|
+
var xe = c(me).replace(/bull/g, ne).replace(/blockCode/g, /(?: {4}| {0,3}\t)/).replace(/fences/g, / {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g, / {0,3}>/).replace(/heading/g, / {0,3}#{1,6}(?:\s|$)/).replace(/hr/g, / {0,3}(?:(?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/).replace(/html/g, / {0,3}<[^\n>]+>\n/).replace(/\|table/g, "").getRegex();
|
|
2912
|
+
var De = c(me).replace(/bull/g, ne).replace(/blockCode/g, /(?: {4}| {0,3}\t)/).replace(/fences/g, / {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g, / {0,3}>/).replace(/heading/g, / {0,3}#{1,6}(?:\s|$)/).replace(/hr/g, / {0,3}(?:(?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/).replace(/html/g, / {0,3}<[^\n>]+>\n/).replace(/table/g, / {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex();
|
|
2913
|
+
var re = /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table|[ \t]+\n)[^\n]+)*)/;
|
|
2914
|
+
var qe = /^[^\n]+/;
|
|
2915
|
+
var se = /(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/;
|
|
2916
|
+
var Ze = c(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label", se).replace("title", /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex();
|
|
2917
|
+
var ve = c(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g, ne).getRegex();
|
|
2918
|
+
var K = "address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul";
|
|
2919
|
+
var ie = /<!--(?:-?>|[\s\S]*?(?:-->|$))/;
|
|
2920
|
+
var He = c("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n*|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>[^\\n]*\\n*|$)|<![A-Z][\\s\\S]*?(?:>[^\\n]*\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>[^\\n]*\\n*|$)|</?(tag)(?:[ \\t]+|\\n|/?>|$)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!(?:script|pre|style|textarea)(?![a-z0-9-]))([a-z][a-z0-9-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</[a-z][a-z0-9-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))", "i").replace("comment", ie).replace("tag", K).replace("attribute", / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex();
|
|
2921
|
+
var be = (a3) => c(re).replace("hr", U).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("|table", "").replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace("list", a3).replace("html", " {0,3}(?:</?(?:tag)(?: +|\\n|/?>)|<(?:(?:script|pre|style|textarea)(?:[\\s>]|$)|!--)|<\\?|<![A-Za-z]|<!\\[CDATA\\[)").replace("tag", K).getRegex();
|
|
2922
|
+
var Ge = be(/ {0,3}(?:[*+-]|1[.)])[ \t]+[^ \t\n]/);
|
|
2923
|
+
var Ne = be(/ {0,3}(?:[*+-]|\d{1,9}[.)])(?:[ \t]|\n|$)/);
|
|
2924
|
+
var Qe = c(/^( {0,3}> ?(?:(?![ \t]*(?:\n|$))(paragraph)|[^\n]*)(?:\n|$))+/).replace("paragraph", Ne).getRegex();
|
|
2925
|
+
var oe = { blockquote: Qe, code: Ee, def: Ze, fences: Ie, heading: Be, hr: U, html: He, lheading: xe, list: ve, newline: Ce, paragraph: Ge, table: B, text: qe };
|
|
2926
|
+
var ke = c("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr", U).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("blockquote", " {0,3}>").replace("code", "(?: {4}| {0,3} )[^\\n]").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace("list", " {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html", " {0,3}(?:</?(?:tag)(?: +|\\n|/?>)|<(?:(?:script|pre|style|textarea)(?:[\\s>]|$)|!--)|<\\?|<![A-Za-z]|<!\\[CDATA\\[)").replace("tag", K).getRegex();
|
|
2927
|
+
var je = { ...oe, lheading: De, table: ke, paragraph: c(re).replace("hr", U).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("table", ke).replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace("list", " {0,3}(?:[*+-]|1[.)])[ \\t]+[^ \\t\\n]").replace("html", " {0,3}(?:</?(?:tag)(?: +|\\n|/?>)|<(?:(?:script|pre|style|textarea)(?:[\\s>]|$)|!--)|<\\?|<![A-Za-z]|<!\\[CDATA\\[)").replace("tag", K).getRegex() };
|
|
2928
|
+
var Fe = { ...oe, html: c(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment", ie).replace(/tag/g, "(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(), def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/, heading: /^(#{1,6})(.*)(?:\n+|$)/, fences: B, lheading: /^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/, paragraph: c(re).replace("hr", U).replace("heading", ` *#{1,6} *[^
|
|
2929
|
+
]`).replace("lheading", xe).replace("|table", "").replace("blockquote", " {0,3}>").replace("|fences", "").replace("|list", "").replace("|html", "").replace("|tag", "").getRegex() };
|
|
2930
|
+
var Ue = /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/;
|
|
2931
|
+
var Ke = /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/;
|
|
2932
|
+
var Re = /^( {2,}|\\)\n(?!\s*$)[ \t]*/;
|
|
2933
|
+
var We = /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/;
|
|
2934
|
+
var $ = /[\p{P}\p{S}]/u;
|
|
2935
|
+
var H = /[\s\p{P}\p{S}]/u;
|
|
2936
|
+
var W = /[^\s\p{P}\p{S}]/u;
|
|
2937
|
+
var Xe = c(/^((?![*_])punctSpace)/, "u").replace(/punctSpace/g, H).getRegex();
|
|
2938
|
+
var Ve = /[\p{Pi}\p{Ps}"']/u;
|
|
2939
|
+
var Te = /(?!~)[\p{P}\p{S}]/u;
|
|
2940
|
+
var Je = /(?!~)[\s\p{P}\p{S}]/u;
|
|
2941
|
+
var Ye = /(?:[^\s\p{P}\p{S}]|~)/u;
|
|
2942
|
+
var et = c(/link|precode-code|html/, "g").replace("link", /\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-", Me ? "(?<!`)()" : "(^^|[^`])").replace("code", /(?<b>`+)[^`]+\k<b>(?!`)/).replace("html", /<(?! )[^<>]*?>/).getRegex();
|
|
2943
|
+
var Oe = /^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/;
|
|
2944
|
+
var tt = c(Oe, "u").replace(/punct/g, $).getRegex();
|
|
2945
|
+
var nt = c(Oe, "u").replace(/punct/g, Te).getRegex();
|
|
2946
|
+
var rt = /^(?:\*+(?:((?!\*)(?!openQuote)punct)|([^\s*]))?)|^_+(?:((?!_)(?!openQuote)punct)|([^\s_]))?/;
|
|
2947
|
+
var st = c(rt, "u").replace(/openQuote/g, Ve).replace(/punct/g, $).getRegex();
|
|
2948
|
+
var we = "^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)";
|
|
2949
|
+
var it = c(we, "gu").replace(/notPunctSpace/g, W).replace(/punctSpace/g, H).replace(/punct/g, $).getRegex();
|
|
2950
|
+
var ot = c(we, "gu").replace(/notPunctSpace/g, Ye).replace(/punctSpace/g, Je).replace(/punct/g, Te).getRegex();
|
|
2951
|
+
var at = "^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)[\\s](\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|(?:(?!\\*)punct|notPunctSpace)(\\*+)(?!\\*)(?=notPunctSpace)";
|
|
2952
|
+
var lt = c(at, "gu").replace(/notPunctSpace/g, W).replace(/punctSpace/g, H).replace(/punct/g, $).getRegex();
|
|
2953
|
+
var ut = c("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)", "gu").replace(/notPunctSpace/g, W).replace(/punctSpace/g, H).replace(/punct/g, $).getRegex();
|
|
2954
|
+
var pt = "^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)[\\s](_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)|(?:(?!_)punct|notPunctSpace)(_+)(?!_)(?=notPunctSpace)";
|
|
2955
|
+
var ct = c(pt, "gu").replace(/notPunctSpace/g, W).replace(/punctSpace/g, H).replace(/punct/g, $).getRegex();
|
|
2956
|
+
var ht = c(/^~~?(?:((?!~)punct)|[^\s~])/, "u").replace(/punct/g, $).getRegex();
|
|
2957
|
+
var dt = "^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)";
|
|
2958
|
+
var kt = c(dt, "gu").replace(/notPunctSpace/g, W).replace(/punctSpace/g, H).replace(/punct/g, $).getRegex();
|
|
2959
|
+
var gt = c(/\\(punct)/, "gu").replace(/punct/g, $).getRegex();
|
|
2960
|
+
var ft = c(/(`+)(?:[^`]|[^`][\s\S]*?[^`])\1(?!`)|`+|\\(punct)/, "gu").replace(/punct/g, $).getRegex();
|
|
2961
|
+
var mt = c(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme", /[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email", /[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex();
|
|
2962
|
+
var xt = c(ie).replace("(?:-->|$)", "-->").getRegex();
|
|
2963
|
+
var bt = c("^comment|^</[a-zA-Z][a-zA-Z0-9-]*\\s*>|^<[a-zA-Z][a-zA-Z0-9-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment", xt).replace("attribute", /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex();
|
|
2964
|
+
var Pe = /\[(?:\\[\s\S]|[^\[\]\\])*\]/;
|
|
2965
|
+
var Y = c(/(?:\[(?:brackets|\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/).replace("brackets", Pe).getRegex();
|
|
2966
|
+
var Rt = c(/^!?\[(label)\]\([ \t\n]*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?[ \t\n]*\)/).replace("label", Y).replace("href", /<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]+|(?=\))/).replace("title", /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex();
|
|
2967
|
+
var Tt = c(/^!?\[(label)\]\[(ref)\]/).replace("label", Y).replace("ref", se).getRegex();
|
|
2968
|
+
var Ot = c(/^!?\[(ref)\](?:\[\])?/).replace("ref", se).getRegex();
|
|
2969
|
+
var ge = /(?!\s*\])(?:\\[\s\S]|[^\[\]\\]){1,999}/;
|
|
2970
|
+
var wt = c(/(?:[^\[\]\\`]*(?:\[(?:brackets|\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\]))){0,999}?[^\[\]\\`]*?/).replace("brackets", Pe).getRegex();
|
|
2971
|
+
var Pt = c("reflink|nolink(?!\\()", "g").replace("reflink", c(/^!?\[(label)\]\[(ref)\]/).replace("label", wt).replace("ref", ge).getRegex()).replace("nolink", c(/^!?\[(ref)\](?:\[\])?/).replace("ref", ge).getRegex()).getRegex();
|
|
2972
|
+
var fe = /[hH][tT][tT][pP][sS]?|[fF][tT][pP]/;
|
|
2973
|
+
var yt = /[A-Za-z0-9._+-]+@[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![\w-])/;
|
|
2974
|
+
var St = c(/(?:mailto:email|xmpp:email(?:\/[A-Za-z0-9@.]+)?)/).replace(/email/g, yt).getRegex();
|
|
2975
|
+
var ae = { _backpedal: B, anyPunctuation: gt, anyPunctuationOutsideCode: ft, autolink: mt, blockSkip: et, br: Re, code: Ke, del: B, delLDelim: B, delRDelim: B, emStrongLDelim: tt, emStrongRDelimAst: it, emStrongRDelimUnd: ut, escape: Ue, link: Rt, nolink: Ot, punctuation: Xe, reflink: Tt, reflinkSearch: Pt, tag: bt, text: We, url: B };
|
|
2976
|
+
var _t = { ...ae, emStrongLDelim: st, emStrongRDelimAst: lt, emStrongRDelimUnd: ct, link: c(/^!?\[(label)\]\((.*?)\)/).replace("label", Y).getRegex(), reflink: c(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label", Y).getRegex() };
|
|
2977
|
+
var te = { ...ae, emStrongRDelimAst: ot, emStrongLDelim: nt, delLDelim: ht, delRDelim: kt, url: c(/^emailProtocol|^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("emailProtocol", St).replace("protocol", fe).replace("email", /[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![\w-])/).getRegex(), _backpedal: /(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/, del: /^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/, text: c(/^(?:[^a-zA-Z0-9](?=emailProtocol)|(`+|~+|[^`~])(?:(?=[`~])|(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9](?=emailProtocol)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@))))/).replace("protocol", fe).replace(/emailProtocol/g, /(?:mailto|xmpp):/).getRegex() };
|
|
2978
|
+
var $t = { ...te, br: c(Re).replace("{2,}", "*").getRegex(), text: c(te.text).replace("\\b_", "\\b_| {2,}\\n").replace(/\{2,\}/g, "*").getRegex() };
|
|
2979
|
+
var X = { normal: oe, gfm: je, pedantic: Fe };
|
|
2980
|
+
var G = { normal: ae, gfm: te, breaks: $t, pedantic: _t };
|
|
2981
|
+
var Lt = { "&": "&", "<": "<", ">": ">", '"': """, "'": "'" };
|
|
2982
|
+
var ye = (a3) => Lt[a3];
|
|
2983
|
+
function P(a3, e) {
|
|
2984
|
+
if (e) {
|
|
2985
|
+
if (T.escapeTest.test(a3)) return a3.replace(T.escapeReplace, ye);
|
|
2986
|
+
} else if (T.escapeTestNoEncode.test(a3)) return a3.replace(T.escapeReplaceNoEncode, ye);
|
|
2987
|
+
return a3;
|
|
2988
|
+
}
|
|
2989
|
+
function Se(a3) {
|
|
2990
|
+
return T.numericCharacterReference.test(a3) ? a3.replace(T.numericCharacterReferenceOrAmpersand, (e, t, n) => {
|
|
2991
|
+
if (t === void 0 && n === void 0) return "&";
|
|
2992
|
+
let s = t === void 0 ? Number.parseInt(n, 16) : Number.parseInt(t, 10);
|
|
2993
|
+
return s === 0 || s > 1114111 || s >= 55296 && s <= 57343 ? "\uFFFD" : s === 38 ? "&" : String.fromCodePoint(s);
|
|
2994
|
+
}) : a3;
|
|
2995
|
+
}
|
|
2996
|
+
function le(a3) {
|
|
2997
|
+
try {
|
|
2998
|
+
a3 = encodeURI(a3).replace(T.percentDecode, "%");
|
|
2999
|
+
} catch {
|
|
3000
|
+
return null;
|
|
3001
|
+
}
|
|
3002
|
+
return a3;
|
|
3003
|
+
}
|
|
3004
|
+
function ue(a3, e) {
|
|
3005
|
+
let t = a3.replace(T.findPipe, (r, o, i) => {
|
|
3006
|
+
let l = false, u = o;
|
|
3007
|
+
for (; --u >= 0 && i[u] === "\\"; ) l = !l;
|
|
3008
|
+
return l ? "|" : " |";
|
|
3009
|
+
}), n = t.split(T.splitPipe), s = 0;
|
|
3010
|
+
if (n[0].trim() || n.shift(), n.length > 0 && !n.at(-1)?.trim() && n.pop(), e) if (n.length > e) n.splice(e);
|
|
3011
|
+
else for (; n.length < e; ) n.push("");
|
|
3012
|
+
for (; s < n.length; s++) n[s] = n[s].trim().replace(T.slashPipe, "|");
|
|
3013
|
+
return n;
|
|
3014
|
+
}
|
|
3015
|
+
function z(a3, e, t) {
|
|
3016
|
+
let n = a3.length;
|
|
3017
|
+
if (n === 0) return "";
|
|
3018
|
+
let s = 0;
|
|
3019
|
+
for (; s < n; ) {
|
|
3020
|
+
let r = a3.charAt(n - s - 1);
|
|
3021
|
+
if (r === e && !t) s++;
|
|
3022
|
+
else if (r !== e && t) s++;
|
|
3023
|
+
else break;
|
|
3024
|
+
}
|
|
3025
|
+
return a3.slice(0, n - s);
|
|
3026
|
+
}
|
|
3027
|
+
function pe(a3) {
|
|
3028
|
+
let e = a3.split(`
|
|
3029
|
+
`), t = e.length - 1;
|
|
3030
|
+
for (; t >= 0 && T.blankLine.test(e[t]); ) t--;
|
|
3031
|
+
return e.length - t <= 2 ? a3 : e.slice(0, t + 1).join(`
|
|
3032
|
+
`);
|
|
3033
|
+
}
|
|
3034
|
+
function N(a3) {
|
|
3035
|
+
return a3.trim().toLowerCase().toUpperCase().toLowerCase();
|
|
3036
|
+
}
|
|
3037
|
+
function ce(a3, e) {
|
|
3038
|
+
if (a3.indexOf(e[0]) === -1 && a3.indexOf(e[1]) === -1) return -1;
|
|
3039
|
+
let t = 0;
|
|
3040
|
+
for (let n = 0; n < a3.length; n++) if (a3[n] === "\\") n++;
|
|
3041
|
+
else if (a3[n] === e[0]) t++;
|
|
3042
|
+
else if (a3[n] === e[1] && (t--, t < 0)) return n;
|
|
3043
|
+
return t > 0 ? -2 : -1;
|
|
3044
|
+
}
|
|
3045
|
+
function V(a3, e = 0) {
|
|
3046
|
+
let t = e, n = "";
|
|
3047
|
+
for (let s of a3) if (s === " ") {
|
|
3048
|
+
let r = 4 - t % 4;
|
|
3049
|
+
n += " ".repeat(r), t += r;
|
|
3050
|
+
} else n += s, t++;
|
|
3051
|
+
return n;
|
|
3052
|
+
}
|
|
3053
|
+
function _e(a3, e, t, n, s) {
|
|
3054
|
+
let r = e.href, o = e.title || null, i = a3[1].replace(s.other.outputLinkReplace, "$1"), l = a3[0].charAt(0) === "!", u = n.state.inLink, h = n.state.linkEmitted, p = n.state.inRawBlock;
|
|
3055
|
+
n.state.inLink = true, n.state.linkEmitted = false;
|
|
3056
|
+
let d = n.inlineTokens(i), g = n.state.linkEmitted;
|
|
3057
|
+
if (n.state.linkEmitted = h, n.state.inLink = u, !l) {
|
|
3058
|
+
if (g) {
|
|
3059
|
+
n.state.inRawBlock = p;
|
|
3060
|
+
return;
|
|
3061
|
+
}
|
|
3062
|
+
n.state.linkEmitted = true;
|
|
3063
|
+
}
|
|
3064
|
+
return { type: l ? "image" : "link", raw: t, href: r, title: o, text: i, tokens: d };
|
|
3065
|
+
}
|
|
3066
|
+
function At(a3, e, t) {
|
|
3067
|
+
let n = a3.match(t.other.indentCodeCompensation);
|
|
3068
|
+
if (n === null) return e;
|
|
3069
|
+
let s = n[1];
|
|
3070
|
+
return e.split(`
|
|
3071
|
+
`).map((r) => {
|
|
3072
|
+
let o = r.match(t.other.beginningSpace);
|
|
3073
|
+
if (o === null) return r;
|
|
3074
|
+
let [i] = o;
|
|
3075
|
+
return r.slice(Math.min(i.length, s.length));
|
|
3076
|
+
}).join(`
|
|
3077
|
+
`);
|
|
3078
|
+
}
|
|
3079
|
+
function $e(a3, e, t, n) {
|
|
3080
|
+
if (!e.includes("<")) return false;
|
|
3081
|
+
for (let s = 0; s < e.length; s++) {
|
|
3082
|
+
if (e[s] === "\\") {
|
|
3083
|
+
s++;
|
|
3084
|
+
continue;
|
|
3085
|
+
}
|
|
3086
|
+
if (e[s] === "`") {
|
|
3087
|
+
let i = n.inline.code.exec(e.slice(s));
|
|
3088
|
+
if (i) {
|
|
3089
|
+
s += i[0].length - 1;
|
|
3090
|
+
continue;
|
|
3091
|
+
}
|
|
3092
|
+
}
|
|
3093
|
+
if (e[s] !== "<") continue;
|
|
3094
|
+
let r = a3.slice(t + s), o = n.inline.tag.exec(r) || n.inline.autolink.exec(r);
|
|
3095
|
+
if (o) {
|
|
3096
|
+
if (o[0].length > e.length - s) return true;
|
|
3097
|
+
s += o[0].length - 1;
|
|
3098
|
+
}
|
|
3099
|
+
}
|
|
3100
|
+
return false;
|
|
3101
|
+
}
|
|
3102
|
+
var _ = class {
|
|
3103
|
+
options;
|
|
3104
|
+
rules;
|
|
3105
|
+
lexer;
|
|
3106
|
+
constructor(e) {
|
|
3107
|
+
this.options = e || y;
|
|
3108
|
+
}
|
|
3109
|
+
space(e) {
|
|
3110
|
+
let t = this.rules.block.newline.exec(e);
|
|
3111
|
+
if (t && t[0].length > 0) return { type: "space", raw: t[0] };
|
|
3112
|
+
}
|
|
3113
|
+
code(e) {
|
|
3114
|
+
let t = this.rules.block.code.exec(e);
|
|
3115
|
+
if (t) {
|
|
3116
|
+
let n = this.options.pedantic ? t[0] : pe(t[0]), s = n.replace(this.rules.other.codeRemoveIndent, "");
|
|
3117
|
+
return { type: "code", raw: n, codeBlockStyle: "indented", text: s };
|
|
3118
|
+
}
|
|
3119
|
+
}
|
|
3120
|
+
fences(e) {
|
|
3121
|
+
let t = this.rules.block.fences.exec(e);
|
|
3122
|
+
if (t) {
|
|
3123
|
+
let n = t[0], s = At(n, t[3] || "", this.rules);
|
|
3124
|
+
return { type: "code", raw: n, lang: t[2] ? t[2].trim().replace(this.rules.inline.anyPunctuation, "$1") : t[2], text: s };
|
|
3125
|
+
}
|
|
3126
|
+
}
|
|
3127
|
+
heading(e) {
|
|
3128
|
+
let t = this.rules.block.heading.exec(e);
|
|
3129
|
+
if (t) {
|
|
3130
|
+
let n = t[2].trim();
|
|
3131
|
+
if (this.rules.other.endingHash.test(n)) {
|
|
3132
|
+
let s = z(n, "#");
|
|
3133
|
+
(this.options.pedantic || !s || this.rules.other.endingSpaceTabChar.test(s)) && (n = s.trim());
|
|
3134
|
+
}
|
|
3135
|
+
return { type: "heading", raw: z(t[0], `
|
|
3136
|
+
`), depth: t[1].length, text: n, tokens: this.lexer.inline(n) };
|
|
3137
|
+
}
|
|
3138
|
+
}
|
|
3139
|
+
hr(e) {
|
|
3140
|
+
let t = this.rules.block.hr.exec(e);
|
|
3141
|
+
if (t) return { type: "hr", raw: z(t[0], `
|
|
3142
|
+
`) };
|
|
3143
|
+
}
|
|
3144
|
+
blockquote(e) {
|
|
3145
|
+
let t = this.rules.block.blockquote.exec(e);
|
|
3146
|
+
if (t) {
|
|
3147
|
+
let n = z(t[0], `
|
|
3148
|
+
`).split(`
|
|
3149
|
+
`), s = "", r = "", o = [];
|
|
3150
|
+
for (; n.length > 0; ) {
|
|
3151
|
+
let i = false, l = [], u;
|
|
3152
|
+
for (u = 0; u < n.length; u++) if (this.rules.other.blockquoteStart.test(n[u])) l.push(n[u]), i = true;
|
|
3153
|
+
else if (!i) l.push(n[u]);
|
|
3154
|
+
else break;
|
|
3155
|
+
n = n.slice(u);
|
|
3156
|
+
let h = l.join(`
|
|
3157
|
+
`), p = h.replace(this.rules.other.blockquoteMarkerWhitespace, (k, b, x) => b + V(x, b.length)).replace(this.rules.other.blockquoteSetextReplace, `
|
|
3158
|
+
$1`).replace(this.rules.other.blockquoteSetextReplace2, "");
|
|
3159
|
+
s = s ? `${s}
|
|
3160
|
+
${h}` : h, r = r ? `${r}
|
|
3161
|
+
${p}` : p;
|
|
3162
|
+
let d = this.lexer.state.top;
|
|
3163
|
+
if (this.lexer.state.top = true, this.lexer.blockTokens(p, o, true), this.lexer.state.top = d, n.length === 0) break;
|
|
3164
|
+
let g = o.at(-1);
|
|
3165
|
+
if (g?.type === "code" || g?.type === "heading" || g?.type === "hr" || g?.type === "html") break;
|
|
3166
|
+
if (g?.type === "blockquote") {
|
|
3167
|
+
let k = g, b = n.join(`
|
|
3168
|
+
`), x = k.raw + `
|
|
3169
|
+
` + b.replace(this.rules.other.blockquoteSetextReplace2, ""), f = this.blockquote(x);
|
|
3170
|
+
o[o.length - 1] = f;
|
|
3171
|
+
let S = x.substring(f.raw.length).replace(/^\n/, ""), R = S ? S.split(`
|
|
3172
|
+
`).length : 0, C = R ? n.slice(0, -R) : n;
|
|
3173
|
+
C.length > 0 && (s = `${s}
|
|
3174
|
+
${C.join(`
|
|
3175
|
+
`)}`), r = r.substring(0, r.length - k.text.length) + f.text;
|
|
3176
|
+
break;
|
|
3177
|
+
} else if (g?.type === "list") {
|
|
3178
|
+
let k = g, b = k.raw + `
|
|
3179
|
+
` + n.join(`
|
|
3180
|
+
`), x = this.list(b);
|
|
3181
|
+
o[o.length - 1] = x;
|
|
3182
|
+
let f = x.raw.length > k.raw.length ? b.slice(k.raw.length + 1, x.raw.length).split(`
|
|
3183
|
+
`).length : 0;
|
|
3184
|
+
if (f > 0) {
|
|
3185
|
+
let S = n.slice(0, f).join(`
|
|
3186
|
+
`);
|
|
3187
|
+
s = `${s}
|
|
3188
|
+
${S}`, r = `${r}
|
|
3189
|
+
${S}`;
|
|
3190
|
+
}
|
|
3191
|
+
n = n.slice(f);
|
|
3192
|
+
continue;
|
|
3193
|
+
}
|
|
3194
|
+
}
|
|
3195
|
+
return { type: "blockquote", raw: s, tokens: o, text: r };
|
|
3196
|
+
}
|
|
3197
|
+
}
|
|
3198
|
+
list(e) {
|
|
3199
|
+
let t = this.rules.block.list.exec(e);
|
|
3200
|
+
if (t) {
|
|
3201
|
+
let n = e, s = () => n.length - e.length, r = t[1].trim(), o = r.length > 1, i = { type: "list", raw: "", ordered: o, start: o ? +r.slice(0, -1) : "", loose: false, items: [] };
|
|
3202
|
+
r = o ? `\\d{1,9}\\${r.slice(-1)}` : `\\${r}`, this.options.pedantic && (r = o ? r : "[*+-]");
|
|
3203
|
+
let l = this.rules.other.listItemRegex(r), u = false;
|
|
3204
|
+
for (; e; ) {
|
|
3205
|
+
let p = false, d = "";
|
|
3206
|
+
if (!(t = l.exec(e)) || this.rules.block.hr.test(e)) break;
|
|
3207
|
+
let g = s();
|
|
3208
|
+
e = e.substring(t[0].length);
|
|
3209
|
+
let k = t[2].split(`
|
|
3210
|
+
`, 1)[0], b = t[1].length, x = this.options.pedantic ? V(k, b) : k.replace(this.rules.other.leadingSpaceTab, (Q) => V(Q, b)), f = e.split(`
|
|
3211
|
+
`, 1)[0], S = !x.trim(), R = 0;
|
|
3212
|
+
if (this.options.pedantic ? (R = 2, d = x.trimStart()) : S ? R = b + 1 : (R = x.search(this.rules.other.nonSpaceChar), R = R > 4 ? 1 : R, d = x.slice(R), R += b), S && this.rules.other.blankLine.test(f) && (e = e.substring(f.length + 1), p = true), !p) {
|
|
3213
|
+
let Q = this.rules.other.nextBulletRegex(R), E = this.rules.other.hrRegex(R), j = this.rules.other.fencesBeginRegex(R), F = this.options.pedantic ? this.rules.other.pedanticHeadingBeginRegex(R) : this.rules.other.headingBeginRegex(R), Le = this.rules.other.htmlBeginRegex(R), Ae = this.rules.other.blockquoteBeginRegex(R);
|
|
3214
|
+
for (; e; ) {
|
|
3215
|
+
let he = e.split(`
|
|
3216
|
+
`, 1)[0], Z;
|
|
3217
|
+
if (f = he, this.options.pedantic ? (f = f.replace(this.rules.other.listReplaceNesting, " "), Z = f) : Z = f.replace(this.rules.other.leadingSpaceTab, (de) => V(de)), j.test(f) || F.test(f) || Le.test(f) || Ae.test(f) || Q.test(f) || E.test(f)) break;
|
|
3218
|
+
if (Z.search(this.rules.other.nonSpaceChar) >= R || !f.trim()) d += `
|
|
3219
|
+
` + Z.slice(R);
|
|
3220
|
+
else {
|
|
3221
|
+
if (S || x.replace(this.rules.other.tabCharGlobal, " ").search(this.rules.other.nonSpaceChar) >= 4 || j.test(x) || F.test(x) || E.test(x)) break;
|
|
3222
|
+
let ze = !this.options.pedantic && /^ {0,3}(?:=+|-+) *$/.test(f) && this.rules.block.lheading.test(`${x}
|
|
3223
|
+
${f}`) ? ` ${Z.replace(/^ {0,3}/, "")}` : f;
|
|
3224
|
+
d += `
|
|
3225
|
+
` + ze;
|
|
3226
|
+
}
|
|
3227
|
+
S = !f.trim(), e = e.substring(he.length + 1), x = Z.slice(R);
|
|
3228
|
+
}
|
|
3229
|
+
}
|
|
3230
|
+
let C = n.slice(g, s());
|
|
3231
|
+
i.loose || (u ? i.loose = true : this.rules.other.doubleBlankLine.test(C) && (u = true)), i.items.push({ type: "list_item", raw: C, task: !!this.options.gfm && this.rules.other.listIsTask.test(d), loose: false, text: d, tokens: [] });
|
|
3232
|
+
}
|
|
3233
|
+
let h = i.items.at(-1);
|
|
3234
|
+
if (h) h.raw = h.raw.trimEnd(), h.text = h.text.trimEnd();
|
|
3235
|
+
else return;
|
|
3236
|
+
i.raw = n.slice(0, s()).trimEnd();
|
|
3237
|
+
for (let p of i.items) if (this.lexer.state.top = false, p.tokens = this.lexer.blockTokens(p.text, []), !i.loose) {
|
|
3238
|
+
let d = p.tokens.filter((k) => k.type === "space"), g = d.length > 0 && d.some((k) => this.rules.other.anyLine.test(k.raw));
|
|
3239
|
+
i.loose = g;
|
|
3240
|
+
}
|
|
3241
|
+
for (let p of i.items) {
|
|
3242
|
+
let d = p.tokens[0];
|
|
3243
|
+
if (p.task && (d?.type === "text" || d?.type === "paragraph")) {
|
|
3244
|
+
p.text = p.text.replace(this.rules.other.listReplaceTask, ""), d.raw = d.raw.replace(this.rules.other.listReplaceTask, ""), d.text = d.text.replace(this.rules.other.listReplaceTask, "");
|
|
3245
|
+
for (let k = this.lexer.inlineQueue.length - 1; k >= 0; k--) if (this.rules.other.listIsTask.test(this.lexer.inlineQueue[k].src)) {
|
|
3246
|
+
this.lexer.inlineQueue[k].src = this.lexer.inlineQueue[k].src.replace(this.rules.other.listReplaceTask, "");
|
|
3247
|
+
break;
|
|
3248
|
+
}
|
|
3249
|
+
let g = this.rules.other.listTaskCheckbox.exec(p.raw);
|
|
3250
|
+
if (g) {
|
|
3251
|
+
let k = { type: "checkbox", raw: g[0] + " ", checked: g[0] !== "[ ]" };
|
|
3252
|
+
p.checked = k.checked, i.loose ? p.tokens[0] && ["paragraph", "text"].includes(p.tokens[0].type) && "tokens" in p.tokens[0] && p.tokens[0].tokens ? (p.tokens[0].raw = k.raw + p.tokens[0].raw, p.tokens[0].text = k.raw + p.tokens[0].text, p.tokens[0].tokens.unshift(k)) : p.tokens.unshift({ type: "paragraph", raw: k.raw, text: k.raw, tokens: [k] }) : p.tokens.unshift(k);
|
|
3253
|
+
}
|
|
3254
|
+
} else p.task && (p.task = false);
|
|
3255
|
+
}
|
|
3256
|
+
if (i.loose) for (let p of i.items) {
|
|
3257
|
+
p.loose = true;
|
|
3258
|
+
for (let d of p.tokens) d.type === "text" && (d.type = "paragraph");
|
|
3259
|
+
}
|
|
3260
|
+
return i;
|
|
3261
|
+
}
|
|
3262
|
+
}
|
|
3263
|
+
html(e) {
|
|
3264
|
+
let t = this.rules.block.html.exec(e);
|
|
3265
|
+
if (t) {
|
|
3266
|
+
let n = pe(t[0]);
|
|
3267
|
+
return { type: "html", block: true, raw: n, pre: t[1] === "pre" || t[1] === "script" || t[1] === "style", text: n };
|
|
3268
|
+
}
|
|
3269
|
+
}
|
|
3270
|
+
def(e) {
|
|
3271
|
+
let t = this.rules.block.def.exec(e);
|
|
3272
|
+
if (t) {
|
|
3273
|
+
if (!this.rules.other.startAngleBracket.test(t[2]) && ce(t[2], "()") !== -1) return;
|
|
3274
|
+
let n = N(t[1]).replace(this.rules.other.multipleSpaceGlobal, " "), s = t[2] ? t[2].replace(this.rules.other.hrefBrackets, "$1").replace(this.rules.inline.anyPunctuation, "$1") : "", r = t[3] ? t[3].substring(1, t[3].length - 1).replace(this.rules.inline.anyPunctuation, "$1") : t[3];
|
|
3275
|
+
return { type: "def", tag: n, raw: z(t[0], `
|
|
3276
|
+
`), href: s, title: r };
|
|
3277
|
+
}
|
|
3278
|
+
}
|
|
3279
|
+
table(e) {
|
|
3280
|
+
let t = this.rules.block.table.exec(e);
|
|
3281
|
+
if (!t || !this.rules.other.tableDelimiter.test(t[2])) return;
|
|
3282
|
+
let n = ue(t[1]), s = t[2].replace(this.rules.other.tableAlignChars, "").split("|"), r = t[3]?.trim() ? t[3].replace(this.rules.other.tableRowBlankLine, "").split(`
|
|
3283
|
+
`) : [], o = { type: "table", raw: z(t[0], `
|
|
3284
|
+
`), header: [], align: [], rows: [] };
|
|
3285
|
+
if (n.length === s.length) {
|
|
3286
|
+
for (let i of s) this.rules.other.tableAlignRight.test(i) ? o.align.push("right") : this.rules.other.tableAlignCenter.test(i) ? o.align.push("center") : this.rules.other.tableAlignLeft.test(i) ? o.align.push("left") : o.align.push(null);
|
|
3287
|
+
for (let i = 0; i < n.length; i++) o.header.push({ text: n[i], tokens: this.lexer.inline(n[i]), header: true, align: o.align[i] });
|
|
3288
|
+
for (let i of r) o.rows.push(ue(i, o.header.length).map((l, u) => ({ text: l, tokens: this.lexer.inline(l), header: false, align: o.align[u] })));
|
|
3289
|
+
return o;
|
|
3290
|
+
}
|
|
3291
|
+
}
|
|
3292
|
+
lheading(e) {
|
|
3293
|
+
let t = this.rules.block.lheading.exec(e);
|
|
3294
|
+
if (t) {
|
|
3295
|
+
let n = t[1].trim();
|
|
3296
|
+
return { type: "heading", raw: z(t[0], `
|
|
3297
|
+
`), depth: t[2].charAt(0) === "=" ? 1 : 2, text: n, tokens: this.lexer.inline(n) };
|
|
3298
|
+
}
|
|
3299
|
+
}
|
|
3300
|
+
paragraph(e) {
|
|
3301
|
+
let t = this.rules.block.paragraph.exec(e);
|
|
3302
|
+
if (t) {
|
|
3303
|
+
let n = t[1].charAt(t[1].length - 1) === `
|
|
3304
|
+
` ? t[1].slice(0, -1) : t[1];
|
|
3305
|
+
return { type: "paragraph", raw: t[0], text: n, tokens: this.lexer.inline(n) };
|
|
3306
|
+
}
|
|
3307
|
+
}
|
|
3308
|
+
text(e) {
|
|
3309
|
+
let t = this.rules.block.text.exec(e);
|
|
3310
|
+
if (t) return { type: "text", raw: t[0], text: t[0], tokens: this.lexer.inline(t[0]) };
|
|
3311
|
+
}
|
|
3312
|
+
escape(e) {
|
|
3313
|
+
let t = this.rules.inline.escape.exec(e);
|
|
3314
|
+
if (t) return { type: "escape", raw: t[0], text: t[1] };
|
|
3315
|
+
}
|
|
3316
|
+
tag(e) {
|
|
3317
|
+
let t = this.rules.inline.tag.exec(e);
|
|
3318
|
+
if (t) return !this.lexer.state.inLink && this.rules.other.startATag.test(t[0]) ? this.lexer.state.inLink = true : this.lexer.state.inLink && this.rules.other.endATag.test(t[0]) && (this.lexer.state.inLink = false), !this.lexer.state.inRawBlock && this.rules.other.startPreScriptTag.test(t[0]) ? this.lexer.state.inRawBlock = true : this.lexer.state.inRawBlock && this.rules.other.endPreScriptTag.test(t[0]) && (this.lexer.state.inRawBlock = false), { type: "html", raw: t[0], inLink: this.lexer.state.inLink, inRawBlock: this.lexer.state.inRawBlock, block: false, text: t[0] };
|
|
3319
|
+
}
|
|
3320
|
+
link(e) {
|
|
3321
|
+
if (this.lexer.state.linkParenPossible === false) return;
|
|
3322
|
+
let t = this.rules.inline.link.exec(e);
|
|
3323
|
+
if (t) {
|
|
3324
|
+
let n = t[0].charAt(0) === "!" ? 2 : 1;
|
|
3325
|
+
if (!this.options.pedantic && $e(e, t[1], n, this.rules)) return;
|
|
3326
|
+
let s = t[2].trim();
|
|
3327
|
+
if (!this.options.pedantic && this.rules.other.startAngleBracket.test(s)) {
|
|
3328
|
+
if (!this.rules.other.endAngleBracket.test(s)) return;
|
|
3329
|
+
let i = z(s.slice(0, -1), "\\");
|
|
3330
|
+
if ((s.length - i.length) % 2 === 0) return;
|
|
3331
|
+
} else {
|
|
3332
|
+
let i = ce(t[2], "()");
|
|
3333
|
+
if (i === -2) return;
|
|
3334
|
+
if (i > -1) {
|
|
3335
|
+
let u = (t[0].indexOf("!") === 0 ? 5 : 4) + t[1].length + i;
|
|
3336
|
+
t[2] = t[2].substring(0, i), t[0] = t[0].substring(0, u).trim(), t[3] = "";
|
|
3337
|
+
}
|
|
3338
|
+
}
|
|
3339
|
+
let r = t[2], o = "";
|
|
3340
|
+
if (this.options.pedantic) {
|
|
3341
|
+
let i = this.rules.other.pedanticHrefTitle.exec(r);
|
|
3342
|
+
i && (r = i[1], o = i[3]);
|
|
3343
|
+
} else o = t[3] ? t[3].slice(1, -1) : "";
|
|
3344
|
+
return r = r.trim(), this.rules.other.startAngleBracket.test(r) && (this.options.pedantic && !this.rules.other.endAngleBracket.test(s) ? r = r.slice(1) : r = r.slice(1, -1)), _e(t, { href: r && r.replace(this.rules.inline.anyPunctuation, "$1"), title: o && o.replace(this.rules.inline.anyPunctuation, "$1") }, t[0], this.lexer, this.rules);
|
|
3345
|
+
}
|
|
3346
|
+
}
|
|
3347
|
+
reflink(e, t) {
|
|
3348
|
+
let n;
|
|
3349
|
+
if ((n = this.rules.inline.reflink.exec(e)) || (n = this.rules.inline.nolink.exec(e))) {
|
|
3350
|
+
let s = n[0].charAt(0) === "!" ? 2 : 1;
|
|
3351
|
+
if (!this.options.pedantic && $e(e, n[1], s, this.rules)) return;
|
|
3352
|
+
let r = (n[2] || n[1]).replace(this.rules.other.multipleSpaceGlobal, " "), o = t[N(r)];
|
|
3353
|
+
if (!o) {
|
|
3354
|
+
let i = n[0].charAt(0);
|
|
3355
|
+
return { type: "text", raw: i, text: i };
|
|
3356
|
+
}
|
|
3357
|
+
return _e(n, o, n[0], this.lexer, this.rules);
|
|
3358
|
+
}
|
|
3359
|
+
}
|
|
3360
|
+
emStrong(e, t, n = "") {
|
|
3361
|
+
let s = this.rules.inline.emStrongLDelim.exec(e);
|
|
3362
|
+
if (!s || !s[1] && !s[2] && !s[3] && !s[4]) return;
|
|
3363
|
+
let r = s[0][0], o = n === r, i = t.length - e.length, l = i;
|
|
3364
|
+
for (; !this.options.pedantic && l > 0 && t[l - 1] === r; ) l--;
|
|
3365
|
+
let u = [...t.slice(Math.max(0, l - 2), l)].at(-1) ?? "", h = u === "*" || u === "_" || !!this.rules.inline.punctuation.exec(u);
|
|
3366
|
+
l < i && (n = u);
|
|
3367
|
+
let p = l < i ? h : !!this.rules.inline.punctuation.exec(n);
|
|
3368
|
+
if (s[4] && n.match(this.rules.other.unicodeAlphaNumeric)) return;
|
|
3369
|
+
let d = s[1] || s[3] || "";
|
|
3370
|
+
if (!d || !n || p) {
|
|
3371
|
+
let g = [...s[0]].length - 1, k, b, x = g, f = 0, S = i - l + g, R = !this.options.pedantic && !!u.trim() && (!!d || r === "*" && !h), C = r === "*" ? this.rules.inline.emStrongRDelimAst : this.rules.inline.emStrongRDelimUnd;
|
|
3372
|
+
for (C.lastIndex = 0, t = t.slice(-1 * e.length + g); (s = C.exec(t)) !== null; ) {
|
|
3373
|
+
if (k = s[1] || s[2] || s[3] || s[4] || s[5] || s[6], !k) continue;
|
|
3374
|
+
if (b = [...k].length, s[3] || s[4]) {
|
|
3375
|
+
x += b;
|
|
3376
|
+
continue;
|
|
3377
|
+
} else if (s[5] || s[6] || R) {
|
|
3378
|
+
if (o && (s[5] || s[6])) break;
|
|
3379
|
+
if (S % 3 && !((S + b) % 3)) {
|
|
3380
|
+
f += b;
|
|
3381
|
+
continue;
|
|
3382
|
+
}
|
|
3383
|
+
}
|
|
3384
|
+
if (x -= b, x > 0) continue;
|
|
3385
|
+
b = Math.min(b, b + x + f);
|
|
3386
|
+
let Q = [...s[0]][0].length, E = e.slice(0, g + s.index + Q + b);
|
|
3387
|
+
if (Math.min(g, b) % 2) {
|
|
3388
|
+
let F = E.slice(1, -1);
|
|
3389
|
+
return { type: "em", raw: E, text: F, tokens: this.lexer.inlineTokens(F) };
|
|
3390
|
+
}
|
|
3391
|
+
let j = E.slice(2, -2);
|
|
3392
|
+
return { type: "strong", raw: E, text: j, tokens: this.lexer.inlineTokens(j) };
|
|
3393
|
+
}
|
|
3394
|
+
}
|
|
3395
|
+
}
|
|
3396
|
+
codespan(e) {
|
|
3397
|
+
let t = this.rules.inline.code.exec(e);
|
|
3398
|
+
if (t) {
|
|
3399
|
+
let n = t[2].replace(this.rules.other.newLineCharGlobal, " "), s = this.rules.other.nonSpaceChar.test(n), r = this.rules.other.startingSpaceChar.test(n) && this.rules.other.endingSpaceChar.test(n);
|
|
3400
|
+
return s && r && (n = n.substring(1, n.length - 1)), { type: "codespan", raw: t[0], text: n };
|
|
3401
|
+
}
|
|
3402
|
+
}
|
|
3403
|
+
br(e) {
|
|
3404
|
+
let t = this.rules.inline.br.exec(e);
|
|
3405
|
+
if (t) return { type: "br", raw: t[0] };
|
|
3406
|
+
}
|
|
3407
|
+
del(e, t, n = "") {
|
|
3408
|
+
let s = this.rules.inline.delLDelim.exec(e);
|
|
3409
|
+
if (!s) return;
|
|
3410
|
+
if (!(s[1] || "") || !n || this.rules.inline.punctuation.exec(n)) {
|
|
3411
|
+
let o = [...s[0]].length - 1, i, l, u = o, h = this.rules.inline.delRDelim;
|
|
3412
|
+
for (h.lastIndex = 0, t = t.slice(-1 * e.length + o); (s = h.exec(t)) !== null; ) {
|
|
3413
|
+
if (i = s[1] || s[2] || s[3] || s[4] || s[5] || s[6], !i || (l = [...i].length, l !== o)) continue;
|
|
3414
|
+
if (s[3] || s[4]) {
|
|
3415
|
+
u += l;
|
|
3416
|
+
continue;
|
|
3417
|
+
}
|
|
3418
|
+
if (u -= l, u > 0) continue;
|
|
3419
|
+
l = Math.min(l, l + u);
|
|
3420
|
+
let p = [...s[0]][0].length, d = e.slice(0, o + s.index + p + l), g = d.slice(o, -o);
|
|
3421
|
+
return { type: "del", raw: d, text: g, tokens: this.lexer.inlineTokens(g) };
|
|
3422
|
+
}
|
|
3423
|
+
}
|
|
3424
|
+
}
|
|
3425
|
+
autolink(e) {
|
|
3426
|
+
let t = this.rules.inline.autolink.exec(e);
|
|
3427
|
+
if (t) {
|
|
3428
|
+
let n, s;
|
|
3429
|
+
return t[2] === "@" ? (n = t[1], s = "mailto:" + n) : (n = t[1], s = n), { type: "link", raw: t[0], text: n, href: s, autolink: true, tokens: [{ type: "text", raw: n, text: n }] };
|
|
3430
|
+
}
|
|
3431
|
+
}
|
|
3432
|
+
url(e) {
|
|
3433
|
+
let t;
|
|
3434
|
+
if (t = this.rules.inline.url.exec(e)) {
|
|
3435
|
+
let n, s;
|
|
3436
|
+
if (t[2] === "@") n = t[0], s = "mailto:" + n;
|
|
3437
|
+
else {
|
|
3438
|
+
let r;
|
|
3439
|
+
do
|
|
3440
|
+
r = t[0], t[0] = this.rules.inline._backpedal.exec(t[0])?.[0] ?? "";
|
|
3441
|
+
while (r !== t[0]);
|
|
3442
|
+
n = t[0], t[1] === "www." ? s = "http://" + t[0] : s = t[0];
|
|
3443
|
+
}
|
|
3444
|
+
return { type: "link", raw: t[0], text: n, href: s, autolink: true, tokens: [{ type: "text", raw: n, text: n }] };
|
|
3445
|
+
}
|
|
3446
|
+
}
|
|
3447
|
+
inlineText(e) {
|
|
3448
|
+
let t = this.rules.inline.text.exec(e);
|
|
3449
|
+
if (t) {
|
|
3450
|
+
let n = this.lexer.state.inRawBlock;
|
|
3451
|
+
return { type: "text", raw: t[0], text: n ? t[0] : Se(t[0]), escaped: n };
|
|
3452
|
+
}
|
|
3453
|
+
}
|
|
3454
|
+
};
|
|
3455
|
+
var O = class a {
|
|
3456
|
+
tokens;
|
|
3457
|
+
options;
|
|
3458
|
+
state;
|
|
3459
|
+
inlineQueue;
|
|
3460
|
+
tokenizer;
|
|
3461
|
+
constructor(e) {
|
|
3462
|
+
this.tokens = [], this.tokens.links = /* @__PURE__ */ Object.create(null), this.options = e || y, this.options.tokenizer = this.options.tokenizer || new _(), this.tokenizer = this.options.tokenizer, this.tokenizer.options = this.options, this.tokenizer.lexer = this, this.inlineQueue = [], this.state = { inLink: false, inRawBlock: false, linkEmitted: false, linkParenPossible: true, top: true };
|
|
3463
|
+
let t = { other: T, block: X.normal, inline: G.normal };
|
|
3464
|
+
this.options.pedantic ? (t.block = X.pedantic, t.inline = G.pedantic) : this.options.gfm && (t.block = X.gfm, this.options.breaks ? t.inline = G.breaks : t.inline = G.gfm), this.tokenizer.rules = t;
|
|
3465
|
+
}
|
|
3466
|
+
static get rules() {
|
|
3467
|
+
return { block: X, inline: G };
|
|
3468
|
+
}
|
|
3469
|
+
static lex(e, t) {
|
|
3470
|
+
return new a(t).lex(e);
|
|
3471
|
+
}
|
|
3472
|
+
static lexInline(e, t) {
|
|
3473
|
+
return new a(t).inlineTokens(e);
|
|
3474
|
+
}
|
|
3475
|
+
lex(e) {
|
|
3476
|
+
e = e.replace(T.carriageReturn, `
|
|
3477
|
+
`), this.blockTokens(e, this.tokens);
|
|
3478
|
+
for (let t = 0; t < this.inlineQueue.length; t++) {
|
|
3479
|
+
let n = this.inlineQueue[t];
|
|
3480
|
+
this.state.inRawBlock = false, this.inlineTokens(n.src, n.tokens);
|
|
3481
|
+
}
|
|
3482
|
+
return this.inlineQueue = [], this.tokens;
|
|
3483
|
+
}
|
|
3484
|
+
blockTokens(e, t = [], n = false) {
|
|
3485
|
+
this.tokenizer.lexer = this, this.options.pedantic && (e = e.replace(T.tabCharGlobal, " ").replace(T.spaceLine, ""));
|
|
3486
|
+
let s = 1 / 0;
|
|
3487
|
+
for (; e; ) {
|
|
3488
|
+
if (e.length < s) s = e.length;
|
|
3489
|
+
else {
|
|
3490
|
+
this.infiniteLoopError(e.charCodeAt(0));
|
|
3491
|
+
break;
|
|
3492
|
+
}
|
|
3493
|
+
let r;
|
|
3494
|
+
if (this.options.extensions?.block?.some((i) => (r = i.call({ lexer: this }, e, t)) ? (e = e.substring(r.raw.length), t.push(r), true) : false)) continue;
|
|
3495
|
+
if (r = this.tokenizer.space(e)) {
|
|
3496
|
+
e = e.substring(r.raw.length);
|
|
3497
|
+
let i = t.at(-1);
|
|
3498
|
+
r.raw.length === 1 && i !== void 0 ? i.raw += `
|
|
3499
|
+
` : t.push(r);
|
|
3500
|
+
continue;
|
|
3501
|
+
}
|
|
3502
|
+
if (r = this.tokenizer.code(e)) {
|
|
3503
|
+
e = e.substring(r.raw.length);
|
|
3504
|
+
let i = t.at(-1);
|
|
3505
|
+
i?.type === "paragraph" || i?.type === "text" ? (i.raw += (i.raw.endsWith(`
|
|
3506
|
+
`) ? "" : `
|
|
3507
|
+
`) + r.raw, i.text += `
|
|
3508
|
+
` + r.text, this.inlineQueue.at(-1).src = i.text) : t.push(r);
|
|
3509
|
+
continue;
|
|
3510
|
+
}
|
|
3511
|
+
if (r = this.tokenizer.fences(e)) {
|
|
3512
|
+
e = e.substring(r.raw.length), t.push(r);
|
|
3513
|
+
continue;
|
|
3514
|
+
}
|
|
3515
|
+
if (r = this.tokenizer.heading(e)) {
|
|
3516
|
+
e = e.substring(r.raw.length), t.push(r);
|
|
3517
|
+
continue;
|
|
3518
|
+
}
|
|
3519
|
+
if (r = this.tokenizer.hr(e)) {
|
|
3520
|
+
e = e.substring(r.raw.length), t.push(r);
|
|
3521
|
+
continue;
|
|
3522
|
+
}
|
|
3523
|
+
if (r = this.tokenizer.blockquote(e)) {
|
|
3524
|
+
e = e.substring(r.raw.length), t.push(r);
|
|
3525
|
+
continue;
|
|
3526
|
+
}
|
|
3527
|
+
if (r = this.tokenizer.list(e)) {
|
|
3528
|
+
e = e.substring(r.raw.length), t.push(r);
|
|
3529
|
+
continue;
|
|
3530
|
+
}
|
|
3531
|
+
if (r = this.tokenizer.html(e)) {
|
|
3532
|
+
e = e.substring(r.raw.length), t.push(r);
|
|
3533
|
+
continue;
|
|
3534
|
+
}
|
|
3535
|
+
if (r = this.tokenizer.def(e)) {
|
|
3536
|
+
e = e.substring(r.raw.length);
|
|
3537
|
+
let i = t.at(-1);
|
|
3538
|
+
i?.type === "paragraph" || i?.type === "text" ? (i.raw += (i.raw.endsWith(`
|
|
3539
|
+
`) ? "" : `
|
|
3540
|
+
`) + r.raw, i.text += `
|
|
3541
|
+
` + r.raw, this.inlineQueue.at(-1).src = i.text) : (this.tokens.links[r.tag] || (this.tokens.links[r.tag] = { href: r.href, title: r.title }), t.push(r));
|
|
3542
|
+
continue;
|
|
3543
|
+
}
|
|
3544
|
+
if (r = this.tokenizer.table(e)) {
|
|
3545
|
+
e = e.substring(r.raw.length), t.push(r);
|
|
3546
|
+
continue;
|
|
3547
|
+
}
|
|
3548
|
+
if (r = this.tokenizer.lheading(e)) {
|
|
3549
|
+
e = e.substring(r.raw.length), t.push(r);
|
|
3550
|
+
continue;
|
|
3551
|
+
}
|
|
3552
|
+
let o = e;
|
|
3553
|
+
if (this.options.extensions?.startBlock) {
|
|
3554
|
+
let i = 1 / 0, l = e.slice(1), u;
|
|
3555
|
+
this.options.extensions.startBlock.forEach((h) => {
|
|
3556
|
+
u = h.call({ lexer: this }, l), typeof u == "number" && u >= 0 && (i = Math.min(i, u));
|
|
3557
|
+
}), i < 1 / 0 && i >= 0 && (o = e.substring(0, i + 1));
|
|
3558
|
+
}
|
|
3559
|
+
if (this.state.top && (r = this.tokenizer.paragraph(o))) {
|
|
3560
|
+
let i = t.at(-1);
|
|
3561
|
+
n && i?.type === "paragraph" ? (i.raw += (i.raw.endsWith(`
|
|
3562
|
+
`) ? "" : `
|
|
3563
|
+
`) + r.raw, i.text += `
|
|
3564
|
+
` + r.text, this.inlineQueue.pop(), this.inlineQueue.at(-1).src = i.text) : t.push(r), n = o.length !== e.length, e = e.substring(r.raw.length);
|
|
3565
|
+
continue;
|
|
3566
|
+
}
|
|
3567
|
+
if (r = this.tokenizer.text(e)) {
|
|
3568
|
+
e = e.substring(r.raw.length);
|
|
3569
|
+
let i = t.at(-1);
|
|
3570
|
+
i?.type === "text" ? (i.raw += (i.raw.endsWith(`
|
|
3571
|
+
`) ? "" : `
|
|
3572
|
+
`) + r.raw, i.text += `
|
|
3573
|
+
` + r.text, this.inlineQueue.pop(), this.inlineQueue.at(-1).src = i.text) : t.push(r);
|
|
3574
|
+
continue;
|
|
3575
|
+
}
|
|
3576
|
+
if (e) {
|
|
3577
|
+
this.infiniteLoopError(e.charCodeAt(0));
|
|
3578
|
+
break;
|
|
3579
|
+
}
|
|
3580
|
+
}
|
|
3581
|
+
return this.state.top = true, t;
|
|
3582
|
+
}
|
|
3583
|
+
inline(e, t = []) {
|
|
3584
|
+
return this.inlineQueue.push({ src: e, tokens: t }), t;
|
|
3585
|
+
}
|
|
3586
|
+
linkInText(e) {
|
|
3587
|
+
if (!e.includes("[")) return false;
|
|
3588
|
+
let t = this.tokenizer.rules.inline.link;
|
|
3589
|
+
for (let n of e.matchAll(this.tokenizer.rules.inline.blockSkip)) if (t.test(n[0]) && e.charAt(n.index - 1) !== "!") return true;
|
|
3590
|
+
for (let n of e.matchAll(this.tokenizer.rules.inline.reflinkSearch)) {
|
|
3591
|
+
let s = n[0], r = s.lastIndexOf("[");
|
|
3592
|
+
if (!(s.charAt(0) === "!" || !Object.hasOwn(this.tokens.links, N(s.slice(r + 1, -1)))) && !(r > 1 && this.linkInText(s.slice(1, r - 1)))) return true;
|
|
3593
|
+
}
|
|
3594
|
+
return false;
|
|
3595
|
+
}
|
|
3596
|
+
inlineTokens(e, t = []) {
|
|
3597
|
+
this.tokenizer.lexer = this;
|
|
3598
|
+
let n = this.state.linkParenPossible;
|
|
3599
|
+
this.state.linkParenPossible = n && e.includes(")");
|
|
3600
|
+
try {
|
|
3601
|
+
return this.#e(e, t);
|
|
3602
|
+
} finally {
|
|
3603
|
+
this.state.linkParenPossible = n;
|
|
3604
|
+
}
|
|
3605
|
+
}
|
|
3606
|
+
#e(e, t) {
|
|
3607
|
+
let n = e.includes("*") || e.includes("_") || e.includes("~") || this.options.hooks?.emStrongMask || this.tokenizer.emStrong !== _.prototype.emStrong || this.tokenizer.del !== _.prototype.del ? this.#t(e) : e, s = false, r = "", o = 1 / 0;
|
|
3608
|
+
for (; e; ) {
|
|
3609
|
+
if (e.length < o) o = e.length;
|
|
3610
|
+
else {
|
|
3611
|
+
this.infiniteLoopError(e.charCodeAt(0));
|
|
3612
|
+
break;
|
|
3613
|
+
}
|
|
3614
|
+
s || (r = ""), s = false;
|
|
3615
|
+
let i;
|
|
3616
|
+
if (this.options.extensions?.inline?.some((u) => (i = u.call({ lexer: this }, e, t)) ? (e = e.substring(i.raw.length), t.push(i), true) : false)) continue;
|
|
3617
|
+
if (i = this.tokenizer.escape(e)) {
|
|
3618
|
+
e = e.substring(i.raw.length), t.push(i);
|
|
3619
|
+
continue;
|
|
3620
|
+
}
|
|
3621
|
+
if (i = this.tokenizer.tag(e)) {
|
|
3622
|
+
e = e.substring(i.raw.length), t.push(i);
|
|
3623
|
+
continue;
|
|
3624
|
+
}
|
|
3625
|
+
if (i = this.tokenizer.link(e)) {
|
|
3626
|
+
e = e.substring(i.raw.length), t.push(i);
|
|
3627
|
+
continue;
|
|
3628
|
+
}
|
|
3629
|
+
if (i = this.tokenizer.reflink(e, this.tokens.links)) {
|
|
3630
|
+
e = e.substring(i.raw.length);
|
|
3631
|
+
let u = t.at(-1);
|
|
3632
|
+
i.type === "text" && u?.type === "text" ? (u.raw += i.raw, u.text += i.text) : t.push(i);
|
|
3633
|
+
continue;
|
|
3634
|
+
}
|
|
3635
|
+
if (i = this.tokenizer.emStrong(e, n, r)) {
|
|
3636
|
+
e = e.substring(i.raw.length), t.push(i);
|
|
3637
|
+
continue;
|
|
3638
|
+
}
|
|
3639
|
+
if (i = this.tokenizer.codespan(e)) {
|
|
3640
|
+
e = e.substring(i.raw.length), t.push(i);
|
|
3641
|
+
continue;
|
|
3642
|
+
}
|
|
3643
|
+
if (i = this.tokenizer.br(e)) {
|
|
3644
|
+
e = e.substring(i.raw.length), t.push(i);
|
|
3645
|
+
continue;
|
|
3646
|
+
}
|
|
3647
|
+
if (i = this.tokenizer.del(e, n, r)) {
|
|
3648
|
+
e = e.substring(i.raw.length), t.push(i);
|
|
3649
|
+
continue;
|
|
3650
|
+
}
|
|
3651
|
+
if (i = this.tokenizer.autolink(e)) {
|
|
3652
|
+
e = e.substring(i.raw.length), t.push(i);
|
|
3653
|
+
continue;
|
|
3654
|
+
}
|
|
3655
|
+
if (!this.state.inLink && (i = this.tokenizer.url(e))) {
|
|
3656
|
+
e = e.substring(i.raw.length), t.push(i);
|
|
3657
|
+
continue;
|
|
3658
|
+
}
|
|
3659
|
+
let l = e;
|
|
3660
|
+
if (this.options.extensions?.startInline) {
|
|
3661
|
+
let u = 1 / 0, h = e.slice(1), p;
|
|
3662
|
+
this.options.extensions.startInline.forEach((d) => {
|
|
3663
|
+
p = d.call({ lexer: this }, h), typeof p == "number" && p >= 0 && (u = Math.min(u, p));
|
|
3664
|
+
}), u < 1 / 0 && u >= 0 && (l = e.substring(0, u + 1));
|
|
3665
|
+
}
|
|
3666
|
+
if (i = this.tokenizer.inlineText(l)) {
|
|
3667
|
+
e = e.substring(i.raw.length), i.raw.slice(-1) !== "_" && (r = i.raw.slice(-1)), s = true;
|
|
3668
|
+
let u = t.at(-1);
|
|
3669
|
+
u?.type === "text" ? (u.raw += i.raw, u.text += i.text) : t.push(i);
|
|
3670
|
+
continue;
|
|
3671
|
+
}
|
|
3672
|
+
if (e) {
|
|
3673
|
+
this.infiniteLoopError(e.charCodeAt(0));
|
|
3674
|
+
break;
|
|
3675
|
+
}
|
|
3676
|
+
}
|
|
3677
|
+
return t;
|
|
3678
|
+
}
|
|
3679
|
+
#t(e) {
|
|
3680
|
+
let t = e;
|
|
3681
|
+
if (this.tokens.links && e.includes("[")) {
|
|
3682
|
+
let n = this.tokenizer.rules.inline.reflinkSearch, s = (r) => {
|
|
3683
|
+
let o = r.lastIndexOf("[");
|
|
3684
|
+
if (!Object.hasOwn(this.tokens.links, N(r.slice(o + 1, -1)))) return r;
|
|
3685
|
+
if (o > 1 && r.charAt(0) !== "!") {
|
|
3686
|
+
let i = r.slice(1, o - 1);
|
|
3687
|
+
if (this.linkInText(i)) return "[" + i.replace(n, s) + "][" + "a".repeat(r.length - o - 2) + "]";
|
|
3688
|
+
}
|
|
3689
|
+
return "[" + "a".repeat(r.length - 2) + "]";
|
|
3690
|
+
};
|
|
3691
|
+
t = t.replace(n, s);
|
|
3692
|
+
}
|
|
3693
|
+
return t = t.replace(this.tokenizer.rules.inline.anyPunctuationOutsideCode, (n, s, r) => r ? "+".repeat(n.length) : s ? s + n.slice(s.length, -s.length).replace(/`/g, "+") + s : n), t = t.replace(this.tokenizer.rules.inline.blockSkip, (n, s, r) => {
|
|
3694
|
+
let o = r ? r.length : 0;
|
|
3695
|
+
return n.slice(0, o) + "[" + "a".repeat(n.length - o - 2) + "]";
|
|
3696
|
+
}), t = this.options.hooks?.emStrongMask?.call({ lexer: this }, t) ?? t, t;
|
|
3697
|
+
}
|
|
3698
|
+
infiniteLoopError(e) {
|
|
3699
|
+
let t = "Infinite loop on byte: " + e;
|
|
3700
|
+
if (this.options.silent) console.error(t);
|
|
3701
|
+
else throw new Error(t);
|
|
3702
|
+
}
|
|
3703
|
+
};
|
|
3704
|
+
var L = class {
|
|
3705
|
+
options;
|
|
3706
|
+
parser;
|
|
3707
|
+
constructor(e) {
|
|
3708
|
+
this.options = e || y;
|
|
3709
|
+
}
|
|
3710
|
+
space(e) {
|
|
3711
|
+
return "";
|
|
3712
|
+
}
|
|
3713
|
+
code({ text: e, lang: t, escaped: n }) {
|
|
3714
|
+
let s = (t || "").match(T.notSpaceStart)?.[0], r = e ? e.replace(T.endingNewline, "") + `
|
|
3715
|
+
` : "";
|
|
3716
|
+
return s ? '<pre><code class="language-' + P(s) + '">' + (n ? r : P(r, true)) + `</code></pre>
|
|
3717
|
+
` : "<pre><code>" + (n ? r : P(r, true)) + `</code></pre>
|
|
3718
|
+
`;
|
|
3719
|
+
}
|
|
3720
|
+
blockquote({ tokens: e }) {
|
|
3721
|
+
return `<blockquote>
|
|
3722
|
+
${this.parser.parse(e)}</blockquote>
|
|
3723
|
+
`;
|
|
3724
|
+
}
|
|
3725
|
+
html({ text: e }) {
|
|
3726
|
+
return e;
|
|
3727
|
+
}
|
|
3728
|
+
def(e) {
|
|
3729
|
+
return "";
|
|
3730
|
+
}
|
|
3731
|
+
heading({ tokens: e, depth: t }) {
|
|
3732
|
+
return `<h${t}>${this.parser.parseInline(e)}</h${t}>
|
|
3733
|
+
`;
|
|
3734
|
+
}
|
|
3735
|
+
hr(e) {
|
|
3736
|
+
return `<hr>
|
|
3737
|
+
`;
|
|
3738
|
+
}
|
|
3739
|
+
list(e) {
|
|
3740
|
+
let t = e.ordered, n = e.start, s = "";
|
|
3741
|
+
for (let i = 0; i < e.items.length; i++) {
|
|
3742
|
+
let l = e.items[i];
|
|
3743
|
+
s += this.listitem(l);
|
|
3744
|
+
}
|
|
3745
|
+
let r = t ? "ol" : "ul", o = t && n !== 1 ? ' start="' + n + '"' : "";
|
|
3746
|
+
return "<" + r + o + `>
|
|
3747
|
+
` + s + "</" + r + `>
|
|
3748
|
+
`;
|
|
3749
|
+
}
|
|
3750
|
+
listitem(e) {
|
|
3751
|
+
return `<li>${this.parser.parse(e.tokens)}</li>
|
|
3752
|
+
`;
|
|
3753
|
+
}
|
|
3754
|
+
checkbox({ checked: e }) {
|
|
3755
|
+
return "<input " + (e ? 'checked="" ' : "") + 'disabled="" type="checkbox"> ';
|
|
3756
|
+
}
|
|
3757
|
+
paragraph({ tokens: e }) {
|
|
3758
|
+
return `<p>${this.parser.parseInline(e)}</p>
|
|
3759
|
+
`;
|
|
3760
|
+
}
|
|
3761
|
+
table(e) {
|
|
3762
|
+
let t = "", n = "";
|
|
3763
|
+
for (let r = 0; r < e.header.length; r++) n += this.tablecell(e.header[r]);
|
|
3764
|
+
t += this.tablerow({ text: n });
|
|
3765
|
+
let s = "";
|
|
3766
|
+
for (let r = 0; r < e.rows.length; r++) {
|
|
3767
|
+
let o = e.rows[r];
|
|
3768
|
+
n = "";
|
|
3769
|
+
for (let i = 0; i < o.length; i++) n += this.tablecell(o[i]);
|
|
3770
|
+
s += this.tablerow({ text: n });
|
|
3771
|
+
}
|
|
3772
|
+
return s && (s = `<tbody>${s}</tbody>`), `<table>
|
|
3773
|
+
<thead>
|
|
3774
|
+
` + t + `</thead>
|
|
3775
|
+
` + s + `</table>
|
|
3776
|
+
`;
|
|
3777
|
+
}
|
|
3778
|
+
tablerow({ text: e }) {
|
|
3779
|
+
return `<tr>
|
|
3780
|
+
${e}</tr>
|
|
3781
|
+
`;
|
|
3782
|
+
}
|
|
3783
|
+
tablecell(e) {
|
|
3784
|
+
let t = this.parser.parseInline(e.tokens), n = e.header ? "th" : "td";
|
|
3785
|
+
return (e.align ? `<${n} align="${e.align}">` : `<${n}>`) + t + `</${n}>
|
|
3786
|
+
`;
|
|
3787
|
+
}
|
|
3788
|
+
strong({ tokens: e }) {
|
|
3789
|
+
return `<strong>${this.parser.parseInline(e)}</strong>`;
|
|
3790
|
+
}
|
|
3791
|
+
em({ tokens: e }) {
|
|
3792
|
+
return `<em>${this.parser.parseInline(e)}</em>`;
|
|
3793
|
+
}
|
|
3794
|
+
codespan({ text: e }) {
|
|
3795
|
+
return `<code>${P(e, true)}</code>`;
|
|
3796
|
+
}
|
|
3797
|
+
br(e) {
|
|
3798
|
+
return "<br>";
|
|
3799
|
+
}
|
|
3800
|
+
del({ tokens: e }) {
|
|
3801
|
+
return `<del>${this.parser.parseInline(e)}</del>`;
|
|
3802
|
+
}
|
|
3803
|
+
link({ href: e, title: t, text: n, tokens: s, autolink: r }) {
|
|
3804
|
+
let o = r ? P(n, true) : this.parser.parseInline(s), i = le(e);
|
|
3805
|
+
if (i === null) return o;
|
|
3806
|
+
e = P(i, r);
|
|
3807
|
+
let l = '<a href="' + e + '"';
|
|
3808
|
+
return t && (l += ' title="' + P(t) + '"'), l += ">" + o + "</a>", l;
|
|
3809
|
+
}
|
|
3810
|
+
image({ href: e, title: t, text: n, tokens: s }) {
|
|
3811
|
+
s && (n = this.parser.parseInline(s, this.parser.textRenderer));
|
|
3812
|
+
let r = le(e);
|
|
3813
|
+
if (r === null) return P(n);
|
|
3814
|
+
e = r;
|
|
3815
|
+
let o = `<img src="${P(e)}" alt="${P(n)}"`;
|
|
3816
|
+
return t && (o += ` title="${P(t)}"`), o += ">", o;
|
|
3817
|
+
}
|
|
3818
|
+
text(e) {
|
|
3819
|
+
return "tokens" in e && e.tokens ? this.parser.parseInline(e.tokens) : "escaped" in e && e.escaped ? e.text : P(e.text);
|
|
3820
|
+
}
|
|
3821
|
+
};
|
|
3822
|
+
var M = class {
|
|
3823
|
+
parser;
|
|
3824
|
+
strong({ text: e, tokens: t }) {
|
|
3825
|
+
return t ? this.parser.parseInline(t, this) : e;
|
|
3826
|
+
}
|
|
3827
|
+
em({ text: e, tokens: t }) {
|
|
3828
|
+
return t ? this.parser.parseInline(t, this) : e;
|
|
3829
|
+
}
|
|
3830
|
+
codespan({ text: e }) {
|
|
3831
|
+
return e;
|
|
3832
|
+
}
|
|
3833
|
+
del({ text: e, tokens: t }) {
|
|
3834
|
+
return t ? this.parser.parseInline(t, this) : e;
|
|
3835
|
+
}
|
|
3836
|
+
html({ text: e }) {
|
|
3837
|
+
return e;
|
|
3838
|
+
}
|
|
3839
|
+
text({ text: e }) {
|
|
3840
|
+
return e;
|
|
3841
|
+
}
|
|
3842
|
+
link({ text: e, tokens: t }) {
|
|
3843
|
+
return t ? this.parser.parseInline(t, this) : e;
|
|
3844
|
+
}
|
|
3845
|
+
image({ text: e, tokens: t }) {
|
|
3846
|
+
return t ? this.parser.parseInline(t, this) : e;
|
|
3847
|
+
}
|
|
3848
|
+
br() {
|
|
3849
|
+
return "";
|
|
3850
|
+
}
|
|
3851
|
+
checkbox({ raw: e }) {
|
|
3852
|
+
return e;
|
|
3853
|
+
}
|
|
3854
|
+
};
|
|
3855
|
+
var w = class a2 {
|
|
3856
|
+
options;
|
|
3857
|
+
renderer;
|
|
3858
|
+
textRenderer;
|
|
3859
|
+
constructor(e) {
|
|
3860
|
+
this.options = e || y, this.options.renderer = this.options.renderer || new L(), this.renderer = this.options.renderer, this.renderer.options = this.options, this.renderer.parser = this, this.textRenderer = new M(), this.textRenderer.parser = this;
|
|
3861
|
+
}
|
|
3862
|
+
static parse(e, t) {
|
|
3863
|
+
return new a2(t).parse(e);
|
|
3864
|
+
}
|
|
3865
|
+
static parseInline(e, t) {
|
|
3866
|
+
return new a2(t).parseInline(e);
|
|
3867
|
+
}
|
|
3868
|
+
parse(e) {
|
|
3869
|
+
this.renderer.parser = this;
|
|
3870
|
+
let t = "";
|
|
3871
|
+
for (let n = 0; n < e.length; n++) {
|
|
3872
|
+
let s = e[n];
|
|
3873
|
+
if (this.options.extensions?.renderers?.[s.type]) {
|
|
3874
|
+
let o = s, i = this.options.extensions.renderers[o.type].call({ parser: this }, o);
|
|
3875
|
+
if (i !== false || !["space", "hr", "heading", "code", "table", "blockquote", "list", "checkbox", "html", "def", "paragraph", "text"].includes(o.type)) {
|
|
3876
|
+
t += i || "";
|
|
3877
|
+
continue;
|
|
3878
|
+
}
|
|
3879
|
+
}
|
|
3880
|
+
let r = s;
|
|
3881
|
+
switch (r.type) {
|
|
3882
|
+
case "space": {
|
|
3883
|
+
t += this.renderer.space(r);
|
|
3884
|
+
break;
|
|
3885
|
+
}
|
|
3886
|
+
case "hr": {
|
|
3887
|
+
t += this.renderer.hr(r);
|
|
3888
|
+
break;
|
|
3889
|
+
}
|
|
3890
|
+
case "heading": {
|
|
3891
|
+
t += this.renderer.heading(r);
|
|
3892
|
+
break;
|
|
3893
|
+
}
|
|
3894
|
+
case "code": {
|
|
3895
|
+
t += this.renderer.code(r);
|
|
3896
|
+
break;
|
|
3897
|
+
}
|
|
3898
|
+
case "table": {
|
|
3899
|
+
t += this.renderer.table(r);
|
|
3900
|
+
break;
|
|
3901
|
+
}
|
|
3902
|
+
case "blockquote": {
|
|
3903
|
+
t += this.renderer.blockquote(r);
|
|
3904
|
+
break;
|
|
3905
|
+
}
|
|
3906
|
+
case "list": {
|
|
3907
|
+
t += this.renderer.list(r);
|
|
3908
|
+
break;
|
|
3909
|
+
}
|
|
3910
|
+
case "checkbox": {
|
|
3911
|
+
t += this.renderer.checkbox(r);
|
|
3912
|
+
break;
|
|
3913
|
+
}
|
|
3914
|
+
case "html": {
|
|
3915
|
+
t += this.renderer.html(r);
|
|
3916
|
+
break;
|
|
3917
|
+
}
|
|
3918
|
+
case "def": {
|
|
3919
|
+
t += this.renderer.def(r);
|
|
3920
|
+
break;
|
|
3921
|
+
}
|
|
3922
|
+
case "paragraph": {
|
|
3923
|
+
t += this.renderer.paragraph(r);
|
|
3924
|
+
break;
|
|
3925
|
+
}
|
|
3926
|
+
case "text": {
|
|
3927
|
+
t += this.renderer.text(r);
|
|
3928
|
+
break;
|
|
3929
|
+
}
|
|
3930
|
+
default: {
|
|
3931
|
+
let o = 'Token with "' + r.type + '" type was not found.';
|
|
3932
|
+
if (this.options.silent) return console.error(o), "";
|
|
3933
|
+
throw new Error(o);
|
|
3934
|
+
}
|
|
3935
|
+
}
|
|
3936
|
+
}
|
|
3937
|
+
return t;
|
|
3938
|
+
}
|
|
3939
|
+
parseInline(e, t = this.renderer) {
|
|
3940
|
+
this.renderer.parser = this;
|
|
3941
|
+
let n = "";
|
|
3942
|
+
for (let s = 0; s < e.length; s++) {
|
|
3943
|
+
let r = e[s];
|
|
3944
|
+
if (this.options.extensions?.renderers?.[r.type]) {
|
|
3945
|
+
let i = this.options.extensions.renderers[r.type].call({ parser: this }, r);
|
|
3946
|
+
if (i !== false || !["escape", "html", "link", "image", "checkbox", "strong", "em", "codespan", "br", "del", "text"].includes(r.type)) {
|
|
3947
|
+
n += i || "";
|
|
3948
|
+
continue;
|
|
3949
|
+
}
|
|
3950
|
+
}
|
|
3951
|
+
let o = r;
|
|
3952
|
+
switch (o.type) {
|
|
3953
|
+
case "escape": {
|
|
3954
|
+
n += t.text(o);
|
|
3955
|
+
break;
|
|
3956
|
+
}
|
|
3957
|
+
case "html": {
|
|
3958
|
+
n += t.html(o);
|
|
3959
|
+
break;
|
|
3960
|
+
}
|
|
3961
|
+
case "link": {
|
|
3962
|
+
n += t.link(o);
|
|
3963
|
+
break;
|
|
3964
|
+
}
|
|
3965
|
+
case "image": {
|
|
3966
|
+
n += t.image(o);
|
|
3967
|
+
break;
|
|
3968
|
+
}
|
|
3969
|
+
case "checkbox": {
|
|
3970
|
+
n += t.checkbox(o);
|
|
3971
|
+
break;
|
|
3972
|
+
}
|
|
3973
|
+
case "strong": {
|
|
3974
|
+
n += t.strong(o);
|
|
3975
|
+
break;
|
|
3976
|
+
}
|
|
3977
|
+
case "em": {
|
|
3978
|
+
n += t.em(o);
|
|
3979
|
+
break;
|
|
3980
|
+
}
|
|
3981
|
+
case "codespan": {
|
|
3982
|
+
n += t.codespan(o);
|
|
3983
|
+
break;
|
|
3984
|
+
}
|
|
3985
|
+
case "br": {
|
|
3986
|
+
n += t.br(o);
|
|
3987
|
+
break;
|
|
3988
|
+
}
|
|
3989
|
+
case "del": {
|
|
3990
|
+
n += t.del(o);
|
|
3991
|
+
break;
|
|
3992
|
+
}
|
|
3993
|
+
case "text": {
|
|
3994
|
+
n += t.text(o);
|
|
3995
|
+
break;
|
|
3996
|
+
}
|
|
3997
|
+
default: {
|
|
3998
|
+
let i = 'Token with "' + o.type + '" type was not found.';
|
|
3999
|
+
if (this.options.silent) return console.error(i), "";
|
|
4000
|
+
throw new Error(i);
|
|
4001
|
+
}
|
|
4002
|
+
}
|
|
4003
|
+
}
|
|
4004
|
+
return n;
|
|
4005
|
+
}
|
|
4006
|
+
};
|
|
4007
|
+
var A = class {
|
|
4008
|
+
options;
|
|
4009
|
+
block;
|
|
4010
|
+
constructor(e) {
|
|
4011
|
+
this.options = e || y;
|
|
4012
|
+
}
|
|
4013
|
+
static passThroughHooks = /* @__PURE__ */ new Set(["preprocess", "postprocess", "processAllTokens", "emStrongMask"]);
|
|
4014
|
+
static passThroughHooksRespectAsync = /* @__PURE__ */ new Set(["preprocess", "postprocess", "processAllTokens"]);
|
|
4015
|
+
preprocess(e) {
|
|
4016
|
+
return e;
|
|
4017
|
+
}
|
|
4018
|
+
postprocess(e) {
|
|
4019
|
+
return e;
|
|
4020
|
+
}
|
|
4021
|
+
processAllTokens(e) {
|
|
4022
|
+
return e;
|
|
4023
|
+
}
|
|
4024
|
+
emStrongMask(e) {
|
|
4025
|
+
return e;
|
|
4026
|
+
}
|
|
4027
|
+
provideLexer(e = this.block) {
|
|
4028
|
+
return e ? O.lex : O.lexInline;
|
|
4029
|
+
}
|
|
4030
|
+
provideParser(e = this.block) {
|
|
4031
|
+
return e ? w.parse : w.parseInline;
|
|
4032
|
+
}
|
|
4033
|
+
};
|
|
4034
|
+
function D(a3, e) {
|
|
4035
|
+
if (Array.isArray(e)) for (let t = 0; t < e.length; t++) a3.push(e[t]);
|
|
4036
|
+
else a3.push(e);
|
|
750
4037
|
}
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
type: "button",
|
|
787
|
-
className: "ghz-hint",
|
|
788
|
-
style: { border: 0, background: "transparent", cursor: "pointer", font: "inherit" },
|
|
789
|
-
onClick: onCancel,
|
|
790
|
-
children: t("drop.cancel")
|
|
791
|
-
}
|
|
792
|
-
)
|
|
793
|
-
]
|
|
4038
|
+
var J = class {
|
|
4039
|
+
defaults = v();
|
|
4040
|
+
options = this.setOptions;
|
|
4041
|
+
parse = this.parseMarkdown(true);
|
|
4042
|
+
parseInline = this.parseMarkdown(false);
|
|
4043
|
+
Parser = w;
|
|
4044
|
+
Renderer = L;
|
|
4045
|
+
TextRenderer = M;
|
|
4046
|
+
Lexer = O;
|
|
4047
|
+
Tokenizer = _;
|
|
4048
|
+
Hooks = A;
|
|
4049
|
+
constructor(...e) {
|
|
4050
|
+
this.use(...e);
|
|
4051
|
+
}
|
|
4052
|
+
walkTokens(e, t) {
|
|
4053
|
+
let n = [];
|
|
4054
|
+
for (let s of e) switch (D(n, t.call(this, s)), s.type) {
|
|
4055
|
+
case "table": {
|
|
4056
|
+
let r = s;
|
|
4057
|
+
for (let o of r.header) D(n, this.walkTokens(o.tokens, t));
|
|
4058
|
+
for (let o of r.rows) for (let i of o) D(n, this.walkTokens(i.tokens, t));
|
|
4059
|
+
break;
|
|
4060
|
+
}
|
|
4061
|
+
case "list": {
|
|
4062
|
+
let r = s;
|
|
4063
|
+
D(n, this.walkTokens(r.items, t));
|
|
4064
|
+
break;
|
|
4065
|
+
}
|
|
4066
|
+
default: {
|
|
4067
|
+
let r = s;
|
|
4068
|
+
this.defaults.extensions?.childTokens?.[r.type] ? this.defaults.extensions.childTokens[r.type].forEach((o) => {
|
|
4069
|
+
let i = r[o].flat(1 / 0);
|
|
4070
|
+
D(n, this.walkTokens(i, t));
|
|
4071
|
+
}) : r.tokens && D(n, this.walkTokens(r.tokens, t));
|
|
4072
|
+
}
|
|
794
4073
|
}
|
|
795
|
-
|
|
4074
|
+
return n;
|
|
4075
|
+
}
|
|
4076
|
+
use(...e) {
|
|
4077
|
+
let t = this.defaults.extensions || { renderers: {}, childTokens: {} };
|
|
4078
|
+
return e.forEach((n) => {
|
|
4079
|
+
let s = { ...n };
|
|
4080
|
+
if (s.async = this.defaults.async || s.async || false, n.extensions && (n.extensions.forEach((r) => {
|
|
4081
|
+
if (!r.name) throw new Error("extension name required");
|
|
4082
|
+
if ("renderer" in r) {
|
|
4083
|
+
let o = t.renderers[r.name];
|
|
4084
|
+
o ? t.renderers[r.name] = function(...i) {
|
|
4085
|
+
let l = r.renderer.apply(this, i);
|
|
4086
|
+
return l === false && (l = o.apply(this, i)), l;
|
|
4087
|
+
} : t.renderers[r.name] = r.renderer;
|
|
4088
|
+
}
|
|
4089
|
+
if ("tokenizer" in r) {
|
|
4090
|
+
if (!r.level || r.level !== "block" && r.level !== "inline") throw new Error("extension level must be 'block' or 'inline'");
|
|
4091
|
+
let o = t[r.level];
|
|
4092
|
+
o ? o.unshift(r.tokenizer) : t[r.level] = [r.tokenizer], r.start && (r.level === "block" ? t.startBlock ? t.startBlock.push(r.start) : t.startBlock = [r.start] : r.level === "inline" && (t.startInline ? t.startInline.push(r.start) : t.startInline = [r.start]));
|
|
4093
|
+
}
|
|
4094
|
+
"childTokens" in r && r.childTokens && (t.childTokens[r.name] = r.childTokens);
|
|
4095
|
+
}), s.extensions = t), n.renderer) {
|
|
4096
|
+
let r = this.defaults.renderer || new L(this.defaults);
|
|
4097
|
+
for (let o in n.renderer) {
|
|
4098
|
+
if (!(o in r)) throw new Error(`renderer '${o}' does not exist`);
|
|
4099
|
+
if (["options", "parser"].includes(o)) continue;
|
|
4100
|
+
let i = o, l = n.renderer[i], u = r[i];
|
|
4101
|
+
r[i] = (...h) => {
|
|
4102
|
+
let p = l.apply(r, h);
|
|
4103
|
+
return p === false && (p = u.apply(r, h)), p || "";
|
|
4104
|
+
};
|
|
4105
|
+
}
|
|
4106
|
+
s.renderer = r;
|
|
4107
|
+
}
|
|
4108
|
+
if (n.tokenizer) {
|
|
4109
|
+
let r = this.defaults.tokenizer || new _(this.defaults);
|
|
4110
|
+
for (let o in n.tokenizer) {
|
|
4111
|
+
if (!(o in r)) throw new Error(`tokenizer '${o}' does not exist`);
|
|
4112
|
+
if (["options", "rules", "lexer"].includes(o)) continue;
|
|
4113
|
+
let i = o, l = n.tokenizer[i], u = r[i];
|
|
4114
|
+
r[i] = (...h) => {
|
|
4115
|
+
let p = l.apply(r, h);
|
|
4116
|
+
return p === false && (p = u.apply(r, h)), p;
|
|
4117
|
+
};
|
|
4118
|
+
}
|
|
4119
|
+
s.tokenizer = r;
|
|
4120
|
+
}
|
|
4121
|
+
if (n.hooks) {
|
|
4122
|
+
let r = this.defaults.hooks || new A();
|
|
4123
|
+
for (let o in n.hooks) {
|
|
4124
|
+
if (!(o in r)) throw new Error(`hook '${o}' does not exist`);
|
|
4125
|
+
if (["options", "block"].includes(o)) continue;
|
|
4126
|
+
let i = o, l = n.hooks[i], u = r[i];
|
|
4127
|
+
A.passThroughHooks.has(o) ? r[i] = (h) => {
|
|
4128
|
+
if (r.options.async && A.passThroughHooksRespectAsync.has(o)) return (async () => {
|
|
4129
|
+
let d = await l.call(r, h);
|
|
4130
|
+
return u.call(r, d);
|
|
4131
|
+
})();
|
|
4132
|
+
let p = l.call(r, h);
|
|
4133
|
+
return u.call(r, p);
|
|
4134
|
+
} : r[i] = (...h) => {
|
|
4135
|
+
if (r.options.async) return (async () => {
|
|
4136
|
+
let d = await l.apply(r, h);
|
|
4137
|
+
return d === false && (d = await u.apply(r, h)), d;
|
|
4138
|
+
})();
|
|
4139
|
+
let p = l.apply(r, h);
|
|
4140
|
+
return p === false && (p = u.apply(r, h)), p;
|
|
4141
|
+
};
|
|
4142
|
+
}
|
|
4143
|
+
s.hooks = r;
|
|
4144
|
+
}
|
|
4145
|
+
if (n.walkTokens) {
|
|
4146
|
+
let r = this.defaults.walkTokens, o = n.walkTokens;
|
|
4147
|
+
s.walkTokens = function(i) {
|
|
4148
|
+
let l = [];
|
|
4149
|
+
return l.push(o.call(this, i)), r && D(l, r.call(this, i)), l;
|
|
4150
|
+
};
|
|
4151
|
+
}
|
|
4152
|
+
this.defaults = { ...this.defaults, ...s };
|
|
4153
|
+
}), this;
|
|
4154
|
+
}
|
|
4155
|
+
setOptions(e) {
|
|
4156
|
+
return this.defaults = { ...this.defaults, ...e }, this;
|
|
4157
|
+
}
|
|
4158
|
+
lexer(e, t) {
|
|
4159
|
+
return O.lex(e, t ?? this.defaults);
|
|
4160
|
+
}
|
|
4161
|
+
parser(e, t) {
|
|
4162
|
+
return w.parse(e, t ?? this.defaults);
|
|
4163
|
+
}
|
|
4164
|
+
parseMarkdown(e) {
|
|
4165
|
+
return (n, s) => {
|
|
4166
|
+
let r = { ...s }, o = { ...this.defaults, ...r }, i = this.onError(!!o.silent, !!o.async);
|
|
4167
|
+
if (this.defaults.async === true && r.async === false) return i(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));
|
|
4168
|
+
if (typeof n > "u" || n === null) return i(new Error("marked(): input parameter is undefined or null"));
|
|
4169
|
+
if (typeof n != "string") return i(new Error("marked(): input parameter is of type " + Object.prototype.toString.call(n) + ", string expected"));
|
|
4170
|
+
if (o.hooks && (o.hooks.options = o, o.hooks.block = e), o.async) return (async () => {
|
|
4171
|
+
let l = o.hooks ? await o.hooks.preprocess(n) : n, h = await (o.hooks ? await o.hooks.provideLexer(e) : e ? O.lex : O.lexInline)(l, o), p = o.hooks ? await o.hooks.processAllTokens(h) : h;
|
|
4172
|
+
o.walkTokens && await Promise.all(this.walkTokens(p, o.walkTokens));
|
|
4173
|
+
let g = await (o.hooks ? await o.hooks.provideParser(e) : e ? w.parse : w.parseInline)(p, o);
|
|
4174
|
+
return o.hooks ? await o.hooks.postprocess(g) : g;
|
|
4175
|
+
})().catch(i);
|
|
4176
|
+
try {
|
|
4177
|
+
o.hooks && (n = o.hooks.preprocess(n));
|
|
4178
|
+
let u = (o.hooks ? o.hooks.provideLexer(e) : e ? O.lex : O.lexInline)(n, o);
|
|
4179
|
+
o.hooks && (u = o.hooks.processAllTokens(u)), o.walkTokens && this.walkTokens(u, o.walkTokens);
|
|
4180
|
+
let p = (o.hooks ? o.hooks.provideParser(e) : e ? w.parse : w.parseInline)(u, o);
|
|
4181
|
+
return o.hooks && (p = o.hooks.postprocess(p)), p;
|
|
4182
|
+
} catch (l) {
|
|
4183
|
+
return i(l);
|
|
4184
|
+
}
|
|
4185
|
+
};
|
|
4186
|
+
}
|
|
4187
|
+
onError(e, t) {
|
|
4188
|
+
return (n) => {
|
|
4189
|
+
if (n.message += `
|
|
4190
|
+
Please report this to https://github.com/markedjs/marked.`, e) {
|
|
4191
|
+
let s = "<p>An error occurred:</p><pre>" + P(n.message + "", true) + "</pre>";
|
|
4192
|
+
return t ? Promise.resolve(s) : s;
|
|
4193
|
+
}
|
|
4194
|
+
if (t) return Promise.reject(n);
|
|
4195
|
+
throw n;
|
|
4196
|
+
};
|
|
4197
|
+
}
|
|
4198
|
+
};
|
|
4199
|
+
var q = new J();
|
|
4200
|
+
function m(a3, e) {
|
|
4201
|
+
return q.parse(a3, e);
|
|
796
4202
|
}
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
.
|
|
802
|
-
|
|
803
|
-
.
|
|
804
|
-
.ghp3-chip:focus-visible{outline:2px solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline-offset:1px}
|
|
805
|
-
.ghp3-ref{font-family:var(--dsh-font-family-code,ui-monospace,SFMono-Regular,Menlo,monospace);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
|
|
806
|
-
.ghp3-remove{pointer-events:auto;display:inline-flex;align-items:center;justify-content:center;width:22px;height:22px;padding:0;border:0;border-radius:50%;background:transparent;color:var(--dsw-alias-label-tertiary);cursor:pointer;flex:none}
|
|
807
|
-
.ghp3-remove:hover{background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-primary)}
|
|
808
|
-
`.trim();
|
|
809
|
-
function GitHubPendingChip(props) {
|
|
810
|
-
const { card, t, onOpenPanel, onRemove } = props;
|
|
811
|
-
const ref = `${card.repo}#${String(card.number)}`;
|
|
812
|
-
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "ghp3-row", "data-github-pending": true, children: [
|
|
813
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(StyleSheet, { chunks: [CONTROLS_CSS, PENDING_CSS] }),
|
|
814
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("button", { type: "button", className: "ghp3-chip", title: `${ref} \xB7 ${card.title}
|
|
815
|
-
${t("pending.tip")}`, onClick: onOpenPanel, children: [
|
|
816
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(GitHubIcon, { size: 12 }),
|
|
817
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "ghp3-ref", children: ref })
|
|
818
|
-
] }),
|
|
819
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("button", { type: "button", className: "ghp3-remove", "aria-label": t("dock.removeDraft"), onClick: onRemove, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(CloseGlyph, { size: 12 }) })
|
|
820
|
-
] });
|
|
4203
|
+
m.options = m.setOptions = function(a3) {
|
|
4204
|
+
return q.setOptions(a3), m.defaults = q.defaults, ee(m.defaults), m;
|
|
4205
|
+
};
|
|
4206
|
+
m.getDefaults = v;
|
|
4207
|
+
m.defaults = y;
|
|
4208
|
+
function zt(...a3) {
|
|
4209
|
+
return q.use(...a3), m.defaults = q.defaults, ee(m.defaults), m;
|
|
821
4210
|
}
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
4211
|
+
m.use = zt;
|
|
4212
|
+
m.walkTokens = function(a3, e) {
|
|
4213
|
+
return q.walkTokens(a3, e);
|
|
4214
|
+
};
|
|
4215
|
+
m.parseInline = q.parseInline;
|
|
4216
|
+
m.Parser = w;
|
|
4217
|
+
m.parser = w.parse;
|
|
4218
|
+
m.Renderer = L;
|
|
4219
|
+
m.TextRenderer = M;
|
|
4220
|
+
m.Lexer = O;
|
|
4221
|
+
m.lexer = O.lex;
|
|
4222
|
+
m.Tokenizer = _;
|
|
4223
|
+
m.Hooks = A;
|
|
4224
|
+
m.parse = m;
|
|
4225
|
+
var Tn = m.options;
|
|
4226
|
+
var On = m.setOptions;
|
|
4227
|
+
var wn = m.walkTokens;
|
|
4228
|
+
var Pn = m.parseInline;
|
|
4229
|
+
var Sn = w.parse;
|
|
4230
|
+
var _n = O.lex;
|
|
825
4231
|
|
|
826
4232
|
// src/client/views/IssueDetail.tsx
|
|
827
4233
|
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
828
4234
|
var ISSUE_DETAIL_CSS = `
|
|
829
|
-
.ghx-pane{display:flex;flex-direction:column;gap:12px;box-sizing:border-box;flex:0 0
|
|
4235
|
+
.ghx-pane{display:flex;flex-direction:column;gap:12px;box-sizing:border-box;flex:0 0 420px;width:420px;min-width:0;padding-left:20px;border-left:0.5px solid var(--dsw-alias-border-l2)}
|
|
830
4236
|
.ghx-head{display:flex;align-items:center;gap:6px;flex-wrap:wrap;min-width:0}
|
|
831
4237
|
.ghx-ref{font-family:var(--dsh-font-family-code,ui-monospace,SFMono-Regular,Menlo,monospace);font-size:12px;line-height:18px;color:var(--dsw-alias-label-tertiary);text-decoration:none;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:100%}
|
|
832
4238
|
.ghx-ref:hover{color:var(--dsw-alias-link);text-decoration:underline}
|
|
@@ -847,7 +4253,32 @@ var ISSUE_DETAIL_CSS = `
|
|
|
847
4253
|
.ghx-session-title{font-size:12px;line-height:16px;color:var(--dsw-alias-label-primary);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
848
4254
|
.ghx-session-ws{font-size:11px;line-height:15px;color:var(--dsw-alias-label-tertiary);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
849
4255
|
.ghx-session-missing{font-size:11px;color:var(--dsw-alias-label-tertiary);flex:none}
|
|
850
|
-
.ghx-
|
|
4256
|
+
.ghx-markdown{font-size:var(--dsh-content-font-size-secondary,13px);line-height:20px;color:var(--dsw-alias-label-primary);overflow-wrap:anywhere}
|
|
4257
|
+
.ghx-markdown>:first-child{margin-top:0}
|
|
4258
|
+
.ghx-markdown>:last-child{margin-bottom:0}
|
|
4259
|
+
.ghx-markdown p{margin:0 0 8px}
|
|
4260
|
+
.ghx-markdown h1,.ghx-markdown h2,.ghx-markdown h3,.ghx-markdown h4,.ghx-markdown h5,.ghx-markdown h6{margin:14px 0 6px;line-height:1.35;font-weight:600}
|
|
4261
|
+
.ghx-markdown h1{font-size:18px}
|
|
4262
|
+
.ghx-markdown h2{font-size:16px}
|
|
4263
|
+
.ghx-markdown h3{font-size:14px}
|
|
4264
|
+
.ghx-markdown h4,.ghx-markdown h5,.ghx-markdown h6{font-size:13px}
|
|
4265
|
+
.ghx-markdown ul,.ghx-markdown ol{margin:0 0 8px;padding-left:20px}
|
|
4266
|
+
.ghx-markdown li{margin:2px 0}
|
|
4267
|
+
.ghx-markdown li>p{margin:0}
|
|
4268
|
+
.ghx-markdown code{font-family:var(--dsh-font-family-code,ui-monospace,SFMono-Regular,Menlo,monospace);font-size:12px;padding:1px 4px;border-radius:var(--dsw-radius-xs,4px);background:var(--dsw-alias-bg-layer-2)}
|
|
4269
|
+
.ghx-markdown pre{margin:0 0 10px;padding:10px 12px;border:0.5px solid var(--dsw-alias-border-l2);border-radius:var(--dsw-radius-md,8px);background:var(--dsw-alias-bg-layer-1);overflow:auto}
|
|
4270
|
+
.ghx-markdown pre code{padding:0;background:transparent;font-size:12px;line-height:18px;white-space:pre}
|
|
4271
|
+
.ghx-markdown blockquote{margin:0 0 10px;padding:2px 0 2px 12px;border-left:2px solid var(--dsw-alias-border-l3);color:var(--dsw-alias-label-secondary)}
|
|
4272
|
+
.ghx-markdown blockquote>*:last-child{margin-bottom:0}
|
|
4273
|
+
.ghx-markdown a{color:var(--dsw-alias-link);text-decoration:none}
|
|
4274
|
+
.ghx-markdown a:hover{text-decoration:underline}
|
|
4275
|
+
.ghx-markdown img{max-width:100%;height:auto;border-radius:var(--dsw-radius-sm,6px)}
|
|
4276
|
+
.ghx-markdown hr{border:0;border-top:0.5px solid var(--dsw-alias-border-l2);margin:12px 0}
|
|
4277
|
+
.ghx-markdown table{border-collapse:collapse;margin:0 0 10px;font-size:12px}
|
|
4278
|
+
.ghx-markdown th,.ghx-markdown td{border:0.5px solid var(--dsw-alias-border-l2);padding:4px 8px;text-align:left}
|
|
4279
|
+
.ghx-markdown th{background:var(--dsw-alias-bg-layer-1);font-weight:600}
|
|
4280
|
+
.ghx-markdown input[type=checkbox]{margin:0 4px 0 0;vertical-align:middle}
|
|
4281
|
+
.ghx-markdown-loading{font-size:12px;line-height:18px;color:var(--dsw-alias-label-tertiary)}
|
|
851
4282
|
.ghx-section{display:flex;flex-direction:column;gap:6px}
|
|
852
4283
|
.ghx-section-title{margin:0;font-size:12px;line-height:18px;font-weight:500;color:var(--dsw-alias-label-tertiary);text-transform:uppercase;letter-spacing:.02em}
|
|
853
4284
|
.ghx-muted{font-size:12px;line-height:18px;color:var(--dsw-alias-label-tertiary)}
|
|
@@ -922,7 +4353,8 @@ function IssueDetailPane({ snapshot, actions, t, resolveSession }) {
|
|
|
922
4353
|
const detailFailed = detail === void 0 && !snapshot.detailLoading && error !== void 0;
|
|
923
4354
|
const showHint = detail === void 0 && !snapshot.detailLoading && error === void 0;
|
|
924
4355
|
const tone = stateTone(card.state, card.stateReason);
|
|
925
|
-
const body = detail?.body
|
|
4356
|
+
const body = detail?.body ?? "";
|
|
4357
|
+
const bodyHtml = body === "" ? "" : renderMarkdown(body);
|
|
926
4358
|
const sessionLinks = card.sessionLinks ?? [];
|
|
927
4359
|
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("aside", { className: "ghx-pane", "aria-label": t("panel.detail"), children: [
|
|
928
4360
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "ghx-head", children: [
|
|
@@ -1020,7 +4452,7 @@ function IssueDetailPane({ snapshot, actions, t, resolveSession }) {
|
|
|
1020
4452
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "ghx-skeleton-line", style: { width: "92%" } }),
|
|
1021
4453
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "ghx-skeleton-line", style: { width: "78%" } }),
|
|
1022
4454
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "ghx-skeleton-line", style: { width: "60%" } })
|
|
1023
|
-
] }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("
|
|
4455
|
+
] }) : bodyHtml === "" ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { className: "ghx-markdown-loading", children: t("panel.noBody") }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "ghx-markdown", dangerouslySetInnerHTML: { __html: bodyHtml } }),
|
|
1024
4456
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("section", { className: "ghx-section", children: [
|
|
1025
4457
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("h3", { className: "ghx-section-title", children: t("panel.milestone") }),
|
|
1026
4458
|
detail.milestone === void 0 ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "ghx-muted", children: t("panel.noMilestone") }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
|
|
@@ -1062,6 +4494,22 @@ function IssueDetailPane({ snapshot, actions, t, resolveSession }) {
|
|
|
1062
4494
|
] })
|
|
1063
4495
|
] });
|
|
1064
4496
|
}
|
|
4497
|
+
m.use({ gfm: true, breaks: true });
|
|
4498
|
+
var linkHookInstalled = false;
|
|
4499
|
+
function renderMarkdown(markdown) {
|
|
4500
|
+
const parsed = m.parse(markdown, { async: false });
|
|
4501
|
+
const purify = purify_default;
|
|
4502
|
+
if (typeof purify.sanitize !== "function") return parsed;
|
|
4503
|
+
if (!linkHookInstalled && typeof purify.addHook === "function") {
|
|
4504
|
+
linkHookInstalled = true;
|
|
4505
|
+
purify.addHook("afterSanitizeAttributes", (node) => {
|
|
4506
|
+
if (node.tagName !== "A") return;
|
|
4507
|
+
node.setAttribute("target", "_blank");
|
|
4508
|
+
node.setAttribute("rel", "noreferrer noopener");
|
|
4509
|
+
});
|
|
4510
|
+
}
|
|
4511
|
+
return purify.sanitize(parsed, { ADD_ATTR: ["target"] });
|
|
4512
|
+
}
|
|
1065
4513
|
|
|
1066
4514
|
// src/client/views/IssueRow.tsx
|
|
1067
4515
|
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
@@ -1276,8 +4724,8 @@ var PAGE_CSS = `
|
|
|
1276
4724
|
.ghp-panel .ghp-body{display:flex;flex:1;min-height:0;margin-top:0}
|
|
1277
4725
|
.ghp-panel .ghp-split{flex:1;min-height:0;width:100%;align-items:stretch}
|
|
1278
4726
|
.ghp-panel .ghp-list-pane{flex:1;min-width:0;overflow:auto;overscroll-behavior:contain;padding-bottom:32px}
|
|
1279
|
-
.ghp-panel .ghx-pane{flex:0 0
|
|
1280
|
-
.ghp-panel .ghp-scope{grid-template-columns:minmax(0
|
|
4727
|
+
.ghp-panel .ghx-pane{flex:0 0 420px;box-sizing:border-box;width:420px;max-height:100%;min-height:0;overflow:auto;overscroll-behavior:contain;padding-bottom:32px}
|
|
4728
|
+
.ghp-panel .ghp-scope{grid-template-columns:minmax(0,1.05fr) minmax(0,1.55fr) minmax(0,1.55fr) minmax(0,1fr) minmax(0,.8fr);gap:10px;margin-top:14px}
|
|
1281
4729
|
@media (max-width:860px){.ghp-panel .ghp-scope{grid-template-columns:repeat(auto-fit,minmax(124px,1fr))}}
|
|
1282
4730
|
.ghp-panel .ghp-filters{margin:12px 0 6px}
|
|
1283
4731
|
@media (max-width:760px){
|
|
@@ -1329,44 +4777,6 @@ function Field(props) {
|
|
|
1329
4777
|
props.children
|
|
1330
4778
|
] });
|
|
1331
4779
|
}
|
|
1332
|
-
function ScopeCombo(props) {
|
|
1333
|
-
const { label, value, placeholder, options, disabled, onChange } = props;
|
|
1334
|
-
const listId = (0, import_react2.useId)();
|
|
1335
|
-
const selected = options.find((option) => option.value === value);
|
|
1336
|
-
const [text, setText] = (0, import_react2.useState)(selected?.label ?? "");
|
|
1337
|
-
(0, import_react2.useEffect)(() => {
|
|
1338
|
-
const current = options.find((option) => option.value === value);
|
|
1339
|
-
setText(current?.label ?? "");
|
|
1340
|
-
}, [value, options]);
|
|
1341
|
-
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
|
|
1342
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1343
|
-
"input",
|
|
1344
|
-
{
|
|
1345
|
-
className: "gh-input",
|
|
1346
|
-
list: listId,
|
|
1347
|
-
value: text,
|
|
1348
|
-
disabled: disabled === true,
|
|
1349
|
-
placeholder,
|
|
1350
|
-
"aria-label": label,
|
|
1351
|
-
onChange: (event) => {
|
|
1352
|
-
const next = event.target.value;
|
|
1353
|
-
setText(next);
|
|
1354
|
-
if (next === "") {
|
|
1355
|
-
onChange(void 0);
|
|
1356
|
-
return;
|
|
1357
|
-
}
|
|
1358
|
-
const match = options.find((option) => option.label === next || option.value === next);
|
|
1359
|
-
if (match !== void 0) onChange(match.value);
|
|
1360
|
-
},
|
|
1361
|
-
onBlur: () => {
|
|
1362
|
-
const current = options.find((option) => option.value === value);
|
|
1363
|
-
setText(current?.label ?? "");
|
|
1364
|
-
}
|
|
1365
|
-
}
|
|
1366
|
-
),
|
|
1367
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("datalist", { id: listId, children: options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("option", { value: option.label }, option.value)) })
|
|
1368
|
-
] });
|
|
1369
|
-
}
|
|
1370
4780
|
function GitHubPage({ snapshot, actions, t, resolveSession }) {
|
|
1371
4781
|
const [filter, setFilter] = (0, import_react2.useState)("");
|
|
1372
4782
|
const prefs = snapshot.prefs;
|
|
@@ -1388,16 +4798,11 @@ function GitHubPage({ snapshot, actions, t, resolveSession }) {
|
|
|
1388
4798
|
label: t(STATE_LABEL[state])
|
|
1389
4799
|
}));
|
|
1390
4800
|
const orgs = snapshot.catalog?.orgs ?? [];
|
|
1391
|
-
const orgOptions =
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
const
|
|
1396
|
-
{ value: "", label: t("panel.allProjects") },
|
|
1397
|
-
...(snapshot.orgProjects ?? []).map((project) => ({ value: project.id, label: project.title }))
|
|
1398
|
-
];
|
|
1399
|
-
const repoSource = prefs.org === void 0 ? snapshot.catalog?.repos ?? [] : snapshot.orgRepos?.items ?? [];
|
|
1400
|
-
const repoOptions = repoSource.map((repo) => ({
|
|
4801
|
+
const orgOptions = orgs.map((org) => ({
|
|
4802
|
+
value: org.login,
|
|
4803
|
+
label: org.name === void 0 ? org.login : `${org.login} \xB7 ${org.name}`
|
|
4804
|
+
}));
|
|
4805
|
+
const repoOptions = (snapshot.orgRepos?.items ?? []).map((repo) => ({
|
|
1401
4806
|
value: repo.nameWithOwner,
|
|
1402
4807
|
label: `${repo.nameWithOwner}${repo.isPrivate ? ` \xB7 ${t("panel.private")}` : ""}${repo.isFork === true ? ` \xB7 ${t("panel.fork")}` : ""}`
|
|
1403
4808
|
}));
|
|
@@ -1407,7 +4812,7 @@ function GitHubPage({ snapshot, actions, t, resolveSession }) {
|
|
|
1407
4812
|
];
|
|
1408
4813
|
const milestoneTitles = [
|
|
1409
4814
|
...prefs.milestone === void 0 ? [] : [prefs.milestone],
|
|
1410
|
-
...snapshot.milestoneOptions ?? []
|
|
4815
|
+
...(snapshot.milestoneOptions ?? []).map((item) => item.title)
|
|
1411
4816
|
].filter((title, index, all) => title !== "" && all.indexOf(title) === index);
|
|
1412
4817
|
const milestoneOptions = [
|
|
1413
4818
|
{ value: "", label: t("panel.allMilestones") },
|
|
@@ -1421,7 +4826,7 @@ function GitHubPage({ snapshot, actions, t, resolveSession }) {
|
|
|
1421
4826
|
const noAuth = snapshot.status?.signedIn === false;
|
|
1422
4827
|
const subtitle = snapshot.status?.signedIn === true && snapshot.status.login !== void 0 ? t("settings.signedIn", { login: snapshot.status.login }) : snapshot.loading ? t("panel.loading") : "";
|
|
1423
4828
|
const split = snapshot.selected !== void 0;
|
|
1424
|
-
const scopeHint = prefs.org === void 0 ? t("panel.scopeGlobal") : `${prefs.org}${prefs.
|
|
4829
|
+
const scopeHint = prefs.org === void 0 ? t("panel.scopeGlobal") : `${prefs.org}${prefs.repo === void 0 ? "" : ` \xB7 ${prefs.repo}`}${prefs.milestone === void 0 ? "" : ` \xB7 ${prefs.milestone}`}`;
|
|
1425
4830
|
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("section", { className: "ghp-page ghp-panel", "data-github-panel": true, "aria-label": t("panel"), children: [
|
|
1426
4831
|
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(StyleSheet, { chunks: [CONTROLS_CSS, PAGE_CSS, ISSUE_ROW_CSS, ISSUE_DETAIL_CSS] }),
|
|
1427
4832
|
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "ghp-content", children: [
|
|
@@ -1449,36 +4854,27 @@ function GitHubPage({ snapshot, actions, t, resolveSession }) {
|
|
|
1449
4854
|
ariaLabel: t("panel.org"),
|
|
1450
4855
|
value: prefs.org ?? "",
|
|
1451
4856
|
options: orgOptions,
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
) }),
|
|
1455
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Field, { label: t("panel.project"), children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1456
|
-
Select,
|
|
1457
|
-
{
|
|
1458
|
-
ariaLabel: t("panel.project"),
|
|
1459
|
-
value: prefs.org === void 0 ? "" : prefs.projectId ?? "",
|
|
1460
|
-
options: projectOptions,
|
|
1461
|
-
disabled: prefs.org === void 0 || snapshot.projectsBlocked,
|
|
1462
|
-
onChange: (value) => actions.setProject(value === "" ? void 0 : value)
|
|
4857
|
+
disabled: orgOptions.length === 0,
|
|
4858
|
+
onChange: (value) => actions.setOrg(value)
|
|
1463
4859
|
}
|
|
1464
4860
|
) }),
|
|
1465
4861
|
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Field, { label: t("panel.repoFilter"), children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1466
|
-
|
|
4862
|
+
Select,
|
|
1467
4863
|
{
|
|
1468
|
-
|
|
1469
|
-
value: prefs.repo,
|
|
1470
|
-
placeholder: prefs.org === void 0 ? t("panel.allRepos") : `${t("panel.allRepos")}\uFF08${String(repoOptions.length)}\uFF09`,
|
|
4864
|
+
ariaLabel: t("panel.repoFilter"),
|
|
4865
|
+
value: prefs.repo ?? "",
|
|
1471
4866
|
options: repoOptions,
|
|
1472
|
-
|
|
4867
|
+
disabled: repoOptions.length === 0,
|
|
4868
|
+
onChange: (value) => actions.setRepo(value)
|
|
1473
4869
|
}
|
|
1474
4870
|
) }),
|
|
1475
4871
|
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Field, { label: t("panel.milestoneFilter"), children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1476
4872
|
Select,
|
|
1477
4873
|
{
|
|
1478
4874
|
ariaLabel: t("panel.milestoneFilter"),
|
|
1479
|
-
value: prefs.
|
|
4875
|
+
value: prefs.milestone ?? "",
|
|
1480
4876
|
options: milestoneOptions,
|
|
1481
|
-
disabled: prefs.
|
|
4877
|
+
disabled: prefs.repo === void 0 || snapshot.scopeLoading,
|
|
1482
4878
|
onChange: (value) => actions.setMilestone(value === "" ? void 0 : value)
|
|
1483
4879
|
}
|
|
1484
4880
|
) }),
|
|
@@ -1501,18 +4897,6 @@ function GitHubPage({ snapshot, actions, t, resolveSession }) {
|
|
|
1501
4897
|
}
|
|
1502
4898
|
) })
|
|
1503
4899
|
] }),
|
|
1504
|
-
prefs.org === void 0 && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "ghp-notice", role: "note", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { children: t("panel.pickOrgHint") }) }),
|
|
1505
|
-
snapshot.projectsBlocked && prefs.org !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "ghp-notice", role: "note", children: [
|
|
1506
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { children: t("panel.projectsBlocked") }),
|
|
1507
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1508
|
-
CommandBlock,
|
|
1509
|
-
{
|
|
1510
|
-
command: PROJECT_SCOPE_COMMAND,
|
|
1511
|
-
copyLabel: t("panel.copyCommand"),
|
|
1512
|
-
onCopy: () => actions.copyText(PROJECT_SCOPE_COMMAND)
|
|
1513
|
-
}
|
|
1514
|
-
)
|
|
1515
|
-
] }),
|
|
1516
4900
|
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "ghp-filters", children: [
|
|
1517
4901
|
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "ghp-search", children: [
|
|
1518
4902
|
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "ghp-search-icon", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(SearchGlyph, { size: 13 }) }),
|
|
@@ -1537,15 +4921,7 @@ function GitHubPage({ snapshot, actions, t, resolveSession }) {
|
|
|
1537
4921
|
{
|
|
1538
4922
|
message: t("panel.error", { message: listError.message }),
|
|
1539
4923
|
retryLabel: t("panel.refresh"),
|
|
1540
|
-
onRetry: () => actions.refresh()
|
|
1541
|
-
children: listError.code === "missing_scope" && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1542
|
-
CommandBlock,
|
|
1543
|
-
{
|
|
1544
|
-
command: PROJECT_SCOPE_COMMAND,
|
|
1545
|
-
copyLabel: t("panel.copyCommand"),
|
|
1546
|
-
onCopy: () => actions.copyText(PROJECT_SCOPE_COMMAND)
|
|
1547
|
-
}
|
|
1548
|
-
)
|
|
4924
|
+
onRetry: () => actions.refresh()
|
|
1549
4925
|
}
|
|
1550
4926
|
),
|
|
1551
4927
|
showSkeleton && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "ghp-list", "aria-hidden": "true", children: [0, 1, 2, 3, 4].map((index) => /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "ghp-skeleton-row", children: [
|
|
@@ -1556,7 +4932,7 @@ function GitHubPage({ snapshot, actions, t, resolveSession }) {
|
|
|
1556
4932
|
EmptyState,
|
|
1557
4933
|
{
|
|
1558
4934
|
icon: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(GitHubIcon, { size: 28 }),
|
|
1559
|
-
title: noAuth ? t("panel.emptyAuth") : snapshot.list?.notice ??
|
|
4935
|
+
title: noAuth ? t("panel.emptyAuth") : snapshot.list?.notice ?? t("panel.empty")
|
|
1560
4936
|
}
|
|
1561
4937
|
),
|
|
1562
4938
|
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "ghp-list", children: filtered.map((card) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
@@ -1582,16 +4958,6 @@ function GitHubPage({ snapshot, actions, t, resolveSession }) {
|
|
|
1582
4958
|
snapshot.toast !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Toast, { text: t(snapshot.toast), onDismiss: () => actions.clearToast(), dismissLabel: t("panel.close") })
|
|
1583
4959
|
] });
|
|
1584
4960
|
}
|
|
1585
|
-
function emptyTitle(prefs, total, t) {
|
|
1586
|
-
const projectId = prefs.org === void 0 ? void 0 : prefs.projectId;
|
|
1587
|
-
if (projectId !== void 0 && prefs.assignee === "@me") {
|
|
1588
|
-
return t("panel.emptyProjectMe", { count: total ?? 0 });
|
|
1589
|
-
}
|
|
1590
|
-
if (projectId !== void 0 && prefs.state === "open") {
|
|
1591
|
-
return t("panel.emptyProjectOpen");
|
|
1592
|
-
}
|
|
1593
|
-
return t("panel.empty");
|
|
1594
|
-
}
|
|
1595
4961
|
|
|
1596
4962
|
// src/client/views/Settings.tsx
|
|
1597
4963
|
var import_react3 = require("react");
|
|
@@ -1683,18 +5049,6 @@ function GitHubSettings({ snapshot, actions, t }) {
|
|
|
1683
5049
|
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "ghs-scopes", children: [
|
|
1684
5050
|
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "gh-field-label", children: t("settings.scopes") }),
|
|
1685
5051
|
status.scopes.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "ghp-muted", children: "\u2014" }) : status.scopes.map((scope) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Badge, { tone: "neutral", children: scope }, scope))
|
|
1686
|
-
] }),
|
|
1687
|
-
status.missingProjectScope && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "ghs-warn", role: "note", children: [
|
|
1688
|
-
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { children: t("settings.missingProject") }),
|
|
1689
|
-
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "ghp-muted", children: t("settings.command") }),
|
|
1690
|
-
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1691
|
-
CommandBlock,
|
|
1692
|
-
{
|
|
1693
|
-
command: PROJECT_SCOPE_COMMAND,
|
|
1694
|
-
copyLabel: t("settings.copy"),
|
|
1695
|
-
onCopy: () => actions.copyText(PROJECT_SCOPE_COMMAND)
|
|
1696
|
-
}
|
|
1697
|
-
)
|
|
1698
5052
|
] })
|
|
1699
5053
|
] })
|
|
1700
5054
|
] }),
|
|
@@ -1970,8 +5324,8 @@ function PendingOverlayHost({ store, t, sessionId, useInput, inputActions }) {
|
|
|
1970
5324
|
}, [snapshot.pendingHandoff, snapshot.pendingHandoffSession, inputActions, sessionId, store]);
|
|
1971
5325
|
(0, import_react5.useEffect)(() => {
|
|
1972
5326
|
if (pending === void 0 || input === void 0 || sessionId === void 0) return;
|
|
1973
|
-
const
|
|
1974
|
-
if (
|
|
5327
|
+
const text2 = input.draft;
|
|
5328
|
+
if (text2.includes(marker)) {
|
|
1975
5329
|
markerSeen.current = true;
|
|
1976
5330
|
if (input.phase !== "plain") submitSeen.current = true;
|
|
1977
5331
|
}
|
|
@@ -1983,14 +5337,14 @@ function PendingOverlayHost({ store, t, sessionId, useInput, inputActions }) {
|
|
|
1983
5337
|
sending.current = false;
|
|
1984
5338
|
return;
|
|
1985
5339
|
}
|
|
1986
|
-
if (
|
|
5340
|
+
if (text2 === "") {
|
|
1987
5341
|
setPending(void 0);
|
|
1988
5342
|
markerSeen.current = false;
|
|
1989
5343
|
submitSeen.current = false;
|
|
1990
5344
|
sending.current = false;
|
|
1991
5345
|
return;
|
|
1992
5346
|
}
|
|
1993
|
-
if (markerSeen.current && !
|
|
5347
|
+
if (markerSeen.current && !text2.includes(marker)) {
|
|
1994
5348
|
setPending(void 0);
|
|
1995
5349
|
markerSeen.current = false;
|
|
1996
5350
|
submitSeen.current = false;
|
|
@@ -2587,6 +5941,19 @@ function asPanelError(error) {
|
|
|
2587
5941
|
}
|
|
2588
5942
|
return { message: error instanceof Error ? error.message : String(error) };
|
|
2589
5943
|
}
|
|
5944
|
+
function applyPrefsPatchLocally(current, patch) {
|
|
5945
|
+
const next = { ...current };
|
|
5946
|
+
if ("org" in patch) next.org = patch.org ?? void 0;
|
|
5947
|
+
if ("projectId" in patch) next.projectId = patch.projectId ?? void 0;
|
|
5948
|
+
if ("repo" in patch) next.repo = patch.repo ?? void 0;
|
|
5949
|
+
if ("milestone" in patch) next.milestone = patch.milestone ?? void 0;
|
|
5950
|
+
if ("assignee" in patch && patch.assignee !== null) next.assignee = patch.assignee;
|
|
5951
|
+
if ("state" in patch && patch.state !== null) next.state = patch.state;
|
|
5952
|
+
if ("handoffMode" in patch && patch.handoffMode !== null) next.handoffMode = patch.handoffMode;
|
|
5953
|
+
if ("promptTemplate" in patch && patch.promptTemplate !== null) next.promptTemplate = patch.promptTemplate;
|
|
5954
|
+
if ("pinned" in patch) next.pinned = patch.pinned ?? void 0;
|
|
5955
|
+
return next;
|
|
5956
|
+
}
|
|
2590
5957
|
async function waitForRemote(ctx) {
|
|
2591
5958
|
const deadline = Date.now() + REMOTE_WAIT_MS;
|
|
2592
5959
|
for (; ; ) {
|
|
@@ -2657,28 +6024,21 @@ var GitHubStore = class {
|
|
|
2657
6024
|
this.update({ loading: true, error: void 0 });
|
|
2658
6025
|
try {
|
|
2659
6026
|
const remote = await this.api();
|
|
6027
|
+
const catalogLoading = this.loadCatalog();
|
|
2660
6028
|
const [status, prefs] = await Promise.all([
|
|
2661
6029
|
remote.status().then((result) => unwrap(result)),
|
|
2662
6030
|
remote.loadPrefs().then((result) => unwrap(result))
|
|
2663
6031
|
]);
|
|
2664
|
-
let sanePrefs = prefs.projectId !== void 0 && prefs.org === void 0 ? { ...prefs, projectId: void 0, repo: prefs.repo } : prefs;
|
|
2665
|
-
if (sanePrefs.projectId !== void 0 && sanePrefs.milestone !== void 0) {
|
|
2666
|
-
sanePrefs = { ...sanePrefs, milestone: void 0 };
|
|
2667
|
-
void this.savePrefs({ milestone: null });
|
|
2668
|
-
}
|
|
2669
6032
|
this.update({
|
|
2670
6033
|
status,
|
|
2671
|
-
prefs:
|
|
6034
|
+
prefs: { ...prefs, projectId: void 0 },
|
|
2672
6035
|
projectsBlocked: status.missingProjectScope,
|
|
2673
6036
|
loading: false
|
|
2674
6037
|
});
|
|
2675
|
-
if (
|
|
2676
|
-
void this.savePrefs({ projectId: null });
|
|
2677
|
-
}
|
|
2678
|
-
if (sanePrefs.repo !== void 0) void this.loadRepoMilestones(sanePrefs.repo);
|
|
2679
|
-
void this.loadCatalog();
|
|
6038
|
+
if (prefs.projectId !== void 0) void this.savePrefs({ projectId: null });
|
|
2680
6039
|
void this.loadLinks();
|
|
2681
|
-
|
|
6040
|
+
await catalogLoading;
|
|
6041
|
+
await this.ensureScopeSelection();
|
|
2682
6042
|
await this.reloadList();
|
|
2683
6043
|
this.schedulePolling(status.config.pollSeconds);
|
|
2684
6044
|
void this.hydratePinned();
|
|
@@ -2710,8 +6070,8 @@ var GitHubStore = class {
|
|
|
2710
6070
|
for (const listener of this.listeners) listener();
|
|
2711
6071
|
}
|
|
2712
6072
|
/** Show one transient confirmation. */
|
|
2713
|
-
toast(
|
|
2714
|
-
this.update({ toast:
|
|
6073
|
+
toast(text2) {
|
|
6074
|
+
this.update({ toast: text2 });
|
|
2715
6075
|
if (this.toastTimer !== void 0) clearTimeout(this.toastTimer);
|
|
2716
6076
|
this.toastTimer = setTimeout(() => {
|
|
2717
6077
|
this.update({ toast: void 0 });
|
|
@@ -2727,14 +6087,21 @@ var GitHubStore = class {
|
|
|
2727
6087
|
after
|
|
2728
6088
|
};
|
|
2729
6089
|
if (prefs.org !== void 0) request.org = prefs.org;
|
|
2730
|
-
if (prefs.org !== void 0 && prefs.projectId !== void 0) request.projectId = prefs.projectId;
|
|
2731
6090
|
if (prefs.repo !== void 0) request.repos = [prefs.repo];
|
|
2732
|
-
if (prefs.
|
|
6091
|
+
if (prefs.milestone !== void 0) {
|
|
6092
|
+
request.milestone = prefs.milestone;
|
|
6093
|
+
const option = this.snapshot.milestoneOptions.find((item) => item.title === prefs.milestone);
|
|
6094
|
+
if (option !== void 0) request.milestoneNumber = option.number;
|
|
6095
|
+
}
|
|
2733
6096
|
return request;
|
|
2734
6097
|
}
|
|
2735
6098
|
/** Fetch the first page of the current cascade. */
|
|
2736
6099
|
async reloadList(quiet = false) {
|
|
2737
6100
|
const seq = ++this.listSeq;
|
|
6101
|
+
if (this.snapshot.prefs.repo === void 0) {
|
|
6102
|
+
this.update({ list: void 0, loading: false, loadingMore: false });
|
|
6103
|
+
return;
|
|
6104
|
+
}
|
|
2738
6105
|
if (!quiet) this.update({ loading: true, error: void 0 });
|
|
2739
6106
|
try {
|
|
2740
6107
|
const remote = await this.api();
|
|
@@ -2746,7 +6113,6 @@ var GitHubStore = class {
|
|
|
2746
6113
|
loadingMore: false,
|
|
2747
6114
|
error: void 0
|
|
2748
6115
|
});
|
|
2749
|
-
this.rememberMilestones(page.items);
|
|
2750
6116
|
this.refreshPinnedCard();
|
|
2751
6117
|
} catch (error) {
|
|
2752
6118
|
if (seq !== this.listSeq) return;
|
|
@@ -2759,55 +6125,73 @@ var GitHubStore = class {
|
|
|
2759
6125
|
try {
|
|
2760
6126
|
const remote = await this.api();
|
|
2761
6127
|
const catalog = await remote.catalog().then((result) => unwrap(result));
|
|
2762
|
-
this.update({
|
|
2763
|
-
catalog,
|
|
2764
|
-
projectsBlocked: this.snapshot.status?.missingProjectScope === true || catalog.projectsBlocked
|
|
2765
|
-
});
|
|
6128
|
+
this.update({ catalog });
|
|
2766
6129
|
} catch (error) {
|
|
2767
6130
|
this.update({ error: asPanelError(error) });
|
|
2768
6131
|
}
|
|
2769
6132
|
}
|
|
2770
|
-
/**
|
|
2771
|
-
* Load the projects and repositories of one organization, once per session.
|
|
2772
|
-
* A Projects v2 permission failure degrades to `projectsBlocked` while the
|
|
2773
|
-
* repository list still works.
|
|
2774
|
-
*/
|
|
6133
|
+
/** Load one organization's repositories, once per session. */
|
|
2775
6134
|
async loadOrgScope(org) {
|
|
2776
6135
|
const cached = this.orgScopes.get(org);
|
|
2777
6136
|
if (cached !== void 0) {
|
|
2778
|
-
this.update({
|
|
2779
|
-
orgProjects: cached.projects,
|
|
2780
|
-
orgRepos: cached.repos,
|
|
2781
|
-
projectsBlocked: cached.blocked || this.snapshot.status?.missingProjectScope === true,
|
|
2782
|
-
...cached.error === void 0 ? { projectsError: void 0 } : { projectsError: cached.error }
|
|
2783
|
-
});
|
|
6137
|
+
this.update({ orgRepos: cached.repos, scopeLoading: false });
|
|
2784
6138
|
return;
|
|
2785
6139
|
}
|
|
2786
6140
|
this.update({ scopeLoading: true });
|
|
2787
6141
|
try {
|
|
2788
6142
|
const remote = await this.api();
|
|
2789
|
-
const
|
|
2790
|
-
|
|
2791
|
-
|
|
2792
|
-
]);
|
|
2793
|
-
const scope = {
|
|
2794
|
-
projects: projects.projects,
|
|
2795
|
-
repos,
|
|
2796
|
-
blocked: projects.blocked || this.snapshot.status?.missingProjectScope === true,
|
|
2797
|
-
...projects.error === void 0 ? {} : { error: projects.error }
|
|
2798
|
-
};
|
|
2799
|
-
this.orgScopes.set(org, scope);
|
|
2800
|
-
this.update({
|
|
2801
|
-
orgProjects: scope.projects,
|
|
2802
|
-
orgRepos: scope.repos,
|
|
2803
|
-
projectsBlocked: scope.blocked,
|
|
2804
|
-
...scope.error === void 0 ? { projectsError: void 0 } : { projectsError: scope.error },
|
|
2805
|
-
scopeLoading: false
|
|
2806
|
-
});
|
|
6143
|
+
const repos = await remote.orgRepos(org).then((result) => unwrap(result));
|
|
6144
|
+
this.orgScopes.set(org, { repos });
|
|
6145
|
+
this.update({ orgRepos: repos, scopeLoading: false });
|
|
2807
6146
|
} catch (error) {
|
|
2808
6147
|
this.update({ scopeLoading: false, error: asPanelError(error) });
|
|
2809
6148
|
}
|
|
2810
6149
|
}
|
|
6150
|
+
/**
|
|
6151
|
+
* Choose an organization when none is restored (or the saved one vanished).
|
|
6152
|
+
* @returns completion once its repository page is loaded.
|
|
6153
|
+
*/
|
|
6154
|
+
async ensureOrgSelection() {
|
|
6155
|
+
const orgs = this.snapshot.catalog?.orgs ?? [];
|
|
6156
|
+
if (orgs.length === 0) return;
|
|
6157
|
+
const current = this.snapshot.prefs.org;
|
|
6158
|
+
const chosen = current !== void 0 && orgs.some((org) => org.login === current) ? current : orgs[0]?.login;
|
|
6159
|
+
if (chosen === void 0) return;
|
|
6160
|
+
if (chosen !== current) {
|
|
6161
|
+
this.resetMilestoneOptions();
|
|
6162
|
+
this.update({
|
|
6163
|
+
prefs: { ...this.snapshot.prefs, org: chosen, repo: void 0, milestone: void 0, projectId: void 0 },
|
|
6164
|
+
orgRepos: void 0
|
|
6165
|
+
});
|
|
6166
|
+
await this.persistPrefs({ org: chosen, projectId: null, repo: null, milestone: null });
|
|
6167
|
+
}
|
|
6168
|
+
await this.loadOrgScope(chosen);
|
|
6169
|
+
await this.ensureRepoSelection();
|
|
6170
|
+
}
|
|
6171
|
+
/**
|
|
6172
|
+
* Choose a repository when none is restored (or it does not belong to the
|
|
6173
|
+
* organization). The repository picker has no "all repositories" state.
|
|
6174
|
+
* @returns completion once the milestone list is loaded.
|
|
6175
|
+
*/
|
|
6176
|
+
async ensureRepoSelection() {
|
|
6177
|
+
const repos = this.snapshot.orgRepos?.items ?? [];
|
|
6178
|
+
if (repos.length === 0) return;
|
|
6179
|
+
const current = this.snapshot.prefs.repo;
|
|
6180
|
+
const valid = current !== void 0 && repos.some((repo) => repo.nameWithOwner === current);
|
|
6181
|
+
const chosen = valid ? current : repos[0]?.nameWithOwner;
|
|
6182
|
+
if (chosen === void 0) return;
|
|
6183
|
+
if (chosen !== current) {
|
|
6184
|
+
this.resetMilestoneOptions();
|
|
6185
|
+
this.update({ prefs: { ...this.snapshot.prefs, repo: chosen, milestone: void 0 } });
|
|
6186
|
+
await this.persistPrefs({ repo: chosen, milestone: null });
|
|
6187
|
+
}
|
|
6188
|
+
await this.loadRepoMilestones(chosen);
|
|
6189
|
+
await this.pruneMilestone(chosen);
|
|
6190
|
+
}
|
|
6191
|
+
/** The default scope selection used by bootstrap. */
|
|
6192
|
+
async ensureScopeSelection() {
|
|
6193
|
+
await this.ensureOrgSelection();
|
|
6194
|
+
}
|
|
2811
6195
|
/** Keep the dock's copy of the pinned issue in sync with the loaded list. */
|
|
2812
6196
|
refreshPinnedCard() {
|
|
2813
6197
|
const pinned = this.snapshot.prefs.pinned;
|
|
@@ -2854,22 +6238,21 @@ var GitHubStore = class {
|
|
|
2854
6238
|
await remote.refresh();
|
|
2855
6239
|
const status = await remote.status().then((result) => unwrap(result));
|
|
2856
6240
|
this.orgScopes.clear();
|
|
6241
|
+
this.resetMilestoneOptions();
|
|
2857
6242
|
this.update({
|
|
2858
6243
|
status,
|
|
2859
6244
|
catalog: void 0,
|
|
2860
|
-
orgProjects: void 0,
|
|
2861
6245
|
orgRepos: void 0,
|
|
2862
|
-
projectsBlocked:
|
|
6246
|
+
projectsBlocked: false,
|
|
2863
6247
|
projectsError: void 0
|
|
2864
6248
|
});
|
|
2865
6249
|
} catch (error) {
|
|
2866
6250
|
this.update({ error: asPanelError(error) });
|
|
2867
6251
|
return;
|
|
2868
6252
|
}
|
|
2869
|
-
|
|
2870
|
-
|
|
6253
|
+
await this.loadCatalog();
|
|
6254
|
+
await this.ensureScopeSelection();
|
|
2871
6255
|
await this.reloadList();
|
|
2872
|
-
void this.loadCatalog();
|
|
2873
6256
|
})();
|
|
2874
6257
|
}
|
|
2875
6258
|
loadMore() {
|
|
@@ -2880,7 +6263,6 @@ var GitHubStore = class {
|
|
|
2880
6263
|
try {
|
|
2881
6264
|
const remote = await this.api();
|
|
2882
6265
|
const next = await remote.listIssues(this.request(page.pageInfo.endCursor)).then((result) => unwrap(result));
|
|
2883
|
-
this.rememberMilestones(next.items);
|
|
2884
6266
|
this.update({
|
|
2885
6267
|
loadingMore: false,
|
|
2886
6268
|
list: {
|
|
@@ -2896,23 +6278,25 @@ var GitHubStore = class {
|
|
|
2896
6278
|
})();
|
|
2897
6279
|
}
|
|
2898
6280
|
setOrg(org) {
|
|
6281
|
+
if (org === this.snapshot.prefs.org) return;
|
|
2899
6282
|
this.resetMilestoneOptions();
|
|
2900
|
-
void this.savePrefs({ org
|
|
2901
|
-
this.update({
|
|
2902
|
-
if (saved.org !== void 0)
|
|
2903
|
-
|
|
2904
|
-
|
|
2905
|
-
|
|
2906
|
-
|
|
2907
|
-
void this.savePrefs({
|
|
2908
|
-
projectId: projectId ?? null,
|
|
2909
|
-
...projectId === void 0 ? {} : { milestone: null }
|
|
6283
|
+
void this.savePrefs({ org, projectId: null, repo: null, milestone: null }, async (saved) => {
|
|
6284
|
+
this.update({ orgRepos: void 0 });
|
|
6285
|
+
if (saved.org !== void 0) {
|
|
6286
|
+
await this.loadOrgScope(saved.org);
|
|
6287
|
+
await this.ensureRepoSelection();
|
|
6288
|
+
await this.reloadList();
|
|
6289
|
+
}
|
|
2910
6290
|
});
|
|
2911
6291
|
}
|
|
2912
6292
|
setRepo(repo) {
|
|
6293
|
+
if (repo === this.snapshot.prefs.repo) return;
|
|
2913
6294
|
this.resetMilestoneOptions();
|
|
2914
|
-
void this.savePrefs({ repo
|
|
2915
|
-
if (saved.repo !== void 0)
|
|
6295
|
+
void this.savePrefs({ repo, milestone: null }, async (saved) => {
|
|
6296
|
+
if (saved.repo !== void 0) {
|
|
6297
|
+
await this.loadRepoMilestones(saved.repo);
|
|
6298
|
+
await this.pruneMilestone(saved.repo);
|
|
6299
|
+
}
|
|
2916
6300
|
});
|
|
2917
6301
|
}
|
|
2918
6302
|
setMilestone(milestone) {
|
|
@@ -2922,24 +6306,14 @@ var GitHubStore = class {
|
|
|
2922
6306
|
resetMilestoneOptions() {
|
|
2923
6307
|
if (this.snapshot.milestoneOptions.length !== 0) this.update({ milestoneOptions: [] });
|
|
2924
6308
|
}
|
|
2925
|
-
/**
|
|
2926
|
-
|
|
2927
|
-
const options = [...this.snapshot.milestoneOptions];
|
|
2928
|
-
const seen = new Set(options);
|
|
6309
|
+
/** Drop a milestone that the selected repository no longer lists. */
|
|
6310
|
+
async pruneMilestone(repo) {
|
|
2929
6311
|
const selected = this.snapshot.prefs.milestone;
|
|
2930
|
-
|
|
2931
|
-
|
|
2932
|
-
|
|
2933
|
-
|
|
2934
|
-
|
|
2935
|
-
options.push(title);
|
|
2936
|
-
changed = true;
|
|
2937
|
-
}
|
|
2938
|
-
if (selected !== void 0 && !seen.has(selected)) {
|
|
2939
|
-
options.unshift(selected);
|
|
2940
|
-
changed = true;
|
|
2941
|
-
}
|
|
2942
|
-
if (changed) this.update({ milestoneOptions: options });
|
|
6312
|
+
if (selected === void 0 || this.snapshot.prefs.repo !== repo) return;
|
|
6313
|
+
const options = this.snapshot.milestoneOptions;
|
|
6314
|
+
if (options.length === 0) return;
|
|
6315
|
+
if (options.some((option) => option.title === selected)) return;
|
|
6316
|
+
await this.savePrefs({ milestone: null });
|
|
2943
6317
|
}
|
|
2944
6318
|
/** Seed the picker from the selected repository's full milestone list. */
|
|
2945
6319
|
async loadRepoMilestones(repo) {
|
|
@@ -2948,11 +6322,11 @@ var GitHubStore = class {
|
|
|
2948
6322
|
const result = await remote.repoMilestones(repo).then((response) => unwrap(response));
|
|
2949
6323
|
if (this.snapshot.prefs.repo !== repo) return;
|
|
2950
6324
|
const options = [...this.snapshot.milestoneOptions];
|
|
2951
|
-
const seen = new Set(options);
|
|
2952
|
-
for (const
|
|
2953
|
-
if (title === "" || seen.has(title)) continue;
|
|
2954
|
-
seen.add(title);
|
|
2955
|
-
options.push(
|
|
6325
|
+
const seen = new Set(options.map((option) => option.title));
|
|
6326
|
+
for (const option of result.milestones) {
|
|
6327
|
+
if (option.title === "" || seen.has(option.title)) continue;
|
|
6328
|
+
seen.add(option.title);
|
|
6329
|
+
options.push(option);
|
|
2956
6330
|
}
|
|
2957
6331
|
this.update({ milestoneOptions: options });
|
|
2958
6332
|
} catch {
|
|
@@ -2969,18 +6343,20 @@ var GitHubStore = class {
|
|
|
2969
6343
|
void (async () => {
|
|
2970
6344
|
try {
|
|
2971
6345
|
const remote = await this.api();
|
|
2972
|
-
const
|
|
6346
|
+
const bodyLoading = remote.issueDetail(card.repo, card.number).then((result) => unwrap(result));
|
|
6347
|
+
const mentionedLoading = remote.issueMentionedPRs(card.repo, card.number).then((result) => unwrap(result)).then((result) => result.mentionedPRs, () => []);
|
|
6348
|
+
const body = await bodyLoading;
|
|
2973
6349
|
this.update({
|
|
2974
6350
|
detail: { ...card, body: body.body, mentionedPRs: [] },
|
|
2975
6351
|
detailLoading: false,
|
|
2976
6352
|
mentionedLoading: true
|
|
2977
6353
|
});
|
|
2978
|
-
const mentioned = await
|
|
6354
|
+
const mentioned = await mentionedLoading;
|
|
2979
6355
|
const current = this.snapshot.detail;
|
|
2980
6356
|
if (current === void 0 || current.repo !== card.repo || current.number !== card.number) return;
|
|
2981
6357
|
const closing = new Set(current.linkedPRs.map((pr) => pr.number));
|
|
2982
6358
|
this.update({
|
|
2983
|
-
detail: { ...current, mentionedPRs: mentioned.
|
|
6359
|
+
detail: { ...current, mentionedPRs: mentioned.filter((pr) => !closing.has(pr.number)) },
|
|
2984
6360
|
mentionedLoading: false
|
|
2985
6361
|
});
|
|
2986
6362
|
} catch (error) {
|
|
@@ -2992,20 +6368,42 @@ var GitHubStore = class {
|
|
|
2992
6368
|
this.update({ selected: void 0, detail: void 0, detailLoading: false, mentionedLoading: false });
|
|
2993
6369
|
}
|
|
2994
6370
|
async savePrefs(patch, after) {
|
|
6371
|
+
const previous = this.snapshot.prefs;
|
|
6372
|
+
const affectsList = ["org", "repo", "assignee", "state", "milestone"].some((key) => key in patch);
|
|
6373
|
+
this.update({ prefs: applyPrefsPatchLocally(previous, patch) });
|
|
6374
|
+
let saveError;
|
|
2995
6375
|
try {
|
|
2996
6376
|
const remote = await this.api();
|
|
2997
|
-
const
|
|
2998
|
-
const
|
|
6377
|
+
const save = remote.savePrefs(patch).then((result) => unwrap(result));
|
|
6378
|
+
const reload = affectsList ? this.reloadList() : Promise.resolve();
|
|
6379
|
+
const [saved] = await Promise.all([save, reload]);
|
|
2999
6380
|
this.update({ prefs: saved });
|
|
3000
|
-
if (affectsList)
|
|
3001
|
-
|
|
3002
|
-
this.refreshPinnedCard();
|
|
3003
|
-
} else if ("handoffMode" in patch || "promptTemplate" in patch) {
|
|
3004
|
-
this.toast("settings.saved");
|
|
3005
|
-
}
|
|
6381
|
+
if (affectsList) this.refreshPinnedCard();
|
|
6382
|
+
else if ("handoffMode" in patch || "promptTemplate" in patch) this.toast("settings.saved");
|
|
3006
6383
|
if (after !== void 0) await after(saved);
|
|
6384
|
+
} catch (error) {
|
|
6385
|
+
saveError = error;
|
|
6386
|
+
this.update({ prefs: previous, error: asPanelError(error) });
|
|
6387
|
+
}
|
|
6388
|
+
void saveError;
|
|
6389
|
+
}
|
|
6390
|
+
/**
|
|
6391
|
+
* Persist a preference patch without touching the list.
|
|
6392
|
+
*
|
|
6393
|
+
* Scope normalization (picking the default organization/repository) uses this
|
|
6394
|
+
* so bootstrapping issues exactly one list request instead of one per default.
|
|
6395
|
+
* @param patch - validated preference patch.
|
|
6396
|
+
* @returns the saved preferences, or `undefined` when persistence failed.
|
|
6397
|
+
*/
|
|
6398
|
+
async persistPrefs(patch) {
|
|
6399
|
+
try {
|
|
6400
|
+
const remote = await this.api();
|
|
6401
|
+
const saved = await remote.savePrefs(patch).then((result) => unwrap(result));
|
|
6402
|
+
this.update({ prefs: saved });
|
|
6403
|
+
return saved;
|
|
3007
6404
|
} catch (error) {
|
|
3008
6405
|
this.update({ error: asPanelError(error) });
|
|
6406
|
+
return void 0;
|
|
3009
6407
|
}
|
|
3010
6408
|
}
|
|
3011
6409
|
pin(card) {
|
|
@@ -3098,9 +6496,9 @@ var GitHubStore = class {
|
|
|
3098
6496
|
promptText(card) {
|
|
3099
6497
|
return renderPrompt(card, this.snapshot.prefs.promptTemplate);
|
|
3100
6498
|
}
|
|
3101
|
-
copyText(
|
|
6499
|
+
copyText(text2) {
|
|
3102
6500
|
try {
|
|
3103
|
-
void navigator.clipboard?.writeText(
|
|
6501
|
+
void navigator.clipboard?.writeText(text2);
|
|
3104
6502
|
} catch {
|
|
3105
6503
|
}
|
|
3106
6504
|
this.toast("panel.toast.copied");
|
|
@@ -3253,9 +6651,9 @@ var GitHubStore = class {
|
|
|
3253
6651
|
/** Insert one issue into the composer, per the configured handoff behavior. */
|
|
3254
6652
|
async insertIntoComposer(card, inputActions) {
|
|
3255
6653
|
if (inputActions === void 0) return;
|
|
3256
|
-
const
|
|
3257
|
-
if (
|
|
3258
|
-
inputActions.setDraft(
|
|
6654
|
+
const text2 = this.promptFor(card);
|
|
6655
|
+
if (text2 === "") return;
|
|
6656
|
+
inputActions.setDraft(text2);
|
|
3259
6657
|
if (this.snapshot.prefs.handoffMode === "send") inputActions.submit();
|
|
3260
6658
|
}
|
|
3261
6659
|
};
|
|
@@ -3265,7 +6663,7 @@ var PANEL_ID = "github";
|
|
|
3265
6663
|
var SETTINGS_ID = "github-issues";
|
|
3266
6664
|
var SIDEBAR_KIND2 = "github-issues";
|
|
3267
6665
|
var inject = ["slots", "locale", "remote"];
|
|
3268
|
-
function
|
|
6666
|
+
function apply3(ctx) {
|
|
3269
6667
|
ctx.effect(() => ctx.locale.register(NS, DICTS), "github-issues: dictionaries");
|
|
3270
6668
|
const t = ctx.locale.bind(NS);
|
|
3271
6669
|
const mounting = ctx.remote.$mount(remoteContribution()).then(
|