@touchvue/chat 1.0.0-beta.5 → 1.0.0-beta.50
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +25 -25
- package/es/_virtual/_plugin-vue_export-helper.mjs +10 -0
- package/es/_virtual/_plugin-vue_export-helper.mjs.map +1 -0
- package/es/index.mjs.map +1 -1
- package/es/node_modules/.pnpm/@touchvue_a2ui@1.0.0-beta.46/node_modules/@touchvue/a2ui/dist/index.mjs +4816 -0
- package/es/node_modules/.pnpm/@touchvue_a2ui@1.0.0-beta.46/node_modules/@touchvue/a2ui/dist/index.mjs.map +1 -0
- package/es/node_modules/.pnpm/dompurify@3.3.0/node_modules/dompurify/dist/purify.es.mjs +1380 -0
- package/es/node_modules/.pnpm/dompurify@3.3.0/node_modules/dompurify/dist/purify.es.mjs.map +1 -0
- package/es/node_modules/.pnpm/html2canvas@1.4.1/node_modules/html2canvas/dist/html2canvas.esm.mjs +7824 -0
- package/es/node_modules/.pnpm/html2canvas@1.4.1/node_modules/html2canvas/dist/html2canvas.esm.mjs.map +1 -0
- package/es/package.json.css +1 -1
- package/es/package.json.mjs +2 -2
- package/es/packages/components/index.mjs +1 -1
- package/es/packages/components/resolver.mjs.map +1 -1
- package/es/packages/components/touchchat/component/AiRobot/HelloChat.vue.mjs +3 -2
- package/es/packages/components/touchchat/component/AiRobot/HelloChat.vue.mjs.map +1 -1
- package/es/packages/components/touchchat/component/AiRobot/HelloChat.vue2.mjs +219 -159
- package/es/packages/components/touchchat/component/AiRobot/HelloChat.vue2.mjs.map +1 -1
- package/es/packages/components/touchchat/component/AiRobot/face.vue.mjs +3 -2
- package/es/packages/components/touchchat/component/AiRobot/face.vue.mjs.map +1 -1
- package/es/packages/components/touchchat/component/AiRobot/face.vue2.mjs +27 -13
- package/es/packages/components/touchchat/component/AiRobot/face.vue2.mjs.map +1 -1
- package/es/packages/components/touchchat/component/AiRobot/letter.vue.mjs +3 -2
- package/es/packages/components/touchchat/component/AiRobot/letter.vue.mjs.map +1 -1
- package/es/packages/components/touchchat/component/AiRobot/letter.vue2.mjs +182 -41
- package/es/packages/components/touchchat/component/AiRobot/letter.vue2.mjs.map +1 -1
- package/es/packages/components/touchchat/component/AiRobot/meterialPrepare.vue.mjs +3 -2
- package/es/packages/components/touchchat/component/AiRobot/meterialPrepare.vue.mjs.map +1 -1
- package/es/packages/components/touchchat/component/AiRobot/meterialPrepare.vue2.mjs +15 -10
- package/es/packages/components/touchchat/component/AiRobot/meterialPrepare.vue2.mjs.map +1 -1
- package/es/packages/components/touchchat/component/AiRobot/start.vue.mjs +3 -2
- package/es/packages/components/touchchat/component/AiRobot/start.vue.mjs.map +1 -1
- package/es/packages/components/touchchat/component/AiRobot/start.vue2.mjs +18 -11
- package/es/packages/components/touchchat/component/AiRobot/start.vue2.mjs.map +1 -1
- package/es/packages/components/touchchat/component/CardView.vue.mjs +3 -2
- package/es/packages/components/touchchat/component/CardView.vue.mjs.map +1 -1
- package/es/packages/components/touchchat/component/CardView.vue2.mjs +66 -42
- package/es/packages/components/touchchat/component/CardView.vue2.mjs.map +1 -1
- package/es/packages/components/touchchat/component/FileContent.vue.mjs +7 -0
- package/es/packages/components/touchchat/component/FileContent.vue.mjs.map +1 -0
- package/es/packages/components/touchchat/component/FileContent.vue2.mjs +206 -0
- package/es/packages/components/touchchat/component/FileContent.vue2.mjs.map +1 -0
- package/es/packages/components/touchchat/component/FileView.vue.mjs +3 -2
- package/es/packages/components/touchchat/component/FileView.vue.mjs.map +1 -1
- package/es/packages/components/touchchat/component/FileView.vue2.mjs +17 -4
- package/es/packages/components/touchchat/component/FileView.vue2.mjs.map +1 -1
- package/es/packages/components/touchchat/component/HelloChat.vue.mjs +3 -2
- package/es/packages/components/touchchat/component/HelloChat.vue.mjs.map +1 -1
- package/es/packages/components/touchchat/component/HelloChat.vue2.mjs +26 -14
- package/es/packages/components/touchchat/component/HelloChat.vue2.mjs.map +1 -1
- package/es/packages/components/touchchat/component/ImageFile.vue.mjs +7 -0
- package/es/packages/components/touchchat/component/ImageFile.vue.mjs.map +1 -0
- package/es/packages/components/touchchat/component/ImageFile.vue2.mjs +162 -0
- package/es/packages/components/touchchat/component/ImageFile.vue2.mjs.map +1 -0
- package/es/packages/components/touchchat/component/ImageView.vue.mjs +3 -2
- package/es/packages/components/touchchat/component/ImageView.vue.mjs.map +1 -1
- package/es/packages/components/touchchat/component/ImageView.vue2.mjs +1 -1
- package/es/packages/components/touchchat/component/ImageView.vue2.mjs.map +1 -1
- package/es/packages/components/touchchat/component/LinkView.vue.mjs +3 -2
- package/es/packages/components/touchchat/component/LinkView.vue.mjs.map +1 -1
- package/es/packages/components/touchchat/component/LinkView.vue2.mjs +19 -5
- package/es/packages/components/touchchat/component/LinkView.vue2.mjs.map +1 -1
- package/es/packages/components/touchchat/component/MarkLayer.vue.mjs +7 -0
- package/es/packages/components/touchchat/component/MarkLayer.vue.mjs.map +1 -0
- package/es/packages/components/touchchat/component/MarkLayer.vue2.mjs +56 -0
- package/es/packages/components/touchchat/component/MarkLayer.vue2.mjs.map +1 -0
- package/es/packages/components/touchchat/component/ModuleSelect.vue.mjs +7 -0
- package/es/packages/components/touchchat/component/ModuleSelect.vue.mjs.map +1 -0
- package/es/packages/components/touchchat/component/ModuleSelect.vue2.mjs +121 -0
- package/es/packages/components/touchchat/component/ModuleSelect.vue2.mjs.map +1 -0
- package/es/packages/components/touchchat/component/PDFFile.vue.mjs +7 -0
- package/es/packages/components/touchchat/component/PDFFile.vue.mjs.map +1 -0
- package/es/packages/components/touchchat/component/PDFFile.vue2.mjs +211 -0
- package/es/packages/components/touchchat/component/PDFFile.vue2.mjs.map +1 -0
- package/es/packages/components/touchchat/component/QuoteContent.vue.mjs +7 -0
- package/es/packages/components/touchchat/component/QuoteContent.vue.mjs.map +1 -0
- package/es/packages/components/touchchat/component/QuoteContent.vue2.mjs +40 -0
- package/es/packages/components/touchchat/component/QuoteContent.vue2.mjs.map +1 -0
- package/es/packages/components/touchchat/component/RealtimeVoice.vue.mjs +7 -0
- package/es/packages/components/touchchat/component/RealtimeVoice.vue.mjs.map +1 -0
- package/es/packages/components/touchchat/component/RealtimeVoice.vue2.mjs +160 -0
- package/es/packages/components/touchchat/component/RealtimeVoice.vue2.mjs.map +1 -0
- package/es/packages/components/touchchat/component/Screenshot.vue.mjs +7 -0
- package/es/packages/components/touchchat/component/Screenshot.vue.mjs.map +1 -0
- package/es/packages/components/touchchat/component/Screenshot.vue2.mjs +208 -0
- package/es/packages/components/touchchat/component/Screenshot.vue2.mjs.map +1 -0
- package/es/packages/components/touchchat/component/ThoughtChain.vue.mjs +7 -0
- package/es/packages/components/touchchat/component/ThoughtChain.vue.mjs.map +1 -0
- package/es/packages/components/touchchat/component/ThoughtChain.vue2.mjs +69 -0
- package/es/packages/components/touchchat/component/ThoughtChain.vue2.mjs.map +1 -0
- package/es/packages/components/touchchat/component/UploadView.vue.mjs +7 -0
- package/es/packages/components/touchchat/component/UploadView.vue.mjs.map +1 -0
- package/es/packages/components/touchchat/component/UploadView.vue2.mjs +186 -0
- package/es/packages/components/touchchat/component/UploadView.vue2.mjs.map +1 -0
- package/es/packages/components/touchchat/component/UploadView_api.vue.mjs +7 -0
- package/es/packages/components/touchchat/component/UploadView_api.vue.mjs.map +1 -0
- package/es/packages/components/touchchat/component/UploadView_api.vue2.mjs +166 -0
- package/es/packages/components/touchchat/component/UploadView_api.vue2.mjs.map +1 -0
- package/es/packages/components/touchchat/component/VideoFile.vue.mjs +7 -0
- package/es/packages/components/touchchat/component/VideoFile.vue.mjs.map +1 -0
- package/es/packages/components/touchchat/component/VideoFile.vue2.mjs +33 -0
- package/es/packages/components/touchchat/component/VideoFile.vue2.mjs.map +1 -0
- package/es/packages/components/touchchat/component/VoiceView.vue.mjs +7 -0
- package/es/packages/components/touchchat/component/VoiceView.vue.mjs.map +1 -0
- package/es/packages/components/touchchat/component/VoiceView.vue2.mjs +165 -0
- package/es/packages/components/touchchat/component/VoiceView.vue2.mjs.map +1 -0
- package/es/packages/components/touchchat/img/file/doc.png.mjs +4 -0
- package/es/packages/components/touchchat/img/file/doc.png.mjs.map +1 -0
- package/es/packages/components/touchchat/img/file/docx.png.mjs +4 -0
- package/es/packages/components/touchchat/img/file/docx.png.mjs.map +1 -0
- package/es/packages/components/touchchat/img/file/gif.png.mjs +4 -0
- package/es/packages/components/touchchat/img/file/gif.png.mjs.map +1 -0
- package/es/packages/components/touchchat/img/file/html.png.mjs +4 -0
- package/es/packages/components/touchchat/img/file/html.png.mjs.map +1 -0
- package/es/packages/components/touchchat/img/file/jpg.png.mjs +4 -0
- package/es/packages/components/touchchat/img/file/jpg.png.mjs.map +1 -0
- package/es/packages/components/touchchat/img/file/mp3.png.mjs +4 -0
- package/es/packages/components/touchchat/img/file/mp3.png.mjs.map +1 -0
- package/es/packages/components/touchchat/img/file/mp4.png.mjs +4 -0
- package/es/packages/components/touchchat/img/file/mp4.png.mjs.map +1 -0
- package/es/packages/components/touchchat/img/file/music.png.mjs +4 -0
- package/es/packages/components/touchchat/img/file/music.png.mjs.map +1 -0
- package/es/packages/components/touchchat/img/file/pdf.png.mjs +4 -0
- package/es/packages/components/touchchat/img/file/pdf.png.mjs.map +1 -0
- package/es/packages/components/touchchat/img/file/png.png.mjs +4 -0
- package/es/packages/components/touchchat/img/file/png.png.mjs.map +1 -0
- package/es/packages/components/touchchat/img/file/ppt.png.mjs +4 -0
- package/es/packages/components/touchchat/img/file/ppt.png.mjs.map +1 -0
- package/es/packages/components/touchchat/img/file/pptx.png.mjs +4 -0
- package/es/packages/components/touchchat/img/file/pptx.png.mjs.map +1 -0
- package/es/packages/components/touchchat/img/file/txt.png.mjs +4 -0
- package/es/packages/components/touchchat/img/file/txt.png.mjs.map +1 -0
- package/es/packages/components/touchchat/img/file/xls.png.mjs +4 -0
- package/es/packages/components/touchchat/img/file/xls.png.mjs.map +1 -0
- package/es/packages/components/touchchat/img/file/xlsx.png.mjs +4 -0
- package/es/packages/components/touchchat/img/file/xlsx.png.mjs.map +1 -0
- package/es/packages/components/touchchat/img/svg/reset.svg.mjs +4 -0
- package/es/packages/components/touchchat/img/svg/reset.svg.mjs.map +1 -0
- package/es/packages/components/touchchat/index.mjs +5 -5
- package/es/packages/components/touchchat/index.mjs.map +1 -1
- package/es/packages/components/touchchat/src/AiChat/AgentsView.vue.mjs +7 -0
- package/es/packages/components/touchchat/src/AiChat/AgentsView.vue.mjs.map +1 -0
- package/es/packages/components/touchchat/src/AiChat/AgentsView.vue2.mjs +59 -0
- package/es/packages/components/touchchat/src/AiChat/AgentsView.vue2.mjs.map +1 -0
- package/es/packages/components/touchchat/src/AiChat/AiMessage.vue.mjs +3 -2
- package/es/packages/components/touchchat/src/AiChat/AiMessage.vue.mjs.map +1 -1
- package/es/packages/components/touchchat/src/AiChat/AiMessage.vue2.mjs +322 -139
- package/es/packages/components/touchchat/src/AiChat/AiMessage.vue2.mjs.map +1 -1
- package/es/packages/components/touchchat/src/AiChat/Chat/TouchChat.mjs +18 -0
- package/es/packages/components/touchchat/src/AiChat/Chat/TouchChat.mjs.map +1 -0
- package/es/packages/components/touchchat/src/AiChat/Chat/scriptMatcher.mjs +145 -0
- package/es/packages/components/touchchat/src/AiChat/Chat/scriptMatcher.mjs.map +1 -0
- package/es/packages/components/touchchat/src/AiChat/Chat/types.mjs +19 -0
- package/es/packages/components/touchchat/src/AiChat/Chat/types.mjs.map +1 -0
- package/es/packages/components/touchchat/src/AiChat/Chat/useChat.mjs +693 -0
- package/es/packages/components/touchchat/src/AiChat/Chat/useChat.mjs.map +1 -0
- package/es/packages/components/touchchat/src/AiChat/Chat/useCopy.mjs +55 -0
- package/es/packages/components/touchchat/src/AiChat/Chat/useCopy.mjs.map +1 -0
- package/es/packages/components/touchchat/src/AiChat/Chat/useMessageRender.mjs +155 -0
- package/es/packages/components/touchchat/src/AiChat/Chat/useMessageRender.mjs.map +1 -0
- package/es/packages/components/touchchat/src/AiChat/Chat/useSSE.mjs +345 -0
- package/es/packages/components/touchchat/src/AiChat/Chat/useSSE.mjs.map +1 -0
- package/es/packages/components/touchchat/src/AiChat/Chat/useScroll.mjs +74 -0
- package/es/packages/components/touchchat/src/AiChat/Chat/useScroll.mjs.map +1 -0
- package/es/packages/components/touchchat/src/AiChat/ChatInput.vue.mjs +3 -2
- package/es/packages/components/touchchat/src/AiChat/ChatInput.vue.mjs.map +1 -1
- package/es/packages/components/touchchat/src/AiChat/ChatInput.vue2.mjs +472 -44
- package/es/packages/components/touchchat/src/AiChat/ChatInput.vue2.mjs.map +1 -1
- package/es/packages/components/touchchat/src/AiChat/HistoryList.vue.mjs +3 -2
- package/es/packages/components/touchchat/src/AiChat/HistoryList.vue.mjs.map +1 -1
- package/es/packages/components/touchchat/src/AiChat/HistoryList.vue2.mjs +180 -98
- package/es/packages/components/touchchat/src/AiChat/HistoryList.vue2.mjs.map +1 -1
- package/es/packages/components/touchchat/src/AiChat/HistorySidebar.vue.mjs +3 -2
- package/es/packages/components/touchchat/src/AiChat/HistorySidebar.vue.mjs.map +1 -1
- package/es/packages/components/touchchat/src/AiChat/HistorySidebar.vue2.mjs +29 -12
- package/es/packages/components/touchchat/src/AiChat/HistorySidebar.vue2.mjs.map +1 -1
- package/es/packages/components/touchchat/src/AiChat/MessageActions.vue.mjs +3 -2
- package/es/packages/components/touchchat/src/AiChat/MessageActions.vue.mjs.map +1 -1
- package/es/packages/components/touchchat/src/AiChat/MessageActions.vue2.mjs +175 -62
- package/es/packages/components/touchchat/src/AiChat/MessageActions.vue2.mjs.map +1 -1
- package/es/packages/components/touchchat/src/AiChat/SiderBarView.vue.mjs +3 -2
- package/es/packages/components/touchchat/src/AiChat/SiderBarView.vue.mjs.map +1 -1
- package/es/packages/components/touchchat/src/AiChat/SiderBarView.vue2.mjs +14 -8
- package/es/packages/components/touchchat/src/AiChat/SiderBarView.vue2.mjs.map +1 -1
- package/es/packages/components/touchchat/src/AiChat/TouchAgent.vue.mjs +7 -0
- package/es/packages/components/touchchat/src/AiChat/TouchAgent.vue.mjs.map +1 -0
- package/es/packages/components/touchchat/src/AiChat/TouchAgent.vue2.mjs +1034 -0
- package/es/packages/components/touchchat/src/AiChat/TouchAgent.vue2.mjs.map +1 -0
- package/es/packages/components/touchchat/src/AiChat/TouchChat.vue.mjs +3 -2
- package/es/packages/components/touchchat/src/AiChat/TouchChat.vue.mjs.map +1 -1
- package/es/packages/components/touchchat/src/AiChat/TouchChat.vue2.mjs +276 -1004
- package/es/packages/components/touchchat/src/AiChat/TouchChat.vue2.mjs.map +1 -1
- package/es/packages/components/touchchat/src/AiChat/TouchHistory.vue.mjs +3 -2
- package/es/packages/components/touchchat/src/AiChat/TouchHistory.vue.mjs.map +1 -1
- package/es/packages/components/touchchat/src/AiChat/TouchHistory.vue2.mjs +346 -122
- package/es/packages/components/touchchat/src/AiChat/TouchHistory.vue2.mjs.map +1 -1
- package/es/packages/components/touchchat/src/AiChat/UserMessage.vue.mjs +3 -2
- package/es/packages/components/touchchat/src/AiChat/UserMessage.vue.mjs.map +1 -1
- package/es/packages/components/touchchat/src/AiChat/UserMessage.vue2.mjs +143 -64
- package/es/packages/components/touchchat/src/AiChat/UserMessage.vue2.mjs.map +1 -1
- package/es/packages/components/touchchat/src/index.vue.mjs +3 -2
- package/es/packages/components/touchchat/src/index.vue.mjs.map +1 -1
- package/es/packages/components/touchchat/src/index.vue2.mjs +252 -143
- package/es/packages/components/touchchat/src/index.vue2.mjs.map +1 -1
- package/es/packages/components/touchchat/src/types/a2a.mjs +11 -0
- package/es/packages/components/touchchat/src/types/a2a.mjs.map +1 -0
- package/es/packages/components/touchchat/utils/a2aService.mjs +316 -0
- package/es/packages/components/touchchat/utils/a2aService.mjs.map +1 -0
- package/es/packages/components/touchchat/utils/fetchStream.mjs +8 -2
- package/es/packages/components/touchchat/utils/fetchStream.mjs.map +1 -1
- package/es/packages/components/touchchat/utils/markdown.mjs +31 -13
- package/es/packages/components/touchchat/utils/markdown.mjs.map +1 -1
- package/es/packages/utils/config.mjs.map +1 -1
- package/es/packages/utils/types.mjs.map +1 -1
- package/global.d.ts +2 -2
- package/lib/_virtual/_plugin-vue_export-helper.js +14 -0
- package/lib/_virtual/_plugin-vue_export-helper.js.map +1 -0
- package/lib/index.js.map +1 -1
- package/lib/node_modules/.pnpm/@touchvue_a2ui@1.0.0-beta.46/node_modules/@touchvue/a2ui/dist/index.js +4819 -0
- package/lib/node_modules/.pnpm/@touchvue_a2ui@1.0.0-beta.46/node_modules/@touchvue/a2ui/dist/index.js.map +1 -0
- package/lib/node_modules/.pnpm/dompurify@3.3.0/node_modules/dompurify/dist/purify.es.js +1384 -0
- package/lib/node_modules/.pnpm/dompurify@3.3.0/node_modules/dompurify/dist/purify.es.js.map +1 -0
- package/lib/node_modules/.pnpm/html2canvas@1.4.1/node_modules/html2canvas/dist/html2canvas.esm.js +7828 -0
- package/lib/node_modules/.pnpm/html2canvas@1.4.1/node_modules/html2canvas/dist/html2canvas.esm.js.map +1 -0
- package/lib/package.json.css +1 -1
- package/lib/package.json.js +2 -2
- package/lib/packages/components/index.js +2 -2
- package/lib/packages/components/resolver.js.map +1 -1
- package/lib/packages/components/touchchat/component/AiRobot/HelloChat.vue.js +3 -2
- package/lib/packages/components/touchchat/component/AiRobot/HelloChat.vue.js.map +1 -1
- package/lib/packages/components/touchchat/component/AiRobot/HelloChat.vue2.js +219 -159
- package/lib/packages/components/touchchat/component/AiRobot/HelloChat.vue2.js.map +1 -1
- package/lib/packages/components/touchchat/component/AiRobot/face.vue.js +3 -2
- package/lib/packages/components/touchchat/component/AiRobot/face.vue.js.map +1 -1
- package/lib/packages/components/touchchat/component/AiRobot/face.vue2.js +26 -12
- package/lib/packages/components/touchchat/component/AiRobot/face.vue2.js.map +1 -1
- package/lib/packages/components/touchchat/component/AiRobot/letter.vue.js +3 -2
- package/lib/packages/components/touchchat/component/AiRobot/letter.vue.js.map +1 -1
- package/lib/packages/components/touchchat/component/AiRobot/letter.vue2.js +181 -40
- package/lib/packages/components/touchchat/component/AiRobot/letter.vue2.js.map +1 -1
- package/lib/packages/components/touchchat/component/AiRobot/meterialPrepare.vue.js +3 -2
- package/lib/packages/components/touchchat/component/AiRobot/meterialPrepare.vue.js.map +1 -1
- package/lib/packages/components/touchchat/component/AiRobot/meterialPrepare.vue2.js +15 -10
- package/lib/packages/components/touchchat/component/AiRobot/meterialPrepare.vue2.js.map +1 -1
- package/lib/packages/components/touchchat/component/AiRobot/start.vue.js +3 -2
- package/lib/packages/components/touchchat/component/AiRobot/start.vue.js.map +1 -1
- package/lib/packages/components/touchchat/component/AiRobot/start.vue2.js +17 -10
- package/lib/packages/components/touchchat/component/AiRobot/start.vue2.js.map +1 -1
- package/lib/packages/components/touchchat/component/CardView.vue.js +3 -2
- package/lib/packages/components/touchchat/component/CardView.vue.js.map +1 -1
- package/lib/packages/components/touchchat/component/CardView.vue2.js +66 -42
- package/lib/packages/components/touchchat/component/CardView.vue2.js.map +1 -1
- package/lib/packages/components/touchchat/component/FileContent.vue.js +11 -0
- package/lib/packages/components/touchchat/component/FileContent.vue.js.map +1 -0
- package/lib/packages/components/touchchat/component/FileContent.vue2.js +210 -0
- package/lib/packages/components/touchchat/component/FileContent.vue2.js.map +1 -0
- package/lib/packages/components/touchchat/component/FileView.vue.js +3 -2
- package/lib/packages/components/touchchat/component/FileView.vue.js.map +1 -1
- package/lib/packages/components/touchchat/component/FileView.vue2.js +16 -3
- package/lib/packages/components/touchchat/component/FileView.vue2.js.map +1 -1
- package/lib/packages/components/touchchat/component/HelloChat.vue.js +3 -2
- package/lib/packages/components/touchchat/component/HelloChat.vue.js.map +1 -1
- package/lib/packages/components/touchchat/component/HelloChat.vue2.js +26 -14
- package/lib/packages/components/touchchat/component/HelloChat.vue2.js.map +1 -1
- package/lib/packages/components/touchchat/component/ImageFile.vue.js +11 -0
- package/lib/packages/components/touchchat/component/ImageFile.vue.js.map +1 -0
- package/lib/packages/components/touchchat/component/ImageFile.vue2.js +166 -0
- package/lib/packages/components/touchchat/component/ImageFile.vue2.js.map +1 -0
- package/lib/packages/components/touchchat/component/ImageView.vue.js +3 -2
- package/lib/packages/components/touchchat/component/ImageView.vue.js.map +1 -1
- package/lib/packages/components/touchchat/component/ImageView.vue2.js +1 -1
- package/lib/packages/components/touchchat/component/ImageView.vue2.js.map +1 -1
- package/lib/packages/components/touchchat/component/LinkView.vue.js +3 -2
- package/lib/packages/components/touchchat/component/LinkView.vue.js.map +1 -1
- package/lib/packages/components/touchchat/component/LinkView.vue2.js +18 -4
- package/lib/packages/components/touchchat/component/LinkView.vue2.js.map +1 -1
- package/lib/packages/components/touchchat/component/MarkLayer.vue.js +11 -0
- package/lib/packages/components/touchchat/component/MarkLayer.vue.js.map +1 -0
- package/lib/packages/components/touchchat/component/MarkLayer.vue2.js +60 -0
- package/lib/packages/components/touchchat/component/MarkLayer.vue2.js.map +1 -0
- package/lib/packages/components/touchchat/component/ModuleSelect.vue.js +11 -0
- package/lib/packages/components/touchchat/component/ModuleSelect.vue.js.map +1 -0
- package/lib/packages/components/touchchat/component/ModuleSelect.vue2.js +125 -0
- package/lib/packages/components/touchchat/component/ModuleSelect.vue2.js.map +1 -0
- package/lib/packages/components/touchchat/component/PDFFile.vue.js +11 -0
- package/lib/packages/components/touchchat/component/PDFFile.vue.js.map +1 -0
- package/lib/packages/components/touchchat/component/PDFFile.vue2.js +215 -0
- package/lib/packages/components/touchchat/component/PDFFile.vue2.js.map +1 -0
- package/lib/packages/components/touchchat/component/QuoteContent.vue.js +11 -0
- package/lib/packages/components/touchchat/component/QuoteContent.vue.js.map +1 -0
- package/lib/packages/components/touchchat/component/QuoteContent.vue2.js +44 -0
- package/lib/packages/components/touchchat/component/QuoteContent.vue2.js.map +1 -0
- package/lib/packages/components/touchchat/component/RealtimeVoice.vue.js +11 -0
- package/lib/packages/components/touchchat/component/RealtimeVoice.vue.js.map +1 -0
- package/lib/packages/components/touchchat/component/RealtimeVoice.vue2.js +164 -0
- package/lib/packages/components/touchchat/component/RealtimeVoice.vue2.js.map +1 -0
- package/lib/packages/components/touchchat/component/Screenshot.vue.js +11 -0
- package/lib/packages/components/touchchat/component/Screenshot.vue.js.map +1 -0
- package/lib/packages/components/touchchat/component/Screenshot.vue2.js +212 -0
- package/lib/packages/components/touchchat/component/Screenshot.vue2.js.map +1 -0
- package/lib/packages/components/touchchat/component/ThoughtChain.vue.js +11 -0
- package/lib/packages/components/touchchat/component/ThoughtChain.vue.js.map +1 -0
- package/lib/packages/components/touchchat/component/ThoughtChain.vue2.js +73 -0
- package/lib/packages/components/touchchat/component/ThoughtChain.vue2.js.map +1 -0
- package/lib/packages/components/touchchat/component/UploadView.vue.js +11 -0
- package/lib/packages/components/touchchat/component/UploadView.vue.js.map +1 -0
- package/lib/packages/components/touchchat/component/UploadView.vue2.js +190 -0
- package/lib/packages/components/touchchat/component/UploadView.vue2.js.map +1 -0
- package/lib/packages/components/touchchat/component/UploadView_api.vue.js +11 -0
- package/lib/packages/components/touchchat/component/UploadView_api.vue.js.map +1 -0
- package/lib/packages/components/touchchat/component/UploadView_api.vue2.js +170 -0
- package/lib/packages/components/touchchat/component/UploadView_api.vue2.js.map +1 -0
- package/lib/packages/components/touchchat/component/VideoFile.vue.js +11 -0
- package/lib/packages/components/touchchat/component/VideoFile.vue.js.map +1 -0
- package/lib/packages/components/touchchat/component/VideoFile.vue2.js +37 -0
- package/lib/packages/components/touchchat/component/VideoFile.vue2.js.map +1 -0
- package/lib/packages/components/touchchat/component/VoiceView.vue.js +11 -0
- package/lib/packages/components/touchchat/component/VoiceView.vue.js.map +1 -0
- package/lib/packages/components/touchchat/component/VoiceView.vue2.js +169 -0
- package/lib/packages/components/touchchat/component/VoiceView.vue2.js.map +1 -0
- package/lib/packages/components/touchchat/img/file/doc.png.js +8 -0
- package/lib/packages/components/touchchat/img/file/doc.png.js.map +1 -0
- package/lib/packages/components/touchchat/img/file/docx.png.js +8 -0
- package/lib/packages/components/touchchat/img/file/docx.png.js.map +1 -0
- package/lib/packages/components/touchchat/img/file/gif.png.js +8 -0
- package/lib/packages/components/touchchat/img/file/gif.png.js.map +1 -0
- package/lib/packages/components/touchchat/img/file/html.png.js +8 -0
- package/lib/packages/components/touchchat/img/file/html.png.js.map +1 -0
- package/lib/packages/components/touchchat/img/file/jpg.png.js +8 -0
- package/lib/packages/components/touchchat/img/file/jpg.png.js.map +1 -0
- package/lib/packages/components/touchchat/img/file/mp3.png.js +8 -0
- package/lib/packages/components/touchchat/img/file/mp3.png.js.map +1 -0
- package/lib/packages/components/touchchat/img/file/mp4.png.js +8 -0
- package/lib/packages/components/touchchat/img/file/mp4.png.js.map +1 -0
- package/lib/packages/components/touchchat/img/file/music.png.js +8 -0
- package/lib/packages/components/touchchat/img/file/music.png.js.map +1 -0
- package/lib/packages/components/touchchat/img/file/pdf.png.js +8 -0
- package/lib/packages/components/touchchat/img/file/pdf.png.js.map +1 -0
- package/lib/packages/components/touchchat/img/file/png.png.js +8 -0
- package/lib/packages/components/touchchat/img/file/png.png.js.map +1 -0
- package/lib/packages/components/touchchat/img/file/ppt.png.js +8 -0
- package/lib/packages/components/touchchat/img/file/ppt.png.js.map +1 -0
- package/lib/packages/components/touchchat/img/file/pptx.png.js +8 -0
- package/lib/packages/components/touchchat/img/file/pptx.png.js.map +1 -0
- package/lib/packages/components/touchchat/img/file/txt.png.js +8 -0
- package/lib/packages/components/touchchat/img/file/txt.png.js.map +1 -0
- package/lib/packages/components/touchchat/img/file/xls.png.js +8 -0
- package/lib/packages/components/touchchat/img/file/xls.png.js.map +1 -0
- package/lib/packages/components/touchchat/img/file/xlsx.png.js +8 -0
- package/lib/packages/components/touchchat/img/file/xlsx.png.js.map +1 -0
- package/lib/packages/components/touchchat/img/svg/reset.svg.js +8 -0
- package/lib/packages/components/touchchat/img/svg/reset.svg.js.map +1 -0
- package/lib/packages/components/touchchat/index.js +6 -6
- package/lib/packages/components/touchchat/index.js.map +1 -1
- package/lib/packages/components/touchchat/src/AiChat/AgentsView.vue.js +11 -0
- package/lib/packages/components/touchchat/src/AiChat/AgentsView.vue.js.map +1 -0
- package/lib/packages/components/touchchat/src/AiChat/AgentsView.vue2.js +63 -0
- package/lib/packages/components/touchchat/src/AiChat/AgentsView.vue2.js.map +1 -0
- package/lib/packages/components/touchchat/src/AiChat/AiMessage.vue.js +3 -2
- package/lib/packages/components/touchchat/src/AiChat/AiMessage.vue.js.map +1 -1
- package/lib/packages/components/touchchat/src/AiChat/AiMessage.vue2.js +321 -138
- package/lib/packages/components/touchchat/src/AiChat/AiMessage.vue2.js.map +1 -1
- package/lib/packages/components/touchchat/src/AiChat/Chat/TouchChat.js +21 -0
- package/lib/packages/components/touchchat/src/AiChat/Chat/TouchChat.js.map +1 -0
- package/lib/packages/components/touchchat/src/AiChat/Chat/scriptMatcher.js +147 -0
- package/lib/packages/components/touchchat/src/AiChat/Chat/scriptMatcher.js.map +1 -0
- package/lib/packages/components/touchchat/src/AiChat/Chat/types.js +22 -0
- package/lib/packages/components/touchchat/src/AiChat/Chat/types.js.map +1 -0
- package/lib/packages/components/touchchat/src/AiChat/Chat/useChat.js +695 -0
- package/lib/packages/components/touchchat/src/AiChat/Chat/useChat.js.map +1 -0
- package/lib/packages/components/touchchat/src/AiChat/Chat/useCopy.js +57 -0
- package/lib/packages/components/touchchat/src/AiChat/Chat/useCopy.js.map +1 -0
- package/lib/packages/components/touchchat/src/AiChat/Chat/useMessageRender.js +157 -0
- package/lib/packages/components/touchchat/src/AiChat/Chat/useMessageRender.js.map +1 -0
- package/lib/packages/components/touchchat/src/AiChat/Chat/useSSE.js +347 -0
- package/lib/packages/components/touchchat/src/AiChat/Chat/useSSE.js.map +1 -0
- package/lib/packages/components/touchchat/src/AiChat/Chat/useScroll.js +76 -0
- package/lib/packages/components/touchchat/src/AiChat/Chat/useScroll.js.map +1 -0
- package/lib/packages/components/touchchat/src/AiChat/ChatInput.vue.js +3 -2
- package/lib/packages/components/touchchat/src/AiChat/ChatInput.vue.js.map +1 -1
- package/lib/packages/components/touchchat/src/AiChat/ChatInput.vue2.js +471 -43
- package/lib/packages/components/touchchat/src/AiChat/ChatInput.vue2.js.map +1 -1
- package/lib/packages/components/touchchat/src/AiChat/HistoryList.vue.js +3 -2
- package/lib/packages/components/touchchat/src/AiChat/HistoryList.vue.js.map +1 -1
- package/lib/packages/components/touchchat/src/AiChat/HistoryList.vue2.js +179 -97
- package/lib/packages/components/touchchat/src/AiChat/HistoryList.vue2.js.map +1 -1
- package/lib/packages/components/touchchat/src/AiChat/HistorySidebar.vue.js +3 -2
- package/lib/packages/components/touchchat/src/AiChat/HistorySidebar.vue.js.map +1 -1
- package/lib/packages/components/touchchat/src/AiChat/HistorySidebar.vue2.js +28 -11
- package/lib/packages/components/touchchat/src/AiChat/HistorySidebar.vue2.js.map +1 -1
- package/lib/packages/components/touchchat/src/AiChat/MessageActions.vue.js +3 -2
- package/lib/packages/components/touchchat/src/AiChat/MessageActions.vue.js.map +1 -1
- package/lib/packages/components/touchchat/src/AiChat/MessageActions.vue2.js +174 -61
- package/lib/packages/components/touchchat/src/AiChat/MessageActions.vue2.js.map +1 -1
- package/lib/packages/components/touchchat/src/AiChat/SiderBarView.vue.js +3 -2
- package/lib/packages/components/touchchat/src/AiChat/SiderBarView.vue.js.map +1 -1
- package/lib/packages/components/touchchat/src/AiChat/SiderBarView.vue2.js +14 -8
- package/lib/packages/components/touchchat/src/AiChat/SiderBarView.vue2.js.map +1 -1
- package/lib/packages/components/touchchat/src/AiChat/TouchAgent.vue.js +11 -0
- package/lib/packages/components/touchchat/src/AiChat/TouchAgent.vue.js.map +1 -0
- package/lib/packages/components/touchchat/src/AiChat/TouchAgent.vue2.js +1038 -0
- package/lib/packages/components/touchchat/src/AiChat/TouchAgent.vue2.js.map +1 -0
- package/lib/packages/components/touchchat/src/AiChat/TouchChat.vue.js +3 -2
- package/lib/packages/components/touchchat/src/AiChat/TouchChat.vue.js.map +1 -1
- package/lib/packages/components/touchchat/src/AiChat/TouchChat.vue2.js +275 -1003
- package/lib/packages/components/touchchat/src/AiChat/TouchChat.vue2.js.map +1 -1
- package/lib/packages/components/touchchat/src/AiChat/TouchHistory.vue.js +3 -2
- package/lib/packages/components/touchchat/src/AiChat/TouchHistory.vue.js.map +1 -1
- package/lib/packages/components/touchchat/src/AiChat/TouchHistory.vue2.js +345 -121
- package/lib/packages/components/touchchat/src/AiChat/TouchHistory.vue2.js.map +1 -1
- package/lib/packages/components/touchchat/src/AiChat/UserMessage.vue.js +3 -2
- package/lib/packages/components/touchchat/src/AiChat/UserMessage.vue.js.map +1 -1
- package/lib/packages/components/touchchat/src/AiChat/UserMessage.vue2.js +142 -63
- package/lib/packages/components/touchchat/src/AiChat/UserMessage.vue2.js.map +1 -1
- package/lib/packages/components/touchchat/src/index.vue.js +3 -2
- package/lib/packages/components/touchchat/src/index.vue.js.map +1 -1
- package/lib/packages/components/touchchat/src/index.vue2.js +251 -142
- package/lib/packages/components/touchchat/src/index.vue2.js.map +1 -1
- package/lib/packages/components/touchchat/src/types/a2a.js +13 -0
- package/lib/packages/components/touchchat/src/types/a2a.js.map +1 -0
- package/lib/packages/components/touchchat/utils/a2aService.js +319 -0
- package/lib/packages/components/touchchat/utils/a2aService.js.map +1 -0
- package/lib/packages/components/touchchat/utils/fetchStream.js +8 -2
- package/lib/packages/components/touchchat/utils/fetchStream.js.map +1 -1
- package/lib/packages/components/touchchat/utils/markdown.js +31 -13
- package/lib/packages/components/touchchat/utils/markdown.js.map +1 -1
- package/lib/packages/utils/config.js.map +1 -1
- package/lib/packages/utils/types.js.map +1 -1
- package/package.json +83 -83
- package/theme/components/index.css +969 -43
- package/theme/font/iconfont.woff +0 -0
- package/theme/font/iconfont.woff2 +0 -0
- package/theme/index.css +969 -43
- package/theme/skin/default.css +969 -43
- package/types/global.d.ts +2 -2
- package/es/packages/components/touchchat/src/AiChat/Scene.vue.mjs +0 -6
- package/es/packages/components/touchchat/src/AiChat/Scene.vue.mjs.map +0 -1
- package/es/packages/components/touchchat/src/AiChat/Scene.vue2.mjs +0 -42
- package/es/packages/components/touchchat/src/AiChat/Scene.vue2.mjs.map +0 -1
- package/lib/packages/components/touchchat/src/AiChat/Scene.vue.js +0 -10
- package/lib/packages/components/touchchat/src/AiChat/Scene.vue.js.map +0 -1
- package/lib/packages/components/touchchat/src/AiChat/Scene.vue2.js +0 -46
- package/lib/packages/components/touchchat/src/AiChat/Scene.vue2.js.map +0 -1
|
@@ -0,0 +1,4816 @@
|
|
|
1
|
+
import { defineComponent, computed, ref, watch, openBlock, createElementBlock, Fragment, renderList, createBlock, shallowRef, onUnmounted, onMounted, resolveComponent, resolveDynamicComponent, mergeProps, toHandlers, withCtx, createCommentVNode } from 'vue';
|
|
2
|
+
|
|
3
|
+
var k;
|
|
4
|
+
(function(n) {
|
|
5
|
+
n.assertEqual = (s) => {
|
|
6
|
+
};
|
|
7
|
+
function e(s) {
|
|
8
|
+
}
|
|
9
|
+
n.assertIs = e;
|
|
10
|
+
function t(s) {
|
|
11
|
+
throw new Error();
|
|
12
|
+
}
|
|
13
|
+
n.assertNever = t, n.arrayToEnum = (s) => {
|
|
14
|
+
const a = {};
|
|
15
|
+
for (const i of s)
|
|
16
|
+
a[i] = i;
|
|
17
|
+
return a;
|
|
18
|
+
}, n.getValidEnumValues = (s) => {
|
|
19
|
+
const a = n.objectKeys(s).filter((o) => typeof s[s[o]] != "number"), i = {};
|
|
20
|
+
for (const o of a)
|
|
21
|
+
i[o] = s[o];
|
|
22
|
+
return n.objectValues(i);
|
|
23
|
+
}, n.objectValues = (s) => n.objectKeys(s).map(function(a) {
|
|
24
|
+
return s[a];
|
|
25
|
+
}), n.objectKeys = typeof Object.keys == "function" ? (s) => Object.keys(s) : (s) => {
|
|
26
|
+
const a = [];
|
|
27
|
+
for (const i in s)
|
|
28
|
+
Object.prototype.hasOwnProperty.call(s, i) && a.push(i);
|
|
29
|
+
return a;
|
|
30
|
+
}, n.find = (s, a) => {
|
|
31
|
+
for (const i of s)
|
|
32
|
+
if (a(i))
|
|
33
|
+
return i;
|
|
34
|
+
}, n.isInteger = typeof Number.isInteger == "function" ? (s) => Number.isInteger(s) : (s) => typeof s == "number" && Number.isFinite(s) && Math.floor(s) === s;
|
|
35
|
+
function r(s, a = " | ") {
|
|
36
|
+
return s.map((i) => typeof i == "string" ? `'${i}'` : i).join(a);
|
|
37
|
+
}
|
|
38
|
+
n.joinValues = r, n.jsonStringifyReplacer = (s, a) => typeof a == "bigint" ? a.toString() : a;
|
|
39
|
+
})(k || (k = {}));
|
|
40
|
+
var mt;
|
|
41
|
+
(function(n) {
|
|
42
|
+
n.mergeShapes = (e, t) => ({
|
|
43
|
+
...e,
|
|
44
|
+
...t
|
|
45
|
+
// second overwrites first
|
|
46
|
+
});
|
|
47
|
+
})(mt || (mt = {}));
|
|
48
|
+
const h = k.arrayToEnum([
|
|
49
|
+
"string",
|
|
50
|
+
"nan",
|
|
51
|
+
"number",
|
|
52
|
+
"integer",
|
|
53
|
+
"float",
|
|
54
|
+
"boolean",
|
|
55
|
+
"date",
|
|
56
|
+
"bigint",
|
|
57
|
+
"symbol",
|
|
58
|
+
"function",
|
|
59
|
+
"undefined",
|
|
60
|
+
"null",
|
|
61
|
+
"array",
|
|
62
|
+
"object",
|
|
63
|
+
"unknown",
|
|
64
|
+
"promise",
|
|
65
|
+
"void",
|
|
66
|
+
"never",
|
|
67
|
+
"map",
|
|
68
|
+
"set"
|
|
69
|
+
]), q = (n) => {
|
|
70
|
+
switch (typeof n) {
|
|
71
|
+
case "undefined":
|
|
72
|
+
return h.undefined;
|
|
73
|
+
case "string":
|
|
74
|
+
return h.string;
|
|
75
|
+
case "number":
|
|
76
|
+
return Number.isNaN(n) ? h.nan : h.number;
|
|
77
|
+
case "boolean":
|
|
78
|
+
return h.boolean;
|
|
79
|
+
case "function":
|
|
80
|
+
return h.function;
|
|
81
|
+
case "bigint":
|
|
82
|
+
return h.bigint;
|
|
83
|
+
case "symbol":
|
|
84
|
+
return h.symbol;
|
|
85
|
+
case "object":
|
|
86
|
+
return Array.isArray(n) ? h.array : n === null ? h.null : n.then && typeof n.then == "function" && n.catch && typeof n.catch == "function" ? h.promise : typeof Map != "undefined" && n instanceof Map ? h.map : typeof Set != "undefined" && n instanceof Set ? h.set : typeof Date != "undefined" && n instanceof Date ? h.date : h.object;
|
|
87
|
+
default:
|
|
88
|
+
return h.unknown;
|
|
89
|
+
}
|
|
90
|
+
}, d = k.arrayToEnum([
|
|
91
|
+
"invalid_type",
|
|
92
|
+
"invalid_literal",
|
|
93
|
+
"custom",
|
|
94
|
+
"invalid_union",
|
|
95
|
+
"invalid_union_discriminator",
|
|
96
|
+
"invalid_enum_value",
|
|
97
|
+
"unrecognized_keys",
|
|
98
|
+
"invalid_arguments",
|
|
99
|
+
"invalid_return_type",
|
|
100
|
+
"invalid_date",
|
|
101
|
+
"invalid_string",
|
|
102
|
+
"too_small",
|
|
103
|
+
"too_big",
|
|
104
|
+
"invalid_intersection_types",
|
|
105
|
+
"not_multiple_of",
|
|
106
|
+
"not_finite"
|
|
107
|
+
]);
|
|
108
|
+
class z extends Error {
|
|
109
|
+
get errors() {
|
|
110
|
+
return this.issues;
|
|
111
|
+
}
|
|
112
|
+
constructor(e) {
|
|
113
|
+
super(), this.issues = [], this.addIssue = (r) => {
|
|
114
|
+
this.issues = [...this.issues, r];
|
|
115
|
+
}, this.addIssues = (r = []) => {
|
|
116
|
+
this.issues = [...this.issues, ...r];
|
|
117
|
+
};
|
|
118
|
+
const t = new.target.prototype;
|
|
119
|
+
Object.setPrototypeOf ? Object.setPrototypeOf(this, t) : this.__proto__ = t, this.name = "ZodError", this.issues = e;
|
|
120
|
+
}
|
|
121
|
+
format(e) {
|
|
122
|
+
const t = e || function(a) {
|
|
123
|
+
return a.message;
|
|
124
|
+
}, r = { _errors: [] }, s = (a) => {
|
|
125
|
+
for (const i of a.issues)
|
|
126
|
+
if (i.code === "invalid_union")
|
|
127
|
+
i.unionErrors.map(s);
|
|
128
|
+
else if (i.code === "invalid_return_type")
|
|
129
|
+
s(i.returnTypeError);
|
|
130
|
+
else if (i.code === "invalid_arguments")
|
|
131
|
+
s(i.argumentsError);
|
|
132
|
+
else if (i.path.length === 0)
|
|
133
|
+
r._errors.push(t(i));
|
|
134
|
+
else {
|
|
135
|
+
let o = r, c = 0;
|
|
136
|
+
for (; c < i.path.length; ) {
|
|
137
|
+
const u = i.path[c];
|
|
138
|
+
c === i.path.length - 1 ? (o[u] = o[u] || { _errors: [] }, o[u]._errors.push(t(i))) : o[u] = o[u] || { _errors: [] }, o = o[u], c++;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
return s(this), r;
|
|
143
|
+
}
|
|
144
|
+
static assert(e) {
|
|
145
|
+
if (!(e instanceof z))
|
|
146
|
+
throw new Error(`Not a ZodError: ${e}`);
|
|
147
|
+
}
|
|
148
|
+
toString() {
|
|
149
|
+
return this.message;
|
|
150
|
+
}
|
|
151
|
+
get message() {
|
|
152
|
+
return JSON.stringify(this.issues, k.jsonStringifyReplacer, 2);
|
|
153
|
+
}
|
|
154
|
+
get isEmpty() {
|
|
155
|
+
return this.issues.length === 0;
|
|
156
|
+
}
|
|
157
|
+
flatten(e = (t) => t.message) {
|
|
158
|
+
const t = {}, r = [];
|
|
159
|
+
for (const s of this.issues)
|
|
160
|
+
if (s.path.length > 0) {
|
|
161
|
+
const a = s.path[0];
|
|
162
|
+
t[a] = t[a] || [], t[a].push(e(s));
|
|
163
|
+
} else
|
|
164
|
+
r.push(e(s));
|
|
165
|
+
return { formErrors: r, fieldErrors: t };
|
|
166
|
+
}
|
|
167
|
+
get formErrors() {
|
|
168
|
+
return this.flatten();
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
z.create = (n) => new z(n);
|
|
172
|
+
const an = (n, e) => {
|
|
173
|
+
let t;
|
|
174
|
+
switch (n.code) {
|
|
175
|
+
case d.invalid_type:
|
|
176
|
+
n.received === h.undefined ? t = "Required" : t = `Expected ${n.expected}, received ${n.received}`;
|
|
177
|
+
break;
|
|
178
|
+
case d.invalid_literal:
|
|
179
|
+
t = `Invalid literal value, expected ${JSON.stringify(n.expected, k.jsonStringifyReplacer)}`;
|
|
180
|
+
break;
|
|
181
|
+
case d.unrecognized_keys:
|
|
182
|
+
t = `Unrecognized key(s) in object: ${k.joinValues(n.keys, ", ")}`;
|
|
183
|
+
break;
|
|
184
|
+
case d.invalid_union:
|
|
185
|
+
t = "Invalid input";
|
|
186
|
+
break;
|
|
187
|
+
case d.invalid_union_discriminator:
|
|
188
|
+
t = `Invalid discriminator value. Expected ${k.joinValues(n.options)}`;
|
|
189
|
+
break;
|
|
190
|
+
case d.invalid_enum_value:
|
|
191
|
+
t = `Invalid enum value. Expected ${k.joinValues(n.options)}, received '${n.received}'`;
|
|
192
|
+
break;
|
|
193
|
+
case d.invalid_arguments:
|
|
194
|
+
t = "Invalid function arguments";
|
|
195
|
+
break;
|
|
196
|
+
case d.invalid_return_type:
|
|
197
|
+
t = "Invalid function return type";
|
|
198
|
+
break;
|
|
199
|
+
case d.invalid_date:
|
|
200
|
+
t = "Invalid date";
|
|
201
|
+
break;
|
|
202
|
+
case d.invalid_string:
|
|
203
|
+
typeof n.validation == "object" ? "includes" in n.validation ? (t = `Invalid input: must include "${n.validation.includes}"`, typeof n.validation.position == "number" && (t = `${t} at one or more positions greater than or equal to ${n.validation.position}`)) : "startsWith" in n.validation ? t = `Invalid input: must start with "${n.validation.startsWith}"` : "endsWith" in n.validation ? t = `Invalid input: must end with "${n.validation.endsWith}"` : k.assertNever(n.validation) : n.validation !== "regex" ? t = `Invalid ${n.validation}` : t = "Invalid";
|
|
204
|
+
break;
|
|
205
|
+
case d.too_small:
|
|
206
|
+
n.type === "array" ? t = `Array must contain ${n.exact ? "exactly" : n.inclusive ? "at least" : "more than"} ${n.minimum} element(s)` : n.type === "string" ? t = `String must contain ${n.exact ? "exactly" : n.inclusive ? "at least" : "over"} ${n.minimum} character(s)` : n.type === "number" ? t = `Number must be ${n.exact ? "exactly equal to " : n.inclusive ? "greater than or equal to " : "greater than "}${n.minimum}` : n.type === "bigint" ? t = `Number must be ${n.exact ? "exactly equal to " : n.inclusive ? "greater than or equal to " : "greater than "}${n.minimum}` : n.type === "date" ? t = `Date must be ${n.exact ? "exactly equal to " : n.inclusive ? "greater than or equal to " : "greater than "}${new Date(Number(n.minimum))}` : t = "Invalid input";
|
|
207
|
+
break;
|
|
208
|
+
case d.too_big:
|
|
209
|
+
n.type === "array" ? t = `Array must contain ${n.exact ? "exactly" : n.inclusive ? "at most" : "less than"} ${n.maximum} element(s)` : n.type === "string" ? t = `String must contain ${n.exact ? "exactly" : n.inclusive ? "at most" : "under"} ${n.maximum} character(s)` : n.type === "number" ? t = `Number must be ${n.exact ? "exactly" : n.inclusive ? "less than or equal to" : "less than"} ${n.maximum}` : n.type === "bigint" ? t = `BigInt must be ${n.exact ? "exactly" : n.inclusive ? "less than or equal to" : "less than"} ${n.maximum}` : n.type === "date" ? t = `Date must be ${n.exact ? "exactly" : n.inclusive ? "smaller than or equal to" : "smaller than"} ${new Date(Number(n.maximum))}` : t = "Invalid input";
|
|
210
|
+
break;
|
|
211
|
+
case d.custom:
|
|
212
|
+
t = "Invalid input";
|
|
213
|
+
break;
|
|
214
|
+
case d.invalid_intersection_types:
|
|
215
|
+
t = "Intersection results could not be merged";
|
|
216
|
+
break;
|
|
217
|
+
case d.not_multiple_of:
|
|
218
|
+
t = `Number must be a multiple of ${n.multipleOf}`;
|
|
219
|
+
break;
|
|
220
|
+
case d.not_finite:
|
|
221
|
+
t = "Number must be finite";
|
|
222
|
+
break;
|
|
223
|
+
default:
|
|
224
|
+
t = e.defaultError, k.assertNever(n);
|
|
225
|
+
}
|
|
226
|
+
return { message: t };
|
|
227
|
+
}, Fe = an;
|
|
228
|
+
let on = Fe;
|
|
229
|
+
function cn() {
|
|
230
|
+
return on;
|
|
231
|
+
}
|
|
232
|
+
const un = (n) => {
|
|
233
|
+
const { data: e, path: t, errorMaps: r, issueData: s } = n, a = [...t, ...s.path || []], i = {
|
|
234
|
+
...s,
|
|
235
|
+
path: a
|
|
236
|
+
};
|
|
237
|
+
if (s.message !== void 0)
|
|
238
|
+
return {
|
|
239
|
+
...s,
|
|
240
|
+
path: a,
|
|
241
|
+
message: s.message
|
|
242
|
+
};
|
|
243
|
+
let o = "";
|
|
244
|
+
const c = r.filter((u) => !!u).slice().reverse();
|
|
245
|
+
for (const u of c)
|
|
246
|
+
o = u(i, { data: e, defaultError: o }).message;
|
|
247
|
+
return {
|
|
248
|
+
...s,
|
|
249
|
+
path: a,
|
|
250
|
+
message: o
|
|
251
|
+
};
|
|
252
|
+
};
|
|
253
|
+
function f(n, e) {
|
|
254
|
+
const t = cn(), r = un({
|
|
255
|
+
issueData: e,
|
|
256
|
+
data: n.data,
|
|
257
|
+
path: n.path,
|
|
258
|
+
errorMaps: [
|
|
259
|
+
n.common.contextualErrorMap,
|
|
260
|
+
// contextual error map is first priority
|
|
261
|
+
n.schemaErrorMap,
|
|
262
|
+
// then schema-bound map if available
|
|
263
|
+
t,
|
|
264
|
+
// then global override map
|
|
265
|
+
t === Fe ? void 0 : Fe
|
|
266
|
+
// then global default map
|
|
267
|
+
].filter((s) => !!s)
|
|
268
|
+
});
|
|
269
|
+
n.common.issues.push(r);
|
|
270
|
+
}
|
|
271
|
+
class P {
|
|
272
|
+
constructor() {
|
|
273
|
+
this.value = "valid";
|
|
274
|
+
}
|
|
275
|
+
dirty() {
|
|
276
|
+
this.value === "valid" && (this.value = "dirty");
|
|
277
|
+
}
|
|
278
|
+
abort() {
|
|
279
|
+
this.value !== "aborted" && (this.value = "aborted");
|
|
280
|
+
}
|
|
281
|
+
static mergeArray(e, t) {
|
|
282
|
+
const r = [];
|
|
283
|
+
for (const s of t) {
|
|
284
|
+
if (s.status === "aborted")
|
|
285
|
+
return g;
|
|
286
|
+
s.status === "dirty" && e.dirty(), r.push(s.value);
|
|
287
|
+
}
|
|
288
|
+
return { status: e.value, value: r };
|
|
289
|
+
}
|
|
290
|
+
static async mergeObjectAsync(e, t) {
|
|
291
|
+
const r = [];
|
|
292
|
+
for (const s of t) {
|
|
293
|
+
const a = await s.key, i = await s.value;
|
|
294
|
+
r.push({
|
|
295
|
+
key: a,
|
|
296
|
+
value: i
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
return P.mergeObjectSync(e, r);
|
|
300
|
+
}
|
|
301
|
+
static mergeObjectSync(e, t) {
|
|
302
|
+
const r = {};
|
|
303
|
+
for (const s of t) {
|
|
304
|
+
const { key: a, value: i } = s;
|
|
305
|
+
if (a.status === "aborted" || i.status === "aborted")
|
|
306
|
+
return g;
|
|
307
|
+
a.status === "dirty" && e.dirty(), i.status === "dirty" && e.dirty(), a.value !== "__proto__" && (typeof i.value != "undefined" || s.alwaysSet) && (r[a.value] = i.value);
|
|
308
|
+
}
|
|
309
|
+
return { status: e.value, value: r };
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
const g = Object.freeze({
|
|
313
|
+
status: "aborted"
|
|
314
|
+
}), fe = (n) => ({ status: "dirty", value: n }), E = (n) => ({ status: "valid", value: n }), yt = (n) => n.status === "aborted", gt = (n) => n.status === "dirty", re = (n) => n.status === "valid", ke = (n) => typeof Promise != "undefined" && n instanceof Promise;
|
|
315
|
+
var p;
|
|
316
|
+
(function(n) {
|
|
317
|
+
n.errToObj = (e) => typeof e == "string" ? { message: e } : e || {}, n.toString = (e) => typeof e == "string" ? e : e == null ? void 0 : e.message;
|
|
318
|
+
})(p || (p = {}));
|
|
319
|
+
class V {
|
|
320
|
+
constructor(e, t, r, s) {
|
|
321
|
+
this._cachedPath = [], this.parent = e, this.data = t, this._path = r, this._key = s;
|
|
322
|
+
}
|
|
323
|
+
get path() {
|
|
324
|
+
return this._cachedPath.length || (Array.isArray(this._key) ? this._cachedPath.push(...this._path, ...this._key) : this._cachedPath.push(...this._path, this._key)), this._cachedPath;
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
const vt = (n, e) => {
|
|
328
|
+
if (re(e))
|
|
329
|
+
return { success: !0, data: e.value };
|
|
330
|
+
if (!n.common.issues.length)
|
|
331
|
+
throw new Error("Validation failed but no issues detected.");
|
|
332
|
+
return {
|
|
333
|
+
success: !1,
|
|
334
|
+
get error() {
|
|
335
|
+
if (this._error)
|
|
336
|
+
return this._error;
|
|
337
|
+
const t = new z(n.common.issues);
|
|
338
|
+
return this._error = t, this._error;
|
|
339
|
+
}
|
|
340
|
+
};
|
|
341
|
+
};
|
|
342
|
+
function _(n) {
|
|
343
|
+
if (!n)
|
|
344
|
+
return {};
|
|
345
|
+
const { errorMap: e, invalid_type_error: t, required_error: r, description: s } = n;
|
|
346
|
+
if (e && (t || r))
|
|
347
|
+
throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);
|
|
348
|
+
return e ? { errorMap: e, description: s } : { errorMap: (i, o) => {
|
|
349
|
+
var u, y;
|
|
350
|
+
const { message: c } = n;
|
|
351
|
+
return i.code === "invalid_enum_value" ? { message: c != null ? c : o.defaultError } : typeof o.data == "undefined" ? { message: (u = c != null ? c : r) != null ? u : o.defaultError } : i.code !== "invalid_type" ? { message: o.defaultError } : { message: (y = c != null ? c : t) != null ? y : o.defaultError };
|
|
352
|
+
}, description: s };
|
|
353
|
+
}
|
|
354
|
+
class b {
|
|
355
|
+
get description() {
|
|
356
|
+
return this._def.description;
|
|
357
|
+
}
|
|
358
|
+
_getType(e) {
|
|
359
|
+
return q(e.data);
|
|
360
|
+
}
|
|
361
|
+
_getOrReturnCtx(e, t) {
|
|
362
|
+
return t || {
|
|
363
|
+
common: e.parent.common,
|
|
364
|
+
data: e.data,
|
|
365
|
+
parsedType: q(e.data),
|
|
366
|
+
schemaErrorMap: this._def.errorMap,
|
|
367
|
+
path: e.path,
|
|
368
|
+
parent: e.parent
|
|
369
|
+
};
|
|
370
|
+
}
|
|
371
|
+
_processInputParams(e) {
|
|
372
|
+
return {
|
|
373
|
+
status: new P(),
|
|
374
|
+
ctx: {
|
|
375
|
+
common: e.parent.common,
|
|
376
|
+
data: e.data,
|
|
377
|
+
parsedType: q(e.data),
|
|
378
|
+
schemaErrorMap: this._def.errorMap,
|
|
379
|
+
path: e.path,
|
|
380
|
+
parent: e.parent
|
|
381
|
+
}
|
|
382
|
+
};
|
|
383
|
+
}
|
|
384
|
+
_parseSync(e) {
|
|
385
|
+
const t = this._parse(e);
|
|
386
|
+
if (ke(t))
|
|
387
|
+
throw new Error("Synchronous parse encountered promise.");
|
|
388
|
+
return t;
|
|
389
|
+
}
|
|
390
|
+
_parseAsync(e) {
|
|
391
|
+
const t = this._parse(e);
|
|
392
|
+
return Promise.resolve(t);
|
|
393
|
+
}
|
|
394
|
+
parse(e, t) {
|
|
395
|
+
const r = this.safeParse(e, t);
|
|
396
|
+
if (r.success)
|
|
397
|
+
return r.data;
|
|
398
|
+
throw r.error;
|
|
399
|
+
}
|
|
400
|
+
safeParse(e, t) {
|
|
401
|
+
var a;
|
|
402
|
+
const r = {
|
|
403
|
+
common: {
|
|
404
|
+
issues: [],
|
|
405
|
+
async: (a = t == null ? void 0 : t.async) != null ? a : !1,
|
|
406
|
+
contextualErrorMap: t == null ? void 0 : t.errorMap
|
|
407
|
+
},
|
|
408
|
+
path: (t == null ? void 0 : t.path) || [],
|
|
409
|
+
schemaErrorMap: this._def.errorMap,
|
|
410
|
+
parent: null,
|
|
411
|
+
data: e,
|
|
412
|
+
parsedType: q(e)
|
|
413
|
+
}, s = this._parseSync({ data: e, path: r.path, parent: r });
|
|
414
|
+
return vt(r, s);
|
|
415
|
+
}
|
|
416
|
+
"~validate"(e) {
|
|
417
|
+
var r, s;
|
|
418
|
+
const t = {
|
|
419
|
+
common: {
|
|
420
|
+
issues: [],
|
|
421
|
+
async: !!this["~standard"].async
|
|
422
|
+
},
|
|
423
|
+
path: [],
|
|
424
|
+
schemaErrorMap: this._def.errorMap,
|
|
425
|
+
parent: null,
|
|
426
|
+
data: e,
|
|
427
|
+
parsedType: q(e)
|
|
428
|
+
};
|
|
429
|
+
if (!this["~standard"].async)
|
|
430
|
+
try {
|
|
431
|
+
const a = this._parseSync({ data: e, path: [], parent: t });
|
|
432
|
+
return re(a) ? {
|
|
433
|
+
value: a.value
|
|
434
|
+
} : {
|
|
435
|
+
issues: t.common.issues
|
|
436
|
+
};
|
|
437
|
+
} catch (a) {
|
|
438
|
+
(s = (r = a == null ? void 0 : a.message) == null ? void 0 : r.toLowerCase()) != null && s.includes("encountered") && (this["~standard"].async = !0), t.common = {
|
|
439
|
+
issues: [],
|
|
440
|
+
async: !0
|
|
441
|
+
};
|
|
442
|
+
}
|
|
443
|
+
return this._parseAsync({ data: e, path: [], parent: t }).then((a) => re(a) ? {
|
|
444
|
+
value: a.value
|
|
445
|
+
} : {
|
|
446
|
+
issues: t.common.issues
|
|
447
|
+
});
|
|
448
|
+
}
|
|
449
|
+
async parseAsync(e, t) {
|
|
450
|
+
const r = await this.safeParseAsync(e, t);
|
|
451
|
+
if (r.success)
|
|
452
|
+
return r.data;
|
|
453
|
+
throw r.error;
|
|
454
|
+
}
|
|
455
|
+
async safeParseAsync(e, t) {
|
|
456
|
+
const r = {
|
|
457
|
+
common: {
|
|
458
|
+
issues: [],
|
|
459
|
+
contextualErrorMap: t == null ? void 0 : t.errorMap,
|
|
460
|
+
async: !0
|
|
461
|
+
},
|
|
462
|
+
path: (t == null ? void 0 : t.path) || [],
|
|
463
|
+
schemaErrorMap: this._def.errorMap,
|
|
464
|
+
parent: null,
|
|
465
|
+
data: e,
|
|
466
|
+
parsedType: q(e)
|
|
467
|
+
}, s = this._parse({ data: e, path: r.path, parent: r }), a = await (ke(s) ? s : Promise.resolve(s));
|
|
468
|
+
return vt(r, a);
|
|
469
|
+
}
|
|
470
|
+
refine(e, t) {
|
|
471
|
+
const r = (s) => typeof t == "string" || typeof t == "undefined" ? { message: t } : typeof t == "function" ? t(s) : t;
|
|
472
|
+
return this._refinement((s, a) => {
|
|
473
|
+
const i = e(s), o = () => a.addIssue({
|
|
474
|
+
code: d.custom,
|
|
475
|
+
...r(s)
|
|
476
|
+
});
|
|
477
|
+
return typeof Promise != "undefined" && i instanceof Promise ? i.then((c) => c ? !0 : (o(), !1)) : i ? !0 : (o(), !1);
|
|
478
|
+
});
|
|
479
|
+
}
|
|
480
|
+
refinement(e, t) {
|
|
481
|
+
return this._refinement((r, s) => e(r) ? !0 : (s.addIssue(typeof t == "function" ? t(r, s) : t), !1));
|
|
482
|
+
}
|
|
483
|
+
_refinement(e) {
|
|
484
|
+
return new K({
|
|
485
|
+
schema: this,
|
|
486
|
+
typeName: l.ZodEffects,
|
|
487
|
+
effect: { type: "refinement", refinement: e }
|
|
488
|
+
});
|
|
489
|
+
}
|
|
490
|
+
superRefine(e) {
|
|
491
|
+
return this._refinement(e);
|
|
492
|
+
}
|
|
493
|
+
constructor(e) {
|
|
494
|
+
this.spa = this.safeParseAsync, this._def = e, this.parse = this.parse.bind(this), this.safeParse = this.safeParse.bind(this), this.parseAsync = this.parseAsync.bind(this), this.safeParseAsync = this.safeParseAsync.bind(this), this.spa = this.spa.bind(this), this.refine = this.refine.bind(this), this.refinement = this.refinement.bind(this), this.superRefine = this.superRefine.bind(this), this.optional = this.optional.bind(this), this.nullable = this.nullable.bind(this), this.nullish = this.nullish.bind(this), this.array = this.array.bind(this), this.promise = this.promise.bind(this), this.or = this.or.bind(this), this.and = this.and.bind(this), this.transform = this.transform.bind(this), this.brand = this.brand.bind(this), this.default = this.default.bind(this), this.catch = this.catch.bind(this), this.describe = this.describe.bind(this), this.pipe = this.pipe.bind(this), this.readonly = this.readonly.bind(this), this.isNullable = this.isNullable.bind(this), this.isOptional = this.isOptional.bind(this), this["~standard"] = {
|
|
495
|
+
version: 1,
|
|
496
|
+
vendor: "zod",
|
|
497
|
+
validate: (t) => this["~validate"](t)
|
|
498
|
+
};
|
|
499
|
+
}
|
|
500
|
+
optional() {
|
|
501
|
+
return H.create(this, this._def);
|
|
502
|
+
}
|
|
503
|
+
nullable() {
|
|
504
|
+
return ce.create(this, this._def);
|
|
505
|
+
}
|
|
506
|
+
nullish() {
|
|
507
|
+
return this.nullable().optional();
|
|
508
|
+
}
|
|
509
|
+
array() {
|
|
510
|
+
return L.create(this);
|
|
511
|
+
}
|
|
512
|
+
promise() {
|
|
513
|
+
return Ae.create(this, this._def);
|
|
514
|
+
}
|
|
515
|
+
or(e) {
|
|
516
|
+
return xe.create([this, e], this._def);
|
|
517
|
+
}
|
|
518
|
+
and(e) {
|
|
519
|
+
return we.create(this, e, this._def);
|
|
520
|
+
}
|
|
521
|
+
transform(e) {
|
|
522
|
+
return new K({
|
|
523
|
+
..._(this._def),
|
|
524
|
+
schema: this,
|
|
525
|
+
typeName: l.ZodEffects,
|
|
526
|
+
effect: { type: "transform", transform: e }
|
|
527
|
+
});
|
|
528
|
+
}
|
|
529
|
+
default(e) {
|
|
530
|
+
const t = typeof e == "function" ? e : () => e;
|
|
531
|
+
return new nt({
|
|
532
|
+
..._(this._def),
|
|
533
|
+
innerType: this,
|
|
534
|
+
defaultValue: t,
|
|
535
|
+
typeName: l.ZodDefault
|
|
536
|
+
});
|
|
537
|
+
}
|
|
538
|
+
brand() {
|
|
539
|
+
return new jn({
|
|
540
|
+
typeName: l.ZodBranded,
|
|
541
|
+
type: this,
|
|
542
|
+
..._(this._def)
|
|
543
|
+
});
|
|
544
|
+
}
|
|
545
|
+
catch(e) {
|
|
546
|
+
const t = typeof e == "function" ? e : () => e;
|
|
547
|
+
return new rt({
|
|
548
|
+
..._(this._def),
|
|
549
|
+
innerType: this,
|
|
550
|
+
catchValue: t,
|
|
551
|
+
typeName: l.ZodCatch
|
|
552
|
+
});
|
|
553
|
+
}
|
|
554
|
+
describe(e) {
|
|
555
|
+
const t = this.constructor;
|
|
556
|
+
return new t({
|
|
557
|
+
...this._def,
|
|
558
|
+
description: e
|
|
559
|
+
});
|
|
560
|
+
}
|
|
561
|
+
pipe(e) {
|
|
562
|
+
return ot.create(this, e);
|
|
563
|
+
}
|
|
564
|
+
readonly() {
|
|
565
|
+
return at.create(this);
|
|
566
|
+
}
|
|
567
|
+
isOptional() {
|
|
568
|
+
return this.safeParse(void 0).success;
|
|
569
|
+
}
|
|
570
|
+
isNullable() {
|
|
571
|
+
return this.safeParse(null).success;
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
const dn = /^c[^\s-]{8,}$/i, ln = /^[0-9a-z]+$/, fn = /^[0-9A-HJKMNP-TV-Z]{26}$/i, hn = /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i, pn = /^[a-z0-9_-]{21}$/i, mn = /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/, yn = /^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/, gn = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i, vn = "^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";
|
|
575
|
+
let Ee;
|
|
576
|
+
const _n = /^(?:(?: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])$/, bn = /^(?:(?: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])\/(3[0-2]|[12]?[0-9])$/, kn = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/, xn = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/, wn = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/, Sn = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/, jt = "((\\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])))", An = new RegExp(`^${jt}$`);
|
|
577
|
+
function It(n) {
|
|
578
|
+
let e = "[0-5]\\d";
|
|
579
|
+
n.precision ? e = `${e}\\.\\d{${n.precision}}` : n.precision == null && (e = `${e}(\\.\\d+)?`);
|
|
580
|
+
const t = n.precision ? "+" : "?";
|
|
581
|
+
return `([01]\\d|2[0-3]):[0-5]\\d(:${e})${t}`;
|
|
582
|
+
}
|
|
583
|
+
function Tn(n) {
|
|
584
|
+
return new RegExp(`^${It(n)}$`);
|
|
585
|
+
}
|
|
586
|
+
function Cn(n) {
|
|
587
|
+
let e = `${jt}T${It(n)}`;
|
|
588
|
+
const t = [];
|
|
589
|
+
return t.push(n.local ? "Z?" : "Z"), n.offset && t.push("([+-]\\d{2}:?\\d{2})"), e = `${e}(${t.join("|")})`, new RegExp(`^${e}$`);
|
|
590
|
+
}
|
|
591
|
+
function On(n, e) {
|
|
592
|
+
return !!((e === "v4" || !e) && _n.test(n) || (e === "v6" || !e) && kn.test(n));
|
|
593
|
+
}
|
|
594
|
+
function Nn(n, e) {
|
|
595
|
+
if (!mn.test(n))
|
|
596
|
+
return !1;
|
|
597
|
+
try {
|
|
598
|
+
const [t] = n.split(".");
|
|
599
|
+
if (!t)
|
|
600
|
+
return !1;
|
|
601
|
+
const r = t.replace(/-/g, "+").replace(/_/g, "/").padEnd(t.length + (4 - t.length % 4) % 4, "="), s = JSON.parse(atob(r));
|
|
602
|
+
return !(typeof s != "object" || s === null || "typ" in s && (s == null ? void 0 : s.typ) !== "JWT" || !s.alg || e && s.alg !== e);
|
|
603
|
+
} catch (t) {
|
|
604
|
+
return !1;
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
function Zn(n, e) {
|
|
608
|
+
return !!((e === "v4" || !e) && bn.test(n) || (e === "v6" || !e) && xn.test(n));
|
|
609
|
+
}
|
|
610
|
+
class F extends b {
|
|
611
|
+
_parse(e) {
|
|
612
|
+
if (this._def.coerce && (e.data = String(e.data)), this._getType(e) !== h.string) {
|
|
613
|
+
const a = this._getOrReturnCtx(e);
|
|
614
|
+
return f(a, {
|
|
615
|
+
code: d.invalid_type,
|
|
616
|
+
expected: h.string,
|
|
617
|
+
received: a.parsedType
|
|
618
|
+
}), g;
|
|
619
|
+
}
|
|
620
|
+
const r = new P();
|
|
621
|
+
let s;
|
|
622
|
+
for (const a of this._def.checks)
|
|
623
|
+
if (a.kind === "min")
|
|
624
|
+
e.data.length < a.value && (s = this._getOrReturnCtx(e, s), f(s, {
|
|
625
|
+
code: d.too_small,
|
|
626
|
+
minimum: a.value,
|
|
627
|
+
type: "string",
|
|
628
|
+
inclusive: !0,
|
|
629
|
+
exact: !1,
|
|
630
|
+
message: a.message
|
|
631
|
+
}), r.dirty());
|
|
632
|
+
else if (a.kind === "max")
|
|
633
|
+
e.data.length > a.value && (s = this._getOrReturnCtx(e, s), f(s, {
|
|
634
|
+
code: d.too_big,
|
|
635
|
+
maximum: a.value,
|
|
636
|
+
type: "string",
|
|
637
|
+
inclusive: !0,
|
|
638
|
+
exact: !1,
|
|
639
|
+
message: a.message
|
|
640
|
+
}), r.dirty());
|
|
641
|
+
else if (a.kind === "length") {
|
|
642
|
+
const i = e.data.length > a.value, o = e.data.length < a.value;
|
|
643
|
+
(i || o) && (s = this._getOrReturnCtx(e, s), i ? f(s, {
|
|
644
|
+
code: d.too_big,
|
|
645
|
+
maximum: a.value,
|
|
646
|
+
type: "string",
|
|
647
|
+
inclusive: !0,
|
|
648
|
+
exact: !0,
|
|
649
|
+
message: a.message
|
|
650
|
+
}) : o && f(s, {
|
|
651
|
+
code: d.too_small,
|
|
652
|
+
minimum: a.value,
|
|
653
|
+
type: "string",
|
|
654
|
+
inclusive: !0,
|
|
655
|
+
exact: !0,
|
|
656
|
+
message: a.message
|
|
657
|
+
}), r.dirty());
|
|
658
|
+
} else if (a.kind === "email")
|
|
659
|
+
gn.test(e.data) || (s = this._getOrReturnCtx(e, s), f(s, {
|
|
660
|
+
validation: "email",
|
|
661
|
+
code: d.invalid_string,
|
|
662
|
+
message: a.message
|
|
663
|
+
}), r.dirty());
|
|
664
|
+
else if (a.kind === "emoji")
|
|
665
|
+
Ee || (Ee = new RegExp(vn, "u")), Ee.test(e.data) || (s = this._getOrReturnCtx(e, s), f(s, {
|
|
666
|
+
validation: "emoji",
|
|
667
|
+
code: d.invalid_string,
|
|
668
|
+
message: a.message
|
|
669
|
+
}), r.dirty());
|
|
670
|
+
else if (a.kind === "uuid")
|
|
671
|
+
hn.test(e.data) || (s = this._getOrReturnCtx(e, s), f(s, {
|
|
672
|
+
validation: "uuid",
|
|
673
|
+
code: d.invalid_string,
|
|
674
|
+
message: a.message
|
|
675
|
+
}), r.dirty());
|
|
676
|
+
else if (a.kind === "nanoid")
|
|
677
|
+
pn.test(e.data) || (s = this._getOrReturnCtx(e, s), f(s, {
|
|
678
|
+
validation: "nanoid",
|
|
679
|
+
code: d.invalid_string,
|
|
680
|
+
message: a.message
|
|
681
|
+
}), r.dirty());
|
|
682
|
+
else if (a.kind === "cuid")
|
|
683
|
+
dn.test(e.data) || (s = this._getOrReturnCtx(e, s), f(s, {
|
|
684
|
+
validation: "cuid",
|
|
685
|
+
code: d.invalid_string,
|
|
686
|
+
message: a.message
|
|
687
|
+
}), r.dirty());
|
|
688
|
+
else if (a.kind === "cuid2")
|
|
689
|
+
ln.test(e.data) || (s = this._getOrReturnCtx(e, s), f(s, {
|
|
690
|
+
validation: "cuid2",
|
|
691
|
+
code: d.invalid_string,
|
|
692
|
+
message: a.message
|
|
693
|
+
}), r.dirty());
|
|
694
|
+
else if (a.kind === "ulid")
|
|
695
|
+
fn.test(e.data) || (s = this._getOrReturnCtx(e, s), f(s, {
|
|
696
|
+
validation: "ulid",
|
|
697
|
+
code: d.invalid_string,
|
|
698
|
+
message: a.message
|
|
699
|
+
}), r.dirty());
|
|
700
|
+
else if (a.kind === "url")
|
|
701
|
+
try {
|
|
702
|
+
new URL(e.data);
|
|
703
|
+
} catch (i) {
|
|
704
|
+
s = this._getOrReturnCtx(e, s), f(s, {
|
|
705
|
+
validation: "url",
|
|
706
|
+
code: d.invalid_string,
|
|
707
|
+
message: a.message
|
|
708
|
+
}), r.dirty();
|
|
709
|
+
}
|
|
710
|
+
else
|
|
711
|
+
a.kind === "regex" ? (a.regex.lastIndex = 0, a.regex.test(e.data) || (s = this._getOrReturnCtx(e, s), f(s, {
|
|
712
|
+
validation: "regex",
|
|
713
|
+
code: d.invalid_string,
|
|
714
|
+
message: a.message
|
|
715
|
+
}), r.dirty())) : a.kind === "trim" ? e.data = e.data.trim() : a.kind === "includes" ? e.data.includes(a.value, a.position) || (s = this._getOrReturnCtx(e, s), f(s, {
|
|
716
|
+
code: d.invalid_string,
|
|
717
|
+
validation: { includes: a.value, position: a.position },
|
|
718
|
+
message: a.message
|
|
719
|
+
}), r.dirty()) : a.kind === "toLowerCase" ? e.data = e.data.toLowerCase() : a.kind === "toUpperCase" ? e.data = e.data.toUpperCase() : a.kind === "startsWith" ? e.data.startsWith(a.value) || (s = this._getOrReturnCtx(e, s), f(s, {
|
|
720
|
+
code: d.invalid_string,
|
|
721
|
+
validation: { startsWith: a.value },
|
|
722
|
+
message: a.message
|
|
723
|
+
}), r.dirty()) : a.kind === "endsWith" ? e.data.endsWith(a.value) || (s = this._getOrReturnCtx(e, s), f(s, {
|
|
724
|
+
code: d.invalid_string,
|
|
725
|
+
validation: { endsWith: a.value },
|
|
726
|
+
message: a.message
|
|
727
|
+
}), r.dirty()) : a.kind === "datetime" ? Cn(a).test(e.data) || (s = this._getOrReturnCtx(e, s), f(s, {
|
|
728
|
+
code: d.invalid_string,
|
|
729
|
+
validation: "datetime",
|
|
730
|
+
message: a.message
|
|
731
|
+
}), r.dirty()) : a.kind === "date" ? An.test(e.data) || (s = this._getOrReturnCtx(e, s), f(s, {
|
|
732
|
+
code: d.invalid_string,
|
|
733
|
+
validation: "date",
|
|
734
|
+
message: a.message
|
|
735
|
+
}), r.dirty()) : a.kind === "time" ? Tn(a).test(e.data) || (s = this._getOrReturnCtx(e, s), f(s, {
|
|
736
|
+
code: d.invalid_string,
|
|
737
|
+
validation: "time",
|
|
738
|
+
message: a.message
|
|
739
|
+
}), r.dirty()) : a.kind === "duration" ? yn.test(e.data) || (s = this._getOrReturnCtx(e, s), f(s, {
|
|
740
|
+
validation: "duration",
|
|
741
|
+
code: d.invalid_string,
|
|
742
|
+
message: a.message
|
|
743
|
+
}), r.dirty()) : a.kind === "ip" ? On(e.data, a.version) || (s = this._getOrReturnCtx(e, s), f(s, {
|
|
744
|
+
validation: "ip",
|
|
745
|
+
code: d.invalid_string,
|
|
746
|
+
message: a.message
|
|
747
|
+
}), r.dirty()) : a.kind === "jwt" ? Nn(e.data, a.alg) || (s = this._getOrReturnCtx(e, s), f(s, {
|
|
748
|
+
validation: "jwt",
|
|
749
|
+
code: d.invalid_string,
|
|
750
|
+
message: a.message
|
|
751
|
+
}), r.dirty()) : a.kind === "cidr" ? Zn(e.data, a.version) || (s = this._getOrReturnCtx(e, s), f(s, {
|
|
752
|
+
validation: "cidr",
|
|
753
|
+
code: d.invalid_string,
|
|
754
|
+
message: a.message
|
|
755
|
+
}), r.dirty()) : a.kind === "base64" ? wn.test(e.data) || (s = this._getOrReturnCtx(e, s), f(s, {
|
|
756
|
+
validation: "base64",
|
|
757
|
+
code: d.invalid_string,
|
|
758
|
+
message: a.message
|
|
759
|
+
}), r.dirty()) : a.kind === "base64url" ? Sn.test(e.data) || (s = this._getOrReturnCtx(e, s), f(s, {
|
|
760
|
+
validation: "base64url",
|
|
761
|
+
code: d.invalid_string,
|
|
762
|
+
message: a.message
|
|
763
|
+
}), r.dirty()) : k.assertNever(a);
|
|
764
|
+
return { status: r.value, value: e.data };
|
|
765
|
+
}
|
|
766
|
+
_regex(e, t, r) {
|
|
767
|
+
return this.refinement((s) => e.test(s), {
|
|
768
|
+
validation: t,
|
|
769
|
+
code: d.invalid_string,
|
|
770
|
+
...p.errToObj(r)
|
|
771
|
+
});
|
|
772
|
+
}
|
|
773
|
+
_addCheck(e) {
|
|
774
|
+
return new F({
|
|
775
|
+
...this._def,
|
|
776
|
+
checks: [...this._def.checks, e]
|
|
777
|
+
});
|
|
778
|
+
}
|
|
779
|
+
email(e) {
|
|
780
|
+
return this._addCheck({ kind: "email", ...p.errToObj(e) });
|
|
781
|
+
}
|
|
782
|
+
url(e) {
|
|
783
|
+
return this._addCheck({ kind: "url", ...p.errToObj(e) });
|
|
784
|
+
}
|
|
785
|
+
emoji(e) {
|
|
786
|
+
return this._addCheck({ kind: "emoji", ...p.errToObj(e) });
|
|
787
|
+
}
|
|
788
|
+
uuid(e) {
|
|
789
|
+
return this._addCheck({ kind: "uuid", ...p.errToObj(e) });
|
|
790
|
+
}
|
|
791
|
+
nanoid(e) {
|
|
792
|
+
return this._addCheck({ kind: "nanoid", ...p.errToObj(e) });
|
|
793
|
+
}
|
|
794
|
+
cuid(e) {
|
|
795
|
+
return this._addCheck({ kind: "cuid", ...p.errToObj(e) });
|
|
796
|
+
}
|
|
797
|
+
cuid2(e) {
|
|
798
|
+
return this._addCheck({ kind: "cuid2", ...p.errToObj(e) });
|
|
799
|
+
}
|
|
800
|
+
ulid(e) {
|
|
801
|
+
return this._addCheck({ kind: "ulid", ...p.errToObj(e) });
|
|
802
|
+
}
|
|
803
|
+
base64(e) {
|
|
804
|
+
return this._addCheck({ kind: "base64", ...p.errToObj(e) });
|
|
805
|
+
}
|
|
806
|
+
base64url(e) {
|
|
807
|
+
return this._addCheck({
|
|
808
|
+
kind: "base64url",
|
|
809
|
+
...p.errToObj(e)
|
|
810
|
+
});
|
|
811
|
+
}
|
|
812
|
+
jwt(e) {
|
|
813
|
+
return this._addCheck({ kind: "jwt", ...p.errToObj(e) });
|
|
814
|
+
}
|
|
815
|
+
ip(e) {
|
|
816
|
+
return this._addCheck({ kind: "ip", ...p.errToObj(e) });
|
|
817
|
+
}
|
|
818
|
+
cidr(e) {
|
|
819
|
+
return this._addCheck({ kind: "cidr", ...p.errToObj(e) });
|
|
820
|
+
}
|
|
821
|
+
datetime(e) {
|
|
822
|
+
var t, r;
|
|
823
|
+
return typeof e == "string" ? this._addCheck({
|
|
824
|
+
kind: "datetime",
|
|
825
|
+
precision: null,
|
|
826
|
+
offset: !1,
|
|
827
|
+
local: !1,
|
|
828
|
+
message: e
|
|
829
|
+
}) : this._addCheck({
|
|
830
|
+
kind: "datetime",
|
|
831
|
+
precision: typeof (e == null ? void 0 : e.precision) == "undefined" ? null : e == null ? void 0 : e.precision,
|
|
832
|
+
offset: (t = e == null ? void 0 : e.offset) != null ? t : !1,
|
|
833
|
+
local: (r = e == null ? void 0 : e.local) != null ? r : !1,
|
|
834
|
+
...p.errToObj(e == null ? void 0 : e.message)
|
|
835
|
+
});
|
|
836
|
+
}
|
|
837
|
+
date(e) {
|
|
838
|
+
return this._addCheck({ kind: "date", message: e });
|
|
839
|
+
}
|
|
840
|
+
time(e) {
|
|
841
|
+
return typeof e == "string" ? this._addCheck({
|
|
842
|
+
kind: "time",
|
|
843
|
+
precision: null,
|
|
844
|
+
message: e
|
|
845
|
+
}) : this._addCheck({
|
|
846
|
+
kind: "time",
|
|
847
|
+
precision: typeof (e == null ? void 0 : e.precision) == "undefined" ? null : e == null ? void 0 : e.precision,
|
|
848
|
+
...p.errToObj(e == null ? void 0 : e.message)
|
|
849
|
+
});
|
|
850
|
+
}
|
|
851
|
+
duration(e) {
|
|
852
|
+
return this._addCheck({ kind: "duration", ...p.errToObj(e) });
|
|
853
|
+
}
|
|
854
|
+
regex(e, t) {
|
|
855
|
+
return this._addCheck({
|
|
856
|
+
kind: "regex",
|
|
857
|
+
regex: e,
|
|
858
|
+
...p.errToObj(t)
|
|
859
|
+
});
|
|
860
|
+
}
|
|
861
|
+
includes(e, t) {
|
|
862
|
+
return this._addCheck({
|
|
863
|
+
kind: "includes",
|
|
864
|
+
value: e,
|
|
865
|
+
position: t == null ? void 0 : t.position,
|
|
866
|
+
...p.errToObj(t == null ? void 0 : t.message)
|
|
867
|
+
});
|
|
868
|
+
}
|
|
869
|
+
startsWith(e, t) {
|
|
870
|
+
return this._addCheck({
|
|
871
|
+
kind: "startsWith",
|
|
872
|
+
value: e,
|
|
873
|
+
...p.errToObj(t)
|
|
874
|
+
});
|
|
875
|
+
}
|
|
876
|
+
endsWith(e, t) {
|
|
877
|
+
return this._addCheck({
|
|
878
|
+
kind: "endsWith",
|
|
879
|
+
value: e,
|
|
880
|
+
...p.errToObj(t)
|
|
881
|
+
});
|
|
882
|
+
}
|
|
883
|
+
min(e, t) {
|
|
884
|
+
return this._addCheck({
|
|
885
|
+
kind: "min",
|
|
886
|
+
value: e,
|
|
887
|
+
...p.errToObj(t)
|
|
888
|
+
});
|
|
889
|
+
}
|
|
890
|
+
max(e, t) {
|
|
891
|
+
return this._addCheck({
|
|
892
|
+
kind: "max",
|
|
893
|
+
value: e,
|
|
894
|
+
...p.errToObj(t)
|
|
895
|
+
});
|
|
896
|
+
}
|
|
897
|
+
length(e, t) {
|
|
898
|
+
return this._addCheck({
|
|
899
|
+
kind: "length",
|
|
900
|
+
value: e,
|
|
901
|
+
...p.errToObj(t)
|
|
902
|
+
});
|
|
903
|
+
}
|
|
904
|
+
/**
|
|
905
|
+
* Equivalent to `.min(1)`
|
|
906
|
+
*/
|
|
907
|
+
nonempty(e) {
|
|
908
|
+
return this.min(1, p.errToObj(e));
|
|
909
|
+
}
|
|
910
|
+
trim() {
|
|
911
|
+
return new F({
|
|
912
|
+
...this._def,
|
|
913
|
+
checks: [...this._def.checks, { kind: "trim" }]
|
|
914
|
+
});
|
|
915
|
+
}
|
|
916
|
+
toLowerCase() {
|
|
917
|
+
return new F({
|
|
918
|
+
...this._def,
|
|
919
|
+
checks: [...this._def.checks, { kind: "toLowerCase" }]
|
|
920
|
+
});
|
|
921
|
+
}
|
|
922
|
+
toUpperCase() {
|
|
923
|
+
return new F({
|
|
924
|
+
...this._def,
|
|
925
|
+
checks: [...this._def.checks, { kind: "toUpperCase" }]
|
|
926
|
+
});
|
|
927
|
+
}
|
|
928
|
+
get isDatetime() {
|
|
929
|
+
return !!this._def.checks.find((e) => e.kind === "datetime");
|
|
930
|
+
}
|
|
931
|
+
get isDate() {
|
|
932
|
+
return !!this._def.checks.find((e) => e.kind === "date");
|
|
933
|
+
}
|
|
934
|
+
get isTime() {
|
|
935
|
+
return !!this._def.checks.find((e) => e.kind === "time");
|
|
936
|
+
}
|
|
937
|
+
get isDuration() {
|
|
938
|
+
return !!this._def.checks.find((e) => e.kind === "duration");
|
|
939
|
+
}
|
|
940
|
+
get isEmail() {
|
|
941
|
+
return !!this._def.checks.find((e) => e.kind === "email");
|
|
942
|
+
}
|
|
943
|
+
get isURL() {
|
|
944
|
+
return !!this._def.checks.find((e) => e.kind === "url");
|
|
945
|
+
}
|
|
946
|
+
get isEmoji() {
|
|
947
|
+
return !!this._def.checks.find((e) => e.kind === "emoji");
|
|
948
|
+
}
|
|
949
|
+
get isUUID() {
|
|
950
|
+
return !!this._def.checks.find((e) => e.kind === "uuid");
|
|
951
|
+
}
|
|
952
|
+
get isNANOID() {
|
|
953
|
+
return !!this._def.checks.find((e) => e.kind === "nanoid");
|
|
954
|
+
}
|
|
955
|
+
get isCUID() {
|
|
956
|
+
return !!this._def.checks.find((e) => e.kind === "cuid");
|
|
957
|
+
}
|
|
958
|
+
get isCUID2() {
|
|
959
|
+
return !!this._def.checks.find((e) => e.kind === "cuid2");
|
|
960
|
+
}
|
|
961
|
+
get isULID() {
|
|
962
|
+
return !!this._def.checks.find((e) => e.kind === "ulid");
|
|
963
|
+
}
|
|
964
|
+
get isIP() {
|
|
965
|
+
return !!this._def.checks.find((e) => e.kind === "ip");
|
|
966
|
+
}
|
|
967
|
+
get isCIDR() {
|
|
968
|
+
return !!this._def.checks.find((e) => e.kind === "cidr");
|
|
969
|
+
}
|
|
970
|
+
get isBase64() {
|
|
971
|
+
return !!this._def.checks.find((e) => e.kind === "base64");
|
|
972
|
+
}
|
|
973
|
+
get isBase64url() {
|
|
974
|
+
return !!this._def.checks.find((e) => e.kind === "base64url");
|
|
975
|
+
}
|
|
976
|
+
get minLength() {
|
|
977
|
+
let e = null;
|
|
978
|
+
for (const t of this._def.checks)
|
|
979
|
+
t.kind === "min" && (e === null || t.value > e) && (e = t.value);
|
|
980
|
+
return e;
|
|
981
|
+
}
|
|
982
|
+
get maxLength() {
|
|
983
|
+
let e = null;
|
|
984
|
+
for (const t of this._def.checks)
|
|
985
|
+
t.kind === "max" && (e === null || t.value < e) && (e = t.value);
|
|
986
|
+
return e;
|
|
987
|
+
}
|
|
988
|
+
}
|
|
989
|
+
F.create = (n) => {
|
|
990
|
+
var e;
|
|
991
|
+
return new F({
|
|
992
|
+
checks: [],
|
|
993
|
+
typeName: l.ZodString,
|
|
994
|
+
coerce: (e = n == null ? void 0 : n.coerce) != null ? e : !1,
|
|
995
|
+
..._(n)
|
|
996
|
+
});
|
|
997
|
+
};
|
|
998
|
+
function Pn(n, e) {
|
|
999
|
+
const t = (n.toString().split(".")[1] || "").length, r = (e.toString().split(".")[1] || "").length, s = t > r ? t : r, a = Number.parseInt(n.toFixed(s).replace(".", "")), i = Number.parseInt(e.toFixed(s).replace(".", ""));
|
|
1000
|
+
return a % i / 10 ** s;
|
|
1001
|
+
}
|
|
1002
|
+
class se extends b {
|
|
1003
|
+
constructor() {
|
|
1004
|
+
super(...arguments), this.min = this.gte, this.max = this.lte, this.step = this.multipleOf;
|
|
1005
|
+
}
|
|
1006
|
+
_parse(e) {
|
|
1007
|
+
if (this._def.coerce && (e.data = Number(e.data)), this._getType(e) !== h.number) {
|
|
1008
|
+
const a = this._getOrReturnCtx(e);
|
|
1009
|
+
return f(a, {
|
|
1010
|
+
code: d.invalid_type,
|
|
1011
|
+
expected: h.number,
|
|
1012
|
+
received: a.parsedType
|
|
1013
|
+
}), g;
|
|
1014
|
+
}
|
|
1015
|
+
let r;
|
|
1016
|
+
const s = new P();
|
|
1017
|
+
for (const a of this._def.checks)
|
|
1018
|
+
a.kind === "int" ? k.isInteger(e.data) || (r = this._getOrReturnCtx(e, r), f(r, {
|
|
1019
|
+
code: d.invalid_type,
|
|
1020
|
+
expected: "integer",
|
|
1021
|
+
received: "float",
|
|
1022
|
+
message: a.message
|
|
1023
|
+
}), s.dirty()) : a.kind === "min" ? (a.inclusive ? e.data < a.value : e.data <= a.value) && (r = this._getOrReturnCtx(e, r), f(r, {
|
|
1024
|
+
code: d.too_small,
|
|
1025
|
+
minimum: a.value,
|
|
1026
|
+
type: "number",
|
|
1027
|
+
inclusive: a.inclusive,
|
|
1028
|
+
exact: !1,
|
|
1029
|
+
message: a.message
|
|
1030
|
+
}), s.dirty()) : a.kind === "max" ? (a.inclusive ? e.data > a.value : e.data >= a.value) && (r = this._getOrReturnCtx(e, r), f(r, {
|
|
1031
|
+
code: d.too_big,
|
|
1032
|
+
maximum: a.value,
|
|
1033
|
+
type: "number",
|
|
1034
|
+
inclusive: a.inclusive,
|
|
1035
|
+
exact: !1,
|
|
1036
|
+
message: a.message
|
|
1037
|
+
}), s.dirty()) : a.kind === "multipleOf" ? Pn(e.data, a.value) !== 0 && (r = this._getOrReturnCtx(e, r), f(r, {
|
|
1038
|
+
code: d.not_multiple_of,
|
|
1039
|
+
multipleOf: a.value,
|
|
1040
|
+
message: a.message
|
|
1041
|
+
}), s.dirty()) : a.kind === "finite" ? Number.isFinite(e.data) || (r = this._getOrReturnCtx(e, r), f(r, {
|
|
1042
|
+
code: d.not_finite,
|
|
1043
|
+
message: a.message
|
|
1044
|
+
}), s.dirty()) : k.assertNever(a);
|
|
1045
|
+
return { status: s.value, value: e.data };
|
|
1046
|
+
}
|
|
1047
|
+
gte(e, t) {
|
|
1048
|
+
return this.setLimit("min", e, !0, p.toString(t));
|
|
1049
|
+
}
|
|
1050
|
+
gt(e, t) {
|
|
1051
|
+
return this.setLimit("min", e, !1, p.toString(t));
|
|
1052
|
+
}
|
|
1053
|
+
lte(e, t) {
|
|
1054
|
+
return this.setLimit("max", e, !0, p.toString(t));
|
|
1055
|
+
}
|
|
1056
|
+
lt(e, t) {
|
|
1057
|
+
return this.setLimit("max", e, !1, p.toString(t));
|
|
1058
|
+
}
|
|
1059
|
+
setLimit(e, t, r, s) {
|
|
1060
|
+
return new se({
|
|
1061
|
+
...this._def,
|
|
1062
|
+
checks: [
|
|
1063
|
+
...this._def.checks,
|
|
1064
|
+
{
|
|
1065
|
+
kind: e,
|
|
1066
|
+
value: t,
|
|
1067
|
+
inclusive: r,
|
|
1068
|
+
message: p.toString(s)
|
|
1069
|
+
}
|
|
1070
|
+
]
|
|
1071
|
+
});
|
|
1072
|
+
}
|
|
1073
|
+
_addCheck(e) {
|
|
1074
|
+
return new se({
|
|
1075
|
+
...this._def,
|
|
1076
|
+
checks: [...this._def.checks, e]
|
|
1077
|
+
});
|
|
1078
|
+
}
|
|
1079
|
+
int(e) {
|
|
1080
|
+
return this._addCheck({
|
|
1081
|
+
kind: "int",
|
|
1082
|
+
message: p.toString(e)
|
|
1083
|
+
});
|
|
1084
|
+
}
|
|
1085
|
+
positive(e) {
|
|
1086
|
+
return this._addCheck({
|
|
1087
|
+
kind: "min",
|
|
1088
|
+
value: 0,
|
|
1089
|
+
inclusive: !1,
|
|
1090
|
+
message: p.toString(e)
|
|
1091
|
+
});
|
|
1092
|
+
}
|
|
1093
|
+
negative(e) {
|
|
1094
|
+
return this._addCheck({
|
|
1095
|
+
kind: "max",
|
|
1096
|
+
value: 0,
|
|
1097
|
+
inclusive: !1,
|
|
1098
|
+
message: p.toString(e)
|
|
1099
|
+
});
|
|
1100
|
+
}
|
|
1101
|
+
nonpositive(e) {
|
|
1102
|
+
return this._addCheck({
|
|
1103
|
+
kind: "max",
|
|
1104
|
+
value: 0,
|
|
1105
|
+
inclusive: !0,
|
|
1106
|
+
message: p.toString(e)
|
|
1107
|
+
});
|
|
1108
|
+
}
|
|
1109
|
+
nonnegative(e) {
|
|
1110
|
+
return this._addCheck({
|
|
1111
|
+
kind: "min",
|
|
1112
|
+
value: 0,
|
|
1113
|
+
inclusive: !0,
|
|
1114
|
+
message: p.toString(e)
|
|
1115
|
+
});
|
|
1116
|
+
}
|
|
1117
|
+
multipleOf(e, t) {
|
|
1118
|
+
return this._addCheck({
|
|
1119
|
+
kind: "multipleOf",
|
|
1120
|
+
value: e,
|
|
1121
|
+
message: p.toString(t)
|
|
1122
|
+
});
|
|
1123
|
+
}
|
|
1124
|
+
finite(e) {
|
|
1125
|
+
return this._addCheck({
|
|
1126
|
+
kind: "finite",
|
|
1127
|
+
message: p.toString(e)
|
|
1128
|
+
});
|
|
1129
|
+
}
|
|
1130
|
+
safe(e) {
|
|
1131
|
+
return this._addCheck({
|
|
1132
|
+
kind: "min",
|
|
1133
|
+
inclusive: !0,
|
|
1134
|
+
value: Number.MIN_SAFE_INTEGER,
|
|
1135
|
+
message: p.toString(e)
|
|
1136
|
+
})._addCheck({
|
|
1137
|
+
kind: "max",
|
|
1138
|
+
inclusive: !0,
|
|
1139
|
+
value: Number.MAX_SAFE_INTEGER,
|
|
1140
|
+
message: p.toString(e)
|
|
1141
|
+
});
|
|
1142
|
+
}
|
|
1143
|
+
get minValue() {
|
|
1144
|
+
let e = null;
|
|
1145
|
+
for (const t of this._def.checks)
|
|
1146
|
+
t.kind === "min" && (e === null || t.value > e) && (e = t.value);
|
|
1147
|
+
return e;
|
|
1148
|
+
}
|
|
1149
|
+
get maxValue() {
|
|
1150
|
+
let e = null;
|
|
1151
|
+
for (const t of this._def.checks)
|
|
1152
|
+
t.kind === "max" && (e === null || t.value < e) && (e = t.value);
|
|
1153
|
+
return e;
|
|
1154
|
+
}
|
|
1155
|
+
get isInt() {
|
|
1156
|
+
return !!this._def.checks.find((e) => e.kind === "int" || e.kind === "multipleOf" && k.isInteger(e.value));
|
|
1157
|
+
}
|
|
1158
|
+
get isFinite() {
|
|
1159
|
+
let e = null, t = null;
|
|
1160
|
+
for (const r of this._def.checks) {
|
|
1161
|
+
if (r.kind === "finite" || r.kind === "int" || r.kind === "multipleOf")
|
|
1162
|
+
return !0;
|
|
1163
|
+
r.kind === "min" ? (t === null || r.value > t) && (t = r.value) : r.kind === "max" && (e === null || r.value < e) && (e = r.value);
|
|
1164
|
+
}
|
|
1165
|
+
return Number.isFinite(t) && Number.isFinite(e);
|
|
1166
|
+
}
|
|
1167
|
+
}
|
|
1168
|
+
se.create = (n) => new se({
|
|
1169
|
+
checks: [],
|
|
1170
|
+
typeName: l.ZodNumber,
|
|
1171
|
+
coerce: (n == null ? void 0 : n.coerce) || !1,
|
|
1172
|
+
..._(n)
|
|
1173
|
+
});
|
|
1174
|
+
class ae extends b {
|
|
1175
|
+
constructor() {
|
|
1176
|
+
super(...arguments), this.min = this.gte, this.max = this.lte;
|
|
1177
|
+
}
|
|
1178
|
+
_parse(e) {
|
|
1179
|
+
if (this._def.coerce)
|
|
1180
|
+
try {
|
|
1181
|
+
e.data = BigInt(e.data);
|
|
1182
|
+
} catch (a) {
|
|
1183
|
+
return this._getInvalidInput(e);
|
|
1184
|
+
}
|
|
1185
|
+
if (this._getType(e) !== h.bigint)
|
|
1186
|
+
return this._getInvalidInput(e);
|
|
1187
|
+
let r;
|
|
1188
|
+
const s = new P();
|
|
1189
|
+
for (const a of this._def.checks)
|
|
1190
|
+
a.kind === "min" ? (a.inclusive ? e.data < a.value : e.data <= a.value) && (r = this._getOrReturnCtx(e, r), f(r, {
|
|
1191
|
+
code: d.too_small,
|
|
1192
|
+
type: "bigint",
|
|
1193
|
+
minimum: a.value,
|
|
1194
|
+
inclusive: a.inclusive,
|
|
1195
|
+
message: a.message
|
|
1196
|
+
}), s.dirty()) : a.kind === "max" ? (a.inclusive ? e.data > a.value : e.data >= a.value) && (r = this._getOrReturnCtx(e, r), f(r, {
|
|
1197
|
+
code: d.too_big,
|
|
1198
|
+
type: "bigint",
|
|
1199
|
+
maximum: a.value,
|
|
1200
|
+
inclusive: a.inclusive,
|
|
1201
|
+
message: a.message
|
|
1202
|
+
}), s.dirty()) : a.kind === "multipleOf" ? e.data % a.value !== BigInt(0) && (r = this._getOrReturnCtx(e, r), f(r, {
|
|
1203
|
+
code: d.not_multiple_of,
|
|
1204
|
+
multipleOf: a.value,
|
|
1205
|
+
message: a.message
|
|
1206
|
+
}), s.dirty()) : k.assertNever(a);
|
|
1207
|
+
return { status: s.value, value: e.data };
|
|
1208
|
+
}
|
|
1209
|
+
_getInvalidInput(e) {
|
|
1210
|
+
const t = this._getOrReturnCtx(e);
|
|
1211
|
+
return f(t, {
|
|
1212
|
+
code: d.invalid_type,
|
|
1213
|
+
expected: h.bigint,
|
|
1214
|
+
received: t.parsedType
|
|
1215
|
+
}), g;
|
|
1216
|
+
}
|
|
1217
|
+
gte(e, t) {
|
|
1218
|
+
return this.setLimit("min", e, !0, p.toString(t));
|
|
1219
|
+
}
|
|
1220
|
+
gt(e, t) {
|
|
1221
|
+
return this.setLimit("min", e, !1, p.toString(t));
|
|
1222
|
+
}
|
|
1223
|
+
lte(e, t) {
|
|
1224
|
+
return this.setLimit("max", e, !0, p.toString(t));
|
|
1225
|
+
}
|
|
1226
|
+
lt(e, t) {
|
|
1227
|
+
return this.setLimit("max", e, !1, p.toString(t));
|
|
1228
|
+
}
|
|
1229
|
+
setLimit(e, t, r, s) {
|
|
1230
|
+
return new ae({
|
|
1231
|
+
...this._def,
|
|
1232
|
+
checks: [
|
|
1233
|
+
...this._def.checks,
|
|
1234
|
+
{
|
|
1235
|
+
kind: e,
|
|
1236
|
+
value: t,
|
|
1237
|
+
inclusive: r,
|
|
1238
|
+
message: p.toString(s)
|
|
1239
|
+
}
|
|
1240
|
+
]
|
|
1241
|
+
});
|
|
1242
|
+
}
|
|
1243
|
+
_addCheck(e) {
|
|
1244
|
+
return new ae({
|
|
1245
|
+
...this._def,
|
|
1246
|
+
checks: [...this._def.checks, e]
|
|
1247
|
+
});
|
|
1248
|
+
}
|
|
1249
|
+
positive(e) {
|
|
1250
|
+
return this._addCheck({
|
|
1251
|
+
kind: "min",
|
|
1252
|
+
value: BigInt(0),
|
|
1253
|
+
inclusive: !1,
|
|
1254
|
+
message: p.toString(e)
|
|
1255
|
+
});
|
|
1256
|
+
}
|
|
1257
|
+
negative(e) {
|
|
1258
|
+
return this._addCheck({
|
|
1259
|
+
kind: "max",
|
|
1260
|
+
value: BigInt(0),
|
|
1261
|
+
inclusive: !1,
|
|
1262
|
+
message: p.toString(e)
|
|
1263
|
+
});
|
|
1264
|
+
}
|
|
1265
|
+
nonpositive(e) {
|
|
1266
|
+
return this._addCheck({
|
|
1267
|
+
kind: "max",
|
|
1268
|
+
value: BigInt(0),
|
|
1269
|
+
inclusive: !0,
|
|
1270
|
+
message: p.toString(e)
|
|
1271
|
+
});
|
|
1272
|
+
}
|
|
1273
|
+
nonnegative(e) {
|
|
1274
|
+
return this._addCheck({
|
|
1275
|
+
kind: "min",
|
|
1276
|
+
value: BigInt(0),
|
|
1277
|
+
inclusive: !0,
|
|
1278
|
+
message: p.toString(e)
|
|
1279
|
+
});
|
|
1280
|
+
}
|
|
1281
|
+
multipleOf(e, t) {
|
|
1282
|
+
return this._addCheck({
|
|
1283
|
+
kind: "multipleOf",
|
|
1284
|
+
value: e,
|
|
1285
|
+
message: p.toString(t)
|
|
1286
|
+
});
|
|
1287
|
+
}
|
|
1288
|
+
get minValue() {
|
|
1289
|
+
let e = null;
|
|
1290
|
+
for (const t of this._def.checks)
|
|
1291
|
+
t.kind === "min" && (e === null || t.value > e) && (e = t.value);
|
|
1292
|
+
return e;
|
|
1293
|
+
}
|
|
1294
|
+
get maxValue() {
|
|
1295
|
+
let e = null;
|
|
1296
|
+
for (const t of this._def.checks)
|
|
1297
|
+
t.kind === "max" && (e === null || t.value < e) && (e = t.value);
|
|
1298
|
+
return e;
|
|
1299
|
+
}
|
|
1300
|
+
}
|
|
1301
|
+
ae.create = (n) => {
|
|
1302
|
+
var e;
|
|
1303
|
+
return new ae({
|
|
1304
|
+
checks: [],
|
|
1305
|
+
typeName: l.ZodBigInt,
|
|
1306
|
+
coerce: (e = n == null ? void 0 : n.coerce) != null ? e : !1,
|
|
1307
|
+
..._(n)
|
|
1308
|
+
});
|
|
1309
|
+
};
|
|
1310
|
+
class Be extends b {
|
|
1311
|
+
_parse(e) {
|
|
1312
|
+
if (this._def.coerce && (e.data = !!e.data), this._getType(e) !== h.boolean) {
|
|
1313
|
+
const r = this._getOrReturnCtx(e);
|
|
1314
|
+
return f(r, {
|
|
1315
|
+
code: d.invalid_type,
|
|
1316
|
+
expected: h.boolean,
|
|
1317
|
+
received: r.parsedType
|
|
1318
|
+
}), g;
|
|
1319
|
+
}
|
|
1320
|
+
return E(e.data);
|
|
1321
|
+
}
|
|
1322
|
+
}
|
|
1323
|
+
Be.create = (n) => new Be({
|
|
1324
|
+
typeName: l.ZodBoolean,
|
|
1325
|
+
coerce: (n == null ? void 0 : n.coerce) || !1,
|
|
1326
|
+
..._(n)
|
|
1327
|
+
});
|
|
1328
|
+
class ge extends b {
|
|
1329
|
+
_parse(e) {
|
|
1330
|
+
if (this._def.coerce && (e.data = new Date(e.data)), this._getType(e) !== h.date) {
|
|
1331
|
+
const a = this._getOrReturnCtx(e);
|
|
1332
|
+
return f(a, {
|
|
1333
|
+
code: d.invalid_type,
|
|
1334
|
+
expected: h.date,
|
|
1335
|
+
received: a.parsedType
|
|
1336
|
+
}), g;
|
|
1337
|
+
}
|
|
1338
|
+
if (Number.isNaN(e.data.getTime())) {
|
|
1339
|
+
const a = this._getOrReturnCtx(e);
|
|
1340
|
+
return f(a, {
|
|
1341
|
+
code: d.invalid_date
|
|
1342
|
+
}), g;
|
|
1343
|
+
}
|
|
1344
|
+
const r = new P();
|
|
1345
|
+
let s;
|
|
1346
|
+
for (const a of this._def.checks)
|
|
1347
|
+
a.kind === "min" ? e.data.getTime() < a.value && (s = this._getOrReturnCtx(e, s), f(s, {
|
|
1348
|
+
code: d.too_small,
|
|
1349
|
+
message: a.message,
|
|
1350
|
+
inclusive: !0,
|
|
1351
|
+
exact: !1,
|
|
1352
|
+
minimum: a.value,
|
|
1353
|
+
type: "date"
|
|
1354
|
+
}), r.dirty()) : a.kind === "max" ? e.data.getTime() > a.value && (s = this._getOrReturnCtx(e, s), f(s, {
|
|
1355
|
+
code: d.too_big,
|
|
1356
|
+
message: a.message,
|
|
1357
|
+
inclusive: !0,
|
|
1358
|
+
exact: !1,
|
|
1359
|
+
maximum: a.value,
|
|
1360
|
+
type: "date"
|
|
1361
|
+
}), r.dirty()) : k.assertNever(a);
|
|
1362
|
+
return {
|
|
1363
|
+
status: r.value,
|
|
1364
|
+
value: new Date(e.data.getTime())
|
|
1365
|
+
};
|
|
1366
|
+
}
|
|
1367
|
+
_addCheck(e) {
|
|
1368
|
+
return new ge({
|
|
1369
|
+
...this._def,
|
|
1370
|
+
checks: [...this._def.checks, e]
|
|
1371
|
+
});
|
|
1372
|
+
}
|
|
1373
|
+
min(e, t) {
|
|
1374
|
+
return this._addCheck({
|
|
1375
|
+
kind: "min",
|
|
1376
|
+
value: e.getTime(),
|
|
1377
|
+
message: p.toString(t)
|
|
1378
|
+
});
|
|
1379
|
+
}
|
|
1380
|
+
max(e, t) {
|
|
1381
|
+
return this._addCheck({
|
|
1382
|
+
kind: "max",
|
|
1383
|
+
value: e.getTime(),
|
|
1384
|
+
message: p.toString(t)
|
|
1385
|
+
});
|
|
1386
|
+
}
|
|
1387
|
+
get minDate() {
|
|
1388
|
+
let e = null;
|
|
1389
|
+
for (const t of this._def.checks)
|
|
1390
|
+
t.kind === "min" && (e === null || t.value > e) && (e = t.value);
|
|
1391
|
+
return e != null ? new Date(e) : null;
|
|
1392
|
+
}
|
|
1393
|
+
get maxDate() {
|
|
1394
|
+
let e = null;
|
|
1395
|
+
for (const t of this._def.checks)
|
|
1396
|
+
t.kind === "max" && (e === null || t.value < e) && (e = t.value);
|
|
1397
|
+
return e != null ? new Date(e) : null;
|
|
1398
|
+
}
|
|
1399
|
+
}
|
|
1400
|
+
ge.create = (n) => new ge({
|
|
1401
|
+
checks: [],
|
|
1402
|
+
coerce: (n == null ? void 0 : n.coerce) || !1,
|
|
1403
|
+
typeName: l.ZodDate,
|
|
1404
|
+
..._(n)
|
|
1405
|
+
});
|
|
1406
|
+
class We extends b {
|
|
1407
|
+
_parse(e) {
|
|
1408
|
+
if (this._getType(e) !== h.symbol) {
|
|
1409
|
+
const r = this._getOrReturnCtx(e);
|
|
1410
|
+
return f(r, {
|
|
1411
|
+
code: d.invalid_type,
|
|
1412
|
+
expected: h.symbol,
|
|
1413
|
+
received: r.parsedType
|
|
1414
|
+
}), g;
|
|
1415
|
+
}
|
|
1416
|
+
return E(e.data);
|
|
1417
|
+
}
|
|
1418
|
+
}
|
|
1419
|
+
We.create = (n) => new We({
|
|
1420
|
+
typeName: l.ZodSymbol,
|
|
1421
|
+
..._(n)
|
|
1422
|
+
});
|
|
1423
|
+
class qe extends b {
|
|
1424
|
+
_parse(e) {
|
|
1425
|
+
if (this._getType(e) !== h.undefined) {
|
|
1426
|
+
const r = this._getOrReturnCtx(e);
|
|
1427
|
+
return f(r, {
|
|
1428
|
+
code: d.invalid_type,
|
|
1429
|
+
expected: h.undefined,
|
|
1430
|
+
received: r.parsedType
|
|
1431
|
+
}), g;
|
|
1432
|
+
}
|
|
1433
|
+
return E(e.data);
|
|
1434
|
+
}
|
|
1435
|
+
}
|
|
1436
|
+
qe.create = (n) => new qe({
|
|
1437
|
+
typeName: l.ZodUndefined,
|
|
1438
|
+
..._(n)
|
|
1439
|
+
});
|
|
1440
|
+
class Je extends b {
|
|
1441
|
+
_parse(e) {
|
|
1442
|
+
if (this._getType(e) !== h.null) {
|
|
1443
|
+
const r = this._getOrReturnCtx(e);
|
|
1444
|
+
return f(r, {
|
|
1445
|
+
code: d.invalid_type,
|
|
1446
|
+
expected: h.null,
|
|
1447
|
+
received: r.parsedType
|
|
1448
|
+
}), g;
|
|
1449
|
+
}
|
|
1450
|
+
return E(e.data);
|
|
1451
|
+
}
|
|
1452
|
+
}
|
|
1453
|
+
Je.create = (n) => new Je({
|
|
1454
|
+
typeName: l.ZodNull,
|
|
1455
|
+
..._(n)
|
|
1456
|
+
});
|
|
1457
|
+
class He extends b {
|
|
1458
|
+
constructor() {
|
|
1459
|
+
super(...arguments), this._any = !0;
|
|
1460
|
+
}
|
|
1461
|
+
_parse(e) {
|
|
1462
|
+
return E(e.data);
|
|
1463
|
+
}
|
|
1464
|
+
}
|
|
1465
|
+
He.create = (n) => new He({
|
|
1466
|
+
typeName: l.ZodAny,
|
|
1467
|
+
..._(n)
|
|
1468
|
+
});
|
|
1469
|
+
class Ge extends b {
|
|
1470
|
+
constructor() {
|
|
1471
|
+
super(...arguments), this._unknown = !0;
|
|
1472
|
+
}
|
|
1473
|
+
_parse(e) {
|
|
1474
|
+
return E(e.data);
|
|
1475
|
+
}
|
|
1476
|
+
}
|
|
1477
|
+
Ge.create = (n) => new Ge({
|
|
1478
|
+
typeName: l.ZodUnknown,
|
|
1479
|
+
..._(n)
|
|
1480
|
+
});
|
|
1481
|
+
class Y extends b {
|
|
1482
|
+
_parse(e) {
|
|
1483
|
+
const t = this._getOrReturnCtx(e);
|
|
1484
|
+
return f(t, {
|
|
1485
|
+
code: d.invalid_type,
|
|
1486
|
+
expected: h.never,
|
|
1487
|
+
received: t.parsedType
|
|
1488
|
+
}), g;
|
|
1489
|
+
}
|
|
1490
|
+
}
|
|
1491
|
+
Y.create = (n) => new Y({
|
|
1492
|
+
typeName: l.ZodNever,
|
|
1493
|
+
..._(n)
|
|
1494
|
+
});
|
|
1495
|
+
class Ye extends b {
|
|
1496
|
+
_parse(e) {
|
|
1497
|
+
if (this._getType(e) !== h.undefined) {
|
|
1498
|
+
const r = this._getOrReturnCtx(e);
|
|
1499
|
+
return f(r, {
|
|
1500
|
+
code: d.invalid_type,
|
|
1501
|
+
expected: h.void,
|
|
1502
|
+
received: r.parsedType
|
|
1503
|
+
}), g;
|
|
1504
|
+
}
|
|
1505
|
+
return E(e.data);
|
|
1506
|
+
}
|
|
1507
|
+
}
|
|
1508
|
+
Ye.create = (n) => new Ye({
|
|
1509
|
+
typeName: l.ZodVoid,
|
|
1510
|
+
..._(n)
|
|
1511
|
+
});
|
|
1512
|
+
class L extends b {
|
|
1513
|
+
_parse(e) {
|
|
1514
|
+
const { ctx: t, status: r } = this._processInputParams(e), s = this._def;
|
|
1515
|
+
if (t.parsedType !== h.array)
|
|
1516
|
+
return f(t, {
|
|
1517
|
+
code: d.invalid_type,
|
|
1518
|
+
expected: h.array,
|
|
1519
|
+
received: t.parsedType
|
|
1520
|
+
}), g;
|
|
1521
|
+
if (s.exactLength !== null) {
|
|
1522
|
+
const i = t.data.length > s.exactLength.value, o = t.data.length < s.exactLength.value;
|
|
1523
|
+
(i || o) && (f(t, {
|
|
1524
|
+
code: i ? d.too_big : d.too_small,
|
|
1525
|
+
minimum: o ? s.exactLength.value : void 0,
|
|
1526
|
+
maximum: i ? s.exactLength.value : void 0,
|
|
1527
|
+
type: "array",
|
|
1528
|
+
inclusive: !0,
|
|
1529
|
+
exact: !0,
|
|
1530
|
+
message: s.exactLength.message
|
|
1531
|
+
}), r.dirty());
|
|
1532
|
+
}
|
|
1533
|
+
if (s.minLength !== null && t.data.length < s.minLength.value && (f(t, {
|
|
1534
|
+
code: d.too_small,
|
|
1535
|
+
minimum: s.minLength.value,
|
|
1536
|
+
type: "array",
|
|
1537
|
+
inclusive: !0,
|
|
1538
|
+
exact: !1,
|
|
1539
|
+
message: s.minLength.message
|
|
1540
|
+
}), r.dirty()), s.maxLength !== null && t.data.length > s.maxLength.value && (f(t, {
|
|
1541
|
+
code: d.too_big,
|
|
1542
|
+
maximum: s.maxLength.value,
|
|
1543
|
+
type: "array",
|
|
1544
|
+
inclusive: !0,
|
|
1545
|
+
exact: !1,
|
|
1546
|
+
message: s.maxLength.message
|
|
1547
|
+
}), r.dirty()), t.common.async)
|
|
1548
|
+
return Promise.all([...t.data].map((i, o) => s.type._parseAsync(new V(t, i, t.path, o)))).then((i) => P.mergeArray(r, i));
|
|
1549
|
+
const a = [...t.data].map((i, o) => s.type._parseSync(new V(t, i, t.path, o)));
|
|
1550
|
+
return P.mergeArray(r, a);
|
|
1551
|
+
}
|
|
1552
|
+
get element() {
|
|
1553
|
+
return this._def.type;
|
|
1554
|
+
}
|
|
1555
|
+
min(e, t) {
|
|
1556
|
+
return new L({
|
|
1557
|
+
...this._def,
|
|
1558
|
+
minLength: { value: e, message: p.toString(t) }
|
|
1559
|
+
});
|
|
1560
|
+
}
|
|
1561
|
+
max(e, t) {
|
|
1562
|
+
return new L({
|
|
1563
|
+
...this._def,
|
|
1564
|
+
maxLength: { value: e, message: p.toString(t) }
|
|
1565
|
+
});
|
|
1566
|
+
}
|
|
1567
|
+
length(e, t) {
|
|
1568
|
+
return new L({
|
|
1569
|
+
...this._def,
|
|
1570
|
+
exactLength: { value: e, message: p.toString(t) }
|
|
1571
|
+
});
|
|
1572
|
+
}
|
|
1573
|
+
nonempty(e) {
|
|
1574
|
+
return this.min(1, e);
|
|
1575
|
+
}
|
|
1576
|
+
}
|
|
1577
|
+
L.create = (n, e) => new L({
|
|
1578
|
+
type: n,
|
|
1579
|
+
minLength: null,
|
|
1580
|
+
maxLength: null,
|
|
1581
|
+
exactLength: null,
|
|
1582
|
+
typeName: l.ZodArray,
|
|
1583
|
+
..._(e)
|
|
1584
|
+
});
|
|
1585
|
+
function te(n) {
|
|
1586
|
+
if (n instanceof C) {
|
|
1587
|
+
const e = {};
|
|
1588
|
+
for (const t in n.shape) {
|
|
1589
|
+
const r = n.shape[t];
|
|
1590
|
+
e[t] = H.create(te(r));
|
|
1591
|
+
}
|
|
1592
|
+
return new C({
|
|
1593
|
+
...n._def,
|
|
1594
|
+
shape: () => e
|
|
1595
|
+
});
|
|
1596
|
+
} else
|
|
1597
|
+
return n instanceof L ? new L({
|
|
1598
|
+
...n._def,
|
|
1599
|
+
type: te(n.element)
|
|
1600
|
+
}) : n instanceof H ? H.create(te(n.unwrap())) : n instanceof ce ? ce.create(te(n.unwrap())) : n instanceof Q ? Q.create(n.items.map((e) => te(e))) : n;
|
|
1601
|
+
}
|
|
1602
|
+
class C extends b {
|
|
1603
|
+
constructor() {
|
|
1604
|
+
super(...arguments), this._cached = null, this.nonstrict = this.passthrough, this.augment = this.extend;
|
|
1605
|
+
}
|
|
1606
|
+
_getCached() {
|
|
1607
|
+
if (this._cached !== null)
|
|
1608
|
+
return this._cached;
|
|
1609
|
+
const e = this._def.shape(), t = k.objectKeys(e);
|
|
1610
|
+
return this._cached = { shape: e, keys: t }, this._cached;
|
|
1611
|
+
}
|
|
1612
|
+
_parse(e) {
|
|
1613
|
+
if (this._getType(e) !== h.object) {
|
|
1614
|
+
const u = this._getOrReturnCtx(e);
|
|
1615
|
+
return f(u, {
|
|
1616
|
+
code: d.invalid_type,
|
|
1617
|
+
expected: h.object,
|
|
1618
|
+
received: u.parsedType
|
|
1619
|
+
}), g;
|
|
1620
|
+
}
|
|
1621
|
+
const { status: r, ctx: s } = this._processInputParams(e), { shape: a, keys: i } = this._getCached(), o = [];
|
|
1622
|
+
if (!(this._def.catchall instanceof Y && this._def.unknownKeys === "strip"))
|
|
1623
|
+
for (const u in s.data)
|
|
1624
|
+
i.includes(u) || o.push(u);
|
|
1625
|
+
const c = [];
|
|
1626
|
+
for (const u of i) {
|
|
1627
|
+
const y = a[u], T = s.data[u];
|
|
1628
|
+
c.push({
|
|
1629
|
+
key: { status: "valid", value: u },
|
|
1630
|
+
value: y._parse(new V(s, T, s.path, u)),
|
|
1631
|
+
alwaysSet: u in s.data
|
|
1632
|
+
});
|
|
1633
|
+
}
|
|
1634
|
+
if (this._def.catchall instanceof Y) {
|
|
1635
|
+
const u = this._def.unknownKeys;
|
|
1636
|
+
if (u === "passthrough")
|
|
1637
|
+
for (const y of o)
|
|
1638
|
+
c.push({
|
|
1639
|
+
key: { status: "valid", value: y },
|
|
1640
|
+
value: { status: "valid", value: s.data[y] }
|
|
1641
|
+
});
|
|
1642
|
+
else if (u === "strict")
|
|
1643
|
+
o.length > 0 && (f(s, {
|
|
1644
|
+
code: d.unrecognized_keys,
|
|
1645
|
+
keys: o
|
|
1646
|
+
}), r.dirty());
|
|
1647
|
+
else if (u !== "strip")
|
|
1648
|
+
throw new Error("Internal ZodObject error: invalid unknownKeys value.");
|
|
1649
|
+
} else {
|
|
1650
|
+
const u = this._def.catchall;
|
|
1651
|
+
for (const y of o) {
|
|
1652
|
+
const T = s.data[y];
|
|
1653
|
+
c.push({
|
|
1654
|
+
key: { status: "valid", value: y },
|
|
1655
|
+
value: u._parse(
|
|
1656
|
+
new V(s, T, s.path, y)
|
|
1657
|
+
//, ctx.child(key), value, getParsedType(value)
|
|
1658
|
+
),
|
|
1659
|
+
alwaysSet: y in s.data
|
|
1660
|
+
});
|
|
1661
|
+
}
|
|
1662
|
+
}
|
|
1663
|
+
return s.common.async ? Promise.resolve().then(async () => {
|
|
1664
|
+
const u = [];
|
|
1665
|
+
for (const y of c) {
|
|
1666
|
+
const T = await y.key, v = await y.value;
|
|
1667
|
+
u.push({
|
|
1668
|
+
key: T,
|
|
1669
|
+
value: v,
|
|
1670
|
+
alwaysSet: y.alwaysSet
|
|
1671
|
+
});
|
|
1672
|
+
}
|
|
1673
|
+
return u;
|
|
1674
|
+
}).then((u) => P.mergeObjectSync(r, u)) : P.mergeObjectSync(r, c);
|
|
1675
|
+
}
|
|
1676
|
+
get shape() {
|
|
1677
|
+
return this._def.shape();
|
|
1678
|
+
}
|
|
1679
|
+
strict(e) {
|
|
1680
|
+
return p.errToObj, new C({
|
|
1681
|
+
...this._def,
|
|
1682
|
+
unknownKeys: "strict",
|
|
1683
|
+
...e !== void 0 ? {
|
|
1684
|
+
errorMap: (t, r) => {
|
|
1685
|
+
var a, i, o, c;
|
|
1686
|
+
const s = (o = (i = (a = this._def).errorMap) == null ? void 0 : i.call(a, t, r).message) != null ? o : r.defaultError;
|
|
1687
|
+
return t.code === "unrecognized_keys" ? {
|
|
1688
|
+
message: (c = p.errToObj(e).message) != null ? c : s
|
|
1689
|
+
} : {
|
|
1690
|
+
message: s
|
|
1691
|
+
};
|
|
1692
|
+
}
|
|
1693
|
+
} : {}
|
|
1694
|
+
});
|
|
1695
|
+
}
|
|
1696
|
+
strip() {
|
|
1697
|
+
return new C({
|
|
1698
|
+
...this._def,
|
|
1699
|
+
unknownKeys: "strip"
|
|
1700
|
+
});
|
|
1701
|
+
}
|
|
1702
|
+
passthrough() {
|
|
1703
|
+
return new C({
|
|
1704
|
+
...this._def,
|
|
1705
|
+
unknownKeys: "passthrough"
|
|
1706
|
+
});
|
|
1707
|
+
}
|
|
1708
|
+
// const AugmentFactory =
|
|
1709
|
+
// <Def extends ZodObjectDef>(def: Def) =>
|
|
1710
|
+
// <Augmentation extends ZodRawShape>(
|
|
1711
|
+
// augmentation: Augmentation
|
|
1712
|
+
// ): ZodObject<
|
|
1713
|
+
// extendShape<ReturnType<Def["shape"]>, Augmentation>,
|
|
1714
|
+
// Def["unknownKeys"],
|
|
1715
|
+
// Def["catchall"]
|
|
1716
|
+
// > => {
|
|
1717
|
+
// return new ZodObject({
|
|
1718
|
+
// ...def,
|
|
1719
|
+
// shape: () => ({
|
|
1720
|
+
// ...def.shape(),
|
|
1721
|
+
// ...augmentation,
|
|
1722
|
+
// }),
|
|
1723
|
+
// }) as any;
|
|
1724
|
+
// };
|
|
1725
|
+
extend(e) {
|
|
1726
|
+
return new C({
|
|
1727
|
+
...this._def,
|
|
1728
|
+
shape: () => ({
|
|
1729
|
+
...this._def.shape(),
|
|
1730
|
+
...e
|
|
1731
|
+
})
|
|
1732
|
+
});
|
|
1733
|
+
}
|
|
1734
|
+
/**
|
|
1735
|
+
* Prior to zod@1.0.12 there was a bug in the
|
|
1736
|
+
* inferred type of merged objects. Please
|
|
1737
|
+
* upgrade if you are experiencing issues.
|
|
1738
|
+
*/
|
|
1739
|
+
merge(e) {
|
|
1740
|
+
return new C({
|
|
1741
|
+
unknownKeys: e._def.unknownKeys,
|
|
1742
|
+
catchall: e._def.catchall,
|
|
1743
|
+
shape: () => ({
|
|
1744
|
+
...this._def.shape(),
|
|
1745
|
+
...e._def.shape()
|
|
1746
|
+
}),
|
|
1747
|
+
typeName: l.ZodObject
|
|
1748
|
+
});
|
|
1749
|
+
}
|
|
1750
|
+
// merge<
|
|
1751
|
+
// Incoming extends AnyZodObject,
|
|
1752
|
+
// Augmentation extends Incoming["shape"],
|
|
1753
|
+
// NewOutput extends {
|
|
1754
|
+
// [k in keyof Augmentation | keyof Output]: k extends keyof Augmentation
|
|
1755
|
+
// ? Augmentation[k]["_output"]
|
|
1756
|
+
// : k extends keyof Output
|
|
1757
|
+
// ? Output[k]
|
|
1758
|
+
// : never;
|
|
1759
|
+
// },
|
|
1760
|
+
// NewInput extends {
|
|
1761
|
+
// [k in keyof Augmentation | keyof Input]: k extends keyof Augmentation
|
|
1762
|
+
// ? Augmentation[k]["_input"]
|
|
1763
|
+
// : k extends keyof Input
|
|
1764
|
+
// ? Input[k]
|
|
1765
|
+
// : never;
|
|
1766
|
+
// }
|
|
1767
|
+
// >(
|
|
1768
|
+
// merging: Incoming
|
|
1769
|
+
// ): ZodObject<
|
|
1770
|
+
// extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
|
|
1771
|
+
// Incoming["_def"]["unknownKeys"],
|
|
1772
|
+
// Incoming["_def"]["catchall"],
|
|
1773
|
+
// NewOutput,
|
|
1774
|
+
// NewInput
|
|
1775
|
+
// > {
|
|
1776
|
+
// const merged: any = new ZodObject({
|
|
1777
|
+
// unknownKeys: merging._def.unknownKeys,
|
|
1778
|
+
// catchall: merging._def.catchall,
|
|
1779
|
+
// shape: () =>
|
|
1780
|
+
// objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
|
|
1781
|
+
// typeName: ZodFirstPartyTypeKind.ZodObject,
|
|
1782
|
+
// }) as any;
|
|
1783
|
+
// return merged;
|
|
1784
|
+
// }
|
|
1785
|
+
setKey(e, t) {
|
|
1786
|
+
return this.augment({ [e]: t });
|
|
1787
|
+
}
|
|
1788
|
+
// merge<Incoming extends AnyZodObject>(
|
|
1789
|
+
// merging: Incoming
|
|
1790
|
+
// ): //ZodObject<T & Incoming["_shape"], UnknownKeys, Catchall> = (merging) => {
|
|
1791
|
+
// ZodObject<
|
|
1792
|
+
// extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
|
|
1793
|
+
// Incoming["_def"]["unknownKeys"],
|
|
1794
|
+
// Incoming["_def"]["catchall"]
|
|
1795
|
+
// > {
|
|
1796
|
+
// // const mergedShape = objectUtil.mergeShapes(
|
|
1797
|
+
// // this._def.shape(),
|
|
1798
|
+
// // merging._def.shape()
|
|
1799
|
+
// // );
|
|
1800
|
+
// const merged: any = new ZodObject({
|
|
1801
|
+
// unknownKeys: merging._def.unknownKeys,
|
|
1802
|
+
// catchall: merging._def.catchall,
|
|
1803
|
+
// shape: () =>
|
|
1804
|
+
// objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
|
|
1805
|
+
// typeName: ZodFirstPartyTypeKind.ZodObject,
|
|
1806
|
+
// }) as any;
|
|
1807
|
+
// return merged;
|
|
1808
|
+
// }
|
|
1809
|
+
catchall(e) {
|
|
1810
|
+
return new C({
|
|
1811
|
+
...this._def,
|
|
1812
|
+
catchall: e
|
|
1813
|
+
});
|
|
1814
|
+
}
|
|
1815
|
+
pick(e) {
|
|
1816
|
+
const t = {};
|
|
1817
|
+
for (const r of k.objectKeys(e))
|
|
1818
|
+
e[r] && this.shape[r] && (t[r] = this.shape[r]);
|
|
1819
|
+
return new C({
|
|
1820
|
+
...this._def,
|
|
1821
|
+
shape: () => t
|
|
1822
|
+
});
|
|
1823
|
+
}
|
|
1824
|
+
omit(e) {
|
|
1825
|
+
const t = {};
|
|
1826
|
+
for (const r of k.objectKeys(this.shape))
|
|
1827
|
+
e[r] || (t[r] = this.shape[r]);
|
|
1828
|
+
return new C({
|
|
1829
|
+
...this._def,
|
|
1830
|
+
shape: () => t
|
|
1831
|
+
});
|
|
1832
|
+
}
|
|
1833
|
+
/**
|
|
1834
|
+
* @deprecated
|
|
1835
|
+
*/
|
|
1836
|
+
deepPartial() {
|
|
1837
|
+
return te(this);
|
|
1838
|
+
}
|
|
1839
|
+
partial(e) {
|
|
1840
|
+
const t = {};
|
|
1841
|
+
for (const r of k.objectKeys(this.shape)) {
|
|
1842
|
+
const s = this.shape[r];
|
|
1843
|
+
e && !e[r] ? t[r] = s : t[r] = s.optional();
|
|
1844
|
+
}
|
|
1845
|
+
return new C({
|
|
1846
|
+
...this._def,
|
|
1847
|
+
shape: () => t
|
|
1848
|
+
});
|
|
1849
|
+
}
|
|
1850
|
+
required(e) {
|
|
1851
|
+
const t = {};
|
|
1852
|
+
for (const r of k.objectKeys(this.shape))
|
|
1853
|
+
if (e && !e[r])
|
|
1854
|
+
t[r] = this.shape[r];
|
|
1855
|
+
else {
|
|
1856
|
+
let a = this.shape[r];
|
|
1857
|
+
for (; a instanceof H; )
|
|
1858
|
+
a = a._def.innerType;
|
|
1859
|
+
t[r] = a;
|
|
1860
|
+
}
|
|
1861
|
+
return new C({
|
|
1862
|
+
...this._def,
|
|
1863
|
+
shape: () => t
|
|
1864
|
+
});
|
|
1865
|
+
}
|
|
1866
|
+
keyof() {
|
|
1867
|
+
return Mt(k.objectKeys(this.shape));
|
|
1868
|
+
}
|
|
1869
|
+
}
|
|
1870
|
+
C.create = (n, e) => new C({
|
|
1871
|
+
shape: () => n,
|
|
1872
|
+
unknownKeys: "strip",
|
|
1873
|
+
catchall: Y.create(),
|
|
1874
|
+
typeName: l.ZodObject,
|
|
1875
|
+
..._(e)
|
|
1876
|
+
});
|
|
1877
|
+
C.strictCreate = (n, e) => new C({
|
|
1878
|
+
shape: () => n,
|
|
1879
|
+
unknownKeys: "strict",
|
|
1880
|
+
catchall: Y.create(),
|
|
1881
|
+
typeName: l.ZodObject,
|
|
1882
|
+
..._(e)
|
|
1883
|
+
});
|
|
1884
|
+
C.lazycreate = (n, e) => new C({
|
|
1885
|
+
shape: n,
|
|
1886
|
+
unknownKeys: "strip",
|
|
1887
|
+
catchall: Y.create(),
|
|
1888
|
+
typeName: l.ZodObject,
|
|
1889
|
+
..._(e)
|
|
1890
|
+
});
|
|
1891
|
+
class xe extends b {
|
|
1892
|
+
_parse(e) {
|
|
1893
|
+
const { ctx: t } = this._processInputParams(e), r = this._def.options;
|
|
1894
|
+
function s(a) {
|
|
1895
|
+
for (const o of a)
|
|
1896
|
+
if (o.result.status === "valid")
|
|
1897
|
+
return o.result;
|
|
1898
|
+
for (const o of a)
|
|
1899
|
+
if (o.result.status === "dirty")
|
|
1900
|
+
return t.common.issues.push(...o.ctx.common.issues), o.result;
|
|
1901
|
+
const i = a.map((o) => new z(o.ctx.common.issues));
|
|
1902
|
+
return f(t, {
|
|
1903
|
+
code: d.invalid_union,
|
|
1904
|
+
unionErrors: i
|
|
1905
|
+
}), g;
|
|
1906
|
+
}
|
|
1907
|
+
if (t.common.async)
|
|
1908
|
+
return Promise.all(r.map(async (a) => {
|
|
1909
|
+
const i = {
|
|
1910
|
+
...t,
|
|
1911
|
+
common: {
|
|
1912
|
+
...t.common,
|
|
1913
|
+
issues: []
|
|
1914
|
+
},
|
|
1915
|
+
parent: null
|
|
1916
|
+
};
|
|
1917
|
+
return {
|
|
1918
|
+
result: await a._parseAsync({
|
|
1919
|
+
data: t.data,
|
|
1920
|
+
path: t.path,
|
|
1921
|
+
parent: i
|
|
1922
|
+
}),
|
|
1923
|
+
ctx: i
|
|
1924
|
+
};
|
|
1925
|
+
})).then(s);
|
|
1926
|
+
{
|
|
1927
|
+
let a;
|
|
1928
|
+
const i = [];
|
|
1929
|
+
for (const c of r) {
|
|
1930
|
+
const u = {
|
|
1931
|
+
...t,
|
|
1932
|
+
common: {
|
|
1933
|
+
...t.common,
|
|
1934
|
+
issues: []
|
|
1935
|
+
},
|
|
1936
|
+
parent: null
|
|
1937
|
+
}, y = c._parseSync({
|
|
1938
|
+
data: t.data,
|
|
1939
|
+
path: t.path,
|
|
1940
|
+
parent: u
|
|
1941
|
+
});
|
|
1942
|
+
if (y.status === "valid")
|
|
1943
|
+
return y;
|
|
1944
|
+
y.status === "dirty" && !a && (a = { result: y, ctx: u }), u.common.issues.length && i.push(u.common.issues);
|
|
1945
|
+
}
|
|
1946
|
+
if (a)
|
|
1947
|
+
return t.common.issues.push(...a.ctx.common.issues), a.result;
|
|
1948
|
+
const o = i.map((c) => new z(c));
|
|
1949
|
+
return f(t, {
|
|
1950
|
+
code: d.invalid_union,
|
|
1951
|
+
unionErrors: o
|
|
1952
|
+
}), g;
|
|
1953
|
+
}
|
|
1954
|
+
}
|
|
1955
|
+
get options() {
|
|
1956
|
+
return this._def.options;
|
|
1957
|
+
}
|
|
1958
|
+
}
|
|
1959
|
+
xe.create = (n, e) => new xe({
|
|
1960
|
+
options: n,
|
|
1961
|
+
typeName: l.ZodUnion,
|
|
1962
|
+
..._(e)
|
|
1963
|
+
});
|
|
1964
|
+
function Ke(n, e) {
|
|
1965
|
+
const t = q(n), r = q(e);
|
|
1966
|
+
if (n === e)
|
|
1967
|
+
return { valid: !0, data: n };
|
|
1968
|
+
if (t === h.object && r === h.object) {
|
|
1969
|
+
const s = k.objectKeys(e), a = k.objectKeys(n).filter((o) => s.indexOf(o) !== -1), i = { ...n, ...e };
|
|
1970
|
+
for (const o of a) {
|
|
1971
|
+
const c = Ke(n[o], e[o]);
|
|
1972
|
+
if (!c.valid)
|
|
1973
|
+
return { valid: !1 };
|
|
1974
|
+
i[o] = c.data;
|
|
1975
|
+
}
|
|
1976
|
+
return { valid: !0, data: i };
|
|
1977
|
+
} else if (t === h.array && r === h.array) {
|
|
1978
|
+
if (n.length !== e.length)
|
|
1979
|
+
return { valid: !1 };
|
|
1980
|
+
const s = [];
|
|
1981
|
+
for (let a = 0; a < n.length; a++) {
|
|
1982
|
+
const i = n[a], o = e[a], c = Ke(i, o);
|
|
1983
|
+
if (!c.valid)
|
|
1984
|
+
return { valid: !1 };
|
|
1985
|
+
s.push(c.data);
|
|
1986
|
+
}
|
|
1987
|
+
return { valid: !0, data: s };
|
|
1988
|
+
} else
|
|
1989
|
+
return t === h.date && r === h.date && +n == +e ? { valid: !0, data: n } : { valid: !1 };
|
|
1990
|
+
}
|
|
1991
|
+
class we extends b {
|
|
1992
|
+
_parse(e) {
|
|
1993
|
+
const { status: t, ctx: r } = this._processInputParams(e), s = (a, i) => {
|
|
1994
|
+
if (yt(a) || yt(i))
|
|
1995
|
+
return g;
|
|
1996
|
+
const o = Ke(a.value, i.value);
|
|
1997
|
+
return o.valid ? ((gt(a) || gt(i)) && t.dirty(), { status: t.value, value: o.data }) : (f(r, {
|
|
1998
|
+
code: d.invalid_intersection_types
|
|
1999
|
+
}), g);
|
|
2000
|
+
};
|
|
2001
|
+
return r.common.async ? Promise.all([
|
|
2002
|
+
this._def.left._parseAsync({
|
|
2003
|
+
data: r.data,
|
|
2004
|
+
path: r.path,
|
|
2005
|
+
parent: r
|
|
2006
|
+
}),
|
|
2007
|
+
this._def.right._parseAsync({
|
|
2008
|
+
data: r.data,
|
|
2009
|
+
path: r.path,
|
|
2010
|
+
parent: r
|
|
2011
|
+
})
|
|
2012
|
+
]).then(([a, i]) => s(a, i)) : s(this._def.left._parseSync({
|
|
2013
|
+
data: r.data,
|
|
2014
|
+
path: r.path,
|
|
2015
|
+
parent: r
|
|
2016
|
+
}), this._def.right._parseSync({
|
|
2017
|
+
data: r.data,
|
|
2018
|
+
path: r.path,
|
|
2019
|
+
parent: r
|
|
2020
|
+
}));
|
|
2021
|
+
}
|
|
2022
|
+
}
|
|
2023
|
+
we.create = (n, e, t) => new we({
|
|
2024
|
+
left: n,
|
|
2025
|
+
right: e,
|
|
2026
|
+
typeName: l.ZodIntersection,
|
|
2027
|
+
..._(t)
|
|
2028
|
+
});
|
|
2029
|
+
class Q extends b {
|
|
2030
|
+
_parse(e) {
|
|
2031
|
+
const { status: t, ctx: r } = this._processInputParams(e);
|
|
2032
|
+
if (r.parsedType !== h.array)
|
|
2033
|
+
return f(r, {
|
|
2034
|
+
code: d.invalid_type,
|
|
2035
|
+
expected: h.array,
|
|
2036
|
+
received: r.parsedType
|
|
2037
|
+
}), g;
|
|
2038
|
+
if (r.data.length < this._def.items.length)
|
|
2039
|
+
return f(r, {
|
|
2040
|
+
code: d.too_small,
|
|
2041
|
+
minimum: this._def.items.length,
|
|
2042
|
+
inclusive: !0,
|
|
2043
|
+
exact: !1,
|
|
2044
|
+
type: "array"
|
|
2045
|
+
}), g;
|
|
2046
|
+
!this._def.rest && r.data.length > this._def.items.length && (f(r, {
|
|
2047
|
+
code: d.too_big,
|
|
2048
|
+
maximum: this._def.items.length,
|
|
2049
|
+
inclusive: !0,
|
|
2050
|
+
exact: !1,
|
|
2051
|
+
type: "array"
|
|
2052
|
+
}), t.dirty());
|
|
2053
|
+
const a = [...r.data].map((i, o) => {
|
|
2054
|
+
const c = this._def.items[o] || this._def.rest;
|
|
2055
|
+
return c ? c._parse(new V(r, i, r.path, o)) : null;
|
|
2056
|
+
}).filter((i) => !!i);
|
|
2057
|
+
return r.common.async ? Promise.all(a).then((i) => P.mergeArray(t, i)) : P.mergeArray(t, a);
|
|
2058
|
+
}
|
|
2059
|
+
get items() {
|
|
2060
|
+
return this._def.items;
|
|
2061
|
+
}
|
|
2062
|
+
rest(e) {
|
|
2063
|
+
return new Q({
|
|
2064
|
+
...this._def,
|
|
2065
|
+
rest: e
|
|
2066
|
+
});
|
|
2067
|
+
}
|
|
2068
|
+
}
|
|
2069
|
+
Q.create = (n, e) => {
|
|
2070
|
+
if (!Array.isArray(n))
|
|
2071
|
+
throw new Error("You must pass an array of schemas to z.tuple([ ... ])");
|
|
2072
|
+
return new Q({
|
|
2073
|
+
items: n,
|
|
2074
|
+
typeName: l.ZodTuple,
|
|
2075
|
+
rest: null,
|
|
2076
|
+
..._(e)
|
|
2077
|
+
});
|
|
2078
|
+
};
|
|
2079
|
+
class Se extends b {
|
|
2080
|
+
get keySchema() {
|
|
2081
|
+
return this._def.keyType;
|
|
2082
|
+
}
|
|
2083
|
+
get valueSchema() {
|
|
2084
|
+
return this._def.valueType;
|
|
2085
|
+
}
|
|
2086
|
+
_parse(e) {
|
|
2087
|
+
const { status: t, ctx: r } = this._processInputParams(e);
|
|
2088
|
+
if (r.parsedType !== h.object)
|
|
2089
|
+
return f(r, {
|
|
2090
|
+
code: d.invalid_type,
|
|
2091
|
+
expected: h.object,
|
|
2092
|
+
received: r.parsedType
|
|
2093
|
+
}), g;
|
|
2094
|
+
const s = [], a = this._def.keyType, i = this._def.valueType;
|
|
2095
|
+
for (const o in r.data)
|
|
2096
|
+
s.push({
|
|
2097
|
+
key: a._parse(new V(r, o, r.path, o)),
|
|
2098
|
+
value: i._parse(new V(r, r.data[o], r.path, o)),
|
|
2099
|
+
alwaysSet: o in r.data
|
|
2100
|
+
});
|
|
2101
|
+
return r.common.async ? P.mergeObjectAsync(t, s) : P.mergeObjectSync(t, s);
|
|
2102
|
+
}
|
|
2103
|
+
get element() {
|
|
2104
|
+
return this._def.valueType;
|
|
2105
|
+
}
|
|
2106
|
+
static create(e, t, r) {
|
|
2107
|
+
return t instanceof b ? new Se({
|
|
2108
|
+
keyType: e,
|
|
2109
|
+
valueType: t,
|
|
2110
|
+
typeName: l.ZodRecord,
|
|
2111
|
+
..._(r)
|
|
2112
|
+
}) : new Se({
|
|
2113
|
+
keyType: F.create(),
|
|
2114
|
+
valueType: e,
|
|
2115
|
+
typeName: l.ZodRecord,
|
|
2116
|
+
..._(t)
|
|
2117
|
+
});
|
|
2118
|
+
}
|
|
2119
|
+
}
|
|
2120
|
+
class Xe extends b {
|
|
2121
|
+
get keySchema() {
|
|
2122
|
+
return this._def.keyType;
|
|
2123
|
+
}
|
|
2124
|
+
get valueSchema() {
|
|
2125
|
+
return this._def.valueType;
|
|
2126
|
+
}
|
|
2127
|
+
_parse(e) {
|
|
2128
|
+
const { status: t, ctx: r } = this._processInputParams(e);
|
|
2129
|
+
if (r.parsedType !== h.map)
|
|
2130
|
+
return f(r, {
|
|
2131
|
+
code: d.invalid_type,
|
|
2132
|
+
expected: h.map,
|
|
2133
|
+
received: r.parsedType
|
|
2134
|
+
}), g;
|
|
2135
|
+
const s = this._def.keyType, a = this._def.valueType, i = [...r.data.entries()].map(([o, c], u) => ({
|
|
2136
|
+
key: s._parse(new V(r, o, r.path, [u, "key"])),
|
|
2137
|
+
value: a._parse(new V(r, c, r.path, [u, "value"]))
|
|
2138
|
+
}));
|
|
2139
|
+
if (r.common.async) {
|
|
2140
|
+
const o = /* @__PURE__ */ new Map();
|
|
2141
|
+
return Promise.resolve().then(async () => {
|
|
2142
|
+
for (const c of i) {
|
|
2143
|
+
const u = await c.key, y = await c.value;
|
|
2144
|
+
if (u.status === "aborted" || y.status === "aborted")
|
|
2145
|
+
return g;
|
|
2146
|
+
(u.status === "dirty" || y.status === "dirty") && t.dirty(), o.set(u.value, y.value);
|
|
2147
|
+
}
|
|
2148
|
+
return { status: t.value, value: o };
|
|
2149
|
+
});
|
|
2150
|
+
} else {
|
|
2151
|
+
const o = /* @__PURE__ */ new Map();
|
|
2152
|
+
for (const c of i) {
|
|
2153
|
+
const u = c.key, y = c.value;
|
|
2154
|
+
if (u.status === "aborted" || y.status === "aborted")
|
|
2155
|
+
return g;
|
|
2156
|
+
(u.status === "dirty" || y.status === "dirty") && t.dirty(), o.set(u.value, y.value);
|
|
2157
|
+
}
|
|
2158
|
+
return { status: t.value, value: o };
|
|
2159
|
+
}
|
|
2160
|
+
}
|
|
2161
|
+
}
|
|
2162
|
+
Xe.create = (n, e, t) => new Xe({
|
|
2163
|
+
valueType: e,
|
|
2164
|
+
keyType: n,
|
|
2165
|
+
typeName: l.ZodMap,
|
|
2166
|
+
..._(t)
|
|
2167
|
+
});
|
|
2168
|
+
class ie extends b {
|
|
2169
|
+
_parse(e) {
|
|
2170
|
+
const { status: t, ctx: r } = this._processInputParams(e);
|
|
2171
|
+
if (r.parsedType !== h.set)
|
|
2172
|
+
return f(r, {
|
|
2173
|
+
code: d.invalid_type,
|
|
2174
|
+
expected: h.set,
|
|
2175
|
+
received: r.parsedType
|
|
2176
|
+
}), g;
|
|
2177
|
+
const s = this._def;
|
|
2178
|
+
s.minSize !== null && r.data.size < s.minSize.value && (f(r, {
|
|
2179
|
+
code: d.too_small,
|
|
2180
|
+
minimum: s.minSize.value,
|
|
2181
|
+
type: "set",
|
|
2182
|
+
inclusive: !0,
|
|
2183
|
+
exact: !1,
|
|
2184
|
+
message: s.minSize.message
|
|
2185
|
+
}), t.dirty()), s.maxSize !== null && r.data.size > s.maxSize.value && (f(r, {
|
|
2186
|
+
code: d.too_big,
|
|
2187
|
+
maximum: s.maxSize.value,
|
|
2188
|
+
type: "set",
|
|
2189
|
+
inclusive: !0,
|
|
2190
|
+
exact: !1,
|
|
2191
|
+
message: s.maxSize.message
|
|
2192
|
+
}), t.dirty());
|
|
2193
|
+
const a = this._def.valueType;
|
|
2194
|
+
function i(c) {
|
|
2195
|
+
const u = /* @__PURE__ */ new Set();
|
|
2196
|
+
for (const y of c) {
|
|
2197
|
+
if (y.status === "aborted")
|
|
2198
|
+
return g;
|
|
2199
|
+
y.status === "dirty" && t.dirty(), u.add(y.value);
|
|
2200
|
+
}
|
|
2201
|
+
return { status: t.value, value: u };
|
|
2202
|
+
}
|
|
2203
|
+
const o = [...r.data.values()].map((c, u) => a._parse(new V(r, c, r.path, u)));
|
|
2204
|
+
return r.common.async ? Promise.all(o).then((c) => i(c)) : i(o);
|
|
2205
|
+
}
|
|
2206
|
+
min(e, t) {
|
|
2207
|
+
return new ie({
|
|
2208
|
+
...this._def,
|
|
2209
|
+
minSize: { value: e, message: p.toString(t) }
|
|
2210
|
+
});
|
|
2211
|
+
}
|
|
2212
|
+
max(e, t) {
|
|
2213
|
+
return new ie({
|
|
2214
|
+
...this._def,
|
|
2215
|
+
maxSize: { value: e, message: p.toString(t) }
|
|
2216
|
+
});
|
|
2217
|
+
}
|
|
2218
|
+
size(e, t) {
|
|
2219
|
+
return this.min(e, t).max(e, t);
|
|
2220
|
+
}
|
|
2221
|
+
nonempty(e) {
|
|
2222
|
+
return this.min(1, e);
|
|
2223
|
+
}
|
|
2224
|
+
}
|
|
2225
|
+
ie.create = (n, e) => new ie({
|
|
2226
|
+
valueType: n,
|
|
2227
|
+
minSize: null,
|
|
2228
|
+
maxSize: null,
|
|
2229
|
+
typeName: l.ZodSet,
|
|
2230
|
+
..._(e)
|
|
2231
|
+
});
|
|
2232
|
+
class Qe extends b {
|
|
2233
|
+
get schema() {
|
|
2234
|
+
return this._def.getter();
|
|
2235
|
+
}
|
|
2236
|
+
_parse(e) {
|
|
2237
|
+
const { ctx: t } = this._processInputParams(e);
|
|
2238
|
+
return this._def.getter()._parse({ data: t.data, path: t.path, parent: t });
|
|
2239
|
+
}
|
|
2240
|
+
}
|
|
2241
|
+
Qe.create = (n, e) => new Qe({
|
|
2242
|
+
getter: n,
|
|
2243
|
+
typeName: l.ZodLazy,
|
|
2244
|
+
..._(e)
|
|
2245
|
+
});
|
|
2246
|
+
class et extends b {
|
|
2247
|
+
_parse(e) {
|
|
2248
|
+
if (e.data !== this._def.value) {
|
|
2249
|
+
const t = this._getOrReturnCtx(e);
|
|
2250
|
+
return f(t, {
|
|
2251
|
+
received: t.data,
|
|
2252
|
+
code: d.invalid_literal,
|
|
2253
|
+
expected: this._def.value
|
|
2254
|
+
}), g;
|
|
2255
|
+
}
|
|
2256
|
+
return { status: "valid", value: e.data };
|
|
2257
|
+
}
|
|
2258
|
+
get value() {
|
|
2259
|
+
return this._def.value;
|
|
2260
|
+
}
|
|
2261
|
+
}
|
|
2262
|
+
et.create = (n, e) => new et({
|
|
2263
|
+
value: n,
|
|
2264
|
+
typeName: l.ZodLiteral,
|
|
2265
|
+
..._(e)
|
|
2266
|
+
});
|
|
2267
|
+
function Mt(n, e) {
|
|
2268
|
+
return new oe({
|
|
2269
|
+
values: n,
|
|
2270
|
+
typeName: l.ZodEnum,
|
|
2271
|
+
..._(e)
|
|
2272
|
+
});
|
|
2273
|
+
}
|
|
2274
|
+
class oe extends b {
|
|
2275
|
+
_parse(e) {
|
|
2276
|
+
if (typeof e.data != "string") {
|
|
2277
|
+
const t = this._getOrReturnCtx(e), r = this._def.values;
|
|
2278
|
+
return f(t, {
|
|
2279
|
+
expected: k.joinValues(r),
|
|
2280
|
+
received: t.parsedType,
|
|
2281
|
+
code: d.invalid_type
|
|
2282
|
+
}), g;
|
|
2283
|
+
}
|
|
2284
|
+
if (this._cache || (this._cache = new Set(this._def.values)), !this._cache.has(e.data)) {
|
|
2285
|
+
const t = this._getOrReturnCtx(e), r = this._def.values;
|
|
2286
|
+
return f(t, {
|
|
2287
|
+
received: t.data,
|
|
2288
|
+
code: d.invalid_enum_value,
|
|
2289
|
+
options: r
|
|
2290
|
+
}), g;
|
|
2291
|
+
}
|
|
2292
|
+
return E(e.data);
|
|
2293
|
+
}
|
|
2294
|
+
get options() {
|
|
2295
|
+
return this._def.values;
|
|
2296
|
+
}
|
|
2297
|
+
get enum() {
|
|
2298
|
+
const e = {};
|
|
2299
|
+
for (const t of this._def.values)
|
|
2300
|
+
e[t] = t;
|
|
2301
|
+
return e;
|
|
2302
|
+
}
|
|
2303
|
+
get Values() {
|
|
2304
|
+
const e = {};
|
|
2305
|
+
for (const t of this._def.values)
|
|
2306
|
+
e[t] = t;
|
|
2307
|
+
return e;
|
|
2308
|
+
}
|
|
2309
|
+
get Enum() {
|
|
2310
|
+
const e = {};
|
|
2311
|
+
for (const t of this._def.values)
|
|
2312
|
+
e[t] = t;
|
|
2313
|
+
return e;
|
|
2314
|
+
}
|
|
2315
|
+
extract(e, t = this._def) {
|
|
2316
|
+
return oe.create(e, {
|
|
2317
|
+
...this._def,
|
|
2318
|
+
...t
|
|
2319
|
+
});
|
|
2320
|
+
}
|
|
2321
|
+
exclude(e, t = this._def) {
|
|
2322
|
+
return oe.create(this.options.filter((r) => !e.includes(r)), {
|
|
2323
|
+
...this._def,
|
|
2324
|
+
...t
|
|
2325
|
+
});
|
|
2326
|
+
}
|
|
2327
|
+
}
|
|
2328
|
+
oe.create = Mt;
|
|
2329
|
+
class tt extends b {
|
|
2330
|
+
_parse(e) {
|
|
2331
|
+
const t = k.getValidEnumValues(this._def.values), r = this._getOrReturnCtx(e);
|
|
2332
|
+
if (r.parsedType !== h.string && r.parsedType !== h.number) {
|
|
2333
|
+
const s = k.objectValues(t);
|
|
2334
|
+
return f(r, {
|
|
2335
|
+
expected: k.joinValues(s),
|
|
2336
|
+
received: r.parsedType,
|
|
2337
|
+
code: d.invalid_type
|
|
2338
|
+
}), g;
|
|
2339
|
+
}
|
|
2340
|
+
if (this._cache || (this._cache = new Set(k.getValidEnumValues(this._def.values))), !this._cache.has(e.data)) {
|
|
2341
|
+
const s = k.objectValues(t);
|
|
2342
|
+
return f(r, {
|
|
2343
|
+
received: r.data,
|
|
2344
|
+
code: d.invalid_enum_value,
|
|
2345
|
+
options: s
|
|
2346
|
+
}), g;
|
|
2347
|
+
}
|
|
2348
|
+
return E(e.data);
|
|
2349
|
+
}
|
|
2350
|
+
get enum() {
|
|
2351
|
+
return this._def.values;
|
|
2352
|
+
}
|
|
2353
|
+
}
|
|
2354
|
+
tt.create = (n, e) => new tt({
|
|
2355
|
+
values: n,
|
|
2356
|
+
typeName: l.ZodNativeEnum,
|
|
2357
|
+
..._(e)
|
|
2358
|
+
});
|
|
2359
|
+
class Ae extends b {
|
|
2360
|
+
unwrap() {
|
|
2361
|
+
return this._def.type;
|
|
2362
|
+
}
|
|
2363
|
+
_parse(e) {
|
|
2364
|
+
const { ctx: t } = this._processInputParams(e);
|
|
2365
|
+
if (t.parsedType !== h.promise && t.common.async === !1)
|
|
2366
|
+
return f(t, {
|
|
2367
|
+
code: d.invalid_type,
|
|
2368
|
+
expected: h.promise,
|
|
2369
|
+
received: t.parsedType
|
|
2370
|
+
}), g;
|
|
2371
|
+
const r = t.parsedType === h.promise ? t.data : Promise.resolve(t.data);
|
|
2372
|
+
return E(r.then((s) => this._def.type.parseAsync(s, {
|
|
2373
|
+
path: t.path,
|
|
2374
|
+
errorMap: t.common.contextualErrorMap
|
|
2375
|
+
})));
|
|
2376
|
+
}
|
|
2377
|
+
}
|
|
2378
|
+
Ae.create = (n, e) => new Ae({
|
|
2379
|
+
type: n,
|
|
2380
|
+
typeName: l.ZodPromise,
|
|
2381
|
+
..._(e)
|
|
2382
|
+
});
|
|
2383
|
+
class K extends b {
|
|
2384
|
+
innerType() {
|
|
2385
|
+
return this._def.schema;
|
|
2386
|
+
}
|
|
2387
|
+
sourceType() {
|
|
2388
|
+
return this._def.schema._def.typeName === l.ZodEffects ? this._def.schema.sourceType() : this._def.schema;
|
|
2389
|
+
}
|
|
2390
|
+
_parse(e) {
|
|
2391
|
+
const { status: t, ctx: r } = this._processInputParams(e), s = this._def.effect || null, a = {
|
|
2392
|
+
addIssue: (i) => {
|
|
2393
|
+
f(r, i), i.fatal ? t.abort() : t.dirty();
|
|
2394
|
+
},
|
|
2395
|
+
get path() {
|
|
2396
|
+
return r.path;
|
|
2397
|
+
}
|
|
2398
|
+
};
|
|
2399
|
+
if (a.addIssue = a.addIssue.bind(a), s.type === "preprocess") {
|
|
2400
|
+
const i = s.transform(r.data, a);
|
|
2401
|
+
if (r.common.async)
|
|
2402
|
+
return Promise.resolve(i).then(async (o) => {
|
|
2403
|
+
if (t.value === "aborted")
|
|
2404
|
+
return g;
|
|
2405
|
+
const c = await this._def.schema._parseAsync({
|
|
2406
|
+
data: o,
|
|
2407
|
+
path: r.path,
|
|
2408
|
+
parent: r
|
|
2409
|
+
});
|
|
2410
|
+
return c.status === "aborted" ? g : c.status === "dirty" || t.value === "dirty" ? fe(c.value) : c;
|
|
2411
|
+
});
|
|
2412
|
+
{
|
|
2413
|
+
if (t.value === "aborted")
|
|
2414
|
+
return g;
|
|
2415
|
+
const o = this._def.schema._parseSync({
|
|
2416
|
+
data: i,
|
|
2417
|
+
path: r.path,
|
|
2418
|
+
parent: r
|
|
2419
|
+
});
|
|
2420
|
+
return o.status === "aborted" ? g : o.status === "dirty" || t.value === "dirty" ? fe(o.value) : o;
|
|
2421
|
+
}
|
|
2422
|
+
}
|
|
2423
|
+
if (s.type === "refinement") {
|
|
2424
|
+
const i = (o) => {
|
|
2425
|
+
const c = s.refinement(o, a);
|
|
2426
|
+
if (r.common.async)
|
|
2427
|
+
return Promise.resolve(c);
|
|
2428
|
+
if (c instanceof Promise)
|
|
2429
|
+
throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");
|
|
2430
|
+
return o;
|
|
2431
|
+
};
|
|
2432
|
+
if (r.common.async === !1) {
|
|
2433
|
+
const o = this._def.schema._parseSync({
|
|
2434
|
+
data: r.data,
|
|
2435
|
+
path: r.path,
|
|
2436
|
+
parent: r
|
|
2437
|
+
});
|
|
2438
|
+
return o.status === "aborted" ? g : (o.status === "dirty" && t.dirty(), i(o.value), { status: t.value, value: o.value });
|
|
2439
|
+
} else
|
|
2440
|
+
return this._def.schema._parseAsync({ data: r.data, path: r.path, parent: r }).then((o) => o.status === "aborted" ? g : (o.status === "dirty" && t.dirty(), i(o.value).then(() => ({ status: t.value, value: o.value }))));
|
|
2441
|
+
}
|
|
2442
|
+
if (s.type === "transform")
|
|
2443
|
+
if (r.common.async === !1) {
|
|
2444
|
+
const i = this._def.schema._parseSync({
|
|
2445
|
+
data: r.data,
|
|
2446
|
+
path: r.path,
|
|
2447
|
+
parent: r
|
|
2448
|
+
});
|
|
2449
|
+
if (!re(i))
|
|
2450
|
+
return g;
|
|
2451
|
+
const o = s.transform(i.value, a);
|
|
2452
|
+
if (o instanceof Promise)
|
|
2453
|
+
throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");
|
|
2454
|
+
return { status: t.value, value: o };
|
|
2455
|
+
} else
|
|
2456
|
+
return this._def.schema._parseAsync({ data: r.data, path: r.path, parent: r }).then((i) => re(i) ? Promise.resolve(s.transform(i.value, a)).then((o) => ({
|
|
2457
|
+
status: t.value,
|
|
2458
|
+
value: o
|
|
2459
|
+
})) : g);
|
|
2460
|
+
k.assertNever(s);
|
|
2461
|
+
}
|
|
2462
|
+
}
|
|
2463
|
+
K.create = (n, e, t) => new K({
|
|
2464
|
+
schema: n,
|
|
2465
|
+
typeName: l.ZodEffects,
|
|
2466
|
+
effect: e,
|
|
2467
|
+
..._(t)
|
|
2468
|
+
});
|
|
2469
|
+
K.createWithPreprocess = (n, e, t) => new K({
|
|
2470
|
+
schema: e,
|
|
2471
|
+
effect: { type: "preprocess", transform: n },
|
|
2472
|
+
typeName: l.ZodEffects,
|
|
2473
|
+
..._(t)
|
|
2474
|
+
});
|
|
2475
|
+
class H extends b {
|
|
2476
|
+
_parse(e) {
|
|
2477
|
+
return this._getType(e) === h.undefined ? E(void 0) : this._def.innerType._parse(e);
|
|
2478
|
+
}
|
|
2479
|
+
unwrap() {
|
|
2480
|
+
return this._def.innerType;
|
|
2481
|
+
}
|
|
2482
|
+
}
|
|
2483
|
+
H.create = (n, e) => new H({
|
|
2484
|
+
innerType: n,
|
|
2485
|
+
typeName: l.ZodOptional,
|
|
2486
|
+
..._(e)
|
|
2487
|
+
});
|
|
2488
|
+
class ce extends b {
|
|
2489
|
+
_parse(e) {
|
|
2490
|
+
return this._getType(e) === h.null ? E(null) : this._def.innerType._parse(e);
|
|
2491
|
+
}
|
|
2492
|
+
unwrap() {
|
|
2493
|
+
return this._def.innerType;
|
|
2494
|
+
}
|
|
2495
|
+
}
|
|
2496
|
+
ce.create = (n, e) => new ce({
|
|
2497
|
+
innerType: n,
|
|
2498
|
+
typeName: l.ZodNullable,
|
|
2499
|
+
..._(e)
|
|
2500
|
+
});
|
|
2501
|
+
class nt extends b {
|
|
2502
|
+
_parse(e) {
|
|
2503
|
+
const { ctx: t } = this._processInputParams(e);
|
|
2504
|
+
let r = t.data;
|
|
2505
|
+
return t.parsedType === h.undefined && (r = this._def.defaultValue()), this._def.innerType._parse({
|
|
2506
|
+
data: r,
|
|
2507
|
+
path: t.path,
|
|
2508
|
+
parent: t
|
|
2509
|
+
});
|
|
2510
|
+
}
|
|
2511
|
+
removeDefault() {
|
|
2512
|
+
return this._def.innerType;
|
|
2513
|
+
}
|
|
2514
|
+
}
|
|
2515
|
+
nt.create = (n, e) => new nt({
|
|
2516
|
+
innerType: n,
|
|
2517
|
+
typeName: l.ZodDefault,
|
|
2518
|
+
defaultValue: typeof e.default == "function" ? e.default : () => e.default,
|
|
2519
|
+
..._(e)
|
|
2520
|
+
});
|
|
2521
|
+
class rt extends b {
|
|
2522
|
+
_parse(e) {
|
|
2523
|
+
const { ctx: t } = this._processInputParams(e), r = {
|
|
2524
|
+
...t,
|
|
2525
|
+
common: {
|
|
2526
|
+
...t.common,
|
|
2527
|
+
issues: []
|
|
2528
|
+
}
|
|
2529
|
+
}, s = this._def.innerType._parse({
|
|
2530
|
+
data: r.data,
|
|
2531
|
+
path: r.path,
|
|
2532
|
+
parent: {
|
|
2533
|
+
...r
|
|
2534
|
+
}
|
|
2535
|
+
});
|
|
2536
|
+
return ke(s) ? s.then((a) => ({
|
|
2537
|
+
status: "valid",
|
|
2538
|
+
value: a.status === "valid" ? a.value : this._def.catchValue({
|
|
2539
|
+
get error() {
|
|
2540
|
+
return new z(r.common.issues);
|
|
2541
|
+
},
|
|
2542
|
+
input: r.data
|
|
2543
|
+
})
|
|
2544
|
+
})) : {
|
|
2545
|
+
status: "valid",
|
|
2546
|
+
value: s.status === "valid" ? s.value : this._def.catchValue({
|
|
2547
|
+
get error() {
|
|
2548
|
+
return new z(r.common.issues);
|
|
2549
|
+
},
|
|
2550
|
+
input: r.data
|
|
2551
|
+
})
|
|
2552
|
+
};
|
|
2553
|
+
}
|
|
2554
|
+
removeCatch() {
|
|
2555
|
+
return this._def.innerType;
|
|
2556
|
+
}
|
|
2557
|
+
}
|
|
2558
|
+
rt.create = (n, e) => new rt({
|
|
2559
|
+
innerType: n,
|
|
2560
|
+
typeName: l.ZodCatch,
|
|
2561
|
+
catchValue: typeof e.catch == "function" ? e.catch : () => e.catch,
|
|
2562
|
+
..._(e)
|
|
2563
|
+
});
|
|
2564
|
+
class st extends b {
|
|
2565
|
+
_parse(e) {
|
|
2566
|
+
if (this._getType(e) !== h.nan) {
|
|
2567
|
+
const r = this._getOrReturnCtx(e);
|
|
2568
|
+
return f(r, {
|
|
2569
|
+
code: d.invalid_type,
|
|
2570
|
+
expected: h.nan,
|
|
2571
|
+
received: r.parsedType
|
|
2572
|
+
}), g;
|
|
2573
|
+
}
|
|
2574
|
+
return { status: "valid", value: e.data };
|
|
2575
|
+
}
|
|
2576
|
+
}
|
|
2577
|
+
st.create = (n) => new st({
|
|
2578
|
+
typeName: l.ZodNaN,
|
|
2579
|
+
..._(n)
|
|
2580
|
+
});
|
|
2581
|
+
class jn extends b {
|
|
2582
|
+
_parse(e) {
|
|
2583
|
+
const { ctx: t } = this._processInputParams(e), r = t.data;
|
|
2584
|
+
return this._def.type._parse({
|
|
2585
|
+
data: r,
|
|
2586
|
+
path: t.path,
|
|
2587
|
+
parent: t
|
|
2588
|
+
});
|
|
2589
|
+
}
|
|
2590
|
+
unwrap() {
|
|
2591
|
+
return this._def.type;
|
|
2592
|
+
}
|
|
2593
|
+
}
|
|
2594
|
+
class ot extends b {
|
|
2595
|
+
_parse(e) {
|
|
2596
|
+
const { status: t, ctx: r } = this._processInputParams(e);
|
|
2597
|
+
if (r.common.async)
|
|
2598
|
+
return (async () => {
|
|
2599
|
+
const a = await this._def.in._parseAsync({
|
|
2600
|
+
data: r.data,
|
|
2601
|
+
path: r.path,
|
|
2602
|
+
parent: r
|
|
2603
|
+
});
|
|
2604
|
+
return a.status === "aborted" ? g : a.status === "dirty" ? (t.dirty(), fe(a.value)) : this._def.out._parseAsync({
|
|
2605
|
+
data: a.value,
|
|
2606
|
+
path: r.path,
|
|
2607
|
+
parent: r
|
|
2608
|
+
});
|
|
2609
|
+
})();
|
|
2610
|
+
{
|
|
2611
|
+
const s = this._def.in._parseSync({
|
|
2612
|
+
data: r.data,
|
|
2613
|
+
path: r.path,
|
|
2614
|
+
parent: r
|
|
2615
|
+
});
|
|
2616
|
+
return s.status === "aborted" ? g : s.status === "dirty" ? (t.dirty(), {
|
|
2617
|
+
status: "dirty",
|
|
2618
|
+
value: s.value
|
|
2619
|
+
}) : this._def.out._parseSync({
|
|
2620
|
+
data: s.value,
|
|
2621
|
+
path: r.path,
|
|
2622
|
+
parent: r
|
|
2623
|
+
});
|
|
2624
|
+
}
|
|
2625
|
+
}
|
|
2626
|
+
static create(e, t) {
|
|
2627
|
+
return new ot({
|
|
2628
|
+
in: e,
|
|
2629
|
+
out: t,
|
|
2630
|
+
typeName: l.ZodPipeline
|
|
2631
|
+
});
|
|
2632
|
+
}
|
|
2633
|
+
}
|
|
2634
|
+
class at extends b {
|
|
2635
|
+
_parse(e) {
|
|
2636
|
+
const t = this._def.innerType._parse(e), r = (s) => (re(s) && (s.value = Object.freeze(s.value)), s);
|
|
2637
|
+
return ke(t) ? t.then((s) => r(s)) : r(t);
|
|
2638
|
+
}
|
|
2639
|
+
unwrap() {
|
|
2640
|
+
return this._def.innerType;
|
|
2641
|
+
}
|
|
2642
|
+
}
|
|
2643
|
+
at.create = (n, e) => new at({
|
|
2644
|
+
innerType: n,
|
|
2645
|
+
typeName: l.ZodReadonly,
|
|
2646
|
+
..._(e)
|
|
2647
|
+
});
|
|
2648
|
+
C.lazycreate;
|
|
2649
|
+
var l;
|
|
2650
|
+
(function(n) {
|
|
2651
|
+
n.ZodString = "ZodString", n.ZodNumber = "ZodNumber", n.ZodNaN = "ZodNaN", n.ZodBigInt = "ZodBigInt", n.ZodBoolean = "ZodBoolean", n.ZodDate = "ZodDate", n.ZodSymbol = "ZodSymbol", n.ZodUndefined = "ZodUndefined", n.ZodNull = "ZodNull", n.ZodAny = "ZodAny", n.ZodUnknown = "ZodUnknown", n.ZodNever = "ZodNever", n.ZodVoid = "ZodVoid", n.ZodArray = "ZodArray", n.ZodObject = "ZodObject", n.ZodUnion = "ZodUnion", n.ZodDiscriminatedUnion = "ZodDiscriminatedUnion", n.ZodIntersection = "ZodIntersection", n.ZodTuple = "ZodTuple", n.ZodRecord = "ZodRecord", n.ZodMap = "ZodMap", n.ZodSet = "ZodSet", n.ZodFunction = "ZodFunction", n.ZodLazy = "ZodLazy", n.ZodLiteral = "ZodLiteral", n.ZodEnum = "ZodEnum", n.ZodEffects = "ZodEffects", n.ZodNativeEnum = "ZodNativeEnum", n.ZodOptional = "ZodOptional", n.ZodNullable = "ZodNullable", n.ZodDefault = "ZodDefault", n.ZodCatch = "ZodCatch", n.ZodPromise = "ZodPromise", n.ZodBranded = "ZodBranded", n.ZodPipeline = "ZodPipeline", n.ZodReadonly = "ZodReadonly";
|
|
2652
|
+
})(l || (l = {}));
|
|
2653
|
+
const D = F.create, _t = se.create;
|
|
2654
|
+
st.create;
|
|
2655
|
+
ae.create;
|
|
2656
|
+
const In = Be.create;
|
|
2657
|
+
ge.create;
|
|
2658
|
+
We.create;
|
|
2659
|
+
qe.create;
|
|
2660
|
+
const Mn = Je.create, ne = He.create;
|
|
2661
|
+
Ge.create;
|
|
2662
|
+
Y.create;
|
|
2663
|
+
Ye.create;
|
|
2664
|
+
const Et = L.create, B = C.create;
|
|
2665
|
+
C.strictCreate;
|
|
2666
|
+
const Ze = xe.create;
|
|
2667
|
+
we.create;
|
|
2668
|
+
Q.create;
|
|
2669
|
+
const ct = Se.create;
|
|
2670
|
+
Xe.create;
|
|
2671
|
+
ie.create;
|
|
2672
|
+
Qe.create;
|
|
2673
|
+
const Pe = et.create;
|
|
2674
|
+
oe.create;
|
|
2675
|
+
tt.create;
|
|
2676
|
+
Ae.create;
|
|
2677
|
+
K.create;
|
|
2678
|
+
H.create;
|
|
2679
|
+
ce.create;
|
|
2680
|
+
K.createWithPreprocess;
|
|
2681
|
+
class je extends Error {
|
|
2682
|
+
constructor(e, t = "UNKNOWN_ERROR") {
|
|
2683
|
+
super(e), this.name = this.constructor.name, this.code = t, Error.captureStackTrace && Error.captureStackTrace(this, this.constructor);
|
|
2684
|
+
}
|
|
2685
|
+
}
|
|
2686
|
+
class Re extends je {
|
|
2687
|
+
constructor(e, t) {
|
|
2688
|
+
super(e, "VALIDATION_ERROR"), this.details = t;
|
|
2689
|
+
}
|
|
2690
|
+
}
|
|
2691
|
+
class le extends je {
|
|
2692
|
+
constructor(e, t) {
|
|
2693
|
+
super(e, "DATA_ERROR"), this.path = t;
|
|
2694
|
+
}
|
|
2695
|
+
}
|
|
2696
|
+
class bt extends je {
|
|
2697
|
+
constructor(e, t, r) {
|
|
2698
|
+
super(e, "EXPRESSION_ERROR"), this.expression = t, this.details = r;
|
|
2699
|
+
}
|
|
2700
|
+
}
|
|
2701
|
+
class he extends je {
|
|
2702
|
+
constructor(e) {
|
|
2703
|
+
super(e, "STATE_ERROR");
|
|
2704
|
+
}
|
|
2705
|
+
}
|
|
2706
|
+
class En {
|
|
2707
|
+
constructor(e, t, r = [], s) {
|
|
2708
|
+
this.id = e;
|
|
2709
|
+
const a = /* @__PURE__ */ new Map();
|
|
2710
|
+
for (const o of t)
|
|
2711
|
+
a.set(o.name, o);
|
|
2712
|
+
this.components = a;
|
|
2713
|
+
const i = /* @__PURE__ */ new Map();
|
|
2714
|
+
for (const o of r)
|
|
2715
|
+
i.set(o.name, o);
|
|
2716
|
+
this.functions = i, this.themeSchema = s, this.invoker = (o, c, u, y) => {
|
|
2717
|
+
var v;
|
|
2718
|
+
const T = this.functions.get(o);
|
|
2719
|
+
if (!T)
|
|
2720
|
+
throw new bt(`Function not found in catalog '${this.id}': ${o}`, o);
|
|
2721
|
+
try {
|
|
2722
|
+
const w = T.schema.parse(c);
|
|
2723
|
+
return T.execute(w, u, y);
|
|
2724
|
+
} catch (w) {
|
|
2725
|
+
throw (w == null ? void 0 : w.name) === "ZodError" || w instanceof z ? new bt(`Validation failed for function '${o}': ${w.message}`, o, (v = w.errors) != null ? v : w.issues) : w;
|
|
2726
|
+
}
|
|
2727
|
+
};
|
|
2728
|
+
}
|
|
2729
|
+
}
|
|
2730
|
+
class G {
|
|
2731
|
+
constructor() {
|
|
2732
|
+
this.listeners = /* @__PURE__ */ new Set();
|
|
2733
|
+
}
|
|
2734
|
+
/**
|
|
2735
|
+
* Subscribes to the event.
|
|
2736
|
+
*
|
|
2737
|
+
* @param listener The listener function to call when the event is emitted.
|
|
2738
|
+
* @returns A subscription object that can be used to unsubscribe.
|
|
2739
|
+
*/
|
|
2740
|
+
subscribe(e) {
|
|
2741
|
+
return this.listeners.add(e), {
|
|
2742
|
+
unsubscribe: () => this.listeners.delete(e)
|
|
2743
|
+
};
|
|
2744
|
+
}
|
|
2745
|
+
/**
|
|
2746
|
+
* Emits an event to all subscribers.
|
|
2747
|
+
*
|
|
2748
|
+
* @param data The data to pass to subscribers.
|
|
2749
|
+
*/
|
|
2750
|
+
async emit(e) {
|
|
2751
|
+
for (const t of this.listeners)
|
|
2752
|
+
try {
|
|
2753
|
+
await t(e);
|
|
2754
|
+
} catch (r) {
|
|
2755
|
+
console.error("EventEmitter error:", r);
|
|
2756
|
+
}
|
|
2757
|
+
}
|
|
2758
|
+
/**
|
|
2759
|
+
* Removes all listeners.
|
|
2760
|
+
*/
|
|
2761
|
+
dispose() {
|
|
2762
|
+
this.listeners.clear();
|
|
2763
|
+
}
|
|
2764
|
+
}
|
|
2765
|
+
var Rn = Symbol.for("preact-signals");
|
|
2766
|
+
function Ie() {
|
|
2767
|
+
if (W > 1)
|
|
2768
|
+
W--;
|
|
2769
|
+
else {
|
|
2770
|
+
var n, e = !1;
|
|
2771
|
+
for (function() {
|
|
2772
|
+
var s = Ce;
|
|
2773
|
+
for (Ce = void 0; s !== void 0; )
|
|
2774
|
+
s.S.v === s.v && (s.S.i = s.i), s = s.o;
|
|
2775
|
+
}(); ye !== void 0; ) {
|
|
2776
|
+
var t = ye;
|
|
2777
|
+
for (ye = void 0, Te++; t !== void 0; ) {
|
|
2778
|
+
var r = t.u;
|
|
2779
|
+
if (t.u = void 0, t.f &= -3, !(8 & t.f) && Dt(t))
|
|
2780
|
+
try {
|
|
2781
|
+
t.c();
|
|
2782
|
+
} catch (s) {
|
|
2783
|
+
e || (n = s, e = !0);
|
|
2784
|
+
}
|
|
2785
|
+
t = r;
|
|
2786
|
+
}
|
|
2787
|
+
}
|
|
2788
|
+
if (Te = 0, W--, e)
|
|
2789
|
+
throw n;
|
|
2790
|
+
}
|
|
2791
|
+
}
|
|
2792
|
+
function kt(n) {
|
|
2793
|
+
if (W > 0)
|
|
2794
|
+
return n();
|
|
2795
|
+
it = ++$n, W++;
|
|
2796
|
+
try {
|
|
2797
|
+
return n();
|
|
2798
|
+
} finally {
|
|
2799
|
+
Ie();
|
|
2800
|
+
}
|
|
2801
|
+
}
|
|
2802
|
+
var S = void 0;
|
|
2803
|
+
function Rt(n) {
|
|
2804
|
+
var e = S;
|
|
2805
|
+
S = void 0;
|
|
2806
|
+
try {
|
|
2807
|
+
return n();
|
|
2808
|
+
} finally {
|
|
2809
|
+
S = e;
|
|
2810
|
+
}
|
|
2811
|
+
}
|
|
2812
|
+
var ye = void 0, W = 0, Te = 0, $n = 0, it = 0, Ce = void 0, Oe = 0;
|
|
2813
|
+
function $t(n) {
|
|
2814
|
+
if (S !== void 0) {
|
|
2815
|
+
var e = n.n;
|
|
2816
|
+
if (e === void 0 || e.t !== S)
|
|
2817
|
+
return e = { i: 0, S: n, p: S.s, n: void 0, t: S, e: void 0, x: void 0, r: e }, S.s !== void 0 && (S.s.n = e), S.s = e, n.n = e, 32 & S.f && n.S(e), e;
|
|
2818
|
+
if (e.i === -1)
|
|
2819
|
+
return e.i = 0, e.n !== void 0 && (e.n.p = e.p, e.p !== void 0 && (e.p.n = e.n), e.p = S.s, e.n = void 0, S.s.n = e, S.s = e), e;
|
|
2820
|
+
}
|
|
2821
|
+
}
|
|
2822
|
+
function j(n, e) {
|
|
2823
|
+
this.v = n, this.i = 0, this.n = void 0, this.t = void 0, this.l = 0, this.W = e == null ? void 0 : e.watched, this.Z = e == null ? void 0 : e.unwatched, this.name = e == null ? void 0 : e.name;
|
|
2824
|
+
}
|
|
2825
|
+
j.prototype.brand = Rn;
|
|
2826
|
+
j.prototype.h = function() {
|
|
2827
|
+
return !0;
|
|
2828
|
+
};
|
|
2829
|
+
j.prototype.S = function(n) {
|
|
2830
|
+
var e = this, t = this.t;
|
|
2831
|
+
t !== n && n.e === void 0 && (n.x = t, this.t = n, t !== void 0 ? t.e = n : Rt(function() {
|
|
2832
|
+
var r;
|
|
2833
|
+
(r = e.W) == null || r.call(e);
|
|
2834
|
+
}));
|
|
2835
|
+
};
|
|
2836
|
+
j.prototype.U = function(n) {
|
|
2837
|
+
var e = this;
|
|
2838
|
+
if (this.t !== void 0) {
|
|
2839
|
+
var t = n.e, r = n.x;
|
|
2840
|
+
t !== void 0 && (t.x = r, n.e = void 0), r !== void 0 && (r.e = t, n.x = void 0), n === this.t && (this.t = r, r === void 0 && Rt(function() {
|
|
2841
|
+
var s;
|
|
2842
|
+
(s = e.Z) == null || s.call(e);
|
|
2843
|
+
}));
|
|
2844
|
+
}
|
|
2845
|
+
};
|
|
2846
|
+
j.prototype.subscribe = function(n) {
|
|
2847
|
+
var e = this;
|
|
2848
|
+
return Ut(function() {
|
|
2849
|
+
var t = e.value, r = S;
|
|
2850
|
+
S = void 0;
|
|
2851
|
+
try {
|
|
2852
|
+
n(t);
|
|
2853
|
+
} finally {
|
|
2854
|
+
S = r;
|
|
2855
|
+
}
|
|
2856
|
+
}, { name: "sub" });
|
|
2857
|
+
};
|
|
2858
|
+
j.prototype.valueOf = function() {
|
|
2859
|
+
return this.value;
|
|
2860
|
+
};
|
|
2861
|
+
j.prototype.toString = function() {
|
|
2862
|
+
return this.value + "";
|
|
2863
|
+
};
|
|
2864
|
+
j.prototype.toJSON = function() {
|
|
2865
|
+
return this.value;
|
|
2866
|
+
};
|
|
2867
|
+
j.prototype.peek = function() {
|
|
2868
|
+
var n = S;
|
|
2869
|
+
S = void 0;
|
|
2870
|
+
try {
|
|
2871
|
+
return this.value;
|
|
2872
|
+
} finally {
|
|
2873
|
+
S = n;
|
|
2874
|
+
}
|
|
2875
|
+
};
|
|
2876
|
+
Object.defineProperty(j.prototype, "value", { get: function() {
|
|
2877
|
+
var n = $t(this);
|
|
2878
|
+
return n !== void 0 && (n.i = this.i), this.v;
|
|
2879
|
+
}, set: function(n) {
|
|
2880
|
+
if (n !== this.v) {
|
|
2881
|
+
if (Te > 100)
|
|
2882
|
+
throw new Error("Cycle detected");
|
|
2883
|
+
((function(t) {
|
|
2884
|
+
W !== 0 && Te === 0 && t.l !== it && (t.l = it, Ce = { S: t, v: t.v, i: t.i, o: Ce });
|
|
2885
|
+
}))(this), this.v = n, this.i++, Oe++, W++;
|
|
2886
|
+
try {
|
|
2887
|
+
for (var e = this.t; e !== void 0; e = e.x)
|
|
2888
|
+
e.t.N();
|
|
2889
|
+
} finally {
|
|
2890
|
+
Ie();
|
|
2891
|
+
}
|
|
2892
|
+
}
|
|
2893
|
+
} });
|
|
2894
|
+
function Dn(n, e) {
|
|
2895
|
+
return new j(n, e);
|
|
2896
|
+
}
|
|
2897
|
+
function Dt(n) {
|
|
2898
|
+
for (var e = n.s; e !== void 0; e = e.n)
|
|
2899
|
+
if (e.S.i !== e.i || !e.S.h() || e.S.i !== e.i)
|
|
2900
|
+
return !0;
|
|
2901
|
+
return !1;
|
|
2902
|
+
}
|
|
2903
|
+
function Lt(n) {
|
|
2904
|
+
for (var e = n.s; e !== void 0; e = e.n) {
|
|
2905
|
+
var t = e.S.n;
|
|
2906
|
+
if (t !== void 0 && (e.r = t), e.S.n = e, e.i = -1, e.n === void 0) {
|
|
2907
|
+
n.s = e;
|
|
2908
|
+
break;
|
|
2909
|
+
}
|
|
2910
|
+
}
|
|
2911
|
+
}
|
|
2912
|
+
function zt(n) {
|
|
2913
|
+
for (var e = n.s, t = void 0; e !== void 0; ) {
|
|
2914
|
+
var r = e.p;
|
|
2915
|
+
e.i === -1 ? (e.S.U(e), r !== void 0 && (r.n = e.n), e.n !== void 0 && (e.n.p = r)) : t = e, e.S.n = e.r, e.r !== void 0 && (e.r = void 0), e = r;
|
|
2916
|
+
}
|
|
2917
|
+
n.s = t;
|
|
2918
|
+
}
|
|
2919
|
+
function ue(n, e) {
|
|
2920
|
+
j.call(this, void 0), this.x = n, this.s = void 0, this.g = Oe - 1, this.f = 4, this.W = e == null ? void 0 : e.watched, this.Z = e == null ? void 0 : e.unwatched, this.name = e == null ? void 0 : e.name;
|
|
2921
|
+
}
|
|
2922
|
+
ue.prototype = new j();
|
|
2923
|
+
ue.prototype.h = function() {
|
|
2924
|
+
if (this.f &= -3, 1 & this.f)
|
|
2925
|
+
return !1;
|
|
2926
|
+
if ((36 & this.f) == 32 || (this.f &= -5, this.g === Oe))
|
|
2927
|
+
return !0;
|
|
2928
|
+
if (this.g = Oe, this.f |= 1, this.i > 0 && !Dt(this))
|
|
2929
|
+
return this.f &= -2, !0;
|
|
2930
|
+
var n = S;
|
|
2931
|
+
try {
|
|
2932
|
+
Lt(this), S = this;
|
|
2933
|
+
var e = this.x();
|
|
2934
|
+
(16 & this.f || this.v !== e || this.i === 0) && (this.v = e, this.f &= -17, this.i++);
|
|
2935
|
+
} catch (t) {
|
|
2936
|
+
this.v = t, this.f |= 16, this.i++;
|
|
2937
|
+
}
|
|
2938
|
+
return S = n, zt(this), this.f &= -2, !0;
|
|
2939
|
+
};
|
|
2940
|
+
ue.prototype.S = function(n) {
|
|
2941
|
+
if (this.t === void 0) {
|
|
2942
|
+
this.f |= 36;
|
|
2943
|
+
for (var e = this.s; e !== void 0; e = e.n)
|
|
2944
|
+
e.S.S(e);
|
|
2945
|
+
}
|
|
2946
|
+
j.prototype.S.call(this, n);
|
|
2947
|
+
};
|
|
2948
|
+
ue.prototype.U = function(n) {
|
|
2949
|
+
if (this.t !== void 0 && (j.prototype.U.call(this, n), this.t === void 0)) {
|
|
2950
|
+
this.f &= -33;
|
|
2951
|
+
for (var e = this.s; e !== void 0; e = e.n)
|
|
2952
|
+
e.S.U(e);
|
|
2953
|
+
}
|
|
2954
|
+
};
|
|
2955
|
+
ue.prototype.N = function() {
|
|
2956
|
+
if (!(2 & this.f)) {
|
|
2957
|
+
this.f |= 6;
|
|
2958
|
+
for (var n = this.t; n !== void 0; n = n.x)
|
|
2959
|
+
n.t.N();
|
|
2960
|
+
}
|
|
2961
|
+
};
|
|
2962
|
+
Object.defineProperty(ue.prototype, "value", { get: function() {
|
|
2963
|
+
if (1 & this.f)
|
|
2964
|
+
throw new Error("Cycle detected");
|
|
2965
|
+
var n = $t(this);
|
|
2966
|
+
if (this.h(), n !== void 0 && (n.i = this.i), 16 & this.f)
|
|
2967
|
+
throw this.v;
|
|
2968
|
+
return this.v;
|
|
2969
|
+
} });
|
|
2970
|
+
function Vt(n) {
|
|
2971
|
+
var e = n.m;
|
|
2972
|
+
if (n.m = void 0, typeof e == "function") {
|
|
2973
|
+
W++;
|
|
2974
|
+
var t = S;
|
|
2975
|
+
S = void 0;
|
|
2976
|
+
try {
|
|
2977
|
+
e();
|
|
2978
|
+
} catch (r) {
|
|
2979
|
+
throw n.f &= -2, n.f |= 8, ut(n), r;
|
|
2980
|
+
} finally {
|
|
2981
|
+
S = t, Ie();
|
|
2982
|
+
}
|
|
2983
|
+
}
|
|
2984
|
+
}
|
|
2985
|
+
function ut(n) {
|
|
2986
|
+
for (var e = n.s; e !== void 0; e = e.n)
|
|
2987
|
+
e.S.U(e);
|
|
2988
|
+
n.x = void 0, n.s = void 0, Vt(n);
|
|
2989
|
+
}
|
|
2990
|
+
function Ln(n) {
|
|
2991
|
+
if (S !== this)
|
|
2992
|
+
throw new Error("Out-of-order effect");
|
|
2993
|
+
zt(this), S = n, this.f &= -2, 8 & this.f && ut(this), Ie();
|
|
2994
|
+
}
|
|
2995
|
+
function de(n, e) {
|
|
2996
|
+
this.x = n, this.m = void 0, this.s = void 0, this.u = void 0, this.f = 32, this.name = e == null ? void 0 : e.name;
|
|
2997
|
+
}
|
|
2998
|
+
de.prototype.c = function() {
|
|
2999
|
+
var n = this.S();
|
|
3000
|
+
try {
|
|
3001
|
+
if (8 & this.f || this.x === void 0)
|
|
3002
|
+
return;
|
|
3003
|
+
var e = this.x();
|
|
3004
|
+
typeof e == "function" && (this.m = e);
|
|
3005
|
+
} finally {
|
|
3006
|
+
n();
|
|
3007
|
+
}
|
|
3008
|
+
};
|
|
3009
|
+
de.prototype.S = function() {
|
|
3010
|
+
if (1 & this.f)
|
|
3011
|
+
throw new Error("Cycle detected");
|
|
3012
|
+
this.f |= 1, this.f &= -9, Vt(this), Lt(this), W++;
|
|
3013
|
+
var n = S;
|
|
3014
|
+
return S = this, Ln.bind(this, n);
|
|
3015
|
+
};
|
|
3016
|
+
de.prototype.N = function() {
|
|
3017
|
+
2 & this.f || (this.f |= 2, this.u = ye, ye = this);
|
|
3018
|
+
};
|
|
3019
|
+
de.prototype.d = function() {
|
|
3020
|
+
this.f |= 8, 1 & this.f || ut(this);
|
|
3021
|
+
};
|
|
3022
|
+
de.prototype.dispose = function() {
|
|
3023
|
+
this.d();
|
|
3024
|
+
};
|
|
3025
|
+
function Ut(n, e) {
|
|
3026
|
+
var t = new de(n, e);
|
|
3027
|
+
try {
|
|
3028
|
+
t.c();
|
|
3029
|
+
} catch (s) {
|
|
3030
|
+
throw t.d(), s;
|
|
3031
|
+
}
|
|
3032
|
+
var r = t.d.bind(t);
|
|
3033
|
+
return r[Symbol.dispose] = r, r;
|
|
3034
|
+
}
|
|
3035
|
+
function $e(n) {
|
|
3036
|
+
return /^\d+$/.test(n);
|
|
3037
|
+
}
|
|
3038
|
+
class zn {
|
|
3039
|
+
/**
|
|
3040
|
+
* Creates a new data model.
|
|
3041
|
+
*
|
|
3042
|
+
* @param initialData The initial data for the model. Defaults to an empty object.
|
|
3043
|
+
*/
|
|
3044
|
+
constructor(e = {}) {
|
|
3045
|
+
this.data = {}, this.signals = /* @__PURE__ */ new Map(), this.subscriptions = /* @__PURE__ */ new Set(), this.data = e;
|
|
3046
|
+
}
|
|
3047
|
+
/**
|
|
3048
|
+
* Retrieves a Preact Signal for a specific data path.
|
|
3049
|
+
*
|
|
3050
|
+
* This provides a reactive way to access a value. If the value at the path changes via `set()`,
|
|
3051
|
+
* the signal will automatically be updated.
|
|
3052
|
+
*
|
|
3053
|
+
* @param path The JSON pointer path to create or retrieve a signal for.
|
|
3054
|
+
* @returns A Preact Signal representing the value at the specified path.
|
|
3055
|
+
*/
|
|
3056
|
+
getSignal(e) {
|
|
3057
|
+
const t = this.normalizePath(e);
|
|
3058
|
+
return this.signals.has(t) || this.signals.set(t, Dn(this.get(t))), this.signals.get(t);
|
|
3059
|
+
}
|
|
3060
|
+
/**
|
|
3061
|
+
* Updates the model at the specific path and notifies all relevant signals.
|
|
3062
|
+
* If path is '/' or empty, replaces the entire root.
|
|
3063
|
+
*
|
|
3064
|
+
* Note on `undefined` values:
|
|
3065
|
+
* - For objects: Setting a property to `undefined` removes the key from the object.
|
|
3066
|
+
* - For arrays: Setting an index to `undefined` sets that index to `undefined` but preserves the array length (sparse array).
|
|
3067
|
+
*/
|
|
3068
|
+
set(e, t) {
|
|
3069
|
+
if (e == null)
|
|
3070
|
+
throw new le("Path cannot be null or undefined.");
|
|
3071
|
+
if (e === "/" || e === "")
|
|
3072
|
+
return this.data = t, this.notifyAllSignals(), this;
|
|
3073
|
+
const r = this.parsePath(e), s = r.pop();
|
|
3074
|
+
this.data || (this.data = {});
|
|
3075
|
+
let a = this.data;
|
|
3076
|
+
for (let i = 0; i < r.length; i++) {
|
|
3077
|
+
const o = r[i];
|
|
3078
|
+
if (Array.isArray(a) && !$e(o))
|
|
3079
|
+
throw new le(`Cannot use non-numeric segment '${o}' on an array in path '${e}'.`, e);
|
|
3080
|
+
if (a[o] !== void 0 && a[o] !== null && typeof a[o] != "object")
|
|
3081
|
+
throw new le(`Cannot set path '${e}': segment '${o}' is a primitive value.`, e);
|
|
3082
|
+
if (a[o] === void 0 || a[o] === null) {
|
|
3083
|
+
const c = i < r.length - 1 ? r[i + 1] : s;
|
|
3084
|
+
a[o] = $e(c) ? [] : {};
|
|
3085
|
+
}
|
|
3086
|
+
a = a[o];
|
|
3087
|
+
}
|
|
3088
|
+
if (Array.isArray(a) && !$e(s))
|
|
3089
|
+
throw new le(`Cannot use non-numeric segment '${s}' on an array in path '${e}'.`, e);
|
|
3090
|
+
return t === void 0 ? Array.isArray(a) ? a[parseInt(s, 10)] = void 0 : delete a[s] : a[s] = t, this.notifySignals(e), this;
|
|
3091
|
+
}
|
|
3092
|
+
/**
|
|
3093
|
+
* Retrieves data at a specific JSON pointer path.
|
|
3094
|
+
*
|
|
3095
|
+
* @param path The JSON pointer path to read from.
|
|
3096
|
+
* @returns The value at the specified path, or undefined if not found.
|
|
3097
|
+
*/
|
|
3098
|
+
get(e) {
|
|
3099
|
+
if (e == null)
|
|
3100
|
+
throw new le("Path cannot be null or undefined.");
|
|
3101
|
+
if (e === "/" || e === "")
|
|
3102
|
+
return this.data;
|
|
3103
|
+
const t = this.parsePath(e);
|
|
3104
|
+
let r = this.data;
|
|
3105
|
+
for (const s of t) {
|
|
3106
|
+
if (r == null)
|
|
3107
|
+
return;
|
|
3108
|
+
r = r[s];
|
|
3109
|
+
}
|
|
3110
|
+
return r;
|
|
3111
|
+
}
|
|
3112
|
+
/**
|
|
3113
|
+
* Subscribes to changes at the specified data path.
|
|
3114
|
+
*
|
|
3115
|
+
* This is a backwards-compatible layer using Preact Signals internally. It allows
|
|
3116
|
+
* listeners to be notified whenever the value at the specified path (or any of its
|
|
3117
|
+
* ancestors/descendants) changes.
|
|
3118
|
+
*
|
|
3119
|
+
* @param path The JSON pointer path to observe.
|
|
3120
|
+
* @param onChange A callback fired whenever the value changes.
|
|
3121
|
+
* @returns A `DataSubscription` containing the initial value and an `unsubscribe` method.
|
|
3122
|
+
*/
|
|
3123
|
+
subscribe(e, t) {
|
|
3124
|
+
const r = this.getSignal(e);
|
|
3125
|
+
let s = !0, a = r.peek();
|
|
3126
|
+
const i = Ut(() => {
|
|
3127
|
+
const o = r.value;
|
|
3128
|
+
a = o, s || t(o);
|
|
3129
|
+
});
|
|
3130
|
+
return s = !1, this.subscriptions.add(i), {
|
|
3131
|
+
get value() {
|
|
3132
|
+
return a;
|
|
3133
|
+
},
|
|
3134
|
+
unsubscribe: () => {
|
|
3135
|
+
i(), this.subscriptions.delete(i);
|
|
3136
|
+
}
|
|
3137
|
+
};
|
|
3138
|
+
}
|
|
3139
|
+
/**
|
|
3140
|
+
* Clears all internal subscriptions.
|
|
3141
|
+
*/
|
|
3142
|
+
dispose() {
|
|
3143
|
+
for (const e of this.subscriptions)
|
|
3144
|
+
e();
|
|
3145
|
+
this.subscriptions.clear(), this.signals.clear();
|
|
3146
|
+
}
|
|
3147
|
+
normalizePath(e) {
|
|
3148
|
+
return e.length > 1 && e.endsWith("/") ? e.slice(0, -1) : e || "/";
|
|
3149
|
+
}
|
|
3150
|
+
parsePath(e) {
|
|
3151
|
+
return e.split("/").filter((t) => t.length > 0);
|
|
3152
|
+
}
|
|
3153
|
+
notifySignals(e) {
|
|
3154
|
+
const t = this.normalizePath(e);
|
|
3155
|
+
kt(() => {
|
|
3156
|
+
this.updateSignal(t);
|
|
3157
|
+
let r = t;
|
|
3158
|
+
for (; r !== "/" && r !== ""; )
|
|
3159
|
+
r = r.substring(0, r.lastIndexOf("/")) || "/", this.updateSignal(r);
|
|
3160
|
+
for (const s of this.signals.keys())
|
|
3161
|
+
this.isDescendant(s, t) && this.updateSignal(s);
|
|
3162
|
+
});
|
|
3163
|
+
}
|
|
3164
|
+
updateSignal(e) {
|
|
3165
|
+
const t = this.signals.get(e);
|
|
3166
|
+
if (t) {
|
|
3167
|
+
const r = this.get(e);
|
|
3168
|
+
Array.isArray(r) ? t.value = [...r] : typeof r == "object" && r !== null ? t.value = { ...r } : t.value = r;
|
|
3169
|
+
}
|
|
3170
|
+
}
|
|
3171
|
+
notifyAllSignals() {
|
|
3172
|
+
kt(() => {
|
|
3173
|
+
for (const e of this.signals.keys())
|
|
3174
|
+
this.updateSignal(e);
|
|
3175
|
+
});
|
|
3176
|
+
}
|
|
3177
|
+
isDescendant(e, t) {
|
|
3178
|
+
return t === "/" || t === "" ? e !== "/" : e.startsWith(t + "/");
|
|
3179
|
+
}
|
|
3180
|
+
}
|
|
3181
|
+
class Vn {
|
|
3182
|
+
constructor() {
|
|
3183
|
+
this.components = /* @__PURE__ */ new Map(), this._onCreated = new G(), this._onDeleted = new G(), this.onCreated = this._onCreated, this.onDeleted = this._onDeleted;
|
|
3184
|
+
}
|
|
3185
|
+
/**
|
|
3186
|
+
* Retrieves a component by its ID.
|
|
3187
|
+
*
|
|
3188
|
+
*
|
|
3189
|
+
* @param id The ID of the component to retrieve.
|
|
3190
|
+
* @returns The component model, or undefined if not found.
|
|
3191
|
+
*/
|
|
3192
|
+
get(e) {
|
|
3193
|
+
return this.components.get(e);
|
|
3194
|
+
}
|
|
3195
|
+
/**
|
|
3196
|
+
* Returns an iterator over the components in the model.
|
|
3197
|
+
*/
|
|
3198
|
+
get entries() {
|
|
3199
|
+
return this.components.entries();
|
|
3200
|
+
}
|
|
3201
|
+
/**
|
|
3202
|
+
* Adds a component to the model.
|
|
3203
|
+
* Throws an error if a component with the same ID already exists.
|
|
3204
|
+
*
|
|
3205
|
+
* @param component The component to add.
|
|
3206
|
+
*/
|
|
3207
|
+
addComponent(e) {
|
|
3208
|
+
if (this.components.has(e.id))
|
|
3209
|
+
throw new he(`Component with id '${e.id}' already exists.`);
|
|
3210
|
+
this.components.set(e.id, e), this._onCreated.emit(e);
|
|
3211
|
+
}
|
|
3212
|
+
/**
|
|
3213
|
+
* Removes a component from the model by its ID.
|
|
3214
|
+
* Disposes of the component upon removal.
|
|
3215
|
+
*
|
|
3216
|
+
* @param id The ID of the component to remove.
|
|
3217
|
+
*/
|
|
3218
|
+
removeComponent(e) {
|
|
3219
|
+
const t = this.components.get(e);
|
|
3220
|
+
t && (this.components.delete(e), t.dispose(), this._onDeleted.emit(e));
|
|
3221
|
+
}
|
|
3222
|
+
/**
|
|
3223
|
+
* Disposes of the model and all its components.
|
|
3224
|
+
*/
|
|
3225
|
+
dispose() {
|
|
3226
|
+
for (const e of this.components.values())
|
|
3227
|
+
e.dispose();
|
|
3228
|
+
this.components.clear(), this._onCreated.dispose(), this._onDeleted.dispose();
|
|
3229
|
+
}
|
|
3230
|
+
}
|
|
3231
|
+
const Ft = B({
|
|
3232
|
+
name: D().describe("The name of the action, taken from the component's action.event.name property."),
|
|
3233
|
+
surfaceId: D().describe("The id of the surface where the event originated."),
|
|
3234
|
+
sourceComponentId: D().describe("The id of the component that triggered the event."),
|
|
3235
|
+
timestamp: D().datetime().describe("An ISO 8601 timestamp of when the event occurred."),
|
|
3236
|
+
context: ct(ne()).describe("A JSON object containing the key-value pairs from the component's action.event.context, after resolving all data bindings.")
|
|
3237
|
+
}).strict(), Un = B({
|
|
3238
|
+
code: Pe("VALIDATION_FAILED"),
|
|
3239
|
+
surfaceId: D().describe("The id of the surface where the error occurred."),
|
|
3240
|
+
path: D().describe("The JSON pointer to the field that failed validation (e.g. '/components/0/text')."),
|
|
3241
|
+
message: D().describe("A short one or two sentence description of why validation failed.")
|
|
3242
|
+
}).strict(), Fn = B({
|
|
3243
|
+
code: D().refine((n) => n !== "VALIDATION_FAILED"),
|
|
3244
|
+
message: D().describe("A short one or two sentence description of why the error occurred."),
|
|
3245
|
+
surfaceId: D().describe("The id of the surface where the error occurred.")
|
|
3246
|
+
}).passthrough(), Bn = Ze([
|
|
3247
|
+
Un,
|
|
3248
|
+
Fn
|
|
3249
|
+
]);
|
|
3250
|
+
B({
|
|
3251
|
+
version: Pe("v0.9")
|
|
3252
|
+
}).and(Ze([
|
|
3253
|
+
B({ action: Ft }),
|
|
3254
|
+
B({ error: Bn })
|
|
3255
|
+
]));
|
|
3256
|
+
B({
|
|
3257
|
+
version: Pe("v0.9"),
|
|
3258
|
+
surfaces: ct(B({}).passthrough()).describe("A map of surface IDs to their current data models.")
|
|
3259
|
+
}).strict();
|
|
3260
|
+
class Wn {
|
|
3261
|
+
/**
|
|
3262
|
+
* Creates a new surface model.
|
|
3263
|
+
*
|
|
3264
|
+
* @param id The unique identifier for this surface.
|
|
3265
|
+
* @param catalog The component catalog used by this surface.
|
|
3266
|
+
* @param theme The theme to apply to this surface.
|
|
3267
|
+
* @param sendDataModel If true, the client will send the full data model.
|
|
3268
|
+
*/
|
|
3269
|
+
constructor(e, t, r = {}, s = !1) {
|
|
3270
|
+
this.id = e, this.catalog = t, this.theme = r, this.sendDataModel = s, this._onAction = new G(), this._onError = new G(), this.onAction = this._onAction, this.onError = this._onError, this.dataModel = new zn({}), this.componentsModel = new Vn();
|
|
3271
|
+
}
|
|
3272
|
+
/**
|
|
3273
|
+
* Dispatches an action from this surface to listeners.
|
|
3274
|
+
*
|
|
3275
|
+
* @param payload The action payload (name and context) to dispatch.
|
|
3276
|
+
* @param sourceComponentId The ID of the component that triggered the action.
|
|
3277
|
+
*/
|
|
3278
|
+
async dispatchAction(e, t) {
|
|
3279
|
+
if (e && typeof e == "object" && "event" in e && e.event) {
|
|
3280
|
+
const r = {
|
|
3281
|
+
name: e.event.name,
|
|
3282
|
+
surfaceId: this.id,
|
|
3283
|
+
sourceComponentId: t,
|
|
3284
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
3285
|
+
context: e.event.context || {}
|
|
3286
|
+
}, s = Ft.safeParse(r);
|
|
3287
|
+
s.success ? await this._onAction.emit(s.data) : console.error("A2UI: Invalid action payload dispatched.", s.error.format());
|
|
3288
|
+
}
|
|
3289
|
+
}
|
|
3290
|
+
/**
|
|
3291
|
+
* Dispatches an error from this surface to listeners.
|
|
3292
|
+
*
|
|
3293
|
+
* @param error The error object to dispatch, conforming to client_to_server schema.
|
|
3294
|
+
*/
|
|
3295
|
+
async dispatchError(e) {
|
|
3296
|
+
await this._onError.emit({
|
|
3297
|
+
...e,
|
|
3298
|
+
surfaceId: this.id
|
|
3299
|
+
});
|
|
3300
|
+
}
|
|
3301
|
+
/**
|
|
3302
|
+
* Disposes of the surface and its resources.
|
|
3303
|
+
*/
|
|
3304
|
+
dispose() {
|
|
3305
|
+
this.dataModel.dispose(), this.componentsModel.dispose(), this._onAction.dispose(), this._onError.dispose();
|
|
3306
|
+
}
|
|
3307
|
+
}
|
|
3308
|
+
class qn {
|
|
3309
|
+
constructor() {
|
|
3310
|
+
this.surfaces = /* @__PURE__ */ new Map(), this.surfaceUnsubscribers = /* @__PURE__ */ new Map(), this._onSurfaceCreated = new G(), this._onSurfaceDeleted = new G(), this._onAction = new G(), this.onSurfaceCreated = this._onSurfaceCreated, this.onSurfaceDeleted = this._onSurfaceDeleted, this.onAction = this._onAction;
|
|
3311
|
+
}
|
|
3312
|
+
/**
|
|
3313
|
+
* Adds a surface to the group.
|
|
3314
|
+
* Ignores if a surface with the same ID already exists.
|
|
3315
|
+
*
|
|
3316
|
+
* @param surface The surface model to add.
|
|
3317
|
+
*/
|
|
3318
|
+
addSurface(e) {
|
|
3319
|
+
if (this.surfaces.has(e.id)) {
|
|
3320
|
+
console.warn(`Surface ${e.id} already exists. Ignoring.`);
|
|
3321
|
+
return;
|
|
3322
|
+
}
|
|
3323
|
+
this.surfaces.set(e.id, e);
|
|
3324
|
+
const t = e.onAction.subscribe((r) => this._onAction.emit(r));
|
|
3325
|
+
this.surfaceUnsubscribers.set(e.id, t), this._onSurfaceCreated.emit(e);
|
|
3326
|
+
}
|
|
3327
|
+
/**
|
|
3328
|
+
* Removes a surface from the group by its ID.
|
|
3329
|
+
* Disposes of the surface upon removal.
|
|
3330
|
+
*
|
|
3331
|
+
* @param id The ID of the surface to remove.
|
|
3332
|
+
*/
|
|
3333
|
+
deleteSurface(e) {
|
|
3334
|
+
const t = this.surfaces.get(e);
|
|
3335
|
+
if (t) {
|
|
3336
|
+
const r = this.surfaceUnsubscribers.get(e);
|
|
3337
|
+
r && (r.unsubscribe(), this.surfaceUnsubscribers.delete(e)), this.surfaces.delete(e), t.dispose(), this._onSurfaceDeleted.emit(e);
|
|
3338
|
+
}
|
|
3339
|
+
}
|
|
3340
|
+
/**
|
|
3341
|
+
* Retrieves a surface by its ID.
|
|
3342
|
+
*
|
|
3343
|
+
*
|
|
3344
|
+
* @param id The ID of the surface to retrieve.
|
|
3345
|
+
* @returns The surface model, or undefined if not found.
|
|
3346
|
+
*/
|
|
3347
|
+
getSurface(e) {
|
|
3348
|
+
return this.surfaces.get(e);
|
|
3349
|
+
}
|
|
3350
|
+
/**
|
|
3351
|
+
* Returns a readonly map of all active surfaces.
|
|
3352
|
+
*/
|
|
3353
|
+
get surfacesMap() {
|
|
3354
|
+
return this.surfaces;
|
|
3355
|
+
}
|
|
3356
|
+
/**
|
|
3357
|
+
* Disposes of the group and all its surfaces.
|
|
3358
|
+
*/
|
|
3359
|
+
dispose() {
|
|
3360
|
+
for (const e of Array.from(this.surfaces.keys()))
|
|
3361
|
+
this.deleteSurface(e);
|
|
3362
|
+
this._onSurfaceCreated.dispose(), this._onSurfaceDeleted.dispose(), this._onAction.dispose();
|
|
3363
|
+
}
|
|
3364
|
+
}
|
|
3365
|
+
class xt {
|
|
3366
|
+
/**
|
|
3367
|
+
* Creates a new component model.
|
|
3368
|
+
*
|
|
3369
|
+
* @param id The unique identifier for this component.
|
|
3370
|
+
* @param type The component type name.
|
|
3371
|
+
* @param initialProperties The initial properties for the component.
|
|
3372
|
+
*/
|
|
3373
|
+
constructor(e, t, r) {
|
|
3374
|
+
this.id = e, this.type = t, this._onUpdated = new G(), this.onUpdated = this._onUpdated, this._properties = r;
|
|
3375
|
+
}
|
|
3376
|
+
/**
|
|
3377
|
+
* The current properties of the component.
|
|
3378
|
+
*/
|
|
3379
|
+
get properties() {
|
|
3380
|
+
return this._properties;
|
|
3381
|
+
}
|
|
3382
|
+
set properties(e) {
|
|
3383
|
+
this._properties = e, this._onUpdated.emit(this);
|
|
3384
|
+
}
|
|
3385
|
+
/**
|
|
3386
|
+
* Disposes of the component and its resources.
|
|
3387
|
+
*/
|
|
3388
|
+
dispose() {
|
|
3389
|
+
this._onUpdated.dispose();
|
|
3390
|
+
}
|
|
3391
|
+
/**
|
|
3392
|
+
* Returns a JSON representation of the component tree.
|
|
3393
|
+
*/
|
|
3394
|
+
get componentTree() {
|
|
3395
|
+
return {
|
|
3396
|
+
id: this.id,
|
|
3397
|
+
type: this.type,
|
|
3398
|
+
...this._properties
|
|
3399
|
+
};
|
|
3400
|
+
}
|
|
3401
|
+
}
|
|
3402
|
+
const Jn = Symbol("Let zodToJsonSchema decide on which parser to use"), wt = {
|
|
3403
|
+
name: void 0,
|
|
3404
|
+
$refStrategy: "root",
|
|
3405
|
+
basePath: ["#"],
|
|
3406
|
+
effectStrategy: "input",
|
|
3407
|
+
pipeStrategy: "all",
|
|
3408
|
+
dateStrategy: "format:date-time",
|
|
3409
|
+
mapStrategy: "entries",
|
|
3410
|
+
removeAdditionalStrategy: "passthrough",
|
|
3411
|
+
allowedAdditionalProperties: !0,
|
|
3412
|
+
rejectedAdditionalProperties: !1,
|
|
3413
|
+
definitionPath: "definitions",
|
|
3414
|
+
target: "jsonSchema7",
|
|
3415
|
+
strictUnions: !1,
|
|
3416
|
+
definitions: {},
|
|
3417
|
+
errorMessages: !1,
|
|
3418
|
+
markdownDescription: !1,
|
|
3419
|
+
patternStrategy: "escape",
|
|
3420
|
+
applyRegexFlags: !1,
|
|
3421
|
+
emailStrategy: "format:email",
|
|
3422
|
+
base64Strategy: "contentEncoding:base64",
|
|
3423
|
+
nameStrategy: "ref",
|
|
3424
|
+
openAiAnyTypeName: "OpenAiAnyType"
|
|
3425
|
+
}, Hn = (n) => typeof n == "string" ? {
|
|
3426
|
+
...wt,
|
|
3427
|
+
name: n
|
|
3428
|
+
} : {
|
|
3429
|
+
...wt,
|
|
3430
|
+
...n
|
|
3431
|
+
}, Gn = (n) => {
|
|
3432
|
+
const e = Hn(n), t = e.name !== void 0 ? [...e.basePath, e.definitionPath, e.name] : e.basePath;
|
|
3433
|
+
return {
|
|
3434
|
+
...e,
|
|
3435
|
+
flags: { hasReferencedOpenAiAnyType: !1 },
|
|
3436
|
+
currentPath: t,
|
|
3437
|
+
propertyPath: void 0,
|
|
3438
|
+
seen: new Map(Object.entries(e.definitions).map(([r, s]) => [
|
|
3439
|
+
s._def,
|
|
3440
|
+
{
|
|
3441
|
+
def: s._def,
|
|
3442
|
+
path: [...e.basePath, e.definitionPath, r],
|
|
3443
|
+
// Resolution of references will be forced even though seen, so it's ok that the schema is undefined here for now.
|
|
3444
|
+
jsonSchema: void 0
|
|
3445
|
+
}
|
|
3446
|
+
]))
|
|
3447
|
+
};
|
|
3448
|
+
};
|
|
3449
|
+
function Bt(n, e, t, r) {
|
|
3450
|
+
r != null && r.errorMessages && t && (n.errorMessage = {
|
|
3451
|
+
...n.errorMessage,
|
|
3452
|
+
[e]: t
|
|
3453
|
+
});
|
|
3454
|
+
}
|
|
3455
|
+
function A(n, e, t, r, s) {
|
|
3456
|
+
n[e] = t, Bt(n, e, r, s);
|
|
3457
|
+
}
|
|
3458
|
+
const Wt = (n, e) => {
|
|
3459
|
+
let t = 0;
|
|
3460
|
+
for (; t < n.length && t < e.length && n[t] === e[t]; t++)
|
|
3461
|
+
;
|
|
3462
|
+
return [(n.length - t).toString(), ...e.slice(t)].join("/");
|
|
3463
|
+
};
|
|
3464
|
+
function M(n) {
|
|
3465
|
+
if (n.target !== "openAi")
|
|
3466
|
+
return {};
|
|
3467
|
+
const e = [
|
|
3468
|
+
...n.basePath,
|
|
3469
|
+
n.definitionPath,
|
|
3470
|
+
n.openAiAnyTypeName
|
|
3471
|
+
];
|
|
3472
|
+
return n.flags.hasReferencedOpenAiAnyType = !0, {
|
|
3473
|
+
$ref: n.$refStrategy === "relative" ? Wt(e, n.currentPath) : e.join("/")
|
|
3474
|
+
};
|
|
3475
|
+
}
|
|
3476
|
+
function Yn(n, e) {
|
|
3477
|
+
var r, s, a;
|
|
3478
|
+
const t = {
|
|
3479
|
+
type: "array"
|
|
3480
|
+
};
|
|
3481
|
+
return (r = n.type) != null && r._def && ((a = (s = n.type) == null ? void 0 : s._def) == null ? void 0 : a.typeName) !== l.ZodAny && (t.items = x(n.type._def, {
|
|
3482
|
+
...e,
|
|
3483
|
+
currentPath: [...e.currentPath, "items"]
|
|
3484
|
+
})), n.minLength && A(t, "minItems", n.minLength.value, n.minLength.message, e), n.maxLength && A(t, "maxItems", n.maxLength.value, n.maxLength.message, e), n.exactLength && (A(t, "minItems", n.exactLength.value, n.exactLength.message, e), A(t, "maxItems", n.exactLength.value, n.exactLength.message, e)), t;
|
|
3485
|
+
}
|
|
3486
|
+
function Kn(n, e) {
|
|
3487
|
+
const t = {
|
|
3488
|
+
type: "integer",
|
|
3489
|
+
format: "int64"
|
|
3490
|
+
};
|
|
3491
|
+
if (!n.checks)
|
|
3492
|
+
return t;
|
|
3493
|
+
for (const r of n.checks)
|
|
3494
|
+
switch (r.kind) {
|
|
3495
|
+
case "min":
|
|
3496
|
+
e.target === "jsonSchema7" ? r.inclusive ? A(t, "minimum", r.value, r.message, e) : A(t, "exclusiveMinimum", r.value, r.message, e) : (r.inclusive || (t.exclusiveMinimum = !0), A(t, "minimum", r.value, r.message, e));
|
|
3497
|
+
break;
|
|
3498
|
+
case "max":
|
|
3499
|
+
e.target === "jsonSchema7" ? r.inclusive ? A(t, "maximum", r.value, r.message, e) : A(t, "exclusiveMaximum", r.value, r.message, e) : (r.inclusive || (t.exclusiveMaximum = !0), A(t, "maximum", r.value, r.message, e));
|
|
3500
|
+
break;
|
|
3501
|
+
case "multipleOf":
|
|
3502
|
+
A(t, "multipleOf", r.value, r.message, e);
|
|
3503
|
+
break;
|
|
3504
|
+
}
|
|
3505
|
+
return t;
|
|
3506
|
+
}
|
|
3507
|
+
function Xn() {
|
|
3508
|
+
return {
|
|
3509
|
+
type: "boolean"
|
|
3510
|
+
};
|
|
3511
|
+
}
|
|
3512
|
+
function qt(n, e) {
|
|
3513
|
+
return x(n.type._def, e);
|
|
3514
|
+
}
|
|
3515
|
+
const Qn = (n, e) => x(n.innerType._def, e);
|
|
3516
|
+
function Jt(n, e, t) {
|
|
3517
|
+
const r = t != null ? t : e.dateStrategy;
|
|
3518
|
+
if (Array.isArray(r))
|
|
3519
|
+
return {
|
|
3520
|
+
anyOf: r.map((s, a) => Jt(n, e, s))
|
|
3521
|
+
};
|
|
3522
|
+
switch (r) {
|
|
3523
|
+
case "string":
|
|
3524
|
+
case "format:date-time":
|
|
3525
|
+
return {
|
|
3526
|
+
type: "string",
|
|
3527
|
+
format: "date-time"
|
|
3528
|
+
};
|
|
3529
|
+
case "format:date":
|
|
3530
|
+
return {
|
|
3531
|
+
type: "string",
|
|
3532
|
+
format: "date"
|
|
3533
|
+
};
|
|
3534
|
+
case "integer":
|
|
3535
|
+
return er(n, e);
|
|
3536
|
+
}
|
|
3537
|
+
}
|
|
3538
|
+
const er = (n, e) => {
|
|
3539
|
+
const t = {
|
|
3540
|
+
type: "integer",
|
|
3541
|
+
format: "unix-time"
|
|
3542
|
+
};
|
|
3543
|
+
if (e.target === "openApi3")
|
|
3544
|
+
return t;
|
|
3545
|
+
for (const r of n.checks)
|
|
3546
|
+
switch (r.kind) {
|
|
3547
|
+
case "min":
|
|
3548
|
+
A(
|
|
3549
|
+
t,
|
|
3550
|
+
"minimum",
|
|
3551
|
+
r.value,
|
|
3552
|
+
// This is in milliseconds
|
|
3553
|
+
r.message,
|
|
3554
|
+
e
|
|
3555
|
+
);
|
|
3556
|
+
break;
|
|
3557
|
+
case "max":
|
|
3558
|
+
A(
|
|
3559
|
+
t,
|
|
3560
|
+
"maximum",
|
|
3561
|
+
r.value,
|
|
3562
|
+
// This is in milliseconds
|
|
3563
|
+
r.message,
|
|
3564
|
+
e
|
|
3565
|
+
);
|
|
3566
|
+
break;
|
|
3567
|
+
}
|
|
3568
|
+
return t;
|
|
3569
|
+
};
|
|
3570
|
+
function tr(n, e) {
|
|
3571
|
+
return {
|
|
3572
|
+
...x(n.innerType._def, e),
|
|
3573
|
+
default: n.defaultValue()
|
|
3574
|
+
};
|
|
3575
|
+
}
|
|
3576
|
+
function nr(n, e) {
|
|
3577
|
+
return e.effectStrategy === "input" ? x(n.schema._def, e) : M(e);
|
|
3578
|
+
}
|
|
3579
|
+
function rr(n) {
|
|
3580
|
+
return {
|
|
3581
|
+
type: "string",
|
|
3582
|
+
enum: Array.from(n.values)
|
|
3583
|
+
};
|
|
3584
|
+
}
|
|
3585
|
+
const sr = (n) => "type" in n && n.type === "string" ? !1 : "allOf" in n;
|
|
3586
|
+
function ar(n, e) {
|
|
3587
|
+
const t = [
|
|
3588
|
+
x(n.left._def, {
|
|
3589
|
+
...e,
|
|
3590
|
+
currentPath: [...e.currentPath, "allOf", "0"]
|
|
3591
|
+
}),
|
|
3592
|
+
x(n.right._def, {
|
|
3593
|
+
...e,
|
|
3594
|
+
currentPath: [...e.currentPath, "allOf", "1"]
|
|
3595
|
+
})
|
|
3596
|
+
].filter((a) => !!a);
|
|
3597
|
+
let r = e.target === "jsonSchema2019-09" ? { unevaluatedProperties: !1 } : void 0;
|
|
3598
|
+
const s = [];
|
|
3599
|
+
return t.forEach((a) => {
|
|
3600
|
+
if (sr(a))
|
|
3601
|
+
s.push(...a.allOf), a.unevaluatedProperties === void 0 && (r = void 0);
|
|
3602
|
+
else {
|
|
3603
|
+
let i = a;
|
|
3604
|
+
if ("additionalProperties" in a && a.additionalProperties === !1) {
|
|
3605
|
+
const { additionalProperties: o, ...c } = a;
|
|
3606
|
+
i = c;
|
|
3607
|
+
} else
|
|
3608
|
+
r = void 0;
|
|
3609
|
+
s.push(i);
|
|
3610
|
+
}
|
|
3611
|
+
}), s.length ? {
|
|
3612
|
+
allOf: s,
|
|
3613
|
+
...r
|
|
3614
|
+
} : void 0;
|
|
3615
|
+
}
|
|
3616
|
+
function ir(n, e) {
|
|
3617
|
+
const t = typeof n.value;
|
|
3618
|
+
return t !== "bigint" && t !== "number" && t !== "boolean" && t !== "string" ? {
|
|
3619
|
+
type: Array.isArray(n.value) ? "array" : "object"
|
|
3620
|
+
} : e.target === "openApi3" ? {
|
|
3621
|
+
type: t === "bigint" ? "integer" : t,
|
|
3622
|
+
enum: [n.value]
|
|
3623
|
+
} : {
|
|
3624
|
+
type: t === "bigint" ? "integer" : t,
|
|
3625
|
+
const: n.value
|
|
3626
|
+
};
|
|
3627
|
+
}
|
|
3628
|
+
let De;
|
|
3629
|
+
const R = {
|
|
3630
|
+
/**
|
|
3631
|
+
* `c` was changed to `[cC]` to replicate /i flag
|
|
3632
|
+
*/
|
|
3633
|
+
cuid: /^[cC][^\s-]{8,}$/,
|
|
3634
|
+
cuid2: /^[0-9a-z]+$/,
|
|
3635
|
+
ulid: /^[0-9A-HJKMNP-TV-Z]{26}$/,
|
|
3636
|
+
/**
|
|
3637
|
+
* `a-z` was added to replicate /i flag
|
|
3638
|
+
*/
|
|
3639
|
+
email: /^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,
|
|
3640
|
+
/**
|
|
3641
|
+
* Constructed a valid Unicode RegExp
|
|
3642
|
+
*
|
|
3643
|
+
* Lazily instantiate since this type of regex isn't supported
|
|
3644
|
+
* in all envs (e.g. React Native).
|
|
3645
|
+
*
|
|
3646
|
+
* See:
|
|
3647
|
+
* https://github.com/colinhacks/zod/issues/2433
|
|
3648
|
+
* Fix in Zod:
|
|
3649
|
+
* https://github.com/colinhacks/zod/commit/9340fd51e48576a75adc919bff65dbc4a5d4c99b
|
|
3650
|
+
*/
|
|
3651
|
+
emoji: () => (De === void 0 && (De = RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$", "u")), De),
|
|
3652
|
+
/**
|
|
3653
|
+
* Unused
|
|
3654
|
+
*/
|
|
3655
|
+
uuid: /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/,
|
|
3656
|
+
/**
|
|
3657
|
+
* Unused
|
|
3658
|
+
*/
|
|
3659
|
+
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])$/,
|
|
3660
|
+
ipv4Cidr: /^(?:(?: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])\/(3[0-2]|[12]?[0-9])$/,
|
|
3661
|
+
/**
|
|
3662
|
+
* Unused
|
|
3663
|
+
*/
|
|
3664
|
+
ipv6: /^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,
|
|
3665
|
+
ipv6Cidr: /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,
|
|
3666
|
+
base64: /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,
|
|
3667
|
+
base64url: /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,
|
|
3668
|
+
nanoid: /^[a-zA-Z0-9_-]{21}$/,
|
|
3669
|
+
jwt: /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/
|
|
3670
|
+
};
|
|
3671
|
+
function Ht(n, e) {
|
|
3672
|
+
const t = {
|
|
3673
|
+
type: "string"
|
|
3674
|
+
};
|
|
3675
|
+
if (n.checks)
|
|
3676
|
+
for (const r of n.checks)
|
|
3677
|
+
switch (r.kind) {
|
|
3678
|
+
case "min":
|
|
3679
|
+
A(t, "minLength", typeof t.minLength == "number" ? Math.max(t.minLength, r.value) : r.value, r.message, e);
|
|
3680
|
+
break;
|
|
3681
|
+
case "max":
|
|
3682
|
+
A(t, "maxLength", typeof t.maxLength == "number" ? Math.min(t.maxLength, r.value) : r.value, r.message, e);
|
|
3683
|
+
break;
|
|
3684
|
+
case "email":
|
|
3685
|
+
switch (e.emailStrategy) {
|
|
3686
|
+
case "format:email":
|
|
3687
|
+
$(t, "email", r.message, e);
|
|
3688
|
+
break;
|
|
3689
|
+
case "format:idn-email":
|
|
3690
|
+
$(t, "idn-email", r.message, e);
|
|
3691
|
+
break;
|
|
3692
|
+
case "pattern:zod":
|
|
3693
|
+
Z(t, R.email, r.message, e);
|
|
3694
|
+
break;
|
|
3695
|
+
}
|
|
3696
|
+
break;
|
|
3697
|
+
case "url":
|
|
3698
|
+
$(t, "uri", r.message, e);
|
|
3699
|
+
break;
|
|
3700
|
+
case "uuid":
|
|
3701
|
+
$(t, "uuid", r.message, e);
|
|
3702
|
+
break;
|
|
3703
|
+
case "regex":
|
|
3704
|
+
Z(t, r.regex, r.message, e);
|
|
3705
|
+
break;
|
|
3706
|
+
case "cuid":
|
|
3707
|
+
Z(t, R.cuid, r.message, e);
|
|
3708
|
+
break;
|
|
3709
|
+
case "cuid2":
|
|
3710
|
+
Z(t, R.cuid2, r.message, e);
|
|
3711
|
+
break;
|
|
3712
|
+
case "startsWith":
|
|
3713
|
+
Z(t, RegExp(`^${Le(r.value, e)}`), r.message, e);
|
|
3714
|
+
break;
|
|
3715
|
+
case "endsWith":
|
|
3716
|
+
Z(t, RegExp(`${Le(r.value, e)}$`), r.message, e);
|
|
3717
|
+
break;
|
|
3718
|
+
case "datetime":
|
|
3719
|
+
$(t, "date-time", r.message, e);
|
|
3720
|
+
break;
|
|
3721
|
+
case "date":
|
|
3722
|
+
$(t, "date", r.message, e);
|
|
3723
|
+
break;
|
|
3724
|
+
case "time":
|
|
3725
|
+
$(t, "time", r.message, e);
|
|
3726
|
+
break;
|
|
3727
|
+
case "duration":
|
|
3728
|
+
$(t, "duration", r.message, e);
|
|
3729
|
+
break;
|
|
3730
|
+
case "length":
|
|
3731
|
+
A(t, "minLength", typeof t.minLength == "number" ? Math.max(t.minLength, r.value) : r.value, r.message, e), A(t, "maxLength", typeof t.maxLength == "number" ? Math.min(t.maxLength, r.value) : r.value, r.message, e);
|
|
3732
|
+
break;
|
|
3733
|
+
case "includes": {
|
|
3734
|
+
Z(t, RegExp(Le(r.value, e)), r.message, e);
|
|
3735
|
+
break;
|
|
3736
|
+
}
|
|
3737
|
+
case "ip": {
|
|
3738
|
+
r.version !== "v6" && $(t, "ipv4", r.message, e), r.version !== "v4" && $(t, "ipv6", r.message, e);
|
|
3739
|
+
break;
|
|
3740
|
+
}
|
|
3741
|
+
case "base64url":
|
|
3742
|
+
Z(t, R.base64url, r.message, e);
|
|
3743
|
+
break;
|
|
3744
|
+
case "jwt":
|
|
3745
|
+
Z(t, R.jwt, r.message, e);
|
|
3746
|
+
break;
|
|
3747
|
+
case "cidr": {
|
|
3748
|
+
r.version !== "v6" && Z(t, R.ipv4Cidr, r.message, e), r.version !== "v4" && Z(t, R.ipv6Cidr, r.message, e);
|
|
3749
|
+
break;
|
|
3750
|
+
}
|
|
3751
|
+
case "emoji":
|
|
3752
|
+
Z(t, R.emoji(), r.message, e);
|
|
3753
|
+
break;
|
|
3754
|
+
case "ulid": {
|
|
3755
|
+
Z(t, R.ulid, r.message, e);
|
|
3756
|
+
break;
|
|
3757
|
+
}
|
|
3758
|
+
case "base64": {
|
|
3759
|
+
switch (e.base64Strategy) {
|
|
3760
|
+
case "format:binary": {
|
|
3761
|
+
$(t, "binary", r.message, e);
|
|
3762
|
+
break;
|
|
3763
|
+
}
|
|
3764
|
+
case "contentEncoding:base64": {
|
|
3765
|
+
A(t, "contentEncoding", "base64", r.message, e);
|
|
3766
|
+
break;
|
|
3767
|
+
}
|
|
3768
|
+
case "pattern:zod": {
|
|
3769
|
+
Z(t, R.base64, r.message, e);
|
|
3770
|
+
break;
|
|
3771
|
+
}
|
|
3772
|
+
}
|
|
3773
|
+
break;
|
|
3774
|
+
}
|
|
3775
|
+
case "nanoid":
|
|
3776
|
+
Z(t, R.nanoid, r.message, e);
|
|
3777
|
+
}
|
|
3778
|
+
return t;
|
|
3779
|
+
}
|
|
3780
|
+
function Le(n, e) {
|
|
3781
|
+
return e.patternStrategy === "escape" ? cr(n) : n;
|
|
3782
|
+
}
|
|
3783
|
+
const or = new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");
|
|
3784
|
+
function cr(n) {
|
|
3785
|
+
let e = "";
|
|
3786
|
+
for (let t = 0; t < n.length; t++)
|
|
3787
|
+
or.has(n[t]) || (e += "\\"), e += n[t];
|
|
3788
|
+
return e;
|
|
3789
|
+
}
|
|
3790
|
+
function $(n, e, t, r) {
|
|
3791
|
+
var s;
|
|
3792
|
+
n.format || (s = n.anyOf) != null && s.some((a) => a.format) ? (n.anyOf || (n.anyOf = []), n.format && (n.anyOf.push({
|
|
3793
|
+
format: n.format,
|
|
3794
|
+
...n.errorMessage && r.errorMessages && {
|
|
3795
|
+
errorMessage: { format: n.errorMessage.format }
|
|
3796
|
+
}
|
|
3797
|
+
}), delete n.format, n.errorMessage && (delete n.errorMessage.format, Object.keys(n.errorMessage).length === 0 && delete n.errorMessage)), n.anyOf.push({
|
|
3798
|
+
format: e,
|
|
3799
|
+
...t && r.errorMessages && { errorMessage: { format: t } }
|
|
3800
|
+
})) : A(n, "format", e, t, r);
|
|
3801
|
+
}
|
|
3802
|
+
function Z(n, e, t, r) {
|
|
3803
|
+
var s;
|
|
3804
|
+
n.pattern || (s = n.allOf) != null && s.some((a) => a.pattern) ? (n.allOf || (n.allOf = []), n.pattern && (n.allOf.push({
|
|
3805
|
+
pattern: n.pattern,
|
|
3806
|
+
...n.errorMessage && r.errorMessages && {
|
|
3807
|
+
errorMessage: { pattern: n.errorMessage.pattern }
|
|
3808
|
+
}
|
|
3809
|
+
}), delete n.pattern, n.errorMessage && (delete n.errorMessage.pattern, Object.keys(n.errorMessage).length === 0 && delete n.errorMessage)), n.allOf.push({
|
|
3810
|
+
pattern: St(e, r),
|
|
3811
|
+
...t && r.errorMessages && { errorMessage: { pattern: t } }
|
|
3812
|
+
})) : A(n, "pattern", St(e, r), t, r);
|
|
3813
|
+
}
|
|
3814
|
+
function St(n, e) {
|
|
3815
|
+
var c;
|
|
3816
|
+
if (!e.applyRegexFlags || !n.flags)
|
|
3817
|
+
return n.source;
|
|
3818
|
+
const t = {
|
|
3819
|
+
i: n.flags.includes("i"),
|
|
3820
|
+
m: n.flags.includes("m"),
|
|
3821
|
+
s: n.flags.includes("s")
|
|
3822
|
+
// `.` matches newlines
|
|
3823
|
+
}, r = t.i ? n.source.toLowerCase() : n.source;
|
|
3824
|
+
let s = "", a = !1, i = !1, o = !1;
|
|
3825
|
+
for (let u = 0; u < r.length; u++) {
|
|
3826
|
+
if (a) {
|
|
3827
|
+
s += r[u], a = !1;
|
|
3828
|
+
continue;
|
|
3829
|
+
}
|
|
3830
|
+
if (t.i) {
|
|
3831
|
+
if (i) {
|
|
3832
|
+
if (r[u].match(/[a-z]/)) {
|
|
3833
|
+
o ? (s += r[u], s += `${r[u - 2]}-${r[u]}`.toUpperCase(), o = !1) : r[u + 1] === "-" && ((c = r[u + 2]) != null && c.match(/[a-z]/)) ? (s += r[u], o = !0) : s += `${r[u]}${r[u].toUpperCase()}`;
|
|
3834
|
+
continue;
|
|
3835
|
+
}
|
|
3836
|
+
} else if (r[u].match(/[a-z]/)) {
|
|
3837
|
+
s += `[${r[u]}${r[u].toUpperCase()}]`;
|
|
3838
|
+
continue;
|
|
3839
|
+
}
|
|
3840
|
+
}
|
|
3841
|
+
if (t.m) {
|
|
3842
|
+
if (r[u] === "^") {
|
|
3843
|
+
s += `(^|(?<=[\r
|
|
3844
|
+
]))`;
|
|
3845
|
+
continue;
|
|
3846
|
+
} else if (r[u] === "$") {
|
|
3847
|
+
s += `($|(?=[\r
|
|
3848
|
+
]))`;
|
|
3849
|
+
continue;
|
|
3850
|
+
}
|
|
3851
|
+
}
|
|
3852
|
+
if (t.s && r[u] === ".") {
|
|
3853
|
+
s += i ? `${r[u]}\r
|
|
3854
|
+
` : `[${r[u]}\r
|
|
3855
|
+
]`;
|
|
3856
|
+
continue;
|
|
3857
|
+
}
|
|
3858
|
+
s += r[u], r[u] === "\\" ? a = !0 : i && r[u] === "]" ? i = !1 : !i && r[u] === "[" && (i = !0);
|
|
3859
|
+
}
|
|
3860
|
+
try {
|
|
3861
|
+
new RegExp(s);
|
|
3862
|
+
} catch (u) {
|
|
3863
|
+
return console.warn(`Could not convert regex pattern at ${e.currentPath.join("/")} to a flag-independent form! Falling back to the flag-ignorant source`), n.source;
|
|
3864
|
+
}
|
|
3865
|
+
return s;
|
|
3866
|
+
}
|
|
3867
|
+
function Gt(n, e) {
|
|
3868
|
+
var r, s, a, i, o, c, u;
|
|
3869
|
+
if (e.target === "openAi" && console.warn("Warning: OpenAI may not support records in schemas! Try an array of key-value pairs instead."), e.target === "openApi3" && ((r = n.keyType) == null ? void 0 : r._def.typeName) === l.ZodEnum)
|
|
3870
|
+
return {
|
|
3871
|
+
type: "object",
|
|
3872
|
+
required: n.keyType._def.values,
|
|
3873
|
+
properties: n.keyType._def.values.reduce((y, T) => {
|
|
3874
|
+
var v;
|
|
3875
|
+
return {
|
|
3876
|
+
...y,
|
|
3877
|
+
[T]: (v = x(n.valueType._def, {
|
|
3878
|
+
...e,
|
|
3879
|
+
currentPath: [...e.currentPath, "properties", T]
|
|
3880
|
+
})) != null ? v : M(e)
|
|
3881
|
+
};
|
|
3882
|
+
}, {}),
|
|
3883
|
+
additionalProperties: e.rejectedAdditionalProperties
|
|
3884
|
+
};
|
|
3885
|
+
const t = {
|
|
3886
|
+
type: "object",
|
|
3887
|
+
additionalProperties: (s = x(n.valueType._def, {
|
|
3888
|
+
...e,
|
|
3889
|
+
currentPath: [...e.currentPath, "additionalProperties"]
|
|
3890
|
+
})) != null ? s : e.allowedAdditionalProperties
|
|
3891
|
+
};
|
|
3892
|
+
if (e.target === "openApi3")
|
|
3893
|
+
return t;
|
|
3894
|
+
if (((a = n.keyType) == null ? void 0 : a._def.typeName) === l.ZodString && ((i = n.keyType._def.checks) != null && i.length)) {
|
|
3895
|
+
const { type: y, ...T } = Ht(n.keyType._def, e);
|
|
3896
|
+
return {
|
|
3897
|
+
...t,
|
|
3898
|
+
propertyNames: T
|
|
3899
|
+
};
|
|
3900
|
+
} else {
|
|
3901
|
+
if (((o = n.keyType) == null ? void 0 : o._def.typeName) === l.ZodEnum)
|
|
3902
|
+
return {
|
|
3903
|
+
...t,
|
|
3904
|
+
propertyNames: {
|
|
3905
|
+
enum: n.keyType._def.values
|
|
3906
|
+
}
|
|
3907
|
+
};
|
|
3908
|
+
if (((c = n.keyType) == null ? void 0 : c._def.typeName) === l.ZodBranded && n.keyType._def.type._def.typeName === l.ZodString && ((u = n.keyType._def.type._def.checks) != null && u.length)) {
|
|
3909
|
+
const { type: y, ...T } = qt(n.keyType._def, e);
|
|
3910
|
+
return {
|
|
3911
|
+
...t,
|
|
3912
|
+
propertyNames: T
|
|
3913
|
+
};
|
|
3914
|
+
}
|
|
3915
|
+
}
|
|
3916
|
+
return t;
|
|
3917
|
+
}
|
|
3918
|
+
function ur(n, e) {
|
|
3919
|
+
if (e.mapStrategy === "record")
|
|
3920
|
+
return Gt(n, e);
|
|
3921
|
+
const t = x(n.keyType._def, {
|
|
3922
|
+
...e,
|
|
3923
|
+
currentPath: [...e.currentPath, "items", "items", "0"]
|
|
3924
|
+
}) || M(e), r = x(n.valueType._def, {
|
|
3925
|
+
...e,
|
|
3926
|
+
currentPath: [...e.currentPath, "items", "items", "1"]
|
|
3927
|
+
}) || M(e);
|
|
3928
|
+
return {
|
|
3929
|
+
type: "array",
|
|
3930
|
+
maxItems: 125,
|
|
3931
|
+
items: {
|
|
3932
|
+
type: "array",
|
|
3933
|
+
items: [t, r],
|
|
3934
|
+
minItems: 2,
|
|
3935
|
+
maxItems: 2
|
|
3936
|
+
}
|
|
3937
|
+
};
|
|
3938
|
+
}
|
|
3939
|
+
function dr(n) {
|
|
3940
|
+
const e = n.values, r = Object.keys(n.values).filter((a) => typeof e[e[a]] != "number").map((a) => e[a]), s = Array.from(new Set(r.map((a) => typeof a)));
|
|
3941
|
+
return {
|
|
3942
|
+
type: s.length === 1 ? s[0] === "string" ? "string" : "number" : ["string", "number"],
|
|
3943
|
+
enum: r
|
|
3944
|
+
};
|
|
3945
|
+
}
|
|
3946
|
+
function lr(n) {
|
|
3947
|
+
return n.target === "openAi" ? void 0 : {
|
|
3948
|
+
not: M({
|
|
3949
|
+
...n,
|
|
3950
|
+
currentPath: [...n.currentPath, "not"]
|
|
3951
|
+
})
|
|
3952
|
+
};
|
|
3953
|
+
}
|
|
3954
|
+
function fr(n) {
|
|
3955
|
+
return n.target === "openApi3" ? {
|
|
3956
|
+
enum: ["null"],
|
|
3957
|
+
nullable: !0
|
|
3958
|
+
} : {
|
|
3959
|
+
type: "null"
|
|
3960
|
+
};
|
|
3961
|
+
}
|
|
3962
|
+
const Ne = {
|
|
3963
|
+
ZodString: "string",
|
|
3964
|
+
ZodNumber: "number",
|
|
3965
|
+
ZodBigInt: "integer",
|
|
3966
|
+
ZodBoolean: "boolean",
|
|
3967
|
+
ZodNull: "null"
|
|
3968
|
+
};
|
|
3969
|
+
function hr(n, e) {
|
|
3970
|
+
if (e.target === "openApi3")
|
|
3971
|
+
return At(n, e);
|
|
3972
|
+
const t = n.options instanceof Map ? Array.from(n.options.values()) : n.options;
|
|
3973
|
+
if (t.every((r) => r._def.typeName in Ne && (!r._def.checks || !r._def.checks.length))) {
|
|
3974
|
+
const r = t.reduce((s, a) => {
|
|
3975
|
+
const i = Ne[a._def.typeName];
|
|
3976
|
+
return i && !s.includes(i) ? [...s, i] : s;
|
|
3977
|
+
}, []);
|
|
3978
|
+
return {
|
|
3979
|
+
type: r.length > 1 ? r : r[0]
|
|
3980
|
+
};
|
|
3981
|
+
} else if (t.every((r) => r._def.typeName === "ZodLiteral" && !r.description)) {
|
|
3982
|
+
const r = t.reduce((s, a) => {
|
|
3983
|
+
const i = typeof a._def.value;
|
|
3984
|
+
switch (i) {
|
|
3985
|
+
case "string":
|
|
3986
|
+
case "number":
|
|
3987
|
+
case "boolean":
|
|
3988
|
+
return [...s, i];
|
|
3989
|
+
case "bigint":
|
|
3990
|
+
return [...s, "integer"];
|
|
3991
|
+
case "object":
|
|
3992
|
+
if (a._def.value === null)
|
|
3993
|
+
return [...s, "null"];
|
|
3994
|
+
case "symbol":
|
|
3995
|
+
case "undefined":
|
|
3996
|
+
case "function":
|
|
3997
|
+
default:
|
|
3998
|
+
return s;
|
|
3999
|
+
}
|
|
4000
|
+
}, []);
|
|
4001
|
+
if (r.length === t.length) {
|
|
4002
|
+
const s = r.filter((a, i, o) => o.indexOf(a) === i);
|
|
4003
|
+
return {
|
|
4004
|
+
type: s.length > 1 ? s : s[0],
|
|
4005
|
+
enum: t.reduce((a, i) => a.includes(i._def.value) ? a : [...a, i._def.value], [])
|
|
4006
|
+
};
|
|
4007
|
+
}
|
|
4008
|
+
} else if (t.every((r) => r._def.typeName === "ZodEnum"))
|
|
4009
|
+
return {
|
|
4010
|
+
type: "string",
|
|
4011
|
+
enum: t.reduce((r, s) => [
|
|
4012
|
+
...r,
|
|
4013
|
+
...s._def.values.filter((a) => !r.includes(a))
|
|
4014
|
+
], [])
|
|
4015
|
+
};
|
|
4016
|
+
return At(n, e);
|
|
4017
|
+
}
|
|
4018
|
+
const At = (n, e) => {
|
|
4019
|
+
const t = (n.options instanceof Map ? Array.from(n.options.values()) : n.options).map((r, s) => x(r._def, {
|
|
4020
|
+
...e,
|
|
4021
|
+
currentPath: [...e.currentPath, "anyOf", `${s}`]
|
|
4022
|
+
})).filter((r) => !!r && (!e.strictUnions || typeof r == "object" && Object.keys(r).length > 0));
|
|
4023
|
+
return t.length ? { anyOf: t } : void 0;
|
|
4024
|
+
};
|
|
4025
|
+
function pr(n, e) {
|
|
4026
|
+
if (["ZodString", "ZodNumber", "ZodBigInt", "ZodBoolean", "ZodNull"].includes(n.innerType._def.typeName) && (!n.innerType._def.checks || !n.innerType._def.checks.length))
|
|
4027
|
+
return e.target === "openApi3" ? {
|
|
4028
|
+
type: Ne[n.innerType._def.typeName],
|
|
4029
|
+
nullable: !0
|
|
4030
|
+
} : {
|
|
4031
|
+
type: [
|
|
4032
|
+
Ne[n.innerType._def.typeName],
|
|
4033
|
+
"null"
|
|
4034
|
+
]
|
|
4035
|
+
};
|
|
4036
|
+
if (e.target === "openApi3") {
|
|
4037
|
+
const r = x(n.innerType._def, {
|
|
4038
|
+
...e,
|
|
4039
|
+
currentPath: [...e.currentPath]
|
|
4040
|
+
});
|
|
4041
|
+
return r && "$ref" in r ? { allOf: [r], nullable: !0 } : r && { ...r, nullable: !0 };
|
|
4042
|
+
}
|
|
4043
|
+
const t = x(n.innerType._def, {
|
|
4044
|
+
...e,
|
|
4045
|
+
currentPath: [...e.currentPath, "anyOf", "0"]
|
|
4046
|
+
});
|
|
4047
|
+
return t && { anyOf: [t, { type: "null" }] };
|
|
4048
|
+
}
|
|
4049
|
+
function mr(n, e) {
|
|
4050
|
+
const t = {
|
|
4051
|
+
type: "number"
|
|
4052
|
+
};
|
|
4053
|
+
if (!n.checks)
|
|
4054
|
+
return t;
|
|
4055
|
+
for (const r of n.checks)
|
|
4056
|
+
switch (r.kind) {
|
|
4057
|
+
case "int":
|
|
4058
|
+
t.type = "integer", Bt(t, "type", r.message, e);
|
|
4059
|
+
break;
|
|
4060
|
+
case "min":
|
|
4061
|
+
e.target === "jsonSchema7" ? r.inclusive ? A(t, "minimum", r.value, r.message, e) : A(t, "exclusiveMinimum", r.value, r.message, e) : (r.inclusive || (t.exclusiveMinimum = !0), A(t, "minimum", r.value, r.message, e));
|
|
4062
|
+
break;
|
|
4063
|
+
case "max":
|
|
4064
|
+
e.target === "jsonSchema7" ? r.inclusive ? A(t, "maximum", r.value, r.message, e) : A(t, "exclusiveMaximum", r.value, r.message, e) : (r.inclusive || (t.exclusiveMaximum = !0), A(t, "maximum", r.value, r.message, e));
|
|
4065
|
+
break;
|
|
4066
|
+
case "multipleOf":
|
|
4067
|
+
A(t, "multipleOf", r.value, r.message, e);
|
|
4068
|
+
break;
|
|
4069
|
+
}
|
|
4070
|
+
return t;
|
|
4071
|
+
}
|
|
4072
|
+
function yr(n, e) {
|
|
4073
|
+
const t = e.target === "openAi", r = {
|
|
4074
|
+
type: "object",
|
|
4075
|
+
properties: {}
|
|
4076
|
+
}, s = [], a = n.shape();
|
|
4077
|
+
for (const o in a) {
|
|
4078
|
+
let c = a[o];
|
|
4079
|
+
if (c === void 0 || c._def === void 0)
|
|
4080
|
+
continue;
|
|
4081
|
+
let u = vr(c);
|
|
4082
|
+
u && t && (c._def.typeName === "ZodOptional" && (c = c._def.innerType), c.isNullable() || (c = c.nullable()), u = !1);
|
|
4083
|
+
const y = x(c._def, {
|
|
4084
|
+
...e,
|
|
4085
|
+
currentPath: [...e.currentPath, "properties", o],
|
|
4086
|
+
propertyPath: [...e.currentPath, "properties", o]
|
|
4087
|
+
});
|
|
4088
|
+
y !== void 0 && (r.properties[o] = y, u || s.push(o));
|
|
4089
|
+
}
|
|
4090
|
+
s.length && (r.required = s);
|
|
4091
|
+
const i = gr(n, e);
|
|
4092
|
+
return i !== void 0 && (r.additionalProperties = i), r;
|
|
4093
|
+
}
|
|
4094
|
+
function gr(n, e) {
|
|
4095
|
+
if (n.catchall._def.typeName !== "ZodNever")
|
|
4096
|
+
return x(n.catchall._def, {
|
|
4097
|
+
...e,
|
|
4098
|
+
currentPath: [...e.currentPath, "additionalProperties"]
|
|
4099
|
+
});
|
|
4100
|
+
switch (n.unknownKeys) {
|
|
4101
|
+
case "passthrough":
|
|
4102
|
+
return e.allowedAdditionalProperties;
|
|
4103
|
+
case "strict":
|
|
4104
|
+
return e.rejectedAdditionalProperties;
|
|
4105
|
+
case "strip":
|
|
4106
|
+
return e.removeAdditionalStrategy === "strict" ? e.allowedAdditionalProperties : e.rejectedAdditionalProperties;
|
|
4107
|
+
}
|
|
4108
|
+
}
|
|
4109
|
+
function vr(n) {
|
|
4110
|
+
try {
|
|
4111
|
+
return n.isOptional();
|
|
4112
|
+
} catch (e) {
|
|
4113
|
+
return !0;
|
|
4114
|
+
}
|
|
4115
|
+
}
|
|
4116
|
+
const _r = (n, e) => {
|
|
4117
|
+
var r;
|
|
4118
|
+
if (e.currentPath.toString() === ((r = e.propertyPath) == null ? void 0 : r.toString()))
|
|
4119
|
+
return x(n.innerType._def, e);
|
|
4120
|
+
const t = x(n.innerType._def, {
|
|
4121
|
+
...e,
|
|
4122
|
+
currentPath: [...e.currentPath, "anyOf", "1"]
|
|
4123
|
+
});
|
|
4124
|
+
return t ? {
|
|
4125
|
+
anyOf: [
|
|
4126
|
+
{
|
|
4127
|
+
not: M(e)
|
|
4128
|
+
},
|
|
4129
|
+
t
|
|
4130
|
+
]
|
|
4131
|
+
} : M(e);
|
|
4132
|
+
}, br = (n, e) => {
|
|
4133
|
+
if (e.pipeStrategy === "input")
|
|
4134
|
+
return x(n.in._def, e);
|
|
4135
|
+
if (e.pipeStrategy === "output")
|
|
4136
|
+
return x(n.out._def, e);
|
|
4137
|
+
const t = x(n.in._def, {
|
|
4138
|
+
...e,
|
|
4139
|
+
currentPath: [...e.currentPath, "allOf", "0"]
|
|
4140
|
+
}), r = x(n.out._def, {
|
|
4141
|
+
...e,
|
|
4142
|
+
currentPath: [...e.currentPath, "allOf", t ? "1" : "0"]
|
|
4143
|
+
});
|
|
4144
|
+
return {
|
|
4145
|
+
allOf: [t, r].filter((s) => s !== void 0)
|
|
4146
|
+
};
|
|
4147
|
+
};
|
|
4148
|
+
function kr(n, e) {
|
|
4149
|
+
return x(n.type._def, e);
|
|
4150
|
+
}
|
|
4151
|
+
function xr(n, e) {
|
|
4152
|
+
const r = {
|
|
4153
|
+
type: "array",
|
|
4154
|
+
uniqueItems: !0,
|
|
4155
|
+
items: x(n.valueType._def, {
|
|
4156
|
+
...e,
|
|
4157
|
+
currentPath: [...e.currentPath, "items"]
|
|
4158
|
+
})
|
|
4159
|
+
};
|
|
4160
|
+
return n.minSize && A(r, "minItems", n.minSize.value, n.minSize.message, e), n.maxSize && A(r, "maxItems", n.maxSize.value, n.maxSize.message, e), r;
|
|
4161
|
+
}
|
|
4162
|
+
function wr(n, e) {
|
|
4163
|
+
return n.rest ? {
|
|
4164
|
+
type: "array",
|
|
4165
|
+
minItems: n.items.length,
|
|
4166
|
+
items: n.items.map((t, r) => x(t._def, {
|
|
4167
|
+
...e,
|
|
4168
|
+
currentPath: [...e.currentPath, "items", `${r}`]
|
|
4169
|
+
})).reduce((t, r) => r === void 0 ? t : [...t, r], []),
|
|
4170
|
+
additionalItems: x(n.rest._def, {
|
|
4171
|
+
...e,
|
|
4172
|
+
currentPath: [...e.currentPath, "additionalItems"]
|
|
4173
|
+
})
|
|
4174
|
+
} : {
|
|
4175
|
+
type: "array",
|
|
4176
|
+
minItems: n.items.length,
|
|
4177
|
+
maxItems: n.items.length,
|
|
4178
|
+
items: n.items.map((t, r) => x(t._def, {
|
|
4179
|
+
...e,
|
|
4180
|
+
currentPath: [...e.currentPath, "items", `${r}`]
|
|
4181
|
+
})).reduce((t, r) => r === void 0 ? t : [...t, r], [])
|
|
4182
|
+
};
|
|
4183
|
+
}
|
|
4184
|
+
function Sr(n) {
|
|
4185
|
+
return {
|
|
4186
|
+
not: M(n)
|
|
4187
|
+
};
|
|
4188
|
+
}
|
|
4189
|
+
function Ar(n) {
|
|
4190
|
+
return M(n);
|
|
4191
|
+
}
|
|
4192
|
+
const Tr = (n, e) => x(n.innerType._def, e), Cr = (n, e, t) => {
|
|
4193
|
+
switch (e) {
|
|
4194
|
+
case l.ZodString:
|
|
4195
|
+
return Ht(n, t);
|
|
4196
|
+
case l.ZodNumber:
|
|
4197
|
+
return mr(n, t);
|
|
4198
|
+
case l.ZodObject:
|
|
4199
|
+
return yr(n, t);
|
|
4200
|
+
case l.ZodBigInt:
|
|
4201
|
+
return Kn(n, t);
|
|
4202
|
+
case l.ZodBoolean:
|
|
4203
|
+
return Xn();
|
|
4204
|
+
case l.ZodDate:
|
|
4205
|
+
return Jt(n, t);
|
|
4206
|
+
case l.ZodUndefined:
|
|
4207
|
+
return Sr(t);
|
|
4208
|
+
case l.ZodNull:
|
|
4209
|
+
return fr(t);
|
|
4210
|
+
case l.ZodArray:
|
|
4211
|
+
return Yn(n, t);
|
|
4212
|
+
case l.ZodUnion:
|
|
4213
|
+
case l.ZodDiscriminatedUnion:
|
|
4214
|
+
return hr(n, t);
|
|
4215
|
+
case l.ZodIntersection:
|
|
4216
|
+
return ar(n, t);
|
|
4217
|
+
case l.ZodTuple:
|
|
4218
|
+
return wr(n, t);
|
|
4219
|
+
case l.ZodRecord:
|
|
4220
|
+
return Gt(n, t);
|
|
4221
|
+
case l.ZodLiteral:
|
|
4222
|
+
return ir(n, t);
|
|
4223
|
+
case l.ZodEnum:
|
|
4224
|
+
return rr(n);
|
|
4225
|
+
case l.ZodNativeEnum:
|
|
4226
|
+
return dr(n);
|
|
4227
|
+
case l.ZodNullable:
|
|
4228
|
+
return pr(n, t);
|
|
4229
|
+
case l.ZodOptional:
|
|
4230
|
+
return _r(n, t);
|
|
4231
|
+
case l.ZodMap:
|
|
4232
|
+
return ur(n, t);
|
|
4233
|
+
case l.ZodSet:
|
|
4234
|
+
return xr(n, t);
|
|
4235
|
+
case l.ZodLazy:
|
|
4236
|
+
return () => n.getter()._def;
|
|
4237
|
+
case l.ZodPromise:
|
|
4238
|
+
return kr(n, t);
|
|
4239
|
+
case l.ZodNaN:
|
|
4240
|
+
case l.ZodNever:
|
|
4241
|
+
return lr(t);
|
|
4242
|
+
case l.ZodEffects:
|
|
4243
|
+
return nr(n, t);
|
|
4244
|
+
case l.ZodAny:
|
|
4245
|
+
return M(t);
|
|
4246
|
+
case l.ZodUnknown:
|
|
4247
|
+
return Ar(t);
|
|
4248
|
+
case l.ZodDefault:
|
|
4249
|
+
return tr(n, t);
|
|
4250
|
+
case l.ZodBranded:
|
|
4251
|
+
return qt(n, t);
|
|
4252
|
+
case l.ZodReadonly:
|
|
4253
|
+
return Tr(n, t);
|
|
4254
|
+
case l.ZodCatch:
|
|
4255
|
+
return Qn(n, t);
|
|
4256
|
+
case l.ZodPipeline:
|
|
4257
|
+
return br(n, t);
|
|
4258
|
+
case l.ZodFunction:
|
|
4259
|
+
case l.ZodVoid:
|
|
4260
|
+
case l.ZodSymbol:
|
|
4261
|
+
return;
|
|
4262
|
+
default:
|
|
4263
|
+
return /* @__PURE__ */ ((r) => {
|
|
4264
|
+
})();
|
|
4265
|
+
}
|
|
4266
|
+
};
|
|
4267
|
+
function x(n, e, t = !1) {
|
|
4268
|
+
var o;
|
|
4269
|
+
const r = e.seen.get(n);
|
|
4270
|
+
if (e.override) {
|
|
4271
|
+
const c = (o = e.override) == null ? void 0 : o.call(e, n, e, r, t);
|
|
4272
|
+
if (c !== Jn)
|
|
4273
|
+
return c;
|
|
4274
|
+
}
|
|
4275
|
+
if (r && !t) {
|
|
4276
|
+
const c = Or(r, e);
|
|
4277
|
+
if (c !== void 0)
|
|
4278
|
+
return c;
|
|
4279
|
+
}
|
|
4280
|
+
const s = { def: n, path: e.currentPath, jsonSchema: void 0 };
|
|
4281
|
+
e.seen.set(n, s);
|
|
4282
|
+
const a = Cr(n, n.typeName, e), i = typeof a == "function" ? x(a(), e) : a;
|
|
4283
|
+
if (i && Nr(n, e, i), e.postProcess) {
|
|
4284
|
+
const c = e.postProcess(i, n, e);
|
|
4285
|
+
return s.jsonSchema = i, c;
|
|
4286
|
+
}
|
|
4287
|
+
return s.jsonSchema = i, i;
|
|
4288
|
+
}
|
|
4289
|
+
const Or = (n, e) => {
|
|
4290
|
+
switch (e.$refStrategy) {
|
|
4291
|
+
case "root":
|
|
4292
|
+
return { $ref: n.path.join("/") };
|
|
4293
|
+
case "relative":
|
|
4294
|
+
return { $ref: Wt(e.currentPath, n.path) };
|
|
4295
|
+
case "none":
|
|
4296
|
+
case "seen":
|
|
4297
|
+
return n.path.length < e.currentPath.length && n.path.every((t, r) => e.currentPath[r] === t) ? (console.warn(`Recursive reference detected at ${e.currentPath.join("/")}! Defaulting to any`), M(e)) : e.$refStrategy === "seen" ? M(e) : void 0;
|
|
4298
|
+
}
|
|
4299
|
+
}, Nr = (n, e, t) => (n.description && (t.description = n.description, e.markdownDescription && (t.markdownDescription = n.description)), t), ze = (n, e) => {
|
|
4300
|
+
var c;
|
|
4301
|
+
const t = Gn(e);
|
|
4302
|
+
let r = typeof e == "object" && e.definitions ? Object.entries(e.definitions).reduce((u, [y, T]) => {
|
|
4303
|
+
var v;
|
|
4304
|
+
return {
|
|
4305
|
+
...u,
|
|
4306
|
+
[y]: (v = x(T._def, {
|
|
4307
|
+
...t,
|
|
4308
|
+
currentPath: [...t.basePath, t.definitionPath, y]
|
|
4309
|
+
}, !0)) != null ? v : M(t)
|
|
4310
|
+
};
|
|
4311
|
+
}, {}) : void 0;
|
|
4312
|
+
const s = typeof e == "string" ? e : (e == null ? void 0 : e.nameStrategy) === "title" || e == null ? void 0 : e.name, a = (c = x(n._def, s === void 0 ? t : {
|
|
4313
|
+
...t,
|
|
4314
|
+
currentPath: [...t.basePath, t.definitionPath, s]
|
|
4315
|
+
}, !1)) != null ? c : M(t), i = typeof e == "object" && e.name !== void 0 && e.nameStrategy === "title" ? e.name : void 0;
|
|
4316
|
+
i !== void 0 && (a.title = i), t.flags.hasReferencedOpenAiAnyType && (r || (r = {}), r[t.openAiAnyTypeName] || (r[t.openAiAnyTypeName] = {
|
|
4317
|
+
// Skipping "object" as no properties can be defined and additionalProperties must be "false"
|
|
4318
|
+
type: ["string", "number", "integer", "boolean", "array", "null"],
|
|
4319
|
+
items: {
|
|
4320
|
+
$ref: t.$refStrategy === "relative" ? "1" : [
|
|
4321
|
+
...t.basePath,
|
|
4322
|
+
t.definitionPath,
|
|
4323
|
+
t.openAiAnyTypeName
|
|
4324
|
+
].join("/")
|
|
4325
|
+
}
|
|
4326
|
+
}));
|
|
4327
|
+
const o = s === void 0 ? r ? {
|
|
4328
|
+
...a,
|
|
4329
|
+
[t.definitionPath]: r
|
|
4330
|
+
} : a : {
|
|
4331
|
+
$ref: [
|
|
4332
|
+
...t.$refStrategy === "relative" ? [] : t.basePath,
|
|
4333
|
+
t.definitionPath,
|
|
4334
|
+
s
|
|
4335
|
+
].join("/"),
|
|
4336
|
+
[t.definitionPath]: {
|
|
4337
|
+
...r,
|
|
4338
|
+
[s]: a
|
|
4339
|
+
}
|
|
4340
|
+
};
|
|
4341
|
+
return t.target === "jsonSchema7" ? o.$schema = "http://json-schema.org/draft-07/schema#" : (t.target === "jsonSchema2019-09" || t.target === "openAi") && (o.$schema = "https://json-schema.org/draft/2019-09/schema#"), t.target === "openAi" && ("anyOf" in o || "oneOf" in o || "allOf" in o || "type" in o && Array.isArray(o.type)) && console.warn("Warning: OpenAI may not support schemas with unions as roots! Try wrapping it in an object property."), o;
|
|
4342
|
+
};
|
|
4343
|
+
class Zr {
|
|
4344
|
+
/**
|
|
4345
|
+
* Creates a new message processor.
|
|
4346
|
+
*
|
|
4347
|
+
* @param catalogs A list of available catalogs.
|
|
4348
|
+
* @param actionHandler A global handler for actions from all surfaces.
|
|
4349
|
+
*/
|
|
4350
|
+
constructor(e, t) {
|
|
4351
|
+
this.catalogs = e, this.actionHandler = t, this.model = new qn(), this.actionHandler && this.model.onAction.subscribe(this.actionHandler);
|
|
4352
|
+
}
|
|
4353
|
+
/**
|
|
4354
|
+
* Generates the a2uiClientCapabilities object for the current processor.
|
|
4355
|
+
*
|
|
4356
|
+
* @param options Configuration for capability generation.
|
|
4357
|
+
* @returns The capabilities object.
|
|
4358
|
+
*/
|
|
4359
|
+
getClientCapabilities(e) {
|
|
4360
|
+
const t = {
|
|
4361
|
+
"v0.9": {
|
|
4362
|
+
supportedCatalogIds: this.catalogs.map((r) => r.id)
|
|
4363
|
+
}
|
|
4364
|
+
};
|
|
4365
|
+
return e != null && e.includeInlineCatalogs && (t["v0.9"].inlineCatalogs = this.catalogs.map((r) => this.generateInlineCatalog(r))), t;
|
|
4366
|
+
}
|
|
4367
|
+
generateInlineCatalog(e) {
|
|
4368
|
+
const t = {};
|
|
4369
|
+
for (const [a, i] of e.components.entries()) {
|
|
4370
|
+
const o = ze(i.schema, {
|
|
4371
|
+
target: "jsonSchema2019-09"
|
|
4372
|
+
});
|
|
4373
|
+
this.processRefs(o), t[a] = {
|
|
4374
|
+
allOf: [
|
|
4375
|
+
{ $ref: "common_types.json#/$defs/ComponentCommon" },
|
|
4376
|
+
{
|
|
4377
|
+
properties: {
|
|
4378
|
+
component: { const: a },
|
|
4379
|
+
...o.properties
|
|
4380
|
+
},
|
|
4381
|
+
required: ["component", ...o.required || []]
|
|
4382
|
+
}
|
|
4383
|
+
]
|
|
4384
|
+
};
|
|
4385
|
+
}
|
|
4386
|
+
const r = [];
|
|
4387
|
+
for (const a of e.functions.values()) {
|
|
4388
|
+
const i = ze(a.schema, {
|
|
4389
|
+
target: "jsonSchema2019-09"
|
|
4390
|
+
});
|
|
4391
|
+
this.processRefs(i), r.push({
|
|
4392
|
+
name: a.name,
|
|
4393
|
+
description: a.schema.description,
|
|
4394
|
+
returnType: a.returnType,
|
|
4395
|
+
parameters: i
|
|
4396
|
+
});
|
|
4397
|
+
}
|
|
4398
|
+
let s;
|
|
4399
|
+
if (e.themeSchema) {
|
|
4400
|
+
const a = ze(e.themeSchema, {
|
|
4401
|
+
target: "jsonSchema2019-09"
|
|
4402
|
+
});
|
|
4403
|
+
this.processRefs(a), s = a.properties;
|
|
4404
|
+
}
|
|
4405
|
+
return {
|
|
4406
|
+
catalogId: e.id,
|
|
4407
|
+
components: t,
|
|
4408
|
+
functions: r.length > 0 ? r : void 0,
|
|
4409
|
+
theme: s
|
|
4410
|
+
};
|
|
4411
|
+
}
|
|
4412
|
+
processRefs(e) {
|
|
4413
|
+
if (!(typeof e != "object" || e === null)) {
|
|
4414
|
+
if (typeof e.description == "string" && e.description.startsWith("REF:")) {
|
|
4415
|
+
const t = e.description.substring(4).split("|"), r = t[0], s = t[1] || "";
|
|
4416
|
+
for (const a of Object.keys(e))
|
|
4417
|
+
delete e[a];
|
|
4418
|
+
e.$ref = r, s && (e.description = s);
|
|
4419
|
+
return;
|
|
4420
|
+
}
|
|
4421
|
+
if (Array.isArray(e))
|
|
4422
|
+
for (const t of e)
|
|
4423
|
+
this.processRefs(t);
|
|
4424
|
+
else
|
|
4425
|
+
for (const t of Object.keys(e))
|
|
4426
|
+
this.processRefs(e[t]);
|
|
4427
|
+
}
|
|
4428
|
+
}
|
|
4429
|
+
/**
|
|
4430
|
+
* Returns the aggregated data model for all surfaces that have 'sendDataModel' enabled.
|
|
4431
|
+
*/
|
|
4432
|
+
getClientDataModel() {
|
|
4433
|
+
const e = {};
|
|
4434
|
+
for (const t of this.model.surfacesMap.values())
|
|
4435
|
+
t.sendDataModel && (e[t.id] = t.dataModel.get("/"));
|
|
4436
|
+
if (Object.keys(e).length !== 0)
|
|
4437
|
+
return {
|
|
4438
|
+
version: "v0.9",
|
|
4439
|
+
surfaces: e
|
|
4440
|
+
};
|
|
4441
|
+
}
|
|
4442
|
+
/**
|
|
4443
|
+
* Subscribes to surface creation events.
|
|
4444
|
+
*/
|
|
4445
|
+
onSurfaceCreated(e) {
|
|
4446
|
+
return this.model.onSurfaceCreated.subscribe(e);
|
|
4447
|
+
}
|
|
4448
|
+
/**
|
|
4449
|
+
* Subscribes to surface deletion events.
|
|
4450
|
+
*/
|
|
4451
|
+
onSurfaceDeleted(e) {
|
|
4452
|
+
return this.model.onSurfaceDeleted.subscribe(e);
|
|
4453
|
+
}
|
|
4454
|
+
/**
|
|
4455
|
+
* Processes a list of messages.
|
|
4456
|
+
*
|
|
4457
|
+
* @param messages The messages to process.
|
|
4458
|
+
*/
|
|
4459
|
+
processMessages(e) {
|
|
4460
|
+
for (const t of e)
|
|
4461
|
+
this.processMessage(t);
|
|
4462
|
+
}
|
|
4463
|
+
processMessage(e) {
|
|
4464
|
+
const t = [
|
|
4465
|
+
"createSurface",
|
|
4466
|
+
"updateComponents",
|
|
4467
|
+
"updateDataModel",
|
|
4468
|
+
"deleteSurface"
|
|
4469
|
+
].filter((r) => r in e);
|
|
4470
|
+
if (t.length > 1)
|
|
4471
|
+
throw new Re(`Message contains multiple update types: ${t.join(", ")}.`);
|
|
4472
|
+
if ("createSurface" in e) {
|
|
4473
|
+
this.processCreateSurfaceMessage(e);
|
|
4474
|
+
return;
|
|
4475
|
+
}
|
|
4476
|
+
if ("deleteSurface" in e) {
|
|
4477
|
+
this.processDeleteSurfaceMessage(e);
|
|
4478
|
+
return;
|
|
4479
|
+
}
|
|
4480
|
+
if ("updateComponents" in e) {
|
|
4481
|
+
this.processUpdateComponentsMessage(e);
|
|
4482
|
+
return;
|
|
4483
|
+
}
|
|
4484
|
+
if ("updateDataModel" in e) {
|
|
4485
|
+
this.processUpdateDataModelMessage(e);
|
|
4486
|
+
return;
|
|
4487
|
+
}
|
|
4488
|
+
}
|
|
4489
|
+
processCreateSurfaceMessage(e) {
|
|
4490
|
+
const t = e.createSurface, { surfaceId: r, catalogId: s, theme: a, sendDataModel: i } = t, o = this.catalogs.find((u) => u.id === s);
|
|
4491
|
+
if (!o)
|
|
4492
|
+
throw new he(`Catalog not found: ${s}`);
|
|
4493
|
+
if (this.model.getSurface(r))
|
|
4494
|
+
throw new he(`Surface ${r} already exists.`);
|
|
4495
|
+
const c = new Wn(r, o, a, i != null ? i : !1);
|
|
4496
|
+
this.model.addSurface(c);
|
|
4497
|
+
}
|
|
4498
|
+
processDeleteSurfaceMessage(e) {
|
|
4499
|
+
const t = e.deleteSurface;
|
|
4500
|
+
t.surfaceId && this.model.deleteSurface(t.surfaceId);
|
|
4501
|
+
}
|
|
4502
|
+
processUpdateComponentsMessage(e) {
|
|
4503
|
+
const t = e.updateComponents;
|
|
4504
|
+
if (!t.surfaceId)
|
|
4505
|
+
return;
|
|
4506
|
+
const r = this.model.getSurface(t.surfaceId);
|
|
4507
|
+
if (!r)
|
|
4508
|
+
throw new he(`Surface not found for message: ${t.surfaceId}`);
|
|
4509
|
+
for (const s of t.components) {
|
|
4510
|
+
const { id: a, component: i, ...o } = s;
|
|
4511
|
+
if (!a)
|
|
4512
|
+
throw new Re(`Component '${i}' is missing an 'id'.`);
|
|
4513
|
+
const c = r.componentsModel.get(a);
|
|
4514
|
+
if (c)
|
|
4515
|
+
if (i && i !== c.type) {
|
|
4516
|
+
r.componentsModel.removeComponent(a);
|
|
4517
|
+
const u = new xt(a, i, o);
|
|
4518
|
+
r.componentsModel.addComponent(u);
|
|
4519
|
+
} else
|
|
4520
|
+
c.properties = o;
|
|
4521
|
+
else {
|
|
4522
|
+
if (!i)
|
|
4523
|
+
throw new Re(`Cannot create component ${a} without a type.`);
|
|
4524
|
+
const u = new xt(a, i, o);
|
|
4525
|
+
r.componentsModel.addComponent(u);
|
|
4526
|
+
}
|
|
4527
|
+
}
|
|
4528
|
+
}
|
|
4529
|
+
processUpdateDataModelMessage(e) {
|
|
4530
|
+
const t = e.updateDataModel;
|
|
4531
|
+
if (!t.surfaceId)
|
|
4532
|
+
return;
|
|
4533
|
+
const r = this.model.getSurface(t.surfaceId);
|
|
4534
|
+
if (!r)
|
|
4535
|
+
throw new he(`Surface not found for message: ${t.surfaceId}`);
|
|
4536
|
+
const s = t.path || "/", a = t.value;
|
|
4537
|
+
r.dataModel.set(s, a);
|
|
4538
|
+
}
|
|
4539
|
+
/**
|
|
4540
|
+
* Resolves a relative path against a context path.
|
|
4541
|
+
*
|
|
4542
|
+
* @param path The path to resolve.
|
|
4543
|
+
* @param contextPath The base path (optional).
|
|
4544
|
+
*/
|
|
4545
|
+
resolvePath(e, t) {
|
|
4546
|
+
return e.startsWith("/") ? e : t ? `${t.endsWith("/") ? t : `${t}/`}${e}` : `/${e}`;
|
|
4547
|
+
}
|
|
4548
|
+
}
|
|
4549
|
+
function Pr(n) {
|
|
4550
|
+
const e = new Zr(n.catalogs, n.onAction), t = shallowRef(/* @__PURE__ */ new Map());
|
|
4551
|
+
let r = 0;
|
|
4552
|
+
function s(o) {
|
|
4553
|
+
if (o.length <= r)
|
|
4554
|
+
return;
|
|
4555
|
+
const c = o.slice(r);
|
|
4556
|
+
try {
|
|
4557
|
+
e.processMessages(c);
|
|
4558
|
+
} catch (u) {
|
|
4559
|
+
return;
|
|
4560
|
+
}
|
|
4561
|
+
r = o.length, t.value = new Map(e.model.surfacesMap);
|
|
4562
|
+
}
|
|
4563
|
+
function a() {
|
|
4564
|
+
e.model.dispose(), r = 0, t.value = /* @__PURE__ */ new Map();
|
|
4565
|
+
}
|
|
4566
|
+
function i() {
|
|
4567
|
+
e.model.dispose();
|
|
4568
|
+
}
|
|
4569
|
+
return onUnmounted(i), { processor: e, surfaces: t, processMessages: s, reset: a, dispose: i };
|
|
4570
|
+
}
|
|
4571
|
+
function jr(n) {
|
|
4572
|
+
switch (n) {
|
|
4573
|
+
case "string":
|
|
4574
|
+
return D();
|
|
4575
|
+
case "number":
|
|
4576
|
+
return _t();
|
|
4577
|
+
case "integer":
|
|
4578
|
+
return _t().int();
|
|
4579
|
+
case "boolean":
|
|
4580
|
+
return In();
|
|
4581
|
+
case "null":
|
|
4582
|
+
return Mn();
|
|
4583
|
+
case "array":
|
|
4584
|
+
return Et(ne());
|
|
4585
|
+
case "object":
|
|
4586
|
+
return ct(ne());
|
|
4587
|
+
default:
|
|
4588
|
+
return ne();
|
|
4589
|
+
}
|
|
4590
|
+
}
|
|
4591
|
+
function Ve(n, e) {
|
|
4592
|
+
let t = n;
|
|
4593
|
+
if (e.enum && e.enum.length > 0) {
|
|
4594
|
+
const r = e.enum.map((s) => Pe(s));
|
|
4595
|
+
return r.length === 1 ? r[0] : Ze([r[0], r[1], ...r.slice(2)]);
|
|
4596
|
+
}
|
|
4597
|
+
return e.type === "string" && (typeof e.minLength == "number" && (t = t.min(e.minLength)), typeof e.maxLength == "number" && (t = t.max(e.maxLength))), (e.type === "number" || e.type === "integer") && (typeof e.minimum == "number" && (t = t.min(e.minimum)), typeof e.maximum == "number" && (t = t.max(e.maximum))), Object.prototype.hasOwnProperty.call(e, "default") && (t = t.default(e.default)), t;
|
|
4598
|
+
}
|
|
4599
|
+
function pe(n) {
|
|
4600
|
+
var r, s;
|
|
4601
|
+
if (!n)
|
|
4602
|
+
return ne();
|
|
4603
|
+
const e = n.type;
|
|
4604
|
+
if (Array.isArray(e) && e.length > 0) {
|
|
4605
|
+
const i = Array.from(new Set(e)).map((o) => pe({ ...n, type: o }));
|
|
4606
|
+
return i.length === 1 ? i[0] : Ze(i);
|
|
4607
|
+
}
|
|
4608
|
+
if (e === "array") {
|
|
4609
|
+
const a = pe(n.items);
|
|
4610
|
+
return Ve(Et(a), n);
|
|
4611
|
+
}
|
|
4612
|
+
if (e === "object" || n.properties) {
|
|
4613
|
+
const a = new Set((r = n.required) != null ? r : []), i = Object.entries((s = n.properties) != null ? s : {}).reduce((c, [u, y]) => {
|
|
4614
|
+
const T = pe(y);
|
|
4615
|
+
return c[u] = a.has(u) ? T : T.optional(), c;
|
|
4616
|
+
}, {});
|
|
4617
|
+
let o = B(i);
|
|
4618
|
+
return n.additionalProperties === !0 ? o = o.catchall(ne()) : n.additionalProperties && typeof n.additionalProperties == "object" && (o = o.catchall(pe(n.additionalProperties))), Ve(o, n);
|
|
4619
|
+
}
|
|
4620
|
+
return Ve(jr(typeof e == "string" ? e : "object"), n);
|
|
4621
|
+
}
|
|
4622
|
+
function Ir(n, e) {
|
|
4623
|
+
var r;
|
|
4624
|
+
const t = pe({
|
|
4625
|
+
type: (r = e.type) != null ? r : "object",
|
|
4626
|
+
properties: e.properties,
|
|
4627
|
+
required: e.required,
|
|
4628
|
+
additionalProperties: e.additionalProperties
|
|
4629
|
+
});
|
|
4630
|
+
return {
|
|
4631
|
+
name: n,
|
|
4632
|
+
schema: t
|
|
4633
|
+
};
|
|
4634
|
+
}
|
|
4635
|
+
function Mr(n) {
|
|
4636
|
+
const e = Object.entries(n.components).map(([t, r]) => Ir(t, r));
|
|
4637
|
+
return new En(n.catalogId, e);
|
|
4638
|
+
}
|
|
4639
|
+
const Er = /* @__PURE__ */ defineComponent({
|
|
4640
|
+
__name: "ComponentNode",
|
|
4641
|
+
props: {
|
|
4642
|
+
componentModel: {},
|
|
4643
|
+
surface: {},
|
|
4644
|
+
components: {},
|
|
4645
|
+
componentEvents: {},
|
|
4646
|
+
componentPropAllowlist: {}
|
|
4647
|
+
},
|
|
4648
|
+
setup(n) {
|
|
4649
|
+
const e = n, t = computed(() => {
|
|
4650
|
+
const v = e.components[e.componentModel.type];
|
|
4651
|
+
return v != null ? v : e.componentModel.type;
|
|
4652
|
+
}), r = shallowRef({});
|
|
4653
|
+
let s = [];
|
|
4654
|
+
function a() {
|
|
4655
|
+
s.forEach((v) => v.unsubscribe()), s = [];
|
|
4656
|
+
}
|
|
4657
|
+
function i(v, w) {
|
|
4658
|
+
if (w && typeof w == "object" && !Array.isArray(w) && "path" in w) {
|
|
4659
|
+
const I = w.path, m = w.default;
|
|
4660
|
+
if (typeof I == "string") {
|
|
4661
|
+
const O = I.startsWith("/") ? I : `/${I}`, N = e.surface.dataModel.subscribe(O, (U) => {
|
|
4662
|
+
r.value = {
|
|
4663
|
+
...r.value,
|
|
4664
|
+
[v]: U === void 0 ? m : U
|
|
4665
|
+
};
|
|
4666
|
+
});
|
|
4667
|
+
return s.push(N), N.value === void 0 ? m : N.value;
|
|
4668
|
+
}
|
|
4669
|
+
}
|
|
4670
|
+
return w;
|
|
4671
|
+
}
|
|
4672
|
+
function o() {
|
|
4673
|
+
a();
|
|
4674
|
+
const v = { ...e.componentModel.properties };
|
|
4675
|
+
delete v.children;
|
|
4676
|
+
const w = e.componentPropAllowlist[e.componentModel.type], I = w && w.length > 0 ? new Set(w) : void 0, m = I ? Object.fromEntries(Object.entries(v).filter(([N]) => I.has(N))) : v, O = Object.fromEntries(Object.entries(m).map(([N, U]) => [N, i(N, U)]));
|
|
4677
|
+
r.value = O;
|
|
4678
|
+
}
|
|
4679
|
+
let c;
|
|
4680
|
+
onMounted(() => {
|
|
4681
|
+
o(), c = e.componentModel.onUpdated.subscribe(() => {
|
|
4682
|
+
o();
|
|
4683
|
+
}).unsubscribe;
|
|
4684
|
+
}), onUnmounted(() => {
|
|
4685
|
+
c == null || c(), a();
|
|
4686
|
+
});
|
|
4687
|
+
const u = computed(() => {
|
|
4688
|
+
var w;
|
|
4689
|
+
const v = (w = e.componentModel.properties) == null ? void 0 : w.children;
|
|
4690
|
+
return v ? Array.isArray(v) ? v : typeof v == "string" ? [v] : [] : [];
|
|
4691
|
+
});
|
|
4692
|
+
function y(v) {
|
|
4693
|
+
return e.surface.componentsModel.get(v);
|
|
4694
|
+
}
|
|
4695
|
+
const T = computed(() => {
|
|
4696
|
+
var I;
|
|
4697
|
+
const v = {}, w = (I = e.componentEvents[e.componentModel.type]) != null ? I : [];
|
|
4698
|
+
for (const m of w)
|
|
4699
|
+
v[m] = (...O) => {
|
|
4700
|
+
e.surface.dispatchAction(
|
|
4701
|
+
{
|
|
4702
|
+
event: {
|
|
4703
|
+
name: m,
|
|
4704
|
+
context: {
|
|
4705
|
+
...r.value,
|
|
4706
|
+
value: O[0],
|
|
4707
|
+
args: O
|
|
4708
|
+
}
|
|
4709
|
+
}
|
|
4710
|
+
},
|
|
4711
|
+
e.componentModel.id
|
|
4712
|
+
);
|
|
4713
|
+
};
|
|
4714
|
+
return v;
|
|
4715
|
+
});
|
|
4716
|
+
return (v, w) => {
|
|
4717
|
+
const I = resolveComponent("ComponentNode", !0);
|
|
4718
|
+
return t.value ? (openBlock(), createBlock(resolveDynamicComponent(t.value), mergeProps({ key: 0 }, r.value, toHandlers(T.value)), {
|
|
4719
|
+
default: withCtx(() => [
|
|
4720
|
+
(openBlock(!0), createElementBlock(Fragment, null, renderList(u.value, (m) => (openBlock(), createBlock(I, {
|
|
4721
|
+
key: m,
|
|
4722
|
+
"component-model": y(m),
|
|
4723
|
+
surface: v.surface,
|
|
4724
|
+
components: v.components,
|
|
4725
|
+
"component-events": v.componentEvents,
|
|
4726
|
+
"component-prop-allowlist": v.componentPropAllowlist
|
|
4727
|
+
}, null, 8, ["component-model", "surface", "components", "component-events", "component-prop-allowlist"]))), 128))
|
|
4728
|
+
]),
|
|
4729
|
+
_: 1
|
|
4730
|
+
}, 16)) : createCommentVNode("", !0);
|
|
4731
|
+
};
|
|
4732
|
+
}
|
|
4733
|
+
}), Rr = /* @__PURE__ */ defineComponent({
|
|
4734
|
+
__name: "A2UISurface",
|
|
4735
|
+
props: {
|
|
4736
|
+
messages: {},
|
|
4737
|
+
surfaceId: {},
|
|
4738
|
+
components: { default: () => ({}) },
|
|
4739
|
+
catalog: { default: () => ({
|
|
4740
|
+
catalogId: "touchvue-a2ui-default",
|
|
4741
|
+
components: {}
|
|
4742
|
+
}) }
|
|
4743
|
+
},
|
|
4744
|
+
emits: ["action"],
|
|
4745
|
+
setup(n, { emit: e }) {
|
|
4746
|
+
const t = n;
|
|
4747
|
+
function r(m, O) {
|
|
4748
|
+
var ee, _e, X, Me, be, dt, lt, ft, ht, pt;
|
|
4749
|
+
const N = (Me = (X = (ee = m == null ? void 0 : m.name) != null ? ee : m == null ? void 0 : m.action) != null ? X : (_e = m == null ? void 0 : m.event) == null ? void 0 : _e.name) != null ? Me : "unknown", U = (lt = (dt = (be = m == null ? void 0 : m.sourceComponentId) != null ? be : m == null ? void 0 : m.componentId) != null ? dt : m == null ? void 0 : m.targetComponentId) != null ? lt : "", ve = (pt = (ht = m == null ? void 0 : m.context) != null ? ht : (ft = m == null ? void 0 : m.event) == null ? void 0 : ft.context) != null ? pt : {};
|
|
4750
|
+
return {
|
|
4751
|
+
name: N,
|
|
4752
|
+
surfaceId: O,
|
|
4753
|
+
sourceComponentId: U,
|
|
4754
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
4755
|
+
context: ve
|
|
4756
|
+
};
|
|
4757
|
+
}
|
|
4758
|
+
const s = e, a = computed(() => Mr(t.catalog)), i = computed(() => {
|
|
4759
|
+
const m = {};
|
|
4760
|
+
for (const [O, N] of Object.entries(t.catalog.components))
|
|
4761
|
+
m[O] = c(N.events);
|
|
4762
|
+
return console.log(m), m;
|
|
4763
|
+
}), o = computed(() => {
|
|
4764
|
+
var O;
|
|
4765
|
+
const m = {};
|
|
4766
|
+
for (const [N, U] of Object.entries(t.catalog.components))
|
|
4767
|
+
m[N] = Object.keys((O = U.properties) != null ? O : {});
|
|
4768
|
+
return m;
|
|
4769
|
+
});
|
|
4770
|
+
function c(m) {
|
|
4771
|
+
return m ? Array.isArray(m) ? m : Object.keys(m) : [];
|
|
4772
|
+
}
|
|
4773
|
+
const { surfaces: u, processMessages: y } = Pr({
|
|
4774
|
+
catalogs: [a.value],
|
|
4775
|
+
onAction: (m) => {
|
|
4776
|
+
s("action", r(m, t.surfaceId));
|
|
4777
|
+
}
|
|
4778
|
+
}), T = ref(0);
|
|
4779
|
+
watch(
|
|
4780
|
+
() => t.messages.length,
|
|
4781
|
+
() => {
|
|
4782
|
+
y(t.messages), T.value++;
|
|
4783
|
+
},
|
|
4784
|
+
{ immediate: !0 }
|
|
4785
|
+
);
|
|
4786
|
+
const v = computed(() => u.value.get(t.surfaceId)), w = computed(() => {
|
|
4787
|
+
var ve;
|
|
4788
|
+
T.value;
|
|
4789
|
+
const m = v.value;
|
|
4790
|
+
if (!m)
|
|
4791
|
+
return [];
|
|
4792
|
+
const O = /* @__PURE__ */ new Set(), N = /* @__PURE__ */ new Set();
|
|
4793
|
+
for (const [ee, _e] of m.componentsModel.entries) {
|
|
4794
|
+
O.add(ee);
|
|
4795
|
+
const X = (ve = _e.properties) == null ? void 0 : ve.children;
|
|
4796
|
+
X && (Array.isArray(X) ? X : [X]).forEach((be) => N.add(be));
|
|
4797
|
+
}
|
|
4798
|
+
return Array.from(O).filter((ee) => !N.has(ee));
|
|
4799
|
+
});
|
|
4800
|
+
function I(m) {
|
|
4801
|
+
var O;
|
|
4802
|
+
return (O = v.value) == null ? void 0 : O.componentsModel.get(m);
|
|
4803
|
+
}
|
|
4804
|
+
return (m, O) => (openBlock(!0), createElementBlock(Fragment, null, renderList(w.value, (N) => (openBlock(), createBlock(Er, {
|
|
4805
|
+
key: N,
|
|
4806
|
+
"component-model": I(N),
|
|
4807
|
+
surface: v.value,
|
|
4808
|
+
components: t.components,
|
|
4809
|
+
"component-events": i.value,
|
|
4810
|
+
"component-prop-allowlist": o.value
|
|
4811
|
+
}, null, 8, ["component-model", "surface", "components", "component-events", "component-prop-allowlist"]))), 128));
|
|
4812
|
+
}
|
|
4813
|
+
});
|
|
4814
|
+
|
|
4815
|
+
export { Rr as TouchA2ui, Pr as useA2UI };
|
|
4816
|
+
//# sourceMappingURL=index.mjs.map
|