zignal-stencil-library 1.0.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/LICENSE +21 -0
- package/dist/cjs/app-globals-V2Kpy_OQ.js +8 -0
- package/dist/cjs/app-globals-V2Kpy_OQ.js.map +1 -0
- package/dist/cjs/autocomplete-select_18.cjs.entry.js +41433 -0
- package/dist/cjs/autocomplete-select_18.cjs.entry.js.map +1 -0
- package/dist/cjs/index-C4CtrJXU.js +2199 -0
- package/dist/cjs/index-C4CtrJXU.js.map +1 -0
- package/dist/cjs/index-tRPYdc8n.js +1927 -0
- package/dist/cjs/index-tRPYdc8n.js.map +1 -0
- package/dist/cjs/index.cjs.js +7 -0
- package/dist/cjs/index.cjs.js.map +1 -0
- package/dist/cjs/loader.cjs.js +16 -0
- package/dist/cjs/loader.cjs.js.map +1 -0
- package/dist/cjs/zignal-stencil-library.cjs.js +28 -0
- package/dist/cjs/zignal-stencil-library.cjs.js.map +1 -0
- package/dist/collection/api/index.js +132 -0
- package/dist/collection/api/index.js.map +1 -0
- package/dist/collection/collection-manifest.json +29 -0
- package/dist/collection/components/autocomplete-select/autocomplete-select.css +1 -0
- package/dist/collection/components/autocomplete-select/autocomplete-select.js +230 -0
- package/dist/collection/components/autocomplete-select/autocomplete-select.js.map +1 -0
- package/dist/collection/components/channel-box/channel-box.css +1 -0
- package/dist/collection/components/channel-box/channel-box.js +93 -0
- package/dist/collection/components/channel-box/channel-box.js.map +1 -0
- package/dist/collection/components/chat-app/chat-app.css +1 -0
- package/dist/collection/components/chat-app/chat-app.js +227 -0
- package/dist/collection/components/chat-app/chat-app.js.map +1 -0
- package/dist/collection/components/chat-header/chat-header.css +1 -0
- package/dist/collection/components/chat-header/chat-header.js +45 -0
- package/dist/collection/components/chat-header/chat-header.js.map +1 -0
- package/dist/collection/components/chat-input/chat-input.css +1 -0
- package/dist/collection/components/chat-input/chat-input.js +118 -0
- package/dist/collection/components/chat-input/chat-input.js.map +1 -0
- package/dist/collection/components/dialog-editor/dialog-editor.css +1 -0
- package/dist/collection/components/dialog-editor/dialog-editor.js +176 -0
- package/dist/collection/components/dialog-editor/dialog-editor.js.map +1 -0
- package/dist/collection/components/dialog-preview-media/dialog-preview-media.css +1 -0
- package/dist/collection/components/dialog-preview-media/dialog-preview-media.js +96 -0
- package/dist/collection/components/dialog-preview-media/dialog-preview-media.js.map +1 -0
- package/dist/collection/components/dialog-search/dialog-search.css +1 -0
- package/dist/collection/components/dialog-search/dialog-search.js +105 -0
- package/dist/collection/components/dialog-search/dialog-search.js.map +1 -0
- package/dist/collection/components/internal-component/chat-item.js +28 -0
- package/dist/collection/components/internal-component/chat-item.js.map +1 -0
- package/dist/collection/components/internal-component/icon.js +9 -0
- package/dist/collection/components/internal-component/icon.js.map +1 -0
- package/dist/collection/components/internal-component/tag-or-status-item.js +9 -0
- package/dist/collection/components/internal-component/tag-or-status-item.js.map +1 -0
- package/dist/collection/components/internal-component/z-button.js +24 -0
- package/dist/collection/components/internal-component/z-button.js.map +1 -0
- package/dist/collection/components/internal-component/z-icon-button.js +23 -0
- package/dist/collection/components/internal-component/z-icon-button.js.map +1 -0
- package/dist/collection/components/internal-component/z-input-area.js +8 -0
- package/dist/collection/components/internal-component/z-input-area.js.map +1 -0
- package/dist/collection/components/internal-component/z-input.js +8 -0
- package/dist/collection/components/internal-component/z-input.js.map +1 -0
- package/dist/collection/components/internal-component/z-select-input.js +9 -0
- package/dist/collection/components/internal-component/z-select-input.js.map +1 -0
- package/dist/collection/components/menu-list/menu-list.css +1 -0
- package/dist/collection/components/menu-list/menu-list.js +168 -0
- package/dist/collection/components/menu-list/menu-list.js.map +1 -0
- package/dist/collection/components/message-box/message-box.css +1 -0
- package/dist/collection/components/message-box/message-box.js +179 -0
- package/dist/collection/components/message-box/message-box.js.map +1 -0
- package/dist/collection/components/message-content/message-content.css +1 -0
- package/dist/collection/components/message-content/message-content.js +98 -0
- package/dist/collection/components/message-content/message-content.js.map +1 -0
- package/dist/collection/components/message-item/message-item.css +1 -0
- package/dist/collection/components/message-item/message-item.js +115 -0
- package/dist/collection/components/message-item/message-item.js.map +1 -0
- package/dist/collection/components/profile-history/profile-history.css +1 -0
- package/dist/collection/components/profile-history/profile-history.js +18 -0
- package/dist/collection/components/profile-history/profile-history.js.map +1 -0
- package/dist/collection/components/profile-info/profile-info.css +1 -0
- package/dist/collection/components/profile-info/profile-info.js +255 -0
- package/dist/collection/components/profile-info/profile-info.js.map +1 -0
- package/dist/collection/components/profile-media/profile-media.css +1 -0
- package/dist/collection/components/profile-media/profile-media.js +18 -0
- package/dist/collection/components/profile-media/profile-media.js.map +1 -0
- package/dist/collection/components/profile-tabs/profile-tabs.css +1 -0
- package/dist/collection/components/profile-tabs/profile-tabs.js +43 -0
- package/dist/collection/components/profile-tabs/profile-tabs.js.map +1 -0
- package/dist/collection/components/search-box/search-box.css +1 -0
- package/dist/collection/components/search-box/search-box.js +71 -0
- package/dist/collection/components/search-box/search-box.js.map +1 -0
- package/dist/collection/components/tag-popper/tag-popper.css +1 -0
- package/dist/collection/components/tag-popper/tag-popper.js +124 -0
- package/dist/collection/components/tag-popper/tag-popper.js.map +1 -0
- package/dist/collection/global/i18n.js +13 -0
- package/dist/collection/global/i18n.js.map +1 -0
- package/dist/collection/index.js +11 -0
- package/dist/collection/index.js.map +1 -0
- package/dist/collection/postcss/property-to-variable.js +54 -0
- package/dist/collection/store/store.js +25 -0
- package/dist/collection/store/store.js.map +1 -0
- package/dist/collection/utils/axios.js +11 -0
- package/dist/collection/utils/axios.js.map +1 -0
- package/dist/collection/utils/constant.js +5 -0
- package/dist/collection/utils/constant.js.map +1 -0
- package/dist/collection/utils/dayjs.js +175 -0
- package/dist/collection/utils/dayjs.js.map +1 -0
- package/dist/collection/utils/socket.js +59 -0
- package/dist/collection/utils/socket.js.map +1 -0
- package/dist/collection/utils/utils.js +8 -0
- package/dist/collection/utils/utils.js.map +1 -0
- package/dist/components/autocomplete-select.d.ts +11 -0
- package/dist/components/autocomplete-select.js +9 -0
- package/dist/components/autocomplete-select.js.map +1 -0
- package/dist/components/channel-box.d.ts +11 -0
- package/dist/components/channel-box.js +9 -0
- package/dist/components/channel-box.js.map +1 -0
- package/dist/components/chat-app.d.ts +11 -0
- package/dist/components/chat-app.js +226 -0
- package/dist/components/chat-app.js.map +1 -0
- package/dist/components/chat-header.d.ts +11 -0
- package/dist/components/chat-header.js +9 -0
- package/dist/components/chat-header.js.map +1 -0
- package/dist/components/chat-input.d.ts +11 -0
- package/dist/components/chat-input.js +9 -0
- package/dist/components/chat-input.js.map +1 -0
- package/dist/components/dialog-editor.d.ts +11 -0
- package/dist/components/dialog-editor.js +9 -0
- package/dist/components/dialog-editor.js.map +1 -0
- package/dist/components/dialog-preview-media.d.ts +11 -0
- package/dist/components/dialog-preview-media.js +9 -0
- package/dist/components/dialog-preview-media.js.map +1 -0
- package/dist/components/dialog-search.d.ts +11 -0
- package/dist/components/dialog-search.js +9 -0
- package/dist/components/dialog-search.js.map +1 -0
- package/dist/components/index.d.ts +33 -0
- package/dist/components/index.js +2199 -0
- package/dist/components/index.js.map +1 -0
- package/dist/components/menu-list.d.ts +11 -0
- package/dist/components/menu-list.js +9 -0
- package/dist/components/menu-list.js.map +1 -0
- package/dist/components/message-box.d.ts +11 -0
- package/dist/components/message-box.js +9 -0
- package/dist/components/message-box.js.map +1 -0
- package/dist/components/message-content.d.ts +11 -0
- package/dist/components/message-content.js +9 -0
- package/dist/components/message-content.js.map +1 -0
- package/dist/components/message-item.d.ts +11 -0
- package/dist/components/message-item.js +9 -0
- package/dist/components/message-item.js.map +1 -0
- package/dist/components/p-6xqe-pLQ.js +1509 -0
- package/dist/components/p-6xqe-pLQ.js.map +1 -0
- package/dist/components/p-B8jcXcXq.js +10 -0
- package/dist/components/p-B8jcXcXq.js.map +1 -0
- package/dist/components/p-BAxNTWPI.js +32 -0
- package/dist/components/p-BAxNTWPI.js.map +1 -0
- package/dist/components/p-BZ4TvILZ.js +24 -0
- package/dist/components/p-BZ4TvILZ.js.map +1 -0
- package/dist/components/p-BZ_KFdA7.js +99 -0
- package/dist/components/p-BZ_KFdA7.js.map +1 -0
- package/dist/components/p-BaEi6GXz.js +27448 -0
- package/dist/components/p-BaEi6GXz.js.map +1 -0
- package/dist/components/p-BcC6bTqM.js +104 -0
- package/dist/components/p-BcC6bTqM.js.map +1 -0
- package/dist/components/p-Beycm8NN.js +3027 -0
- package/dist/components/p-Beycm8NN.js.map +1 -0
- package/dist/components/p-Bf89k6bd.js +3932 -0
- package/dist/components/p-Bf89k6bd.js.map +1 -0
- package/dist/components/p-BtkLsQfZ.js +17 -0
- package/dist/components/p-BtkLsQfZ.js.map +1 -0
- package/dist/components/p-C9EokLnL.js +102 -0
- package/dist/components/p-C9EokLnL.js.map +1 -0
- package/dist/components/p-CHaS9akB.js +33 -0
- package/dist/components/p-CHaS9akB.js.map +1 -0
- package/dist/components/p-CQZRPVaY.js +1715 -0
- package/dist/components/p-CQZRPVaY.js.map +1 -0
- package/dist/components/p-CS8eN-II.js +60 -0
- package/dist/components/p-CS8eN-II.js.map +1 -0
- package/dist/components/p-CUmphmPD.js +48 -0
- package/dist/components/p-CUmphmPD.js.map +1 -0
- package/dist/components/p-ChdOg2lI.js +90 -0
- package/dist/components/p-ChdOg2lI.js.map +1 -0
- package/dist/components/p-CkqA8kPB.js +210 -0
- package/dist/components/p-CkqA8kPB.js.map +1 -0
- package/dist/components/p-CmWIRJ5t.js +91 -0
- package/dist/components/p-CmWIRJ5t.js.map +1 -0
- package/dist/components/p-CzESq-LE.js +88 -0
- package/dist/components/p-CzESq-LE.js.map +1 -0
- package/dist/components/p-DD3M-jE2.js +87 -0
- package/dist/components/p-DD3M-jE2.js.map +1 -0
- package/dist/components/p-DFjLV5Vy.js +71 -0
- package/dist/components/p-DFjLV5Vy.js.map +1 -0
- package/dist/components/p-DYI8iHdE.js +279 -0
- package/dist/components/p-DYI8iHdE.js.map +1 -0
- package/dist/components/p-DfRY75vS.js +16 -0
- package/dist/components/p-DfRY75vS.js.map +1 -0
- package/dist/components/p-DspEZ2pG.js +85 -0
- package/dist/components/p-DspEZ2pG.js.map +1 -0
- package/dist/components/p-LCZ_Vyoy.js +4084 -0
- package/dist/components/p-LCZ_Vyoy.js.map +1 -0
- package/dist/components/p-N-wb2wDd.js +236 -0
- package/dist/components/p-N-wb2wDd.js.map +1 -0
- package/dist/components/p-Urxy5c9-.js +154 -0
- package/dist/components/p-Urxy5c9-.js.map +1 -0
- package/dist/components/p-nz95LAGz.js +33 -0
- package/dist/components/p-nz95LAGz.js.map +1 -0
- package/dist/components/profile-history.d.ts +11 -0
- package/dist/components/profile-history.js +9 -0
- package/dist/components/profile-history.js.map +1 -0
- package/dist/components/profile-info.d.ts +11 -0
- package/dist/components/profile-info.js +9 -0
- package/dist/components/profile-info.js.map +1 -0
- package/dist/components/profile-media.d.ts +11 -0
- package/dist/components/profile-media.js +9 -0
- package/dist/components/profile-media.js.map +1 -0
- package/dist/components/profile-tabs.d.ts +11 -0
- package/dist/components/profile-tabs.js +9 -0
- package/dist/components/profile-tabs.js.map +1 -0
- package/dist/components/search-box.d.ts +11 -0
- package/dist/components/search-box.js +9 -0
- package/dist/components/search-box.js.map +1 -0
- package/dist/components/tag-popper.d.ts +11 -0
- package/dist/components/tag-popper.js +9 -0
- package/dist/components/tag-popper.js.map +1 -0
- package/dist/esm/app-globals-DQuL1Twl.js +6 -0
- package/dist/esm/app-globals-DQuL1Twl.js.map +1 -0
- package/dist/esm/autocomplete-select.channel-box.chat-app.chat-header.chat-input.dialog-editor.dialog-preview-media.dialog-search.menu-list.message-box.message-content.message-item.profile-history.profile-info.profile-media.profile-tabs.search-box.tag-popper.entry.js.map +1 -0
- package/dist/esm/autocomplete-select_18.entry.js +41414 -0
- package/dist/esm/autocomplete-select_18.entry.js.map +1 -0
- package/dist/esm/index-C0ey1F02.js +1917 -0
- package/dist/esm/index-C0ey1F02.js.map +1 -0
- package/dist/esm/index-DasOEma2.js +2197 -0
- package/dist/esm/index-DasOEma2.js.map +1 -0
- package/dist/esm/index.js +4 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/loader.js +14 -0
- package/dist/esm/loader.js.map +1 -0
- package/dist/esm/zignal-stencil-library.js +24 -0
- package/dist/esm/zignal-stencil-library.js.map +1 -0
- package/dist/index.cjs.js +1 -0
- package/dist/index.js +1 -0
- package/dist/types/api/index.d.ts +12 -0
- package/dist/types/api/index.type.d.ts +98 -0
- package/dist/types/components/autocomplete-select/autocomplete-select.d.ts +19 -0
- package/dist/types/components/channel-box/channel-box.d.ts +11 -0
- package/dist/types/components/chat-app/chat-app.d.ts +25 -0
- package/dist/types/components/chat-header/chat-header.d.ts +3 -0
- package/dist/types/components/chat-input/chat-input.d.ts +9 -0
- package/dist/types/components/dialog-editor/dialog-editor.d.ts +16 -0
- package/dist/types/components/dialog-preview-media/dialog-preview-media.d.ts +8 -0
- package/dist/types/components/dialog-search/dialog-search.d.ts +18 -0
- package/dist/types/components/internal-component/chat-item.d.ts +6 -0
- package/dist/types/components/internal-component/icon.d.ts +7 -0
- package/dist/types/components/internal-component/tag-or-status-item.d.ts +7 -0
- package/dist/types/components/internal-component/z-button.d.ts +15 -0
- package/dist/types/components/internal-component/z-icon-button.d.ts +13 -0
- package/dist/types/components/internal-component/z-input-area.d.ts +13 -0
- package/dist/types/components/internal-component/z-input.d.ts +13 -0
- package/dist/types/components/internal-component/z-select-input.d.ts +13 -0
- package/dist/types/components/menu-list/menu-list.d.ts +17 -0
- package/dist/types/components/message-box/message-box.d.ts +19 -0
- package/dist/types/components/message-content/message-content.d.ts +8 -0
- package/dist/types/components/message-item/message-item.d.ts +9 -0
- package/dist/types/components/profile-history/profile-history.d.ts +3 -0
- package/dist/types/components/profile-info/profile-info.d.ts +29 -0
- package/dist/types/components/profile-media/profile-media.d.ts +3 -0
- package/dist/types/components/profile-tabs/profile-tabs.d.ts +8 -0
- package/dist/types/components/search-box/search-box.d.ts +10 -0
- package/dist/types/components/tag-popper/tag-popper.d.ts +13 -0
- package/dist/types/components.d.ts +498 -0
- package/dist/types/global/i18n.d.ts +2 -0
- package/dist/types/index.d.ts +11 -0
- package/dist/types/stencil-public-runtime.d.ts +1709 -0
- package/dist/types/store/store.d.ts +16 -0
- package/dist/types/store/store.type.d.ts +132 -0
- package/dist/types/utils/axios.d.ts +1 -0
- package/dist/types/utils/constant.d.ts +1 -0
- package/dist/types/utils/dayjs.d.ts +31 -0
- package/dist/types/utils/socket.d.ts +6 -0
- package/dist/types/utils/utils.d.ts +2 -0
- package/dist/zignal-stencil-library/index.esm.js +2 -0
- package/dist/zignal-stencil-library/index.esm.js.map +1 -0
- package/dist/zignal-stencil-library/loader.esm.js.map +1 -0
- package/dist/zignal-stencil-library/p-C0ey1F02.js +3 -0
- package/dist/zignal-stencil-library/p-C0ey1F02.js.map +1 -0
- package/dist/zignal-stencil-library/p-DQuL1Twl.js +2 -0
- package/dist/zignal-stencil-library/p-DQuL1Twl.js.map +1 -0
- package/dist/zignal-stencil-library/p-DasOEma2.js +2 -0
- package/dist/zignal-stencil-library/p-DasOEma2.js.map +1 -0
- package/dist/zignal-stencil-library/p-ee2ebe92.entry.js +9777 -0
- package/dist/zignal-stencil-library/p-ee2ebe92.entry.js.map +1 -0
- package/dist/zignal-stencil-library/zignal-stencil-library.css +1 -0
- package/dist/zignal-stencil-library/zignal-stencil-library.esm.js +2 -0
- package/dist/zignal-stencil-library/zignal-stencil-library.esm.js.map +1 -0
- package/loader/cdn.js +1 -0
- package/loader/index.cjs.js +1 -0
- package/loader/index.d.ts +24 -0
- package/loader/index.es2017.js +1 -0
- package/loader/index.js +2 -0
- package/package.json +73 -0
|
@@ -0,0 +1,3027 @@
|
|
|
1
|
+
import { h, p as proxyCustomElement, H, c as createEvent, a as Host } from './p-CQZRPVaY.js';
|
|
2
|
+
import { c as configStore } from './p-N-wb2wDd.js';
|
|
3
|
+
import { Z as ZInput } from './p-DfRY75vS.js';
|
|
4
|
+
import { Z as ZButton } from './p-BAxNTWPI.js';
|
|
5
|
+
|
|
6
|
+
const ZInputArea = ({ id, label, placeholder = '', value = '', onChange, autoFocus, rows = 3, error }) => {
|
|
7
|
+
const theme = configStore.get('theme');
|
|
8
|
+
return (h("div", { class: "mb-4" },
|
|
9
|
+
h("label", { class: `block text-sm font-medium mb-1 z-text-${theme}` }, label),
|
|
10
|
+
h("textarea", { id: id, placeholder: placeholder, class: `w-full border z-border-${theme} text-sm px-4 py-2 rounded-lg ring-primary focus:outline-none focus:border-primary z-paper-${theme} z-text-${theme}`, value: value, onInput: (e) => onChange?.(e.target.value), autoFocus: autoFocus, rows: rows }),
|
|
11
|
+
error &&
|
|
12
|
+
h("p", { class: "text-red-500 text-xs mt-1" }, error)));
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
/** A special constant with type `never` */
|
|
16
|
+
function $constructor(name, initializer, params) {
|
|
17
|
+
function init(inst, def) {
|
|
18
|
+
var _a;
|
|
19
|
+
Object.defineProperty(inst, "_zod", {
|
|
20
|
+
value: inst._zod ?? {},
|
|
21
|
+
enumerable: false,
|
|
22
|
+
});
|
|
23
|
+
(_a = inst._zod).traits ?? (_a.traits = new Set());
|
|
24
|
+
inst._zod.traits.add(name);
|
|
25
|
+
initializer(inst, def);
|
|
26
|
+
// support prototype modifications
|
|
27
|
+
for (const k in _.prototype) {
|
|
28
|
+
if (!(k in inst))
|
|
29
|
+
Object.defineProperty(inst, k, { value: _.prototype[k].bind(inst) });
|
|
30
|
+
}
|
|
31
|
+
inst._zod.constr = _;
|
|
32
|
+
inst._zod.def = def;
|
|
33
|
+
}
|
|
34
|
+
// doesn't work if Parent has a constructor with arguments
|
|
35
|
+
const Parent = params?.Parent ?? Object;
|
|
36
|
+
class Definition extends Parent {
|
|
37
|
+
}
|
|
38
|
+
Object.defineProperty(Definition, "name", { value: name });
|
|
39
|
+
function _(def) {
|
|
40
|
+
var _a;
|
|
41
|
+
const inst = params?.Parent ? new Definition() : this;
|
|
42
|
+
init(inst, def);
|
|
43
|
+
(_a = inst._zod).deferred ?? (_a.deferred = []);
|
|
44
|
+
for (const fn of inst._zod.deferred) {
|
|
45
|
+
fn();
|
|
46
|
+
}
|
|
47
|
+
return inst;
|
|
48
|
+
}
|
|
49
|
+
Object.defineProperty(_, "init", { value: init });
|
|
50
|
+
Object.defineProperty(_, Symbol.hasInstance, {
|
|
51
|
+
value: (inst) => {
|
|
52
|
+
if (params?.Parent && inst instanceof params.Parent)
|
|
53
|
+
return true;
|
|
54
|
+
return inst?._zod?.traits?.has(name);
|
|
55
|
+
},
|
|
56
|
+
});
|
|
57
|
+
Object.defineProperty(_, "name", { value: name });
|
|
58
|
+
return _;
|
|
59
|
+
}
|
|
60
|
+
class $ZodAsyncError extends Error {
|
|
61
|
+
constructor() {
|
|
62
|
+
super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
const globalConfig = {};
|
|
66
|
+
function config(newConfig) {
|
|
67
|
+
return globalConfig;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// functions
|
|
71
|
+
function getEnumValues(entries) {
|
|
72
|
+
const numericValues = Object.values(entries).filter((v) => typeof v === "number");
|
|
73
|
+
const values = Object.entries(entries)
|
|
74
|
+
.filter(([k, _]) => numericValues.indexOf(+k) === -1)
|
|
75
|
+
.map(([_, v]) => v);
|
|
76
|
+
return values;
|
|
77
|
+
}
|
|
78
|
+
function jsonStringifyReplacer(_, value) {
|
|
79
|
+
if (typeof value === "bigint")
|
|
80
|
+
return value.toString();
|
|
81
|
+
return value;
|
|
82
|
+
}
|
|
83
|
+
function cached(getter) {
|
|
84
|
+
return {
|
|
85
|
+
get value() {
|
|
86
|
+
{
|
|
87
|
+
const value = getter();
|
|
88
|
+
Object.defineProperty(this, "value", { value });
|
|
89
|
+
return value;
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
function nullish(input) {
|
|
95
|
+
return input === null || input === undefined;
|
|
96
|
+
}
|
|
97
|
+
function cleanRegex(source) {
|
|
98
|
+
const start = source.startsWith("^") ? 1 : 0;
|
|
99
|
+
const end = source.endsWith("$") ? source.length - 1 : source.length;
|
|
100
|
+
return source.slice(start, end);
|
|
101
|
+
}
|
|
102
|
+
const EVALUATING = Symbol("evaluating");
|
|
103
|
+
function defineLazy(object, key, getter) {
|
|
104
|
+
let value = undefined;
|
|
105
|
+
Object.defineProperty(object, key, {
|
|
106
|
+
get() {
|
|
107
|
+
if (value === EVALUATING) {
|
|
108
|
+
// Circular reference detected, return undefined to break the cycle
|
|
109
|
+
return undefined;
|
|
110
|
+
}
|
|
111
|
+
if (value === undefined) {
|
|
112
|
+
value = EVALUATING;
|
|
113
|
+
value = getter();
|
|
114
|
+
}
|
|
115
|
+
return value;
|
|
116
|
+
},
|
|
117
|
+
set(v) {
|
|
118
|
+
Object.defineProperty(object, key, {
|
|
119
|
+
value: v,
|
|
120
|
+
// configurable: true,
|
|
121
|
+
});
|
|
122
|
+
// object[key] = v;
|
|
123
|
+
},
|
|
124
|
+
configurable: true,
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
function objectClone(obj) {
|
|
128
|
+
return Object.create(Object.getPrototypeOf(obj), Object.getOwnPropertyDescriptors(obj));
|
|
129
|
+
}
|
|
130
|
+
function assignProp(target, prop, value) {
|
|
131
|
+
Object.defineProperty(target, prop, {
|
|
132
|
+
value,
|
|
133
|
+
writable: true,
|
|
134
|
+
enumerable: true,
|
|
135
|
+
configurable: true,
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
function mergeDefs(...defs) {
|
|
139
|
+
const mergedDescriptors = {};
|
|
140
|
+
for (const def of defs) {
|
|
141
|
+
const descriptors = Object.getOwnPropertyDescriptors(def);
|
|
142
|
+
Object.assign(mergedDescriptors, descriptors);
|
|
143
|
+
}
|
|
144
|
+
return Object.defineProperties({}, mergedDescriptors);
|
|
145
|
+
}
|
|
146
|
+
function esc(str) {
|
|
147
|
+
return JSON.stringify(str);
|
|
148
|
+
}
|
|
149
|
+
const captureStackTrace = ("captureStackTrace" in Error ? Error.captureStackTrace : (..._args) => { });
|
|
150
|
+
function isObject(data) {
|
|
151
|
+
return typeof data === "object" && data !== null && !Array.isArray(data);
|
|
152
|
+
}
|
|
153
|
+
const allowsEval = cached(() => {
|
|
154
|
+
// @ts-ignore
|
|
155
|
+
if (typeof navigator !== "undefined" && navigator?.userAgent?.includes("Cloudflare")) {
|
|
156
|
+
return false;
|
|
157
|
+
}
|
|
158
|
+
try {
|
|
159
|
+
const F = Function;
|
|
160
|
+
new F("");
|
|
161
|
+
return true;
|
|
162
|
+
}
|
|
163
|
+
catch (_) {
|
|
164
|
+
return false;
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
function isPlainObject(o) {
|
|
168
|
+
if (isObject(o) === false)
|
|
169
|
+
return false;
|
|
170
|
+
// modified constructor
|
|
171
|
+
const ctor = o.constructor;
|
|
172
|
+
if (ctor === undefined)
|
|
173
|
+
return true;
|
|
174
|
+
// modified prototype
|
|
175
|
+
const prot = ctor.prototype;
|
|
176
|
+
if (isObject(prot) === false)
|
|
177
|
+
return false;
|
|
178
|
+
// ctor doesn't have static `isPrototypeOf`
|
|
179
|
+
if (Object.prototype.hasOwnProperty.call(prot, "isPrototypeOf") === false) {
|
|
180
|
+
return false;
|
|
181
|
+
}
|
|
182
|
+
return true;
|
|
183
|
+
}
|
|
184
|
+
const propertyKeyTypes = new Set(["string", "number", "symbol"]);
|
|
185
|
+
function escapeRegex(str) {
|
|
186
|
+
return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
187
|
+
}
|
|
188
|
+
// zod-specific utils
|
|
189
|
+
function clone(inst, def, params) {
|
|
190
|
+
const cl = new inst._zod.constr(def ?? inst._zod.def);
|
|
191
|
+
if (!def || params?.parent)
|
|
192
|
+
cl._zod.parent = inst;
|
|
193
|
+
return cl;
|
|
194
|
+
}
|
|
195
|
+
function normalizeParams(_params) {
|
|
196
|
+
const params = _params;
|
|
197
|
+
if (!params)
|
|
198
|
+
return {};
|
|
199
|
+
if (typeof params === "string")
|
|
200
|
+
return { error: () => params };
|
|
201
|
+
if (params?.message !== undefined) {
|
|
202
|
+
if (params?.error !== undefined)
|
|
203
|
+
throw new Error("Cannot specify both `message` and `error` params");
|
|
204
|
+
params.error = params.message;
|
|
205
|
+
}
|
|
206
|
+
delete params.message;
|
|
207
|
+
if (typeof params.error === "string")
|
|
208
|
+
return { ...params, error: () => params.error };
|
|
209
|
+
return params;
|
|
210
|
+
}
|
|
211
|
+
function optionalKeys(shape) {
|
|
212
|
+
return Object.keys(shape).filter((k) => {
|
|
213
|
+
return shape[k]._zod.optin === "optional" && shape[k]._zod.optout === "optional";
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
function pick(schema, mask) {
|
|
217
|
+
const currDef = schema._zod.def;
|
|
218
|
+
const def = mergeDefs(schema._zod.def, {
|
|
219
|
+
get shape() {
|
|
220
|
+
const newShape = {};
|
|
221
|
+
for (const key in mask) {
|
|
222
|
+
if (!(key in currDef.shape)) {
|
|
223
|
+
throw new Error(`Unrecognized key: "${key}"`);
|
|
224
|
+
}
|
|
225
|
+
if (!mask[key])
|
|
226
|
+
continue;
|
|
227
|
+
newShape[key] = currDef.shape[key];
|
|
228
|
+
}
|
|
229
|
+
assignProp(this, "shape", newShape); // self-caching
|
|
230
|
+
return newShape;
|
|
231
|
+
},
|
|
232
|
+
checks: [],
|
|
233
|
+
});
|
|
234
|
+
return clone(schema, def);
|
|
235
|
+
}
|
|
236
|
+
function omit(schema, mask) {
|
|
237
|
+
const currDef = schema._zod.def;
|
|
238
|
+
const def = mergeDefs(schema._zod.def, {
|
|
239
|
+
get shape() {
|
|
240
|
+
const newShape = { ...schema._zod.def.shape };
|
|
241
|
+
for (const key in mask) {
|
|
242
|
+
if (!(key in currDef.shape)) {
|
|
243
|
+
throw new Error(`Unrecognized key: "${key}"`);
|
|
244
|
+
}
|
|
245
|
+
if (!mask[key])
|
|
246
|
+
continue;
|
|
247
|
+
delete newShape[key];
|
|
248
|
+
}
|
|
249
|
+
assignProp(this, "shape", newShape); // self-caching
|
|
250
|
+
return newShape;
|
|
251
|
+
},
|
|
252
|
+
checks: [],
|
|
253
|
+
});
|
|
254
|
+
return clone(schema, def);
|
|
255
|
+
}
|
|
256
|
+
function extend(schema, shape) {
|
|
257
|
+
if (!isPlainObject(shape)) {
|
|
258
|
+
throw new Error("Invalid input to extend: expected a plain object");
|
|
259
|
+
}
|
|
260
|
+
const def = mergeDefs(schema._zod.def, {
|
|
261
|
+
get shape() {
|
|
262
|
+
const _shape = { ...schema._zod.def.shape, ...shape };
|
|
263
|
+
assignProp(this, "shape", _shape); // self-caching
|
|
264
|
+
return _shape;
|
|
265
|
+
},
|
|
266
|
+
checks: [],
|
|
267
|
+
});
|
|
268
|
+
return clone(schema, def);
|
|
269
|
+
}
|
|
270
|
+
function merge(a, b) {
|
|
271
|
+
const def = mergeDefs(a._zod.def, {
|
|
272
|
+
get shape() {
|
|
273
|
+
const _shape = { ...a._zod.def.shape, ...b._zod.def.shape };
|
|
274
|
+
assignProp(this, "shape", _shape); // self-caching
|
|
275
|
+
return _shape;
|
|
276
|
+
},
|
|
277
|
+
get catchall() {
|
|
278
|
+
return b._zod.def.catchall;
|
|
279
|
+
},
|
|
280
|
+
checks: [], // delete existing checks
|
|
281
|
+
});
|
|
282
|
+
return clone(a, def);
|
|
283
|
+
}
|
|
284
|
+
function partial(Class, schema, mask) {
|
|
285
|
+
const def = mergeDefs(schema._zod.def, {
|
|
286
|
+
get shape() {
|
|
287
|
+
const oldShape = schema._zod.def.shape;
|
|
288
|
+
const shape = { ...oldShape };
|
|
289
|
+
if (mask) {
|
|
290
|
+
for (const key in mask) {
|
|
291
|
+
if (!(key in oldShape)) {
|
|
292
|
+
throw new Error(`Unrecognized key: "${key}"`);
|
|
293
|
+
}
|
|
294
|
+
if (!mask[key])
|
|
295
|
+
continue;
|
|
296
|
+
// if (oldShape[key]!._zod.optin === "optional") continue;
|
|
297
|
+
shape[key] = Class
|
|
298
|
+
? new Class({
|
|
299
|
+
type: "optional",
|
|
300
|
+
innerType: oldShape[key],
|
|
301
|
+
})
|
|
302
|
+
: oldShape[key];
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
else {
|
|
306
|
+
for (const key in oldShape) {
|
|
307
|
+
// if (oldShape[key]!._zod.optin === "optional") continue;
|
|
308
|
+
shape[key] = Class
|
|
309
|
+
? new Class({
|
|
310
|
+
type: "optional",
|
|
311
|
+
innerType: oldShape[key],
|
|
312
|
+
})
|
|
313
|
+
: oldShape[key];
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
assignProp(this, "shape", shape); // self-caching
|
|
317
|
+
return shape;
|
|
318
|
+
},
|
|
319
|
+
checks: [],
|
|
320
|
+
});
|
|
321
|
+
return clone(schema, def);
|
|
322
|
+
}
|
|
323
|
+
function required(Class, schema, mask) {
|
|
324
|
+
const def = mergeDefs(schema._zod.def, {
|
|
325
|
+
get shape() {
|
|
326
|
+
const oldShape = schema._zod.def.shape;
|
|
327
|
+
const shape = { ...oldShape };
|
|
328
|
+
if (mask) {
|
|
329
|
+
for (const key in mask) {
|
|
330
|
+
if (!(key in shape)) {
|
|
331
|
+
throw new Error(`Unrecognized key: "${key}"`);
|
|
332
|
+
}
|
|
333
|
+
if (!mask[key])
|
|
334
|
+
continue;
|
|
335
|
+
// overwrite with non-optional
|
|
336
|
+
shape[key] = new Class({
|
|
337
|
+
type: "nonoptional",
|
|
338
|
+
innerType: oldShape[key],
|
|
339
|
+
});
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
else {
|
|
343
|
+
for (const key in oldShape) {
|
|
344
|
+
// overwrite with non-optional
|
|
345
|
+
shape[key] = new Class({
|
|
346
|
+
type: "nonoptional",
|
|
347
|
+
innerType: oldShape[key],
|
|
348
|
+
});
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
assignProp(this, "shape", shape); // self-caching
|
|
352
|
+
return shape;
|
|
353
|
+
},
|
|
354
|
+
checks: [],
|
|
355
|
+
});
|
|
356
|
+
return clone(schema, def);
|
|
357
|
+
}
|
|
358
|
+
// invalid_type | too_big | too_small | invalid_format | not_multiple_of | unrecognized_keys | invalid_union | invalid_key | invalid_element | invalid_value | custom
|
|
359
|
+
function aborted(x, startIndex = 0) {
|
|
360
|
+
for (let i = startIndex; i < x.issues.length; i++) {
|
|
361
|
+
if (x.issues[i]?.continue !== true) {
|
|
362
|
+
return true;
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
return false;
|
|
366
|
+
}
|
|
367
|
+
function prefixIssues(path, issues) {
|
|
368
|
+
return issues.map((iss) => {
|
|
369
|
+
var _a;
|
|
370
|
+
(_a = iss).path ?? (_a.path = []);
|
|
371
|
+
iss.path.unshift(path);
|
|
372
|
+
return iss;
|
|
373
|
+
});
|
|
374
|
+
}
|
|
375
|
+
function unwrapMessage(message) {
|
|
376
|
+
return typeof message === "string" ? message : message?.message;
|
|
377
|
+
}
|
|
378
|
+
function finalizeIssue(iss, ctx, config) {
|
|
379
|
+
const full = { ...iss, path: iss.path ?? [] };
|
|
380
|
+
// for backwards compatibility
|
|
381
|
+
if (!iss.message) {
|
|
382
|
+
const message = unwrapMessage(iss.inst?._zod.def?.error?.(iss)) ??
|
|
383
|
+
unwrapMessage(ctx?.error?.(iss)) ??
|
|
384
|
+
unwrapMessage(config.customError?.(iss)) ??
|
|
385
|
+
unwrapMessage(config.localeError?.(iss)) ??
|
|
386
|
+
"Invalid input";
|
|
387
|
+
full.message = message;
|
|
388
|
+
}
|
|
389
|
+
// delete (full as any).def;
|
|
390
|
+
delete full.inst;
|
|
391
|
+
delete full.continue;
|
|
392
|
+
if (!ctx?.reportInput) {
|
|
393
|
+
delete full.input;
|
|
394
|
+
}
|
|
395
|
+
return full;
|
|
396
|
+
}
|
|
397
|
+
function getLengthableOrigin(input) {
|
|
398
|
+
if (Array.isArray(input))
|
|
399
|
+
return "array";
|
|
400
|
+
if (typeof input === "string")
|
|
401
|
+
return "string";
|
|
402
|
+
return "unknown";
|
|
403
|
+
}
|
|
404
|
+
function issue(...args) {
|
|
405
|
+
const [iss, input, inst] = args;
|
|
406
|
+
if (typeof iss === "string") {
|
|
407
|
+
return {
|
|
408
|
+
message: iss,
|
|
409
|
+
code: "custom",
|
|
410
|
+
input,
|
|
411
|
+
inst,
|
|
412
|
+
};
|
|
413
|
+
}
|
|
414
|
+
return { ...iss };
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
const initializer$1 = (inst, def) => {
|
|
418
|
+
inst.name = "$ZodError";
|
|
419
|
+
Object.defineProperty(inst, "_zod", {
|
|
420
|
+
value: inst._zod,
|
|
421
|
+
enumerable: false,
|
|
422
|
+
});
|
|
423
|
+
Object.defineProperty(inst, "issues", {
|
|
424
|
+
value: def,
|
|
425
|
+
enumerable: false,
|
|
426
|
+
});
|
|
427
|
+
inst.message = JSON.stringify(def, jsonStringifyReplacer, 2);
|
|
428
|
+
Object.defineProperty(inst, "toString", {
|
|
429
|
+
value: () => inst.message,
|
|
430
|
+
enumerable: false,
|
|
431
|
+
});
|
|
432
|
+
};
|
|
433
|
+
const $ZodError = $constructor("$ZodError", initializer$1);
|
|
434
|
+
const $ZodRealError = $constructor("$ZodError", initializer$1, { Parent: Error });
|
|
435
|
+
function flattenError(error, mapper = (issue) => issue.message) {
|
|
436
|
+
const fieldErrors = {};
|
|
437
|
+
const formErrors = [];
|
|
438
|
+
for (const sub of error.issues) {
|
|
439
|
+
if (sub.path.length > 0) {
|
|
440
|
+
fieldErrors[sub.path[0]] = fieldErrors[sub.path[0]] || [];
|
|
441
|
+
fieldErrors[sub.path[0]].push(mapper(sub));
|
|
442
|
+
}
|
|
443
|
+
else {
|
|
444
|
+
formErrors.push(mapper(sub));
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
return { formErrors, fieldErrors };
|
|
448
|
+
}
|
|
449
|
+
function formatError(error, _mapper) {
|
|
450
|
+
const mapper = _mapper ||
|
|
451
|
+
function (issue) {
|
|
452
|
+
return issue.message;
|
|
453
|
+
};
|
|
454
|
+
const fieldErrors = { _errors: [] };
|
|
455
|
+
const processError = (error) => {
|
|
456
|
+
for (const issue of error.issues) {
|
|
457
|
+
if (issue.code === "invalid_union" && issue.errors.length) {
|
|
458
|
+
issue.errors.map((issues) => processError({ issues }));
|
|
459
|
+
}
|
|
460
|
+
else if (issue.code === "invalid_key") {
|
|
461
|
+
processError({ issues: issue.issues });
|
|
462
|
+
}
|
|
463
|
+
else if (issue.code === "invalid_element") {
|
|
464
|
+
processError({ issues: issue.issues });
|
|
465
|
+
}
|
|
466
|
+
else if (issue.path.length === 0) {
|
|
467
|
+
fieldErrors._errors.push(mapper(issue));
|
|
468
|
+
}
|
|
469
|
+
else {
|
|
470
|
+
let curr = fieldErrors;
|
|
471
|
+
let i = 0;
|
|
472
|
+
while (i < issue.path.length) {
|
|
473
|
+
const el = issue.path[i];
|
|
474
|
+
const terminal = i === issue.path.length - 1;
|
|
475
|
+
if (!terminal) {
|
|
476
|
+
curr[el] = curr[el] || { _errors: [] };
|
|
477
|
+
}
|
|
478
|
+
else {
|
|
479
|
+
curr[el] = curr[el] || { _errors: [] };
|
|
480
|
+
curr[el]._errors.push(mapper(issue));
|
|
481
|
+
}
|
|
482
|
+
curr = curr[el];
|
|
483
|
+
i++;
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
};
|
|
488
|
+
processError(error);
|
|
489
|
+
return fieldErrors;
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
const _parse = (_Err) => (schema, value, _ctx, _params) => {
|
|
493
|
+
const ctx = _ctx ? Object.assign(_ctx, { async: false }) : { async: false };
|
|
494
|
+
const result = schema._zod.run({ value, issues: [] }, ctx);
|
|
495
|
+
if (result instanceof Promise) {
|
|
496
|
+
throw new $ZodAsyncError();
|
|
497
|
+
}
|
|
498
|
+
if (result.issues.length) {
|
|
499
|
+
const e = new (_params?.Err ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
|
|
500
|
+
captureStackTrace(e, _params?.callee);
|
|
501
|
+
throw e;
|
|
502
|
+
}
|
|
503
|
+
return result.value;
|
|
504
|
+
};
|
|
505
|
+
const _parseAsync = (_Err) => async (schema, value, _ctx, params) => {
|
|
506
|
+
const ctx = _ctx ? Object.assign(_ctx, { async: true }) : { async: true };
|
|
507
|
+
let result = schema._zod.run({ value, issues: [] }, ctx);
|
|
508
|
+
if (result instanceof Promise)
|
|
509
|
+
result = await result;
|
|
510
|
+
if (result.issues.length) {
|
|
511
|
+
const e = new (params?.Err ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
|
|
512
|
+
captureStackTrace(e, params?.callee);
|
|
513
|
+
throw e;
|
|
514
|
+
}
|
|
515
|
+
return result.value;
|
|
516
|
+
};
|
|
517
|
+
const _safeParse = (_Err) => (schema, value, _ctx) => {
|
|
518
|
+
const ctx = _ctx ? { ..._ctx, async: false } : { async: false };
|
|
519
|
+
const result = schema._zod.run({ value, issues: [] }, ctx);
|
|
520
|
+
if (result instanceof Promise) {
|
|
521
|
+
throw new $ZodAsyncError();
|
|
522
|
+
}
|
|
523
|
+
return result.issues.length
|
|
524
|
+
? {
|
|
525
|
+
success: false,
|
|
526
|
+
error: new (_Err ?? $ZodError)(result.issues.map((iss) => finalizeIssue(iss, ctx, config()))),
|
|
527
|
+
}
|
|
528
|
+
: { success: true, data: result.value };
|
|
529
|
+
};
|
|
530
|
+
const safeParse$1 = /* @__PURE__*/ _safeParse($ZodRealError);
|
|
531
|
+
const _safeParseAsync = (_Err) => async (schema, value, _ctx) => {
|
|
532
|
+
const ctx = _ctx ? Object.assign(_ctx, { async: true }) : { async: true };
|
|
533
|
+
let result = schema._zod.run({ value, issues: [] }, ctx);
|
|
534
|
+
if (result instanceof Promise)
|
|
535
|
+
result = await result;
|
|
536
|
+
return result.issues.length
|
|
537
|
+
? {
|
|
538
|
+
success: false,
|
|
539
|
+
error: new _Err(result.issues.map((iss) => finalizeIssue(iss, ctx, config()))),
|
|
540
|
+
}
|
|
541
|
+
: { success: true, data: result.value };
|
|
542
|
+
};
|
|
543
|
+
const safeParseAsync$1 = /* @__PURE__*/ _safeParseAsync($ZodRealError);
|
|
544
|
+
|
|
545
|
+
const cuid = /^[cC][^\s-]{8,}$/;
|
|
546
|
+
const cuid2 = /^[0-9a-z]+$/;
|
|
547
|
+
const ulid = /^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/;
|
|
548
|
+
const xid = /^[0-9a-vA-V]{20}$/;
|
|
549
|
+
const ksuid = /^[A-Za-z0-9]{27}$/;
|
|
550
|
+
const nanoid = /^[a-zA-Z0-9_-]{21}$/;
|
|
551
|
+
/** ISO 8601-1 duration regex. Does not support the 8601-2 extensions like negative durations or fractional/negative components. */
|
|
552
|
+
const duration$1 = /^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;
|
|
553
|
+
/** A regex for any UUID-like identifier: 8-4-4-4-12 hex pattern */
|
|
554
|
+
const guid = /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/;
|
|
555
|
+
/** Returns a regex for validating an RFC 9562/4122 UUID.
|
|
556
|
+
*
|
|
557
|
+
* @param version Optionally specify a version 1-8. If no version is specified, all versions are supported. */
|
|
558
|
+
const uuid = (version) => {
|
|
559
|
+
if (!version)
|
|
560
|
+
return /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000)$/;
|
|
561
|
+
return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${version}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`);
|
|
562
|
+
};
|
|
563
|
+
/** Practical email validation */
|
|
564
|
+
const email$1 = /^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;
|
|
565
|
+
// from https://thekevinscott.com/emojis-in-javascript/#writing-a-regular-expression
|
|
566
|
+
const _emoji$1 = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
|
|
567
|
+
function emoji() {
|
|
568
|
+
return new RegExp(_emoji$1, "u");
|
|
569
|
+
}
|
|
570
|
+
const ipv4 = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/;
|
|
571
|
+
const ipv6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})$/;
|
|
572
|
+
const cidrv4 = /^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/;
|
|
573
|
+
const cidrv6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/;
|
|
574
|
+
// https://stackoverflow.com/questions/7860392/determine-if-string-is-in-base64-using-javascript
|
|
575
|
+
const base64 = /^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/;
|
|
576
|
+
const base64url = /^[A-Za-z0-9_-]*$/;
|
|
577
|
+
// based on https://stackoverflow.com/questions/106179/regular-expression-to-match-dns-hostname-or-ip-address
|
|
578
|
+
// export const hostname: RegExp = /^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+$/;
|
|
579
|
+
const hostname = /^(?=.{1,253}\.?$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[-0-9a-zA-Z]{0,61}[0-9a-zA-Z])?)*\.?$/;
|
|
580
|
+
// https://blog.stevenlevithan.com/archives/validate-phone-number#r4-3 (regex sans spaces)
|
|
581
|
+
const e164 = /^\+(?:[0-9]){6,14}[0-9]$/;
|
|
582
|
+
// const dateSource = `((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))`;
|
|
583
|
+
const dateSource = `(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`;
|
|
584
|
+
const date$1 = /*@__PURE__*/ new RegExp(`^${dateSource}$`);
|
|
585
|
+
function timeSource(args) {
|
|
586
|
+
const hhmm = `(?:[01]\\d|2[0-3]):[0-5]\\d`;
|
|
587
|
+
const regex = typeof args.precision === "number"
|
|
588
|
+
? args.precision === -1
|
|
589
|
+
? `${hhmm}`
|
|
590
|
+
: args.precision === 0
|
|
591
|
+
? `${hhmm}:[0-5]\\d`
|
|
592
|
+
: `${hhmm}:[0-5]\\d\\.\\d{${args.precision}}`
|
|
593
|
+
: `${hhmm}(?::[0-5]\\d(?:\\.\\d+)?)?`;
|
|
594
|
+
return regex;
|
|
595
|
+
}
|
|
596
|
+
function time$1(args) {
|
|
597
|
+
return new RegExp(`^${timeSource(args)}$`);
|
|
598
|
+
}
|
|
599
|
+
// Adapted from https://stackoverflow.com/a/3143231
|
|
600
|
+
function datetime$1(args) {
|
|
601
|
+
const time = timeSource({ precision: args.precision });
|
|
602
|
+
const opts = ["Z"];
|
|
603
|
+
if (args.local)
|
|
604
|
+
opts.push("");
|
|
605
|
+
// if (args.offset) opts.push(`([+-]\\d{2}:\\d{2})`);
|
|
606
|
+
if (args.offset)
|
|
607
|
+
opts.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);
|
|
608
|
+
const timeRegex = `${time}(?:${opts.join("|")})`;
|
|
609
|
+
return new RegExp(`^${dateSource}T(?:${timeRegex})$`);
|
|
610
|
+
}
|
|
611
|
+
const string$1 = (params) => {
|
|
612
|
+
const regex = params ? `[\\s\\S]{${params?.minimum ?? 0},${params?.maximum ?? ""}}` : `[\\s\\S]*`;
|
|
613
|
+
return new RegExp(`^${regex}$`);
|
|
614
|
+
};
|
|
615
|
+
// regex for string with no uppercase letters
|
|
616
|
+
const lowercase = /^[^A-Z]*$/;
|
|
617
|
+
// regex for string with no lowercase letters
|
|
618
|
+
const uppercase = /^[^a-z]*$/;
|
|
619
|
+
|
|
620
|
+
// import { $ZodType } from "./schemas.js";
|
|
621
|
+
const $ZodCheck = /*@__PURE__*/ $constructor("$ZodCheck", (inst, def) => {
|
|
622
|
+
var _a;
|
|
623
|
+
inst._zod ?? (inst._zod = {});
|
|
624
|
+
inst._zod.def = def;
|
|
625
|
+
(_a = inst._zod).onattach ?? (_a.onattach = []);
|
|
626
|
+
});
|
|
627
|
+
const $ZodCheckMaxLength = /*@__PURE__*/ $constructor("$ZodCheckMaxLength", (inst, def) => {
|
|
628
|
+
var _a;
|
|
629
|
+
$ZodCheck.init(inst, def);
|
|
630
|
+
(_a = inst._zod.def).when ?? (_a.when = (payload) => {
|
|
631
|
+
const val = payload.value;
|
|
632
|
+
return !nullish(val) && val.length !== undefined;
|
|
633
|
+
});
|
|
634
|
+
inst._zod.onattach.push((inst) => {
|
|
635
|
+
const curr = (inst._zod.bag.maximum ?? Number.POSITIVE_INFINITY);
|
|
636
|
+
if (def.maximum < curr)
|
|
637
|
+
inst._zod.bag.maximum = def.maximum;
|
|
638
|
+
});
|
|
639
|
+
inst._zod.check = (payload) => {
|
|
640
|
+
const input = payload.value;
|
|
641
|
+
const length = input.length;
|
|
642
|
+
if (length <= def.maximum)
|
|
643
|
+
return;
|
|
644
|
+
const origin = getLengthableOrigin(input);
|
|
645
|
+
payload.issues.push({
|
|
646
|
+
origin,
|
|
647
|
+
code: "too_big",
|
|
648
|
+
maximum: def.maximum,
|
|
649
|
+
inclusive: true,
|
|
650
|
+
input,
|
|
651
|
+
inst,
|
|
652
|
+
continue: !def.abort,
|
|
653
|
+
});
|
|
654
|
+
};
|
|
655
|
+
});
|
|
656
|
+
const $ZodCheckMinLength = /*@__PURE__*/ $constructor("$ZodCheckMinLength", (inst, def) => {
|
|
657
|
+
var _a;
|
|
658
|
+
$ZodCheck.init(inst, def);
|
|
659
|
+
(_a = inst._zod.def).when ?? (_a.when = (payload) => {
|
|
660
|
+
const val = payload.value;
|
|
661
|
+
return !nullish(val) && val.length !== undefined;
|
|
662
|
+
});
|
|
663
|
+
inst._zod.onattach.push((inst) => {
|
|
664
|
+
const curr = (inst._zod.bag.minimum ?? Number.NEGATIVE_INFINITY);
|
|
665
|
+
if (def.minimum > curr)
|
|
666
|
+
inst._zod.bag.minimum = def.minimum;
|
|
667
|
+
});
|
|
668
|
+
inst._zod.check = (payload) => {
|
|
669
|
+
const input = payload.value;
|
|
670
|
+
const length = input.length;
|
|
671
|
+
if (length >= def.minimum)
|
|
672
|
+
return;
|
|
673
|
+
const origin = getLengthableOrigin(input);
|
|
674
|
+
payload.issues.push({
|
|
675
|
+
origin,
|
|
676
|
+
code: "too_small",
|
|
677
|
+
minimum: def.minimum,
|
|
678
|
+
inclusive: true,
|
|
679
|
+
input,
|
|
680
|
+
inst,
|
|
681
|
+
continue: !def.abort,
|
|
682
|
+
});
|
|
683
|
+
};
|
|
684
|
+
});
|
|
685
|
+
const $ZodCheckLengthEquals = /*@__PURE__*/ $constructor("$ZodCheckLengthEquals", (inst, def) => {
|
|
686
|
+
var _a;
|
|
687
|
+
$ZodCheck.init(inst, def);
|
|
688
|
+
(_a = inst._zod.def).when ?? (_a.when = (payload) => {
|
|
689
|
+
const val = payload.value;
|
|
690
|
+
return !nullish(val) && val.length !== undefined;
|
|
691
|
+
});
|
|
692
|
+
inst._zod.onattach.push((inst) => {
|
|
693
|
+
const bag = inst._zod.bag;
|
|
694
|
+
bag.minimum = def.length;
|
|
695
|
+
bag.maximum = def.length;
|
|
696
|
+
bag.length = def.length;
|
|
697
|
+
});
|
|
698
|
+
inst._zod.check = (payload) => {
|
|
699
|
+
const input = payload.value;
|
|
700
|
+
const length = input.length;
|
|
701
|
+
if (length === def.length)
|
|
702
|
+
return;
|
|
703
|
+
const origin = getLengthableOrigin(input);
|
|
704
|
+
const tooBig = length > def.length;
|
|
705
|
+
payload.issues.push({
|
|
706
|
+
origin,
|
|
707
|
+
...(tooBig ? { code: "too_big", maximum: def.length } : { code: "too_small", minimum: def.length }),
|
|
708
|
+
inclusive: true,
|
|
709
|
+
exact: true,
|
|
710
|
+
input: payload.value,
|
|
711
|
+
inst,
|
|
712
|
+
continue: !def.abort,
|
|
713
|
+
});
|
|
714
|
+
};
|
|
715
|
+
});
|
|
716
|
+
const $ZodCheckStringFormat = /*@__PURE__*/ $constructor("$ZodCheckStringFormat", (inst, def) => {
|
|
717
|
+
var _a, _b;
|
|
718
|
+
$ZodCheck.init(inst, def);
|
|
719
|
+
inst._zod.onattach.push((inst) => {
|
|
720
|
+
const bag = inst._zod.bag;
|
|
721
|
+
bag.format = def.format;
|
|
722
|
+
if (def.pattern) {
|
|
723
|
+
bag.patterns ?? (bag.patterns = new Set());
|
|
724
|
+
bag.patterns.add(def.pattern);
|
|
725
|
+
}
|
|
726
|
+
});
|
|
727
|
+
if (def.pattern)
|
|
728
|
+
(_a = inst._zod).check ?? (_a.check = (payload) => {
|
|
729
|
+
def.pattern.lastIndex = 0;
|
|
730
|
+
if (def.pattern.test(payload.value))
|
|
731
|
+
return;
|
|
732
|
+
payload.issues.push({
|
|
733
|
+
origin: "string",
|
|
734
|
+
code: "invalid_format",
|
|
735
|
+
format: def.format,
|
|
736
|
+
input: payload.value,
|
|
737
|
+
...(def.pattern ? { pattern: def.pattern.toString() } : {}),
|
|
738
|
+
inst,
|
|
739
|
+
continue: !def.abort,
|
|
740
|
+
});
|
|
741
|
+
});
|
|
742
|
+
else
|
|
743
|
+
(_b = inst._zod).check ?? (_b.check = () => { });
|
|
744
|
+
});
|
|
745
|
+
const $ZodCheckRegex = /*@__PURE__*/ $constructor("$ZodCheckRegex", (inst, def) => {
|
|
746
|
+
$ZodCheckStringFormat.init(inst, def);
|
|
747
|
+
inst._zod.check = (payload) => {
|
|
748
|
+
def.pattern.lastIndex = 0;
|
|
749
|
+
if (def.pattern.test(payload.value))
|
|
750
|
+
return;
|
|
751
|
+
payload.issues.push({
|
|
752
|
+
origin: "string",
|
|
753
|
+
code: "invalid_format",
|
|
754
|
+
format: "regex",
|
|
755
|
+
input: payload.value,
|
|
756
|
+
pattern: def.pattern.toString(),
|
|
757
|
+
inst,
|
|
758
|
+
continue: !def.abort,
|
|
759
|
+
});
|
|
760
|
+
};
|
|
761
|
+
});
|
|
762
|
+
const $ZodCheckLowerCase = /*@__PURE__*/ $constructor("$ZodCheckLowerCase", (inst, def) => {
|
|
763
|
+
def.pattern ?? (def.pattern = lowercase);
|
|
764
|
+
$ZodCheckStringFormat.init(inst, def);
|
|
765
|
+
});
|
|
766
|
+
const $ZodCheckUpperCase = /*@__PURE__*/ $constructor("$ZodCheckUpperCase", (inst, def) => {
|
|
767
|
+
def.pattern ?? (def.pattern = uppercase);
|
|
768
|
+
$ZodCheckStringFormat.init(inst, def);
|
|
769
|
+
});
|
|
770
|
+
const $ZodCheckIncludes = /*@__PURE__*/ $constructor("$ZodCheckIncludes", (inst, def) => {
|
|
771
|
+
$ZodCheck.init(inst, def);
|
|
772
|
+
const escapedRegex = escapeRegex(def.includes);
|
|
773
|
+
const pattern = new RegExp(typeof def.position === "number" ? `^.{${def.position}}${escapedRegex}` : escapedRegex);
|
|
774
|
+
def.pattern = pattern;
|
|
775
|
+
inst._zod.onattach.push((inst) => {
|
|
776
|
+
const bag = inst._zod.bag;
|
|
777
|
+
bag.patterns ?? (bag.patterns = new Set());
|
|
778
|
+
bag.patterns.add(pattern);
|
|
779
|
+
});
|
|
780
|
+
inst._zod.check = (payload) => {
|
|
781
|
+
if (payload.value.includes(def.includes, def.position))
|
|
782
|
+
return;
|
|
783
|
+
payload.issues.push({
|
|
784
|
+
origin: "string",
|
|
785
|
+
code: "invalid_format",
|
|
786
|
+
format: "includes",
|
|
787
|
+
includes: def.includes,
|
|
788
|
+
input: payload.value,
|
|
789
|
+
inst,
|
|
790
|
+
continue: !def.abort,
|
|
791
|
+
});
|
|
792
|
+
};
|
|
793
|
+
});
|
|
794
|
+
const $ZodCheckStartsWith = /*@__PURE__*/ $constructor("$ZodCheckStartsWith", (inst, def) => {
|
|
795
|
+
$ZodCheck.init(inst, def);
|
|
796
|
+
const pattern = new RegExp(`^${escapeRegex(def.prefix)}.*`);
|
|
797
|
+
def.pattern ?? (def.pattern = pattern);
|
|
798
|
+
inst._zod.onattach.push((inst) => {
|
|
799
|
+
const bag = inst._zod.bag;
|
|
800
|
+
bag.patterns ?? (bag.patterns = new Set());
|
|
801
|
+
bag.patterns.add(pattern);
|
|
802
|
+
});
|
|
803
|
+
inst._zod.check = (payload) => {
|
|
804
|
+
if (payload.value.startsWith(def.prefix))
|
|
805
|
+
return;
|
|
806
|
+
payload.issues.push({
|
|
807
|
+
origin: "string",
|
|
808
|
+
code: "invalid_format",
|
|
809
|
+
format: "starts_with",
|
|
810
|
+
prefix: def.prefix,
|
|
811
|
+
input: payload.value,
|
|
812
|
+
inst,
|
|
813
|
+
continue: !def.abort,
|
|
814
|
+
});
|
|
815
|
+
};
|
|
816
|
+
});
|
|
817
|
+
const $ZodCheckEndsWith = /*@__PURE__*/ $constructor("$ZodCheckEndsWith", (inst, def) => {
|
|
818
|
+
$ZodCheck.init(inst, def);
|
|
819
|
+
const pattern = new RegExp(`.*${escapeRegex(def.suffix)}$`);
|
|
820
|
+
def.pattern ?? (def.pattern = pattern);
|
|
821
|
+
inst._zod.onattach.push((inst) => {
|
|
822
|
+
const bag = inst._zod.bag;
|
|
823
|
+
bag.patterns ?? (bag.patterns = new Set());
|
|
824
|
+
bag.patterns.add(pattern);
|
|
825
|
+
});
|
|
826
|
+
inst._zod.check = (payload) => {
|
|
827
|
+
if (payload.value.endsWith(def.suffix))
|
|
828
|
+
return;
|
|
829
|
+
payload.issues.push({
|
|
830
|
+
origin: "string",
|
|
831
|
+
code: "invalid_format",
|
|
832
|
+
format: "ends_with",
|
|
833
|
+
suffix: def.suffix,
|
|
834
|
+
input: payload.value,
|
|
835
|
+
inst,
|
|
836
|
+
continue: !def.abort,
|
|
837
|
+
});
|
|
838
|
+
};
|
|
839
|
+
});
|
|
840
|
+
const $ZodCheckOverwrite = /*@__PURE__*/ $constructor("$ZodCheckOverwrite", (inst, def) => {
|
|
841
|
+
$ZodCheck.init(inst, def);
|
|
842
|
+
inst._zod.check = (payload) => {
|
|
843
|
+
payload.value = def.tx(payload.value);
|
|
844
|
+
};
|
|
845
|
+
});
|
|
846
|
+
|
|
847
|
+
class Doc {
|
|
848
|
+
constructor(args = []) {
|
|
849
|
+
this.content = [];
|
|
850
|
+
this.indent = 0;
|
|
851
|
+
if (this)
|
|
852
|
+
this.args = args;
|
|
853
|
+
}
|
|
854
|
+
indented(fn) {
|
|
855
|
+
this.indent += 1;
|
|
856
|
+
fn(this);
|
|
857
|
+
this.indent -= 1;
|
|
858
|
+
}
|
|
859
|
+
write(arg) {
|
|
860
|
+
if (typeof arg === "function") {
|
|
861
|
+
arg(this, { execution: "sync" });
|
|
862
|
+
arg(this, { execution: "async" });
|
|
863
|
+
return;
|
|
864
|
+
}
|
|
865
|
+
const content = arg;
|
|
866
|
+
const lines = content.split("\n").filter((x) => x);
|
|
867
|
+
const minIndent = Math.min(...lines.map((x) => x.length - x.trimStart().length));
|
|
868
|
+
const dedented = lines.map((x) => x.slice(minIndent)).map((x) => " ".repeat(this.indent * 2) + x);
|
|
869
|
+
for (const line of dedented) {
|
|
870
|
+
this.content.push(line);
|
|
871
|
+
}
|
|
872
|
+
}
|
|
873
|
+
compile() {
|
|
874
|
+
const F = Function;
|
|
875
|
+
const args = this?.args;
|
|
876
|
+
const content = this?.content ?? [``];
|
|
877
|
+
const lines = [...content.map((x) => ` ${x}`)];
|
|
878
|
+
// console.log(lines.join("\n"));
|
|
879
|
+
return new F(...args, lines.join("\n"));
|
|
880
|
+
}
|
|
881
|
+
}
|
|
882
|
+
|
|
883
|
+
const version = {
|
|
884
|
+
major: 4,
|
|
885
|
+
minor: 0,
|
|
886
|
+
patch: 15,
|
|
887
|
+
};
|
|
888
|
+
|
|
889
|
+
const $ZodType = /*@__PURE__*/ $constructor("$ZodType", (inst, def) => {
|
|
890
|
+
var _a;
|
|
891
|
+
inst ?? (inst = {});
|
|
892
|
+
inst._zod.def = def; // set _def property
|
|
893
|
+
inst._zod.bag = inst._zod.bag || {}; // initialize _bag object
|
|
894
|
+
inst._zod.version = version;
|
|
895
|
+
const checks = [...(inst._zod.def.checks ?? [])];
|
|
896
|
+
// if inst is itself a checks.$ZodCheck, run it as a check
|
|
897
|
+
if (inst._zod.traits.has("$ZodCheck")) {
|
|
898
|
+
checks.unshift(inst);
|
|
899
|
+
}
|
|
900
|
+
//
|
|
901
|
+
for (const ch of checks) {
|
|
902
|
+
for (const fn of ch._zod.onattach) {
|
|
903
|
+
fn(inst);
|
|
904
|
+
}
|
|
905
|
+
}
|
|
906
|
+
if (checks.length === 0) {
|
|
907
|
+
// deferred initializer
|
|
908
|
+
// inst._zod.parse is not yet defined
|
|
909
|
+
(_a = inst._zod).deferred ?? (_a.deferred = []);
|
|
910
|
+
inst._zod.deferred?.push(() => {
|
|
911
|
+
inst._zod.run = inst._zod.parse;
|
|
912
|
+
});
|
|
913
|
+
}
|
|
914
|
+
else {
|
|
915
|
+
const runChecks = (payload, checks, ctx) => {
|
|
916
|
+
let isAborted = aborted(payload);
|
|
917
|
+
let asyncResult;
|
|
918
|
+
for (const ch of checks) {
|
|
919
|
+
if (ch._zod.def.when) {
|
|
920
|
+
const shouldRun = ch._zod.def.when(payload);
|
|
921
|
+
if (!shouldRun)
|
|
922
|
+
continue;
|
|
923
|
+
}
|
|
924
|
+
else if (isAborted) {
|
|
925
|
+
continue;
|
|
926
|
+
}
|
|
927
|
+
const currLen = payload.issues.length;
|
|
928
|
+
const _ = ch._zod.check(payload);
|
|
929
|
+
if (_ instanceof Promise && ctx?.async === false) {
|
|
930
|
+
throw new $ZodAsyncError();
|
|
931
|
+
}
|
|
932
|
+
if (asyncResult || _ instanceof Promise) {
|
|
933
|
+
asyncResult = (asyncResult ?? Promise.resolve()).then(async () => {
|
|
934
|
+
await _;
|
|
935
|
+
const nextLen = payload.issues.length;
|
|
936
|
+
if (nextLen === currLen)
|
|
937
|
+
return;
|
|
938
|
+
if (!isAborted)
|
|
939
|
+
isAborted = aborted(payload, currLen);
|
|
940
|
+
});
|
|
941
|
+
}
|
|
942
|
+
else {
|
|
943
|
+
const nextLen = payload.issues.length;
|
|
944
|
+
if (nextLen === currLen)
|
|
945
|
+
continue;
|
|
946
|
+
if (!isAborted)
|
|
947
|
+
isAborted = aborted(payload, currLen);
|
|
948
|
+
}
|
|
949
|
+
}
|
|
950
|
+
if (asyncResult) {
|
|
951
|
+
return asyncResult.then(() => {
|
|
952
|
+
return payload;
|
|
953
|
+
});
|
|
954
|
+
}
|
|
955
|
+
return payload;
|
|
956
|
+
};
|
|
957
|
+
inst._zod.run = (payload, ctx) => {
|
|
958
|
+
const result = inst._zod.parse(payload, ctx);
|
|
959
|
+
if (result instanceof Promise) {
|
|
960
|
+
if (ctx.async === false)
|
|
961
|
+
throw new $ZodAsyncError();
|
|
962
|
+
return result.then((result) => runChecks(result, checks, ctx));
|
|
963
|
+
}
|
|
964
|
+
return runChecks(result, checks, ctx);
|
|
965
|
+
};
|
|
966
|
+
}
|
|
967
|
+
inst["~standard"] = {
|
|
968
|
+
validate: (value) => {
|
|
969
|
+
try {
|
|
970
|
+
const r = safeParse$1(inst, value);
|
|
971
|
+
return r.success ? { value: r.data } : { issues: r.error?.issues };
|
|
972
|
+
}
|
|
973
|
+
catch (_) {
|
|
974
|
+
return safeParseAsync$1(inst, value).then((r) => (r.success ? { value: r.data } : { issues: r.error?.issues }));
|
|
975
|
+
}
|
|
976
|
+
},
|
|
977
|
+
vendor: "zod",
|
|
978
|
+
version: 1,
|
|
979
|
+
};
|
|
980
|
+
});
|
|
981
|
+
const $ZodString = /*@__PURE__*/ $constructor("$ZodString", (inst, def) => {
|
|
982
|
+
$ZodType.init(inst, def);
|
|
983
|
+
inst._zod.pattern = [...(inst?._zod.bag?.patterns ?? [])].pop() ?? string$1(inst._zod.bag);
|
|
984
|
+
inst._zod.parse = (payload, _) => {
|
|
985
|
+
if (def.coerce)
|
|
986
|
+
try {
|
|
987
|
+
payload.value = String(payload.value);
|
|
988
|
+
}
|
|
989
|
+
catch (_) { }
|
|
990
|
+
if (typeof payload.value === "string")
|
|
991
|
+
return payload;
|
|
992
|
+
payload.issues.push({
|
|
993
|
+
expected: "string",
|
|
994
|
+
code: "invalid_type",
|
|
995
|
+
input: payload.value,
|
|
996
|
+
inst,
|
|
997
|
+
});
|
|
998
|
+
return payload;
|
|
999
|
+
};
|
|
1000
|
+
});
|
|
1001
|
+
const $ZodStringFormat = /*@__PURE__*/ $constructor("$ZodStringFormat", (inst, def) => {
|
|
1002
|
+
// check initialization must come first
|
|
1003
|
+
$ZodCheckStringFormat.init(inst, def);
|
|
1004
|
+
$ZodString.init(inst, def);
|
|
1005
|
+
});
|
|
1006
|
+
const $ZodGUID = /*@__PURE__*/ $constructor("$ZodGUID", (inst, def) => {
|
|
1007
|
+
def.pattern ?? (def.pattern = guid);
|
|
1008
|
+
$ZodStringFormat.init(inst, def);
|
|
1009
|
+
});
|
|
1010
|
+
const $ZodUUID = /*@__PURE__*/ $constructor("$ZodUUID", (inst, def) => {
|
|
1011
|
+
if (def.version) {
|
|
1012
|
+
const versionMap = {
|
|
1013
|
+
v1: 1,
|
|
1014
|
+
v2: 2,
|
|
1015
|
+
v3: 3,
|
|
1016
|
+
v4: 4,
|
|
1017
|
+
v5: 5,
|
|
1018
|
+
v6: 6,
|
|
1019
|
+
v7: 7,
|
|
1020
|
+
v8: 8,
|
|
1021
|
+
};
|
|
1022
|
+
const v = versionMap[def.version];
|
|
1023
|
+
if (v === undefined)
|
|
1024
|
+
throw new Error(`Invalid UUID version: "${def.version}"`);
|
|
1025
|
+
def.pattern ?? (def.pattern = uuid(v));
|
|
1026
|
+
}
|
|
1027
|
+
else
|
|
1028
|
+
def.pattern ?? (def.pattern = uuid());
|
|
1029
|
+
$ZodStringFormat.init(inst, def);
|
|
1030
|
+
});
|
|
1031
|
+
const $ZodEmail = /*@__PURE__*/ $constructor("$ZodEmail", (inst, def) => {
|
|
1032
|
+
def.pattern ?? (def.pattern = email$1);
|
|
1033
|
+
$ZodStringFormat.init(inst, def);
|
|
1034
|
+
});
|
|
1035
|
+
const $ZodURL = /*@__PURE__*/ $constructor("$ZodURL", (inst, def) => {
|
|
1036
|
+
$ZodStringFormat.init(inst, def);
|
|
1037
|
+
inst._zod.check = (payload) => {
|
|
1038
|
+
try {
|
|
1039
|
+
// Trim whitespace from input
|
|
1040
|
+
const trimmed = payload.value.trim();
|
|
1041
|
+
// @ts-ignore
|
|
1042
|
+
const url = new URL(trimmed);
|
|
1043
|
+
if (def.hostname) {
|
|
1044
|
+
def.hostname.lastIndex = 0;
|
|
1045
|
+
if (!def.hostname.test(url.hostname)) {
|
|
1046
|
+
payload.issues.push({
|
|
1047
|
+
code: "invalid_format",
|
|
1048
|
+
format: "url",
|
|
1049
|
+
note: "Invalid hostname",
|
|
1050
|
+
pattern: hostname.source,
|
|
1051
|
+
input: payload.value,
|
|
1052
|
+
inst,
|
|
1053
|
+
continue: !def.abort,
|
|
1054
|
+
});
|
|
1055
|
+
}
|
|
1056
|
+
}
|
|
1057
|
+
if (def.protocol) {
|
|
1058
|
+
def.protocol.lastIndex = 0;
|
|
1059
|
+
if (!def.protocol.test(url.protocol.endsWith(":") ? url.protocol.slice(0, -1) : url.protocol)) {
|
|
1060
|
+
payload.issues.push({
|
|
1061
|
+
code: "invalid_format",
|
|
1062
|
+
format: "url",
|
|
1063
|
+
note: "Invalid protocol",
|
|
1064
|
+
pattern: def.protocol.source,
|
|
1065
|
+
input: payload.value,
|
|
1066
|
+
inst,
|
|
1067
|
+
continue: !def.abort,
|
|
1068
|
+
});
|
|
1069
|
+
}
|
|
1070
|
+
}
|
|
1071
|
+
// Set the output value based on normalize flag
|
|
1072
|
+
if (def.normalize) {
|
|
1073
|
+
// Use normalized URL
|
|
1074
|
+
payload.value = url.href;
|
|
1075
|
+
}
|
|
1076
|
+
else {
|
|
1077
|
+
// Preserve the original input (trimmed)
|
|
1078
|
+
payload.value = trimmed;
|
|
1079
|
+
}
|
|
1080
|
+
return;
|
|
1081
|
+
}
|
|
1082
|
+
catch (_) {
|
|
1083
|
+
payload.issues.push({
|
|
1084
|
+
code: "invalid_format",
|
|
1085
|
+
format: "url",
|
|
1086
|
+
input: payload.value,
|
|
1087
|
+
inst,
|
|
1088
|
+
continue: !def.abort,
|
|
1089
|
+
});
|
|
1090
|
+
}
|
|
1091
|
+
};
|
|
1092
|
+
});
|
|
1093
|
+
const $ZodEmoji = /*@__PURE__*/ $constructor("$ZodEmoji", (inst, def) => {
|
|
1094
|
+
def.pattern ?? (def.pattern = emoji());
|
|
1095
|
+
$ZodStringFormat.init(inst, def);
|
|
1096
|
+
});
|
|
1097
|
+
const $ZodNanoID = /*@__PURE__*/ $constructor("$ZodNanoID", (inst, def) => {
|
|
1098
|
+
def.pattern ?? (def.pattern = nanoid);
|
|
1099
|
+
$ZodStringFormat.init(inst, def);
|
|
1100
|
+
});
|
|
1101
|
+
const $ZodCUID = /*@__PURE__*/ $constructor("$ZodCUID", (inst, def) => {
|
|
1102
|
+
def.pattern ?? (def.pattern = cuid);
|
|
1103
|
+
$ZodStringFormat.init(inst, def);
|
|
1104
|
+
});
|
|
1105
|
+
const $ZodCUID2 = /*@__PURE__*/ $constructor("$ZodCUID2", (inst, def) => {
|
|
1106
|
+
def.pattern ?? (def.pattern = cuid2);
|
|
1107
|
+
$ZodStringFormat.init(inst, def);
|
|
1108
|
+
});
|
|
1109
|
+
const $ZodULID = /*@__PURE__*/ $constructor("$ZodULID", (inst, def) => {
|
|
1110
|
+
def.pattern ?? (def.pattern = ulid);
|
|
1111
|
+
$ZodStringFormat.init(inst, def);
|
|
1112
|
+
});
|
|
1113
|
+
const $ZodXID = /*@__PURE__*/ $constructor("$ZodXID", (inst, def) => {
|
|
1114
|
+
def.pattern ?? (def.pattern = xid);
|
|
1115
|
+
$ZodStringFormat.init(inst, def);
|
|
1116
|
+
});
|
|
1117
|
+
const $ZodKSUID = /*@__PURE__*/ $constructor("$ZodKSUID", (inst, def) => {
|
|
1118
|
+
def.pattern ?? (def.pattern = ksuid);
|
|
1119
|
+
$ZodStringFormat.init(inst, def);
|
|
1120
|
+
});
|
|
1121
|
+
const $ZodISODateTime = /*@__PURE__*/ $constructor("$ZodISODateTime", (inst, def) => {
|
|
1122
|
+
def.pattern ?? (def.pattern = datetime$1(def));
|
|
1123
|
+
$ZodStringFormat.init(inst, def);
|
|
1124
|
+
});
|
|
1125
|
+
const $ZodISODate = /*@__PURE__*/ $constructor("$ZodISODate", (inst, def) => {
|
|
1126
|
+
def.pattern ?? (def.pattern = date$1);
|
|
1127
|
+
$ZodStringFormat.init(inst, def);
|
|
1128
|
+
});
|
|
1129
|
+
const $ZodISOTime = /*@__PURE__*/ $constructor("$ZodISOTime", (inst, def) => {
|
|
1130
|
+
def.pattern ?? (def.pattern = time$1(def));
|
|
1131
|
+
$ZodStringFormat.init(inst, def);
|
|
1132
|
+
});
|
|
1133
|
+
const $ZodISODuration = /*@__PURE__*/ $constructor("$ZodISODuration", (inst, def) => {
|
|
1134
|
+
def.pattern ?? (def.pattern = duration$1);
|
|
1135
|
+
$ZodStringFormat.init(inst, def);
|
|
1136
|
+
});
|
|
1137
|
+
const $ZodIPv4 = /*@__PURE__*/ $constructor("$ZodIPv4", (inst, def) => {
|
|
1138
|
+
def.pattern ?? (def.pattern = ipv4);
|
|
1139
|
+
$ZodStringFormat.init(inst, def);
|
|
1140
|
+
inst._zod.onattach.push((inst) => {
|
|
1141
|
+
const bag = inst._zod.bag;
|
|
1142
|
+
bag.format = `ipv4`;
|
|
1143
|
+
});
|
|
1144
|
+
});
|
|
1145
|
+
const $ZodIPv6 = /*@__PURE__*/ $constructor("$ZodIPv6", (inst, def) => {
|
|
1146
|
+
def.pattern ?? (def.pattern = ipv6);
|
|
1147
|
+
$ZodStringFormat.init(inst, def);
|
|
1148
|
+
inst._zod.onattach.push((inst) => {
|
|
1149
|
+
const bag = inst._zod.bag;
|
|
1150
|
+
bag.format = `ipv6`;
|
|
1151
|
+
});
|
|
1152
|
+
inst._zod.check = (payload) => {
|
|
1153
|
+
try {
|
|
1154
|
+
// @ts-ignore
|
|
1155
|
+
new URL(`http://[${payload.value}]`);
|
|
1156
|
+
// return;
|
|
1157
|
+
}
|
|
1158
|
+
catch {
|
|
1159
|
+
payload.issues.push({
|
|
1160
|
+
code: "invalid_format",
|
|
1161
|
+
format: "ipv6",
|
|
1162
|
+
input: payload.value,
|
|
1163
|
+
inst,
|
|
1164
|
+
continue: !def.abort,
|
|
1165
|
+
});
|
|
1166
|
+
}
|
|
1167
|
+
};
|
|
1168
|
+
});
|
|
1169
|
+
const $ZodCIDRv4 = /*@__PURE__*/ $constructor("$ZodCIDRv4", (inst, def) => {
|
|
1170
|
+
def.pattern ?? (def.pattern = cidrv4);
|
|
1171
|
+
$ZodStringFormat.init(inst, def);
|
|
1172
|
+
});
|
|
1173
|
+
const $ZodCIDRv6 = /*@__PURE__*/ $constructor("$ZodCIDRv6", (inst, def) => {
|
|
1174
|
+
def.pattern ?? (def.pattern = cidrv6); // not used for validation
|
|
1175
|
+
$ZodStringFormat.init(inst, def);
|
|
1176
|
+
inst._zod.check = (payload) => {
|
|
1177
|
+
const [address, prefix] = payload.value.split("/");
|
|
1178
|
+
try {
|
|
1179
|
+
if (!prefix)
|
|
1180
|
+
throw new Error();
|
|
1181
|
+
const prefixNum = Number(prefix);
|
|
1182
|
+
if (`${prefixNum}` !== prefix)
|
|
1183
|
+
throw new Error();
|
|
1184
|
+
if (prefixNum < 0 || prefixNum > 128)
|
|
1185
|
+
throw new Error();
|
|
1186
|
+
// @ts-ignore
|
|
1187
|
+
new URL(`http://[${address}]`);
|
|
1188
|
+
}
|
|
1189
|
+
catch {
|
|
1190
|
+
payload.issues.push({
|
|
1191
|
+
code: "invalid_format",
|
|
1192
|
+
format: "cidrv6",
|
|
1193
|
+
input: payload.value,
|
|
1194
|
+
inst,
|
|
1195
|
+
continue: !def.abort,
|
|
1196
|
+
});
|
|
1197
|
+
}
|
|
1198
|
+
};
|
|
1199
|
+
});
|
|
1200
|
+
////////////////////////////// ZodBase64 //////////////////////////////
|
|
1201
|
+
function isValidBase64(data) {
|
|
1202
|
+
if (data === "")
|
|
1203
|
+
return true;
|
|
1204
|
+
if (data.length % 4 !== 0)
|
|
1205
|
+
return false;
|
|
1206
|
+
try {
|
|
1207
|
+
// @ts-ignore
|
|
1208
|
+
atob(data);
|
|
1209
|
+
return true;
|
|
1210
|
+
}
|
|
1211
|
+
catch {
|
|
1212
|
+
return false;
|
|
1213
|
+
}
|
|
1214
|
+
}
|
|
1215
|
+
const $ZodBase64 = /*@__PURE__*/ $constructor("$ZodBase64", (inst, def) => {
|
|
1216
|
+
def.pattern ?? (def.pattern = base64);
|
|
1217
|
+
$ZodStringFormat.init(inst, def);
|
|
1218
|
+
inst._zod.onattach.push((inst) => {
|
|
1219
|
+
inst._zod.bag.contentEncoding = "base64";
|
|
1220
|
+
});
|
|
1221
|
+
inst._zod.check = (payload) => {
|
|
1222
|
+
if (isValidBase64(payload.value))
|
|
1223
|
+
return;
|
|
1224
|
+
payload.issues.push({
|
|
1225
|
+
code: "invalid_format",
|
|
1226
|
+
format: "base64",
|
|
1227
|
+
input: payload.value,
|
|
1228
|
+
inst,
|
|
1229
|
+
continue: !def.abort,
|
|
1230
|
+
});
|
|
1231
|
+
};
|
|
1232
|
+
});
|
|
1233
|
+
////////////////////////////// ZodBase64 //////////////////////////////
|
|
1234
|
+
function isValidBase64URL(data) {
|
|
1235
|
+
if (!base64url.test(data))
|
|
1236
|
+
return false;
|
|
1237
|
+
const base64 = data.replace(/[-_]/g, (c) => (c === "-" ? "+" : "/"));
|
|
1238
|
+
const padded = base64.padEnd(Math.ceil(base64.length / 4) * 4, "=");
|
|
1239
|
+
return isValidBase64(padded);
|
|
1240
|
+
}
|
|
1241
|
+
const $ZodBase64URL = /*@__PURE__*/ $constructor("$ZodBase64URL", (inst, def) => {
|
|
1242
|
+
def.pattern ?? (def.pattern = base64url);
|
|
1243
|
+
$ZodStringFormat.init(inst, def);
|
|
1244
|
+
inst._zod.onattach.push((inst) => {
|
|
1245
|
+
inst._zod.bag.contentEncoding = "base64url";
|
|
1246
|
+
});
|
|
1247
|
+
inst._zod.check = (payload) => {
|
|
1248
|
+
if (isValidBase64URL(payload.value))
|
|
1249
|
+
return;
|
|
1250
|
+
payload.issues.push({
|
|
1251
|
+
code: "invalid_format",
|
|
1252
|
+
format: "base64url",
|
|
1253
|
+
input: payload.value,
|
|
1254
|
+
inst,
|
|
1255
|
+
continue: !def.abort,
|
|
1256
|
+
});
|
|
1257
|
+
};
|
|
1258
|
+
});
|
|
1259
|
+
const $ZodE164 = /*@__PURE__*/ $constructor("$ZodE164", (inst, def) => {
|
|
1260
|
+
def.pattern ?? (def.pattern = e164);
|
|
1261
|
+
$ZodStringFormat.init(inst, def);
|
|
1262
|
+
});
|
|
1263
|
+
////////////////////////////// ZodJWT //////////////////////////////
|
|
1264
|
+
function isValidJWT(token, algorithm = null) {
|
|
1265
|
+
try {
|
|
1266
|
+
const tokensParts = token.split(".");
|
|
1267
|
+
if (tokensParts.length !== 3)
|
|
1268
|
+
return false;
|
|
1269
|
+
const [header] = tokensParts;
|
|
1270
|
+
if (!header)
|
|
1271
|
+
return false;
|
|
1272
|
+
// @ts-ignore
|
|
1273
|
+
const parsedHeader = JSON.parse(atob(header));
|
|
1274
|
+
if ("typ" in parsedHeader && parsedHeader?.typ !== "JWT")
|
|
1275
|
+
return false;
|
|
1276
|
+
if (!parsedHeader.alg)
|
|
1277
|
+
return false;
|
|
1278
|
+
if (algorithm && (!("alg" in parsedHeader) || parsedHeader.alg !== algorithm))
|
|
1279
|
+
return false;
|
|
1280
|
+
return true;
|
|
1281
|
+
}
|
|
1282
|
+
catch {
|
|
1283
|
+
return false;
|
|
1284
|
+
}
|
|
1285
|
+
}
|
|
1286
|
+
const $ZodJWT = /*@__PURE__*/ $constructor("$ZodJWT", (inst, def) => {
|
|
1287
|
+
$ZodStringFormat.init(inst, def);
|
|
1288
|
+
inst._zod.check = (payload) => {
|
|
1289
|
+
if (isValidJWT(payload.value, def.alg))
|
|
1290
|
+
return;
|
|
1291
|
+
payload.issues.push({
|
|
1292
|
+
code: "invalid_format",
|
|
1293
|
+
format: "jwt",
|
|
1294
|
+
input: payload.value,
|
|
1295
|
+
inst,
|
|
1296
|
+
continue: !def.abort,
|
|
1297
|
+
});
|
|
1298
|
+
};
|
|
1299
|
+
});
|
|
1300
|
+
const $ZodUnknown = /*@__PURE__*/ $constructor("$ZodUnknown", (inst, def) => {
|
|
1301
|
+
$ZodType.init(inst, def);
|
|
1302
|
+
inst._zod.parse = (payload) => payload;
|
|
1303
|
+
});
|
|
1304
|
+
const $ZodNever = /*@__PURE__*/ $constructor("$ZodNever", (inst, def) => {
|
|
1305
|
+
$ZodType.init(inst, def);
|
|
1306
|
+
inst._zod.parse = (payload, _ctx) => {
|
|
1307
|
+
payload.issues.push({
|
|
1308
|
+
expected: "never",
|
|
1309
|
+
code: "invalid_type",
|
|
1310
|
+
input: payload.value,
|
|
1311
|
+
inst,
|
|
1312
|
+
});
|
|
1313
|
+
return payload;
|
|
1314
|
+
};
|
|
1315
|
+
});
|
|
1316
|
+
function handleArrayResult(result, final, index) {
|
|
1317
|
+
if (result.issues.length) {
|
|
1318
|
+
final.issues.push(...prefixIssues(index, result.issues));
|
|
1319
|
+
}
|
|
1320
|
+
final.value[index] = result.value;
|
|
1321
|
+
}
|
|
1322
|
+
const $ZodArray = /*@__PURE__*/ $constructor("$ZodArray", (inst, def) => {
|
|
1323
|
+
$ZodType.init(inst, def);
|
|
1324
|
+
inst._zod.parse = (payload, ctx) => {
|
|
1325
|
+
const input = payload.value;
|
|
1326
|
+
if (!Array.isArray(input)) {
|
|
1327
|
+
payload.issues.push({
|
|
1328
|
+
expected: "array",
|
|
1329
|
+
code: "invalid_type",
|
|
1330
|
+
input,
|
|
1331
|
+
inst,
|
|
1332
|
+
});
|
|
1333
|
+
return payload;
|
|
1334
|
+
}
|
|
1335
|
+
payload.value = Array(input.length);
|
|
1336
|
+
const proms = [];
|
|
1337
|
+
for (let i = 0; i < input.length; i++) {
|
|
1338
|
+
const item = input[i];
|
|
1339
|
+
const result = def.element._zod.run({
|
|
1340
|
+
value: item,
|
|
1341
|
+
issues: [],
|
|
1342
|
+
}, ctx);
|
|
1343
|
+
if (result instanceof Promise) {
|
|
1344
|
+
proms.push(result.then((result) => handleArrayResult(result, payload, i)));
|
|
1345
|
+
}
|
|
1346
|
+
else {
|
|
1347
|
+
handleArrayResult(result, payload, i);
|
|
1348
|
+
}
|
|
1349
|
+
}
|
|
1350
|
+
if (proms.length) {
|
|
1351
|
+
return Promise.all(proms).then(() => payload);
|
|
1352
|
+
}
|
|
1353
|
+
return payload; //handleArrayResultsAsync(parseResults, final);
|
|
1354
|
+
};
|
|
1355
|
+
});
|
|
1356
|
+
function handlePropertyResult(result, final, key, input) {
|
|
1357
|
+
if (result.issues.length) {
|
|
1358
|
+
final.issues.push(...prefixIssues(key, result.issues));
|
|
1359
|
+
}
|
|
1360
|
+
if (result.value === undefined) {
|
|
1361
|
+
if (key in input) {
|
|
1362
|
+
final.value[key] = undefined;
|
|
1363
|
+
}
|
|
1364
|
+
}
|
|
1365
|
+
else {
|
|
1366
|
+
final.value[key] = result.value;
|
|
1367
|
+
}
|
|
1368
|
+
}
|
|
1369
|
+
const $ZodObject = /*@__PURE__*/ $constructor("$ZodObject", (inst, def) => {
|
|
1370
|
+
// requires cast because technically $ZodObject doesn't extend
|
|
1371
|
+
$ZodType.init(inst, def);
|
|
1372
|
+
const _normalized = cached(() => {
|
|
1373
|
+
const keys = Object.keys(def.shape);
|
|
1374
|
+
for (const k of keys) {
|
|
1375
|
+
if (!(def.shape[k] instanceof $ZodType)) {
|
|
1376
|
+
throw new Error(`Invalid element at key "${k}": expected a Zod schema`);
|
|
1377
|
+
}
|
|
1378
|
+
}
|
|
1379
|
+
const okeys = optionalKeys(def.shape);
|
|
1380
|
+
return {
|
|
1381
|
+
shape: def.shape,
|
|
1382
|
+
keys,
|
|
1383
|
+
keySet: new Set(keys),
|
|
1384
|
+
numKeys: keys.length,
|
|
1385
|
+
optionalKeys: new Set(okeys),
|
|
1386
|
+
};
|
|
1387
|
+
});
|
|
1388
|
+
defineLazy(inst._zod, "propValues", () => {
|
|
1389
|
+
const shape = def.shape;
|
|
1390
|
+
const propValues = {};
|
|
1391
|
+
for (const key in shape) {
|
|
1392
|
+
const field = shape[key]._zod;
|
|
1393
|
+
if (field.values) {
|
|
1394
|
+
propValues[key] ?? (propValues[key] = new Set());
|
|
1395
|
+
for (const v of field.values)
|
|
1396
|
+
propValues[key].add(v);
|
|
1397
|
+
}
|
|
1398
|
+
}
|
|
1399
|
+
return propValues;
|
|
1400
|
+
});
|
|
1401
|
+
const generateFastpass = (shape) => {
|
|
1402
|
+
const doc = new Doc(["shape", "payload", "ctx"]);
|
|
1403
|
+
const normalized = _normalized.value;
|
|
1404
|
+
const parseStr = (key) => {
|
|
1405
|
+
const k = esc(key);
|
|
1406
|
+
return `shape[${k}]._zod.run({ value: input[${k}], issues: [] }, ctx)`;
|
|
1407
|
+
};
|
|
1408
|
+
doc.write(`const input = payload.value;`);
|
|
1409
|
+
const ids = Object.create(null);
|
|
1410
|
+
let counter = 0;
|
|
1411
|
+
for (const key of normalized.keys) {
|
|
1412
|
+
ids[key] = `key_${counter++}`;
|
|
1413
|
+
}
|
|
1414
|
+
// A: preserve key order {
|
|
1415
|
+
doc.write(`const newResult = {}`);
|
|
1416
|
+
for (const key of normalized.keys) {
|
|
1417
|
+
const id = ids[key];
|
|
1418
|
+
const k = esc(key);
|
|
1419
|
+
doc.write(`const ${id} = ${parseStr(key)};`);
|
|
1420
|
+
doc.write(`
|
|
1421
|
+
if (${id}.issues.length) {
|
|
1422
|
+
payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
|
|
1423
|
+
...iss,
|
|
1424
|
+
path: iss.path ? [${k}, ...iss.path] : [${k}]
|
|
1425
|
+
})));
|
|
1426
|
+
}
|
|
1427
|
+
|
|
1428
|
+
if (${id}.value === undefined) {
|
|
1429
|
+
if (${k} in input) {
|
|
1430
|
+
newResult[${k}] = undefined;
|
|
1431
|
+
}
|
|
1432
|
+
} else {
|
|
1433
|
+
newResult[${k}] = ${id}.value;
|
|
1434
|
+
}
|
|
1435
|
+
`);
|
|
1436
|
+
}
|
|
1437
|
+
doc.write(`payload.value = newResult;`);
|
|
1438
|
+
doc.write(`return payload;`);
|
|
1439
|
+
const fn = doc.compile();
|
|
1440
|
+
return (payload, ctx) => fn(shape, payload, ctx);
|
|
1441
|
+
};
|
|
1442
|
+
let fastpass;
|
|
1443
|
+
const isObject$1 = isObject;
|
|
1444
|
+
const jit = !globalConfig.jitless;
|
|
1445
|
+
const allowsEval$1 = allowsEval;
|
|
1446
|
+
const fastEnabled = jit && allowsEval$1.value; // && !def.catchall;
|
|
1447
|
+
const catchall = def.catchall;
|
|
1448
|
+
let value;
|
|
1449
|
+
inst._zod.parse = (payload, ctx) => {
|
|
1450
|
+
value ?? (value = _normalized.value);
|
|
1451
|
+
const input = payload.value;
|
|
1452
|
+
if (!isObject$1(input)) {
|
|
1453
|
+
payload.issues.push({
|
|
1454
|
+
expected: "object",
|
|
1455
|
+
code: "invalid_type",
|
|
1456
|
+
input,
|
|
1457
|
+
inst,
|
|
1458
|
+
});
|
|
1459
|
+
return payload;
|
|
1460
|
+
}
|
|
1461
|
+
const proms = [];
|
|
1462
|
+
if (jit && fastEnabled && ctx?.async === false && ctx.jitless !== true) {
|
|
1463
|
+
// always synchronous
|
|
1464
|
+
if (!fastpass)
|
|
1465
|
+
fastpass = generateFastpass(def.shape);
|
|
1466
|
+
payload = fastpass(payload, ctx);
|
|
1467
|
+
}
|
|
1468
|
+
else {
|
|
1469
|
+
payload.value = {};
|
|
1470
|
+
const shape = value.shape;
|
|
1471
|
+
for (const key of value.keys) {
|
|
1472
|
+
const el = shape[key];
|
|
1473
|
+
const r = el._zod.run({ value: input[key], issues: [] }, ctx);
|
|
1474
|
+
if (r instanceof Promise) {
|
|
1475
|
+
proms.push(r.then((r) => handlePropertyResult(r, payload, key, input)));
|
|
1476
|
+
}
|
|
1477
|
+
else {
|
|
1478
|
+
handlePropertyResult(r, payload, key, input);
|
|
1479
|
+
}
|
|
1480
|
+
}
|
|
1481
|
+
}
|
|
1482
|
+
if (!catchall) {
|
|
1483
|
+
return proms.length ? Promise.all(proms).then(() => payload) : payload;
|
|
1484
|
+
}
|
|
1485
|
+
const unrecognized = [];
|
|
1486
|
+
// iterate over input keys
|
|
1487
|
+
const keySet = value.keySet;
|
|
1488
|
+
const _catchall = catchall._zod;
|
|
1489
|
+
const t = _catchall.def.type;
|
|
1490
|
+
for (const key of Object.keys(input)) {
|
|
1491
|
+
if (keySet.has(key))
|
|
1492
|
+
continue;
|
|
1493
|
+
if (t === "never") {
|
|
1494
|
+
unrecognized.push(key);
|
|
1495
|
+
continue;
|
|
1496
|
+
}
|
|
1497
|
+
const r = _catchall.run({ value: input[key], issues: [] }, ctx);
|
|
1498
|
+
if (r instanceof Promise) {
|
|
1499
|
+
proms.push(r.then((r) => handlePropertyResult(r, payload, key, input)));
|
|
1500
|
+
}
|
|
1501
|
+
else {
|
|
1502
|
+
handlePropertyResult(r, payload, key, input);
|
|
1503
|
+
}
|
|
1504
|
+
}
|
|
1505
|
+
if (unrecognized.length) {
|
|
1506
|
+
payload.issues.push({
|
|
1507
|
+
code: "unrecognized_keys",
|
|
1508
|
+
keys: unrecognized,
|
|
1509
|
+
input,
|
|
1510
|
+
inst,
|
|
1511
|
+
});
|
|
1512
|
+
}
|
|
1513
|
+
if (!proms.length)
|
|
1514
|
+
return payload;
|
|
1515
|
+
return Promise.all(proms).then(() => {
|
|
1516
|
+
return payload;
|
|
1517
|
+
});
|
|
1518
|
+
};
|
|
1519
|
+
});
|
|
1520
|
+
function handleUnionResults(results, final, inst, ctx) {
|
|
1521
|
+
for (const result of results) {
|
|
1522
|
+
if (result.issues.length === 0) {
|
|
1523
|
+
final.value = result.value;
|
|
1524
|
+
return final;
|
|
1525
|
+
}
|
|
1526
|
+
}
|
|
1527
|
+
const nonaborted = results.filter((r) => !aborted(r));
|
|
1528
|
+
if (nonaborted.length === 1) {
|
|
1529
|
+
final.value = nonaborted[0].value;
|
|
1530
|
+
return nonaborted[0];
|
|
1531
|
+
}
|
|
1532
|
+
final.issues.push({
|
|
1533
|
+
code: "invalid_union",
|
|
1534
|
+
input: final.value,
|
|
1535
|
+
inst,
|
|
1536
|
+
errors: results.map((result) => result.issues.map((iss) => finalizeIssue(iss, ctx, config()))),
|
|
1537
|
+
});
|
|
1538
|
+
return final;
|
|
1539
|
+
}
|
|
1540
|
+
const $ZodUnion = /*@__PURE__*/ $constructor("$ZodUnion", (inst, def) => {
|
|
1541
|
+
$ZodType.init(inst, def);
|
|
1542
|
+
defineLazy(inst._zod, "optin", () => def.options.some((o) => o._zod.optin === "optional") ? "optional" : undefined);
|
|
1543
|
+
defineLazy(inst._zod, "optout", () => def.options.some((o) => o._zod.optout === "optional") ? "optional" : undefined);
|
|
1544
|
+
defineLazy(inst._zod, "values", () => {
|
|
1545
|
+
if (def.options.every((o) => o._zod.values)) {
|
|
1546
|
+
return new Set(def.options.flatMap((option) => Array.from(option._zod.values)));
|
|
1547
|
+
}
|
|
1548
|
+
return undefined;
|
|
1549
|
+
});
|
|
1550
|
+
defineLazy(inst._zod, "pattern", () => {
|
|
1551
|
+
if (def.options.every((o) => o._zod.pattern)) {
|
|
1552
|
+
const patterns = def.options.map((o) => o._zod.pattern);
|
|
1553
|
+
return new RegExp(`^(${patterns.map((p) => cleanRegex(p.source)).join("|")})$`);
|
|
1554
|
+
}
|
|
1555
|
+
return undefined;
|
|
1556
|
+
});
|
|
1557
|
+
const single = def.options.length === 1;
|
|
1558
|
+
const first = def.options[0]._zod.run;
|
|
1559
|
+
inst._zod.parse = (payload, ctx) => {
|
|
1560
|
+
if (single) {
|
|
1561
|
+
return first(payload, ctx);
|
|
1562
|
+
}
|
|
1563
|
+
let async = false;
|
|
1564
|
+
const results = [];
|
|
1565
|
+
for (const option of def.options) {
|
|
1566
|
+
const result = option._zod.run({
|
|
1567
|
+
value: payload.value,
|
|
1568
|
+
issues: [],
|
|
1569
|
+
}, ctx);
|
|
1570
|
+
if (result instanceof Promise) {
|
|
1571
|
+
results.push(result);
|
|
1572
|
+
async = true;
|
|
1573
|
+
}
|
|
1574
|
+
else {
|
|
1575
|
+
if (result.issues.length === 0)
|
|
1576
|
+
return result;
|
|
1577
|
+
results.push(result);
|
|
1578
|
+
}
|
|
1579
|
+
}
|
|
1580
|
+
if (!async)
|
|
1581
|
+
return handleUnionResults(results, payload, inst, ctx);
|
|
1582
|
+
return Promise.all(results).then((results) => {
|
|
1583
|
+
return handleUnionResults(results, payload, inst, ctx);
|
|
1584
|
+
});
|
|
1585
|
+
};
|
|
1586
|
+
});
|
|
1587
|
+
const $ZodIntersection = /*@__PURE__*/ $constructor("$ZodIntersection", (inst, def) => {
|
|
1588
|
+
$ZodType.init(inst, def);
|
|
1589
|
+
inst._zod.parse = (payload, ctx) => {
|
|
1590
|
+
const input = payload.value;
|
|
1591
|
+
const left = def.left._zod.run({ value: input, issues: [] }, ctx);
|
|
1592
|
+
const right = def.right._zod.run({ value: input, issues: [] }, ctx);
|
|
1593
|
+
const async = left instanceof Promise || right instanceof Promise;
|
|
1594
|
+
if (async) {
|
|
1595
|
+
return Promise.all([left, right]).then(([left, right]) => {
|
|
1596
|
+
return handleIntersectionResults(payload, left, right);
|
|
1597
|
+
});
|
|
1598
|
+
}
|
|
1599
|
+
return handleIntersectionResults(payload, left, right);
|
|
1600
|
+
};
|
|
1601
|
+
});
|
|
1602
|
+
function mergeValues(a, b) {
|
|
1603
|
+
// const aType = parse.t(a);
|
|
1604
|
+
// const bType = parse.t(b);
|
|
1605
|
+
if (a === b) {
|
|
1606
|
+
return { valid: true, data: a };
|
|
1607
|
+
}
|
|
1608
|
+
if (a instanceof Date && b instanceof Date && +a === +b) {
|
|
1609
|
+
return { valid: true, data: a };
|
|
1610
|
+
}
|
|
1611
|
+
if (isPlainObject(a) && isPlainObject(b)) {
|
|
1612
|
+
const bKeys = Object.keys(b);
|
|
1613
|
+
const sharedKeys = Object.keys(a).filter((key) => bKeys.indexOf(key) !== -1);
|
|
1614
|
+
const newObj = { ...a, ...b };
|
|
1615
|
+
for (const key of sharedKeys) {
|
|
1616
|
+
const sharedValue = mergeValues(a[key], b[key]);
|
|
1617
|
+
if (!sharedValue.valid) {
|
|
1618
|
+
return {
|
|
1619
|
+
valid: false,
|
|
1620
|
+
mergeErrorPath: [key, ...sharedValue.mergeErrorPath],
|
|
1621
|
+
};
|
|
1622
|
+
}
|
|
1623
|
+
newObj[key] = sharedValue.data;
|
|
1624
|
+
}
|
|
1625
|
+
return { valid: true, data: newObj };
|
|
1626
|
+
}
|
|
1627
|
+
if (Array.isArray(a) && Array.isArray(b)) {
|
|
1628
|
+
if (a.length !== b.length) {
|
|
1629
|
+
return { valid: false, mergeErrorPath: [] };
|
|
1630
|
+
}
|
|
1631
|
+
const newArray = [];
|
|
1632
|
+
for (let index = 0; index < a.length; index++) {
|
|
1633
|
+
const itemA = a[index];
|
|
1634
|
+
const itemB = b[index];
|
|
1635
|
+
const sharedValue = mergeValues(itemA, itemB);
|
|
1636
|
+
if (!sharedValue.valid) {
|
|
1637
|
+
return {
|
|
1638
|
+
valid: false,
|
|
1639
|
+
mergeErrorPath: [index, ...sharedValue.mergeErrorPath],
|
|
1640
|
+
};
|
|
1641
|
+
}
|
|
1642
|
+
newArray.push(sharedValue.data);
|
|
1643
|
+
}
|
|
1644
|
+
return { valid: true, data: newArray };
|
|
1645
|
+
}
|
|
1646
|
+
return { valid: false, mergeErrorPath: [] };
|
|
1647
|
+
}
|
|
1648
|
+
function handleIntersectionResults(result, left, right) {
|
|
1649
|
+
if (left.issues.length) {
|
|
1650
|
+
result.issues.push(...left.issues);
|
|
1651
|
+
}
|
|
1652
|
+
if (right.issues.length) {
|
|
1653
|
+
result.issues.push(...right.issues);
|
|
1654
|
+
}
|
|
1655
|
+
if (aborted(result))
|
|
1656
|
+
return result;
|
|
1657
|
+
const merged = mergeValues(left.value, right.value);
|
|
1658
|
+
if (!merged.valid) {
|
|
1659
|
+
throw new Error(`Unmergable intersection. Error path: ` + `${JSON.stringify(merged.mergeErrorPath)}`);
|
|
1660
|
+
}
|
|
1661
|
+
result.value = merged.data;
|
|
1662
|
+
return result;
|
|
1663
|
+
}
|
|
1664
|
+
const $ZodEnum = /*@__PURE__*/ $constructor("$ZodEnum", (inst, def) => {
|
|
1665
|
+
$ZodType.init(inst, def);
|
|
1666
|
+
const values = getEnumValues(def.entries);
|
|
1667
|
+
const valuesSet = new Set(values);
|
|
1668
|
+
inst._zod.values = valuesSet;
|
|
1669
|
+
inst._zod.pattern = new RegExp(`^(${values
|
|
1670
|
+
.filter((k) => propertyKeyTypes.has(typeof k))
|
|
1671
|
+
.map((o) => (typeof o === "string" ? escapeRegex(o) : o.toString()))
|
|
1672
|
+
.join("|")})$`);
|
|
1673
|
+
inst._zod.parse = (payload, _ctx) => {
|
|
1674
|
+
const input = payload.value;
|
|
1675
|
+
if (valuesSet.has(input)) {
|
|
1676
|
+
return payload;
|
|
1677
|
+
}
|
|
1678
|
+
payload.issues.push({
|
|
1679
|
+
code: "invalid_value",
|
|
1680
|
+
values,
|
|
1681
|
+
input,
|
|
1682
|
+
inst,
|
|
1683
|
+
});
|
|
1684
|
+
return payload;
|
|
1685
|
+
};
|
|
1686
|
+
});
|
|
1687
|
+
const $ZodTransform = /*@__PURE__*/ $constructor("$ZodTransform", (inst, def) => {
|
|
1688
|
+
$ZodType.init(inst, def);
|
|
1689
|
+
inst._zod.parse = (payload, _ctx) => {
|
|
1690
|
+
const _out = def.transform(payload.value, payload);
|
|
1691
|
+
if (_ctx.async) {
|
|
1692
|
+
const output = _out instanceof Promise ? _out : Promise.resolve(_out);
|
|
1693
|
+
return output.then((output) => {
|
|
1694
|
+
payload.value = output;
|
|
1695
|
+
return payload;
|
|
1696
|
+
});
|
|
1697
|
+
}
|
|
1698
|
+
if (_out instanceof Promise) {
|
|
1699
|
+
throw new $ZodAsyncError();
|
|
1700
|
+
}
|
|
1701
|
+
payload.value = _out;
|
|
1702
|
+
return payload;
|
|
1703
|
+
};
|
|
1704
|
+
});
|
|
1705
|
+
function handleOptionalResult(result, input) {
|
|
1706
|
+
if (result.issues.length && input === undefined) {
|
|
1707
|
+
return { issues: [], value: undefined };
|
|
1708
|
+
}
|
|
1709
|
+
return result;
|
|
1710
|
+
}
|
|
1711
|
+
const $ZodOptional = /*@__PURE__*/ $constructor("$ZodOptional", (inst, def) => {
|
|
1712
|
+
$ZodType.init(inst, def);
|
|
1713
|
+
inst._zod.optin = "optional";
|
|
1714
|
+
inst._zod.optout = "optional";
|
|
1715
|
+
defineLazy(inst._zod, "values", () => {
|
|
1716
|
+
return def.innerType._zod.values ? new Set([...def.innerType._zod.values, undefined]) : undefined;
|
|
1717
|
+
});
|
|
1718
|
+
defineLazy(inst._zod, "pattern", () => {
|
|
1719
|
+
const pattern = def.innerType._zod.pattern;
|
|
1720
|
+
return pattern ? new RegExp(`^(${cleanRegex(pattern.source)})?$`) : undefined;
|
|
1721
|
+
});
|
|
1722
|
+
inst._zod.parse = (payload, ctx) => {
|
|
1723
|
+
if (def.innerType._zod.optin === "optional") {
|
|
1724
|
+
const result = def.innerType._zod.run(payload, ctx);
|
|
1725
|
+
if (result instanceof Promise)
|
|
1726
|
+
return result.then((r) => handleOptionalResult(r, payload.value));
|
|
1727
|
+
return handleOptionalResult(result, payload.value);
|
|
1728
|
+
}
|
|
1729
|
+
if (payload.value === undefined) {
|
|
1730
|
+
return payload;
|
|
1731
|
+
}
|
|
1732
|
+
return def.innerType._zod.run(payload, ctx);
|
|
1733
|
+
};
|
|
1734
|
+
});
|
|
1735
|
+
const $ZodNullable = /*@__PURE__*/ $constructor("$ZodNullable", (inst, def) => {
|
|
1736
|
+
$ZodType.init(inst, def);
|
|
1737
|
+
defineLazy(inst._zod, "optin", () => def.innerType._zod.optin);
|
|
1738
|
+
defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
|
|
1739
|
+
defineLazy(inst._zod, "pattern", () => {
|
|
1740
|
+
const pattern = def.innerType._zod.pattern;
|
|
1741
|
+
return pattern ? new RegExp(`^(${cleanRegex(pattern.source)}|null)$`) : undefined;
|
|
1742
|
+
});
|
|
1743
|
+
defineLazy(inst._zod, "values", () => {
|
|
1744
|
+
return def.innerType._zod.values ? new Set([...def.innerType._zod.values, null]) : undefined;
|
|
1745
|
+
});
|
|
1746
|
+
inst._zod.parse = (payload, ctx) => {
|
|
1747
|
+
if (payload.value === null)
|
|
1748
|
+
return payload;
|
|
1749
|
+
return def.innerType._zod.run(payload, ctx);
|
|
1750
|
+
};
|
|
1751
|
+
});
|
|
1752
|
+
const $ZodDefault = /*@__PURE__*/ $constructor("$ZodDefault", (inst, def) => {
|
|
1753
|
+
$ZodType.init(inst, def);
|
|
1754
|
+
// inst._zod.qin = "true";
|
|
1755
|
+
inst._zod.optin = "optional";
|
|
1756
|
+
defineLazy(inst._zod, "values", () => def.innerType._zod.values);
|
|
1757
|
+
inst._zod.parse = (payload, ctx) => {
|
|
1758
|
+
if (payload.value === undefined) {
|
|
1759
|
+
payload.value = def.defaultValue;
|
|
1760
|
+
/**
|
|
1761
|
+
* $ZodDefault always returns the default value immediately.
|
|
1762
|
+
* It doesn't pass the default value into the validator ("prefault"). There's no reason to pass the default value through validation. The validity of the default is enforced by TypeScript statically. Otherwise, it's the responsibility of the user to ensure the default is valid. In the case of pipes with divergent in/out types, you can specify the default on the `in` schema of your ZodPipe to set a "prefault" for the pipe. */
|
|
1763
|
+
return payload;
|
|
1764
|
+
}
|
|
1765
|
+
const result = def.innerType._zod.run(payload, ctx);
|
|
1766
|
+
if (result instanceof Promise) {
|
|
1767
|
+
return result.then((result) => handleDefaultResult(result, def));
|
|
1768
|
+
}
|
|
1769
|
+
return handleDefaultResult(result, def);
|
|
1770
|
+
};
|
|
1771
|
+
});
|
|
1772
|
+
function handleDefaultResult(payload, def) {
|
|
1773
|
+
if (payload.value === undefined) {
|
|
1774
|
+
payload.value = def.defaultValue;
|
|
1775
|
+
}
|
|
1776
|
+
return payload;
|
|
1777
|
+
}
|
|
1778
|
+
const $ZodPrefault = /*@__PURE__*/ $constructor("$ZodPrefault", (inst, def) => {
|
|
1779
|
+
$ZodType.init(inst, def);
|
|
1780
|
+
inst._zod.optin = "optional";
|
|
1781
|
+
defineLazy(inst._zod, "values", () => def.innerType._zod.values);
|
|
1782
|
+
inst._zod.parse = (payload, ctx) => {
|
|
1783
|
+
if (payload.value === undefined) {
|
|
1784
|
+
payload.value = def.defaultValue;
|
|
1785
|
+
}
|
|
1786
|
+
return def.innerType._zod.run(payload, ctx);
|
|
1787
|
+
};
|
|
1788
|
+
});
|
|
1789
|
+
const $ZodNonOptional = /*@__PURE__*/ $constructor("$ZodNonOptional", (inst, def) => {
|
|
1790
|
+
$ZodType.init(inst, def);
|
|
1791
|
+
defineLazy(inst._zod, "values", () => {
|
|
1792
|
+
const v = def.innerType._zod.values;
|
|
1793
|
+
return v ? new Set([...v].filter((x) => x !== undefined)) : undefined;
|
|
1794
|
+
});
|
|
1795
|
+
inst._zod.parse = (payload, ctx) => {
|
|
1796
|
+
const result = def.innerType._zod.run(payload, ctx);
|
|
1797
|
+
if (result instanceof Promise) {
|
|
1798
|
+
return result.then((result) => handleNonOptionalResult(result, inst));
|
|
1799
|
+
}
|
|
1800
|
+
return handleNonOptionalResult(result, inst);
|
|
1801
|
+
};
|
|
1802
|
+
});
|
|
1803
|
+
function handleNonOptionalResult(payload, inst) {
|
|
1804
|
+
if (!payload.issues.length && payload.value === undefined) {
|
|
1805
|
+
payload.issues.push({
|
|
1806
|
+
code: "invalid_type",
|
|
1807
|
+
expected: "nonoptional",
|
|
1808
|
+
input: payload.value,
|
|
1809
|
+
inst,
|
|
1810
|
+
});
|
|
1811
|
+
}
|
|
1812
|
+
return payload;
|
|
1813
|
+
}
|
|
1814
|
+
const $ZodCatch = /*@__PURE__*/ $constructor("$ZodCatch", (inst, def) => {
|
|
1815
|
+
$ZodType.init(inst, def);
|
|
1816
|
+
defineLazy(inst._zod, "optin", () => def.innerType._zod.optin);
|
|
1817
|
+
defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
|
|
1818
|
+
defineLazy(inst._zod, "values", () => def.innerType._zod.values);
|
|
1819
|
+
inst._zod.parse = (payload, ctx) => {
|
|
1820
|
+
const result = def.innerType._zod.run(payload, ctx);
|
|
1821
|
+
if (result instanceof Promise) {
|
|
1822
|
+
return result.then((result) => {
|
|
1823
|
+
payload.value = result.value;
|
|
1824
|
+
if (result.issues.length) {
|
|
1825
|
+
payload.value = def.catchValue({
|
|
1826
|
+
...payload,
|
|
1827
|
+
error: {
|
|
1828
|
+
issues: result.issues.map((iss) => finalizeIssue(iss, ctx, config())),
|
|
1829
|
+
},
|
|
1830
|
+
input: payload.value,
|
|
1831
|
+
});
|
|
1832
|
+
payload.issues = [];
|
|
1833
|
+
}
|
|
1834
|
+
return payload;
|
|
1835
|
+
});
|
|
1836
|
+
}
|
|
1837
|
+
payload.value = result.value;
|
|
1838
|
+
if (result.issues.length) {
|
|
1839
|
+
payload.value = def.catchValue({
|
|
1840
|
+
...payload,
|
|
1841
|
+
error: {
|
|
1842
|
+
issues: result.issues.map((iss) => finalizeIssue(iss, ctx, config())),
|
|
1843
|
+
},
|
|
1844
|
+
input: payload.value,
|
|
1845
|
+
});
|
|
1846
|
+
payload.issues = [];
|
|
1847
|
+
}
|
|
1848
|
+
return payload;
|
|
1849
|
+
};
|
|
1850
|
+
});
|
|
1851
|
+
const $ZodPipe = /*@__PURE__*/ $constructor("$ZodPipe", (inst, def) => {
|
|
1852
|
+
$ZodType.init(inst, def);
|
|
1853
|
+
defineLazy(inst._zod, "values", () => def.in._zod.values);
|
|
1854
|
+
defineLazy(inst._zod, "optin", () => def.in._zod.optin);
|
|
1855
|
+
defineLazy(inst._zod, "optout", () => def.out._zod.optout);
|
|
1856
|
+
defineLazy(inst._zod, "propValues", () => def.in._zod.propValues);
|
|
1857
|
+
inst._zod.parse = (payload, ctx) => {
|
|
1858
|
+
const left = def.in._zod.run(payload, ctx);
|
|
1859
|
+
if (left instanceof Promise) {
|
|
1860
|
+
return left.then((left) => handlePipeResult(left, def, ctx));
|
|
1861
|
+
}
|
|
1862
|
+
return handlePipeResult(left, def, ctx);
|
|
1863
|
+
};
|
|
1864
|
+
});
|
|
1865
|
+
function handlePipeResult(left, def, ctx) {
|
|
1866
|
+
if (left.issues.length) {
|
|
1867
|
+
return left;
|
|
1868
|
+
}
|
|
1869
|
+
return def.out._zod.run({ value: left.value, issues: left.issues }, ctx);
|
|
1870
|
+
}
|
|
1871
|
+
const $ZodReadonly = /*@__PURE__*/ $constructor("$ZodReadonly", (inst, def) => {
|
|
1872
|
+
$ZodType.init(inst, def);
|
|
1873
|
+
defineLazy(inst._zod, "propValues", () => def.innerType._zod.propValues);
|
|
1874
|
+
defineLazy(inst._zod, "values", () => def.innerType._zod.values);
|
|
1875
|
+
defineLazy(inst._zod, "optin", () => def.innerType._zod.optin);
|
|
1876
|
+
defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
|
|
1877
|
+
inst._zod.parse = (payload, ctx) => {
|
|
1878
|
+
const result = def.innerType._zod.run(payload, ctx);
|
|
1879
|
+
if (result instanceof Promise) {
|
|
1880
|
+
return result.then(handleReadonlyResult);
|
|
1881
|
+
}
|
|
1882
|
+
return handleReadonlyResult(result);
|
|
1883
|
+
};
|
|
1884
|
+
});
|
|
1885
|
+
function handleReadonlyResult(payload) {
|
|
1886
|
+
payload.value = Object.freeze(payload.value);
|
|
1887
|
+
return payload;
|
|
1888
|
+
}
|
|
1889
|
+
const $ZodCustom = /*@__PURE__*/ $constructor("$ZodCustom", (inst, def) => {
|
|
1890
|
+
$ZodCheck.init(inst, def);
|
|
1891
|
+
$ZodType.init(inst, def);
|
|
1892
|
+
inst._zod.parse = (payload, _) => {
|
|
1893
|
+
return payload;
|
|
1894
|
+
};
|
|
1895
|
+
inst._zod.check = (payload) => {
|
|
1896
|
+
const input = payload.value;
|
|
1897
|
+
const r = def.fn(input);
|
|
1898
|
+
if (r instanceof Promise) {
|
|
1899
|
+
return r.then((r) => handleRefineResult(r, payload, input, inst));
|
|
1900
|
+
}
|
|
1901
|
+
handleRefineResult(r, payload, input, inst);
|
|
1902
|
+
return;
|
|
1903
|
+
};
|
|
1904
|
+
});
|
|
1905
|
+
function handleRefineResult(result, payload, input, inst) {
|
|
1906
|
+
if (!result) {
|
|
1907
|
+
const _iss = {
|
|
1908
|
+
code: "custom",
|
|
1909
|
+
input,
|
|
1910
|
+
inst, // incorporates params.error into issue reporting
|
|
1911
|
+
path: [...(inst._zod.def.path ?? [])], // incorporates params.error into issue reporting
|
|
1912
|
+
continue: !inst._zod.def.abort,
|
|
1913
|
+
// params: inst._zod.def.params,
|
|
1914
|
+
};
|
|
1915
|
+
if (inst._zod.def.params)
|
|
1916
|
+
_iss.params = inst._zod.def.params;
|
|
1917
|
+
payload.issues.push(issue(_iss));
|
|
1918
|
+
}
|
|
1919
|
+
}
|
|
1920
|
+
|
|
1921
|
+
class $ZodRegistry {
|
|
1922
|
+
constructor() {
|
|
1923
|
+
this._map = new Map();
|
|
1924
|
+
this._idmap = new Map();
|
|
1925
|
+
}
|
|
1926
|
+
add(schema, ..._meta) {
|
|
1927
|
+
const meta = _meta[0];
|
|
1928
|
+
this._map.set(schema, meta);
|
|
1929
|
+
if (meta && typeof meta === "object" && "id" in meta) {
|
|
1930
|
+
if (this._idmap.has(meta.id)) {
|
|
1931
|
+
throw new Error(`ID ${meta.id} already exists in the registry`);
|
|
1932
|
+
}
|
|
1933
|
+
this._idmap.set(meta.id, schema);
|
|
1934
|
+
}
|
|
1935
|
+
return this;
|
|
1936
|
+
}
|
|
1937
|
+
clear() {
|
|
1938
|
+
this._map = new Map();
|
|
1939
|
+
this._idmap = new Map();
|
|
1940
|
+
return this;
|
|
1941
|
+
}
|
|
1942
|
+
remove(schema) {
|
|
1943
|
+
const meta = this._map.get(schema);
|
|
1944
|
+
if (meta && typeof meta === "object" && "id" in meta) {
|
|
1945
|
+
this._idmap.delete(meta.id);
|
|
1946
|
+
}
|
|
1947
|
+
this._map.delete(schema);
|
|
1948
|
+
return this;
|
|
1949
|
+
}
|
|
1950
|
+
get(schema) {
|
|
1951
|
+
// return this._map.get(schema) as any;
|
|
1952
|
+
// inherit metadata
|
|
1953
|
+
const p = schema._zod.parent;
|
|
1954
|
+
if (p) {
|
|
1955
|
+
const pm = { ...(this.get(p) ?? {}) };
|
|
1956
|
+
delete pm.id; // do not inherit id
|
|
1957
|
+
const f = { ...pm, ...this._map.get(schema) };
|
|
1958
|
+
return Object.keys(f).length ? f : undefined;
|
|
1959
|
+
}
|
|
1960
|
+
return this._map.get(schema);
|
|
1961
|
+
}
|
|
1962
|
+
has(schema) {
|
|
1963
|
+
return this._map.has(schema);
|
|
1964
|
+
}
|
|
1965
|
+
}
|
|
1966
|
+
// registries
|
|
1967
|
+
function registry() {
|
|
1968
|
+
return new $ZodRegistry();
|
|
1969
|
+
}
|
|
1970
|
+
const globalRegistry = /*@__PURE__*/ registry();
|
|
1971
|
+
|
|
1972
|
+
function _string(Class, params) {
|
|
1973
|
+
return new Class({
|
|
1974
|
+
type: "string",
|
|
1975
|
+
...normalizeParams(params),
|
|
1976
|
+
});
|
|
1977
|
+
}
|
|
1978
|
+
function _email(Class, params) {
|
|
1979
|
+
return new Class({
|
|
1980
|
+
type: "string",
|
|
1981
|
+
format: "email",
|
|
1982
|
+
check: "string_format",
|
|
1983
|
+
abort: false,
|
|
1984
|
+
...normalizeParams(params),
|
|
1985
|
+
});
|
|
1986
|
+
}
|
|
1987
|
+
function _guid(Class, params) {
|
|
1988
|
+
return new Class({
|
|
1989
|
+
type: "string",
|
|
1990
|
+
format: "guid",
|
|
1991
|
+
check: "string_format",
|
|
1992
|
+
abort: false,
|
|
1993
|
+
...normalizeParams(params),
|
|
1994
|
+
});
|
|
1995
|
+
}
|
|
1996
|
+
function _uuid(Class, params) {
|
|
1997
|
+
return new Class({
|
|
1998
|
+
type: "string",
|
|
1999
|
+
format: "uuid",
|
|
2000
|
+
check: "string_format",
|
|
2001
|
+
abort: false,
|
|
2002
|
+
...normalizeParams(params),
|
|
2003
|
+
});
|
|
2004
|
+
}
|
|
2005
|
+
function _uuidv4(Class, params) {
|
|
2006
|
+
return new Class({
|
|
2007
|
+
type: "string",
|
|
2008
|
+
format: "uuid",
|
|
2009
|
+
check: "string_format",
|
|
2010
|
+
abort: false,
|
|
2011
|
+
version: "v4",
|
|
2012
|
+
...normalizeParams(params),
|
|
2013
|
+
});
|
|
2014
|
+
}
|
|
2015
|
+
function _uuidv6(Class, params) {
|
|
2016
|
+
return new Class({
|
|
2017
|
+
type: "string",
|
|
2018
|
+
format: "uuid",
|
|
2019
|
+
check: "string_format",
|
|
2020
|
+
abort: false,
|
|
2021
|
+
version: "v6",
|
|
2022
|
+
...normalizeParams(params),
|
|
2023
|
+
});
|
|
2024
|
+
}
|
|
2025
|
+
function _uuidv7(Class, params) {
|
|
2026
|
+
return new Class({
|
|
2027
|
+
type: "string",
|
|
2028
|
+
format: "uuid",
|
|
2029
|
+
check: "string_format",
|
|
2030
|
+
abort: false,
|
|
2031
|
+
version: "v7",
|
|
2032
|
+
...normalizeParams(params),
|
|
2033
|
+
});
|
|
2034
|
+
}
|
|
2035
|
+
function _url(Class, params) {
|
|
2036
|
+
return new Class({
|
|
2037
|
+
type: "string",
|
|
2038
|
+
format: "url",
|
|
2039
|
+
check: "string_format",
|
|
2040
|
+
abort: false,
|
|
2041
|
+
...normalizeParams(params),
|
|
2042
|
+
});
|
|
2043
|
+
}
|
|
2044
|
+
function _emoji(Class, params) {
|
|
2045
|
+
return new Class({
|
|
2046
|
+
type: "string",
|
|
2047
|
+
format: "emoji",
|
|
2048
|
+
check: "string_format",
|
|
2049
|
+
abort: false,
|
|
2050
|
+
...normalizeParams(params),
|
|
2051
|
+
});
|
|
2052
|
+
}
|
|
2053
|
+
function _nanoid(Class, params) {
|
|
2054
|
+
return new Class({
|
|
2055
|
+
type: "string",
|
|
2056
|
+
format: "nanoid",
|
|
2057
|
+
check: "string_format",
|
|
2058
|
+
abort: false,
|
|
2059
|
+
...normalizeParams(params),
|
|
2060
|
+
});
|
|
2061
|
+
}
|
|
2062
|
+
function _cuid(Class, params) {
|
|
2063
|
+
return new Class({
|
|
2064
|
+
type: "string",
|
|
2065
|
+
format: "cuid",
|
|
2066
|
+
check: "string_format",
|
|
2067
|
+
abort: false,
|
|
2068
|
+
...normalizeParams(params),
|
|
2069
|
+
});
|
|
2070
|
+
}
|
|
2071
|
+
function _cuid2(Class, params) {
|
|
2072
|
+
return new Class({
|
|
2073
|
+
type: "string",
|
|
2074
|
+
format: "cuid2",
|
|
2075
|
+
check: "string_format",
|
|
2076
|
+
abort: false,
|
|
2077
|
+
...normalizeParams(params),
|
|
2078
|
+
});
|
|
2079
|
+
}
|
|
2080
|
+
function _ulid(Class, params) {
|
|
2081
|
+
return new Class({
|
|
2082
|
+
type: "string",
|
|
2083
|
+
format: "ulid",
|
|
2084
|
+
check: "string_format",
|
|
2085
|
+
abort: false,
|
|
2086
|
+
...normalizeParams(params),
|
|
2087
|
+
});
|
|
2088
|
+
}
|
|
2089
|
+
function _xid(Class, params) {
|
|
2090
|
+
return new Class({
|
|
2091
|
+
type: "string",
|
|
2092
|
+
format: "xid",
|
|
2093
|
+
check: "string_format",
|
|
2094
|
+
abort: false,
|
|
2095
|
+
...normalizeParams(params),
|
|
2096
|
+
});
|
|
2097
|
+
}
|
|
2098
|
+
function _ksuid(Class, params) {
|
|
2099
|
+
return new Class({
|
|
2100
|
+
type: "string",
|
|
2101
|
+
format: "ksuid",
|
|
2102
|
+
check: "string_format",
|
|
2103
|
+
abort: false,
|
|
2104
|
+
...normalizeParams(params),
|
|
2105
|
+
});
|
|
2106
|
+
}
|
|
2107
|
+
function _ipv4(Class, params) {
|
|
2108
|
+
return new Class({
|
|
2109
|
+
type: "string",
|
|
2110
|
+
format: "ipv4",
|
|
2111
|
+
check: "string_format",
|
|
2112
|
+
abort: false,
|
|
2113
|
+
...normalizeParams(params),
|
|
2114
|
+
});
|
|
2115
|
+
}
|
|
2116
|
+
function _ipv6(Class, params) {
|
|
2117
|
+
return new Class({
|
|
2118
|
+
type: "string",
|
|
2119
|
+
format: "ipv6",
|
|
2120
|
+
check: "string_format",
|
|
2121
|
+
abort: false,
|
|
2122
|
+
...normalizeParams(params),
|
|
2123
|
+
});
|
|
2124
|
+
}
|
|
2125
|
+
function _cidrv4(Class, params) {
|
|
2126
|
+
return new Class({
|
|
2127
|
+
type: "string",
|
|
2128
|
+
format: "cidrv4",
|
|
2129
|
+
check: "string_format",
|
|
2130
|
+
abort: false,
|
|
2131
|
+
...normalizeParams(params),
|
|
2132
|
+
});
|
|
2133
|
+
}
|
|
2134
|
+
function _cidrv6(Class, params) {
|
|
2135
|
+
return new Class({
|
|
2136
|
+
type: "string",
|
|
2137
|
+
format: "cidrv6",
|
|
2138
|
+
check: "string_format",
|
|
2139
|
+
abort: false,
|
|
2140
|
+
...normalizeParams(params),
|
|
2141
|
+
});
|
|
2142
|
+
}
|
|
2143
|
+
function _base64(Class, params) {
|
|
2144
|
+
return new Class({
|
|
2145
|
+
type: "string",
|
|
2146
|
+
format: "base64",
|
|
2147
|
+
check: "string_format",
|
|
2148
|
+
abort: false,
|
|
2149
|
+
...normalizeParams(params),
|
|
2150
|
+
});
|
|
2151
|
+
}
|
|
2152
|
+
function _base64url(Class, params) {
|
|
2153
|
+
return new Class({
|
|
2154
|
+
type: "string",
|
|
2155
|
+
format: "base64url",
|
|
2156
|
+
check: "string_format",
|
|
2157
|
+
abort: false,
|
|
2158
|
+
...normalizeParams(params),
|
|
2159
|
+
});
|
|
2160
|
+
}
|
|
2161
|
+
function _e164(Class, params) {
|
|
2162
|
+
return new Class({
|
|
2163
|
+
type: "string",
|
|
2164
|
+
format: "e164",
|
|
2165
|
+
check: "string_format",
|
|
2166
|
+
abort: false,
|
|
2167
|
+
...normalizeParams(params),
|
|
2168
|
+
});
|
|
2169
|
+
}
|
|
2170
|
+
function _jwt(Class, params) {
|
|
2171
|
+
return new Class({
|
|
2172
|
+
type: "string",
|
|
2173
|
+
format: "jwt",
|
|
2174
|
+
check: "string_format",
|
|
2175
|
+
abort: false,
|
|
2176
|
+
...normalizeParams(params),
|
|
2177
|
+
});
|
|
2178
|
+
}
|
|
2179
|
+
function _isoDateTime(Class, params) {
|
|
2180
|
+
return new Class({
|
|
2181
|
+
type: "string",
|
|
2182
|
+
format: "datetime",
|
|
2183
|
+
check: "string_format",
|
|
2184
|
+
offset: false,
|
|
2185
|
+
local: false,
|
|
2186
|
+
precision: null,
|
|
2187
|
+
...normalizeParams(params),
|
|
2188
|
+
});
|
|
2189
|
+
}
|
|
2190
|
+
function _isoDate(Class, params) {
|
|
2191
|
+
return new Class({
|
|
2192
|
+
type: "string",
|
|
2193
|
+
format: "date",
|
|
2194
|
+
check: "string_format",
|
|
2195
|
+
...normalizeParams(params),
|
|
2196
|
+
});
|
|
2197
|
+
}
|
|
2198
|
+
function _isoTime(Class, params) {
|
|
2199
|
+
return new Class({
|
|
2200
|
+
type: "string",
|
|
2201
|
+
format: "time",
|
|
2202
|
+
check: "string_format",
|
|
2203
|
+
precision: null,
|
|
2204
|
+
...normalizeParams(params),
|
|
2205
|
+
});
|
|
2206
|
+
}
|
|
2207
|
+
function _isoDuration(Class, params) {
|
|
2208
|
+
return new Class({
|
|
2209
|
+
type: "string",
|
|
2210
|
+
format: "duration",
|
|
2211
|
+
check: "string_format",
|
|
2212
|
+
...normalizeParams(params),
|
|
2213
|
+
});
|
|
2214
|
+
}
|
|
2215
|
+
function _unknown(Class) {
|
|
2216
|
+
return new Class({
|
|
2217
|
+
type: "unknown",
|
|
2218
|
+
});
|
|
2219
|
+
}
|
|
2220
|
+
function _never(Class, params) {
|
|
2221
|
+
return new Class({
|
|
2222
|
+
type: "never",
|
|
2223
|
+
...normalizeParams(params),
|
|
2224
|
+
});
|
|
2225
|
+
}
|
|
2226
|
+
function _maxLength(maximum, params) {
|
|
2227
|
+
const ch = new $ZodCheckMaxLength({
|
|
2228
|
+
check: "max_length",
|
|
2229
|
+
...normalizeParams(params),
|
|
2230
|
+
maximum,
|
|
2231
|
+
});
|
|
2232
|
+
return ch;
|
|
2233
|
+
}
|
|
2234
|
+
function _minLength(minimum, params) {
|
|
2235
|
+
return new $ZodCheckMinLength({
|
|
2236
|
+
check: "min_length",
|
|
2237
|
+
...normalizeParams(params),
|
|
2238
|
+
minimum,
|
|
2239
|
+
});
|
|
2240
|
+
}
|
|
2241
|
+
function _length(length, params) {
|
|
2242
|
+
return new $ZodCheckLengthEquals({
|
|
2243
|
+
check: "length_equals",
|
|
2244
|
+
...normalizeParams(params),
|
|
2245
|
+
length,
|
|
2246
|
+
});
|
|
2247
|
+
}
|
|
2248
|
+
function _regex(pattern, params) {
|
|
2249
|
+
return new $ZodCheckRegex({
|
|
2250
|
+
check: "string_format",
|
|
2251
|
+
format: "regex",
|
|
2252
|
+
...normalizeParams(params),
|
|
2253
|
+
pattern,
|
|
2254
|
+
});
|
|
2255
|
+
}
|
|
2256
|
+
function _lowercase(params) {
|
|
2257
|
+
return new $ZodCheckLowerCase({
|
|
2258
|
+
check: "string_format",
|
|
2259
|
+
format: "lowercase",
|
|
2260
|
+
...normalizeParams(params),
|
|
2261
|
+
});
|
|
2262
|
+
}
|
|
2263
|
+
function _uppercase(params) {
|
|
2264
|
+
return new $ZodCheckUpperCase({
|
|
2265
|
+
check: "string_format",
|
|
2266
|
+
format: "uppercase",
|
|
2267
|
+
...normalizeParams(params),
|
|
2268
|
+
});
|
|
2269
|
+
}
|
|
2270
|
+
function _includes(includes, params) {
|
|
2271
|
+
return new $ZodCheckIncludes({
|
|
2272
|
+
check: "string_format",
|
|
2273
|
+
format: "includes",
|
|
2274
|
+
...normalizeParams(params),
|
|
2275
|
+
includes,
|
|
2276
|
+
});
|
|
2277
|
+
}
|
|
2278
|
+
function _startsWith(prefix, params) {
|
|
2279
|
+
return new $ZodCheckStartsWith({
|
|
2280
|
+
check: "string_format",
|
|
2281
|
+
format: "starts_with",
|
|
2282
|
+
...normalizeParams(params),
|
|
2283
|
+
prefix,
|
|
2284
|
+
});
|
|
2285
|
+
}
|
|
2286
|
+
function _endsWith(suffix, params) {
|
|
2287
|
+
return new $ZodCheckEndsWith({
|
|
2288
|
+
check: "string_format",
|
|
2289
|
+
format: "ends_with",
|
|
2290
|
+
...normalizeParams(params),
|
|
2291
|
+
suffix,
|
|
2292
|
+
});
|
|
2293
|
+
}
|
|
2294
|
+
function _overwrite(tx) {
|
|
2295
|
+
return new $ZodCheckOverwrite({
|
|
2296
|
+
check: "overwrite",
|
|
2297
|
+
tx,
|
|
2298
|
+
});
|
|
2299
|
+
}
|
|
2300
|
+
// normalize
|
|
2301
|
+
function _normalize(form) {
|
|
2302
|
+
return _overwrite((input) => input.normalize(form));
|
|
2303
|
+
}
|
|
2304
|
+
// trim
|
|
2305
|
+
function _trim() {
|
|
2306
|
+
return _overwrite((input) => input.trim());
|
|
2307
|
+
}
|
|
2308
|
+
// toLowerCase
|
|
2309
|
+
function _toLowerCase() {
|
|
2310
|
+
return _overwrite((input) => input.toLowerCase());
|
|
2311
|
+
}
|
|
2312
|
+
// toUpperCase
|
|
2313
|
+
function _toUpperCase() {
|
|
2314
|
+
return _overwrite((input) => input.toUpperCase());
|
|
2315
|
+
}
|
|
2316
|
+
function _array(Class, element, params) {
|
|
2317
|
+
return new Class({
|
|
2318
|
+
type: "array",
|
|
2319
|
+
element,
|
|
2320
|
+
// get element() {
|
|
2321
|
+
// return element;
|
|
2322
|
+
// },
|
|
2323
|
+
...normalizeParams(params),
|
|
2324
|
+
});
|
|
2325
|
+
}
|
|
2326
|
+
// same as _custom but defaults to abort:false
|
|
2327
|
+
function _refine(Class, fn, _params) {
|
|
2328
|
+
const schema = new Class({
|
|
2329
|
+
type: "custom",
|
|
2330
|
+
check: "custom",
|
|
2331
|
+
fn: fn,
|
|
2332
|
+
...normalizeParams(_params),
|
|
2333
|
+
});
|
|
2334
|
+
return schema;
|
|
2335
|
+
}
|
|
2336
|
+
function _superRefine(fn) {
|
|
2337
|
+
const ch = _check((payload) => {
|
|
2338
|
+
payload.addIssue = (issue$1) => {
|
|
2339
|
+
if (typeof issue$1 === "string") {
|
|
2340
|
+
payload.issues.push(issue(issue$1, payload.value, ch._zod.def));
|
|
2341
|
+
}
|
|
2342
|
+
else {
|
|
2343
|
+
// for Zod 3 backwards compatibility
|
|
2344
|
+
const _issue = issue$1;
|
|
2345
|
+
if (_issue.fatal)
|
|
2346
|
+
_issue.continue = false;
|
|
2347
|
+
_issue.code ?? (_issue.code = "custom");
|
|
2348
|
+
_issue.input ?? (_issue.input = payload.value);
|
|
2349
|
+
_issue.inst ?? (_issue.inst = ch);
|
|
2350
|
+
_issue.continue ?? (_issue.continue = !ch._zod.def.abort);
|
|
2351
|
+
payload.issues.push(issue(_issue));
|
|
2352
|
+
}
|
|
2353
|
+
};
|
|
2354
|
+
return fn(payload.value, payload);
|
|
2355
|
+
});
|
|
2356
|
+
return ch;
|
|
2357
|
+
}
|
|
2358
|
+
function _check(fn, params) {
|
|
2359
|
+
const ch = new $ZodCheck({
|
|
2360
|
+
check: "custom",
|
|
2361
|
+
...normalizeParams(params),
|
|
2362
|
+
});
|
|
2363
|
+
ch._zod.check = fn;
|
|
2364
|
+
return ch;
|
|
2365
|
+
}
|
|
2366
|
+
|
|
2367
|
+
const ZodISODateTime = /*@__PURE__*/ $constructor("ZodISODateTime", (inst, def) => {
|
|
2368
|
+
$ZodISODateTime.init(inst, def);
|
|
2369
|
+
ZodStringFormat.init(inst, def);
|
|
2370
|
+
});
|
|
2371
|
+
function datetime(params) {
|
|
2372
|
+
return _isoDateTime(ZodISODateTime, params);
|
|
2373
|
+
}
|
|
2374
|
+
const ZodISODate = /*@__PURE__*/ $constructor("ZodISODate", (inst, def) => {
|
|
2375
|
+
$ZodISODate.init(inst, def);
|
|
2376
|
+
ZodStringFormat.init(inst, def);
|
|
2377
|
+
});
|
|
2378
|
+
function date(params) {
|
|
2379
|
+
return _isoDate(ZodISODate, params);
|
|
2380
|
+
}
|
|
2381
|
+
const ZodISOTime = /*@__PURE__*/ $constructor("ZodISOTime", (inst, def) => {
|
|
2382
|
+
$ZodISOTime.init(inst, def);
|
|
2383
|
+
ZodStringFormat.init(inst, def);
|
|
2384
|
+
});
|
|
2385
|
+
function time(params) {
|
|
2386
|
+
return _isoTime(ZodISOTime, params);
|
|
2387
|
+
}
|
|
2388
|
+
const ZodISODuration = /*@__PURE__*/ $constructor("ZodISODuration", (inst, def) => {
|
|
2389
|
+
$ZodISODuration.init(inst, def);
|
|
2390
|
+
ZodStringFormat.init(inst, def);
|
|
2391
|
+
});
|
|
2392
|
+
function duration(params) {
|
|
2393
|
+
return _isoDuration(ZodISODuration, params);
|
|
2394
|
+
}
|
|
2395
|
+
|
|
2396
|
+
const initializer = (inst, issues) => {
|
|
2397
|
+
$ZodError.init(inst, issues);
|
|
2398
|
+
inst.name = "ZodError";
|
|
2399
|
+
Object.defineProperties(inst, {
|
|
2400
|
+
format: {
|
|
2401
|
+
value: (mapper) => formatError(inst, mapper),
|
|
2402
|
+
// enumerable: false,
|
|
2403
|
+
},
|
|
2404
|
+
flatten: {
|
|
2405
|
+
value: (mapper) => flattenError(inst, mapper),
|
|
2406
|
+
// enumerable: false,
|
|
2407
|
+
},
|
|
2408
|
+
addIssue: {
|
|
2409
|
+
value: (issue) => {
|
|
2410
|
+
inst.issues.push(issue);
|
|
2411
|
+
inst.message = JSON.stringify(inst.issues, jsonStringifyReplacer, 2);
|
|
2412
|
+
},
|
|
2413
|
+
// enumerable: false,
|
|
2414
|
+
},
|
|
2415
|
+
addIssues: {
|
|
2416
|
+
value: (issues) => {
|
|
2417
|
+
inst.issues.push(...issues);
|
|
2418
|
+
inst.message = JSON.stringify(inst.issues, jsonStringifyReplacer, 2);
|
|
2419
|
+
},
|
|
2420
|
+
// enumerable: false,
|
|
2421
|
+
},
|
|
2422
|
+
isEmpty: {
|
|
2423
|
+
get() {
|
|
2424
|
+
return inst.issues.length === 0;
|
|
2425
|
+
},
|
|
2426
|
+
// enumerable: false,
|
|
2427
|
+
},
|
|
2428
|
+
});
|
|
2429
|
+
// Object.defineProperty(inst, "isEmpty", {
|
|
2430
|
+
// get() {
|
|
2431
|
+
// return inst.issues.length === 0;
|
|
2432
|
+
// },
|
|
2433
|
+
// });
|
|
2434
|
+
};
|
|
2435
|
+
const ZodRealError = $constructor("ZodError", initializer, {
|
|
2436
|
+
Parent: Error,
|
|
2437
|
+
});
|
|
2438
|
+
// /** @deprecated Use `z.core.$ZodErrorMapCtx` instead. */
|
|
2439
|
+
// export type ErrorMapCtx = core.$ZodErrorMapCtx;
|
|
2440
|
+
|
|
2441
|
+
const parse = /* @__PURE__ */ _parse(ZodRealError);
|
|
2442
|
+
const parseAsync = /* @__PURE__ */ _parseAsync(ZodRealError);
|
|
2443
|
+
const safeParse = /* @__PURE__ */ _safeParse(ZodRealError);
|
|
2444
|
+
const safeParseAsync = /* @__PURE__ */ _safeParseAsync(ZodRealError);
|
|
2445
|
+
|
|
2446
|
+
const ZodType = /*@__PURE__*/ $constructor("ZodType", (inst, def) => {
|
|
2447
|
+
$ZodType.init(inst, def);
|
|
2448
|
+
inst.def = def;
|
|
2449
|
+
Object.defineProperty(inst, "_def", { value: def });
|
|
2450
|
+
// base methods
|
|
2451
|
+
inst.check = (...checks) => {
|
|
2452
|
+
return inst.clone({
|
|
2453
|
+
...def,
|
|
2454
|
+
checks: [
|
|
2455
|
+
...(def.checks ?? []),
|
|
2456
|
+
...checks.map((ch) => typeof ch === "function" ? { _zod: { check: ch, def: { check: "custom" }, onattach: [] } } : ch),
|
|
2457
|
+
],
|
|
2458
|
+
}
|
|
2459
|
+
// { parent: true }
|
|
2460
|
+
);
|
|
2461
|
+
};
|
|
2462
|
+
inst.clone = (def, params) => clone(inst, def, params);
|
|
2463
|
+
inst.brand = () => inst;
|
|
2464
|
+
inst.register = ((reg, meta) => {
|
|
2465
|
+
reg.add(inst, meta);
|
|
2466
|
+
return inst;
|
|
2467
|
+
});
|
|
2468
|
+
// parsing
|
|
2469
|
+
inst.parse = (data, params) => parse(inst, data, params, { callee: inst.parse });
|
|
2470
|
+
inst.safeParse = (data, params) => safeParse(inst, data, params);
|
|
2471
|
+
inst.parseAsync = async (data, params) => parseAsync(inst, data, params, { callee: inst.parseAsync });
|
|
2472
|
+
inst.safeParseAsync = async (data, params) => safeParseAsync(inst, data, params);
|
|
2473
|
+
inst.spa = inst.safeParseAsync;
|
|
2474
|
+
// refinements
|
|
2475
|
+
inst.refine = (check, params) => inst.check(refine(check, params));
|
|
2476
|
+
inst.superRefine = (refinement) => inst.check(superRefine(refinement));
|
|
2477
|
+
inst.overwrite = (fn) => inst.check(_overwrite(fn));
|
|
2478
|
+
// wrappers
|
|
2479
|
+
inst.optional = () => optional(inst);
|
|
2480
|
+
inst.nullable = () => nullable(inst);
|
|
2481
|
+
inst.nullish = () => optional(nullable(inst));
|
|
2482
|
+
inst.nonoptional = (params) => nonoptional(inst, params);
|
|
2483
|
+
inst.array = () => array(inst);
|
|
2484
|
+
inst.or = (arg) => union([inst, arg]);
|
|
2485
|
+
inst.and = (arg) => intersection(inst, arg);
|
|
2486
|
+
inst.transform = (tx) => pipe(inst, transform(tx));
|
|
2487
|
+
inst.default = (def) => _default(inst, def);
|
|
2488
|
+
inst.prefault = (def) => prefault(inst, def);
|
|
2489
|
+
// inst.coalesce = (def, params) => coalesce(inst, def, params);
|
|
2490
|
+
inst.catch = (params) => _catch(inst, params);
|
|
2491
|
+
inst.pipe = (target) => pipe(inst, target);
|
|
2492
|
+
inst.readonly = () => readonly(inst);
|
|
2493
|
+
// meta
|
|
2494
|
+
inst.describe = (description) => {
|
|
2495
|
+
const cl = inst.clone();
|
|
2496
|
+
globalRegistry.add(cl, { description });
|
|
2497
|
+
return cl;
|
|
2498
|
+
};
|
|
2499
|
+
Object.defineProperty(inst, "description", {
|
|
2500
|
+
get() {
|
|
2501
|
+
return globalRegistry.get(inst)?.description;
|
|
2502
|
+
},
|
|
2503
|
+
configurable: true,
|
|
2504
|
+
});
|
|
2505
|
+
inst.meta = (...args) => {
|
|
2506
|
+
if (args.length === 0) {
|
|
2507
|
+
return globalRegistry.get(inst);
|
|
2508
|
+
}
|
|
2509
|
+
const cl = inst.clone();
|
|
2510
|
+
globalRegistry.add(cl, args[0]);
|
|
2511
|
+
return cl;
|
|
2512
|
+
};
|
|
2513
|
+
// helpers
|
|
2514
|
+
inst.isOptional = () => inst.safeParse(undefined).success;
|
|
2515
|
+
inst.isNullable = () => inst.safeParse(null).success;
|
|
2516
|
+
return inst;
|
|
2517
|
+
});
|
|
2518
|
+
/** @internal */
|
|
2519
|
+
const _ZodString = /*@__PURE__*/ $constructor("_ZodString", (inst, def) => {
|
|
2520
|
+
$ZodString.init(inst, def);
|
|
2521
|
+
ZodType.init(inst, def);
|
|
2522
|
+
const bag = inst._zod.bag;
|
|
2523
|
+
inst.format = bag.format ?? null;
|
|
2524
|
+
inst.minLength = bag.minimum ?? null;
|
|
2525
|
+
inst.maxLength = bag.maximum ?? null;
|
|
2526
|
+
// validations
|
|
2527
|
+
inst.regex = (...args) => inst.check(_regex(...args));
|
|
2528
|
+
inst.includes = (...args) => inst.check(_includes(...args));
|
|
2529
|
+
inst.startsWith = (...args) => inst.check(_startsWith(...args));
|
|
2530
|
+
inst.endsWith = (...args) => inst.check(_endsWith(...args));
|
|
2531
|
+
inst.min = (...args) => inst.check(_minLength(...args));
|
|
2532
|
+
inst.max = (...args) => inst.check(_maxLength(...args));
|
|
2533
|
+
inst.length = (...args) => inst.check(_length(...args));
|
|
2534
|
+
inst.nonempty = (...args) => inst.check(_minLength(1, ...args));
|
|
2535
|
+
inst.lowercase = (params) => inst.check(_lowercase(params));
|
|
2536
|
+
inst.uppercase = (params) => inst.check(_uppercase(params));
|
|
2537
|
+
// transforms
|
|
2538
|
+
inst.trim = () => inst.check(_trim());
|
|
2539
|
+
inst.normalize = (...args) => inst.check(_normalize(...args));
|
|
2540
|
+
inst.toLowerCase = () => inst.check(_toLowerCase());
|
|
2541
|
+
inst.toUpperCase = () => inst.check(_toUpperCase());
|
|
2542
|
+
});
|
|
2543
|
+
const ZodString = /*@__PURE__*/ $constructor("ZodString", (inst, def) => {
|
|
2544
|
+
$ZodString.init(inst, def);
|
|
2545
|
+
_ZodString.init(inst, def);
|
|
2546
|
+
inst.email = (params) => inst.check(_email(ZodEmail, params));
|
|
2547
|
+
inst.url = (params) => inst.check(_url(ZodURL, params));
|
|
2548
|
+
inst.jwt = (params) => inst.check(_jwt(ZodJWT, params));
|
|
2549
|
+
inst.emoji = (params) => inst.check(_emoji(ZodEmoji, params));
|
|
2550
|
+
inst.guid = (params) => inst.check(_guid(ZodGUID, params));
|
|
2551
|
+
inst.uuid = (params) => inst.check(_uuid(ZodUUID, params));
|
|
2552
|
+
inst.uuidv4 = (params) => inst.check(_uuidv4(ZodUUID, params));
|
|
2553
|
+
inst.uuidv6 = (params) => inst.check(_uuidv6(ZodUUID, params));
|
|
2554
|
+
inst.uuidv7 = (params) => inst.check(_uuidv7(ZodUUID, params));
|
|
2555
|
+
inst.nanoid = (params) => inst.check(_nanoid(ZodNanoID, params));
|
|
2556
|
+
inst.guid = (params) => inst.check(_guid(ZodGUID, params));
|
|
2557
|
+
inst.cuid = (params) => inst.check(_cuid(ZodCUID, params));
|
|
2558
|
+
inst.cuid2 = (params) => inst.check(_cuid2(ZodCUID2, params));
|
|
2559
|
+
inst.ulid = (params) => inst.check(_ulid(ZodULID, params));
|
|
2560
|
+
inst.base64 = (params) => inst.check(_base64(ZodBase64, params));
|
|
2561
|
+
inst.base64url = (params) => inst.check(_base64url(ZodBase64URL, params));
|
|
2562
|
+
inst.xid = (params) => inst.check(_xid(ZodXID, params));
|
|
2563
|
+
inst.ksuid = (params) => inst.check(_ksuid(ZodKSUID, params));
|
|
2564
|
+
inst.ipv4 = (params) => inst.check(_ipv4(ZodIPv4, params));
|
|
2565
|
+
inst.ipv6 = (params) => inst.check(_ipv6(ZodIPv6, params));
|
|
2566
|
+
inst.cidrv4 = (params) => inst.check(_cidrv4(ZodCIDRv4, params));
|
|
2567
|
+
inst.cidrv6 = (params) => inst.check(_cidrv6(ZodCIDRv6, params));
|
|
2568
|
+
inst.e164 = (params) => inst.check(_e164(ZodE164, params));
|
|
2569
|
+
// iso
|
|
2570
|
+
inst.datetime = (params) => inst.check(datetime(params));
|
|
2571
|
+
inst.date = (params) => inst.check(date(params));
|
|
2572
|
+
inst.time = (params) => inst.check(time(params));
|
|
2573
|
+
inst.duration = (params) => inst.check(duration(params));
|
|
2574
|
+
});
|
|
2575
|
+
function string(params) {
|
|
2576
|
+
return _string(ZodString, params);
|
|
2577
|
+
}
|
|
2578
|
+
const ZodStringFormat = /*@__PURE__*/ $constructor("ZodStringFormat", (inst, def) => {
|
|
2579
|
+
$ZodStringFormat.init(inst, def);
|
|
2580
|
+
_ZodString.init(inst, def);
|
|
2581
|
+
});
|
|
2582
|
+
const ZodEmail = /*@__PURE__*/ $constructor("ZodEmail", (inst, def) => {
|
|
2583
|
+
// ZodStringFormat.init(inst, def);
|
|
2584
|
+
$ZodEmail.init(inst, def);
|
|
2585
|
+
ZodStringFormat.init(inst, def);
|
|
2586
|
+
});
|
|
2587
|
+
function email(params) {
|
|
2588
|
+
return _email(ZodEmail, params);
|
|
2589
|
+
}
|
|
2590
|
+
const ZodGUID = /*@__PURE__*/ $constructor("ZodGUID", (inst, def) => {
|
|
2591
|
+
// ZodStringFormat.init(inst, def);
|
|
2592
|
+
$ZodGUID.init(inst, def);
|
|
2593
|
+
ZodStringFormat.init(inst, def);
|
|
2594
|
+
});
|
|
2595
|
+
const ZodUUID = /*@__PURE__*/ $constructor("ZodUUID", (inst, def) => {
|
|
2596
|
+
// ZodStringFormat.init(inst, def);
|
|
2597
|
+
$ZodUUID.init(inst, def);
|
|
2598
|
+
ZodStringFormat.init(inst, def);
|
|
2599
|
+
});
|
|
2600
|
+
const ZodURL = /*@__PURE__*/ $constructor("ZodURL", (inst, def) => {
|
|
2601
|
+
// ZodStringFormat.init(inst, def);
|
|
2602
|
+
$ZodURL.init(inst, def);
|
|
2603
|
+
ZodStringFormat.init(inst, def);
|
|
2604
|
+
});
|
|
2605
|
+
const ZodEmoji = /*@__PURE__*/ $constructor("ZodEmoji", (inst, def) => {
|
|
2606
|
+
// ZodStringFormat.init(inst, def);
|
|
2607
|
+
$ZodEmoji.init(inst, def);
|
|
2608
|
+
ZodStringFormat.init(inst, def);
|
|
2609
|
+
});
|
|
2610
|
+
const ZodNanoID = /*@__PURE__*/ $constructor("ZodNanoID", (inst, def) => {
|
|
2611
|
+
// ZodStringFormat.init(inst, def);
|
|
2612
|
+
$ZodNanoID.init(inst, def);
|
|
2613
|
+
ZodStringFormat.init(inst, def);
|
|
2614
|
+
});
|
|
2615
|
+
const ZodCUID = /*@__PURE__*/ $constructor("ZodCUID", (inst, def) => {
|
|
2616
|
+
// ZodStringFormat.init(inst, def);
|
|
2617
|
+
$ZodCUID.init(inst, def);
|
|
2618
|
+
ZodStringFormat.init(inst, def);
|
|
2619
|
+
});
|
|
2620
|
+
const ZodCUID2 = /*@__PURE__*/ $constructor("ZodCUID2", (inst, def) => {
|
|
2621
|
+
// ZodStringFormat.init(inst, def);
|
|
2622
|
+
$ZodCUID2.init(inst, def);
|
|
2623
|
+
ZodStringFormat.init(inst, def);
|
|
2624
|
+
});
|
|
2625
|
+
const ZodULID = /*@__PURE__*/ $constructor("ZodULID", (inst, def) => {
|
|
2626
|
+
// ZodStringFormat.init(inst, def);
|
|
2627
|
+
$ZodULID.init(inst, def);
|
|
2628
|
+
ZodStringFormat.init(inst, def);
|
|
2629
|
+
});
|
|
2630
|
+
const ZodXID = /*@__PURE__*/ $constructor("ZodXID", (inst, def) => {
|
|
2631
|
+
// ZodStringFormat.init(inst, def);
|
|
2632
|
+
$ZodXID.init(inst, def);
|
|
2633
|
+
ZodStringFormat.init(inst, def);
|
|
2634
|
+
});
|
|
2635
|
+
const ZodKSUID = /*@__PURE__*/ $constructor("ZodKSUID", (inst, def) => {
|
|
2636
|
+
// ZodStringFormat.init(inst, def);
|
|
2637
|
+
$ZodKSUID.init(inst, def);
|
|
2638
|
+
ZodStringFormat.init(inst, def);
|
|
2639
|
+
});
|
|
2640
|
+
const ZodIPv4 = /*@__PURE__*/ $constructor("ZodIPv4", (inst, def) => {
|
|
2641
|
+
// ZodStringFormat.init(inst, def);
|
|
2642
|
+
$ZodIPv4.init(inst, def);
|
|
2643
|
+
ZodStringFormat.init(inst, def);
|
|
2644
|
+
});
|
|
2645
|
+
const ZodIPv6 = /*@__PURE__*/ $constructor("ZodIPv6", (inst, def) => {
|
|
2646
|
+
// ZodStringFormat.init(inst, def);
|
|
2647
|
+
$ZodIPv6.init(inst, def);
|
|
2648
|
+
ZodStringFormat.init(inst, def);
|
|
2649
|
+
});
|
|
2650
|
+
const ZodCIDRv4 = /*@__PURE__*/ $constructor("ZodCIDRv4", (inst, def) => {
|
|
2651
|
+
$ZodCIDRv4.init(inst, def);
|
|
2652
|
+
ZodStringFormat.init(inst, def);
|
|
2653
|
+
});
|
|
2654
|
+
const ZodCIDRv6 = /*@__PURE__*/ $constructor("ZodCIDRv6", (inst, def) => {
|
|
2655
|
+
$ZodCIDRv6.init(inst, def);
|
|
2656
|
+
ZodStringFormat.init(inst, def);
|
|
2657
|
+
});
|
|
2658
|
+
const ZodBase64 = /*@__PURE__*/ $constructor("ZodBase64", (inst, def) => {
|
|
2659
|
+
// ZodStringFormat.init(inst, def);
|
|
2660
|
+
$ZodBase64.init(inst, def);
|
|
2661
|
+
ZodStringFormat.init(inst, def);
|
|
2662
|
+
});
|
|
2663
|
+
const ZodBase64URL = /*@__PURE__*/ $constructor("ZodBase64URL", (inst, def) => {
|
|
2664
|
+
// ZodStringFormat.init(inst, def);
|
|
2665
|
+
$ZodBase64URL.init(inst, def);
|
|
2666
|
+
ZodStringFormat.init(inst, def);
|
|
2667
|
+
});
|
|
2668
|
+
const ZodE164 = /*@__PURE__*/ $constructor("ZodE164", (inst, def) => {
|
|
2669
|
+
// ZodStringFormat.init(inst, def);
|
|
2670
|
+
$ZodE164.init(inst, def);
|
|
2671
|
+
ZodStringFormat.init(inst, def);
|
|
2672
|
+
});
|
|
2673
|
+
const ZodJWT = /*@__PURE__*/ $constructor("ZodJWT", (inst, def) => {
|
|
2674
|
+
// ZodStringFormat.init(inst, def);
|
|
2675
|
+
$ZodJWT.init(inst, def);
|
|
2676
|
+
ZodStringFormat.init(inst, def);
|
|
2677
|
+
});
|
|
2678
|
+
const ZodUnknown = /*@__PURE__*/ $constructor("ZodUnknown", (inst, def) => {
|
|
2679
|
+
$ZodUnknown.init(inst, def);
|
|
2680
|
+
ZodType.init(inst, def);
|
|
2681
|
+
});
|
|
2682
|
+
function unknown() {
|
|
2683
|
+
return _unknown(ZodUnknown);
|
|
2684
|
+
}
|
|
2685
|
+
const ZodNever = /*@__PURE__*/ $constructor("ZodNever", (inst, def) => {
|
|
2686
|
+
$ZodNever.init(inst, def);
|
|
2687
|
+
ZodType.init(inst, def);
|
|
2688
|
+
});
|
|
2689
|
+
function never(params) {
|
|
2690
|
+
return _never(ZodNever, params);
|
|
2691
|
+
}
|
|
2692
|
+
const ZodArray = /*@__PURE__*/ $constructor("ZodArray", (inst, def) => {
|
|
2693
|
+
$ZodArray.init(inst, def);
|
|
2694
|
+
ZodType.init(inst, def);
|
|
2695
|
+
inst.element = def.element;
|
|
2696
|
+
inst.min = (minLength, params) => inst.check(_minLength(minLength, params));
|
|
2697
|
+
inst.nonempty = (params) => inst.check(_minLength(1, params));
|
|
2698
|
+
inst.max = (maxLength, params) => inst.check(_maxLength(maxLength, params));
|
|
2699
|
+
inst.length = (len, params) => inst.check(_length(len, params));
|
|
2700
|
+
inst.unwrap = () => inst.element;
|
|
2701
|
+
});
|
|
2702
|
+
function array(element, params) {
|
|
2703
|
+
return _array(ZodArray, element, params);
|
|
2704
|
+
}
|
|
2705
|
+
const ZodObject = /*@__PURE__*/ $constructor("ZodObject", (inst, def) => {
|
|
2706
|
+
$ZodObject.init(inst, def);
|
|
2707
|
+
ZodType.init(inst, def);
|
|
2708
|
+
defineLazy(inst, "shape", () => def.shape);
|
|
2709
|
+
inst.keyof = () => _enum(Object.keys(inst._zod.def.shape));
|
|
2710
|
+
inst.catchall = (catchall) => inst.clone({ ...inst._zod.def, catchall: catchall });
|
|
2711
|
+
inst.passthrough = () => inst.clone({ ...inst._zod.def, catchall: unknown() });
|
|
2712
|
+
inst.loose = () => inst.clone({ ...inst._zod.def, catchall: unknown() });
|
|
2713
|
+
inst.strict = () => inst.clone({ ...inst._zod.def, catchall: never() });
|
|
2714
|
+
inst.strip = () => inst.clone({ ...inst._zod.def, catchall: undefined });
|
|
2715
|
+
inst.extend = (incoming) => {
|
|
2716
|
+
return extend(inst, incoming);
|
|
2717
|
+
};
|
|
2718
|
+
inst.merge = (other) => merge(inst, other);
|
|
2719
|
+
inst.pick = (mask) => pick(inst, mask);
|
|
2720
|
+
inst.omit = (mask) => omit(inst, mask);
|
|
2721
|
+
inst.partial = (...args) => partial(ZodOptional, inst, args[0]);
|
|
2722
|
+
inst.required = (...args) => required(ZodNonOptional, inst, args[0]);
|
|
2723
|
+
});
|
|
2724
|
+
function object(shape, params) {
|
|
2725
|
+
const def = {
|
|
2726
|
+
type: "object",
|
|
2727
|
+
get shape() {
|
|
2728
|
+
assignProp(this, "shape", shape ? objectClone(shape) : {});
|
|
2729
|
+
return this.shape;
|
|
2730
|
+
},
|
|
2731
|
+
...normalizeParams(params),
|
|
2732
|
+
};
|
|
2733
|
+
return new ZodObject(def);
|
|
2734
|
+
}
|
|
2735
|
+
const ZodUnion = /*@__PURE__*/ $constructor("ZodUnion", (inst, def) => {
|
|
2736
|
+
$ZodUnion.init(inst, def);
|
|
2737
|
+
ZodType.init(inst, def);
|
|
2738
|
+
inst.options = def.options;
|
|
2739
|
+
});
|
|
2740
|
+
function union(options, params) {
|
|
2741
|
+
return new ZodUnion({
|
|
2742
|
+
type: "union",
|
|
2743
|
+
options: options,
|
|
2744
|
+
...normalizeParams(params),
|
|
2745
|
+
});
|
|
2746
|
+
}
|
|
2747
|
+
const ZodIntersection = /*@__PURE__*/ $constructor("ZodIntersection", (inst, def) => {
|
|
2748
|
+
$ZodIntersection.init(inst, def);
|
|
2749
|
+
ZodType.init(inst, def);
|
|
2750
|
+
});
|
|
2751
|
+
function intersection(left, right) {
|
|
2752
|
+
return new ZodIntersection({
|
|
2753
|
+
type: "intersection",
|
|
2754
|
+
left: left,
|
|
2755
|
+
right: right,
|
|
2756
|
+
});
|
|
2757
|
+
}
|
|
2758
|
+
const ZodEnum = /*@__PURE__*/ $constructor("ZodEnum", (inst, def) => {
|
|
2759
|
+
$ZodEnum.init(inst, def);
|
|
2760
|
+
ZodType.init(inst, def);
|
|
2761
|
+
inst.enum = def.entries;
|
|
2762
|
+
inst.options = Object.values(def.entries);
|
|
2763
|
+
const keys = new Set(Object.keys(def.entries));
|
|
2764
|
+
inst.extract = (values, params) => {
|
|
2765
|
+
const newEntries = {};
|
|
2766
|
+
for (const value of values) {
|
|
2767
|
+
if (keys.has(value)) {
|
|
2768
|
+
newEntries[value] = def.entries[value];
|
|
2769
|
+
}
|
|
2770
|
+
else
|
|
2771
|
+
throw new Error(`Key ${value} not found in enum`);
|
|
2772
|
+
}
|
|
2773
|
+
return new ZodEnum({
|
|
2774
|
+
...def,
|
|
2775
|
+
checks: [],
|
|
2776
|
+
...normalizeParams(params),
|
|
2777
|
+
entries: newEntries,
|
|
2778
|
+
});
|
|
2779
|
+
};
|
|
2780
|
+
inst.exclude = (values, params) => {
|
|
2781
|
+
const newEntries = { ...def.entries };
|
|
2782
|
+
for (const value of values) {
|
|
2783
|
+
if (keys.has(value)) {
|
|
2784
|
+
delete newEntries[value];
|
|
2785
|
+
}
|
|
2786
|
+
else
|
|
2787
|
+
throw new Error(`Key ${value} not found in enum`);
|
|
2788
|
+
}
|
|
2789
|
+
return new ZodEnum({
|
|
2790
|
+
...def,
|
|
2791
|
+
checks: [],
|
|
2792
|
+
...normalizeParams(params),
|
|
2793
|
+
entries: newEntries,
|
|
2794
|
+
});
|
|
2795
|
+
};
|
|
2796
|
+
});
|
|
2797
|
+
function _enum(values, params) {
|
|
2798
|
+
const entries = Array.isArray(values) ? Object.fromEntries(values.map((v) => [v, v])) : values;
|
|
2799
|
+
return new ZodEnum({
|
|
2800
|
+
type: "enum",
|
|
2801
|
+
entries,
|
|
2802
|
+
...normalizeParams(params),
|
|
2803
|
+
});
|
|
2804
|
+
}
|
|
2805
|
+
const ZodTransform = /*@__PURE__*/ $constructor("ZodTransform", (inst, def) => {
|
|
2806
|
+
$ZodTransform.init(inst, def);
|
|
2807
|
+
ZodType.init(inst, def);
|
|
2808
|
+
inst._zod.parse = (payload, _ctx) => {
|
|
2809
|
+
payload.addIssue = (issue$1) => {
|
|
2810
|
+
if (typeof issue$1 === "string") {
|
|
2811
|
+
payload.issues.push(issue(issue$1, payload.value, def));
|
|
2812
|
+
}
|
|
2813
|
+
else {
|
|
2814
|
+
// for Zod 3 backwards compatibility
|
|
2815
|
+
const _issue = issue$1;
|
|
2816
|
+
if (_issue.fatal)
|
|
2817
|
+
_issue.continue = false;
|
|
2818
|
+
_issue.code ?? (_issue.code = "custom");
|
|
2819
|
+
_issue.input ?? (_issue.input = payload.value);
|
|
2820
|
+
_issue.inst ?? (_issue.inst = inst);
|
|
2821
|
+
// _issue.continue ??= true;
|
|
2822
|
+
payload.issues.push(issue(_issue));
|
|
2823
|
+
}
|
|
2824
|
+
};
|
|
2825
|
+
const output = def.transform(payload.value, payload);
|
|
2826
|
+
if (output instanceof Promise) {
|
|
2827
|
+
return output.then((output) => {
|
|
2828
|
+
payload.value = output;
|
|
2829
|
+
return payload;
|
|
2830
|
+
});
|
|
2831
|
+
}
|
|
2832
|
+
payload.value = output;
|
|
2833
|
+
return payload;
|
|
2834
|
+
};
|
|
2835
|
+
});
|
|
2836
|
+
function transform(fn) {
|
|
2837
|
+
return new ZodTransform({
|
|
2838
|
+
type: "transform",
|
|
2839
|
+
transform: fn,
|
|
2840
|
+
});
|
|
2841
|
+
}
|
|
2842
|
+
const ZodOptional = /*@__PURE__*/ $constructor("ZodOptional", (inst, def) => {
|
|
2843
|
+
$ZodOptional.init(inst, def);
|
|
2844
|
+
ZodType.init(inst, def);
|
|
2845
|
+
inst.unwrap = () => inst._zod.def.innerType;
|
|
2846
|
+
});
|
|
2847
|
+
function optional(innerType) {
|
|
2848
|
+
return new ZodOptional({
|
|
2849
|
+
type: "optional",
|
|
2850
|
+
innerType: innerType,
|
|
2851
|
+
});
|
|
2852
|
+
}
|
|
2853
|
+
const ZodNullable = /*@__PURE__*/ $constructor("ZodNullable", (inst, def) => {
|
|
2854
|
+
$ZodNullable.init(inst, def);
|
|
2855
|
+
ZodType.init(inst, def);
|
|
2856
|
+
inst.unwrap = () => inst._zod.def.innerType;
|
|
2857
|
+
});
|
|
2858
|
+
function nullable(innerType) {
|
|
2859
|
+
return new ZodNullable({
|
|
2860
|
+
type: "nullable",
|
|
2861
|
+
innerType: innerType,
|
|
2862
|
+
});
|
|
2863
|
+
}
|
|
2864
|
+
const ZodDefault = /*@__PURE__*/ $constructor("ZodDefault", (inst, def) => {
|
|
2865
|
+
$ZodDefault.init(inst, def);
|
|
2866
|
+
ZodType.init(inst, def);
|
|
2867
|
+
inst.unwrap = () => inst._zod.def.innerType;
|
|
2868
|
+
inst.removeDefault = inst.unwrap;
|
|
2869
|
+
});
|
|
2870
|
+
function _default(innerType, defaultValue) {
|
|
2871
|
+
return new ZodDefault({
|
|
2872
|
+
type: "default",
|
|
2873
|
+
innerType: innerType,
|
|
2874
|
+
get defaultValue() {
|
|
2875
|
+
return typeof defaultValue === "function" ? defaultValue() : defaultValue;
|
|
2876
|
+
},
|
|
2877
|
+
});
|
|
2878
|
+
}
|
|
2879
|
+
const ZodPrefault = /*@__PURE__*/ $constructor("ZodPrefault", (inst, def) => {
|
|
2880
|
+
$ZodPrefault.init(inst, def);
|
|
2881
|
+
ZodType.init(inst, def);
|
|
2882
|
+
inst.unwrap = () => inst._zod.def.innerType;
|
|
2883
|
+
});
|
|
2884
|
+
function prefault(innerType, defaultValue) {
|
|
2885
|
+
return new ZodPrefault({
|
|
2886
|
+
type: "prefault",
|
|
2887
|
+
innerType: innerType,
|
|
2888
|
+
get defaultValue() {
|
|
2889
|
+
return typeof defaultValue === "function" ? defaultValue() : defaultValue;
|
|
2890
|
+
},
|
|
2891
|
+
});
|
|
2892
|
+
}
|
|
2893
|
+
const ZodNonOptional = /*@__PURE__*/ $constructor("ZodNonOptional", (inst, def) => {
|
|
2894
|
+
$ZodNonOptional.init(inst, def);
|
|
2895
|
+
ZodType.init(inst, def);
|
|
2896
|
+
inst.unwrap = () => inst._zod.def.innerType;
|
|
2897
|
+
});
|
|
2898
|
+
function nonoptional(innerType, params) {
|
|
2899
|
+
return new ZodNonOptional({
|
|
2900
|
+
type: "nonoptional",
|
|
2901
|
+
innerType: innerType,
|
|
2902
|
+
...normalizeParams(params),
|
|
2903
|
+
});
|
|
2904
|
+
}
|
|
2905
|
+
const ZodCatch = /*@__PURE__*/ $constructor("ZodCatch", (inst, def) => {
|
|
2906
|
+
$ZodCatch.init(inst, def);
|
|
2907
|
+
ZodType.init(inst, def);
|
|
2908
|
+
inst.unwrap = () => inst._zod.def.innerType;
|
|
2909
|
+
inst.removeCatch = inst.unwrap;
|
|
2910
|
+
});
|
|
2911
|
+
function _catch(innerType, catchValue) {
|
|
2912
|
+
return new ZodCatch({
|
|
2913
|
+
type: "catch",
|
|
2914
|
+
innerType: innerType,
|
|
2915
|
+
catchValue: (typeof catchValue === "function" ? catchValue : () => catchValue),
|
|
2916
|
+
});
|
|
2917
|
+
}
|
|
2918
|
+
const ZodPipe = /*@__PURE__*/ $constructor("ZodPipe", (inst, def) => {
|
|
2919
|
+
$ZodPipe.init(inst, def);
|
|
2920
|
+
ZodType.init(inst, def);
|
|
2921
|
+
inst.in = def.in;
|
|
2922
|
+
inst.out = def.out;
|
|
2923
|
+
});
|
|
2924
|
+
function pipe(in_, out) {
|
|
2925
|
+
return new ZodPipe({
|
|
2926
|
+
type: "pipe",
|
|
2927
|
+
in: in_,
|
|
2928
|
+
out: out,
|
|
2929
|
+
// ...util.normalizeParams(params),
|
|
2930
|
+
});
|
|
2931
|
+
}
|
|
2932
|
+
const ZodReadonly = /*@__PURE__*/ $constructor("ZodReadonly", (inst, def) => {
|
|
2933
|
+
$ZodReadonly.init(inst, def);
|
|
2934
|
+
ZodType.init(inst, def);
|
|
2935
|
+
inst.unwrap = () => inst._zod.def.innerType;
|
|
2936
|
+
});
|
|
2937
|
+
function readonly(innerType) {
|
|
2938
|
+
return new ZodReadonly({
|
|
2939
|
+
type: "readonly",
|
|
2940
|
+
innerType: innerType,
|
|
2941
|
+
});
|
|
2942
|
+
}
|
|
2943
|
+
const ZodCustom = /*@__PURE__*/ $constructor("ZodCustom", (inst, def) => {
|
|
2944
|
+
$ZodCustom.init(inst, def);
|
|
2945
|
+
ZodType.init(inst, def);
|
|
2946
|
+
});
|
|
2947
|
+
function refine(fn, _params = {}) {
|
|
2948
|
+
return _refine(ZodCustom, fn, _params);
|
|
2949
|
+
}
|
|
2950
|
+
// superRefine
|
|
2951
|
+
function superRefine(fn) {
|
|
2952
|
+
return _superRefine(fn);
|
|
2953
|
+
}
|
|
2954
|
+
|
|
2955
|
+
const dialogEditorCss = "@layer base{*,::backdrop,:after,:before{--tw-space-y-reverse:0;--tw-translate-x:0;--tw-translate-y:0;--tw-translate-z:0;--tw-space-x-reverse:0;--tw-border-style:solid;--tw-drop-shadow-alpha:100%;--tw-shadow:0 0 #0000;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-alpha:100%;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-offset-width:0;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000;border:0 solid;box-sizing:border-box;margin:0;padding:0}}/*! tailwindcss v4.1.11 | MIT License | https://tailwindcss.com */@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,::backdrop,:after,:before{--tw-font-weight:initial;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000;--tw-space-y-reverse:0;--tw-translate-x:0;--tw-translate-y:0;--tw-translate-z:0;--tw-space-x-reverse:0;--tw-border-style:solid;--tw-blur:initial;--tw-brightness:initial;--tw-contrast:initial;--tw-grayscale:initial;--tw-hue-rotate:initial;--tw-invert:initial;--tw-opacity:initial;--tw-saturate:initial;--tw-sepia:initial;--tw-drop-shadow:initial;--tw-drop-shadow-color:initial;--tw-drop-shadow-alpha:100%;--tw-drop-shadow-size:initial}}}@layer theme{:host,:root{--container-lg:32rem;--color-yellow-300:oklch(90.5% .182 98.111);--radius-md:.375rem;--color-red-500:oklch(63.7% .237 25.331);--color-green-500:oklch(72.3% .219 149.579);--color-blue-500:oklch(62.3% .214 259.815);--color-pink-100:oklch(94.8% .028 342.258);--color-gray-600:oklch(44.6% .03 256.802);--text-xs:.75rem;--text-xs--line-height:1.33333;--text-sm:.875rem;--text-sm--line-height:1.42857;--text-base:1rem;--text-base--line-height:1.5;--font-weight-semibold:600;--radius-xl:.75rem;--default-transition-duration:.15s;--default-transition-timing-function:cubic-bezier(.4,0,.2,1);--font-weight-medium:500;--font-mono:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,\"Liberation Mono\",\"Courier New\",monospace;--color-gray-100:oklch(96.7% .003 264.542);--color-gray-200:oklch(92.8% .006 264.531);--color-gray-300:oklch(87.2% .01 258.338);--color-gray-400:oklch(70.7% .022 261.325);--color-gray-500:oklch(55.1% .027 264.364);--color-gray-700:oklch(37.3% .034 259.733);--color-black:#000;--color-white:#fff;--spacing:.25rem;--container-xl:36rem;--text-lg:1.125rem;--text-lg--line-height:1.55556;--font-weight-bold:700;--radius-lg:.5rem;--default-font-family:\"Kanit\",var(--default-font);--default-mono-font-family:var(--font-mono);--default-font:ui-sans-serif,system-ui,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\",\"Segoe UI Symbol\",\"Noto Color Emoji\";--color-primary:#e02848;--color-secondary:#023761;--color-background:#fff;--color-primary-dark:#b50f30;--color-secondary-dark:#fff;--color-background-dark:#23292d}}@layer base{::file-selector-button{appearance:button;background-color:#0000;border:0 solid;border-radius:0;box-sizing:border-box;color:inherit;font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;margin:0;margin-inline-end:4px;opacity:1;padding:0}:host,html{-webkit-text-size-adjust:100%;font-family:var(--default-font-family,ui-sans-serif,system-ui,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\",\"Segoe UI Symbol\",\"Noto Color Emoji\");font-feature-settings:var(--default-font-feature-settings,normal);font-variation-settings:var(--default-font-variation-settings,normal);tab-size:4;-webkit-tap-highlight-color:transparent;line-height:1.5}hr{border-top-width:1px;color:inherit;height:0}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,pre,samp{font-family:var(--default-mono-font-family,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,\"Liberation Mono\",\"Courier New\",monospace);font-feature-settings:var(--default-mono-font-feature-settings,normal);font-size:1em;font-variation-settings:var(--default-mono-font-variation-settings,normal)}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{border-collapse:collapse;border-color:inherit;text-indent:0}:-moz-focusring{outline:auto}progress{vertical-align:baseline}summary{display:list-item}menu,ol,ul{list-style:none}audio,canvas,embed,iframe,img,object,svg,video{display:block;vertical-align:middle}img,video{height:auto;max-width:100%}button,input,optgroup,select,textarea{background-color:#0000;border-radius:0;color:inherit;font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;opacity:1}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::placeholder{opacity:1}@supports (not ((-webkit-appearance:-apple-pay-button))) or (contain-intrinsic-size:1px){::placeholder{color:currentColor}@supports (color:color-mix(in lab,red,red)){::placeholder{color:currentColor;color:color-mix(in oklab,currentcolor 50%,transparent)}}}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;min-height:1.5em;text-align:inherit}::-webkit-datetime-edit{display:inline-flex}::-webkit-datetime-edit,::-webkit-datetime-edit-year-field{padding-block:0;padding-bottom:0;padding-top:0}::-webkit-datetime-edit-day-field,::-webkit-datetime-edit-month-field{padding-block:0;padding-bottom:0;padding-top:0}::-webkit-datetime-edit-hour-field,::-webkit-datetime-edit-minute-field{padding-block:0;padding-bottom:0;padding-top:0}::-webkit-datetime-edit-millisecond-field,::-webkit-datetime-edit-second-field{padding-block:0;padding-bottom:0;padding-top:0}::-webkit-datetime-edit-meridiem-field{padding-block:0;padding-bottom:0;padding-top:0}:-moz-ui-invalid{box-shadow:none}button,input:where([type=button],[type=reset],[type=submit]){appearance:button}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[hidden]:where(:not([hidden=until-found])){display:none!important}[multiple],[type=date],[type=datetime-local],[type=email],[type=month],[type=number],[type=password],[type=search],[type=tel],[type=text],[type=time],[type=url],[type=week],input:where(:not([type])),select,textarea{appearance:none;--tw-shadow:0 0 #0000;background-color:#fff;border-color:oklch(55.1% .027 264.364);border-radius:0;border-width:1px;font-size:1rem;line-height:1.5rem;padding:.5rem .75rem}:is([type=text],input:where(:not([type])),[type=email],[type=url],[type=password],[type=number],[type=date],[type=datetime-local],[type=month],[type=search],[type=tel],[type=time],[type=week],[multiple],textarea,select):focus{outline-offset:2px;--tw-ring-inset:var(--tw-empty, );--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:oklch(54.6% .245 262.881);--tw-ring-offset-shadow:var(--tw-ring-inset)0 0 0 var(--tw-ring-offset-width)var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset)0 0 0 calc(1px + var(--tw-ring-offset-width))var(--tw-ring-color);border-color:oklch(54.6% .245 262.881);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow);outline:2px solid #0000}input::placeholder,textarea::placeholder{color:oklch(55.1% .027 264.364);opacity:1}::-webkit-datetime-edit-fields-wrapper{padding:0}select{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3E%3Cpath stroke='oklch(55.1%25 0.027 264.364)' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3E%3C/svg%3E\");background-position:right .5rem center;background-repeat:no-repeat;background-size:1.5em 1.5em;padding-right:2.5rem;print-color-adjust:exact}[multiple],[size]:where(select:not([size=\"1\"])){background-image:none;background-position:0 0;background-repeat:unset;background-size:initial;padding-right:.75rem;print-color-adjust:unset}[type=checkbox],[type=radio]{appearance:none;color:oklch(54.6% .245 262.881);print-color-adjust:exact;-webkit-user-select:none;user-select:none;vertical-align:middle;--tw-shadow:0 0 #0000;background-color:#fff;background-origin:border-box;border-color:oklch(55.1% .027 264.364);border-width:1px;display:inline-block;flex-shrink:0;height:1rem;padding:0;width:1rem}[type=checkbox]{border-radius:0}[type=radio]{border-radius:100%}[type=checkbox]:focus,[type=radio]:focus{outline-offset:2px;--tw-ring-inset:var(--tw-empty, );--tw-ring-offset-width:2px;--tw-ring-offset-color:#fff;--tw-ring-color:oklch(54.6% .245 262.881);--tw-ring-offset-shadow:var(--tw-ring-inset)0 0 0 var(--tw-ring-offset-width)var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset)0 0 0 calc(2px + var(--tw-ring-offset-width))var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow);outline:2px solid #0000}[type=checkbox]:checked,[type=radio]:checked{background-color:currentColor;background-position:50%;background-repeat:no-repeat;background-size:100% 100%;border-color:#0000}[type=checkbox]:checked{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%23fff' viewBox='0 0 16 16'%3E%3Cpath d='M12.207 4.793a1 1 0 0 1 0 1.414l-5 5a1 1 0 0 1-1.414 0l-2-2a1 1 0 0 1 1.414-1.414L6.5 9.086l4.293-4.293a1 1 0 0 1 1.414 0'/%3E%3C/svg%3E\")}[type=radio]:checked{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%23fff' viewBox='0 0 16 16'%3E%3Ccircle cx='8' cy='8' r='3'/%3E%3C/svg%3E\")}[type=checkbox]:checked:focus,[type=checkbox]:checked:hover,[type=radio]:checked:focus,[type=radio]:checked:hover{background-color:currentColor;border-color:#0000}[type=checkbox]:indeterminate{background-color:currentColor;background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 16 16'%3E%3Cpath stroke='%23fff' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M4 8h8'/%3E%3C/svg%3E\");background-position:50%;background-repeat:no-repeat;background-size:100% 100%;border-color:#0000}[type=checkbox]:indeterminate:focus,[type=checkbox]:indeterminate:hover{background-color:currentColor;border-color:#0000}[type=file]{background:unset;border-color:inherit;border-radius:0;border-width:0;font-size:unset;line-height:inherit;padding:0}[type=file]:focus{outline:1px solid buttontext;outline:1px auto -webkit-focus-ring-color}}@layer components;@layer utilities{.absolute{position:absolute}.relative{position:relative}.top-1{top:calc(var(--spacing)*1)}.right-1{right:calc(var(--spacing)*1)}.z-\\[99\\]{z-index:99}.flex{display:flex}.w-full{width:100%}.min-w-\\[280px\\]{min-width:280px}.flex-1{flex:1}.flex-col{flex-direction:column}.flex-row{flex-direction:row}.overflow-x-hidden{overflow-x:hidden}.overflow-y-auto{overflow-y:auto}.scroll-smooth{scroll-behavior:smooth}.text-\\[10px\\]{font-size:10px}.text-\\[gray\\]{color:gray}.opacity-10{opacity:.1}.shadow-md{--tw-shadow:0 4px 6px -1px var(--tw-shadow-color,#0000001a),0 2px 4px -2px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}}.scroll-container::-webkit-scrollbar{background:0 0;height:8px;width:8px}.scroll-container:active::-webkit-scrollbar,.scroll-container:hover::-webkit-scrollbar{background:#0000001a}.scroll-container:active::-webkit-scrollbar-thumb,.scroll-container:hover::-webkit-scrollbar-thumb{background:#0006;border-radius:4px}.z-text-light{color:var(--color-black)}.z-text-dark{color:var(--color-white)}.z-text-primary-light{color:var(--color-primary)}.z-text-primary-dark{color:var(--color-primary-dark)}.z-text-gray-light{color:var(--color-gray-500)}.z-text-gray-dark{color:var(--color-gray-300)}.z-border-light{border-color:var(--color-black)}.z-border-dark{border-color:var(--color-white)}.z-border-primary-light{border-color:var(--color-primary)}.z-border-primary-dark{border-color:var(--color-primary-dark)}.z-border-divider-light{border-color:var(--color-gray-400)}.z-border-divider-dark{border-color:var(--color-gray-300)}.z-search-input-background-light{background-color:var(--color-gray-200)}.z-search-input-background-dark{background-color:var(--color-gray-500)}.z-chat-input-background-light{background-color:var(--color-white)}.z-chat-input-background-dark{background-color:var(--color-gray-700)}.z-placeholder-light::placeholder{color:var(--color-gray-500)}.z-placeholder-dark::placeholder{color:var(--color-gray-200)}.z-background-light{background-color:var(--color-background)}.z-background-dark{background-color:var(--color-background-dark)}.z-paper-light{background-color:var(--color-gray-100)}.z-paper-dark{background-color:var(--color-gray-700)}.z-width-100{width:100%}.z-width-75{width:75%}.z-width-50{width:50%}.z-width-25{width:25%}.z-width-0{width:0}/*! tailwindcss v4.1.11 | MIT License | https://tailwindcss.com */@layer properties{}@layer base{}@layer components;@layer utilities{.my-auto{margin-block:auto}.size-8{height:calc(var(--spacing)*8);width:calc(var(--spacing)*8)}.h-4{height:calc(var(--spacing)*4)}.h-\\[60px\\]{height:60px}.w-4{width:calc(var(--spacing)*4)}.items-center{align-items:center}.justify-between{justify-content:space-between}.gap-1{gap:calc(var(--spacing)*1)}:where(.space-x-1>:not(:last-child)){--tw-space-x-reverse:0;margin-inline-end:calc(var(--spacing)*1*(1 - var(--tw-space-x-reverse)));margin-inline-start:calc(var(--spacing)*1*var(--tw-space-x-reverse))}.rounded-full{border-radius:3.40282e+38px}.object-cover{object-fit:cover}.px-2{padding-inline:calc(var(--spacing)*2)}.py-3{padding-block:calc(var(--spacing)*3)}.text-base{font-size:var(--text-base);line-height:var(--tw-leading,var(--text-base--line-height))}.text-sm{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height))}.font-semibold{--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.text-blue-500{color:var(--color-blue-500)}.text-green-500{color:var(--color-green-500)}.shadow-lg{--tw-shadow:0 10px 15px -3px var(--tw-shadow-color,#0000001a),0 4px 6px -4px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.mb-2{margin-bottom:calc(var(--spacing)*2)}.mb-auto{margin-bottom:auto}.ml-2{margin-left:calc(var(--spacing)*2)}.border-none{--tw-border-style:none;border-style:none}.bg-pink-100{background-color:var(--color-pink-100)}.px-4{padding-inline:calc(var(--spacing)*4)}.py-2{padding-block:calc(var(--spacing)*2)}.text-xs{font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height))}.text-black{color:var(--color-black)}.text-gray-500{color:var(--color-gray-500)}.shadow-inner{--tw-shadow:inset 0 2px 4px 0 var(--tw-shadow-color,#0000000d);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.ring-primary{--tw-ring-color:var(--color-primary)}.focus\\:outline-none:focus{--tw-outline-style:none;outline-style:none}.mt-6{margin-top:calc(var(--spacing)*6)}.mb-6{margin-bottom:calc(var(--spacing)*6)}.max-h-\\[80vh\\]{max-height:80vh}.w-xl{width:var(--container-xl)}.gap-2{gap:calc(var(--spacing)*2)}}/*! tailwindcss v4.1.11 | MIT License | https://tailwindcss.com */@layer properties{}@layer base{}@layer components;@layer utilities{}/*! tailwindcss v4.1.11 | MIT License | https://tailwindcss.com */@layer properties{}@layer base{}@layer components;@layer utilities{:where(.space-y-2>:not(:last-child)){--tw-space-y-reverse:0;margin-block-end:calc(var(--spacing)*2*(1 - var(--tw-space-y-reverse)));margin-block-start:calc(var(--spacing)*2*var(--tw-space-y-reverse))}.overflow-auto{overflow:auto}.rounded-lg{border-radius:var(--radius-lg)}.p-6{padding:calc(var(--spacing)*6)}.text-lg{font-size:var(--text-lg);line-height:var(--tw-leading,var(--text-lg--line-height))}.font-bold{--tw-font-weight:var(--font-weight-bold);font-weight:var(--font-weight-bold)}.top-0\\.5{top:calc(var(--spacing)*.5)}.right-0\\.5{right:calc(var(--spacing)*.5)}.m-auto{margin:auto}.w-lg{width:var(--container-lg)}.justify-center{justify-content:center}.object-contain{object-fit:contain}.pt-8{padding-top:calc(var(--spacing)*8)}.mx-auto{margin-inline:auto}.mb-10{margin-bottom:calc(var(--spacing)*10)}.grid{display:grid}.h-18{height:calc(var(--spacing)*18)}.w-18{width:calc(var(--spacing)*18)}.place-content-center{place-content:center}.p-4{padding:calc(var(--spacing)*4)}.text-center{text-align:center}.text-gray-400{color:var(--color-gray-400)}.text-primary{color:var(--color-primary)}.right-0{right:calc(var(--spacing)*0)}.bottom-\\[40px\\]{bottom:40px}.left-0{left:calc(var(--spacing)*0)}.z-50{z-index:50}.mt-2{margin-top:calc(var(--spacing)*2)}.w-32{width:calc(var(--spacing)*32)}.cursor-pointer{cursor:pointer}.rounded-md{border-radius:var(--radius-md)}.fixed{position:fixed}.inset-0{inset:calc(var(--spacing)*0)}.size-42{height:calc(var(--spacing)*42);width:calc(var(--spacing)*42)}.rounded-xl{border-radius:var(--radius-xl)}.rounded-br-\\[0\\]{border-bottom-right-radius:0}.rounded-bl-\\[0\\]{border-bottom-left-radius:0}.bg-black\\/40{background-color:#0006}}/*! tailwindcss v4.1.11 | MIT License | https://tailwindcss.com */@layer properties{}@layer base{}@layer components;@layer utilities{}/*! tailwindcss v4.1.11 | MIT License | https://tailwindcss.com */@layer properties{}@layer base{}@layer components;@layer utilities{}/*! tailwindcss v4.1.11 | MIT License | https://tailwindcss.com */@layer properties{}@layer base{}@layer components;@layer utilities{}/*! tailwindcss v4.1.11 | MIT License | https://tailwindcss.com */@layer properties{}@layer base{}@layer components;@layer utilities{@supports (color:color-mix(in lab,red,red)){.bg-black\\/40{background-color:color-mix(in srgb,#00040%,transparent);background-color:color-mix(in oklab,var(--color-black)40%,transparent)}}.bg-gray-200{background-color:var(--color-gray-200)}.bg-primary{background-color:var(--color-primary)}.p-2{padding:calc(var(--spacing)*2)}.px-3{padding-inline:calc(var(--spacing)*3)}.pt-2{padding-top:calc(var(--spacing)*2)}.pb-5{padding-bottom:calc(var(--spacing)*5)}.text-white{color:var(--color-white)}.shadow-sm{--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,#0000001a),0 1px 2px -1px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.right-full{right:100%}.-bottom-2{bottom:calc(var(--spacing)*-2)}.left-full{left:100%}.mt-0\\.5{margin-top:calc(var(--spacing)*.5)}.mt-1{margin-top:calc(var(--spacing)*1)}.mr-2{margin-right:calc(var(--spacing)*2)}.mb-\\[-0\\.75rem\\]{margin-bottom:-.75rem}.h-6{height:calc(var(--spacing)*6)}.w-6{width:calc(var(--spacing)*6)}.w-8{width:calc(var(--spacing)*8)}.justify-end{justify-content:flex-end}.justify-start{justify-content:flex-start}.bg-yellow-300{background-color:var(--color-yellow-300)}.text-left{text-align:left}.text-right{text-align:right}.col-span-1{grid-column:span 1/span 1}.col-span-2{grid-column:span 2/span 2}.col-span-3{grid-column:span 3/span 3}.mr-1{margin-right:calc(var(--spacing)*1)}.size-4{height:calc(var(--spacing)*4);width:calc(var(--spacing)*4)}.size-16{height:calc(var(--spacing)*16);width:calc(var(--spacing)*16)}.min-h-20{min-height:calc(var(--spacing)*20)}.grid-flow-row-dense{grid-auto-flow:dense}.grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.grid-rows-1{grid-template-rows:repeat(1,minmax(0,1fr))}.flex-wrap{flex-wrap:wrap}.items-baseline-last{align-items:last baseline}.gap-y-1{row-gap:calc(var(--spacing)*1)}.border-b-\\[0\\.5px\\]{border-bottom-style:var(--tw-border-style);border-bottom-width:.5px}.pt-0{padding-top:calc(var(--spacing)*0)}.whitespace-pre-line{white-space:pre-line}.capitalize{text-transform:capitalize}.top-1\\/2{top:50%}.right-1\\.25{right:calc(var(--spacing)*1.25)}.max-w-xl{max-width:var(--container-xl)}.-translate-y-1\\/2{--tw-translate-y:-50%;translate:var(--tw-translate-x)var(--tw-translate-y)}.p-1\\.5{padding:calc(var(--spacing)*1.5)}.shadow{--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,#0000001a),0 1px 2px -1px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.mt-auto{margin-top:auto}.hidden{display:none}}/*! tailwindcss v4.1.11 | MIT License | https://tailwindcss.com */@layer properties{}@layer base{}@layer components;/*! tailwindcss v4.1.11 | MIT License | https://tailwindcss.com */@layer properties{}@layer base{}@layer components;@layer utilities{}/*! tailwindcss v4.1.11 | MIT License | https://tailwindcss.com */@layer properties{}@layer base{}@layer components;@layer utilities{} /*! tailwindcss v4.1.11 | MIT License | https://tailwindcss.com */@layer base{}@layer components,utilities; /*! tailwindcss v4.1.11 | MIT License | https://tailwindcss.com */@layer base{}@layer components,utilities;/*! tailwindcss v4.1.11 | MIT License | https://tailwindcss.com */@layer properties{}@layer base{}@layer components;@layer utilities{}/*! tailwindcss v4.1.11 | MIT License | https://tailwindcss.com */@layer properties{}@layer base{}@layer components;@layer utilities{:where(.space-x-8>:not(:last-child)){--tw-space-x-reverse:0;margin-inline-end:calc(var(--spacing)*8*(1 - var(--tw-space-x-reverse)));margin-inline-start:calc(var(--spacing)*8*var(--tw-space-x-reverse))}.border-b-2{border-bottom-style:var(--tw-border-style);border-bottom-width:2px}.border-transparent{border-color:#0000}.py-4{padding-block:calc(var(--spacing)*4)}.font-medium{--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium)}.filter{filter:var(--tw-blur,)var(--tw-brightness,)var(--tw-contrast,)var(--tw-grayscale,)var(--tw-hue-rotate,)var(--tw-invert,)var(--tw-saturate,)var(--tw-sepia,)var(--tw-drop-shadow,)}.w-52{width:calc(var(--spacing)*52)}.top-0{top:calc(var(--spacing)*0)}.col-span-4{grid-column:span 4/span 4}.mx-2{margin-inline:calc(var(--spacing)*2)}.my-1{margin-block:calc(var(--spacing)*1)}.mr-0{margin-right:calc(var(--spacing)*0)}.mb-1{margin-bottom:calc(var(--spacing)*1)}.mb-4{margin-bottom:calc(var(--spacing)*4)}.ml-auto{margin-left:auto}.block{display:block}.inline-block{display:inline-block}.inline-flex{display:inline-flex}.size-3{height:calc(var(--spacing)*3);width:calc(var(--spacing)*3)}.size-5{height:calc(var(--spacing)*5);width:calc(var(--spacing)*5)}.h-0{height:calc(var(--spacing)*0)}.h-5{height:calc(var(--spacing)*5)}.w-0{width:calc(var(--spacing)*0)}.w-5{width:calc(var(--spacing)*5)}.cursor-not-allowed{cursor:not-allowed}.grid-cols-7{grid-template-columns:repeat(7,minmax(0,1fr))}.items-start{align-items:flex-start}}/*! tailwindcss v4.1.11 | MIT License | https://tailwindcss.com */@layer properties{}@layer base{}@layer components;@layer utilities{}/*! tailwindcss v4.1.11 | MIT License | https://tailwindcss.com */@layer properties{}@layer base{}@layer components;/*! tailwindcss v4.1.11 | MIT License | https://tailwindcss.com */@layer properties{}@layer base{}@layer components;@layer utilities{:where(.space-x-4>:not(:last-child)){--tw-space-x-reverse:0;margin-inline-end:calc(var(--spacing)*4*(1 - var(--tw-space-x-reverse)));margin-inline-start:calc(var(--spacing)*4*var(--tw-space-x-reverse))}.border{border-style:var(--tw-border-style);border-width:1px}.border-t-\\[14px\\]{border-top-style:var(--tw-border-style);border-top-width:14px}.border-l-\\[14px\\]{border-left-style:var(--tw-border-style);border-left-width:14px}.border-primary{border-color:var(--color-primary)}.border-t-red-500{border-top-color:var(--color-red-500)}.border-l-transparent{border-left-color:#0000}.py-0\\.5{padding-block:calc(var(--spacing)*.5)}.py-1{padding-block:calc(var(--spacing)*1)}.py-1\\.5{padding-block:calc(var(--spacing)*1.5)}.text-nowrap{text-wrap:nowrap}.text-gray-600{color:var(--color-gray-600)}.text-red-500{color:var(--color-red-500)}.opacity-50{opacity:.5}.transition{transition-duration:var(--tw-duration,var(--default-transition-duration));transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to,opacity,box-shadow,transform,translate,scale,rotate,filter,-webkit-backdrop-filter,backdrop-filter,display,visibility,content-visibility,overlay,pointer-events;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function))}.focus\\:border-primary:focus{border-color:var(--color-primary)}}/*! tailwindcss v4.1.11 | MIT License | https://tailwindcss.com */@layer properties{}@layer base{}@layer components;/*! tailwindcss v4.1.11 | MIT License | https://tailwindcss.com */@layer properties{}@layer base{}@layer components;/*! tailwindcss v4.1.11 | MIT License | https://tailwindcss.com */@layer properties{}@layer base{}@layer components;/*! tailwindcss v4.1.11 | MIT License | https://tailwindcss.com */@layer properties{}@layer base{}@layer components;/*! tailwindcss v4.1.11 | MIT License | https://tailwindcss.com */@layer properties{}@layer base{}@layer components;/*! tailwindcss v4.1.11 | MIT License | https://tailwindcss.com */@layer properties{}@layer base{}@layer components;/*! tailwindcss v4.1.11 | MIT License | https://tailwindcss.com */@layer properties{}@layer base{}@layer components;/*! tailwindcss v4.1.11 | MIT License | https://tailwindcss.com */@layer properties{}@layer base{}@layer components;@layer utilities{}@property --tw-space-y-reverse{syntax:\"*\";inherits:false;initial-value:0}@property --tw-translate-x{syntax:\"*\";inherits:false;initial-value:0}@property --tw-translate-y{syntax:\"*\";inherits:false;initial-value:0}@property --tw-translate-z{syntax:\"*\";inherits:false;initial-value:0}@property --tw-space-x-reverse{syntax:\"*\";inherits:false;initial-value:0}@property --tw-border-style{syntax:\"*\";inherits:false;initial-value:solid}@property --tw-blur{syntax:\"*\";inherits:false}@property --tw-brightness{syntax:\"*\";inherits:false}@property --tw-contrast{syntax:\"*\";inherits:false}@property --tw-grayscale{syntax:\"*\";inherits:false}@property --tw-hue-rotate{syntax:\"*\";inherits:false}@property --tw-invert{syntax:\"*\";inherits:false}@property --tw-opacity{syntax:\"*\";inherits:false}@property --tw-saturate{syntax:\"*\";inherits:false}@property --tw-sepia{syntax:\"*\";inherits:false}@property --tw-drop-shadow{syntax:\"*\";inherits:false}@property --tw-drop-shadow-color{syntax:\"*\";inherits:false}@property --tw-drop-shadow-alpha{syntax:\"<percentage>\";inherits:false;initial-value:100%}@property --tw-drop-shadow-size{syntax:\"*\";inherits:false}:host{display:block}@property --tw-font-weight{syntax:\"*\";inherits:false}@property --tw-shadow{syntax:\"*\";inherits:false;initial-value:0 0 #0000}@property --tw-shadow-color{syntax:\"*\";inherits:false}@property --tw-shadow-alpha{syntax:\"<percentage>\";inherits:false;initial-value:100%}@property --tw-inset-shadow{syntax:\"*\";inherits:false;initial-value:0 0 #0000}@property --tw-inset-shadow-color{syntax:\"*\";inherits:false}@property --tw-inset-shadow-alpha{syntax:\"<percentage>\";inherits:false;initial-value:100%}@property --tw-ring-color{syntax:\"*\";inherits:false}@property --tw-ring-shadow{syntax:\"*\";inherits:false;initial-value:0 0 #0000}@property --tw-inset-ring-color{syntax:\"*\";inherits:false}@property --tw-inset-ring-shadow{syntax:\"*\";inherits:false;initial-value:0 0 #0000}@property --tw-ring-inset{syntax:\"*\";inherits:false}@property --tw-ring-offset-width{syntax:\"<length>\";inherits:false;initial-value:0}@property --tw-ring-offset-color{syntax:\"*\";inherits:false;initial-value:#fff}@property --tw-ring-offset-shadow{syntax:\"*\";inherits:false;initial-value:0 0 #0000}@media (forced-colors:active){[type=checkbox]:checked,[type=radio]:checked{appearance:auto}[type=checkbox]:indeterminate{appearance:auto}[type=checkbox]:checked,[type=checkbox]:indeterminate,[type=radio]:checked{appearance:auto}}@media (hover:hover){.hover\\:opacity-100:hover{opacity:1}.hover\\:brightness-110:hover{--tw-brightness:brightness(110%);filter:var(--tw-blur,)var(--tw-brightness,)var(--tw-contrast,)var(--tw-grayscale,)var(--tw-hue-rotate,)var(--tw-invert,)var(--tw-saturate,)var(--tw-sepia,)var(--tw-drop-shadow,)}}@media screen and (min-width:0){.z-max-height{height:calc(100vh - 56px)}}@media screen and (min-width:600px){.z-max-height{height:calc(100vh - 64px)}}";
|
|
2956
|
+
|
|
2957
|
+
const DialogEditor = /*@__PURE__*/ proxyCustomElement(class DialogEditor extends H {
|
|
2958
|
+
constructor() {
|
|
2959
|
+
super();
|
|
2960
|
+
this.__registerHost();
|
|
2961
|
+
this.cancel = createEvent(this, "cancel");
|
|
2962
|
+
this.save = createEvent(this, "save");
|
|
2963
|
+
}
|
|
2964
|
+
dialogType = 'input';
|
|
2965
|
+
label;
|
|
2966
|
+
field;
|
|
2967
|
+
value;
|
|
2968
|
+
data = '';
|
|
2969
|
+
error = null;
|
|
2970
|
+
cancel;
|
|
2971
|
+
save;
|
|
2972
|
+
async componentWillLoad() {
|
|
2973
|
+
this.data = this.value || '';
|
|
2974
|
+
}
|
|
2975
|
+
handleCancel = () => {
|
|
2976
|
+
this.data = '';
|
|
2977
|
+
this.cancel.emit();
|
|
2978
|
+
};
|
|
2979
|
+
handleChange = (val) => {
|
|
2980
|
+
this.data = val;
|
|
2981
|
+
};
|
|
2982
|
+
handleSubmit = () => {
|
|
2983
|
+
const schema = object({ [this.field]: this.field.toLowerCase() === 'email' ? email() : string() });
|
|
2984
|
+
const validator = schema.safeParse({ [this.field]: this.data });
|
|
2985
|
+
if (!validator.success) {
|
|
2986
|
+
this.error = validator.error.issues[0].message;
|
|
2987
|
+
}
|
|
2988
|
+
else {
|
|
2989
|
+
this.error = null;
|
|
2990
|
+
this.save.emit(this.data);
|
|
2991
|
+
this.data = '';
|
|
2992
|
+
}
|
|
2993
|
+
};
|
|
2994
|
+
render() {
|
|
2995
|
+
const theme = configStore.get('theme');
|
|
2996
|
+
return (h(Host, { key: '1e4f43d5eb71fabaca9f7cf27deceb6c88575939' }, h("slot", { key: '933c19a3ed9c1d3630a9732266ca0e6347c3c8b5' }, h("div", { key: 'acf9d8b0be70b68d8651dd4c28eec6e6f49c6cbd', class: `p-6 z-background-${theme} rounded-lg shadow-lg w-xl xs:w-xs max-h-[80vh] overflow-auto` }, h("h2", { key: 'afea041f9050dcecb744a5ddffa6cd6b9ed19178', class: `text-lg font-bold mb-6 z-text-${theme}` }, "\u0E41\u0E01\u0E49\u0E44\u0E02 ", this.label), this.dialogType === 'input' &&
|
|
2997
|
+
h(ZInput, { key: '4a91b78ccd04690d371c05bd1226f3506e42b47b', autoFocus: true, id: this.field, label: this.label, placeholder: this.label, value: this.data, onChange: (val) => this.handleChange(val), type: this.field.toLowerCase() === 'email' ? 'email' : 'text', error: this.error }), this.dialogType === 'textarea' &&
|
|
2998
|
+
h(ZInputArea, { key: '0b5caa3f931ca90537ecf03420715a7bf839c2fe', autoFocus: true, id: this.field, label: this.label, placeholder: this.label, value: this.data, onChange: (val) => this.handleChange(val), error: this.error }), h("div", { key: 'c0739f9b05b1357d759601f97da995444acabb87', class: "flex justify-between items-center mt-6 gap-2" }, h(ZButton, { key: '52d9fe8219ea8fbbddcb069aa1fbf50e242cd4b2', label: "\u0E22\u0E01\u0E40\u0E25\u0E34\u0E01", variant: 'outlined', fullWidth: true, onClick: this.handleCancel }), h(ZButton, { key: 'eb4d711d84c9eb04866507793b3cdfa9f02cdf2c', label: "\u0E1A\u0E31\u0E19\u0E17\u0E36\u0E01", fullWidth: true, onClick: this.handleSubmit, disabled: this.data.length === 0 }))))));
|
|
2999
|
+
}
|
|
3000
|
+
static get style() { return dialogEditorCss; }
|
|
3001
|
+
}, [260, "dialog-editor", {
|
|
3002
|
+
"dialogType": [1, "dialog-type"],
|
|
3003
|
+
"label": [1],
|
|
3004
|
+
"field": [1],
|
|
3005
|
+
"value": [1],
|
|
3006
|
+
"data": [32],
|
|
3007
|
+
"error": [32]
|
|
3008
|
+
}]);
|
|
3009
|
+
function defineCustomElement() {
|
|
3010
|
+
if (typeof customElements === "undefined") {
|
|
3011
|
+
return;
|
|
3012
|
+
}
|
|
3013
|
+
const components = ["dialog-editor"];
|
|
3014
|
+
components.forEach(tagName => { switch (tagName) {
|
|
3015
|
+
case "dialog-editor":
|
|
3016
|
+
if (!customElements.get(tagName)) {
|
|
3017
|
+
customElements.define(tagName, DialogEditor);
|
|
3018
|
+
}
|
|
3019
|
+
break;
|
|
3020
|
+
} });
|
|
3021
|
+
}
|
|
3022
|
+
defineCustomElement();
|
|
3023
|
+
|
|
3024
|
+
export { DialogEditor as D, defineCustomElement as d };
|
|
3025
|
+
//# sourceMappingURL=p-Beycm8NN.js.map
|
|
3026
|
+
|
|
3027
|
+
//# sourceMappingURL=p-Beycm8NN.js.map
|